diff --git a/md_pdf/assets/templates/cover-template.html b/md_pdf/assets/templates/cover-template.html
index cac7519..841d1fa 100644
--- a/md_pdf/assets/templates/cover-template.html
+++ b/md_pdf/assets/templates/cover-template.html
@@ -1,7 +1,7 @@
-
+
{{ title }}
diff --git a/md_pdf/assets/templates/footer-template.html b/md_pdf/assets/templates/footer-template.html
index 2ea9fde..731b9fb 100644
--- a/md_pdf/assets/templates/footer-template.html
+++ b/md_pdf/assets/templates/footer-template.html
@@ -1,7 +1,7 @@
-
+
-
+
diff --git a/md_pdf/assets/templates/header-template.html b/md_pdf/assets/templates/header-template.html
index 579edb0..2c211f2 100644
--- a/md_pdf/assets/templates/header-template.html
+++ b/md_pdf/assets/templates/header-template.html
@@ -1,7 +1,7 @@
-
+
-
+
diff --git a/md_pdf/build/context.py b/md_pdf/build/context.py
index 1d43af8..61506ff 100644
--- a/md_pdf/build/context.py
+++ b/md_pdf/build/context.py
@@ -1,4 +1,4 @@
-from md_pdf.consts import TEMPLATES_DIR, STATIC_DIR, DATE_FORMAT, TIME_FORMAT, DATETIME_FORMAT
+from md_pdf.consts import TEMPLATES_DIR, STATIC_DIR, DATE_FORMAT, TIME_FORMAT, DATETIME_FORMAT, INTERNAL_TEMPLATES_DIR, INTERNAL_STATIC_DIR
from word_count import word_count
from md_pdf.utils import get_plain_text
from md_pdf import __version__
@@ -10,6 +10,8 @@ import os
EXTRA_CONTEXT = {
'templates_dir': TEMPLATES_DIR,
'static_dir': STATIC_DIR,
+ 'internal_templates_dir': INTERNAL_TEMPLATES_DIR,
+ 'internal_static_dir': INTERNAL_STATIC_DIR,
'date': datetime.datetime.now().strftime(DATE_FORMAT),
'time': datetime.datetime.now().strftime(TIME_FORMAT),
'datetime': datetime.datetime.now().strftime(DATETIME_FORMAT),
diff --git a/md_pdf/build/css.py b/md_pdf/build/css.py
index 0843923..ccbb01a 100644
--- a/md_pdf/build/css.py
+++ b/md_pdf/build/css.py
@@ -1,10 +1,10 @@
from scss import Compiler
-from md_pdf.consts import STATIC_DIR
+from md_pdf.consts import INTERNAL_STATIC_DIR
from md_pdf.build.pdf import STYLE_FILE
import os
-STYLE_SRC_FILE = os.path.join(STATIC_DIR, 'style.scss')
+STYLE_SRC_FILE = os.path.join(INTERNAL_STATIC_DIR, 'style.scss')
def render_css():
diff --git a/md_pdf/build/templates.py b/md_pdf/build/templates.py
index e593f5c..0266672 100644
--- a/md_pdf/build/templates.py
+++ b/md_pdf/build/templates.py
@@ -1,5 +1,5 @@
from jinja2 import Template
-from md_pdf.consts import TEMPLATES_DIR
+from md_pdf.consts import TEMPLATES_DIR, INTERNAL_TEMPLATES_DIR
from md_pdf.build.context import get_context
import os
import logging
@@ -8,7 +8,7 @@ logger = logging.getLogger(__file__)
FILE_NAME_FORMAT = os.path.join(TEMPLATES_DIR, "{}.html")
-TEMPLATE_FORMAT = os.path.join(TEMPLATES_DIR, "{}-template.html")
+TEMPLATE_FORMAT = os.path.join(INTERNAL_TEMPLATES_DIR, "{}-template.html")
def render_page(input_file, output_file, context):
@@ -30,4 +30,4 @@ def render_templates(config, content):
]:
render_page(TEMPLATE_FORMAT.format(template), FILE_NAME_FORMAT.format(template), context)
if config.get('toc', False):
- render_page(os.path.join(TEMPLATES_DIR, 'toc-template.xsl'), os.path.join(TEMPLATES_DIR, 'toc.xsl'), context)
+ render_page(os.path.join(INTERNAL_TEMPLATES_DIR, 'toc-template.xsl'), os.path.join(TEMPLATES_DIR, 'toc.xsl'), context)
diff --git a/md_pdf/consts.py b/md_pdf/consts.py
index 7e3620e..a02f0a7 100644
--- a/md_pdf/consts.py
+++ b/md_pdf/consts.py
@@ -1,12 +1,23 @@
import os
+import shutil
PROJECT_DIR = os.path.dirname(__file__)
WORKING_DIR = os.getcwd()
-ASSET_DIR = os.path.join(PROJECT_DIR, 'assets')
-CSL_DIR = os.path.join(ASSET_DIR, 'csl')
-TEMPLATES_DIR = os.path.join(ASSET_DIR, 'templates')
-STATIC_DIR = os.path.join(ASSET_DIR, 'static')
+try:
+ ASSETS_DIR = os.path.join(os.environ['APPDATA'], '.mdp')
+except KeyError:
+ ASSETS_DIR = os.path.join(os.environ['HOME'], '.mdp')
+
+
+CSL_DIR = os.path.join(ASSETS_DIR, 'csl')
+TEMPLATES_DIR = os.path.join(ASSETS_DIR, 'templates')
+STATIC_DIR = os.path.join(ASSETS_DIR, 'static')
+
+INTERNAL_ASSETS_DIR = os.path.join(PROJECT_DIR, 'assets')
+INTERNAL_STATIC_DIR = os.path.join(INTERNAL_ASSETS_DIR, 'static')
+INTERNAL_TEMPLATES_DIR = os.path.join(INTERNAL_ASSETS_DIR, 'templates')
+
CONFIG_FILE = os.path.join(WORKING_DIR, 'mdp.yml')
@@ -15,3 +26,8 @@ CSL_DOWNLOAD_LINK = "https://github.com/citation-style-language/styles/archive/m
DATE_FORMAT = "%d %B %Y"
TIME_FORMAT = "%H:%M"
DATETIME_FORMAT = "{} {}".format(DATE_FORMAT, TIME_FORMAT)
+
+
+os.makedirs(ASSETS_DIR, exist_ok=True)
+os.makedirs(TEMPLATES_DIR, exist_ok=True)
+os.makedirs(STATIC_DIR, exist_ok=True)
diff --git a/md_pdf/csl.py b/md_pdf/csl.py
index 1d45830..a779058 100644
--- a/md_pdf/csl.py
+++ b/md_pdf/csl.py
@@ -1,4 +1,4 @@
-from md_pdf.consts import CSL_DOWNLOAD_LINK, ASSET_DIR, CSL_DIR
+from md_pdf.consts import CSL_DOWNLOAD_LINK, ASSETS_DIR, CSL_DIR
from md_pdf.exceptions import PrematureExit
import os
import urllib
@@ -12,7 +12,7 @@ import logging
logger = logging.getLogger(__file__)
-CSL_TEMP_DIR = os.path.join(ASSET_DIR, 'styles-master')
+CSL_TEMP_DIR = os.path.join(ASSETS_DIR, 'styles-master')
def check_csl():