diff --git a/src/hub/settings/base.py b/src/hub/settings/base.py index 262abdcd744d3120331e723228ed5968122f6eeb..2a35d0ed6789d6fb904052abf42218b68fa45c00 100644 --- a/src/hub/settings/base.py +++ b/src/hub/settings/base.py @@ -52,6 +52,7 @@ env = environ.FileAwareEnv( PRETIX_SECRET=(str, None), METRICS_SERVER_IPS=(list, ['*']), TIMEZONE=(str, 'Europe/Berlin'), + ARCHIVE_MODE=(bool, False), BIGBLUEBUTTON=(bool, False), BIGBLUEBUTTON_API_URL=(str, None), BIGBLUEBUTTON_API_TOKEN=(str, None), @@ -577,6 +578,9 @@ SELECTED_CONFERENCE_ID = env('SELECTED_CONFERENCE_ID') # PlainUI Configuration # ---------------------------------- +# archive mode disables user login etc. +ARCHIVE_MODE = env('ARCHIVE_MODE') + # Absolute url to use when dereferring links. Replaces `{quoted_target}` with the urlquoted target url # If you modify this on a non-empty database you should run `manage.py rerender_markdown` to update cashed markdown that contains old urls. PLAINUI_DEREFERER_URL = env('PLAINUI_DEREFERER_URL') diff --git a/src/plainui/jinja2.py b/src/plainui/jinja2.py index 3414a89661d039a86c0304878e90720c912e7f6e..c33949e63057e6487716b007a34d4eb5ccaf97b0 100644 --- a/src/plainui/jinja2.py +++ b/src/plainui/jinja2.py @@ -1,5 +1,6 @@ import re from datetime import datetime, timedelta +from django.conf import settings from typing import Any from jinja2 import Environment, pass_context @@ -275,6 +276,7 @@ def environment(**options): env = MyEnvironment(**{'extensions': ['jinja2.ext.i18n', 'jinja2.ext.debug'], **options}) env.globals.update( { + 'archive_mode': settings.ARCHIVE_MODE, 'browser_type': browser_type, 'build_report_url': build_report_url, 'css_scope': css_scope, diff --git a/src/plainui/jinja2/plainui/badge_list.html.j2 b/src/plainui/jinja2/plainui/badge_list.html.j2 index 2327d81380445dcb9e63b21b9ca487fe94996fca..c0ee0839d6ea0113a5da29fddab04b4f6e394b32 100644 --- a/src/plainui/jinja2/plainui/badge_list.html.j2 +++ b/src/plainui/jinja2/plainui/badge_list.html.j2 @@ -17,6 +17,7 @@ {{ wikiMacro.card('_intro_badges', class="hub-col-remaining") }} <div class="hub-card hub-col-325px"> <h2 class="hub-section-title">{{ _("Redeem badge") }}</h2> + {% if not archive_mode %} <form method="POST" action="{{ url("plainui:manage_badges") }}{%- if request.GET.next -%}?next={{ request.GET.next }}{%- endif -%}" @@ -36,6 +37,9 @@ {{ _("Manage badges") }} </a> </div> + {% else %} + {{ _('archivemode_notavailable') }} + {% endif %} </div> </div> @@ -65,10 +69,12 @@ ) }} {% endfor %} + {% if not archive_mode %} <div class="hub-tag-divider"></div> {{ tagbox.filter(_("yours"), 'owned', 'true') }} {{ tagbox.filter(_("missing"), 'owned', 'false') }} + {% endif %} </div> <div class="hub-card"> diff --git a/src/plainui/jinja2/plainui/board.html b/src/plainui/jinja2/plainui/board.html index 9eb445d73d5f8be0884ef293ea8371b2bc95230a..f13e18ec409624533259a6199a91f9a81935753b 100644 --- a/src/plainui/jinja2/plainui/board.html +++ b/src/plainui/jinja2/plainui/board.html @@ -7,6 +7,7 @@ {% block content %} {% if private %}{{ navMacro.top_nav(_("My Bulletin Board")) }}{%else%}{{ navMacro.top_nav(_("Bulletin Board")) }}{%endif%} + {% if not archive_mode %} <div class="my-3"> <ul class="mb-0 list-unstyled d-flex justify-content-center"> {% if current_user and not private %} @@ -81,4 +82,7 @@ {%- endif %} </ul> </div> + {% else %}{# archive mode #} + {{ _('archivemode_notavailable') }} + {% endif %} {% endblock %} diff --git a/src/plainui/jinja2/plainui/components/function_btns.html b/src/plainui/jinja2/plainui/components/function_btns.html index b7769a9e05725977907c42ea06fef253ab3a5d3e..08aeff647ed7345b102c3a1886555ba38ce66123 100644 --- a/src/plainui/jinja2/plainui/components/function_btns.html +++ b/src/plainui/jinja2/plainui/components/function_btns.html @@ -6,6 +6,7 @@ #} {% macro fav(fav_id, fav_type, fav_is, color="transparent", next=request.get_full_path() ) -%} + {% if not archive_mode %} <form action="{{ url('plainui:modify_favorites') }}" class="d-inline-block" method="POST"> {{ csrf_input }} <input type="hidden" name="next" value="{{ next ~ '#fav_' ~ fav_id}}"> @@ -29,9 +30,11 @@ </button> {% endif -%} </form> + {% endif %} {%- endmacro %} {% macro schedule(sch_id, sch_is, color="transparent", next=request.get_full_path() ) -%} + {% if not archive_mode %} <form action="{{ url('plainui:modify_personal_calendar') }}" class="d-inline-block" method="POST"> {{ csrf_input }} <input type="hidden" name="next" value="{{ next ~ '#sch_' ~ sch_id }}"> @@ -53,6 +56,7 @@ </button> {% endif -%} </form> + {% endif %} {%- endmacro %} {% macro share(view_name, title=_("share this "), color="transparent") -%} @@ -74,18 +78,22 @@ {%- endmacro %} # {% macro report(report_url=none, kind=none, next=none, lookup_key=none, title=_("report this url"), color="transparent" ) -%} + {% if not archive_mode %} <a href="{{ build_report_url(request, reported_url=report_url, kind=kind, next_url=next, lookup_key=lookup_key) }}" class="me-2 btn-icon-big btn btn-{{ color }}" title="{{ title }}"> <svg width="1.25rem" height="1.25rem" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500" style="enable-background:new 0 0 500 500" fill="currentColor"> <style>.st0{display:none}.st1{display:inline}.st2{fill:none;stroke:#000;stroke-width:18;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10}</style> <g><path d="M248.37 310.4c-9.86 0-16.38 1.9-19.56 5.7-3.19 3.8-4.78 10.01-4.78 18.63 0 8.83 1.59 15.1 4.78 18.79 3.18 3.7 9.7 5.54 19.56 5.54 9.85 0 16.32-1.85 19.4-5.54 3.08-3.7 4.62-9.96 4.62-18.79 0-8.62-1.53-14.83-4.62-18.63-3.08-3.8-9.55-5.7-19.4-5.7zM224.96 160.55c-1.23 1.34-1.85 2.93-1.85 4.78l10.78 126.29h29.57l10.47-126.29c0-1.85-.56-3.44-1.69-4.78-1.13-1.33-3.74-2-7.85-2h-32.03c-3.71 0-6.17.67-7.4 2z"/><path d="M448.65 237.65 262.3 51.3a16.992 16.992 0 0 0-24.04 0L51.9 237.65c-6.64 6.64-6.64 17.4 0 24.04l186.35 186.35a16.992 16.992 0 0 0 24.04 0l186.35-186.35c6.65-6.64 6.65-17.4.01-24.04zM250.27 411.98 87.96 249.67 250.28 87.36l162.31 162.31-162.32 162.31z"/></g> </svg> </a> + {% endif %} {%- endmacro %} {% macro edit(edit, title=_("edit this"), color="transparent" ) -%} + {% if not archive_mode %} <a href="{{ edit }}" class="me-2 btn-icon-big btn btn-{{ color }}" title="{{ title }}"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil" viewBox="0 0 16 16"> <path fill-rule="evenodd" d="M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5L13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175l-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325z"/> </svg> </a> + {% endif %} {%- endmacro %} diff --git a/src/plainui/jinja2/plainui/components/nav.html b/src/plainui/jinja2/plainui/components/nav.html index 762d29b0b8d075a8c95eb0afde579e1bc2f20384..3f0ba1d84554a891862e459ca4d64a5f3cd233e5 100644 --- a/src/plainui/jinja2/plainui/components/nav.html +++ b/src/plainui/jinja2/plainui/components/nav.html @@ -17,6 +17,7 @@ {%- endmacro %} {% macro dms() %} + {% if not archive_mode %} {% set chat_url = url('plainui:personal_message') %} {% set num_unread = num_of_unread_messages(request) -%} <a @@ -32,6 +33,7 @@ </span> {% endif %} </a> + {% endif %} {% endmacro %} {% macro usermenu() %} @@ -40,7 +42,14 @@ <i class="bi bi-person-circle hub-top-nav__button-icon"> </i> </a> <ul class="dropdown-menu dropdown-menu-start" aria-labelledby="navbarDropdown"> - {% if request.user.is_authenticated %} + {% if archive_mode %} + <li><a class="dropdown-item disabled text-decoration-line-through" + disabled="disabled" + href="#" + title="{{ _("archivemode_loginlink_hint") }}"> + Login</a> + </li> + {% elif request.user.is_authenticated %} <li> {% set num_of_pending_badges = num_of_pending_badges(request) -%} <a @@ -79,14 +88,15 @@ </button> </form> </li> - {% else %} - <li><a class="dropdown-item" href="{{ url('plainui:login') }}">Login</a></li> - {% endif %} + {% else %} + <li><a class="dropdown-item" href="{{ url('plainui:login') }}">Login</a></li> + {% endif %} </ul> </div> {% endmacro %} {% macro createmenu() %} +{% if not archive_mode %} <div class="dropdown"> <button class="hub-top-nav__button dropdown-toggle me-2" @@ -117,6 +127,7 @@ </li> </ul> </div> +{% endif %} {% endmacro %} {# @@ -126,10 +137,12 @@ {% macro top_nav(title, has_breadcrumbs=False) %} <div class="hub-top-nav {% if has_breadcrumbs %}hub-top-nav--breadcrumbs{% endif %}"> <h1 class="hub-head-page">{{ title }}</h1> + {% if not archive_mode %} <form method="POST" action="{{ url('plainui:search') }}" role="search"> {{ csrf_input }} <input class="form-control" name="q" type="text" placeholder="{{ _("search") }}" value="{% if search_query is defined %}{{ search_query }}{% endif %}"> </form> + {% endif %} <div class="hub-top-nav__buttons"> {{ dms() }} {{ createmenu() }} diff --git a/src/plainui/jinja2/plainui/login.html b/src/plainui/jinja2/plainui/login.html index b89828d4c987814e0e22d03859239e2b20a4f33d..52c2ad0e9f415e9e0298689e71644d85cd730892 100644 --- a/src/plainui/jinja2/plainui/login.html +++ b/src/plainui/jinja2/plainui/login.html @@ -13,6 +13,7 @@ </figure> <div class="mw-320 mx-auto"> <h2>{{ _("Login") }}</h2> + {% if not archive_mode %} <form method="POST" id="login" class="hub-landing__form"> <!--<h1 class="text-center bg-secondary p-2 text-dark h3 m-0">{{ _("login") }}</h1>--> <div class=""> @@ -46,6 +47,9 @@ </div> </div> </form> + {% else %} + <p class="mb-2 text-white">{{ _("archivemode_nologin") }}</p> + {% endif %} </div> <hr class="hub-spacer"> diff --git a/src/plainui/jinja2/plainui/room.html b/src/plainui/jinja2/plainui/room.html index 67f1089a5ad52c975390d89cb9d814f0dbe2fa62..2cef0050a1eff374f6a642bfab805a25da7b6f7d 100644 --- a/src/plainui/jinja2/plainui/room.html +++ b/src/plainui/jinja2/plainui/room.html @@ -55,7 +55,7 @@ {% endif %} </div> - {% if voc_stream %} + {% if voc_stream and not archive_mode %} <div class="hub-card"> <h2 class="hub-section-title mb-0">{{ _("Currently Streaming") }}</h2> {{ integrations.vocPlayer(vocStream=voc_stream) }} diff --git a/src/plainui/jinja2/plainui/signup.html b/src/plainui/jinja2/plainui/signup.html index 04f8c0570574532df3a141db347594c758964df0..2bddfbfb4c86e35d1c65969cfa5434aa7244b36b 100644 --- a/src/plainui/jinja2/plainui/signup.html +++ b/src/plainui/jinja2/plainui/signup.html @@ -12,6 +12,7 @@ <p>{{ _("Registration Info Text") }}</p> + {% if not archive_mode %} <form method="POST" id="registration" @@ -35,6 +36,9 @@ </ul> </div> </form> + {% else %} + <p class="mb-2 text-white">{{ _("archivemode_nologin") }}</p> + {% endif %} <hr class="hub-spacer"> </article> diff --git a/src/plainui/jinja2/plainui/static_page.html b/src/plainui/jinja2/plainui/static_page.html index a9e0dcbcf1aeb13b447e5e52f44cfeb84e95496c..a2e0c413150cf83eda35f43f9ad88a7a223d0e77 100644 --- a/src/plainui/jinja2/plainui/static_page.html +++ b/src/plainui/jinja2/plainui/static_page.html @@ -36,6 +36,7 @@ {{ navMacro.top_nav(_("Wiki page")) }} + {% if not archive_mode %} <div class="row"> <div class="col m-2 d-flex justify-content-start"> <a href="{{ url('plainui:static_page_global_history') }}" class="btn btn-dark me-2">{{ _("Global History") }}</a> @@ -51,6 +52,7 @@ <a href="{{ url('plainui:static_page_history', page_slug=page_slug) }}" class="btn btn-dark">{{ _("History") }}</a> </div> </div> + {% endif %} <div class="hub-card"> <h2 class="hub-section-title">{{ page.title }}</h2> diff --git a/src/plainui/locale/de/LC_MESSAGES/django.po b/src/plainui/locale/de/LC_MESSAGES/django.po index 30e2c9c8a72b5505f95bfe642862f0483cdcfcd3..5ac50500d795242c859f7b8b99d0afd823473cc5 100644 --- a/src/plainui/locale/de/LC_MESSAGES/django.po +++ b/src/plainui/locale/de/LC_MESSAGES/django.po @@ -147,6 +147,9 @@ msgstr "Einlösen" msgid "Manage badges" msgstr "Badge-Verwaltung" +msgid "archivemode_notavailable" +msgstr "Diese Funktion steht nicht mehr zur Verfügung, da die Webseite archiviert wurde." + msgid "all" msgstr "alle" @@ -322,6 +325,9 @@ msgstr "Kapazität" msgid "chat" msgstr "DNs" +msgid "archivemode_loginlink_hint" +msgstr "nicht verfügbar, Seite ist archiviert" + msgid "profile" msgstr "Profil" @@ -449,6 +455,9 @@ msgstr "Neu hier?" msgid "sign up (new account)" msgstr "Account anlegen" +msgid "archivemode_nologin" +msgstr "Diese Webseite wurde archiviert, ein Login ist nicht mehr möglich." + msgid "Profile" msgstr "Profil" diff --git a/src/plainui/locale/en/LC_MESSAGES/django.po b/src/plainui/locale/en/LC_MESSAGES/django.po index 9866561eb2c966fb82983dd0ee5353427f7446bd..6bd304f2771b1d09d291a2e8f5b582fd0a444a08 100644 --- a/src/plainui/locale/en/LC_MESSAGES/django.po +++ b/src/plainui/locale/en/LC_MESSAGES/django.po @@ -132,6 +132,9 @@ msgstr "" msgid "assembly badges" msgstr "" +msgid "archivemode_notavailable" +msgstr "This function is not available any more as this website has been archived." + msgid "all" msgstr "" @@ -301,6 +304,9 @@ msgstr "" msgid "chat" msgstr "DMs" +msgid "archivemode_loginlink_hint" +msgstr "not available, page has been archived" + msgid "profile" msgstr "" @@ -428,6 +434,9 @@ msgstr "New here?" msgid "sign up (new account)" msgstr "Sign up" +msgid "archivemode_nologin" +msgstr "This website has been archived, logging in is not possible any more." + msgid "Profile" msgstr ""