├── .browserslistrc ├── .dockerignore ├── .eslintrc.js ├── .github ├── dependabot.yml ├── release-drafter.yml ├── shell │ ├── build_and_update_cdn.sh │ └── copy.sh └── workflows │ ├── ci.yml │ ├── codeql-analysis.yml │ ├── main.yml │ ├── release-drafter.yml │ └── upload-to-release.yml ├── .gitignore ├── DEPLOY.md ├── Dockerfile ├── LICENSE ├── README.md ├── babel.config.js ├── e2e_test ├── README.md ├── __init__.py ├── driver.py ├── mock.py ├── proxy.py └── requirements.txt ├── init.sh ├── lang-list.json ├── package-lock.json ├── package.json ├── postcss.config.js ├── public ├── conf.d │ ├── docker.conf │ └── nginx.conf ├── favicon.ico ├── img │ ├── aliyun.svg │ ├── sponsor.png │ ├── touch-icon-ipad-retina.png │ ├── touch-icon-ipad.png │ ├── touch-icon-iphone-retina.png │ └── touch-icon-iphone.png ├── index.html └── usr │ ├── config.example.json │ └── usr.js ├── src ├── App.vue ├── assets │ ├── css │ │ ├── github-gist.css │ │ ├── global.css │ │ └── highlightjs-line-numbers.css │ ├── js │ │ ├── api.js │ │ ├── event │ │ │ └── directive-register.js │ │ ├── external │ │ │ ├── markdown-it-links.js │ │ │ ├── markdown-it-mermaid.js │ │ │ ├── markdown-it-table-contents.js │ │ │ └── markdown-it.js │ │ ├── getters.js │ │ ├── highlightjs-line-numbers.js │ │ ├── i18n.js │ │ ├── mixins │ │ │ └── stateMixin.js │ │ ├── router.js │ │ └── store.js │ └── lang │ │ ├── en.js │ │ └── zh-CN.js ├── components │ ├── Footer.vue │ ├── Form.vue │ ├── Header.vue │ ├── Loading.vue │ ├── ManualDeleted.vue │ ├── PasswordAuth.vue │ ├── PasteView.vue │ ├── Success.vue │ └── icons │ │ ├── Bell.vue │ │ └── GlobalAsia.vue ├── main.js └── views │ ├── Home.vue │ ├── NotFound.vue │ └── View.vue ├── tests.py └── vue.config.js /.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | src 3 | .git 4 | .idea 5 | .github -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true 5 | }, 6 | 'extends': [ 7 | 'plugin:vue/essential', 8 | 'eslint:recommended' 9 | ], 10 | rules: { 11 | 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', 12 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' 13 | }, 14 | parserOptions: { 15 | parser: 'babel-eslint' 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | target-branch: dev 9 | ignore: 10 | - dependency-name: core-js 11 | versions: 12 | - 3.10.0 13 | - 3.10.1 14 | - 3.10.2 15 | - 3.8.3 16 | - 3.9.0 17 | - 3.9.1 18 | - dependency-name: webpack-bundle-analyzer 19 | versions: 20 | - 4.4.0 21 | - dependency-name: mermaid 22 | versions: 23 | - 8.9.0 24 | - 8.9.1 25 | - 8.9.2 26 | - dependency-name: "@vue/cli-service" 27 | versions: 28 | - 4.5.11 29 | - dependency-name: babel-eslint 30 | versions: 31 | - 10.1.0 32 | - dependency-name: css-loader 33 | versions: 34 | - 5.0.1 35 | - 5.0.2 36 | - 5.1.0 37 | - 5.1.1 38 | - 5.1.2 39 | - dependency-name: clipboard 40 | versions: 41 | - 2.0.6 42 | - 2.0.7 43 | - dependency-name: markdown-it-anchor 44 | versions: 45 | - 7.0.0 46 | - 7.0.1 47 | - 7.0.2 48 | - dependency-name: lodash 49 | versions: 50 | - 4.17.20 51 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name-template: '$RESOLVED_VERSION' 2 | tag-template: '$RESOLVED_VERSION' 3 | categories: 4 | - title: 'Features' 5 | labels: 6 | - 'feature' 7 | - 'enhancement' 8 | - title: 'Bug Fixes' 9 | labels: 10 | - 'fix' 11 | - 'bugfix' 12 | - 'bug' 13 | - title: 'Maintenance' 14 | labels: 15 | - 'chore' 16 | - 'documentation' 17 | - title: 'Dependencies' 18 | labels: 19 | - 'dependencies' 20 | change-template: '- $TITLE (#$NUMBER) @$AUTHOR' 21 | version-resolver: 22 | major: 23 | labels: 24 | - 'major' 25 | minor: 26 | labels: 27 | - 'minor' 28 | patch: 29 | labels: 30 | - 'patch' 31 | default: patch 32 | template: | 33 | # Changes 34 | 35 | $CHANGES -------------------------------------------------------------------------------- /.github/shell/build_and_update_cdn.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | rm -rf .git && \ 3 | git clone https://github.com/PasteUs/CDN.git -b master pasteme_cdn && \ 4 | npm ci && \ 5 | npm run build --if-present && \ 6 | bash -x .github/shell/copy.sh && \ 7 | cd pasteme_cdn && \ 8 | git config user.name "Lucien Shui" && \ 9 | git config user.email "lucien@lucien.ink" && \ 10 | git add --all && \ 11 | set +x && \ 12 | git diff-index --quiet HEAD || (git commit -m "Pushed by github action $(TZ=UTC-8 date +'%Y-%m-%d %H:%M:%S')" && \ 13 | git push https://"${GH_TOKEN}"@github.com/PasteUs/CDN.git master) && \ 14 | set -x && \ 15 | cd .. 16 | -------------------------------------------------------------------------------- /.github/shell/copy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | for each in css js img 3 | do 4 | eval "cp pasteme/${each}/* pasteme_cdn/pasteme/${each}/" 5 | done 6 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [pull_request] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | strategy: 11 | matrix: 12 | node_version: [12.x] 13 | action: [test, run lint] 14 | 15 | name: npm ${{ matrix.action }} 16 | 17 | steps: 18 | - uses: actions/checkout@v1 19 | - name: use Node.js ${{ matrix.node_version }} ${{ matrix.action }} 20 | uses: actions/setup-node@v1 21 | with: 22 | node_version: ${{ matrix.node_version }} 23 | 24 | - name: npm install, build, and ${{ matrix.action }} 25 | run: | 26 | npm ci 27 | npm run build --if-present 28 | npm ${{ matrix.action }} 29 | env: 30 | CI: true 31 | 32 | e2e_unittest: 33 | 34 | runs-on: ubuntu-latest 35 | 36 | strategy: 37 | matrix: 38 | node_version: [12.x] 39 | 40 | name: E2E Testing 41 | 42 | steps: 43 | - uses: actions/checkout@v1 44 | - name: use Node.js ${{ matrix.node_version }} 45 | uses: actions/setup-node@v1 46 | with: 47 | node_version: ${{ matrix.node_version }} 48 | 49 | - name: npm install 50 | run: | 51 | npm ci 52 | cp public/usr/config.example.json public/usr/config.json 53 | env: 54 | CI: true 55 | 56 | - name: pip install 57 | run: | 58 | pip3 install -r e2e_test/requirements.txt 59 | 60 | - name: python unittest 61 | run: | 62 | python3 -m unittest tests.PasteMeEndToEndUnitTest 63 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ main ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ main ] 20 | schedule: 21 | - cron: '21 6 * * 2' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'javascript', 'python' ] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 37 | # Learn more: 38 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 39 | 40 | steps: 41 | - name: Checkout repository 42 | uses: actions/checkout@v2 43 | 44 | # Initializes the CodeQL tools for scanning. 45 | - name: Initialize CodeQL 46 | uses: github/codeql-action/init@v1 47 | with: 48 | languages: ${{ matrix.language }} 49 | # If you wish to specify custom queries, you can do so here or in a config file. 50 | # By default, queries listed here will override any specified in a config file. 51 | # Prefix the list here with "+" to use these queries and those in the config file. 52 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 53 | 54 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 55 | # If this step fails, then you should remove it and run the build manually (see below) 56 | - name: Autobuild 57 | uses: github/codeql-action/autobuild@v1 58 | 59 | # ℹ️ Command-line programs to run using the OS shell. 60 | # 📚 https://git.io/JvXDl 61 | 62 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 63 | # and modify them (or add more) to build your code if your project 64 | # uses a compiled language 65 | 66 | #- run: | 67 | # make bootstrap 68 | # make release 69 | 70 | - name: Perform CodeQL Analysis 71 | uses: github/codeql-action/analyze@v1 72 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Publish beta to docker registry 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | 10 | release: 11 | strategy: 12 | matrix: 13 | node_version: [12.x] 14 | os: [ubuntu-latest] 15 | 16 | if: github.repository == 'PasteUs/PasteMeFrontend' 17 | name: Build with node ${{ matrix.node_version }} on ${{ matrix.os }} and upload 18 | runs-on: ${{ matrix.os }} 19 | 20 | steps: 21 | - uses: actions/checkout@v1 22 | - name: use Node.js ${{ matrix.node_version }} 23 | uses: actions/setup-node@v1 24 | with: 25 | node_version: ${{ matrix.node_version }} 26 | 27 | - name: build and update cdn 28 | run: | 29 | GH_TOKEN=${{ secrets.PRIVATE_TOKEN }} bash .github/shell/build_and_update_cdn.sh 30 | 31 | - name: Set up QEMU 32 | uses: docker/setup-qemu-action@v1 33 | 34 | - name: Set up Docker Buildx 35 | uses: docker/setup-buildx-action@v1 36 | 37 | - name: Login to DockerHub 38 | uses: docker/login-action@v1 39 | with: 40 | username: ${{ secrets.DOCKERHUB_USERNAME }} 41 | password: ${{ secrets.DOCKERHUB_TOKEN }} 42 | 43 | - name: Login to Aliyun Docker Registry 44 | uses: docker/login-action@v1 45 | with: 46 | registry: registry.cn-hangzhou.aliyuncs.com 47 | username: ${{ secrets.ALIYUN_DOCKER_REGISTRY_USERNAME }} 48 | password: ${{ secrets.ALIYUN_DOCKER_REGISTRY_TOKEN }} 49 | 50 | - name: Build and push 51 | id: docker_build 52 | uses: docker/build-push-action@v2 53 | with: 54 | context: . 55 | platforms: | 56 | linux/amd64 57 | linux/arm64 58 | linux/arm/v7 59 | linux/arm/v6 60 | linux/386 61 | push: true 62 | tags: | 63 | pasteme/frontend:beta 64 | registry.cn-hangzhou.aliyuncs.com/pasteus/pasteme-frontend:beta 65 | 66 | - name: Image digest 67 | run: echo ${{ steps.docker_build.outputs.digest }} 68 | 69 | - name: Trigger Webhook 70 | run: | 71 | curl -X POST "${{ secrets.BETA_WEBHOOK }}frontend" 72 | -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | draft_release: 10 | if: github.repository == 'PasteUs/PasteMeFrontend' 11 | name: Draft release 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: release-drafter/release-drafter@v5 15 | name: Draft 16 | with: 17 | config-name: release-drafter.yml 18 | env: 19 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 20 | -------------------------------------------------------------------------------- /.github/workflows/upload-to-release.yml: -------------------------------------------------------------------------------- 1 | name: Upload to release and publish 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | 9 | release: 10 | strategy: 11 | matrix: 12 | node_version: [12.x] 13 | os: [ubuntu-latest] 14 | 15 | if: github.repository == 'PasteUs/PasteMeFrontend' 16 | name: Build with node ${{ matrix.node_version }} on ${{ matrix.os }} and upload 17 | runs-on: ${{ matrix.os }} 18 | 19 | steps: 20 | - uses: actions/checkout@v1 21 | - name: use Node.js ${{ matrix.node_version }} 22 | uses: actions/setup-node@v1 23 | with: 24 | node_version: ${{ matrix.node_version }} 25 | 26 | - name: build and update cdn 27 | run: | 28 | GH_TOKEN=${{ secrets.PRIVATE_TOKEN }} bash .github/shell/build_and_update_cdn.sh 29 | 30 | - name: Release Version 31 | id: release_version 32 | run: | 33 | echo ::set-output name=tag::$(echo "${GITHUB_REF}" | sed -e "s/refs\/tags\///g") 34 | 35 | - name: gzip 36 | run: | 37 | tar -czvf pasteme-${{ steps.release_version.outputs.tag }}-frontend.tar.gz pasteme 38 | 39 | - name: Upload to release 40 | uses: JasonEtco/upload-to-release@master 41 | with: 42 | args: pasteme-${{ steps.release_version.outputs.tag }}-frontend.tar.gz application/octet-stream 43 | env: 44 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 45 | 46 | - name: Set up QEMU 47 | uses: docker/setup-qemu-action@v1 48 | 49 | - name: Set up Docker Buildx 50 | uses: docker/setup-buildx-action@v1 51 | 52 | - name: Login to DockerHub 53 | uses: docker/login-action@v1 54 | with: 55 | username: ${{ secrets.DOCKERHUB_USERNAME }} 56 | password: ${{ secrets.DOCKERHUB_TOKEN }} 57 | 58 | - name: Login to Aliyun Docker Registry 59 | uses: docker/login-action@v1 60 | with: 61 | registry: registry.cn-hangzhou.aliyuncs.com 62 | username: ${{ secrets.ALIYUN_DOCKER_REGISTRY_USERNAME }} 63 | password: ${{ secrets.ALIYUN_DOCKER_REGISTRY_TOKEN }} 64 | 65 | - name: Build and push 66 | id: docker_build 67 | uses: docker/build-push-action@v2 68 | with: 69 | context: . 70 | platforms: | 71 | linux/amd64 72 | linux/arm64 73 | linux/arm/v7 74 | linux/arm/v6 75 | linux/386 76 | push: true 77 | tags: | 78 | pasteme/frontend:latest 79 | pasteme/frontend:${{ steps.release_version.outputs.tag }} 80 | registry.cn-hangzhou.aliyuncs.com/pasteus/pasteme-frontend:latest 81 | registry.cn-hangzhou.aliyuncs.com/pasteus/pasteme-frontend:${{ steps.release_version.outputs.tag }} 82 | 83 | - name: Image digest 84 | run: echo ${{ steps.docker_build.outputs.digest }} 85 | 86 | - name: Trigger Webhook 87 | run: | 88 | curl -X POST "${{ secrets.RELEASE_WEBHOOK }}frontend" 89 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | config.json 2 | .DS_Store 3 | node_modules 4 | /pasteme 5 | /dist 6 | 7 | # local env files 8 | .env.local 9 | .env.*.local 10 | 11 | # Log files 12 | npm-debug.log* 13 | yarn-debug.log* 14 | yarn-error.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | 25 | # python 26 | __pycache__ 27 | *.ipynb 28 | 29 | # tar 30 | *.tar.gz -------------------------------------------------------------------------------- /DEPLOY.md: -------------------------------------------------------------------------------- 1 | # Deployment 2 | 3 | 1. Download and unzip `pasteme.tar.gz` from [release](https://github.com/PasteUs/PasteMeFrontend/releases/latest) 4 | 2. Edit `usr/config.json` 5 | 6 | ## 1. usr/config.json 7 | 8 | | Name | Value | Description | Example | 9 | | :---: | :---: | --- | --- | 10 | | api.backend | URL | Backend's address | `/api/` | 11 | | api.admin | URL | Admin's address | `` | 12 | | footer | JSON Array | Custom frontend footer's link | `[]` | 13 | | footer.url | URL | Link's URL | `http://blog.lucien.ink/go/csdn` | 14 | | footer.text | Text | Link's text | `CSDN` | 15 | 16 | ### 1.1 Example 17 | 18 | > usr/config.example.json 19 | 20 | ```json 21 | { 22 | "api": { 23 | "backend": "/api/v3/", 24 | "admin": "" 25 | }, 26 | "footer": [ 27 | { 28 | "url": "http://blog.lucien.ink/go/csdn", 29 | "text": "CSDN" 30 | }, 31 | { 32 | "url": "http://www.miitbeian.gov.cn/", 33 | "text": "鲁ICP备18007563号" 34 | } 35 | ] 36 | } 37 | ``` 38 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:1.18-alpine 2 | LABEL maintainer="Lucien Shui" \ 3 | email="lucien@lucien.ink" 4 | 5 | ENV TZ=Asia/Shanghai 6 | COPY init.sh /temp 7 | RUN cat /docker-entrypoint.sh >> /temp && \ 8 | mv /temp /docker-entrypoint.sh && \ 9 | chmod +x /docker-entrypoint.sh 10 | 11 | COPY public/conf.d/docker.conf pasteme/index.html pasteme/usr pasteme/favicon.ico /pasteme_tmp/ 12 | RUN mv /pasteme_tmp/docker.conf /etc/nginx/conf.d/default.conf && \ 13 | mkdir -p /www/pasteme/usr && \ 14 | mv /pasteme_tmp/index.html /pasteme_tmp/favicon.ico /www/pasteme/ && \ 15 | mv /pasteme_tmp/config.example.json /config.example.json && \ 16 | rm -rf /pasteme_tmp 17 | EXPOSE 8080 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PasteMe Frontend 2 | 3 | [![CI](https://github.com/PasteUs/PasteMeFrontend/actions/workflows/ci.yml/badge.svg)](https://github.com/PasteUs/PasteMeFrontend/actions/workflows/ci.yml) 4 | [![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/PasteUs/PasteMeFrontend?color=white&label=latest&sort=semver)](https://github.com/PasteUs/PasteMeFrontend/releases) 5 | [![Docker Image Version (latest semver)](https://img.shields.io/docker/v/pasteme/frontend?label=Docker%20Hub&sort=semver)](https://hub.docker.com/r/pasteme/frontend) 6 | 7 | > From version 3.3.0, PasteMe Frontend uses hash router instead of history router, and is incompatible with PasteMe Go Backend version before 3.4.0 8 | 9 | Using Vue 2 and Bootstrap-Vue. 10 | 11 | ## Project setup 12 | 13 | ```bash 14 | npm install 15 | cp public/usr/config.example.json public/usr/config.json 16 | ``` 17 | 18 | ### Compiles and hot-reloads for development 19 | 20 | ```bash 21 | npm run serve 22 | ``` 23 | 24 | ### Compiles and minifies for production 25 | 26 | ```bash 27 | npm run build 28 | ``` 29 | 30 | ### Run your tests 31 | 32 | ```bash 33 | npm run test 34 | ``` 35 | 36 | ### Lints and fixes files 37 | 38 | ```bash 39 | npm run lint 40 | ``` 41 | 42 | ### Customize configuration 43 | 44 | See [Configuration Reference](https://cli.vuejs.org/config/). 45 | 46 | ## Deployment 47 | 48 | [Deploy Document](./DEPLOY.md) 49 | 50 | ## Non-unit testing 51 | 52 | 1. Create & access permanent paste 53 | 2. Create & access temporary paste 54 | 3. Create temporary with custom paste key 55 | 4. Create & access permanent paste with password 56 | 57 | ## Browsers support 58 | 59 | Modern browsers and Internet Explorer 10+. 60 | 61 | | [IE / Edge](https://godban.github.io/browsers-support-badges/)
IE / Edge | [Firefox](https://godban.github.io/browsers-support-badges/)
Firefox | [Chrome](https://godban.github.io/browsers-support-badges/)
Chrome | [Safari](https://godban.github.io/browsers-support-badges/)
Safari | 62 | | --------- | --------- | --------- | --------- | 63 | | IE10, IE11, Edge| last 2 versions| last 2 versions| last 2 versions | 64 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/app' 4 | ] 5 | }; 6 | -------------------------------------------------------------------------------- /e2e_test/README.md: -------------------------------------------------------------------------------- 1 | # PasteMe 端到端测试 2 | 3 | 使用 `Python` 的 `selenium` + `unittest` 作为测试的载体 4 | 5 | `GitHub Actions` 的镜像内置 `Chrome` 和 `chromedriver`,详见文档 [Ubuntu 18.04.5 LTS](https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu1804-README.md) 6 | 7 | ## 内部结构 8 | 9 | 所有单元测试的代码位于 [tests.py](../tests.py) 10 | 11 | `e2e_test` 分为三部分: 12 | 1. `PasteMeDriver` 封装了 `selenium` 的一些操作 13 | 2. `MockBackend` + `Flask` 用内存作为数据库模拟了 `PasteMe` 的后端 14 | 3. [proxy.py](./proxy.py) 中的 `Flask` 用来作为反向代理 15 | 16 | 单元测试过程中,会分别开 3 个进程去启动上述 2、3,以及执行 `npm run serve` 命令。 17 | 18 | `node` 会监听 `8080` 端口,作为前端的本地服务。 19 | 20 | `MockBackend` 会监听 `8000` 端口,作为 `MockBackend`。 21 | 22 | 而 `proxy` 会监听 `3000` 端口,将 `Frontend` 和 `MockBackend` 编排起来。 23 | 24 | 最后单元测试会使用 `PasteMeDriver`(也就是 `selenium`)去对 `3000` 端口的网页上进行端到端测试。 25 | 26 | ## 相关资料 27 | 28 | 1. [Simple Reverse Proxy Server Using Flask](https://medium.com/customorchestrator/simple-reverse-proxy-server-using-flask-936087ce0afb) -------------------------------------------------------------------------------- /e2e_test/__init__.py: -------------------------------------------------------------------------------- 1 | from .driver import PasteMeDriver 2 | from .mock import main as backend 3 | from .proxy import main as reverse_proxy 4 | -------------------------------------------------------------------------------- /e2e_test/driver.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | from selenium.webdriver.common.by import By 3 | from typing import Callable 4 | import os 5 | 6 | from selenium.webdriver.remote.webelement import WebElement 7 | from selenium.webdriver.support import expected_conditions 8 | from selenium.webdriver.support.wait import WebDriverWait 9 | 10 | 11 | class PasteMeDriver: 12 | def __init__(self, headless: bool = False, timeout: int = 3): 13 | self.timeout = timeout 14 | options = webdriver.ChromeOptions() 15 | for option in ['--disable-gpu', '--no-sandbox']: 16 | options.add_argument(option) 17 | 18 | if headless: 19 | options.add_argument('--headless') 20 | 21 | prefs = { 22 | "credentials_enable_service": False, 23 | "profile.password_manager_enabled": False 24 | } 25 | options.add_experimental_option("prefs", prefs) 26 | options.add_experimental_option('excludeSwitches', ['enable-automation']) 27 | 28 | executable_path = os.path.join(os.environ.get('CHROMEWEBDRIVER'), 'chromedriver') 29 | assert executable_path is not None, 'no chrome web driver founded in ENV' 30 | self.browser = webdriver.Chrome(executable_path=executable_path, options=options) 31 | 32 | def __del__(self): 33 | try: 34 | self.browser.close() 35 | except AttributeError: 36 | pass 37 | 38 | def screenshot(self, img_path: str): 39 | self.browser.get_screenshot_as_file(img_path) 40 | 41 | def open(self, url): 42 | self.browser.get(url) 43 | 44 | def get(self, pattern: str, by: str = By.XPATH, 45 | condition: Callable = expected_conditions.visibility_of_element_located) -> WebElement: 46 | return WebDriverWait(self.browser, self.timeout).until(condition((by, pattern))) 47 | -------------------------------------------------------------------------------- /e2e_test/mock.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime, timedelta 2 | from threading import Lock 3 | 4 | from flask import Flask, request, jsonify 5 | 6 | 7 | class MockBackend: 8 | def __init__(self): 9 | self.database = {} 10 | self.key = 0 11 | self.key_lock = Lock() 12 | self.db_lock = Lock() 13 | 14 | def get_key(self) -> str: 15 | with self.key_lock: 16 | self.key += 1 17 | key = self.key 18 | return f'{key:08d}' 19 | 20 | @classmethod 21 | def beat(cls) -> dict: 22 | return { 23 | 'code': 200 24 | } 25 | 26 | def create(self, body: dict) -> dict: 27 | key = self.get_key() 28 | body['create_time'] = datetime.now() 29 | with self.db_lock: 30 | self.database[key] = body 31 | return { 32 | 'code': 201, 33 | 'key': key 34 | } 35 | 36 | def get(self, key: str, password: str) -> (dict, int): 37 | with self.db_lock: 38 | if key in self.database: 39 | paste: dict = self.database[key] 40 | 41 | if paste['self_destruct']: 42 | if paste['create_time'] + timedelta(seconds=paste['expire_second']) < datetime.now(): 43 | self.database.pop(key) 44 | return { 45 | 'code': 40402, 46 | 'message': 'paste not found' 47 | }, 404 48 | 49 | if password == paste.get('password', ''): 50 | if paste['self_destruct']: 51 | paste['expire_count'] -= 1 52 | if paste['expire_count'] == 0: 53 | self.database.pop(key) 54 | return { 55 | 'code': 200, 56 | 'lang': paste['lang'], 57 | 'content': paste['content'] 58 | }, 200 59 | else: 60 | return { 61 | 'code': 40301, 62 | 'message': 'wrong password' 63 | }, 403 64 | return { 65 | 'code': 40402, 66 | 'message': 'paste not found' 67 | }, 404 68 | 69 | 70 | app = Flask(__name__) 71 | backend = MockBackend() 72 | 73 | 74 | @app.route('/api/v3/', methods=['GET']) 75 | def beat(): 76 | return jsonify(backend.beat()) 77 | 78 | 79 | @app.route('/api/v3/paste/', methods=['POST']) 80 | def create(): 81 | return jsonify(backend.create(request.get_json())) 82 | 83 | 84 | @app.route('/api/v3/paste/', methods=['GET']) 85 | def get(key: str): 86 | try: 87 | response, code = backend.get(key, request.args.get('password', '')) 88 | return jsonify(response), code 89 | except Exception as e: 90 | return jsonify({'code': 500, 'message': str(e)}), 500 91 | 92 | 93 | 94 | def main(): 95 | app.run('127.0.0.1', 8000) 96 | 97 | 98 | if __name__ == '__main__': 99 | main() 100 | -------------------------------------------------------------------------------- /e2e_test/proxy.py: -------------------------------------------------------------------------------- 1 | import flask 2 | import requests 3 | 4 | app = flask.Flask(__name__) 5 | 6 | FRONTEND = 'http://localhost:8080/' 7 | BACKEND = 'http://localhost:8000/api/' 8 | 9 | 10 | def proxy(url: str) -> flask.Response: 11 | request_headers = {} 12 | for key, value in flask.request.headers: 13 | request_headers[key] = value 14 | 15 | kwargs = { 16 | 'json': flask.request.get_json(), 17 | 'headers': request_headers, 18 | 'params': flask.request.args 19 | } 20 | 21 | proxy_response = requests.request(flask.request.method, url, **kwargs) 22 | headers = [(name, value) for (name, value) in proxy_response.raw.headers.items() if name.lower()] 23 | response = flask.Response(proxy_response.content, proxy_response.status_code, headers) 24 | return response 25 | 26 | 27 | @app.route('/api/', methods=['GET', 'POST']) 28 | def index(path: str = ''): 29 | return proxy(BACKEND + path) 30 | 31 | 32 | @app.route('/', methods=['GET']) 33 | @app.route('/', methods=['GET']) 34 | def api(path: str = ''): 35 | return proxy(FRONTEND + path) 36 | 37 | 38 | def main(): 39 | app.run('127.0.0.1', 3000) 40 | 41 | 42 | if __name__ == '__main__': 43 | main() 44 | -------------------------------------------------------------------------------- /e2e_test/requirements.txt: -------------------------------------------------------------------------------- 1 | selenium~=3.141.0 2 | flask~=2.0.1 3 | requests~=2.26.0 -------------------------------------------------------------------------------- /init.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | USER_JS_PATH="/www/pasteme/usr/usr.js" 4 | CONFIG_PATH="/www/pasteme/usr/config.json" 5 | EXAMPLE_CONFIG_PATH="/config.example.json" 6 | 7 | if [ ! -f "${USER_JS_PATH}" ]; then 8 | echo 'console.log("This is a log defined by user")' > /www/pasteme/usr/usr.js 9 | fi 10 | 11 | # 如果配置文件不存在,就使用默认配置 12 | if [ ! -f "${CONFIG_PATH}" ]; then 13 | cp ${EXAMPLE_CONFIG_PATH} ${CONFIG_PATH} 14 | fi 15 | -------------------------------------------------------------------------------- /lang-list.json: -------------------------------------------------------------------------------- 1 | { 2 | "list": ["af", "sq", "ar-SA", "ar-IQ", "ar-EG", "ar-LY", "ar-DZ", "ar-MA", "ar-TN", "ar-OM", 3 | "ar-YE", "ar-SY", "ar-JO", "ar-LB", "ar-KW", "ar-AE", "ar-BH", "ar-QA", "eu", "bg", 4 | "be", "ca", "zh-TW", "zh-CN", "zh-HK", "zh-SG", "hr", "cs", "da", "nl", "nl-BE", "en", 5 | "en-US", "en-EG", "en-AU", "en-GB", "en-CA", "en-NZ", "en-IE", "en-ZA", "en-JM", 6 | "en-BZ", "en-TT", "et", "fo", "fa", "fi", "fr", "fr-BE", "fr-CA", "fr-CH", "fr-LU", 7 | "gd", "gd-IE", "de", "de-CH", "de-AT", "de-LU", "de-LI", "el", "he", "hi", "hu", 8 | "is", "id", "it", "it-CH", "ja", "ko", "lv", "lt", "mk", "mt", "no", "pl", 9 | "pt-BR", "pt", "rm", "ro", "ro-MO", "ru", "ru-MI", "sz", "sr", "sk", "sl", "sb", 10 | "es", "es-AR", "es-GT", "es-CR", "es-PA", "es-DO", "es-MX", "es-VE", "es-CO", 11 | "es-PE", "es-EC", "es-CL", "es-UY", "es-PY", "es-BO", "es-SV", "es-HN", "es-NI", 12 | "es-PR", "sx", "sv", "sv-FI", "th", "ts", "tn", "tr", "uk", "ur", "ve", "vi", "xh", 13 | "ji", "zu"] 14 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pasteme", 3 | "version": "3.4.2", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint", 9 | "test": "echo 'Error: no test specified'", 10 | "analyz": "NODE_ENV=production npm_config_report=true npm run build" 11 | }, 12 | "dependencies": { 13 | "@chenfengyuan/vue-qrcode": "^1.0.1", 14 | "axios": "^0.22.0", 15 | "bootstrap-vue": "^2.0.0-rc.28", 16 | "clipboard": "^2.0.4", 17 | "core-js": "^2.6.9", 18 | "markdown-it": "^12.2.0", 19 | "markdown-it-highlightjs": "^3.0.0", 20 | "markdown-it-task-checkbox": "^1.0.6", 21 | "mermaid": "^8.13.2", 22 | "vue": "^2.6.10", 23 | "vue-cookie": "^1.1.4", 24 | "vue-github-button": "^1.0.8", 25 | "vue-i18n": "^8.26.5", 26 | "vue-router": "^3.5.2", 27 | "vuex": "^3.1.1" 28 | }, 29 | "devDependencies": { 30 | "@ryanlee2014/markdown-it-katex": "^1.0.4", 31 | "@vue/cli-plugin-babel": "^3.11.0", 32 | "@vue/cli-plugin-eslint": "^4.5.13", 33 | "@vue/cli-service": "^4.5.13", 34 | "acorn": "^8.5.0", 35 | "babel-eslint": "^10.0.3", 36 | "compression-webpack-plugin": "^9.0.0", 37 | "css-loader": "^5.2.7", 38 | "eslint": "^7.32.0", 39 | "eslint-plugin-vue": "^7.19.1", 40 | "html-webpack-plugin": "^4.5.2", 41 | "markdown-it-anchor": "^8.3.1", 42 | "style-loader": "^0.23.1", 43 | "uslug": "^1.0.4", 44 | "vue-cli-plugin-webpack-bundle-analyzer": "^1.4.0", 45 | "vue-template-compiler": "^2.5.21", 46 | "webpack": "^4.39.3", 47 | "webpack-bundle-analyzer": "^4.4.2" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | autoprefixer: {} 4 | } 5 | }; 6 | -------------------------------------------------------------------------------- /public/conf.d/docker.conf: -------------------------------------------------------------------------------- 1 | server 2 | { 3 | listen 8080; 4 | server_name _; 5 | index index.html; 6 | root /www/pasteme; 7 | 8 | gzip_http_version 1.0; 9 | 10 | location / { 11 | location ~ .*\.(js|css)?$ { 12 | gzip_static on; 13 | } 14 | } 15 | 16 | location /api/v3/ { 17 | proxy_set_header Host $host; 18 | proxy_set_header X-Real-IP $remote_addr; 19 | proxy_set_header REMOTE-HOST $remote_addr; 20 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 21 | proxy_pass http://pasteme-backend:8000/api/v3/; 22 | } 23 | 24 | location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md) 25 | { 26 | return 404; 27 | } 28 | 29 | access_log /var/lib/pasteme/pasteme.log; 30 | error_log /var/lib/pasteme/pasteme.error.log; 31 | } -------------------------------------------------------------------------------- /public/conf.d/nginx.conf: -------------------------------------------------------------------------------- 1 | server 2 | { 3 | listen 80; 4 | server_name _; 5 | index index.html; 6 | root /www/pasteme; 7 | 8 | location / { 9 | location ~ .*\.(js|css)?$ { 10 | gzip_static on; 11 | } 12 | } 13 | 14 | location /api/v3/ { 15 | proxy_set_header Host $host; 16 | proxy_set_header X-Real-IP $remote_addr; 17 | proxy_set_header REMOTE-HOST $remote_addr; 18 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 19 | proxy_pass http://localhost:8000/api/v3/; 20 | } 21 | 22 | location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md) 23 | { 24 | return 404; 25 | } 26 | 27 | access_log /var/lib/pasteme/pasteme.log; 28 | error_log /var/lib/pasteme/pasteme.error.log; 29 | } -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PasteUs/PasteMeFrontend/74c93d17d2694e3098bc4ec8b8b69c43624d3437/public/favicon.ico -------------------------------------------------------------------------------- /public/img/aliyun.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/img/sponsor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PasteUs/PasteMeFrontend/74c93d17d2694e3098bc4ec8b8b69c43624d3437/public/img/sponsor.png -------------------------------------------------------------------------------- /public/img/touch-icon-ipad-retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PasteUs/PasteMeFrontend/74c93d17d2694e3098bc4ec8b8b69c43624d3437/public/img/touch-icon-ipad-retina.png -------------------------------------------------------------------------------- /public/img/touch-icon-ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PasteUs/PasteMeFrontend/74c93d17d2694e3098bc4ec8b8b69c43624d3437/public/img/touch-icon-ipad.png -------------------------------------------------------------------------------- /public/img/touch-icon-iphone-retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PasteUs/PasteMeFrontend/74c93d17d2694e3098bc4ec8b8b69c43624d3437/public/img/touch-icon-iphone-retina.png -------------------------------------------------------------------------------- /public/img/touch-icon-iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PasteUs/PasteMeFrontend/74c93d17d2694e3098bc4ec8b8b69c43624d3437/public/img/touch-icon-iphone.png -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | PasteMe - 一个不算糟糕的可私有文本分享平台 11 | 13 | 15 | 17 | 19 | <% for (var i in 20 | htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.css) { %> 21 | 22 | <% } %> 23 | 24 | 25 | <% for (var i in 26 | htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.js) { %> 27 | 28 | <% } %> 29 | 30 | 31 | 35 |
36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /public/usr/config.example.json: -------------------------------------------------------------------------------- 1 | { 2 | "api": { 3 | "backend": "/api/v3/", 4 | "admin": "" 5 | }, 6 | "footer": [ 7 | { 8 | "url": "http://blog.lucien.ink/go/csdn", 9 | "text": "CSDN" 10 | }, 11 | { 12 | "url": "https://github.com/LucienShui", 13 | "text": "GitHub" 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /public/usr/usr.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | console.log("This is a log defined by user") 3 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 27 | 28 | 49 | -------------------------------------------------------------------------------- /src/assets/css/github-gist.css: -------------------------------------------------------------------------------- 1 | /** 2 | * GitHub Gist Theme 3 | * Author : Louis Barranqueiro - https://github.com/LouisBarranqueiro 4 | */ 5 | 6 | .hljs { 7 | display: block; 8 | background: white; 9 | padding: 0.5em; 10 | color: #333333; 11 | overflow-x: auto; 12 | } 13 | 14 | .hljs-comment, 15 | .hljs-meta { 16 | color: #969896; 17 | } 18 | 19 | .hljs-string, 20 | .hljs-variable, 21 | .hljs-template-variable, 22 | .hljs-strong, 23 | .hljs-emphasis, 24 | .hljs-quote { 25 | color: #df5000; 26 | } 27 | 28 | .hljs-keyword, 29 | .hljs-selector-tag, 30 | .hljs-type { 31 | color: #a71d5d; 32 | } 33 | 34 | .hljs-literal, 35 | .hljs-symbol, 36 | .hljs-bullet, 37 | .hljs-attribute { 38 | color: #0086b3; 39 | } 40 | 41 | .hljs-section, 42 | .hljs-name { 43 | color: #63a35c; 44 | } 45 | 46 | .hljs-tag { 47 | color: #333333; 48 | } 49 | 50 | .hljs-title, 51 | .hljs-attr, 52 | .hljs-selector-id, 53 | .hljs-selector-class, 54 | .hljs-selector-attr, 55 | .hljs-selector-pseudo { 56 | color: #795da3; 57 | } 58 | 59 | .hljs-addition { 60 | color: #55a532; 61 | background-color: #eaffea; 62 | } 63 | 64 | .hljs-deletion { 65 | color: #bd2c00; 66 | background-color: #ffecec; 67 | } 68 | 69 | .hljs-link { 70 | text-decoration: underline; 71 | } 72 | -------------------------------------------------------------------------------- /src/assets/css/global.css: -------------------------------------------------------------------------------- 1 | .max-height { 2 | height: 100% 3 | } 4 | 5 | .github-corner:hover .octo-arm { 6 | animation: octocat-wave 560ms ease-in-out 7 | } 8 | 9 | @keyframes octocat-wave { 10 | 0%,100% { 11 | transform: rotate(0) 12 | } 13 | 14 | 20%,60% { 15 | transform: rotate(-25deg) 16 | } 17 | 18 | 40%,80% { 19 | transform: rotate(10deg) 20 | } 21 | } 22 | 23 | @media (max-width:500px) { 24 | .github-corner:hover .octo-arm { 25 | animation: none 26 | } 27 | 28 | .github-corner .octo-arm { 29 | animation: octocat-wave 560ms ease-in-out 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/assets/css/highlightjs-line-numbers.css: -------------------------------------------------------------------------------- 1 | /* for block of numbers */ 2 | .hljs-ln-numbers { 3 | -webkit-touch-callout: none; 4 | -webkit-user-select: none; 5 | -khtml-user-select: none; 6 | -moz-user-select: none; 7 | -ms-user-select: none; 8 | user-select: none; 9 | 10 | text-align: center; 11 | color: #ccc; 12 | vertical-align: top; 13 | padding-right: 5px; 14 | 15 | /* your custom style here */ 16 | } 17 | 18 | /* for block of code */ 19 | .hljs-ln-code { 20 | padding-left: 1em; 21 | } 22 | -------------------------------------------------------------------------------- /src/assets/js/api.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | 3 | function getLast(value) { 4 | return value[value.length - 1]; 5 | } 6 | 7 | /** 8 | * 判断是否属于后端已定义的返回值 9 | * @param error 10 | * @returns boolean 11 | */ 12 | function validator(error) { 13 | return error.response && error.response.data && error.response.data.code && 14 | error.response.data.message && typeof error.response.data.code === 'number' && 15 | error.response.data.code > 20000; 16 | } 17 | 18 | function defaultErrorHandler(error, alert_error = true) { 19 | if (alert_error) { 20 | if (validator(error)) { 21 | let data = error.response.data; 22 | alert(data.code + ': ' + data.message); 23 | } else { 24 | alert(JSON.stringify({ 25 | message: error.message, 26 | method: error.config.method, 27 | url: error.config.url, 28 | params: error.config.params 29 | })) 30 | } 31 | } 32 | } 33 | 34 | function wrapper(func) { 35 | return function (url, params = {}, acceptedCode = [], errorHandler = defaultErrorHandler) { 36 | return new Promise((resolve, reject) => { 37 | func(url, params).then(response => { 38 | resolve(response.data); 39 | }).catch(error => { 40 | if (validator(error)) { 41 | let data = error.response.data; 42 | if (acceptedCode.includes(data.code)) { 43 | resolve(data) 44 | return 45 | } 46 | } 47 | errorHandler(error); 48 | reject(error); 49 | }); 50 | }); 51 | } 52 | } 53 | 54 | export default { 55 | get: wrapper(function (url, params) { 56 | return axios.get(url, { 57 | params: params, 58 | headers: { 59 | 'Accept': 'application/json' 60 | } 61 | }) 62 | }), 63 | post: wrapper(axios.post), 64 | put: wrapper(axios.put), 65 | delete: wrapper(axios.delete), 66 | patch: wrapper(axios.patch), 67 | join: function (...args) { 68 | let result = args.map(pathPart => pathPart.replace(/(^\/|\/$)/g, "")).join("/"); 69 | return result + (getLast(getLast(args)) === '/' ? '/' : ''); 70 | }, 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/assets/js/event/directive-register.js: -------------------------------------------------------------------------------- 1 | export default (Vue) => { 2 | Vue.directive('focus', { 3 | inserted: function (el) { 4 | el.focus() 5 | } 6 | }); 7 | } 8 | -------------------------------------------------------------------------------- /src/assets/js/external/markdown-it-links.js: -------------------------------------------------------------------------------- 1 | 2 | function markdownItLinkTarget(md, config) { 3 | config = config || {}; 4 | 5 | const defaultRender = md.renderer.rules.link_open || this.defaultRender; 6 | const target = config.target || '_blank'; 7 | 8 | md.renderer.rules.link_open = function (tokens, idx, options, env, self) { 9 | // If you are sure other plugins can't add `target` - drop check below 10 | const aIndex = tokens[idx].attrIndex('target'); 11 | 12 | if (aIndex < 0) { 13 | tokens[idx].attrPush(['target', target]) // add new attribute 14 | } else { 15 | tokens[idx].attrs[aIndex][1] = target // replace value of existing attr 16 | } 17 | 18 | // pass token to default renderer. 19 | return defaultRender(tokens, idx, options, env, self) 20 | } 21 | } 22 | 23 | markdownItLinkTarget.defaultRender = function (tokens, idx, options, env, self) { 24 | return self.renderToken(tokens, idx, options) 25 | }; 26 | 27 | module.exports = markdownItLinkTarget; 28 | -------------------------------------------------------------------------------- /src/assets/js/external/markdown-it-mermaid.js: -------------------------------------------------------------------------------- 1 | import mermaid from "mermaid"; 2 | 3 | const o = function (e) { 4 | function r(n) { 5 | if (t[n]) return t[n].exports; 6 | var a = t[n] = {i: n, l: !1, exports: {}}; 7 | return e[n].call(a.exports, a, a.exports, r), a.l = !0, a.exports 8 | } 9 | 10 | var t = {}; 11 | return r.m = e, r.c = t, r.d = function (e, t, n) { 12 | r.o(e, t) || Object.defineProperty(e, t, {configurable: !1, enumerable: !0, get: n}) 13 | }, r.n = function (e) { 14 | var t = e && e.__esModule ? function () { 15 | return e.default 16 | } : function () { 17 | return e 18 | }; 19 | return r.d(t, "a", t), t 20 | }, r.o = function (e, r) { 21 | return Object.prototype.hasOwnProperty.call(e, r) 22 | }, r.p = "", r(r.s = 0) 23 | }([function (e, r, t) { 24 | "use strict"; 25 | Object.defineProperty(r, "__esModule", {value: !0}); 26 | var n = t(1), a = function (e) { 27 | return e && e.__esModule ? e : {default: e} 28 | }(n), u = function (e) { 29 | try { 30 | return a.default.parse(e), '
' + e + "
" 31 | } catch (e) { 32 | var r = e.str; 33 | e.hash; 34 | return "
" + r + "
" 35 | } 36 | }, i = function (e) { 37 | e.mermaid = a.default, a.default.loadPreferences = function (e) { 38 | var r = e.get("mermaid-theme"); 39 | void 0 === r && (r = "default"); 40 | var t = e.get("gantt-axis-format"); 41 | return void 0 === t && (t = "%Y-%m-%d"), a.default.initialize({ 42 | theme: r, 43 | gantt: { 44 | axisFormatter: [[t, function (e) { 45 | return 1 === e.getDay() 46 | }]] 47 | }, 48 | startOnLoad: false 49 | }), {"mermaid-theme": r, "gantt-axis-format": t} 50 | }; 51 | var r = e.renderer.rules.fence.bind(e.renderer.rules); 52 | e.renderer.rules.fence = function (e, t, n, a, i) { 53 | var o = e[t], f = o.content.trim(); 54 | if ("mermaid" === o.info) return u(f); 55 | var c = f.split(/\n/)[0].trim(); 56 | return "gantt" === c || "sequenceDiagram" === c || c.match(/^graph (?:TB|BT|RL|LR|TD);?$/) ? u(f) : r(e, t, n, a, i) 57 | } 58 | }; 59 | r.default = i 60 | // eslint-disable-next-line no-unused-vars 61 | }, function (e, r) { 62 | e.exports = mermaid 63 | }]); 64 | export default o; 65 | //# sourceMappingURL=index.js.map 66 | -------------------------------------------------------------------------------- /src/assets/js/external/markdown-it-table-contents.js: -------------------------------------------------------------------------------- 1 | const slugify = (s) => encodeURIComponent(String(s).trim().toLowerCase().replace(/\s+/g, '-')); 2 | const defaults = { 3 | includeLevel: [ 1, 2 ], 4 | containerClass: 'table-of-contents', 5 | slugify, 6 | markerPattern: /^\[\[toc\]\]/im, 7 | listType: 'ul', 8 | format: undefined, 9 | forceFullToc: false, 10 | containerHeaderHtml: undefined, 11 | containerFooterHtml: undefined, 12 | }; 13 | 14 | export default (md, o) => { 15 | const options = Object.assign({}, defaults, o); 16 | const tocRegexp = options.markerPattern; 17 | let gstate; 18 | 19 | function toc(state, silent) { 20 | var token; 21 | var match; 22 | 23 | // Reject if the token does not start with [ 24 | if (state.src.charCodeAt(state.pos) !== 0x5B /* [ */ ) { 25 | return false; 26 | } 27 | // Don't run any pairs in validation mode 28 | if (silent) { 29 | return false; 30 | } 31 | 32 | // Detect TOC markdown 33 | match = tocRegexp.exec(state.src.substr(state.pos)); 34 | match = !match ? [] : match.filter(function(m) { return m; }); 35 | if (match.length < 1) { 36 | return false; 37 | } 38 | 39 | // Build content 40 | token = state.push('toc_open', 'toc', 1); 41 | token.markup = '[[toc]]'; 42 | token = state.push('toc_body', '', 0); 43 | token = state.push('toc_close', 'toc', -1); 44 | 45 | // Update pos so the parser can continue 46 | var newline = state.src.indexOf('\n', state.pos); 47 | if (newline !== -1) { 48 | state.pos = newline; 49 | } else { 50 | state.pos = state.pos + state.posMax + 1; 51 | } 52 | 53 | return true; 54 | } 55 | 56 | // eslint-disable-next-line no-unused-vars 57 | md.renderer.rules.toc_open = function(tokens, index) { 58 | var tocOpenHtml = `
`; 59 | 60 | if (options.containerHeaderHtml) { 61 | tocOpenHtml += options.containerHeaderHtml; 62 | } 63 | 64 | return tocOpenHtml; 65 | }; 66 | 67 | // eslint-disable-next-line no-unused-vars 68 | md.renderer.rules.toc_close = function(tokens, index) { 69 | var tocFooterHtml = ''; 70 | 71 | if (options.containerFooterHtml) { 72 | tocFooterHtml = options.containerFooterHtml; 73 | } 74 | 75 | return tocFooterHtml + `
`; 76 | }; 77 | 78 | // eslint-disable-next-line no-unused-vars 79 | md.renderer.rules.toc_body = function(tokens, index) { 80 | if (options.forceFullToc) { 81 | /* 82 | 83 | Renders full TOC even if the hierarchy of headers contains 84 | a header greater than the first appearing header 85 | 86 | ## heading 2 87 | ### heading 3 88 | # heading 1 89 | 90 | Result TOC: 91 | - heading 2 92 | - heading 3 93 | - heading 1 94 | 95 | */ 96 | var tocBody = ''; 97 | var pos = 0; 98 | var tokenLength = gstate && gstate.tokens && gstate.tokens.length; 99 | 100 | while (pos < tokenLength) { 101 | var tocHierarchy = renderChildsTokens(pos, gstate.tokens); 102 | pos = tocHierarchy[0]; 103 | tocBody += tocHierarchy[1]; 104 | } 105 | 106 | return tocBody; 107 | } else { 108 | return renderChildsTokens(0, gstate.tokens)[1]; 109 | } 110 | }; 111 | 112 | function renderChildsTokens(pos, tokens) { 113 | var headings = [], 114 | buffer = '', 115 | currentLevel, 116 | subHeadings, 117 | size = tokens.length, 118 | i = pos; 119 | while(i < size) { 120 | var token = tokens[i]; 121 | var heading = tokens[i - 1]; 122 | var level = token.tag && parseInt(token.tag.substr(1, 1)); 123 | if (token.type !== 'heading_close' || options.includeLevel.indexOf(level) == -1 || heading.type !== 'inline') { 124 | i++; continue; // Skip if not matching criteria 125 | } 126 | if (!currentLevel) { 127 | currentLevel = level;// We init with the first found level 128 | } else { 129 | if (level > currentLevel) { 130 | subHeadings = renderChildsTokens(i, tokens); 131 | buffer += subHeadings[1]; 132 | i = subHeadings[0]; 133 | continue; 134 | } 135 | if (level < currentLevel) { 136 | // Finishing the sub headings 137 | buffer += ``; 138 | headings.push(buffer); 139 | return [i, `<${options.listType}>${headings.join('')}`]; 140 | } 141 | if (level == currentLevel) { 142 | // Finishing the sub headings 143 | buffer += ``; 144 | headings.push(buffer); 145 | } 146 | } 147 | buffer = ``; 148 | buffer += typeof options.format === 'function' ? options.format(heading.content) : heading.content; 149 | buffer += ``; 150 | i++; 151 | } 152 | buffer += buffer === '' ? '' : ``; 153 | headings.push(buffer); 154 | return [i, `<${options.listType}>${headings.join('')}`]; 155 | } 156 | 157 | // Catch all the tokens for iteration later 158 | md.core.ruler.push('grab_state', function(state) { 159 | gstate = state; 160 | }); 161 | 162 | // Insert TOC 163 | md.inline.ruler.after('emphasis', 'toc', toc); 164 | }; 165 | -------------------------------------------------------------------------------- /src/assets/js/external/markdown-it.js: -------------------------------------------------------------------------------- 1 | /* Author: Ryan Lee(ryanlee2014) 2 | * Created at 08/18/2019 3 | * MarkdownIt Instance 4 | */ 5 | 6 | const uslug = require("uslug") 7 | const uslugify = s => uslug(s) 8 | 9 | function Instance(key = "", problem_id = "") { 10 | const md = require("markdown-it")({ 11 | html: true, 12 | linkify: true, 13 | typographer: true, 14 | breaks: true 15 | }) 16 | const mh = require("markdown-it-highlightjs") 17 | const mk = require("@ryanlee2014/markdown-it-katex") 18 | const ma = require("markdown-it-anchor").default 19 | md.use(mk) 20 | md.use(mh) 21 | md.use(ma, { 22 | slugify: uslugify 23 | }) 24 | md.use(require('markdown-it-task-checkbox'), { 25 | disabled: true, 26 | divWrap: false, 27 | divClass: 'checkbox', 28 | idPrefix: 'cbx_', 29 | ulClass: 'task-list', 30 | liClass: 'task-list-item' 31 | }) 32 | md.use(require("./markdown-it-links")) 33 | md.use(require("./markdown-it-mermaid").default.default) 34 | 35 | const markdownPack = (html) => { 36 | // return `
${html}
` 37 | return html; 38 | } 39 | 40 | const preToSegment = (html) => { 41 | return html.replace(/
[\s\S]+?<\/pre>/g, `
42 | $&
`) 43 | } 44 | 45 | const _render = md.render 46 | 47 | md.render = function () { 48 | return markdownPack(_render.apply(md, arguments)) 49 | } 50 | 51 | md.renderRaw = function () { 52 | return preToSegment(md.renderInline(...arguments)) 53 | } 54 | 55 | return Object.assign(md, {key, problem_id}) 56 | } 57 | 58 | const md = Instance() 59 | md.newInstance = Instance 60 | export default md 61 | -------------------------------------------------------------------------------- /src/assets/js/getters.js: -------------------------------------------------------------------------------- 1 | export default { 2 | config: state => state.config, 3 | key: state => state.key, 4 | content: state => state.content, 5 | view: state => state.view, 6 | lang: state => state.lang 7 | } 8 | -------------------------------------------------------------------------------- /src/assets/js/highlightjs-line-numbers.js: -------------------------------------------------------------------------------- 1 | // jshint multistr:true 2 | 3 | export default lineNumbersBlock; 4 | 5 | let w = window, d = document; 6 | 7 | let TABLE_NAME = 'hljs-ln', 8 | LINE_NAME = 'hljs-ln-line', 9 | CODE_BLOCK_NAME = 'hljs-ln-code', 10 | NUMBERS_BLOCK_NAME = 'hljs-ln-numbers', 11 | NUMBER_LINE_NAME = 'hljs-ln-n', 12 | DATA_ATTR_NAME = 'data-line-number', 13 | BREAK_LINE_REGEXP = /\r\n|\r|\n/g; 14 | 15 | addStyles(); 16 | 17 | function isHljsLnCodeDescendant(domElt) { 18 | let curElt = domElt; 19 | while (curElt) { 20 | if (curElt.className && curElt.className.indexOf('hljs-ln-code') !== -1) { 21 | return true; 22 | } 23 | curElt = curElt.parentNode; 24 | } 25 | return false; 26 | } 27 | 28 | function getHljsLnTable(hljsLnDomElt) { 29 | let curElt = hljsLnDomElt; 30 | while (curElt.nodeName !== 'TABLE') { 31 | curElt = curElt.parentNode; 32 | } 33 | return curElt; 34 | } 35 | 36 | // Function to workaround a copy issue with Microsoft Edge. 37 | // Due to hljs-ln wrapping the lines of code inside a element, 38 | // itself wrapped inside a
 element, window.getSelection().toString()
 39 | // does not contain any line breaks. So we need to get them back using the
 40 | // rendered code in the DOM as reference.
 41 | function edgeGetSelectedCodeLines(selection) {
 42 |     // current selected text without line breaks
 43 |     let selectionText = selection.toString();
 44 | 
 45 |     // get the 
' + 175 | '' + 178 | '' + 181 | '', 182 | [ 183 | LINE_NAME, 184 | NUMBERS_BLOCK_NAME, 185 | NUMBER_LINE_NAME, 186 | DATA_ATTR_NAME, 187 | CODE_BLOCK_NAME, 188 | i + 1, 189 | lines[i].length > 0 ? lines[i] : ' ' 190 | ]); 191 | } 192 | 193 | return format('
element wrapping the first line of selected code 46 | let tdAnchor = selection.anchorNode; 47 | while (tdAnchor.nodeName !== 'TD') { 48 | tdAnchor = tdAnchor.parentNode; 49 | } 50 | 51 | // get the element wrapping the last line of selected code 52 | let tdFocus = selection.focusNode; 53 | while (tdFocus.nodeName !== 'TD') { 54 | tdFocus = tdFocus.parentNode; 55 | } 56 | 57 | // extract line numbers 58 | let firstLineNumber = parseInt(tdAnchor.dataset.lineNumber); 59 | let lastLineNumber = parseInt(tdFocus.dataset.lineNumber); 60 | 61 | // multi-lines copied case 62 | if (firstLineNumber !== lastLineNumber) { 63 | 64 | let firstLineText = tdAnchor.textContent; 65 | let lastLineText = tdFocus.textContent; 66 | 67 | // if the selection was made backward, swap values 68 | if (firstLineNumber > lastLineNumber) { 69 | let tmp = firstLineNumber; 70 | firstLineNumber = lastLineNumber; 71 | lastLineNumber = tmp; 72 | tmp = firstLineText; 73 | firstLineText = lastLineText; 74 | lastLineText = tmp; 75 | } 76 | 77 | // discard not copied characters in first line 78 | while (selectionText.indexOf(firstLineText) !== 0) { 79 | firstLineText = firstLineText.slice(1); 80 | } 81 | 82 | // discard not copied characters in last line 83 | while (selectionText.lastIndexOf(lastLineText) === -1) { 84 | lastLineText = lastLineText.slice(0, -1); 85 | } 86 | 87 | // reconstruct and return the real copied text 88 | let selectedText = firstLineText; 89 | let hljsLnTable = getHljsLnTable(tdAnchor); 90 | for (let i = firstLineNumber + 1 ; i < lastLineNumber ; ++i) { 91 | let codeLineSel = format('.{0}[{1}="{2}"]', [CODE_BLOCK_NAME, DATA_ATTR_NAME, i]); 92 | let codeLineElt = hljsLnTable.querySelector(codeLineSel); 93 | selectedText += '\n' + codeLineElt.textContent; 94 | } 95 | selectedText += '\n' + lastLineText; 96 | return selectedText; 97 | // single copied line case 98 | } else { 99 | return selectionText; 100 | } 101 | } 102 | 103 | // ensure consistent code copy/paste behavior across all browsers 104 | // (see https://github.com/wcoder/highlightjs-line-numbers.js/issues/51) 105 | document.addEventListener('copy', function(e) { 106 | // get current selection 107 | let selection = window.getSelection(); 108 | // override behavior when one wants to copy line of codes 109 | if (isHljsLnCodeDescendant(selection.anchorNode)) { 110 | let selectionText; 111 | // workaround an issue with Microsoft Edge as copied line breaks 112 | // are removed otherwise from the selection string 113 | if (window.navigator.userAgent.indexOf("Edge") !== -1) { 114 | selectionText = edgeGetSelectedCodeLines(selection); 115 | } else { 116 | // other browsers can directly use the selection string 117 | selectionText = selection.toString(); 118 | } 119 | e.clipboardData.setData('text/plain', selectionText); 120 | e.preventDefault(); 121 | } 122 | }); 123 | 124 | function addStyles () { 125 | let css = d.createElement('style'); 126 | css.innerHTML = format( 127 | '.{0}{border-collapse:collapse}' + 128 | '.{0} td{padding-top: 0; padding-bottom: 0; padding-right: 0;}' + 129 | '.{1}:before{content:attr({2})}', 130 | [ 131 | TABLE_NAME, 132 | NUMBER_LINE_NAME, 133 | DATA_ATTR_NAME 134 | ]); 135 | d.getElementsByTagName('head')[0].appendChild(css); 136 | } 137 | 138 | function lineNumbersBlock (element, options) { 139 | if (typeof element !== 'object') return; 140 | 141 | async(function () { 142 | element.innerHTML = lineNumbersInternal(element, options); 143 | }); 144 | } 145 | 146 | function lineNumbersInternal (element, options) { 147 | // define options or set default 148 | options = options || { 149 | singleLine: false 150 | }; 151 | 152 | // convert options 153 | let firstLineIndex = options.singleLine ? 0 : 1; 154 | 155 | duplicateMultilineNodes(element); 156 | 157 | return addLineNumbersBlockFor(element.innerHTML, firstLineIndex); 158 | } 159 | 160 | function addLineNumbersBlockFor (inputHtml, firstLineIndex) { 161 | 162 | let lines = getLines(inputHtml); 163 | 164 | // if last line contains only carriage return remove it 165 | if (lines[lines.length-1].trim() === '') { 166 | lines.pop(); 167 | } 168 | 169 | if (lines.length > firstLineIndex) { 170 | let html = ''; 171 | 172 | for (let i = 0, l = lines.length; i < l; i++) { 173 | html += format( 174 | '
' + 176 | '
' + 177 | '
' + 179 | '{6}' + 180 | '
{1}
', [ TABLE_NAME, html ]); 194 | } 195 | 196 | return inputHtml; 197 | } 198 | 199 | /** 200 | * Recursive method for fix multi-line elements implementation in highlight.js 201 | * Doing deep passage on child nodes. 202 | * @param {HTMLElement} element 203 | */ 204 | function duplicateMultilineNodes (element) { 205 | let nodes = element.childNodes; 206 | for (let node in nodes) { 207 | // eslint-disable-next-line no-prototype-builtins 208 | if (nodes.hasOwnProperty(node)) { 209 | let child = nodes[node]; 210 | if (getLinesCount(child.textContent) > 0) { 211 | if (child.childNodes.length > 0) { 212 | duplicateMultilineNodes(child); 213 | } else { 214 | duplicateMultilineNode(child.parentNode); 215 | } 216 | } 217 | } 218 | } 219 | } 220 | 221 | /** 222 | * Method for fix multi-line elements implementation in highlight.js 223 | * @param {HTMLElement} element 224 | */ 225 | function duplicateMultilineNode (element) { 226 | let className = element.className; 227 | 228 | if ( ! /hljs-/.test(className)) return; 229 | 230 | let lines = getLines(element.innerHTML); 231 | 232 | let result = ''; 233 | 234 | for (let i = 0; i < lines.length; i++) { 235 | let lineText = lines[i].length > 0 ? lines[i] : ' '; 236 | result += format('{1}\n', [ className, lineText ]); 237 | } 238 | 239 | element.innerHTML = result.trim(); 240 | } 241 | 242 | function getLines (text) { 243 | if (text.length === 0) return []; 244 | return text.split(BREAK_LINE_REGEXP); 245 | } 246 | 247 | function getLinesCount (text) { 248 | return (text.trim().match(BREAK_LINE_REGEXP) || []).length; 249 | } 250 | 251 | function async (func) { 252 | w.setTimeout(func, 0); 253 | } 254 | 255 | /** 256 | * {@link https://wcoder.github.io/notes/string-format-for-string-formating-in-javascript} 257 | * @param {string} format 258 | * @param {array} args 259 | */ 260 | function format (format, args) { 261 | return format.replace(/\{(\d+)\}/g, function(m, n){ 262 | return args[n] ? args[n] : m; 263 | }); 264 | } 265 | -------------------------------------------------------------------------------- /src/assets/js/i18n.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import VueI18n from 'vue-i18n' 3 | 4 | Vue.use(VueI18n); 5 | 6 | const i18n = new VueI18n({ 7 | locale: 'zh-CN', 8 | fallbackLocale: 'zh-CN', 9 | messages: { 10 | 'zh-CN': require('../lang/zh-CN') 11 | } 12 | }); 13 | 14 | const loadedLanguages = ['zh-CN']; 15 | const supportedLanguage = ['zh-CN', 'en']; 16 | 17 | function setI18nLanguage(lang) { 18 | i18n.locale = lang; 19 | document.querySelector('html').setAttribute('lang', lang); 20 | } 21 | 22 | Vue.prototype.setI18n = function (lang) { 23 | if (i18n.locale !== lang) { 24 | if (supportedLanguage.includes(lang)) { 25 | if (!loadedLanguages.includes(lang)) { 26 | import(/* webpackChunkName: "lang-[request]" */ `../lang/${lang}`).then(messages => { 27 | i18n.setLocaleMessage(lang, messages); 28 | loadedLanguages.push(lang); 29 | setI18nLanguage(lang); 30 | }).catch(error => { 31 | alert(JSON.stringify(error)); 32 | }); 33 | } else setI18nLanguage(lang); 34 | } else setI18nLanguage(supportedLanguage[0]); 35 | } 36 | }; 37 | 38 | export default i18n; 39 | -------------------------------------------------------------------------------- /src/assets/js/mixins/stateMixin.js: -------------------------------------------------------------------------------- 1 | export default { 2 | methods: { 3 | _baseUpdate(object) { 4 | this.$store.commit("updateState", object); 5 | }, 6 | updateView(view) { 7 | this._baseUpdate({ view }); 8 | }, 9 | updateContent(content) { 10 | this._baseUpdate({ content }); 11 | }, 12 | updateKey(key) { 13 | this._baseUpdate({ key }); 14 | }, 15 | updateLang(lang) { 16 | this._baseUpdate({ lang }); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/assets/js/router.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue" 2 | import Router from "vue-router" 3 | import View from "../../views/View"; 4 | import Home from "../../views/Home"; 5 | // eslint-disable-next-line no-unused-vars 6 | const emptyFunc = (arg) => {}; 7 | // warn if in developing env 8 | // eslint-disable-next-line no-console 9 | const warn = process.env.NODE_ENV !== "production" ? (console && console.warn || emptyFunc) : emptyFunc; 10 | const originalPush = Router.prototype.push; 11 | Router.prototype.push = function push(location, onResolve, onReject) { 12 | if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject); 13 | return originalPush.call(this, location).catch(warn); 14 | }; 15 | 16 | Vue.use(Router); 17 | 18 | export default new Router({ 19 | mode: "hash", 20 | base: "/", 21 | routes: [ 22 | { 23 | path: "/", 24 | name: "home", 25 | component: Home 26 | }, 27 | { 28 | path: "/:key([a-zA-Z0-9]{3,8})", 29 | name: "view", 30 | component: View 31 | }, 32 | { 33 | path: "/What_are_you_nong_sha_lei?", 34 | name: "NotFound", 35 | component: () => import(/* webpackChunkName: "not_found" */ "../../views/NotFound") 36 | }, 37 | { 38 | path: "*", 39 | redirect: "/What_are_you_nong_sha_lei?" 40 | }, 41 | /* TODO 42 | { 43 | path: "pasteme-admin", 44 | name: "pasteme-admin" 45 | }, 46 | */ 47 | ] 48 | }) 49 | -------------------------------------------------------------------------------- /src/assets/js/store.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | import getters from './getters' 4 | 5 | Vue.use(Vuex); 6 | 7 | export default new Vuex.Store({ 8 | state: { 9 | read_once: false, 10 | not_found: false, 11 | config: { 12 | api: { 13 | backend: '', 14 | admin: '' 15 | }, 16 | footer: [] 17 | }, 18 | view: "loading", 19 | namespace: 'nobody', 20 | key: "", 21 | content: "", 22 | lang: "" 23 | }, 24 | mutations: { 25 | updateMode(state, payload) { 26 | state.read_once = payload.read_once; 27 | }, 28 | updateNotFound(state, payload) { 29 | state.not_found = payload.not_found; 30 | }, 31 | init(state) { 32 | state.not_found = state.read_once = false; 33 | }, 34 | updateState(state, payload) { 35 | Object.assign(state, payload); 36 | } 37 | }, 38 | getters 39 | }); 40 | -------------------------------------------------------------------------------- /src/assets/lang/en.js: -------------------------------------------------------------------------------- 1 | export const lang = { 2 | error: { 3 | text: 'A fatal error was detected. Please contact the administrator with the information', 4 | }, 5 | form: { 6 | input: [ 7 | { 8 | prepend: 'Syntax', 9 | }, 10 | { 11 | prepend: 'Passwd', 12 | placeholder: 'Empty disabled', 13 | } 14 | ], 15 | textarea: { 16 | placeholder: { 17 | write_something_here: 'Make the most of your creativity.', 18 | read_once: 'Burn after reading.', 19 | }, 20 | }, 21 | select: { 22 | plain: 'Plain', 23 | }, 24 | submit: 'Submit', 25 | checkbox: { 26 | text: 'Self-destruct', 27 | popover: 'Disable unless login, but there is no login yet', 28 | }, 29 | count: { 30 | prepend: 'access', 31 | append: 'times', 32 | }, 33 | time: { 34 | prepend: 'after', 35 | append: 'minutes', 36 | } 37 | }, 38 | success: { 39 | h2: 'Success!', 40 | p: [ 41 | { 42 | text: 'How to access this Paste {key} :', 43 | }, 44 | { 45 | button: 'Return', 46 | }, 47 | ], 48 | ul: { 49 | li: [ 50 | { 51 | text: 'Enter Paste\'s number in the nav bar area.', 52 | }, 53 | { 54 | browser: 'Direct click to access: ', 55 | tooltip: 'Open on a new window', 56 | }, 57 | { 58 | scan_qr_code: 'Scan the QR code', 59 | } 60 | ], 61 | }, 62 | popover: { 63 | text: 'Enter Paste\'s number here to access to it.', 64 | }, 65 | badge: { 66 | copy: 'Copy', 67 | success: 'Copied!', 68 | fail: 'Error!', 69 | } 70 | }, 71 | auth: { 72 | form: { 73 | label: 'Please offer your password to access:', 74 | button: 'Submit', 75 | placeholder: 'Wrong password.', 76 | } 77 | }, 78 | nav: { 79 | router_link: 'Homepage', 80 | form: { 81 | placeholder: 'Paste\'s number', 82 | button: 'Go', 83 | }, 84 | lang: { 85 | zh_CN: '简体中文', 86 | en: 'English', 87 | }, 88 | something: { 89 | text: 'Something', 90 | log: 'Change Logs', 91 | help: 'Guidance', 92 | feedback: 'Feedback', 93 | }, 94 | more: 'More', 95 | donate: 'Donation', 96 | beg: 'Star', 97 | }, 98 | not_found: { 99 | content: { 100 | title: 'Page not found', 101 | go_home: 'Home', 102 | }, 103 | footer: { 104 | text: 'If you\'d like to know more, you can search online later for this error: ERROR_404_GIRLFRIEND_NOT_FOUND', 105 | beg: { 106 | left: 'Please give me one', 107 | right: 'in GitHub', 108 | } 109 | } 110 | }, 111 | footer: { 112 | tooltip: 'Click to change', 113 | }, 114 | view: { 115 | parsed: 'Parsed', 116 | raw: 'Raw', 117 | } 118 | }; 119 | -------------------------------------------------------------------------------- /src/assets/lang/zh-CN.js: -------------------------------------------------------------------------------- 1 | export const lang = { 2 | error: { 3 | text: '遇到一个致命错误,请将输出的信息发送给管理员', 4 | }, 5 | form: { 6 | input: [ 7 | { 8 | prepend: '高亮', 9 | }, 10 | { 11 | prepend: '密码', 12 | placeholder: '无需设置密码请留空', 13 | } 14 | ], 15 | textarea: { 16 | placeholder: { 17 | write_something_here: '写点什么进来吧', 18 | read_once: '一次有效,阅后即焚', 19 | }, 20 | }, 21 | select: { 22 | plain: '纯文本', 23 | }, 24 | submit: '保存', 25 | checkbox: { 26 | text: '自我销毁', 27 | popover: '只有登陆状态下才能解锁此项,而目前暂时没有做好登陆的模块', 28 | }, 29 | count: { 30 | prepend: '浏览', 31 | append: '次', 32 | }, 33 | time: { 34 | prepend: '', 35 | append: '分钟后', 36 | }, 37 | }, 38 | success: { 39 | h2: '保存成功', 40 | p: [ 41 | { 42 | text: '欲访问 {key} 所对应的一贴', 43 | }, 44 | { 45 | button: '返回主页', 46 | }, 47 | ], 48 | ul: { 49 | li: [ 50 | { 51 | text: '在导航栏中输入索引', 52 | }, 53 | { 54 | browser: '在浏览器中访问', 55 | tooltip: '在新页面中查看', 56 | }, 57 | { 58 | scan_qr_code: '扫描二维码', 59 | } 60 | ], 61 | }, 62 | popover: { 63 | text: '在这里填入 索引 即可查看相应的一贴', 64 | }, 65 | badge: { 66 | copy: '复制链接', 67 | success: '复制成功', 68 | fail: '复制失败', 69 | } 70 | }, 71 | auth: { 72 | form: { 73 | label: '此一贴已加密,请输入密码:', 74 | button: '提交', 75 | placeholder: '密码错误', 76 | } 77 | }, 78 | nav: { 79 | router_link: '返回主页', 80 | form: { 81 | placeholder: '索引', 82 | button: '前往', 83 | }, 84 | lang: { 85 | zh_CN: '简体中文', 86 | en: 'English', 87 | }, 88 | something: { 89 | text: '聚合', 90 | log: '更新日志', 91 | help: '使用指南', 92 | feedback: '我要吐槽', 93 | }, 94 | donate: '捐助', 95 | more: '更多', 96 | beg: '给个 Star 好不啦', 97 | }, 98 | not_found: { 99 | content: { 100 | title: '您访问的页面没有找到', 101 | go_home: '返回主页', 102 | }, 103 | footer: { 104 | text: '如果您想了解更多信息,则可以稍后在线搜索此错误:ERROR_404_GIRLFRIEND_NOT_FOUND', 105 | beg: { 106 | left: '在 GitHub 里给本项目一个', 107 | right: '吧 Orz', 108 | } 109 | } 110 | }, 111 | footer: { 112 | tooltip: { 113 | refresh: '点按以刷新', 114 | wait: '{sec} 秒后可以再次刷新', 115 | } 116 | }, 117 | view: { 118 | parsed: '渲染', 119 | raw: '源码', 120 | lines: '行', 121 | lang: { 122 | cpp: 'C/C++', 123 | java: 'Java', 124 | bash: 'Bash', 125 | html: 'HTML', 126 | python: 'Python', 127 | markdown: 'Markdown', 128 | go: 'Go', 129 | json: 'JSON', 130 | plaintext: '纯文本', 131 | }, 132 | copy: '复制', 133 | tooltip: { 134 | click: '点按以复制', 135 | success: '成功', 136 | fail: '失败', 137 | } 138 | } 139 | }; 140 | -------------------------------------------------------------------------------- /src/components/Footer.vue: -------------------------------------------------------------------------------- 1 | 37 | 38 | 85 | 86 | 124 | -------------------------------------------------------------------------------- /src/components/Form.vue: -------------------------------------------------------------------------------- 1 | 88 | 89 | 145 | 146 | 149 | -------------------------------------------------------------------------------- /src/components/Header.vue: -------------------------------------------------------------------------------- 1 | 142 | 143 | 238 | 239 | 283 | -------------------------------------------------------------------------------- /src/components/Loading.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 20 | 21 | -------------------------------------------------------------------------------- /src/components/ManualDeleted.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 21 | 22 | -------------------------------------------------------------------------------- /src/components/PasswordAuth.vue: -------------------------------------------------------------------------------- 1 | 19 | 20 | 53 | 54 | 57 | -------------------------------------------------------------------------------- /src/components/PasteView.vue: -------------------------------------------------------------------------------- 1 | 46 | 47 | 136 | 141 | 165 | -------------------------------------------------------------------------------- /src/components/Success.vue: -------------------------------------------------------------------------------- 1 | 57 | 58 | 100 | 101 | 112 | -------------------------------------------------------------------------------- /src/components/icons/Bell.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 10 | 11 | 104 | -------------------------------------------------------------------------------- /src/components/icons/GlobalAsia.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 10 | 11 | 104 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import VueQrcode from '@chenfengyuan/vue-qrcode' 3 | import clipboard from 'clipboard' 4 | import BootstrapVue from 'bootstrap-vue' 5 | 6 | import App from './App.vue' 7 | import router from './assets/js/router' 8 | import store from './assets/js/store' 9 | import i18n from './assets/js/i18n' 10 | import api from './assets/js/api' 11 | import markdownIt from './assets/js/external/markdown-it' 12 | import DirectiveRegister from './assets/js/event/directive-register' 13 | 14 | import '@/assets/css/global.css' 15 | 16 | let VueCookie = require('vue-cookie'); 17 | DirectiveRegister(Vue); 18 | Vue.config.productionTip = false; 19 | Vue.use(BootstrapVue); 20 | Vue.use(VueCookie); 21 | Vue.prototype.clipboard = clipboard; 22 | Vue.prototype.api = api; 23 | 24 | Vue.prototype.markdown = markdownIt; 25 | 26 | Vue.component('QRCode', VueQrcode); 27 | 28 | api.get('/usr/config.json').then(response => { 29 | store.state.config = response; 30 | return api.get(store.state.config.api.backend, {method: "beat"}); 31 | }).then(() => { 32 | return new Vue({ 33 | store, 34 | i18n, 35 | router, 36 | render: h => h(App) 37 | }).$mount('#app'); 38 | }); 39 | -------------------------------------------------------------------------------- /src/views/Home.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 36 | 37 | 46 | -------------------------------------------------------------------------------- /src/views/NotFound.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 33 | 34 | 53 | -------------------------------------------------------------------------------- /src/views/View.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 64 | 65 | 74 | -------------------------------------------------------------------------------- /tests.py: -------------------------------------------------------------------------------- 1 | import multiprocessing 2 | import os 3 | import signal 4 | import subprocess 5 | import time 6 | import unittest 7 | import socket 8 | 9 | from e2e_test import PasteMeDriver, reverse_proxy, backend 10 | 11 | 12 | def check_port(port) -> True: 13 | with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: 14 | return sock.connect_ex(('127.0.0.1', port)) == 0 15 | 16 | 17 | def check() -> bool: 18 | time.sleep(3) 19 | for port in [8080, 8000, 3000]: 20 | if not check_port(port): 21 | print(f'port {port} not ready') 22 | return False 23 | return True 24 | 25 | 26 | class PasteMeEndToEndUnitTest(unittest.TestCase): 27 | process = subprocess.Popen('npm run serve', subprocess.PIPE, shell=True, preexec_fn=os.setsid) 28 | api = multiprocessing.Process(target=backend) 29 | 30 | proxy = multiprocessing.Process(target=reverse_proxy) 31 | 32 | @classmethod 33 | def setUpClass(cls) -> None: 34 | cls.proxy.start() 35 | cls.api.start() 36 | 37 | cnt = 0 38 | retry = 10 39 | 40 | while not check() and cnt < retry: 41 | cnt += 1 42 | 43 | if cnt == retry: 44 | cls.tearDownClass() 45 | raise ChildProcessError 46 | 47 | @classmethod 48 | def tearDownClass(cls) -> None: 49 | try: 50 | os.killpg(os.getpgid(cls.process.pid), signal.SIGTERM) 51 | except ProcessLookupError: 52 | pass 53 | 54 | cls.proxy.terminate() 55 | cls.api.terminate() 56 | 57 | cls.proxy.join() 58 | cls.api.join() 59 | 60 | def main(self, password: str = None): 61 | content = 'print("Hello World!")' 62 | 63 | pasteme = PasteMeDriver(headless=True) 64 | pasteme.open('http://localhost:3000') 65 | 66 | language_selector = pasteme.get('//a[@role = "button"]') 67 | language_selector.click() 68 | 69 | chinese_language = pasteme.get('//a[@class = "dropdown-item" and contains(text(), "简体中文")]') 70 | chinese_language.click() 71 | 72 | python_selection = pasteme.get('//select/option[text() = "Python"]') 73 | python_selection.click() 74 | 75 | if password is not None: 76 | password_setter = pasteme.get('//input[@type = "password"]') 77 | password_setter.clear() 78 | password_setter.send_keys(password) 79 | 80 | textarea = pasteme.get('//textarea') 81 | textarea.clear() 82 | textarea.send_keys(content) 83 | 84 | save_button = pasteme.get('//button[@type = "submit" and contains(text(), "保存")]') 85 | save_button.click() 86 | 87 | self.assertEqual(pasteme.get('//h2').get_attribute('innerText'), '保存成功') 88 | 89 | key = pasteme.get('//p[contains(text(), "欲访问")]/strong').get_attribute('innerText') 90 | 91 | search_input = pasteme.get('//input[@type = "search"]') 92 | search_input.clear() 93 | search_input.send_keys(key) 94 | 95 | search_button = pasteme.get('//button[@type = "submit" and contains(text(), "前往")]') 96 | search_button.click() 97 | 98 | if password is not None: 99 | password_validation_input = pasteme.get('//input[@type = "password"]') 100 | password_validation_input.clear() 101 | password_validation_input.send_keys(f'wrong_{password}') 102 | 103 | password_submit_button = pasteme.get('//button[@type = "submit" and contains(text(), "提交")]') 104 | password_submit_button.click() 105 | 106 | password_validation_input = pasteme.get('//input[@type = "password" and @placeholder = "密码错误"]') 107 | self.assertEqual(password_validation_input.get_attribute('placeholder'), '密码错误') 108 | 109 | password_validation_input.clear() 110 | password_validation_input.send_keys(password) 111 | 112 | password_submit_button = pasteme.get('//button[@type = "submit" and contains(text(), "提交")]') 113 | password_submit_button.click() 114 | 115 | line_1 = pasteme.get('//td[@class = "hljs-ln-line hljs-ln-code" and @data-line-number="1"]') 116 | self.assertEqual(line_1.get_attribute('innerText'), content) 117 | 118 | def test_save_with_password(self): 119 | self.main(password='password') 120 | 121 | def test_save_without_password(self): 122 | self.main() 123 | 124 | 125 | if __name__ == '__main__': 126 | unittest.main() 127 | -------------------------------------------------------------------------------- /vue.config.js: -------------------------------------------------------------------------------- 1 | const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; 2 | 3 | // 取消用 tag 来区分版本 4 | // const version = require("./build.config").version; 5 | const version = 'master'; 6 | 7 | let webPath = 'https://fastly.jsdelivr.net/gh/PasteUs/CDN@' + version + '/pasteme/'; 8 | 9 | const cdn = { 10 | // 开发环境 11 | dev: { 12 | css: [ 13 | "https://shadow.elemecdn.com/npm/katex@0.11.0/dist/katex.min.css", 14 | "https://cdn.staticfile.org/github-markdown-css/3.0.1/github-markdown.min.css", 15 | "https://shadow.elemecdn.com/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css", 16 | "https://shadow.elemecdn.com/npm/bootstrap-vue@2.0.0-rc.28/dist/bootstrap-vue.min.css" 17 | ], 18 | js: [ 19 | "https://fastly.jsdelivr.net/gh/highlightjs/cdn-release@9.15.9/build/highlight.min.js" 20 | ] 21 | }, 22 | // 生产环境 23 | build: { 24 | css: [ 25 | "https://shadow.elemecdn.com/npm/katex@0.11.0/dist/katex.min.css", 26 | "https://cdn.staticfile.org/github-markdown-css/3.0.1/github-markdown.min.css", 27 | "https://shadow.elemecdn.com/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css", 28 | "https://shadow.elemecdn.com/npm/bootstrap-vue@2.0.0-rc.28/dist/bootstrap-vue.min.css" 29 | ], 30 | js: [ 31 | 'https://shadow.elemecdn.com/npm/vue@2.6.10/dist/vue.runtime.min.js', 32 | 'https://shadow.elemecdn.com/npm/vue-router@3.1.2/dist/vue-router.min.js', 33 | 'https://shadow.elemecdn.com/npm/vuex@3.1.1/dist/vuex.min.js', 34 | 'https://shadow.elemecdn.com/npm/axios@0.19.0/dist/axios.min.js', 35 | 'https://shadow.elemecdn.com/npm/katex@0.11.0/dist/katex.min.js', 36 | "https://shadow.elemecdn.com/npm/mermaid@8.2.3/dist/mermaid.min.js", 37 | "https://fastly.jsdelivr.net/gh/highlightjs/cdn-release@9.15.9/build/highlight.min.js", 38 | "https://fastly.jsdelivr.net/npm/d3@5.9.7/dist/d3.min.js", 39 | "https://shadow.elemecdn.com/npm/bootstrap-vue@2.0.0-rc.28/dist/bootstrap-vue.min.js", 40 | "https://fastly.jsdelivr.net/npm/markdown-it@9.1.0/dist/markdown-it.min.js", 41 | "https://fastly.jsdelivr.net/npm/unorm@1.6.0/lib/unorm.min.js", 42 | "https://fastly.jsdelivr.net/npm/@chenfengyuan/vue-qrcode@1.0.1/dist/vue-qrcode.min.js", 43 | "https://fastly.jsdelivr.net/npm/vue-i18n@8.14.0/dist/vue-i18n.min.js" 44 | ] 45 | } 46 | }; 47 | 48 | module.exports = { 49 | devServer: { 50 | proxy: { 51 | "/api/v3/": { 52 | secure: false, 53 | target: "http://beta.pasteme.lucien.ink/", 54 | // target: "http://localhost:8000/", 55 | changeOrigin: true 56 | } 57 | } 58 | }, 59 | publicPath: process.env.NODE_ENV === 'production' ? webPath : '/', 60 | outputDir: 'pasteme', 61 | productionSourceMap: false, 62 | configureWebpack: config => { // eslint-disable-line 63 | if (process.env.NODE_ENV === 'production') { 64 | config.plugins.push(new BundleAnalyzerPlugin({ 65 | analyzerMode: "static" 66 | })); 67 | config.externals = { 68 | "vue": "Vue", 69 | "vuex": "Vuex", 70 | "vue-router": "VueRouter", 71 | "katex": "katex", 72 | "axios": "axios", 73 | "mermaid": "mermaid", 74 | "highlight.js": "hljs", 75 | "d3": "d3", 76 | "bootstrap-vue": "BootstrapVue", 77 | "markdown-it": "markdownit", 78 | "unorm": "unorm", 79 | "@chenfengyuan/vue-qrcode": "VueQrcode", 80 | "vue-i18n": "VueI18n" 81 | }; 82 | } 83 | return { 84 | output: { 85 | libraryExport: 'default', 86 | jsonpFunction: 'jsonpFunction' 87 | } 88 | } 89 | }, 90 | chainWebpack: config => { 91 | config.plugin('html').tap(args => { 92 | if (process.env.NODE_ENV === 'production') { 93 | args[0].cdn = cdn.build 94 | } 95 | if (process.env.NODE_ENV === 'development') { 96 | args[0].cdn = cdn.dev 97 | } 98 | return args 99 | }) 100 | } 101 | }; 102 | --------------------------------------------------------------------------------