Skip to content

Commit

Permalink
Merge branch 'main' into tooltips-on-mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
frcroth authored Aug 12, 2023
2 parents a5f0aae + a6db67e commit 4eed4ee
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 19 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ If you want to do that manually, run `pre-commit run --all-files`. Next to that,

## Tips

- To create translations, run `django-admin makemessages -l de` in the myhpi directory.

### Reset database

1. Delete `db.sqlite3`
Expand Down
22 changes: 22 additions & 0 deletions myhpi/core/markdown/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from markdown.inlinepatterns import LinkInlineProcessor
from markdown.preprocessors import Preprocessor
from wagtail.core.models import Page
from wagtail.images.models import Image


class MinutesBasePreprocessor(Preprocessor):
Expand Down Expand Up @@ -158,6 +159,22 @@ def url(self, id):
return Page.objects.get(id=id).localized.get_url()


class ImagePattern(LinkInlineProcessor):
def handleMatch(self, m, data=None):
el = markdown.util.etree.Element("img")
try:
el.set("src", self.url(m.group("id")))
el.set("alt", markdown.util.AtomicString(m.group("title")))
el.set("class", "rendered-image")
except ObjectDoesNotExist:
el = markdown.util.etree.Element("span")
el.text = markdown.util.AtomicString(_("[missing image]"))
return el, m.start(0), m.end(0)

def url(self, id):
return Image.objects.get(id=id).get_rendition("width-800").url


class MinuteExtension(Extension):
def extendMarkdown(self, md):
md.registerExtension(self)
Expand All @@ -172,3 +189,8 @@ def extendMarkdown(self, md):
"InternalLinkPattern",
200,
)
md.inlinePatterns.register(
ImagePattern(r"!\[(?P<title>[^\[]+)\]\(image:(?P<id>\d+)\)", md),
"ImagePattern",
200,
)
3 changes: 2 additions & 1 deletion myhpi/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ class InformationPage(BasePage):
@property
def last_edited_by(self):
if self.get_latest_revision():
return self.get_latest_revision().user
user = self.get_latest_revision().user
return f"{user.first_name} {user.last_name}"


class MinutesList(BasePage):
Expand Down
2 changes: 1 addition & 1 deletion myhpi/core/templates/core/information_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h1 class="page-title">
<h1 class="toc-title">{% translate "Last edited" %}</h1>
{{ page.last_published_at|date:"d.m.Y, H:i" }}
{% if page.author_visible %}
<i>von</i>
<i>{% translate "by" %}</i>
{{ page.last_edited_by }}
{% endif %}
</aside>
Expand Down
43 changes: 27 additions & 16 deletions myhpi/locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-04-14 12:42+0000\n"
"POT-Creation-Date: 2023-08-09 16:50+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -70,6 +70,10 @@ msgstr "[link fehlt]"
msgid "Last edited"
msgstr "Zuletzt bearbeitet"

#: core/templates/core/information_page.html:22
msgid "by"
msgstr "von"

#: core/templates/core/information_page.html:27
#: core/templates/core/minutes.html:47 polls/templates/polls/poll.html:29
msgid "Table of contents"
Expand Down Expand Up @@ -178,38 +182,46 @@ msgstr " Ergebnisse gefunden."
msgid "No results found."
msgstr "Keine Ergebnisse gefunden."

#: search/templates/search/search_field.html:6 templates/base.html:150
#: search/templates/search/search_field.html:6 templates/base.html:157
msgid "Search..."
msgstr "Suchen..."

#: templates/403.html:5 myhpi/templates/403.html:11
#: templates/403.html:5 templates/403.html:11
msgid "Access denied"
msgstr "Zugang verweigert"

#: templates/403.html:13
msgid ""
"Unfortunately you are not allowed to view this page. This might have one of "
"the following reasons:"
msgstr "Du bist nicht berechtigt, diese Seite zu sehen. Das kann einen der folgenden Gründe haben:"
msgstr ""
"Du bist nicht berechtigt, diese Seite zu sehen. Das kann einen der folgenden "
"Gründe haben:"

#: templates/403.html:16
msgid ""
"You are not logged in and are not accessing the page from the university "
"network."
msgstr "Du bist nicht eingeloggt oder rufst die Seite nicht aus dem Universitätsnetzwerk auf."
msgstr ""
"Du bist nicht eingeloggt oder rufst die Seite nicht aus dem "
"Universitätsnetzwerk auf."

#: templates/403.html:17
msgid ""
"You are not logged in and the page is only available for logged in users."
msgstr "Du bist nicht eingeloggt und die Seite ist nur für eingeloggte Nutzer sichtbar."
msgstr ""
"Du bist nicht eingeloggt und die Seite ist nur für eingeloggte Nutzer "
"sichtbar."

#: templates/403.html:18
msgid ""
"You are logged in but don't have the required permissions to access this "
"page."
msgstr "Du bist eingeloggt, aber hast keine ausreichenden Berechtigungen, um diese Seite zu sehen."
msgstr ""
"Du bist eingeloggt, aber hast keine ausreichenden Berechtigungen, um diese "
"Seite zu sehen."

#: myhpi/templates/404.html:7
#: templates/404.html:7
msgid "Page not found"
msgstr "Seite nicht gefunden."

Expand All @@ -229,19 +241,19 @@ msgstr "Zur Startseite"
msgid "Ctrl+K"
msgstr "Strg+K"

#: templates/base.html:73
#: templates/base.html:74
msgid "Sign in"
msgstr "Anmelden"

#: templates/base.html:93
#: templates/base.html:99
msgid "Your groups:"
msgstr "Deine Gruppen"

#: templates/base.html:100
#: templates/base.html:106
msgid "Sign out"
msgstr "Abmelden"

#: templates/base.html:152
#: templates/base.html:159
msgid "Start search"
msgstr "Suche starten"

Expand Down Expand Up @@ -330,8 +342,10 @@ msgstr ""
"\t"

#: tenca_django/templates/tenca_django/delete_list.html:20
#, fuzzy
#| msgid "Delete list"
msgid "Delete"
msgstr "Löschen"
msgstr "Liste Löschen"

#: tenca_django/templates/tenca_django/delete_list.html:21
msgid "Cancel"
Expand Down Expand Up @@ -484,6 +498,3 @@ msgstr "Die Anmeldung von {email} auf {list} wurde rückgänig gemacht."
#~ msgstr ""
#~ " Die angeforderte Seite existiert nicht. Bitte überprüfe die URL oder "
#~ "nutze das Menü oben, um die gewünschte Seite zu finden. "

#~ msgid "Previous"
#~ msgstr "Vorherige "
2 changes: 1 addition & 1 deletion myhpi/static/js/admin/easymde_custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ window.wagtailMarkdown.options = {
onload: IMAGE_CHOOSER_MODAL_ONLOAD_HANDLERS,
responses: {
imageChosen: function (t) {
editor.codemirror.replaceSelection("![" + t.title + "](" + t.preview.url + ")")
editor.codemirror.replaceSelection("![" + t.title + "](image:" + t.id + ")");
}
},

Expand Down
4 changes: 4 additions & 0 deletions myhpi/static/scss/myHPI.scss
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ h1.toc-title::after {
margin-top: -0.25rem;
}

.rendered-image {
max-width: 100%;
}

@import "./navbar.scss";
@import "./footer.scss";

Expand Down

0 comments on commit 4eed4ee

Please sign in to comment.