diff options
Diffstat (limited to '')
-rw-r--r-- | config/blog.toml | 12 | ||||
-rw-r--r-- | config/generator.toml | 21 | ||||
-rwxr-xr-x | pyblog | 74 | ||||
-rw-r--r-- | requirements.txt | 1 |
4 files changed, 73 insertions, 35 deletions
diff --git a/config/blog.toml b/config/blog.toml new file mode 100644 index 00000000..48de9493 --- /dev/null +++ b/config/blog.toml @@ -0,0 +1,12 @@ +[blog] + BLOG_HOME = "http://neodarz.net/" + CUSTOM_DOMAIN = "neodarz.net" # GitHub Pages custom domain (could be None) + BLOG_TITLE = "Why is there always a cat on whatever you're editing?" + BLOG_DESCRIPTION = "Just my stupid personal website" + LANGUAGE = "en-us" + AUTHOR = "neodarz" + AUTHOR_EMAIL = "neodarz@neodarz.net" + ATOM_ICON_PATH = "img/icon-400.png" # set to None to leave it out + RSS_ICON_PATH = "img/icon-100.png" # set to None to leave it out + RSS_ICON_WIDTH = 100 + RSS_ICON_HEIGHT = 100 diff --git a/config/generator.toml b/config/generator.toml new file mode 100644 index 00000000..d2177c07 --- /dev/null +++ b/config/generator.toml @@ -0,0 +1,21 @@ +########################### GENERATOR CONFIGURATIONS ########################### +# Do not touch unless you know what you are doing. +[generator] + GENERATOR_NAME = "pyblog" + GENERATOR_HOME_PAGE = "https://github.com/zmwangx/zmwangx.github.io" + + SOURCEDIR = "source" + POSTSDIR = "blog" + INDEXMD = "index.md" + GENERATORSOURCE = "pyblog" + HTMLTEMPLATE = "template.html" + BUILDDIR = "build" + ATOM = "atom.xml" + RSS = "rss.xml" + INDEXHTML = "index.html" + EXCLUDELIST = ".exclude" + + FEED_MAX_ENTRIES = 20 + CODE_LINE_HEIGHT = 18 +####################### END OF GENERATOR CONFIGURATIONS ######################## + @@ -2,7 +2,6 @@ """A simple blog generator with Pandoc as backend.""" -# TODO: put blog configurations in a config file # TODO: auto retouch: prompt for git commit amend after touching # (display commit message to avoid amending the wrong commit) @@ -41,42 +40,47 @@ from bs4 import UnicodeDammit from pprint import pprint import requests -############################# BLOG CONFIGURATIONS ############################## -# Safe to customize -BLOG_HOME = "http://neodarz.net/" -CUSTOM_DOMAIN = "neodarz.net" # GitHub Pages custom domain (could be None) -BLOG_TITLE = "Why is there always a cat on whatever you're editing?" -BLOG_DESCRIPTION = "Just my stupid personal website" -LANGUAGE = "en-us" -AUTHOR = "neodarz" -AUTHOR_EMAIL = "neodarz@neodarz.net" -ATOM_ICON_PATH = "img/icon-400.png" # set to None to leave it out -RSS_ICON_PATH = "img/icon-100.png" # set to None to leave it out -RSS_ICON_WIDTH = 100 -RSS_ICON_HEIGHT = 100 -########################## END OF BLOG CONFIGURATIONS ########################## - - -########################### GENERATOR CONFIGURATIONS ########################### -# Do not touch unless you know what you are doing. -GENERATOR_NAME = "pyblog" -GENERATOR_HOME_PAGE = "https://github.com/zmwangx/zmwangx.github.io" +import toml ROOTDIR = os.path.dirname(os.path.realpath(__file__)) -SOURCEDIR = os.path.join(ROOTDIR, "source") -POSTSDIR = os.path.join(SOURCEDIR, "blog") -INDEXMD = os.path.join(SOURCEDIR, "index.md") -GENERATORSOURCE = os.path.join(ROOTDIR, "pyblog") -HTMLTEMPLATE = os.path.join(SOURCEDIR, "template.html") -BUILDDIR = os.path.join(ROOTDIR, "build") -ATOM = os.path.join(BUILDDIR, "atom.xml") -RSS = os.path.join(BUILDDIR, "rss.xml") -INDEXHTML = os.path.join(BUILDDIR, "index.html") -EXCLUDELIST = os.path.join(SOURCEDIR, ".exclude") - -FEED_MAX_ENTRIES = 20 -CODE_LINE_HEIGHT = 18 -####################### END OF GENERATOR CONFIGURATIONS ######################## + + +config_blog = toml.load(os.path.join(ROOTDIR, "config/blog.toml")) +config_generator = toml.load(os.path.join(ROOTDIR, "config/generator.toml")) + + +config = {**config_blog, **config_generator} + +# Blog configuration +BLOG_HOME = config["blog"]["BLOG_HOME"] +CUSTOM_DOMAIN = config["blog"]["CUSTOM_DOMAIN"] +BLOG_TITLE = config["blog"]["BLOG_TITLE"] +BLOG_DESCRIPTION = config["blog"]["BLOG_DESCRIPTION"] +LANGUAGE = config["blog"]["LANGUAGE"] +AUTHOR = config["blog"]["AUTHOR"] +AUTHOR_EMAIL = config["blog"]["AUTHOR_EMAIL"] +ATOM_ICON_PATH = config["blog"]["ATOM_ICON_PATH"] +RSS_ICON_PATH = config["blog"]["RSS_ICON_PATH"] +RSS_ICON_WIDTH = config["blog"]["RSS_ICON_WIDTH"] +RSS_ICON_HEIGHT = config["blog"]["RSS_ICON_HEIGHT"] + +#generator configurations +GENERATOR_NAME = config["generator"]["GENERATOR_NAME"] +GENERATOR_HOME_PAGE = config["generator"]["GENERATOR_HOME_PAGE"] + +SOURCEDIR = os.path.join(ROOTDIR, config["generator"]["SOURCEDIR"]) +POSTSDIR = os.path.join(SOURCEDIR, config["generator"]["POSTSDIR"]) +INDEXMD = os.path.join(SOURCEDIR, config["generator"]["INDEXMD"]) +GENERATORSOURCE = os.path.join(ROOTDIR, config["generator"]["GENERATORSOURCE"]) +HTMLTEMPLATE = os.path.join(SOURCEDIR, config["generator"]["HTMLTEMPLATE"]) +BUILDDIR = os.path.join(ROOTDIR, config["generator"]["BUILDDIR"]) +ATOM = os.path.join(BUILDDIR, config["generator"]["ATOM"]) +RSS = os.path.join(BUILDDIR, config["generator"]["RSS"]) +INDEXHTML = os.path.join(BUILDDIR, config["generator"]["INDEXHTML"]) +EXCLUDELIST = os.path.join(SOURCEDIR, config["generator"]["EXCLUDELIST"]) + +FEED_MAX_ENTRIES = config["generator"]["FEED_MAX_ENTRIES"] +CODE_LINE_HEIGHT = config["generator"]["CODE_LINE_HEIGHT"] # declare the global foreground ANSI codes diff --git a/requirements.txt b/requirements.txt index 9ea29c20..49c845ac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ blessed colorama lxml python-dateutil +toml |