add screenfetch to metadata
This commit is contained in:
parent
5e97934204
commit
cde89c2826
3 changed files with 23 additions and 7 deletions
|
@ -64,7 +64,8 @@ PLUGINS = [
|
|||
"filetime_from_git",
|
||||
"pelican-jinja2content",
|
||||
"metatags",
|
||||
"autopages"
|
||||
"autopages",
|
||||
"screenfetch"
|
||||
]
|
||||
|
||||
if BUILD_PRODUCTION:
|
||||
|
@ -97,6 +98,5 @@ import filters
|
|||
JINJA_FILTERS = {
|
||||
"datetime": filters.format_datetime,
|
||||
"category_find": filters.category_find,
|
||||
"limit": filters.limit,
|
||||
"ansi2html": filters.ansi2html
|
||||
"limit": filters.limit
|
||||
}
|
||||
|
|
|
@ -19,7 +19,3 @@ def limit(line, length):
|
|||
return " ".join(line.split(" ")[:length]) + '...'
|
||||
elif isinstance(line, list):
|
||||
return line[:length]
|
||||
|
||||
|
||||
def ansi2html(content):
|
||||
return "<pre class='highlight ansi-up'>{0}</pre>".format(content)
|
||||
|
|
20
plugins/screenfetch.py
Normal file
20
plugins/screenfetch.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
from pelican import signals
|
||||
import os.path
|
||||
|
||||
|
||||
def screenfetch(instance):
|
||||
base_path = os.path.dirname(os.path.abspath(__file__))
|
||||
if type(instance).__name__ not in ['Article', 'Page', 'Draft']:
|
||||
return
|
||||
|
||||
if not instance.metadata.get('screenfetch_path', False):
|
||||
return
|
||||
|
||||
content_dir = os.path.join(base_path, instance.settings['PATH'])
|
||||
|
||||
file_data = open(os.path.join(content_dir, instance.metadata['screenfetch_path'])).read()
|
||||
instance.screenfetch = "<pre class='highlight ansi-up'>{0}</pre>".format(file_data)
|
||||
|
||||
|
||||
def register():
|
||||
signals.content_object_init.connect(screenfetch)
|
Reference in a new issue