From 2e708ef16cfa9f691f30ee1b056a878a84bc58d9 Mon Sep 17 00:00:00 2001 From: rra Date: Sun, 7 Oct 2018 20:38:45 +0200 Subject: [PATCH] improvements to layout on mobile and in general --- pelican/pelicanconf.py | 12 +- pelican/plugins | 1 - .../addressable_paragraphs/__init__.py | 1 + .../addressable_paragraphs.py | 48 ++++++ pelican/plugins/extract_toc/README.md | 137 ++++++++++++++++++ pelican/plugins/extract_toc/__init__.py | 1 + pelican/plugins/extract_toc/extract_toc.py | 64 ++++++++ .../plugins/representative_image/Readme.md | 45 ++++++ .../plugins/representative_image/__init__.py | 1 + .../representative_image.py | 50 +++++++ pelican/plugins/summary/Readme.rst | 56 +++++++ pelican/plugins/summary/__init__.py | 1 + pelican/plugins/summary/summary.py | 111 ++++++++++++++ pelican/plugins/summary/test_summary.py | 96 ++++++++++++ .../homebrewserver.club/static/css/main.css | 63 +++++++- 15 files changed, 674 insertions(+), 13 deletions(-) delete mode 160000 pelican/plugins create mode 100644 pelican/plugins/addressable_paragraphs/__init__.py create mode 100644 pelican/plugins/addressable_paragraphs/addressable_paragraphs.py create mode 100644 pelican/plugins/extract_toc/README.md create mode 100644 pelican/plugins/extract_toc/__init__.py create mode 100644 pelican/plugins/extract_toc/extract_toc.py create mode 100644 pelican/plugins/representative_image/Readme.md create mode 100644 pelican/plugins/representative_image/__init__.py create mode 100644 pelican/plugins/representative_image/representative_image.py create mode 100644 pelican/plugins/summary/Readme.rst create mode 100644 pelican/plugins/summary/__init__.py create mode 100644 pelican/plugins/summary/summary.py create mode 100644 pelican/plugins/summary/test_summary.py diff --git a/pelican/pelicanconf.py b/pelican/pelicanconf.py index c47fd32..6717ac5 100644 --- a/pelican/pelicanconf.py +++ b/pelican/pelicanconf.py @@ -11,9 +11,11 @@ TIMEZONE = 'Europe/Paris' DEFAULT_LANG = u'en' -# Feed generation is usually not desired when developing -FEED_ALL_ATOM = None -CATEGORY_FEED_ATOM = None +# Feeds +FEED_DOMAIN = SITEURL +FEED_ALL_ATOM = 'feeds/all.atom.xml' +FEED_ALL_RSS = 'feeds/all.rss.xml' +CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml' TRANSLATION_FEED_ATOM = None AUTHOR_FEED_ATOM = None AUTHOR_FEED_RSS = None @@ -24,7 +26,7 @@ DEFAULT_PAGINATION = False #RELATIVE_URLS = True PLUGIN_PATHS = ['./plugins'] -PLUGINS = ['extract_toc', 'summary'] # ,'pelican-open_graph'] #<-- cant get that one to work +PLUGINS = ['extract_toc', 'summary','representative_image','addressable_paragraphs'] # ,'pelican-open_graph'] #<-- cant get that one to work MARKDOWN = {'extensions': ['markdown.extensions.codehilite', 'markdown.extensions.extra', @@ -54,4 +56,4 @@ MENUITEMS=( ('LINKS', '/pages/links.html') ) THEME = 'themes/homebrewserver.club' -RELATIVE_URLS = True +#RELATIVE_URLS = True diff --git a/pelican/plugins b/pelican/plugins deleted file mode 160000 index 76a8be9..0000000 --- a/pelican/plugins +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 76a8be9978bcfddc6dcf05678420fb06ee32cb0d diff --git a/pelican/plugins/addressable_paragraphs/__init__.py b/pelican/plugins/addressable_paragraphs/__init__.py new file mode 100644 index 0000000..bcb138c --- /dev/null +++ b/pelican/plugins/addressable_paragraphs/__init__.py @@ -0,0 +1 @@ +from .addressable_paragraphs import * diff --git a/pelican/plugins/addressable_paragraphs/addressable_paragraphs.py b/pelican/plugins/addressable_paragraphs/addressable_paragraphs.py new file mode 100644 index 0000000..55c375c --- /dev/null +++ b/pelican/plugins/addressable_paragraphs/addressable_paragraphs.py @@ -0,0 +1,48 @@ +""" +Addressable Paragraphs +------------------------ +In converting from .md to .html, images are wrapped in

tags. +This plugin gives those paragraphs the 'img' class for styling enhancements. +In case there is any description immediately following that image, it is wrapped in another paragraph with the 'caption' class. + +Copyright (C) 2018 Roel Roscam Abbing + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" + +from __future__ import unicode_literals +from pelican import signals +from bs4 import BeautifulSoup + +def content_object_init(instance): + + if instance._content is not None: + content = instance._content + soup = BeautifulSoup(content, 'html.parser') + + for p in soup(['p', 'object']): + if p.findChild('img'): + p.attrs['class'] = 'img' + caption = soup.new_tag('p',**{'class':'caption'}) + if len(p.contents) > 1: #if we have more than just the tag + for i in reversed(p.contents): + if i.name != 'img': #if it is not an tag + caption.insert(0,i.extract()) + p.insert_after(caption) + + instance._content = soup.decode() + + +def register(): + signals.content_object_init.connect(content_object_init) diff --git a/pelican/plugins/extract_toc/README.md b/pelican/plugins/extract_toc/README.md new file mode 100644 index 0000000..40d2bee --- /dev/null +++ b/pelican/plugins/extract_toc/README.md @@ -0,0 +1,137 @@ +Extract Table of Content +======================== + +A Pelican plugin to extract table of contents (ToC) from `article.content` and +place it in its own `article.toc` variable for use in templates. + +Copyright (c) Talha Mansoor + +Author | Talha Mansoor +----------------|----- +Author Email | talha131@gmail.com +Author Homepage | http://onCrashReboot.com +Github Account | https://github.com/talha131 + + +Acknowledgement +--------------- + +Thanks to [Avaris](https://github.com/avaris) for going out of the way to help +me fix Unicode issues and doing a thorough code review. + +Thanks to [gw0](http://gw.tnode.com/) for adding Pandoc reader support. + + +Why do you need it? +=================== + +Pelican can generate ToC of reST and Markdown files, using markup's respective +directive and extension. Such ToC is generated and placed at the beginning of +`article.content` like a string. Consequently it can not be placed anywhere +else on the page (eg. `