Custom plugins for Pelican, used in the Varia website.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.1 KiB

#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from pelican import signals
from os import listdir, path
import time
from datetime import datetime
def getCreationTime(img):
creationtime = time.ctime(path.getctime(img))
date = datetime(creationtime).strftime('%y%m%d')
print('creationtime', date)
return date
def getStream(generator):
for page in generator.pages:
dir = "/var/www/stream"
if path.exists(dir):
# NOTE(decentral1se); Sorry! I had to comment this out because I am not sure
# what it is doing and it is breaking the site generation at the moment. The
# error I am seeing is: "CRITICAL: TypeError: an integer is required (got type str)"
# images = [(getCreationTime(dir+'/'+f), f) for f in listdir(dir) if path.isfile(path.join(dir, f))]
pass
else: # if the website is generated locally
images = ['placeholder.png']
print('>>> The stream is streaming!', images)
page.stream = images
def register():
# Note(decentral1se): disabling for now
# signals.page_generator_finalized.connect(getStream)
pass