francescomecca.eu/plugins/symlinks/symlinks.py
2018-11-10 18:19:00 +01:00

44 lines
1.1 KiB
Python

import glob
from nikola.plugin_categories import Task
from nikola import utils
from mako.template import Template
from mako.lookup import TemplateLookup
from nikola.utils import LOGGER
# self.site is defined in nikola.nikola.Nikola(object)
class Plugin(Task):
name = "symlinks"
def gen_tasks(self):
# This function will be called when the task is executed
def say_hi(bye):
import os
pwd = os.getcwd()
os.chdir('output')
try:
os.symlink('assets/favicon.ico', 'favicon.ico')
except FileExistsError as e:
pass
try:
os.symlink('../wp-content/', 'wp-content')
except FileExistsError as e:
pass
os.chdir(pwd)
return True
# Never fail because a config key is missing.
bye = self.site.config.get('BYE_WORLD', False)
# Yield a task for Doit
return {
'basename': 'symlinks',
'actions': [(say_hi, [bye])],
'uptodate': [False],
}