")
-def article(article_name, data=None):
+def article(article_name, lang=None, data=None):
# We use an explicit session ID so that each payment (or payment replay) is
# bound to a browser. This forces re-play and prevents sharing the article
# by just sharing the URL.
@@ -218,9 +229,11 @@ def article(article_name, data=None):
##
# First-timer; generate order first.
if not order_id:
+ if not lang:
+ err_abort(403, message="Direct access forbidden")
order = dict(
amount=ARTICLE_AMOUNT,
- extra=dict(article_name=article_name),
+ extra=dict(article_name=article_name,lang=lang),
fulfillment_url=flask.request.base_url,
summary="Essay: " + article_name.replace("_", " "),
# 10 minutes time for a refund
@@ -251,5 +264,6 @@ def article(article_name, data=None):
# Redirect the browser to a page where the wallet can
# run the payment protocol.
response = flask.redirect(pay_status["order_status_url"])
- response.set_cookie("order_id", order_id, path=f"/essay/{article_name}")
+ response.set_cookie("order_id", order_id, path=urllib.parse.quote(f"/essay/{article_name}"))
+ response.set_cookie("order_id", order_id, path=urllib.parse.quote(f"/{lang}/essay/{article_name}"))
return response
diff --git a/talermerchantdemos/blog/content.py b/talermerchantdemos/blog/content.py
index a0e90dd..fa9ace2 100644
--- a/talermerchantdemos/blog/content.py
+++ b/talermerchantdemos/blog/content.py
@@ -26,7 +26,7 @@ from pkg_resources import resource_stream, resource_filename
LOGGER = logging.getLogger(__name__)
NOISY_LOGGER = logging.getLogger("chardet.charsetprober")
NOISY_LOGGER.setLevel(logging.INFO)
-Article = namedtuple("Article", "slug title teaser main_file extra_files")
+Article = namedtuple("Article", "slug title teaser main_file extra_files lang")
##
# @var if a article is added to this list, then it will
@@ -43,8 +43,9 @@ ARTICLES = OrderedDict()
# @param main_file path to the article's HTML file.
# @param extra_file collection of extra files associated with the
# article, like images and sounds.
-def add_article(slug, title, teaser, main_file, extra_files):
- ARTICLES[slug] = Article(slug, title, teaser, main_file, extra_files)
+# @param lang language of the arcile
+def add_article(slug, title, teaser, main_file, extra_files, lang='en'):
+ ARTICLES[slug] = Article(slug, title, teaser, main_file, extra_files, lang)
##
@@ -85,7 +86,7 @@ def add_from_html(resource_name, teaser_paragraph=0, title=None):
if title is None:
title_el = soup.find("h1", attrs={"class": ["chapter", "unnumbered"]})
if title_el is None:
- LOGGER.warning("Can't extract title from '%s'", resource_name)
+ LOGGER.warning("Cannot extract title from '%s'", resource_name)
title = resource_name
else:
title = title_el.get_text().strip()
@@ -97,7 +98,7 @@ def add_from_html(resource_name, teaser_paragraph=0, title=None):
teaser = paragraphs[teaser_paragraph].get_text()
else:
teaser = teaser.get_text()
- re_proc = re.compile("^/essay/[^/]+/data/[^/]+$")
+ re_proc = re.compile("^/[^/][^/]/essay/[^/]+/data/[^/]+$")
imgs = soup.find_all("img")
extra_files = []
for img in imgs:
@@ -114,7 +115,7 @@ def add_from_html(resource_name, teaser_paragraph=0, title=None):
else:
LOGGER.warning("Image src and slug don't match: '%s' != '%s'" \
% (img['src'].split(os.sep)[2], slug))
- add_article(slug, title, teaser, resource_name, extra_files)
+ add_article(slug, title, teaser, resource_name, extra_files, 'en')
add_from_html("blog/articles/scrap1_U.0.html", 0)
diff --git a/talermerchantdemos/blog/templates/article_frame.html b/talermerchantdemos/blog/templates/article_frame.html
index 1efc0d1..8c2b6d4 100644
--- a/talermerchantdemos/blog/templates/article_frame.html
+++ b/talermerchantdemos/blog/templates/article_frame.html
@@ -4,7 +4,8 @@
- You don't like this article? Get a refund within
- the first hour after buying it.
+ You did not like this article?
+ Get a refund
+ within the first hour after buying it.
{% endblock main %}
diff --git a/talermerchantdemos/blog/templates/confirm_refund.html b/talermerchantdemos/blog/templates/confirm_refund.html
index 10aaa74..c4773d3 100644
--- a/talermerchantdemos/blog/templates/confirm_refund.html
+++ b/talermerchantdemos/blog/templates/confirm_refund.html
@@ -3,12 +3,12 @@
Refund Article?
- Do you want to get a refund for the article {{ article_name }}? After you've requested a refund,
+ Do you want to get a refund for the article {{ article_name }}? After you have requested a refund,
you won't be able to read the article anymore.
- You will only be able to receive the refund on the same wallet that you've used to pay
+ You will only be able to receive the refund on the same wallet that you have used to pay
for this article originally.
diff --git a/talermerchantdemos/blog/templates/index.html b/talermerchantdemos/blog/templates/index.html
index 0159779..0702bf7 100644
--- a/talermerchantdemos/blog/templates/index.html
+++ b/talermerchantdemos/blog/templates/index.html
@@ -24,14 +24,15 @@
Chapters
Click on an individual chapter to to purchase it. You can
- get free, virtual money to buy articles on this page at the
bank.
+ get free, virtual money to buy articles on this page at the
+
bank.
{% for article in articles %}
{% else %}
(No articles available)
--
cgit v1.2.3