From 47adb37b571b89e52b456ac5a586874a74c5376d Mon Sep 17 00:00:00 2001 From: marcosptf Date: Sun, 19 May 2019 10:28:12 -0300 Subject: [PATCH 1/3] updating Dockerfile to 3.8 tag version --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5babf6988..99faa067e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ # Requires Docker v17.05 # Base image for build and runtime -FROM python:3.7-slim-stretch AS base +FROM python:3.8.0a4-stretch AS base LABEL maintainer="Eric Ho " WORKDIR /usr/src/app @@ -40,7 +40,7 @@ FROM base AS run # Copy from build image COPY --from=build /usr/src/app/ /usr/src/app/ -COPY --from=build /usr/local/lib/python3.7/ /usr/local/lib/python3.7/ +COPY --from=build /usr/local/lib/python3.8/ /usr/local/lib/python3.8/ COPY --from=build /usr/local/bin/quokka /usr/local/bin/quokka WORKDIR /usr/src/app/quokka/project_template From 6f1496b51580f2570f987b660e295d75f3543e05 Mon Sep 17 00:00:00 2001 From: marcosptf Date: Thu, 6 Jun 2019 08:12:51 -0300 Subject: [PATCH 2/3] fixing pep8 --- quokka/core/content/models.py | 14 +++++++------- quokka/core/content/utils.py | 6 ++++-- quokka/core/content/views.py | 5 +++-- quokka/core/db.py | 19 ++++++++----------- quokka/core/views/sitemap.py | 10 +++++----- quokka/utils/upload.py | 2 +- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/quokka/core/content/models.py b/quokka/core/content/models.py index 6d2fcc4d9..5358ed079 100644 --- a/quokka/core/content/models.py +++ b/quokka/core/content/models.py @@ -230,13 +230,13 @@ def metadata(self): # TODO: get metadata from database # TODO: implement libratar/gravatar # return { - # 'cover': 'foo', - # 'author_gravatar': 'http://i.pravatar.cc/300', - # 'about_author': 'About Author', - # 'translations': ['en'], - # 'og_image': 'foo', - # 'series': 'aa', - # 'asides': 'aaa' + # 'cover': 'foo', + # 'author_gravatar': 'http://i.pravatar.cc/300', + # 'about_author': 'About Author', + # 'translations': ['en'], + # 'og_image': 'foo', + # 'series': 'aa', + # 'asides': 'aaa' # } data = {} data.update(custom_var_dict(self.data.get('custom_vars'))) diff --git a/quokka/core/content/utils.py b/quokka/core/content/utils.py index 57aaef312..d4c5ff1e7 100644 --- a/quokka/core/content/utils.py +++ b/quokka/core/content/utils.py @@ -10,10 +10,12 @@ def url_for_content(content, include_ext=True): else: data = content + category_slug_data = data.get('category_slug') + category_data = slugify_category(data.get('category') or '') category_slug = ( - data.get('category_slug') or - slugify_category(data.get('category') or '') + category_slug_data or category_data ) + slug = data.get('slug') or slugify(data.get('title')) if category_slug: diff --git a/quokka/core/content/views.py b/quokka/core/content/views.py index 74c72d288..08d6d9bc1 100644 --- a/quokka/core/content/views.py +++ b/quokka/core/content/views.py @@ -255,6 +255,8 @@ def render_rss(self, content_type, templates, **context): for content in contents: content = make_model(content) + content_data = content.title.encode('utf-8') + content_data += content.url.encode('utf-8') if content.date > rss_pubdate: rss_pubdate = content.date @@ -267,8 +269,7 @@ def render_rss(self, content_type, templates, **context): author=str(content.author), categories=[str(content.tags)], guid=hashlib.sha1( - content.title.encode('utf-8') + - content.url.encode('utf-8') + content_data ).hexdigest(), pubDate=content.date, ) diff --git a/quokka/core/db.py b/quokka/core/db.py index 431c55aea..afc09ad77 100644 --- a/quokka/core/db.py +++ b/quokka/core/db.py @@ -183,17 +183,14 @@ def page_set(self, *args, **kwargs): return self.content_set(*args, **kwargs) def block_set(self, *args, **kwargs): - kwargs.setdefault( - 'sort', - self.app.theme_context.get( - 'BLOCK_ORDER_BY', [('title', -1)] - ) - ) - if not args: - args = [{'content_type': 'block'}] - elif isinstance(args[0], dict): - args[0]['content_type'] = 'block' - return self.content_set(*args, **kwargs) + kwargs.setdefault('sort', self.app.theme_context.get( + 'BLOCK_ORDER_BY', [('title', -1)] + )) + if not args: + args = [{'content_type': 'block'}] + elif isinstance(args[0], dict): + args[0]['content_type'] = 'block' + return self.content_set(*args, **kwargs) def select(self, colname, *args, **kwargs): return self.get_collection(colname).find(*args, **kwargs) diff --git a/quokka/core/views/sitemap.py b/quokka/core/views/sitemap.py index 871372817..2cdca943b 100644 --- a/quokka/core/views/sitemap.py +++ b/quokka/core/views/sitemap.py @@ -11,12 +11,12 @@ def get_contents(self): TODO: Should include extra paths, fixed paths config based paths, static paths """ + content = self.get_index() + self.get_categories() + content += self.get_tags() + self.get_authors() + content += self.get_articles_and_pages() + return ( - self.get_index() + - self.get_categories() + - self.get_tags() + - self.get_authors() + - self.get_articles_and_pages() + content ) def get_index(self): diff --git a/quokka/utils/upload.py b/quokka/utils/upload.py index 251e1c50f..bc8042679 100644 --- a/quokka/utils/upload.py +++ b/quokka/utils/upload.py @@ -9,7 +9,7 @@ def dated_path(obj, file_data): try: - prefix = getattr(obj, 'model_name') + prefix = getattr(obj, 'model_name', None) except BaseException: prefix = "undefined" From edb5142a083e641b090fe6a504f9ec39599311cc Mon Sep 17 00:00:00 2001 From: marcosptf Date: Thu, 6 Jun 2019 08:17:27 -0300 Subject: [PATCH 3/3] fixing pep8 - v2 --- quokka/admin/wtforms_html5.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quokka/admin/wtforms_html5.py b/quokka/admin/wtforms_html5.py index ccc3a1c09..85e01933f 100644 --- a/quokka/admin/wtforms_html5.py +++ b/quokka/admin/wtforms_html5.py @@ -195,7 +195,7 @@ def set_title(field, render_kw=None): """ if render_kw is None: render_kw = {} - if 'title' not in render_kw and getattr(field, 'description'): + if 'title' not in render_kw and getattr(field, 'description', None): render_kw['title'] = '{}'.format(field.description) return render_kw