summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pyssg/builder.py38
-rw-r--r--src/pyssg/md/parser.py15
-rw-r--r--src/pyssg/plt/default.yaml15
-rw-r--r--src/pyssg/plt/page.html4
-rw-r--r--src/pyssg/plt/page_index.html4
-rw-r--r--src/pyssg/plt/tag_list.html4
6 files changed, 37 insertions, 43 deletions
diff --git a/src/pyssg/builder.py b/src/pyssg/builder.py
index 0cb1728..d70b976 100644
--- a/src/pyssg/builder.py
+++ b/src/pyssg/builder.py
@@ -95,29 +95,20 @@ class Builder:
all_pages=self.all_files,
all_tags=self.all_tags)
- self.__render_pages(self.dir_cfg['plt'])
+ self.__render_pages(self.dir_cfg['plt']['page'])
- if self.dir_cfg['tags']:
+ if 'tags' in self.dir_cfg['plt']:
create_dir(os.path.join(self.dir_cfg['dst'], 'tags'), True)
- if isinstance(self.dir_cfg['tags'], str):
- self.__render_tags(self.dir_cfg['tags'])
- else:
- self.__render_tags('tag.html')
- log.debug('rendered tags for dir "%s"', self.dir_cfg['dir'])
-
- default_plts: dict[str, str] = {'index': 'index.html',
- 'rss': 'rss.xml',
- 'sitemap': 'sitemap.xml'}
- for opt in default_plts.keys():
- if self.dir_cfg[opt]:
- if isinstance(self.dir_cfg[opt], str):
- self.__render_template(self.dir_cfg[opt],
- default_plts[opt],
- **self.common_vars)
- else:
- self.__render_template(default_plts[opt],
- default_plts[opt],
- **self.common_vars)
+ self.__render_tags(self.dir_cfg['plt']['tags'])
+
+ generic: dict[str, str] = {'index': 'index.html',
+ 'rss': 'rss.xml',
+ 'sitemap': 'sitemap.xml'}
+ for plt in generic:
+ if plt in self.dir_cfg['plt']:
+ self.__render_template(self.dir_cfg['plt'][plt],
+ generic[plt],
+ **self.common_vars)
def __create_dir_structure(self) -> None:
log.debug('creating dir structure for dir "%s"', self.dir_cfg['dir'])
@@ -153,6 +144,9 @@ class Builder:
def __render_tags(self, template_name: str) -> None:
log.debug('rendering tags with template "%s"', template_name)
+ tag_prefix: str = ''
+ if self.dir_cfg['tags_prefix']:
+ tag_prefix = self.dir_cfg['tags_prefix']
tag_vars: dict = deepcopy(self.common_vars)
tag_pages: list[Page]
for t in self.all_tags:
@@ -164,7 +158,7 @@ class Builder:
log.debug('added page "%s" to tag "%s"', p.name, t)
tag_vars['tag'] = t
tag_vars['tag_pages'] = tag_pages
- t_fname: str = f'tags/{t}.html'
+ t_fname: str = f'tags/{tag_prefix}{t}.html'
# actually render tag page
self.__render_template(template_name, t_fname, **tag_vars)
log.debug('rendered tag "%s"', t)
diff --git a/src/pyssg/md/parser.py b/src/pyssg/md/parser.py
index 34a8922..32f86d2 100644
--- a/src/pyssg/md/parser.py
+++ b/src/pyssg/md/parser.py
@@ -109,15 +109,12 @@ class MDParser:
page.parse_metadata()
self.all_files.append(page)
- if self.dir_config['tags']:
- if entry[4] is not None:
- if set(page.tags) != set(entry[4]):
- self.db.update_tags(f, page.tags)
-
- for t in page.tags:
- if t not in self.all_tags:
- self.all_tags.append(t)
- log.debug('added tag "%s" to all tags', t)
+ # always the most up to date tags
+ self.db.update_tags(f, page.tags)
+ for t in page.tags:
+ if t not in self.all_tags:
+ self.all_tags.append(t)
+ log.debug('added tag "%s" to all tags', t)
self.all_files.sort(reverse=True)
self.all_tags.sort()
diff --git a/src/pyssg/plt/default.yaml b/src/pyssg/plt/default.yaml
index cca0fbc..9be299a 100644
--- a/src/pyssg/plt/default.yaml
+++ b/src/pyssg/plt/default.yaml
@@ -14,15 +14,18 @@ fmt:
date: "%a, %b %d, %Y @ %H:%M %Z"
rss_date: "%a, %d %b %Y %H:%M:%S GMT"
sitemap_date: "%Y-%m-%d"
+ list_date: "%b %d"
+ list_sep_date: "%Y"
info:
version: "0.0.0"
...
---
dir: "/"
-plt: "page.html"
-tags: False
-tags_prefix: ''
-index: False
-rss: False
-sitemap: False
+plt:
+ page: "page.html"
+ index: "page_index.html"
+ tags: "tag_index.html"
+ rss: "rss.xml"
+ sitemap: "sitemap.xml"
+tags_prefix: '@'
...
diff --git a/src/pyssg/plt/page.html b/src/pyssg/plt/page.html
index 395b0f0..c412938 100644
--- a/src/pyssg/plt/page.html
+++ b/src/pyssg/plt/page.html
@@ -6,7 +6,7 @@
{%block body_content%}
<h1>{{page.title}} -- {{config['title']}}</h1>
- <p>By {{page.author}}</p>
+ <p>By {{', '.join(page.author)}}</p>
<p>Created: {{page.date(page.cts, 'date')}}</p>
{%if page.mtimestamp != 0.0%}
<p>Modified: {{page.date(page.mts, 'date')}}</p>
@@ -15,5 +15,5 @@
{{page.content}}
{%import "tag_list.html" as tag_list%}
- {{tag_list.print(page.tags)}}
+ {{tag_list.print(page.tags, config['tags_prefix'])}}
{%endblock body_content%}
diff --git a/src/pyssg/plt/page_index.html b/src/pyssg/plt/page_index.html
index 70639b2..677005c 100644
--- a/src/pyssg/plt/page_index.html
+++ b/src/pyssg/plt/page_index.html
@@ -5,10 +5,10 @@
{%block body_content%}
<h1>Index -- {{config['title']}}</h1>
- {{page.content}}
+ <p>Some text here</p>
{%import "tag_list.html" as tag_list%}
- {{tag_list.print(all_tags)}}
+ {{tag_list.print(all_tags, config['tags_prefix'])}}
{%import "page_list.html" as page_list%}
{{page_list.print("Articles", all_pages)}}
diff --git a/src/pyssg/plt/tag_list.html b/src/pyssg/plt/tag_list.html
index ebc864e..5175a91 100644
--- a/src/pyssg/plt/tag_list.html
+++ b/src/pyssg/plt/tag_list.html
@@ -1,7 +1,7 @@
-{%macro print(tags)%}
+{%macro print(tags, prefix)%}
<p>Tags:
{%for t in tags-%}
- <a href="/tags/{{t}}.html">{{t}}</a>{{", " if not loop.last else ""}}
+ <a href="/tags/{{prefix}}{{t}}.html">{{t}}</a>{{", " if not loop.last else ""}}
{%-endfor%}
</p>
{%endmacro%}