diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000000..032b212400 --- /dev/null +++ b/Containerfile @@ -0,0 +1,41 @@ +ARG builder_image +FROM ${builder_image} AS builder + +ARG repo_org=CSCfi +ARG repo_name=csc-user-guide +ARG repo_branch=master + +ADD .git-revision-date-ignore-revs mkdocs.yml . + +RUN \ + git clone --no-checkout \ + --single-branch \ + --branch=${repo_branch} \ + https://github.com/${repo_org}/${repo_name} \ + /tmp/src \ +&& \ + git -C /tmp/src sparse-checkout init --no-cone \ +&& \ + git -C /tmp/src sparse-checkout set docs \ +&& \ + git -C /tmp/src checkout \ +&& \ + mv /tmp/src/{.git,docs} ./ \ +&& \ + for feat in new glossary; do \ + bash scripts/generate_${feat}.sh; \ + done \ +&& \ + mkdocs build --site-dir=/tmp/site + + +FROM registry.access.redhat.com/ubi8/nginx-124 + +LABEL maintainer="CSC Service Desk " + +COPY --from=builder /tmp/site "${NGINX_APP_ROOT}/src" +ADD nginx.conf "${NGINX_CONF_PATH}" + +EXPOSE 8000/tcp + +CMD nginx diff --git a/Containerfile.alternate b/Containerfile.alternate new file mode 100644 index 0000000000..f01a5a09f6 --- /dev/null +++ b/Containerfile.alternate @@ -0,0 +1,91 @@ +ARG restic_image=ghcr.io/restic/restic +ARG translator_image +ARG builder_image +ARG nginx_image=ubi8/nginx-124 + +FROM ${restic_image} AS restic_snapshots + +RUN \ + restic --json snapshots --path /tmp/docs/${LANG_CODE} \ + > /tmp/snapshots.json \ +&& \ + restic restore --exclude-xattr '*' \ + --path /tmp/docs/${LANG_CODE} \ + --target /tmp/stale_translation \ + latest + + +FROM ${translator_image} AS translator + +ARG repo_org=CSCfi +ARG repo_name=csc-user-guide +ARG repo_branch=master +ENV REPO_ORG=${repo_org} +ENV REPO_NAME=${repo_name} +ENV REPO_BRANCH=${repo_branch} + +COPY --from=restic_snapshots /tmp/snapshots.json . +COPY --from=restic_snapshots /tmp/stale_translation /tmp/fresh_translation +ADD translation/exclude.txt translation/force.yml translation/dictionary.yml . + +USER 0 +RUN chown -R 1001:0 /tmp/fresh_translation snapshots.json +USER 1001 + +RUN python3 refresh_translation.py /tmp/fresh_translation \ + /tmp/commit_sha.txt + + +FROM restic_snapshots AS restic_backup + +COPY --from=translator /tmp/fresh_translation /tmp/docs/${LANG_CODE} +COPY --from=translator /tmp/commit_sha.txt /tmp + +RUN \ + cd /tmp/docs/${LANG_CODE} \ +&& \ + restic backup --tag "$(cat /tmp/commit_sha.txt)" \ + --exclude '.*' \ + --iexclude '* !*.md' \ + --skip-if-unchanged \ + ./ + + +FROM ${builder_image} AS builder + +ADD docs /tmp/src/docs +ADD .git-revision-date-ignore-revs mkdocs_${LANG_CODE}.yml . +COPY --from=translator /tmp/fresh_translation /tmp/fresh_translation +COPY --from=translator /tmp/.git /tmp/src/.git + +USER 0 +RUN \ + mv /tmp/src/{.git,docs} . \ +&& \ + cp --recursive \ + --no-dereference \ + --remove-destination \ + /tmp/fresh_translation/* docs \ +&& \ + chown -R 1001:0 ./ +USER 1001 + +RUN \ + for feat in new glossary; do \ + bash scripts/generate_${feat}.sh; \ + done \ +&& \ + mkdocs build --site-dir=/tmp/site \ + --config-file="mkdocs_${LANG_CODE}.yml" + + +FROM ${nginx_image} + +LABEL maintainer="CSC Service Desk " + +COPY --from=builder /tmp/site "${NGINX_APP_ROOT}/src" +ADD nginx.conf "${NGINX_CONF_PATH}" + +EXPOSE 8000/tcp + +CMD nginx diff --git a/Containerfile.builder b/Containerfile.builder new file mode 100644 index 0000000000..96e0047d5a --- /dev/null +++ b/Containerfile.builder @@ -0,0 +1,21 @@ +ARG python_image=ubi8/python-311 +FROM ${python_image} + +LABEL maintainer="CSC Service Desk " + +ADD requirements.txt mkdocs.yml . +ADD csc-overrides ./csc-overrides +ADD hooks ./hooks +ADD scripts ./scripts + +USER 0 +RUN \ + mkdir /tmp/src \ +&& \ + chown -R 1001:0 /tmp/src ./ +USER 1001 + +RUN \ + pip install --upgrade pip \ +&& \ + pip install --requirement=requirements.txt diff --git a/Containerfile.translator b/Containerfile.translator new file mode 100644 index 0000000000..c376656604 --- /dev/null +++ b/Containerfile.translator @@ -0,0 +1,12 @@ +ARG python_image=ubi8/python-311 +FROM ${python_image} + +LABEL maintainer="CSC Service Desk " + +ADD translation/requirements.txt translation/refresh_translation.py . +ADD translation/translator ./translator + +RUN \ + pip install --upgrade pip \ +&& \ + pip install --requirement requirements.txt diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 665b3b5816..0000000000 --- a/Dockerfile +++ /dev/null @@ -1,43 +0,0 @@ -FROM rockylinux:8 - -LABEL maintainer="CSC Service Desk " - -# These need to be owned and writable by the root group in OpenShift -ENV ROOT_GROUP_DIRS='/var/run /var/log/nginx /var/lib/nginx' - -ARG repo_org=CSCfi -ARG repo_name=csc-user-guide -ARG repo_branch=master - -COPY requirements.txt /tmp - -WORKDIR /tmp - -RUN dnf -y install epel-release \ - nginx \ - python3.11 \ - python3.11-pip \ - git \ - findutils &&\ - dnf clean all &&\ - pip3 install --use-pep517 --no-cache-dir -r requirements.txt - -RUN chgrp -R root ${ROOT_GROUP_DIRS} &&\ - chmod -R g+rwx ${ROOT_GROUP_DIRS} - -COPY . /tmp - -RUN if [ ! -d ".git" ]; then \ - git clone --bare --single-branch --branch=$repo_branch https://github.com/$repo_org/$repo_name .git && \ - git init && \ - git switch --force $repo_branch; \ - fi && \ - bash scripts/generate_new.sh && \ - bash scripts/generate_glossary.sh && \ - mkdocs build -d /usr/share/nginx/html - -COPY nginx.conf /etc/nginx - -EXPOSE 8000 - -CMD [ "/usr/sbin/nginx" ] diff --git a/csc-overrides/404.html b/csc-overrides/404.html index 39c44fe8d1..41f783ba49 100644 --- a/csc-overrides/404.html +++ b/csc-overrides/404.html @@ -1,15 +1,29 @@ {% extends "main.html" %} {% block htmltitle %} +{% if config.theme.language == 'fi' %} +Sivua ei löydy - Docs CSC +{% else %} Page not found - Docs CSC +{% endif %} {% endblock htmltitle %} {% block content %} {% block breadcrumbs %} {% endblock breadcrumbs %} +{% if config.theme.language == 'fi' %} +

Virhe 404: Sivua ei löydy

+

Pahoittelumme, mutta etsimääsi sisältöä ei löytynyt

+

Kokeile etsiä sisältöä hakutoiminnon avulla tai palata takaisin etusivulle.

+{% else %}

Error 404: Page not found

Sorry, we couldn't find what you're looking for

Please retry looking for the content using the search function, or return to the Home page.

+{% endif %} {% endblock content %} diff --git a/csc-overrides/assets/stylesheets/catalog.css b/csc-overrides/assets/stylesheets/catalog.css index 6293be63c3..6284d5ce3a 100644 --- a/csc-overrides/assets/stylesheets/catalog.css +++ b/csc-overrides/assets/stylesheets/catalog.css @@ -52,7 +52,6 @@ } .md-typeset .catalog-toc ul li a[href^="#lumi"] .md-tag:is(:active, :hover) { - /* background-color: hsl(from black h s calc(l + 96)); */ background-color: var(--c-black); color: var(--c-white); } diff --git a/csc-overrides/assets/stylesheets/disclaimer.css b/csc-overrides/assets/stylesheets/disclaimer.css index 102e7b04d0..26c329ea90 100644 --- a/csc-overrides/assets/stylesheets/disclaimer.css +++ b/csc-overrides/assets/stylesheets/disclaimer.css @@ -7,6 +7,10 @@ max-width: calc(100vw / 3); } +#disclaimer-container > :not(:first-child) { + margin-top: .5rem; +} + .disclaimer { display: none; border-style: solid; @@ -23,6 +27,10 @@ border-color: var(--csc-admonition-info-border-color); } +.disclaimer.translation { + border-color: var(--csc-admonition-warning-border-color); +} + .disclaimer > .disclaimer-title { margin: unset; padding: .4rem .6rem .4rem 2rem; @@ -51,6 +59,12 @@ background-color: var(--csc-admonition-info-border-color); } +.disclaimer.translation > .disclaimer-title:before { + -webkit-mask-image: var(--md-admonition-icon--warning); + mask-image: var(--md-admonition-icon--warning); + background-color: var(--csc-admonition-warning-border-color); +} + .disclaimer > .disclaimer-content { margin-top: 0; font-style: italic; @@ -72,6 +86,7 @@ .disclaimer .button-row { margin: .6em; display: flex; + flex-direction: row-reverse; justify-content: space-between; } diff --git a/csc-overrides/main.html b/csc-overrides/main.html index 7c0846868b..99f4faa16b 100644 --- a/csc-overrides/main.html +++ b/csc-overrides/main.html @@ -18,7 +18,8 @@ {% endblock content %} {% block footer %} {{ super() }} - {% if config.extra.environment == "preview" %} + {% if config.extra.environment == "preview" or + config.theme.language != "en" %} {% include "partials/disclaimer.html" %} {% endif %} {% endblock footer %} diff --git a/csc-overrides/partials/apps-list-item.html b/csc-overrides/partials/apps-list-item.html index e214498879..59fc31d963 100644 --- a/csc-overrides/partials/apps-list-item.html +++ b/csc-overrides/partials/apps-list-item.html @@ -17,8 +17,9 @@ {%- endmacro -%} {%- macro description(app) -%} -{%- if app.description -%} - — {{ app.description }} +{%- set app_desc = app["description_" ~ config.theme.language] or app.description %} +{%- if app_desc -%} + — {{ app_desc }} {%- elif app.unchecked -%} * {%- endif -%} diff --git a/csc-overrides/partials/apps-list-phrases.html b/csc-overrides/partials/apps-list-phrases.html new file mode 100644 index 0000000000..30d1b0359d --- /dev/null +++ b/csc-overrides/partials/apps-list-phrases.html @@ -0,0 +1,22 @@ +{%- macro translate(phrase_string, lang_code) -%} +{% set lookup = { + "Applications available on": { + "fi": "Sovellukset saatavilla järjestelmässä" + }, + "Interactive web applications available on": { + "fi": "Interaktiiviset web-sovellukset saatavilla järjestelmässä" + }, + "web interface": { + "fi": "web-käyttöliittymä" + } +}%} +{{ lookup[phrase_string][lang_code] }} +{%- endmacro -%} + +{%- macro phrase(phrase_string) -%} +{%- if config.theme.language != "en" -%} +{{ translate(phrase_string, lang_code=config.theme.language) }} +{%- else -%} +{{ phrase_string }} +{%- endif -%} +{%- endmacro -%} diff --git a/csc-overrides/partials/apps-list.html b/csc-overrides/partials/apps-list.html index 4d04d401ce..af8057dbf1 100644 --- a/csc-overrides/partials/apps-list.html +++ b/csc-overrides/partials/apps-list.html @@ -1,4 +1,5 @@ {% from "partials/apps-list-item.html" import app_item with context %} +{% from "partials/apps-list-phrases.html" import phrase with context %} {% macro as_heading(item, alpha=false) %} {% set level = 2 if not alpha else 3 %} @@ -59,16 +60,16 @@ {% elif "by_discipline" in catalog %} {{ as_groups(catalog.by_discipline) }} {% elif "by_availability" in catalog %} -

Applications available on

+

{{ phrase("Applications available on") }}

{{ as_toc(catalog.by_availability.on_systems) }} -

Interactive web applications available on

-{{ as_toc(catalog.by_availability.on_web, suffix="web interface") }} +

{{ phrase("Interactive web applications available on") }}

+{{ as_toc(catalog.by_availability.on_web, suffix=phrase("web interface")) }} {%- for system in catalog.by_availability.on_systems %} {{ as_heading(system) }} {{ as_list(system.apps) }} {% endfor -%} {%- for system in catalog.by_availability.on_web %} -{% set web_system = {"name": system.name ~ " " ~ "web interface", "id": system.id} %} +{% set web_system = {"name": system.name ~ " " ~ phrase("web interface"), "id": system.id} %} {{ as_heading(web_system) }} {{ as_list(system.apps) }} {% endfor -%} diff --git a/csc-overrides/partials/disclaimer.html b/csc-overrides/partials/disclaimer.html index 0e920b2afd..484534c20a 100644 --- a/csc-overrides/partials/disclaimer.html +++ b/csc-overrides/partials/disclaimer.html @@ -1,5 +1,15 @@ {% from "partials/commit.html" import commit_link %}
+ {% if config.theme.language == "fi" %} +
+

Suomenkielinen konekäännös

+

Sisällössä voi esiintyä virheellistä tietoa konekäännöksestä johtuen.

+ +
+ {% endif %} + {% if config.extra.environment == "preview" %}

You are viewing a development build

The content on this page has not been approved for release.

@@ -7,10 +17,11 @@ {{ commit_link(page.git.head, config.repo_url, status=page.git.status) }} {% endif %}
+ {% endif %}