1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
theorangeone.net-legacy/plugins/screenfetch.py

21 lines
615 B
Python

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)