diff --git a/babel.cfg b/babel.cfg index 9ba026f..d82fb6e 100644 --- a/babel.cfg +++ b/babel.cfg @@ -1,3 +1,4 @@ [python: snikket_web/**.py] [jinja2: snikket_web/templates/**.html] +[jinja2: snikket_web/templates/**.j2] extensions=jinja2.ext.autoescape,jinja2.ext.with_ diff --git a/snikket_web/scss/app.scss b/snikket_web/scss/app.scss index 7dc75da..5a34479 100644 --- a/snikket_web/scss/app.scss +++ b/snikket_web/scss/app.scss @@ -789,6 +789,21 @@ table { } } +.long-url-link { + display: block; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.link-col { + width: $w-l6; +} + +#clipboard-result + span { + display: none; +} + /* linearisation / responsive stuff */ @@ -828,7 +843,6 @@ table { .copy-to-clipboard { cursor: pointer; - margin-left: 0.5em; font-style: normal; text-decoration: none; } diff --git a/snikket_web/templates/admin_edit_invite.html b/snikket_web/templates/admin_edit_invite.html index 21aa78a..8c8e60e 100644 --- a/snikket_web/templates/admin_edit_invite.html +++ b/snikket_web/templates/admin_edit_invite.html @@ -1,36 +1,21 @@ {% extends "admin_app.html" %} +{% from "library.j2" import showuri %} {% block head_lead %} {{ super() }} {% include "copy-snippet.html" %} {% endblock %} - -{% macro clipboard_button(caller=None) -%} -{%- set text = caller() -%} -📋 -{%- endmacro %} - -{% macro showuri(uri, caller=None) %} -{%- if uri is none -%} -— -{%- else -%} -{{ uri }} {% call clipboard_button() %}{{ uri }}{% endcall %} -{%- endif -%} -{% endmacro %} - {% block content %}

{% trans %}View invitation{% endtrans %}

{{ form.csrf_token }}
-
Created
+
{% trans %}Created{% endtrans %}
{{ invite.created_at | format_date }}
-
Valid until
+
{% trans %}Valid until{% endtrans %}
{{ invite.expires | format_date }}
-
Landing page
+
{% trans %}Link{% endtrans %}
{% call showuri(invite.landing_page) %}{% endcall %}
-
XMPP URI
-
{% call showuri(invite.xmpp_uri) %}{% endcall %}
{#- -#} diff --git a/snikket_web/templates/admin_invites.html b/snikket_web/templates/admin_invites.html index 7b8372b..1c140c8 100644 --- a/snikket_web/templates/admin_invites.html +++ b/snikket_web/templates/admin_invites.html @@ -1,4 +1,8 @@ {% extends "admin_app.html" %} +{% block head_lead %} +{{ super() }} +{% include "copy-snippet.html" %} +{% endblock %} {% block content %}

{% trans %}Manage invitations{% endtrans %}

{{ form.csrf_token }} @@ -12,11 +16,14 @@

{% trans %}Pending invitations{% endtrans %}

{% if invites %} + + + - - - + + + @@ -24,9 +31,11 @@ -
CreatedExpiresActions{% trans %}Created{% endtrans %}{% trans %}Valid until{% endtrans %}{% trans %}Actions{% endtrans %}
{{ invite.created_at | format_date }} {{ (invite.expires - now) | format_timedelta(add_direction=True) }} + {#- -#} - {% trans %}Show invite details{% endtrans %} + {% trans %}Show invite details{% endtrans %} + {#- -#} + 📋 {#- -#} {#- -#} diff --git a/snikket_web/templates/copy-snippet.html b/snikket_web/templates/copy-snippet.html index ddb7d0d..c2f9eda 100644 --- a/snikket_web/templates/copy-snippet.html +++ b/snikket_web/templates/copy-snippet.html @@ -36,6 +36,15 @@ function copyTextToClipboard(text, context, callback) { } /* end of https://stackoverflow.com/a/30810322/1248008 */ +var insert_first = function(parent_el, new_el) { + var first = parent_el.firstChild; + if (!first) { + parent_el.appendChild(new_el); + } else { + parent_el.insertBefore(new_el, first); + } +} + var copy_to_clipboard = function(el) { var text = el.dataset.cliptext; if (!text) { @@ -51,12 +60,12 @@ var copy_to_clipboard = function(el) { result_el.id = "clipboard-result"; if (success) { result_el.classList.add("success"); - result_el.innerText = "Copied!"; + result_el.innerText = "✓"; } else { result_el.classList.add("error"); - result_el.innerText = "Clipboard operation failed!"; + result_el.innerText = "❌"; } - el.appendChild(result_el); + insert_first(el, result_el); setTimeout(function() { el.removeChild(result_el); el.blur(); diff --git a/snikket_web/templates/library.j2 b/snikket_web/templates/library.j2 index 8a5285d..643f487 100644 --- a/snikket_web/templates/library.j2 +++ b/snikket_web/templates/library.j2 @@ -9,3 +9,17 @@
{%- endif -%} {%- endmacro %} + +{% macro clipboard_button(label=_("Copy link"), caller=None) -%} +{%- set text = caller() -%} +{{ label }} +{%- endmacro %} + +{% macro showuri(uri, caller=None) %} +{%- if uri is none -%} +— +{%- else -%} +
+
{% call clipboard_button() %}{{ uri }}{% endcall %}
+{%- endif -%} +{% endmacro %} diff --git a/snikket_web/translations/de/LC_MESSAGES/messages.po b/snikket_web/translations/de/LC_MESSAGES/messages.po index 8933276..e4887db 100644 --- a/snikket_web/translations/de/LC_MESSAGES/messages.po +++ b/snikket_web/translations/de/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: SnikketWeb 0.1.0\n" "Report-Msgid-Bugs-To: jonas@zombofant.net\n" -"POT-Creation-Date: 2021-01-17 20:11+0100\n" +"POT-Creation-Date: 2021-01-17 20:12+0100\n" "PO-Revision-Date: 2020-03-07 16:32+0100\n" "Last-Translator: Jonas Schäfer \n" "Language: de\n" @@ -117,11 +117,25 @@ msgstr "E-Mail-Adresse" msgid "Danger" msgstr "Gefahr" -#: snikket_web/templates/admin_edit_invite.html:21 +#: snikket_web/templates/admin_edit_invite.html:8 msgid "View invitation" msgstr "Einladung anzeigen" -#: snikket_web/templates/admin_edit_invite.html:39 +#: snikket_web/templates/admin_edit_invite.html:13 +#: snikket_web/templates/admin_invites.html:24 +msgid "Created" +msgstr "Erzeugt" + +#: snikket_web/templates/admin_edit_invite.html:15 +#: snikket_web/templates/admin_invites.html:25 +msgid "Valid until" +msgstr "Gültig bis" + +#: snikket_web/templates/admin_edit_invite.html:17 +msgid "Link" +msgstr "Link" + +#: snikket_web/templates/admin_edit_invite.html:24 #: snikket_web/templates/user_passwd.html:39 #: snikket_web/templates/user_profile.html:24 msgid "Back" @@ -172,7 +186,7 @@ msgid "Modify administrative user information or delete users." msgstr "Benutzerinformationen verändern oder Benutzer löschen." #: snikket_web/templates/admin_home.html:11 -#: snikket_web/templates/admin_invites.html:3 +#: snikket_web/templates/admin_invites.html:7 msgid "Manage invitations" msgstr "Einladungen verwalten" @@ -188,11 +202,11 @@ msgstr "Zurück zur Hauptseite" msgid "Go back to your user’s web portal page." msgstr "Zurück zur Startseite deines Benutzers." -#: snikket_web/templates/admin_invites.html:6 +#: snikket_web/templates/admin_invites.html:10 msgid "Create new invitation" msgstr "Neue Einladung erzeugen" -#: snikket_web/templates/admin_invites.html:7 +#: snikket_web/templates/admin_invites.html:11 msgid "" "Create a new invitation link to invite more users to your Snikket " "instance by clicking the button below." @@ -200,19 +214,28 @@ msgstr "" "Erzeuge eine neue Einladung um mehr Benutzer auf deine Snikket-Instanz " "einzuladen indem du den folgenden Button klickst." -#: snikket_web/templates/admin_invites.html:12 +#: snikket_web/templates/admin_invites.html:16 msgid "Pending invitations" msgstr "Ausstehende Einladungen" -#: snikket_web/templates/admin_invites.html:29 +#: snikket_web/templates/admin_invites.html:26 +#: snikket_web/templates/admin_users.html:18 +msgid "Actions" +msgstr "Aktionen" + +#: snikket_web/templates/admin_invites.html:36 msgid "Show invite details" msgstr "Einladungsdetails anzeigen" -#: snikket_web/templates/admin_invites.html:31 +#: snikket_web/templates/admin_invites.html:38 +msgid "Copy invite link to clipboard" +msgstr "Einladungslink kopieren" + +#: snikket_web/templates/admin_invites.html:40 msgid "Delete invitation" msgstr "Einladung löschen" -#: snikket_web/templates/admin_invites.html:39 +#: snikket_web/templates/admin_invites.html:48 msgid "Currently, there are no pending invitations." msgstr "Derzeit gibt es keine ausstehenden Einladungen." @@ -220,15 +243,20 @@ msgstr "Derzeit gibt es keine ausstehenden Einladungen." msgid "Phone number" msgstr "Telefonnummer" -#: snikket_web/templates/admin_users.html:18 -msgid "Actions" -msgstr "Aktionen" - #: snikket_web/templates/app.html:20 snikket_web/templates/login.html:36 #, python-format msgid "A Snikket server" msgstr "Ein Snikket-Server" +#: snikket_web/templates/library.j2:13 +msgid "Copy link" +msgstr "Link kopieren" + +#: snikket_web/templates/library.j2:15 +#, python-format +msgid "Copy "%(content)s" to clipboard" +msgstr ""%(content)s" kopieren" + #: snikket_web/templates/login.html:5 msgid "Snikket Login" msgstr "Snikket Anmeldung" @@ -339,6 +367,3 @@ msgstr "" msgid "Apply" msgstr "Übernehmen" -#~ msgid "none" -#~ msgstr "keiner" - diff --git a/snikket_web/translations/en/LC_MESSAGES/messages.po b/snikket_web/translations/en/LC_MESSAGES/messages.po index a6055f6..65ed530 100644 --- a/snikket_web/translations/en/LC_MESSAGES/messages.po +++ b/snikket_web/translations/en/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2021-01-17 20:11+0100\n" +"POT-Creation-Date: 2021-01-17 20:12+0100\n" "PO-Revision-Date: 2020-03-07 16:50+0100\n" "Last-Translator: FULL NAME \n" "Language: en\n" @@ -119,11 +119,25 @@ msgstr "Address" msgid "Danger" msgstr "" -#: snikket_web/templates/admin_edit_invite.html:21 +#: snikket_web/templates/admin_edit_invite.html:8 msgid "View invitation" msgstr "" -#: snikket_web/templates/admin_edit_invite.html:39 +#: snikket_web/templates/admin_edit_invite.html:13 +#: snikket_web/templates/admin_invites.html:24 +msgid "Created" +msgstr "" + +#: snikket_web/templates/admin_edit_invite.html:15 +#: snikket_web/templates/admin_invites.html:25 +msgid "Valid until" +msgstr "" + +#: snikket_web/templates/admin_edit_invite.html:17 +msgid "Link" +msgstr "" + +#: snikket_web/templates/admin_edit_invite.html:24 #: snikket_web/templates/user_passwd.html:39 #: snikket_web/templates/user_profile.html:24 msgid "Back" @@ -170,7 +184,7 @@ msgid "Modify administrative user information or delete users." msgstr "" #: snikket_web/templates/admin_home.html:11 -#: snikket_web/templates/admin_invites.html:3 +#: snikket_web/templates/admin_invites.html:7 msgid "Manage invitations" msgstr "" @@ -186,29 +200,38 @@ msgstr "" msgid "Go back to your user’s web portal page." msgstr "" -#: snikket_web/templates/admin_invites.html:6 +#: snikket_web/templates/admin_invites.html:10 msgid "Create new invitation" msgstr "" -#: snikket_web/templates/admin_invites.html:7 +#: snikket_web/templates/admin_invites.html:11 msgid "" "Create a new invitation link to invite more users to your Snikket " "instance by clicking the button below." msgstr "" -#: snikket_web/templates/admin_invites.html:12 +#: snikket_web/templates/admin_invites.html:16 msgid "Pending invitations" msgstr "" -#: snikket_web/templates/admin_invites.html:29 +#: snikket_web/templates/admin_invites.html:26 +#: snikket_web/templates/admin_users.html:18 +msgid "Actions" +msgstr "" + +#: snikket_web/templates/admin_invites.html:36 msgid "Show invite details" msgstr "" -#: snikket_web/templates/admin_invites.html:31 +#: snikket_web/templates/admin_invites.html:38 +msgid "Copy invite link to clipboard" +msgstr "" + +#: snikket_web/templates/admin_invites.html:40 msgid "Delete invitation" msgstr "" -#: snikket_web/templates/admin_invites.html:39 +#: snikket_web/templates/admin_invites.html:48 msgid "Currently, there are no pending invitations." msgstr "" @@ -216,15 +239,20 @@ msgstr "" msgid "Phone number" msgstr "" -#: snikket_web/templates/admin_users.html:18 -msgid "Actions" -msgstr "" - #: snikket_web/templates/app.html:20 snikket_web/templates/login.html:36 #, python-format msgid "A Snikket server" msgstr "A Snikket server" +#: snikket_web/templates/library.j2:13 +msgid "Copy link" +msgstr "" + +#: snikket_web/templates/library.j2:15 +#, python-format +msgid "Copy "%(content)s" to clipboard" +msgstr "" + #: snikket_web/templates/login.html:5 msgid "Snikket Login" msgstr "Snikket Login"