vcards for buiseness card added
authorReimar Bauer <rb.proj AT googlemail DOT com>
Tue, 20 May 2014 15:45:14 +0200
changeset 2756d0b1a0468af
parent 274 b174d1f1716e
child 276 45bf3ac57e9a
vcards for buiseness card added
eskp.py
requirements.txt
templates/author_info.html
templates/buiseness_card.html
templates/info_link.html
translations/de/LC_MESSAGES/messages.mo
translations/de/LC_MESSAGES/messages.po
translations/en/LC_MESSAGES/messages.po
translations/eskp.pot
vcards/jug.vcf
     1.1 --- a/eskp.py	Mon May 19 10:58:39 2014 +0200
     1.2 +++ b/eskp.py	Tue May 20 15:45:14 2014 +0200
     1.3 @@ -2,15 +2,22 @@
     1.4  
     1.5  import os
     1.6  import codecs
     1.7 +import vobject
     1.8 +import StringIO
     1.9 +
    1.10 +import qrcode
    1.11 +from qrcode.image.pure import PymagingImage
    1.12  
    1.13  from docutils.core import publish_parts
    1.14 -from flask import Flask, Response
    1.15 +from flask import Flask
    1.16  from flask import render_template
    1.17  from flask import request
    1.18  from flask.ext.babel import gettext as _
    1.19  from flask.ext.babel import Babel
    1.20  from config import LANGUAGES
    1.21  
    1.22 +import base64
    1.23 +
    1.24  LANGUAGE_SELECTED = "de"
    1.25  #ToDo after engelish is implemented set LANGUAGE_SELECTED = None
    1.26  
    1.27 @@ -22,6 +29,15 @@
    1.28  
    1.29  app.config['BABEL_DEFAULT_LOCALE'] = 'de'
    1.30  
    1.31 +
    1.32 +
    1.33 +def get_vcard(filename):
    1.34 +    with codecs.open(filename, 'r', 'utf-8') as f:
    1.35 +            vcard = f.read()
    1.36 +            f.close()
    1.37 +    return vobject.readOne(vcard)
    1.38 +
    1.39 +
    1.40  def get_content(filename, overrides=None):
    1.41      content = u""
    1.42      filename = os.path.join(ESKP_PATH, filename)
    1.43 @@ -64,7 +80,6 @@
    1.44  
    1.45  def modal_info(template, act, title, filename):
    1.46      content = get_content(filename)
    1.47 -    print template
    1.48      html = render_template(template, act=act, title=title, content=content, exit=_(u"Close"))
    1.49      return html
    1.50  
    1.51 @@ -125,16 +140,43 @@
    1.52      return render_template("/eskp.html", act="eskp", content=content, headline=headline)
    1.53  
    1.54  
    1.55 +def qr_image_data(card):
    1.56 +    buf= StringIO.StringIO()
    1.57 +    qr = qrcode.QRCode(
    1.58 +        version=1,
    1.59 +        error_correction=qrcode.constants.ERROR_CORRECT_L,
    1.60 +        box_size=2,
    1.61 +        border=2,
    1.62 +        )
    1.63 +    qr.add_data(card.serialize())
    1.64 +    qr.make(fit=True)
    1.65 +    img = qr.make_image()
    1.66 +    img.save(buf)
    1.67 +    image = buf.getvalue()
    1.68 +    return base64.b64encode(image)
    1.69 +
    1.70 +
    1.71  @app.route("/ozoneloss")
    1.72  def ozoneloss():
    1.73 +
    1.74      filename = os.path.join("templates", get_locale(), "rst", "ozoneloss.rst")
    1.75      content = get_content(filename)
    1.76 -    filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_author.rst")
    1.77 -    author = modal_info("/author_info.html", "author", _(u"Ozoneloss"), filename)
    1.78 +
    1.79 +    vcard_file = os.path.join("vcards", "jug.vcf")
    1.80 +    author = u""
    1.81 +    try:
    1.82 +        card = get_vcard(vcard_file)
    1.83 +    except IOError:
    1.84 +        card = None
    1.85 +    if card is not None:
    1.86 +        qr_image = qr_image_data(card)
    1.87 +        author = render_template("/author_info.html", act="author", title=_(u"Ozoneloss"),
    1.88 +                                  card=card, image=qr_image, contact=_(u"Contact"), exit=_(u"Close"))
    1.89 +
    1.90      filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_publications.rst")
    1.91      publications = modal_info("/publications_info.html", "publications", _(u"Ozoneloss"), filename)
    1.92      return render_template("/ozoneloss.html", act="ozoneloss", content=content,
    1.93 -                           author=author, contact = u"Dr. Jens-Uwe Grooß", publications=publications )
    1.94 +                           author=author,card=card, publications=publications )
    1.95  
    1.96  @app.route("/ozoneloss/clams")
    1.97  def ozoneloss_clams():
     2.1 --- a/requirements.txt	Mon May 19 10:58:39 2014 +0200
     2.2 +++ b/requirements.txt	Tue May 20 15:45:14 2014 +0200
     2.3 @@ -9,4 +9,6 @@
     2.4  itsdangerous==0.23
     2.5  pytz==2013.8
     2.6  speaklater==1.3
     2.7 -wsgiref==0.1.2
     2.8 \ No newline at end of file
     2.9 +wsgiref==0.1.2
    2.10 +vobject==0.8.1c
    2.11 +qrcode==4.0.4
    2.12 \ No newline at end of file
     3.1 --- a/templates/author_info.html	Mon May 19 10:58:39 2014 +0200
     3.2 +++ b/templates/author_info.html	Tue May 20 15:45:14 2014 +0200
     3.3 @@ -13,7 +13,7 @@
     3.4              </h4>
     3.5           </div>
     3.6           <div class="modal-body">
     3.7 -            {{ content|safe }}
     3.8 +              {% include "buiseness_card.html" %}
     3.9           </div>
    3.10           <div class="modal-footer">
    3.11              <button type="button" class="btn btn-default"
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/templates/buiseness_card.html	Tue May 20 15:45:14 2014 +0200
     4.3 @@ -0,0 +1,19 @@
     4.4 +<h1 class="title"> {{ contact }}</h1>
     4.5 +<div class="container">
     4.6 +    <div class="column">
     4.7 +        <div class="col-md-3">
     4.8 +            <p> {{ card.title.value }} {{ card.fn.value }}</p>
     4.9 +            <p> {{ card.org.value[0] }}</p>
    4.10 +            <p><a href="mailto:{{ card.email.value|safe }}">{{ card.email.value|safe }}</a></p>
    4.11 +            <img src="data:image/png;base64,{{ image|safe }}"/>
    4.12 +        </div>
    4.13 +
    4.14 +        <div class="col-md-3">
    4.15 +            <img class="logo" src="{{ card.photo.value|safe}}" alt="Image von Person" />
    4.16 +
    4.17 +            <div class="collapse navbar-collapse">
    4.18 +              <ul class="nav navbar-nav navbar-right">
    4.19 +            </div>
    4.20 +        </div>
    4.21 +    </div>
    4.22 +</div>
     5.1 --- a/templates/info_link.html	Mon May 19 10:58:39 2014 +0200
     5.2 +++ b/templates/info_link.html	Tue May 20 15:45:14 2014 +0200
     5.3 @@ -2,7 +2,7 @@
     5.4  <ul class="list-unstyled">
     5.5  <li>
     5.6      <a data-toggle="modal" data-target="#AuthorInfoModal">
     5.7 -Kontakt: {{ contact }}
     5.8 +Kontakt: {{ card.title.value }} {{ card.fn.value }}
     5.9  </a>
    5.10  </li>
    5.11  {% if publications %}
     6.1 Binary file translations/de/LC_MESSAGES/messages.mo has changed
     7.1 --- a/translations/de/LC_MESSAGES/messages.po	Mon May 19 10:58:39 2014 +0200
     7.2 +++ b/translations/de/LC_MESSAGES/messages.po	Tue May 20 15:45:14 2014 +0200
     7.3 @@ -8,7 +8,7 @@
     7.4  msgstr ""
     7.5  "Project-Id-Version: PROJECT VERSION\n"
     7.6  "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
     7.7 -"POT-Creation-Date: 2014-05-15 10:13+0200\n"
     7.8 +"POT-Creation-Date: 2014-05-19 11:22+0200\n"
     7.9  "PO-Revision-Date: 2014-05-05 11:10+0200\n"
    7.10  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    7.11  "Language-Team: de <LL@li.org>\n"
    7.12 @@ -18,52 +18,56 @@
    7.13  "Content-Transfer-Encoding: 8bit\n"
    7.14  "Generated-By: Babel 1.3\n"
    7.15  
    7.16 -#: eskp.py:37 eskp.py:135
    7.17 +#: eskp.py:50 eskp.py:159 eskp.py:163
    7.18  msgid "Ozoneloss"
    7.19  msgstr "Ozonverlust"
    7.20  
    7.21 -#: eskp.py:38
    7.22 +#: eskp.py:51
    7.23  msgid "ESKP"
    7.24  msgstr ""
    7.25  
    7.26 -#: eskp.py:39
    7.27 +#: eskp.py:52 eskp.py:184
    7.28  msgid "IEK-7"
    7.29  msgstr "IEK-7"
    7.30  
    7.31 -#: eskp.py:46 eskp.py:55
    7.32 +#: eskp.py:59 eskp.py:68
    7.33  msgid "2012"
    7.34  msgstr ""
    7.35  
    7.36 -#: eskp.py:47 eskp.py:56
    7.37 +#: eskp.py:60 eskp.py:69
    7.38  msgid "2011"
    7.39  msgstr ""
    7.40  
    7.41 -#: eskp.py:48 eskp.py:57
    7.42 +#: eskp.py:61 eskp.py:70
    7.43  msgid "2010"
    7.44  msgstr ""
    7.45  
    7.46 -#: eskp.py:53
    7.47 +#: eskp.py:66
    7.48  msgid "2014"
    7.49  msgstr ""
    7.50  
    7.51 -#: eskp.py:54
    7.52 +#: eskp.py:67
    7.53  msgid "2013"
    7.54  msgstr ""
    7.55  
    7.56 -#: eskp.py:66
    7.57 +#: eskp.py:80 eskp.py:160
    7.58  msgid "Close"
    7.59  msgstr "Schließen"
    7.60  
    7.61 -#: eskp.py:80 eskp.py:109 eskp.py:120
    7.62 +#: eskp.py:94 eskp.py:120 eskp.py:128
    7.63  msgid "About ESKP"
    7.64  msgstr "Über ESKP"
    7.65  
    7.66 -#: eskp.py:170
    7.67 +#: eskp.py:160
    7.68 +msgid "Contact"
    7.69 +msgstr "Ansprechpartner"
    7.70 +
    7.71 +#: eskp.py:201
    7.72  #, python-format
    7.73  msgid "Url: %(url)s not found"
    7.74  msgstr "Url: %(url)s nicht gefunden"
    7.75  
    7.76 -#: eskp.py:171
    7.77 +#: eskp.py:202
    7.78  msgid "This information is not available!"
    7.79  msgstr "Diese Information steht nicht zur Verfügung"
    7.80  
     8.1 --- a/translations/en/LC_MESSAGES/messages.po	Mon May 19 10:58:39 2014 +0200
     8.2 +++ b/translations/en/LC_MESSAGES/messages.po	Tue May 20 15:45:14 2014 +0200
     8.3 @@ -8,7 +8,7 @@
     8.4  msgstr ""
     8.5  "Project-Id-Version: PROJECT VERSION\n"
     8.6  "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
     8.7 -"POT-Creation-Date: 2014-05-15 10:13+0200\n"
     8.8 +"POT-Creation-Date: 2014-05-19 11:22+0200\n"
     8.9  "PO-Revision-Date: 2014-05-05 11:10+0200\n"
    8.10  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    8.11  "Language-Team: en <LL@li.org>\n"
    8.12 @@ -18,52 +18,56 @@
    8.13  "Content-Transfer-Encoding: 8bit\n"
    8.14  "Generated-By: Babel 1.3\n"
    8.15  
    8.16 -#: eskp.py:37 eskp.py:135
    8.17 +#: eskp.py:50 eskp.py:159 eskp.py:163
    8.18  msgid "Ozoneloss"
    8.19  msgstr ""
    8.20  
    8.21 -#: eskp.py:38
    8.22 +#: eskp.py:51
    8.23  msgid "ESKP"
    8.24  msgstr ""
    8.25  
    8.26 -#: eskp.py:39
    8.27 +#: eskp.py:52 eskp.py:184
    8.28  msgid "IEK-7"
    8.29  msgstr ""
    8.30  
    8.31 -#: eskp.py:46 eskp.py:55
    8.32 +#: eskp.py:59 eskp.py:68
    8.33  msgid "2012"
    8.34  msgstr ""
    8.35  
    8.36 -#: eskp.py:47 eskp.py:56
    8.37 +#: eskp.py:60 eskp.py:69
    8.38  msgid "2011"
    8.39  msgstr ""
    8.40  
    8.41 -#: eskp.py:48 eskp.py:57
    8.42 +#: eskp.py:61 eskp.py:70
    8.43  msgid "2010"
    8.44  msgstr ""
    8.45  
    8.46 -#: eskp.py:53
    8.47 +#: eskp.py:66
    8.48  msgid "2014"
    8.49  msgstr ""
    8.50  
    8.51 -#: eskp.py:54
    8.52 +#: eskp.py:67
    8.53  msgid "2013"
    8.54  msgstr ""
    8.55  
    8.56 -#: eskp.py:66
    8.57 +#: eskp.py:80 eskp.py:160
    8.58  msgid "Close"
    8.59  msgstr ""
    8.60  
    8.61 -#: eskp.py:80 eskp.py:109 eskp.py:120
    8.62 +#: eskp.py:94 eskp.py:120 eskp.py:128
    8.63  msgid "About ESKP"
    8.64  msgstr ""
    8.65  
    8.66 -#: eskp.py:170
    8.67 +#: eskp.py:160
    8.68 +msgid "Contact"
    8.69 +msgstr ""
    8.70 +
    8.71 +#: eskp.py:201
    8.72  #, python-format
    8.73  msgid "Url: %(url)s not found"
    8.74  msgstr ""
    8.75  
    8.76 -#: eskp.py:171
    8.77 +#: eskp.py:202
    8.78  msgid "This information is not available!"
    8.79  msgstr ""
    8.80  
     9.1 --- a/translations/eskp.pot	Mon May 19 10:58:39 2014 +0200
     9.2 +++ b/translations/eskp.pot	Tue May 20 15:45:14 2014 +0200
     9.3 @@ -8,7 +8,7 @@
     9.4  msgstr ""
     9.5  "Project-Id-Version: PROJECT VERSION\n"
     9.6  "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
     9.7 -"POT-Creation-Date: 2014-05-15 10:13+0200\n"
     9.8 +"POT-Creation-Date: 2014-05-19 11:22+0200\n"
     9.9  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    9.10  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    9.11  "Language-Team: LANGUAGE <LL@li.org>\n"
    9.12 @@ -17,52 +17,56 @@
    9.13  "Content-Transfer-Encoding: 8bit\n"
    9.14  "Generated-By: Babel 1.3\n"
    9.15  
    9.16 -#: eskp.py:37 eskp.py:135
    9.17 +#: eskp.py:50 eskp.py:159 eskp.py:163
    9.18  msgid "Ozoneloss"
    9.19  msgstr ""
    9.20  
    9.21 -#: eskp.py:38
    9.22 +#: eskp.py:51
    9.23  msgid "ESKP"
    9.24  msgstr ""
    9.25  
    9.26 -#: eskp.py:39
    9.27 +#: eskp.py:52 eskp.py:184
    9.28  msgid "IEK-7"
    9.29  msgstr ""
    9.30  
    9.31 -#: eskp.py:46 eskp.py:55
    9.32 +#: eskp.py:59 eskp.py:68
    9.33  msgid "2012"
    9.34  msgstr ""
    9.35  
    9.36 -#: eskp.py:47 eskp.py:56
    9.37 +#: eskp.py:60 eskp.py:69
    9.38  msgid "2011"
    9.39  msgstr ""
    9.40  
    9.41 -#: eskp.py:48 eskp.py:57
    9.42 +#: eskp.py:61 eskp.py:70
    9.43  msgid "2010"
    9.44  msgstr ""
    9.45  
    9.46 -#: eskp.py:53
    9.47 +#: eskp.py:66
    9.48  msgid "2014"
    9.49  msgstr ""
    9.50  
    9.51 -#: eskp.py:54
    9.52 +#: eskp.py:67
    9.53  msgid "2013"
    9.54  msgstr ""
    9.55  
    9.56 -#: eskp.py:66
    9.57 +#: eskp.py:80 eskp.py:160
    9.58  msgid "Close"
    9.59  msgstr ""
    9.60  
    9.61 -#: eskp.py:80 eskp.py:109 eskp.py:120
    9.62 +#: eskp.py:94 eskp.py:120 eskp.py:128
    9.63  msgid "About ESKP"
    9.64  msgstr ""
    9.65  
    9.66 -#: eskp.py:170
    9.67 +#: eskp.py:160
    9.68 +msgid "Contact"
    9.69 +msgstr ""
    9.70 +
    9.71 +#: eskp.py:201
    9.72  #, python-format
    9.73  msgid "Url: %(url)s not found"
    9.74  msgstr ""
    9.75  
    9.76 -#: eskp.py:171
    9.77 +#: eskp.py:202
    9.78  msgid "This information is not available!"
    9.79  msgstr ""
    9.80  
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/vcards/jug.vcf	Tue May 20 15:45:14 2014 +0200
    10.3 @@ -0,0 +1,9 @@
    10.4 +BEGIN:VCARD
    10.5 +VERSION:3.0
    10.6 +ORG:Institut für Energie- und Klimaforschung Stratosphäre (IEK-7)
    10.7 +PHOTO;VALUE=URL;TYPE=JPG:http://www.fz-juelich.de/SharedDocs/Bilder/IEK/IEK-7/DE/Mitarbeiter/grooss_j_u.jpg?__blob=normal
    10.8 +TITLE:Dr.
    10.9 +FN:Jens-Uwe Grooß
   10.10 +N:Grooß;Jens-Uwe;;;
   10.11 +EMAIL;TYPE=INTERNET:j.-u.grooss@fz-juelich.de
   10.12 +END:VCARD
Impressum Datenschutzerklärung