From c4c68f7f7e9fb4deb4b3f40625ead98986cd4cf8 Mon Sep 17 00:00:00 2001 From: Jonah Aragon Date: Thu, 11 Apr 2024 06:41:22 +0000 Subject: [PATCH] Add run.sh script to project (#2517) Signed-off-by: Daniel Gray --- .devcontainer/devcontainer.json | 2 +- .devcontainer/team/devcontainer.json | 2 +- .github/workflows/build.yml | 68 +--------- .gitignore | 1 + .mailmap | 16 +++ Dockerfile | 8 +- Pipfile | 2 +- Pipfile.lock | 189 +-------------------------- README.md | 15 ++- mkdocs-production.yml | 27 ---- mkdocs.yml | 11 +- run.sh | 140 ++++++++++++++++++++ theme/partials/content.html | 3 +- theme/partials/source-file.html | 103 +++++++++++++++ 14 files changed, 301 insertions(+), 286 deletions(-) create mode 100644 .mailmap delete mode 100644 mkdocs-production.yml create mode 100755 run.sh create mode 100644 theme/partials/source-file.html diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index bb948551..38664c2f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,5 +4,5 @@ "name": "Privacy Guides", "image": "ghcr.io/squidfunk/mkdocs-material:9.5.17", "forwardPorts": [8000], - "postCreateCommand": "git submodule init; git submodule update theme/assets/brand; mkdocs serve --dev-addr=0.0.0.0:8000" + "postCreateCommand": "git submodule init; git submodule update theme/assets/brand; ./run.sh" } diff --git a/.devcontainer/team/devcontainer.json b/.devcontainer/team/devcontainer.json index 06046a1e..d828e707 100644 --- a/.devcontainer/team/devcontainer.json +++ b/.devcontainer/team/devcontainer.json @@ -4,5 +4,5 @@ "name": "Privacy Guides Team", "image": "ghcr.io/privacyguides/privacyguides.org:main", "forwardPorts": [8000], - "postCreateCommand": "git submodule init; git submodule update theme/assets/brand; mkdocs serve --dev-addr=0.0.0.0:8000 --config-file mkdocs-production.yml" + "postCreateCommand": "git submodule init; git submodule update theme/assets/brand; ./run.sh --cmd=mkdocs --insiders --production --cmd_flags=--dev-addr=0.0.0.0:8000" } diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 74faa83f..f53bf6c9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,62 +45,20 @@ jobs: run: | { echo "BUILD_CONTEXT=${{ inputs.context }}" - echo "BUILD_EDIT_URI_TEMPLATE=blob/main/docs/{path}?plain=1" - echo "BUILD_REPO_URL=https://github.com/privacyguides/privacyguides.org" - echo "PRODUCTION=true" + echo "EXTRA_FLAGS=""$EXTRA_FLAGS" --production"" } >> "$GITHUB_ENV" - name: Set Metadata for Privileged Builds if: inputs.privileged - run: echo "BUILD_INSIDERS=true" >> "$GITHUB_ENV" + run: | + echo "BUILD_INSIDERS=true" >> "$GITHUB_ENV" + echo "EXTRA_FLAGS=""$EXTRA_FLAGS" --insiders"" >> "$GITHUB_ENV" - name: Set Metadata for Offline Mode if: inputs.config == 'offline' run: | { - echo "BUILD_EDIT_URI_TEMPLATE=''" - echo "BUILD_OFFLINE=true" - echo "BUILD_REPO_URL=''" - echo "CARDS=false" - echo "HOMEPAGE_BUTTON_GET_STARTED_LINK=basics/why-privacy-matters.html" - echo "HOMEPAGE_BUTTON_TOOLS_LINK=tools.html" - } >> "$GITHUB_ENV" - - - name: Set Metadata for Translations - if: inputs.lang != 'en' - run: | - { - echo "BUILD_ABBREVIATIONS=includes/abbreviations.${{ inputs.lang }}.txt" - echo "BUILD_DOCS_DIR=i18n/${{ inputs.lang }}" - echo "BUILD_EDIT_URI_TEMPLATE=https://github.com/privacyguides/i18n/blob/main/i18n/${{ inputs.lang }}/{path}?plain=1" - echo "BUILD_SITE_DIR=site/${{ inputs.lang }}" - echo "BUILD_SITE_URL=https://privacyguides.org/${{ inputs.lang }}" - echo "BUILD_THEME_LANGUAGE=${{ inputs.lang }}" - } >> "$GITHUB_ENV" - - - name: Set Metadata for Hebrew Translation - if: inputs.lang == 'he' - run: | - { - echo "BUILD_THEME_FONT_CODE=Cousine" - echo "BUILD_THEME_FONT_TEXT=Open Sans" - echo "TRANSLATION_STYLESHEET=assets/stylesheets/lang-${{ inputs.lang }}.css?v=20240410" - } >> "$GITHUB_ENV" - - - name: Set Metadata for Russian Translation - if: inputs.lang == 'ru' - run: | - { - echo "TRANSLATION_STYLESHEET=assets/stylesheets/lang-${{ inputs.lang }}.css?v=20240410" - } >> "$GITHUB_ENV" - - - name: Set Metadata for Chinese (Traditional) Translation - if: inputs.lang == 'zh-Hant' - run: | - { - echo "BUILD_THEME_FONT_CODE=Noto Sans TC" - echo "BUILD_THEME_FONT_TEXT=Noto Sans TC" - echo "TRANSLATION_STYLESHEET=assets/stylesheets/lang-${{ inputs.lang }}.css?v=20240410" + echo "EXTRA_FLAGS=""$EXTRA_FLAGS" --offline"" } >> "$GITHUB_ENV" - name: Download Repository @@ -189,24 +147,10 @@ jobs: pip install mkdocs-material sudo apt install pngquant - - name: Set Translated String Environment Variables - uses: falti/dotenv-action@v1.1 - with: - path: includes/strings.${{ inputs.lang }}.env - export-variables: true - keys-case: bypass - - name: Build Website if: inputs.privileged run: | - pipenv run mkdocs build --config-file mkdocs-production.yml - pipenv run mkdocs --version - - - name: Build Website (Unprivileged) - if: ${{ !inputs.privileged }} - run: | - mkdocs build - mkdocs --version + eval ./run.sh --build --lang=${{ inputs.lang }} "$EXTRA_FLAGS" - name: Package Website run: | diff --git a/.gitignore b/.gitignore index e8ae2199..00a1e425 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ node_modules # Python .venv .env +.mkdocs-insiders-* diff --git a/.mailmap b/.mailmap new file mode 100644 index 00000000..65aefd6f --- /dev/null +++ b/.mailmap @@ -0,0 +1,16 @@ +Daniel Gray +Daniel Gray <48640805+dngray@users.noreply.github.com> +Daniel Gray +Daniel Gray +Jonah Aragon +Jonah Aragon +Jonah Aragon +mfwmyfacewhen <94880365+mfwmyfacewhen@users.noreply.github.com> +mbananasynergy <> +mbananasynergy <107055883+matchboxbananasynergy@users.noreply.github.com> +rollsicecream <153316540+rollsicecream@users.noreply.github.com> +rollsicecream +Freddy +Freddy +Niek de Wilde +Niek de Wilde diff --git a/Dockerfile b/Dockerfile index 6e038ede..39c666ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,7 +43,8 @@ RUN \ tini \ zlib-dev \ libffi-dev \ - musl-dev + musl-dev \ + bash # Copy virtual env from python-deps stage COPY --from=python-deps /.venv /.venv @@ -59,6 +60,7 @@ COPY theme theme COPY includes includes COPY *.yml . COPY .cache/plugin/social/fonts .cache/plugin/social/fonts +COPY run.sh . EXPOSE 8000 @@ -66,5 +68,5 @@ ENV MKDOCS_INHERIT mkdocs-production.yml HEALTHCHECK NONE -ENTRYPOINT ["mkdocs"] -CMD ["serve", "--dev-addr=0.0.0.0:8000", "--config-file=mkdocs-production.yml"] +ENTRYPOINT ["./run.sh"] +CMD ["--cmd=mkdocs", "--insiders", "--cmd_flags=--dev-addr=0.0.0.0:8000"] diff --git a/Pipfile b/Pipfile index 459a02ae..f54b7c23 100644 --- a/Pipfile +++ b/Pipfile @@ -26,7 +26,7 @@ name = "pypi" [packages] mkdocs-material = {extras = ["imaging"], path = "./modules/mkdocs-material"} mkdocs-git-revision-date-localized-plugin = "~=1.2" -mkdocs-git-committers-plugin-2 = "~=1.1" +mkdocs-git-authors-plugin = "~=0.8" mkdocs-macros-plugin = "~=1.0" jieba = "~=0.42" diff --git a/Pipfile.lock b/Pipfile.lock index cb9599cc..5ce05db7 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "93ebf65ff6386809b3bea7cadd6e1eb71f8b0bb066846d81ec8d95422d32af64" + "sha256": "ea18b0cfbbad56281087e2422684e4943753ad503e1319ef1f2f054b7a05f608" }, "pipfile-spec": 6, "requires": { @@ -24,14 +24,6 @@ "markers": "python_version >= '3.7'", "version": "==2.14.0" }, - "beautifulsoup4": { - "hashes": [ - "sha256:74e3d1928edc070d21748185c46e3fb33490f22f52a3addee9aee0f4f7781051", - "sha256:b80878c9f40111313e55da8ba20bdba06d8fa3969fc68304167741bbf9e082ed" - ], - "markers": "python_full_version >= '3.6.0'", - "version": "==4.12.3" - }, "cairocffi": { "hashes": [ "sha256:78e6bbe47357640c453d0be929fa49cd05cce2e1286f3d2a1ca9cbda7efdb8b7", @@ -287,167 +279,6 @@ "markers": "python_version >= '3.7'", "version": "==3.1.3" }, - "lxml": { - "hashes": [ - "sha256:04ab5415bf6c86e0518d57240a96c4d1fcfc3cb370bb2ac2a732b67f579e5a04", - "sha256:057cdc6b86ab732cf361f8b4d8af87cf195a1f6dc5b0ff3de2dced242c2015e0", - "sha256:058a1308914f20784c9f4674036527e7c04f7be6fb60f5d61353545aa7fcb739", - "sha256:08802f0c56ed150cc6885ae0788a321b73505d2263ee56dad84d200cab11c07a", - "sha256:0a15438253b34e6362b2dc41475e7f80de76320f335e70c5528b7148cac253a1", - "sha256:0c3f67e2aeda739d1cc0b1102c9a9129f7dc83901226cc24dd72ba275ced4218", - "sha256:0e7259016bc4345a31af861fdce942b77c99049d6c2107ca07dc2bba2435c1d9", - "sha256:0ed777c1e8c99b63037b91f9d73a6aad20fd035d77ac84afcc205225f8f41188", - "sha256:0f5d65c39f16717a47c36c756af0fb36144069c4718824b7533f803ecdf91138", - "sha256:0f8c09ed18ecb4ebf23e02b8e7a22a05d6411911e6fabef3a36e4f371f4f2585", - "sha256:11a04306fcba10cd9637e669fd73aa274c1c09ca64af79c041aa820ea992b637", - "sha256:1ae67b4e737cddc96c99461d2f75d218bdf7a0c3d3ad5604d1f5e7464a2f9ffe", - "sha256:1c5bb205e9212d0ebddf946bc07e73fa245c864a5f90f341d11ce7b0b854475d", - "sha256:1f7785f4f789fdb522729ae465adcaa099e2a3441519df750ebdccc481d961a1", - "sha256:200e63525948e325d6a13a76ba2911f927ad399ef64f57898cf7c74e69b71095", - "sha256:21c2e6b09565ba5b45ae161b438e033a86ad1736b8c838c766146eff8ceffff9", - "sha256:2213afee476546a7f37c7a9b4ad4d74b1e112a6fafffc9185d6d21f043128c81", - "sha256:27aa20d45c2e0b8cd05da6d4759649170e8dfc4f4e5ef33a34d06f2d79075d57", - "sha256:2a66bf12fbd4666dd023b6f51223aed3d9f3b40fef06ce404cb75bafd3d89536", - "sha256:2c9d147f754b1b0e723e6afb7ba1566ecb162fe4ea657f53d2139bbf894d050a", - "sha256:2ddfe41ddc81f29a4c44c8ce239eda5ade4e7fc305fb7311759dd6229a080052", - "sha256:31e9a882013c2f6bd2f2c974241bf4ba68c85eba943648ce88936d23209a2e01", - "sha256:3249cc2989d9090eeac5467e50e9ec2d40704fea9ab72f36b034ea34ee65ca98", - "sha256:3545039fa4779be2df51d6395e91a810f57122290864918b172d5dc7ca5bb433", - "sha256:394ed3924d7a01b5bd9a0d9d946136e1c2f7b3dc337196d99e61740ed4bc6fe1", - "sha256:3a6b45da02336895da82b9d472cd274b22dc27a5cea1d4b793874eead23dd14f", - "sha256:3a74c4f27167cb95c1d4af1c0b59e88b7f3e0182138db2501c353555f7ec57f4", - "sha256:3d0c3dd24bb4605439bf91068598d00c6370684f8de4a67c2992683f6c309d6b", - "sha256:3dbe858ee582cbb2c6294dc85f55b5f19c918c2597855e950f34b660f1a5ede6", - "sha256:3dc773b2861b37b41a6136e0b72a1a44689a9c4c101e0cddb6b854016acc0aa8", - "sha256:3e183c6e3298a2ed5af9d7a356ea823bccaab4ec2349dc9ed83999fd289d14d5", - "sha256:3f7765e69bbce0906a7c74d5fe46d2c7a7596147318dbc08e4a2431f3060e306", - "sha256:417d14450f06d51f363e41cace6488519038f940676ce9664b34ebf5653433a5", - "sha256:44f6c7caff88d988db017b9b0e4ab04934f11e3e72d478031efc7edcac6c622f", - "sha256:491755202eb21a5e350dae00c6d9a17247769c64dcf62d8c788b5c135e179dc4", - "sha256:4951e4f7a5680a2db62f7f4ab2f84617674d36d2d76a729b9a8be4b59b3659be", - "sha256:52421b41ac99e9d91934e4d0d0fe7da9f02bfa7536bb4431b4c05c906c8c6919", - "sha256:530e7c04f72002d2f334d5257c8a51bf409db0316feee7c87e4385043be136af", - "sha256:533658f8fbf056b70e434dff7e7aa611bcacb33e01f75de7f821810e48d1bb66", - "sha256:5670fb70a828663cc37552a2a85bf2ac38475572b0e9b91283dc09efb52c41d1", - "sha256:56c22432809085b3f3ae04e6e7bdd36883d7258fcd90e53ba7b2e463efc7a6af", - "sha256:58278b29cb89f3e43ff3e0c756abbd1518f3ee6adad9e35b51fb101c1c1daaec", - "sha256:588008b8497667f1ddca7c99f2f85ce8511f8f7871b4a06ceede68ab62dff64b", - "sha256:59565f10607c244bc4c05c0c5fa0c190c990996e0c719d05deec7030c2aa8289", - "sha256:59689a75ba8d7ffca577aefd017d08d659d86ad4585ccc73e43edbfc7476781a", - "sha256:5aea8212fb823e006b995c4dda533edcf98a893d941f173f6c9506126188860d", - "sha256:5c670c0406bdc845b474b680b9a5456c561c65cf366f8db5a60154088c92d102", - "sha256:5ca1e8188b26a819387b29c3895c47a5e618708fe6f787f3b1a471de2c4a94d9", - "sha256:5d077bc40a1fe984e1a9931e801e42959a1e6598edc8a3223b061d30fbd26bbc", - "sha256:5d5792e9b3fb8d16a19f46aa8208987cfeafe082363ee2745ea8b643d9cc5b45", - "sha256:5dd1537e7cc06efd81371f5d1a992bd5ab156b2b4f88834ca852de4a8ea523fa", - "sha256:5ea7b6766ac2dfe4bcac8b8595107665a18ef01f8c8343f00710b85096d1b53a", - "sha256:622020d4521e22fb371e15f580d153134bfb68d6a429d1342a25f051ec72df1c", - "sha256:627402ad8dea044dde2eccde4370560a2b750ef894c9578e1d4f8ffd54000461", - "sha256:644df54d729ef810dcd0f7732e50e5ad1bd0a135278ed8d6bcb06f33b6b6f708", - "sha256:64641a6068a16201366476731301441ce93457eb8452056f570133a6ceb15fca", - "sha256:64c2baa7774bc22dd4474248ba16fe1a7f611c13ac6123408694d4cc93d66dbd", - "sha256:6588c459c5627fefa30139be4d2e28a2c2a1d0d1c265aad2ba1935a7863a4913", - "sha256:66bc5eb8a323ed9894f8fa0ee6cb3e3fb2403d99aee635078fd19a8bc7a5a5da", - "sha256:68a2610dbe138fa8c5826b3f6d98a7cfc29707b850ddcc3e21910a6fe51f6ca0", - "sha256:6935bbf153f9a965f1e07c2649c0849d29832487c52bb4a5c5066031d8b44fd5", - "sha256:6992030d43b916407c9aa52e9673612ff39a575523c5f4cf72cdef75365709a5", - "sha256:6a014510830df1475176466b6087fc0c08b47a36714823e58d8b8d7709132a96", - "sha256:6ab833e4735a7e5533711a6ea2df26459b96f9eec36d23f74cafe03631647c41", - "sha256:6cc6ee342fb7fa2471bd9b6d6fdfc78925a697bf5c2bcd0a302e98b0d35bfad3", - "sha256:6cf58416653c5901e12624e4013708b6e11142956e7f35e7a83f1ab02f3fe456", - "sha256:70a9768e1b9d79edca17890175ba915654ee1725975d69ab64813dd785a2bd5c", - "sha256:70ac664a48aa64e5e635ae5566f5227f2ab7f66a3990d67566d9907edcbbf867", - "sha256:71e97313406ccf55d32cc98a533ee05c61e15d11b99215b237346171c179c0b0", - "sha256:7221d49259aa1e5a8f00d3d28b1e0b76031655ca74bb287123ef56c3db92f213", - "sha256:74b28c6334cca4dd704e8004cba1955af0b778cf449142e581e404bd211fb619", - "sha256:764b521b75701f60683500d8621841bec41a65eb739b8466000c6fdbc256c240", - "sha256:78bfa756eab503673991bdcf464917ef7845a964903d3302c5f68417ecdc948c", - "sha256:794f04eec78f1d0e35d9e0c36cbbb22e42d370dda1609fb03bcd7aeb458c6377", - "sha256:79bd05260359170f78b181b59ce871673ed01ba048deef4bf49a36ab3e72e80b", - "sha256:7a7efd5b6d3e30d81ec68ab8a88252d7c7c6f13aaa875009fe3097eb4e30b84c", - "sha256:7c17b64b0a6ef4e5affae6a3724010a7a66bda48a62cfe0674dabd46642e8b54", - "sha256:804f74efe22b6a227306dd890eecc4f8c59ff25ca35f1f14e7482bbce96ef10b", - "sha256:853e074d4931dbcba7480d4dcab23d5c56bd9607f92825ab80ee2bd916edea53", - "sha256:857500f88b17a6479202ff5fe5f580fc3404922cd02ab3716197adf1ef628029", - "sha256:865bad62df277c04beed9478fe665b9ef63eb28fe026d5dedcb89b537d2e2ea6", - "sha256:88e22fc0a6684337d25c994381ed8a1580a6f5ebebd5ad41f89f663ff4ec2885", - "sha256:8b9c07e7a45bb64e21df4b6aa623cb8ba214dfb47d2027d90eac197329bb5e94", - "sha256:8de8f9d6caa7f25b204fc861718815d41cbcf27ee8f028c89c882a0cf4ae4134", - "sha256:8e77c69d5892cb5ba71703c4057091e31ccf534bd7f129307a4d084d90d014b8", - "sha256:9123716666e25b7b71c4e1789ec829ed18663152008b58544d95b008ed9e21e9", - "sha256:958244ad566c3ffc385f47dddde4145088a0ab893504b54b52c041987a8c1863", - "sha256:96323338e6c14e958d775700ec8a88346014a85e5de73ac7967db0367582049b", - "sha256:9676bfc686fa6a3fa10cd4ae6b76cae8be26eb5ec6811d2a325636c460da1806", - "sha256:9b0ff53900566bc6325ecde9181d89afadc59c5ffa39bddf084aaedfe3b06a11", - "sha256:9b9ec9c9978b708d488bec36b9e4c94d88fd12ccac3e62134a9d17ddba910ea9", - "sha256:9c6ad0fbf105f6bcc9300c00010a2ffa44ea6f555df1a2ad95c88f5656104817", - "sha256:9ca66b8e90daca431b7ca1408cae085d025326570e57749695d6a01454790e95", - "sha256:9e2addd2d1866fe112bc6f80117bcc6bc25191c5ed1bfbcf9f1386a884252ae8", - "sha256:a0af35bd8ebf84888373630f73f24e86bf016642fb8576fba49d3d6b560b7cbc", - "sha256:a2b44bec7adf3e9305ce6cbfa47a4395667e744097faed97abb4728748ba7d47", - "sha256:a2dfe7e2473f9b59496247aad6e23b405ddf2e12ef0765677b0081c02d6c2c0b", - "sha256:a55ee573116ba208932e2d1a037cc4b10d2c1cb264ced2184d00b18ce585b2c0", - "sha256:a7baf9ffc238e4bf401299f50e971a45bfcc10a785522541a6e3179c83eabf0a", - "sha256:a8d5c70e04aac1eda5c829a26d1f75c6e5286c74743133d9f742cda8e53b9c2f", - "sha256:a91481dbcddf1736c98a80b122afa0f7296eeb80b72344d7f45dc9f781551f56", - "sha256:ab31a88a651039a07a3ae327d68ebdd8bc589b16938c09ef3f32a4b809dc96ef", - "sha256:abc25c3cab9ec7fcd299b9bcb3b8d4a1231877e425c650fa1c7576c5107ab851", - "sha256:adfb84ca6b87e06bc6b146dc7da7623395db1e31621c4785ad0658c5028b37d7", - "sha256:afbbdb120d1e78d2ba8064a68058001b871154cc57787031b645c9142b937a62", - "sha256:afd5562927cdef7c4f5550374acbc117fd4ecc05b5007bdfa57cc5355864e0a4", - "sha256:b070bbe8d3f0f6147689bed981d19bbb33070225373338df755a46893528104a", - "sha256:b0b58fbfa1bf7367dde8a557994e3b1637294be6cf2169810375caf8571a085c", - "sha256:b560e3aa4b1d49e0e6c847d72665384db35b2f5d45f8e6a5c0072e0283430533", - "sha256:b6241d4eee5f89453307c2f2bfa03b50362052ca0af1efecf9fef9a41a22bb4f", - "sha256:b6787b643356111dfd4032b5bffe26d2f8331556ecb79e15dacb9275da02866e", - "sha256:bcbf4af004f98793a95355980764b3d80d47117678118a44a80b721c9913436a", - "sha256:beb72935a941965c52990f3a32d7f07ce869fe21c6af8b34bf6a277b33a345d3", - "sha256:bf2e2458345d9bffb0d9ec16557d8858c9c88d2d11fed53998512504cd9df49b", - "sha256:c2d35a1d047efd68027817b32ab1586c1169e60ca02c65d428ae815b593e65d4", - "sha256:c38d7b9a690b090de999835f0443d8aa93ce5f2064035dfc48f27f02b4afc3d0", - "sha256:c6f2c8372b98208ce609c9e1d707f6918cc118fea4e2c754c9f0812c04ca116d", - "sha256:c817d420c60a5183953c783b0547d9eb43b7b344a2c46f69513d5952a78cddf3", - "sha256:c8ba129e6d3b0136a0f50345b2cb3db53f6bda5dd8c7f5d83fbccba97fb5dcb5", - "sha256:c94e75445b00319c1fad60f3c98b09cd63fe1134a8a953dcd48989ef42318534", - "sha256:cc4691d60512798304acb9207987e7b2b7c44627ea88b9d77489bbe3e6cc3bd4", - "sha256:cc518cea79fd1e2f6c90baafa28906d4309d24f3a63e801d855e7424c5b34144", - "sha256:cd53553ddad4a9c2f1f022756ae64abe16da1feb497edf4d9f87f99ec7cf86bd", - "sha256:cf22b41fdae514ee2f1691b6c3cdeae666d8b7fa9434de445f12bbeee0cf48dd", - "sha256:d38c8f50ecf57f0463399569aa388b232cf1a2ffb8f0a9a5412d0db57e054860", - "sha256:d3be9b2076112e51b323bdf6d5a7f8a798de55fb8d95fcb64bd179460cdc0704", - "sha256:d4f2cc7060dc3646632d7f15fe68e2fa98f58e35dd5666cd525f3b35d3fed7f8", - "sha256:d7520db34088c96cc0e0a3ad51a4fd5b401f279ee112aa2b7f8f976d8582606d", - "sha256:d793bebb202a6000390a5390078e945bbb49855c29c7e4d56a85901326c3b5d9", - "sha256:da052e7962ea2d5e5ef5bc0355d55007407087392cf465b7ad84ce5f3e25fe0f", - "sha256:dae0ed02f6b075426accbf6b2863c3d0a7eacc1b41fb40f2251d931e50188dad", - "sha256:ddc678fb4c7e30cf830a2b5a8d869538bc55b28d6c68544d09c7d0d8f17694dc", - "sha256:df2e6f546c4df14bc81f9498bbc007fbb87669f1bb707c6138878c46b06f6510", - "sha256:e02c5175f63effbd7c5e590399c118d5db6183bbfe8e0d118bdb5c2d1b48d937", - "sha256:e196a4ff48310ba62e53a8e0f97ca2bca83cdd2fe2934d8b5cb0df0a841b193a", - "sha256:e233db59c8f76630c512ab4a4daf5a5986da5c3d5b44b8e9fc742f2a24dbd460", - "sha256:e32be23d538753a8adb6c85bd539f5fd3b15cb987404327c569dfc5fd8366e85", - "sha256:e3d30321949861404323c50aebeb1943461a67cd51d4200ab02babc58bd06a86", - "sha256:e89580a581bf478d8dcb97d9cd011d567768e8bc4095f8557b21c4d4c5fea7d0", - "sha256:e998e304036198b4f6914e6a1e2b6f925208a20e2042563d9734881150c6c246", - "sha256:ec42088248c596dbd61d4ae8a5b004f97a4d91a9fd286f632e42e60b706718d7", - "sha256:efa7b51824aa0ee957ccd5a741c73e6851de55f40d807f08069eb4c5a26b2baa", - "sha256:f0a1bc63a465b6d72569a9bba9f2ef0334c4e03958e043da1920299100bc7c08", - "sha256:f18a5a84e16886898e51ab4b1d43acb3083c39b14c8caeb3589aabff0ee0b270", - "sha256:f2a9efc53d5b714b8df2b4b3e992accf8ce5bbdfe544d74d5c6766c9e1146a3a", - "sha256:f3bbbc998d42f8e561f347e798b85513ba4da324c2b3f9b7969e9c45b10f6169", - "sha256:f42038016852ae51b4088b2862126535cc4fc85802bfe30dea3500fdfaf1864e", - "sha256:f443cdef978430887ed55112b491f670bba6462cea7a7742ff8f14b7abb98d75", - "sha256:f51969bac61441fd31f028d7b3b45962f3ecebf691a510495e5d2cd8c8092dbd", - "sha256:f8aca2e3a72f37bfc7b14ba96d4056244001ddcc18382bd0daa087fd2e68a354", - "sha256:f9737bf36262046213a28e789cc82d82c6ef19c85a0cf05e75c670a33342ac2c", - "sha256:fd6037392f2d57793ab98d9e26798f44b8b4da2f2464388588f48ac52c489ea1", - "sha256:feaa45c0eae424d3e90d78823f3828e7dc42a42f21ed420db98da2c4ecf0a2cb", - "sha256:ff097ae562e637409b429a7ac958a20aab237a0378c42dabaa1e3abf2f896e5f", - "sha256:ff46d772d5f6f73564979cd77a4fffe55c916a05f3cb70e7c9c0590059fb29ef" - ], - "markers": "python_version >= '3.6'", - "version": "==5.2.1" - }, "markdown": { "hashes": [ "sha256:48f276f4d8cfb8ce6527c8f79e2ee29708508bf4d40aa410fbc3b4ee832c850f", @@ -538,14 +369,14 @@ "markers": "python_version >= '3.7'", "version": "==1.5.3" }, - "mkdocs-git-committers-plugin-2": { + "mkdocs-git-authors-plugin": { "hashes": [ - "sha256:0bb5d71cdd9d43fec0dec16e52a9aad2784256b0fa6ef9bb0cceffc36c081ab3", - "sha256:921da26b3f4393e6c170279ac34089151dfc22cd29ec4fbce3506218541685c8" + "sha256:0614f4f87d31eabd0a0d607c9e0532608fc593997ebee282ec564ee6dc1c041e", + "sha256:10dfc57fb10d5c3aceb0e5cdea199ac3a7588979f26484eba46d935dc1044c26" ], "index": "pypi", - "markers": "python_version >= '3.8' and python_version < '4'", - "version": "==1.2.0" + "markers": "python_version >= '3.7'", + "version": "==0.8.0" }, "mkdocs-git-revision-date-localized-plugin": { "hashes": [ @@ -912,14 +743,6 @@ "markers": "python_version >= '3.7'", "version": "==5.0.1" }, - "soupsieve": { - "hashes": [ - "sha256:5663d5a7b3bfaeee0bc4372e7fc48f9cff4940b3eec54a6451cc5299f1097690", - "sha256:eaa337ff55a1579b6549dc679565eac1e3d000563bcb1c8ab0d0fefbc0c2cdc7" - ], - "markers": "python_version >= '3.8'", - "version": "==2.5" - }, "termcolor": { "hashes": [ "sha256:9297c0df9c99445c2412e832e882a7884038a25617c60cea2ad69488d4040d63", diff --git a/README.md b/README.md index bc63e5c6..6ba9f063 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ Committing to this repository requires [signing your commits](https://docs.githu ### With `mkdocs-material` 1. Install required packages: `pip install mkdocs-material` -2. Run a local preview of the English site: `mkdocs serve` +2. Run a local preview of the English site: `./run.sh` ### With `mkdocs-material-insiders` @@ -126,13 +126,22 @@ This website uses [`mkdocs-material-insiders`](https://squidfunk.github.io/mkdoc 3. Install Python **3.12**. 4. Install **pipenv**: `pip install pipenv` 5. Install dependencies: `pipenv install --dev` (install [Pillow and CairoSVG](https://squidfunk.github.io/mkdocs-material/setup/setting-up-social-cards/#dependencies) as well to generate social cards) -6. Serve the site locally: `pipenv run mkdocs serve --config-file mkdocs-production.yml` (set `CARDS=true` to generate social cards) +6. Serve the site locally: `./run.sh --insiders` (set `CARDS=true` to generate social cards) - The site will be available at `http://localhost:8000` - - You can build the site locally with `pipenv run mkdocs build --config-file mkdocs-production.yml` + - You can build the site locally with `./run.sh --insiders --build` - This version of the site should be identical to the live, production version If you commit to `main` with commits signed with your SSH key, you should add your SSH key to [`.allowed_signers`](/.allowed_signers) in this repo. +### Local Translated Site Builds + +1. Install the [Crowdin CLI Tool](https://developer.crowdin.com/cli-tool) (`brew install crowdin`) +2. Set the `CROWDIN_PERSONAL_TOKEN` environment variable to your Crowdin personal access token +3. Run `crowdin download` in the root of this repo +4. Serve the site locally: `./run.sh --insiders --lang=fr` (replacing fr with the appropriate language in [/config](/config)) + +Translations downloaded from Crowdin are [.gitignore](/.gitignore)'d, so any local changes to the translated site cannot be committed to this repo. Actual modifications need to be made on Crowdin. As an alternative to steps 1-3, you can copy the folders from [privacyguides/i18n](https://github.com/privacyguides/i18n) to the root of this repo to obtain the translated files. + ## Releasing It is required to create a GitHub release to publish the current site to privacyguides.org. The current `main` branch can be previewed at [https://main.staging.privacyguides.dev](https://main.staging.privacyguides.dev) prior to release. diff --git a/mkdocs-production.yml b/mkdocs-production.yml deleted file mode 100644 index 39b89a33..00000000 --- a/mkdocs-production.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2022-2024 Jonah Aragon - -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: - -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. - -INHERIT: mkdocs.yml - -markdown_extensions: - material.extensions.preview: - sources: - exclude: - - tools.md diff --git a/mkdocs.yml b/mkdocs.yml index 65cbdba9..132439d5 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -319,15 +319,18 @@ plugins: plugins: macros: {} meta: {} - git-committers: - enabled: !ENV [GITCOMMITTERS, PRODUCTION, NETLIFY, false] - repository: privacyguides/privacyguides.org - branch: main + git-authors: + enabled: !ENV [GITAUTHORS, PRODUCTION, NETLIFY, false] + sort_authors_by: contribution + show_contribution: true + fallback_to_empty: true + authorship_threshold_percent: 1 git-revision-date-localized: enabled: !ENV [GITREVISIONDATE, PRODUCTION, NETLIFY, false] exclude: - index.md fallback_to_build_date: true + enable_creation_date: true optimize: enabled: !ENV [OPTIMIZE, PRODUCTION, NETLIFY, false] typeset: {} diff --git a/run.sh b/run.sh new file mode 100755 index 00000000..9bed5a3a --- /dev/null +++ b/run.sh @@ -0,0 +1,140 @@ +#!/bin/bash + +# Add --help output +if [ "$1" == "--help" ]; then + echo "Usage: ./run.sh [options]" + echo "Options:" + echo " --lang= (default: en) Language code for the site" + echo " --insiders Enable insiders mode" + echo ' --cmd="" Base command to run mkdocs' + echo ' (default: "pipenv run mkdocs")' + echo ' --cmd_flags="" Flags to pass to the base command' + echo " --build Build the site instead of serving it" + echo " --offline Build the site in offline mode" + echo " --production Build the site in production mode" + echo "" + echo "Examples:" + echo " $ bash run.sh" + echo " $ bash run.sh --lang=ru --insiders" + echo ' $ bash run.sh --cmd="mkdocs" --cmd_flags="--dev-addr=0.0.0.0:8000"' + echo " $ bash run.sh --build" + exit +fi + +# Defaults +build=false +language="en" +base_cmd="pipenv run mkdocs" +offline=false +cmd_flags=() +insiders=false +export PRODUCTION=false + +# Parse command-line arguments +for arg in "$@" +do + case $arg in + --lang=*) + language="${arg#*=}" + shift + ;; + --insiders) + insiders=true + shift + ;; + --cmd=*) + base_cmd="${arg#*=}" + shift + ;; + --build) + build=true + shift + ;; + --offline) + offline=true + shift + ;; + --production) + export PRODUCTION=true + shift + ;; + --cmd_flags=*) + cmd_flags+=("${arg#*=}") + shift + ;; + *) + shift + ;; + esac +done + +# Set variables for offline mode +if $offline ; then + export BUILD_EDIT_URI_TEMPLATE='' + export BUILD_OFFLINE=true + export BUILD_REPO_URL='' + export CARDS=false + export HOMEPAGE_BUTTON_GET_STARTED_LINK="basics/why-privacy-matters.html" + export HOMEPAGE_BUTTON_TOOLS_LINK="tools.html" +fi + +# Set environment variables if language is not en +if [ "$language" != "en" ]; then + export BUILD_ABBREVIATIONS="includes/abbreviations.$language.txt" + export BUILD_DOCS_DIR="i18n/$language" + export BUILD_EDIT_URI_TEMPLATE="https://github.com/privacyguides/i18n/blob/main/i18n/$language/{path}?plain=1" + export BUILD_SITE_DIR="site/$language" + export BUILD_SITE_URL="https://privacyguides.org/$language" + export BUILD_THEME_LANGUAGE="$language" + set -a + # shellcheck disable=SC1090 + source "$PWD/includes/strings.$language.env" + set +a +fi + +# Set font if hebrew +if [ "$language" == "he" ]; then + export BUILD_THEME_FONT_CODE="Cousine" + export BUILD_THEME_FONT_TEXT="Open Sans" +fi + +# Set font if chinese +if [ "$language" == "zh-Hant" ]; then + export BUILD_THEME_FONT_CODE="Noto Sans TC" + export BUILD_THEME_FONT_TEXT="Noto Sans TC" +fi + +# Set stylesheet if hebrew or russian or chinese +if [[ "he ru zh-Hant" =~ $language ]]; then + export TRANSLATION_STYLESHEET="assets/stylesheets/lang-$language.css?v=20240410" +fi + +# Set theme if insiders +if $insiders ; then + random_num=$RANDOM + export BUILD_INSIDERS=true + cmd_flags+=("--config-file=$PWD/.mkdocs-insiders-$random_num.yml") + touch "$PWD/.mkdocs-insiders-$random_num.yml" + cat <> "$PWD/.mkdocs-insiders-$random_num.yml" +INHERIT: mkdocs.yml + +watch: + - theme + - includes + - mkdocs.yml + +markdown_extensions: + material.extensions.preview: + sources: + exclude: + - tools.md +EOT + trap 'rm $PWD/.mkdocs-insiders-$random_num.yml' EXIT +fi + +# Run the command with the specified language +if $build ; then + $base_cmd build "${cmd_flags[@]}" +else + $base_cmd serve "${cmd_flags[@]}" +fi diff --git a/theme/partials/content.html b/theme/partials/content.html index 734f1227..a8d4cc88 100644 --- a/theme/partials/content.html +++ b/theme/partials/content.html @@ -19,11 +19,12 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + {{ config.extra.privacy_guides.translation_stylesheet | url }} --> {% if page and page.meta and page.meta.cover %}
- +

{{ page.title | d(config.site_name, true)}}

{% endif %} diff --git a/theme/partials/source-file.html b/theme/partials/source-file.html new file mode 100644 index 00000000..ff9cd460 --- /dev/null +++ b/theme/partials/source-file.html @@ -0,0 +1,103 @@ + + + +{% macro render_updated(date) %} + + + {% include ".icons/material/clock-edit-outline.svg" %} + + {{ date }} + +{% endmacro %} + + +{% macro render_created(date) %} + + + {% include ".icons/material/clock-plus-outline.svg" %} + + {{ date }} + +{% endmacro %} + + + + +{% macro render_authors(authors) %} + {% set git_authors = config.plugins.get("git-authors") %} + + + {% if authors | length == 1 %} + {% include ".icons/material/account.svg" %} + {% else %} + {% include ".icons/material/account-group.svg" %} + {% endif %} + + + +{% endmacro %} + + + + + +{% if page.meta %} + {% if page.meta.git_revision_date_localized %} + {% set updated = page.meta.git_revision_date_localized %} + {% elif page.meta.revision_date %} + {% set updated = page.meta.revision_date %} + {% endif %} + + + {% if page.meta.git_creation_date_localized %} + {% set created = page.meta.git_creation_date_localized %} + {% endif %} +{% endif %} + + +{% if updated or created or git_info %} + +{% endif %}