From 42a247c89fd533083731df40d601610e175d1c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Thu, 10 Dec 2015 15:44:10 +0100 Subject: [PATCH] Added tags --- balkiantheme/static/css/main.css | 25 +++++++++++++++++ balkiantheme/templates/article.html | 2 +- balkiantheme/templates/base.html | 15 ++++++++-- balkiantheme/templates/index.html | 4 +-- balkiantheme/templates/tags.html | 10 +++++++ content/cheats/2015-12-10-org-tricks.rst | 15 ++++++++++ pelicanconf.py | 35 ++++++++++++++++++++---- 7 files changed, 95 insertions(+), 11 deletions(-) create mode 100644 balkiantheme/templates/tags.html create mode 100644 content/cheats/2015-12-10-org-tricks.rst diff --git a/balkiantheme/static/css/main.css b/balkiantheme/static/css/main.css index b0ea0dc..735f32c 100755 --- a/balkiantheme/static/css/main.css +++ b/balkiantheme/static/css/main.css @@ -450,7 +450,10 @@ footer a:hover { font-weight: bold; clear: both; border-top: dashed 1px #CCC; + padding: 0.2em; + padding-top: 0.5em; } + .entries dd { float: right; margin: 2px; @@ -471,8 +474,13 @@ a:hover { -webkit-transform-origin: 95% 50%; } +.tag { + margin: 2px; +} + .tag * { display: inline-block; + color: black; } .hll { @@ -493,4 +501,21 @@ a:hover { .label:after{ content: " •"; color: #666; +} + +.readmore { + background: #EAEAEA; + padding: 0.5em; + color: white; + border-radius: 0.5em; + margin: 1em auto; + display: inline-block; +} + +.readmore:hover { + background: #DADADA; +} + +.readmore a { + color: black; } \ No newline at end of file diff --git a/balkiantheme/templates/article.html b/balkiantheme/templates/article.html index 8422468..f369c51 100644 --- a/balkiantheme/templates/article.html +++ b/balkiantheme/templates/article.html @@ -15,7 +15,7 @@

{{ article.title }}

{{ article.date | date_to_string }} {% for c in article.tags %} - {{ c }} + {{ c }} {% endfor %} diff --git a/balkiantheme/templates/base.html b/balkiantheme/templates/base.html index 78bd097..e0e7dd4 100644 --- a/balkiantheme/templates/base.html +++ b/balkiantheme/templates/base.html @@ -27,9 +27,18 @@
diff --git a/balkiantheme/templates/index.html b/balkiantheme/templates/index.html index c70e0c0..afe19c3 100644 --- a/balkiantheme/templates/index.html +++ b/balkiantheme/templates/index.html @@ -28,13 +28,13 @@ balkian.com

{{ post.title }}

{{ post.date | date_to_string }} {% for c in post.tags %} - {{ c }} + {{ c }} {% endfor %}
{{ post.summary }}
- Read more... +
Read more...
{% endfor %} {% if articles_paginator.num_pages > 0 %} diff --git a/balkiantheme/templates/tags.html b/balkiantheme/templates/tags.html new file mode 100644 index 0000000..5ccea5b --- /dev/null +++ b/balkiantheme/templates/tags.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} +{% block content_title %} +{{ page_name }} +{% endblock %} +{% block content %} +

Post tags

+{% for tag, carticles in tags | sort_by_article_count %} +{{ tag }} ({{ carticles | length }}) +{% endfor %} +{% endblock %} diff --git a/content/cheats/2015-12-10-org-tricks.rst b/content/cheats/2015-12-10-org-tricks.rst new file mode 100644 index 0000000..2a134ac --- /dev/null +++ b/content/cheats/2015-12-10-org-tricks.rst @@ -0,0 +1,15 @@ +Org-mode tricks +############### +:date: 2015-12-10 Thu 11:34:00 +:tags: emacs, productivity, editor, org +:category: cheats + + +Show plain text version +@@@@@@@@@@@@@@@@@@@@@@@ + +.. code-block:: elisp + + (font-lock-mode) + + diff --git a/pelicanconf.py b/pelicanconf.py index 92c38b1..85b84a7 100644 --- a/pelicanconf.py +++ b/pelicanconf.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # from __future__ import unicode_literals +from functools import partial +from collections import Counter AUTHOR = u'J. Fernando S\xe1nchez' SITENAME = u'balkian.com' @@ -35,11 +37,6 @@ DEFAULT_PAGINATION = 10 #RELATIVE_URLS = True THEME = "balkiantheme" -def date_to_string(date): - return date.strftime('%Y-%m-%d') - -JINJA_FILTERS = {'date_to_string': date_to_string} - PLUGIN_PATHS = ["plugins/",] PLUGINS = ["neighbors",] @@ -60,3 +57,31 @@ IGNORE_FILES = ['.*'] MENUITEMS=[('CV','http://jfernando.es')] DISPLAY_PAGES_ON_MENU=True +DISPLAY_CATEGORIES_ON_MENU = True + +CATEGORY_URL = 'category/{slug}.html' +CATEGORY_SAVE_AS = 'category/{slug}.html' + +CATEGORIES_SAVE_AS = 'categories.html' +DEFAULT_CATEGORY = 'misc' + + +def date_to_string(date): + return date.strftime('%Y-%m-%d') + +def sort_by_article_count(x): + return sorted(x, key=lambda tags: len(tags[1]), reverse=True) + +def normalize_count(x): + articles, tag = x + counter = Counter() + for i in articles: + counter.update(i.tags) + maximum = counter.most_common(1)[0][1] + return 100*counter[tag]/maximum + +JINJA_FILTERS = { + 'sort_by_article_count': sort_by_article_count, + 'date_to_string': date_to_string, + 'normalize_count': normalize_count +}