Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Code-refactory and fixes to Makefile #682

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ Bruno Rocha <[email protected]>
Eric Ho <[email protected]>
Filipe Amaral <[email protected]>
Lex Quarkie <[email protected]>
Micheal Waltz <[email protected]>
Red Hat Developers Launcher <[email protected]>
marcosptf <[email protected]>
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
CHANGES
=======

* Initial commit
* Update README.md
* Update setup.cfg
* Update README.md
* Re-factor Dockerfile to use multi-stage builds, fixes #606
* debugger docker file (#669)
* removing flit from dockerfile (#668)
* added --pre release to readme
* 0.4.1
* removed unused \_\_version\_\_
* Fix wrong template call
Expand Down
27 changes: 18 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: docs test pep8 clean install build publish tree create_env devserver pandoc adduser
.PHONY: docs test pep8 clean install build publish tree createvenv devserver pandoc adduser develop

test: pep8
QUOKKA_MODE=test py.test --cov=quokka -l --tb=short --maxfail=1 tests/
QUOKKA_MODE=test pytest --cov=quokka -l --tb=short --maxfail=1 tests/

pep8:
@flake8 quokka --ignore=F403 --exclude=migrations
Expand All @@ -21,27 +21,36 @@ clean:
@rm -rf *.egg-info


develop:
@. .venv/bin/activate
@pip install --upgrade pip
@pip install -r requirements.txt
@pip install -r requirements-dev.txt
@pip freeze

reqs:
@pip install pbr pypandoc pygments

pandoc: reqs
@pandoc --from=markdown --to=rst --output=README.rst README.md

install: clean pandoc
@python setup.py develop
install:
@python3.6 setup.py develop

build: clean pandoc
@python setup.py sdist bdist_wheel --universal
build:
@python3.6 setup.py sdist bdist_wheel --universal

publish: build
@twine upload dist/*

tree:
@tree -L 1 -a -I __pycache__ --dirsfirst --noreport

create_env:
@rm -rf venv
@python3.6 -m venv venv
createvenv:
@rm -rf .venv
@python3.6 -m venv .venv
@. .venv/bin/activate
@ls -lparth

devserver:
$(info "Running quokka project template...")
Expand Down
2 changes: 1 addition & 1 deletion quokka/admin/wtforms_html5.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 0 additions & 11 deletions quokka/core/content/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,6 @@ def locale_modified(self):

@property
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'
# }
data = {}
data.update(custom_var_dict(self.data.get('custom_vars')))
return data
Expand Down
5 changes: 3 additions & 2 deletions quokka/core/content/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ 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', ''))
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'))

Expand Down
5 changes: 3 additions & 2 deletions quokka/core/content/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
)
Expand Down
19 changes: 8 additions & 11 deletions quokka/core/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions quokka/core/views/sitemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion quokka/utils/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down