gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-blog] 02/02: no need for custom URL helpers


From: gnunet
Subject: [GNUnet-SVN] [taler-blog] 02/02: no need for custom URL helpers
Date: Tue, 16 Jan 2018 13:27:19 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository blog.

commit 27414f7f097d4e878bdb279ad7d41f6cdcbc2eb7
Author: Florian Dold <address@hidden>
AuthorDate: Tue Jan 16 13:27:14 2018 +0100

    no need for custom URL helpers
---
 talerblog/blog/blog.py             |  5 +--
 talerblog/blog/templates/base.html | 12 +++---
 talerblog/helpers.py               | 79 --------------------------------------
 3 files changed, 7 insertions(+), 89 deletions(-)

diff --git a/talerblog/blog/blog.py b/talerblog/blog/blog.py
index 9894a34..9c88e81 100644
--- a/talerblog/blog/blog.py
+++ b/talerblog/blog/blog.py
@@ -29,7 +29,6 @@ import base64
 import requests
 import flask
 from talerblog.talerconfig import TalerConfig
-from ..helpers import join_urlparts
 from ..blog.content import ARTICLES, get_article_file, get_image_file
 
 
@@ -50,11 +49,9 @@ app.config.from_object(__name__)
 @app.context_processor
 def utility_processor():
     # These helpers will be available in templates
-    def url(my_url):
-        return join_urlparts(flask.request.script_root, my_url)
     def env(name, default=None):
         return os.environ.get(name, default)
-    return dict(url=url, env=env)
+    return dict(env=env)
 
 
 def err_abort(status_code, **params):
diff --git a/talerblog/blog/templates/base.html 
b/talerblog/blog/templates/base.html
index 755e72f..c21a082 100644
--- a/talerblog/blog/templates/base.html
+++ b/talerblog/blog/templates/base.html
@@ -18,11 +18,11 @@
 <html data-taler-nojs="true">
 <head>
   <title>Taler Donation Demo</title>
-  <link rel="stylesheet" type="text/css" href="{{ 
url('/static/web-common/pure.css') }}" />
-  <link rel="stylesheet" type="text/css" href="{{ 
url('/static/web-common/demo.css') }}" />
-  <link rel="stylesheet" type="text/css" href="{{ 
url('/static/web-common/taler-fallback.css') }}" id="taler-presence-stylesheet" 
/>
-  <script src="{{ url("/static/web-common/taler-wallet-lib.js") }}" 
type="application/javascript"></script>
-  <script src="{{ url("/static/web-common/lang.js") }}" 
type="application/javascript"></script>
+  <link rel="stylesheet" type="text/css" href="{{ url_for('static', 
'web-common/pure.css') }}" />
+  <link rel="stylesheet" type="text/css" href="{{ url_for('static', 
'web-common/demo.css') }}" />
+  <link rel="stylesheet" type="text/css" href="{{ url_for('static', 
'web-common/taler-fallback.css') }}" id="taler-presence-stylesheet" />
+  <script src="{{ url_for('static', 'web-common/taler-wallet-lib.js') }}" 
type="application/javascript"></script>
+  <script src="{{ url_for('static', 'web-common/lang.js') }}" 
type="application/javascript"></script>
   {% block styles %}{% endblock %}
   {% block scripts %}{% endblock %}
 </head>
@@ -43,7 +43,7 @@
   </div>
 
   <section id="main" class="content">
-    <a href="{{ url("/") }}">
+    <a href="{{ url_for('index') }}">
       <div id="logo">
         <svg height="100" width="100">
           <circle cx="50" cy="50" r="40" stroke="darkcyan" stroke-width="6" 
fill="white" />
diff --git a/talerblog/helpers.py b/talerblog/helpers.py
deleted file mode 100644
index 83eccd5..0000000
--- a/talerblog/helpers.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#  This file is part of TALER
-#  (C) 2016 INRIA
-#
-#  TALER is free software; you can redistribute it and/or modify it under the
-#  terms of the GNU Affero General Public License as published by the Free 
Software
-#  Foundation; either version 3, or (at your option) any later version.
-#
-#  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
-#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR
-#  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-#
-#  You should have received a copy of the GNU General Public License along with
-#  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
-#
-#  @author Florian Dold
-#  @author Marcello Stanisci
-
-from urllib.parse import urljoin, urlencode
-import logging
-import json
-import flask
-from .talerconfig import TalerConfig
-
-LOGGER = logging.getLogger(__name__)
-
-TC = TalerConfig.from_env()
-BACKEND_URL = TC["frontends"]["backend"].value_string(required=True)
-NDIGITS = TC["frontends"]["NDIGITS"].value_int()
-CURRENCY = TC["taler"]["CURRENCY"].value_string()
-
-FRACTION_BASE = 1e8
-
-if not NDIGITS:
-    NDIGITS = 2
-
-class MissingParameterException(Exception):
-    def __init__(self, param):
-        self.param = param
-        super().__init__()
-
-def amount_to_float(amount):
-    return amount['value'] + (float(amount['fraction']) / float(FRACTION_BASE))
-
-
-def amount_from_float(floatx):
-    value = int(floatx)
-    fraction = int((floatx - value) * FRACTION_BASE)
-    return dict(currency=CURRENCY, value=value, fraction=fraction)
-
-
-def join_urlparts(*parts):
-    ret = ""
-    part = 0
-    while part < len(parts):
-        buf = parts[part]
-        part += 1
-        if ret.endswith("/"):
-            buf = buf.lstrip("/")
-        elif ret and not buf.startswith("/"):
-            buf = "/" + buf
-        ret += buf
-    return ret
-
-
-def make_url(page, *query_params):
-    """
-    Return a URL to a page in the current Flask application with the given
-    query parameters (sequence of key/value pairs).
-    """
-    query = urlencode(query_params)
-    if page.startswith("/"):
-        root = flask.request.url_root
-        page = page.lstrip("/")
-    else:
-        root = flask.request.base_url
-    url = urljoin(root, "%s?%s" % (page, query))
-    # urlencode is overly eager with quoting, the wallet right now
-    # needs some characters unquoted.
-    return url.replace("%24", "$").replace("%7B", "{").replace("%7D", "}")

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]