From a49e0873b37b87d5724801fdce191c01989188f8 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 27 May 2016 23:19:03 +0100 Subject: [PATCH] Add projects category page --- pelicanconf.py | 6 ++++-- plugins/filters.py | 8 +++++++ requirements.txt | 1 + theme/templates/category.html | 40 +++++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 theme/templates/category.html diff --git a/pelicanconf.py b/pelicanconf.py index 85b4263..0f6f8d3 100644 --- a/pelicanconf.py +++ b/pelicanconf.py @@ -36,7 +36,6 @@ SOCIAL = social.generate() DEFAULT_PAGINATION = False DELETE_OUTPUT_DIRECTORY = True - PAGE_PATHS = ["pages"] PAGE_SAVE_AS = "{slug}/index.html" PAGE_URL = "{slug}" @@ -68,6 +67,8 @@ ARCHIVES_URL = False ARCHIVES_SAVE_AS = False CATEGORY_SAVE_AS = "{slug}/index.html" +CATEGORY_URL = "{slug}/" + CATEGORIES_SAVE_AS = False USE_FOLDER_AS_CATEGORY = True @@ -80,6 +81,7 @@ SITEMAP = { import filters JINJA_FILTERS = { - "datetime": filters.format_datetime + "datetime": filters.format_datetime, + "raw": filters.html_to_raw } # Extra context diff --git a/plugins/filters.py b/plugins/filters.py index 4b6d384..4789504 100644 --- a/plugins/filters.py +++ b/plugins/filters.py @@ -1,5 +1,13 @@ import iso8601 +from bs4 import BeautifulSoup def format_datetime(value): return iso8601.parse_date(str(value)).strftime("%x %-H:%M") + + +def html_to_raw(html): + soup = BeautifulSoup(html, "html.parser") + for script in soup(["script", "style"]): # Remove script / style tags + script.extract() + return soup.get_text() diff --git a/requirements.txt b/requirements.txt index 4ddd624..50f5471 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +beautifulsoup4==4.4.1 colorama==0.3.6 flake8==2.5.0 gitpython==2.0.3 diff --git a/theme/templates/category.html b/theme/templates/category.html new file mode 100644 index 0000000..34c8468 --- /dev/null +++ b/theme/templates/category.html @@ -0,0 +1,40 @@ +{% extends "base.html" %} + +{% block htmltitle %} + All {{ category }} +{% endblock %} + +{% block content %} +
+
+
+
+

About Me

+
+
+
+
+
+
+
+
+ {% for article in dates %} + + {% endfor %} +
+
+
+{% endblock %}