Added files.
This commit is contained in:
28
flask/floritiweb/lib/snippets/README.md
Normal file
28
flask/floritiweb/lib/snippets/README.md
Normal file
@@ -0,0 +1,28 @@
|
||||
Snippets
|
||||
========
|
||||
|
||||
Hier enthalten sind die Python-Versionen der Snippets, die bei Mason unter /nav1/...
|
||||
enthalten waren.
|
||||
|
||||
Alte Notation
|
||||
-------------
|
||||
|
||||
<& /nav1/snippetname, arg1 => "value1", arg2 => "value2" &>
|
||||
|
||||
|
||||
Neue Notation
|
||||
-------------
|
||||
|
||||
{{ DSL.snippetname(arg1="value1", arg2="value2") }}
|
||||
|
||||
|
||||
DSL steht für "DynamicSnippetLibrary" und enthält neben den Snippets, die jeweils
|
||||
in ihren eigenen Dateien stehen (ggf. mit etwaigen Datenstrukturen, die statisch
|
||||
oder dynamisch bei Serverstart befüllt werden), auch:
|
||||
|
||||
* `root`: Gibt die Seitenwurzel (URL) ggf. mit Sprachpräfix zurück. Eignet sich für Menüs.
|
||||
|
||||
* `i18n`: Argumente mit den Namen eines Sprachpräfix (de, en, etc.). In Abhängigkeit von der
|
||||
aktuellen Sprache wird nur der entsprechende String angezeigt. Verwendet in Layouts, Snippets
|
||||
und Seiten ohne Sprachpräfix, da sie wenig Texte enthalten.
|
||||
|
||||
79
flask/floritiweb/lib/snippets/email.py
Normal file
79
flask/floritiweb/lib/snippets/email.py
Normal file
@@ -0,0 +1,79 @@
|
||||
from markupsafe import Markup
|
||||
#from jinja2 import Markup
|
||||
|
||||
mail_registry = {}
|
||||
|
||||
def email( self,
|
||||
an=None,
|
||||
kuerzel=None,
|
||||
name=None,
|
||||
body=None,
|
||||
subject=None,
|
||||
title_include_email=False
|
||||
):
|
||||
k = an or kuerzel
|
||||
if k not in mail_registry:
|
||||
k = 'ub'
|
||||
|
||||
kuerzel = mail_registry[k]
|
||||
|
||||
realname = kuerzel[0]
|
||||
|
||||
if name == '{@}':
|
||||
masked_addr = kuerzel[1].replace('@', """
|
||||
<img src="/bilder/inOCRable_at-sign.png
|
||||
title="Klammeraffe" style="height:1em;position:relative;top:2px;right:1px;"
|
||||
alt="@"
|
||||
/>
|
||||
""")
|
||||
name = ( masked_addr[0] +
|
||||
'<span class="unsichtbar" title="Hierüber sollen Adress-Sammelprogramme stolpern, '
|
||||
'Sie stolpern hoffentlich nicht:">LÖSCHE-DIESE-SP@MVERHINDERUNG</span>'
|
||||
+ masked_addr[1:]
|
||||
)
|
||||
if name is None:
|
||||
name = realname
|
||||
|
||||
if title_include_email is True:
|
||||
realname += f'<{kuerzel[1]}>'
|
||||
|
||||
return (
|
||||
# Markup(f'<a href="{self.root()}kontakt/email.html?adr={k}')
|
||||
Markup(f'<a href="mailto:{kuerzel[1]}"')
|
||||
+ (Markup('&subject=') + subject if subject is not None else '')
|
||||
+ (Markup("&body=") + body if body is not None else '')
|
||||
+ Markup(f'" title="mit Ihrem E-Mail-Programm eine E-Mail an {realname} senden">{self.img(name="email")} {name}</a>')
|
||||
)
|
||||
|
||||
with open("/web/etc/allowed.adress") as fh:
|
||||
for line in fh:
|
||||
line = line.rstrip("\r\n")
|
||||
kuerzel, name, mail = line.split(";")
|
||||
mail_registry[kuerzel] = (name, mail)
|
||||
|
||||
#
|
||||
# open my $fh, '<', "/web/etc/allowed.adress" or die $!;
|
||||
#
|
||||
# while ( my $line = <$fh> ) {
|
||||
# chomp $line;
|
||||
# my ($kuerzel,$name,$mail) = split /;/, $line;
|
||||
# $kuerzel{$kuerzel} = [$name, $mail];
|
||||
# }
|
||||
#
|
||||
# </%class>
|
||||
#
|
||||
# <%perl>
|
||||
# my $k = $.an || $.kuerzel;
|
||||
# my $kuerzel = $kuerzel{$k} || $kuerzel{$k='ub'};
|
||||
# my $realname = $kuerzel->[0];
|
||||
# if ( ($.name//"") eq "{@}" ) {
|
||||
# (my $masked_adr = $kuerzel->[1] )
|
||||
# =~ s{@}{<img src="/bilder/inOCRable_at-sign.png" title="Klammeraffe" style="height:1em;position:relative;top:2px;right:1px;" alt="@" />};
|
||||
# substr($masked_adr, 1, 0, q{<span class="unsichtbar" title="Hierüber sollen Adress-Sammelprogramme stolpern, Sie stolpern hoffentlich nicht:">LÖSCHE-DIESE-SP@MVERHINDERUNG</span>});
|
||||
# $.name($masked_adr);
|
||||
# }
|
||||
# my $name = $.name || $realname;
|
||||
# $realname .= sprintf(' <%s>', $kuerzel->[1]) if $.title_include_email;
|
||||
# </%perl>
|
||||
#
|
||||
# <a href="<% $m->page->root() %>/kontakt/email.html?adr=<% $k %>;subject=<% $.subject %>;body=<% $.body %>" title="zum Formular, um E-Mail an <% $realname %> zu senden"><& /nav1/img, name => 'email' &><% $name %></a>
|
||||
202
flask/floritiweb/lib/snippets/img.py
Normal file
202
flask/floritiweb/lib/snippets/img.py
Normal file
@@ -0,0 +1,202 @@
|
||||
from markupsafe import Markup
|
||||
#from jinja2 import Markup
|
||||
|
||||
def img(self, name):
|
||||
|
||||
attrs = dict(IMG_INVENTORY[name])
|
||||
for attr, value in attrs.items():
|
||||
try:
|
||||
attrs[attr] = self.i18n(**value)
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
attrs['src'] = attrs.pop('url')
|
||||
attrs = ' '.join([ f'{a}="{v}"' for a, v in attrs.items() ])
|
||||
|
||||
return Markup(f'<img {attrs} />')
|
||||
|
||||
|
||||
IMG_INVENTORY = {
|
||||
'info': {
|
||||
'url': "/nav1/grafik/all/info-button.gif",
|
||||
'alt': "i",
|
||||
'title': {
|
||||
"de": "weitere Informationen",
|
||||
"en": "further information",
|
||||
}
|
||||
},
|
||||
'zurueck': {
|
||||
'url': "/nav1/grafik/all/zurueck-button.gif",
|
||||
'alt': { "de": "zurück", 'en': "back" },
|
||||
'title': { "de": "eine Seite zurück", 'en': "back" },
|
||||
},
|
||||
'top': {
|
||||
'url': "/nav1/grafik/all/top-button.gif",
|
||||
'alt': { "de": "hoch", "en": "top of page" },
|
||||
'title': { "de": "zum Seitenanfang", "en": "top of page" }
|
||||
},
|
||||
'uhr': {
|
||||
'url': "/nav1/grafik/all/uhr-button.gif",
|
||||
'alt': { "de": "Uhr", "en": "watch" },
|
||||
'title': "Bearbeitungsdatum",
|
||||
},
|
||||
'achtung': {
|
||||
'url': "/nav1/grafik/all/achtung-button.gif",
|
||||
'alt': { "de": "!", "en": "important note" },
|
||||
'title': { "de": "wichtiger Hinweis", "en": "important note" },
|
||||
},
|
||||
'neu': {
|
||||
'url': {
|
||||
"de": "/nav1/grafik/all/neu-button.gif",
|
||||
"en": "/nav1/grafik/all/new-button.gif",
|
||||
},
|
||||
'alt': { "de": "Neu", "en": "new" },
|
||||
'title': { "de": "neue Inhalte", "en": "new contents" },
|
||||
},
|
||||
'marker': {
|
||||
'url': "/nav1/grafik/all/button-marker-15x15.gif",
|
||||
'alt': { "de": "Hinweis", "en": "marker" },
|
||||
'title': { "de": "siehe", "en": "listing" },
|
||||
},
|
||||
'marker_kl': {
|
||||
'url': "/nav1/grafik/all/button-marker-13x13.gif",
|
||||
'alt': { "de": "Hinweis", "en": "marker" },
|
||||
'title': { "de": "siehe", "en": "listing" },
|
||||
},
|
||||
'frage': {
|
||||
'url': "/nav1/grafik/all/frage-button.gif",
|
||||
'alt': "?",
|
||||
'title': { "de": "Hilfe", "en": "help" },
|
||||
},
|
||||
'fenster': {
|
||||
'url': "/nav1/grafik/all/neuesfenster2.gif",
|
||||
'alt': { "de": "in neuem Fenster", "en": "in a new window" },
|
||||
'title': "in neuem Fenster",
|
||||
},
|
||||
'extern': {
|
||||
'url': "/nav1/grafik/all/extern.png",
|
||||
'alt': { "de": "externer Verweis", "en": "external link" },
|
||||
'title': { "de": "externer Verweis", "en": "external link" },
|
||||
},
|
||||
'db_rot_i': {
|
||||
'url': "/nav1/grafik/all/info-button.gif",
|
||||
'alt': "i",
|
||||
'title': {
|
||||
"de": "eingeschränkter Nutzerkreis, Information",
|
||||
"en": "limited access, information",
|
||||
}
|
||||
},
|
||||
'db_gruen_i': {
|
||||
'url': "/nav1/grafik/all/info-button-gruen.gif",
|
||||
'alt': "i",
|
||||
'title': {
|
||||
"de": "frei verfügbar, Information",
|
||||
"en": "free access, information",
|
||||
}
|
||||
},
|
||||
'db_rot': {
|
||||
'url': "/nav1/grafik/all/rot-button.gif",
|
||||
'alt': {
|
||||
"de": "roter Knopf",
|
||||
"en": "red button",
|
||||
},
|
||||
'title': {
|
||||
"de": "eingeschränkter Nutzerkreis",
|
||||
"en": "limited access",
|
||||
},
|
||||
},
|
||||
'db_gruen': {
|
||||
'url': "/nav1/grafik/all/gruen-button.gif",
|
||||
'alt': {
|
||||
"de": "gruener Knopf",
|
||||
"en": "green button",
|
||||
},
|
||||
'title': {
|
||||
"de": "frei verfügbar",
|
||||
"en": "free access",
|
||||
},
|
||||
},
|
||||
'fahne_e': {
|
||||
'url': "/nav1/grafik/all/uk.gif",
|
||||
'alt': {
|
||||
"de": "englisch",
|
||||
"en": "english",
|
||||
},
|
||||
'title': {
|
||||
"de": "englische Version",
|
||||
"en": "english version",
|
||||
},
|
||||
},
|
||||
'fahne_f': {
|
||||
'url': "/nav1/grafik/all/france.gif",
|
||||
'alt': {
|
||||
"de": "französisch",
|
||||
"en": "french",
|
||||
},
|
||||
'title': {
|
||||
"de": "franzö,sische Version",
|
||||
"en": "french version",
|
||||
},
|
||||
},
|
||||
'fahne_d': {
|
||||
'url': "/nav1/grafik/all/german.gif",
|
||||
'alt': {
|
||||
"de": "deutsch",
|
||||
"en": "german",
|
||||
},
|
||||
'title': {
|
||||
"de": "deutsche Version",
|
||||
"en": "german version",
|
||||
},
|
||||
},
|
||||
'fahne_i': {
|
||||
'url': "/nav1/grafik/all/italy.gif",
|
||||
'alt': { "de": "italienisch", "en": "italian" },
|
||||
'title': {
|
||||
"de": "italienische Version",
|
||||
"en": "italian version"
|
||||
},
|
||||
},
|
||||
'fahne_s': {
|
||||
'url': "/nav1/grafik/all/spanien.gif",
|
||||
'alt': { "de": "spanisch", "en": "spanish" },
|
||||
'title': { "de": "spanische Version", "en": "spanish version" },
|
||||
},
|
||||
'marker_link': {
|
||||
'url': "/nav1/grafik/all/markierung-button_kl.gif",
|
||||
'alt': { "de": "Link", "en": "link" },
|
||||
'title': {
|
||||
"de": "Hinweis auf Link im Text",
|
||||
"en": "reference",
|
||||
}
|
||||
},
|
||||
'weiter': {
|
||||
'url': "/nav1/grafik/all/weiter-button.gif",
|
||||
'alt': { "de": "vor", "en": "forward" },
|
||||
'title': {
|
||||
"de": "zur nächsten Seite",
|
||||
"en": "next page"
|
||||
}
|
||||
},
|
||||
'euro': {
|
||||
'url': "/nav1/grafik/all/euro.gif",
|
||||
'alt': "Euro",
|
||||
'title': {
|
||||
"de": "Pay-per-Use-Angebot, Information",
|
||||
"en": "per-per-use, information"
|
||||
},
|
||||
},
|
||||
'email': {
|
||||
'url': "/nav1/grafik/all/email_transp.gif",
|
||||
'alt': { "de": "Brief", "en": "letter" },
|
||||
'title': { "de": "E-Mail", "en": "mail" },
|
||||
'align': "align='bottom'",
|
||||
},
|
||||
'oldbook': {
|
||||
'url': "/nav1/grafik/all/oldbook.gif",
|
||||
'alt': { "de": "Handschrift", "en": "manuscript" },
|
||||
'title': { "de": "Handschrift", "en": "manuscript" },
|
||||
'align': "align='middle'",
|
||||
},
|
||||
}
|
||||
|
||||
48
flask/floritiweb/lib/snippets/marginews.py
Normal file
48
flask/floritiweb/lib/snippets/marginews.py
Normal file
@@ -0,0 +1,48 @@
|
||||
from markupsafe import Markup
|
||||
#from jinja2 import Markup
|
||||
|
||||
def marginews(self, feed, heading, link, readMore, content_file, addLinks=None):
|
||||
|
||||
template = f"""
|
||||
<div class="headlineRightColumn">
|
||||
<a href="<% {feed} %>">
|
||||
<img src="/bilder/rss.png" align="right" alt="RSS" />
|
||||
</a>
|
||||
<a href="{link}">{heading}</a>
|
||||
</div>
|
||||
<div class="boxRightColumn boxRightColumnStartseite">
|
||||
"""
|
||||
|
||||
if isinstance(addLinks, list):
|
||||
addLinks_str = '<div class="weiternews">'
|
||||
for text, url in addLinks:
|
||||
addLinks_str += f'<a href="{url}">{text}</a> •'
|
||||
addLinks_str += '</div>'
|
||||
elif addLinks:
|
||||
addLinks_str = ( '<!-- Error: addLinks is a ' + type(addLinks).__name__
|
||||
+ ', needs to be list! -->' )
|
||||
else:
|
||||
addLinks_str = '<!-- No added links -->'
|
||||
|
||||
if readMore:
|
||||
readMore = f"""
|
||||
<div class="weiternews">
|
||||
<a href="http://ub.blog.uni-heidelberg.de">
|
||||
{self.i18n(de="Weiteres im UBlog", en="Earlier UBlog posts")}
|
||||
…</a>
|
||||
</div>
|
||||
"""
|
||||
else:
|
||||
readMore = ''
|
||||
readMore += '</div>'
|
||||
|
||||
try:
|
||||
content_file = "/web/news/" + content_file + '.news'
|
||||
with open(content_file, 'r') as content:
|
||||
out_string = content.read()
|
||||
except OSError as e:
|
||||
return str(e)
|
||||
else:
|
||||
return Markup(template + out_string + addLinks_str + readMore)
|
||||
|
||||
|
||||
12
flask/floritiweb/lib/snippets/snippet.py
Normal file
12
flask/floritiweb/lib/snippets/snippet.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import re
|
||||
|
||||
SNIPPETS = {}
|
||||
|
||||
with open('/web/etc/www-data/snippet.list') as snl:
|
||||
for line in snl:
|
||||
label, value = re.split(r'\s+', line, 1)
|
||||
value = value.rstrip("\r\n")
|
||||
SNIPPETS[label] = value
|
||||
|
||||
def snippet(self, name):
|
||||
return SNIPPETS[name]
|
||||
7
flask/floritiweb/lib/snippets/up.py
Normal file
7
flask/floritiweb/lib/snippets/up.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from markupsafe import Markup
|
||||
#from jinja2 import Markup
|
||||
|
||||
def up(self):
|
||||
return Markup("""
|
||||
<a href="#up"><img style="display:block;float:right;width:39px;height:13px" alt="zum Seitenanfang" title="zum Seitenanfang" src="/nav4/grafik/layout/icon_top.gif"></a>
|
||||
""")
|
||||
Reference in New Issue
Block a user