From 8461a3b8d48bc772ef449e37e5c98ffc254930fe Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Wed, 14 Dec 2022 22:02:30 -0600 Subject: add new files for pyssg.xyz, add multiple document support --- pyssg.xyz/config.yaml | 31 ++++++++++++++++++++ pyssg.xyz/plt/blog/index.html | 32 +++++++++++++++++++++ pyssg.xyz/plt/blog/page.html | 25 ++++++++++++++++ pyssg.xyz/plt/blog/tag.html | 26 +++++++++++++++++ pyssg.xyz/plt/index.html | 32 --------------------- pyssg.xyz/plt/page.html | 25 ---------------- pyssg.xyz/plt/tag.html | 26 ----------------- pyssg.xyz/src/blog/first.md | 10 +++++++ src/pyssg/pyssg.py | 67 ++++++++++++++++++++++--------------------- 9 files changed, 159 insertions(+), 115 deletions(-) create mode 100644 pyssg.xyz/plt/blog/index.html create mode 100644 pyssg.xyz/plt/blog/page.html create mode 100644 pyssg.xyz/plt/blog/tag.html delete mode 100644 pyssg.xyz/plt/index.html delete mode 100644 pyssg.xyz/plt/page.html delete mode 100644 pyssg.xyz/plt/tag.html create mode 100644 pyssg.xyz/src/blog/first.md diff --git a/pyssg.xyz/config.yaml b/pyssg.xyz/config.yaml index cd5d4d7..7fa948e 100644 --- a/pyssg.xyz/config.yaml +++ b/pyssg.xyz/config.yaml @@ -29,4 +29,35 @@ dirs: rss: True sitemap: True exclude_dirs: [] +... +--- +define: &root_path "$HOME/pyssg/pyssg.xyz/" + +title: "pyssg blog" +author: "David Luévano Alvarado" +author_email: "david@luevano.xyz" +description: "PySSG blog, the python static site generator official blog." +lang: "en" +path: + src: !join [*root_path, "src/blog"] + dst: !join [*root_path, "live/blog"] + plt: !join [*root_path, "plt"] + db: !join [*root_path, "db_blog.psv"] +url: + main: "https://blog.pyssg.xyz" + static: "https://static.pyssg.xyz" + default_image: "images/default.png" +fmt: + date: "%a, %b %d, %Y @ %H:%M %Z" + list_date: "%b %d" + list_sep_date: "%B %Y" +dirs: + /: + cfg: + plt: "blog/page.html" + tags: "blog/tag.html" + index: "blog/index.html" + rss: True + sitemap: True + exclude_dirs: [] ... \ No newline at end of file diff --git a/pyssg.xyz/plt/blog/index.html b/pyssg.xyz/plt/blog/index.html new file mode 100644 index 0000000..96d66ef --- /dev/null +++ b/pyssg.xyz/plt/blog/index.html @@ -0,0 +1,32 @@ + + + + + + Index -- {{config['title']}} + + +

Index -- {{config['title']}}

+

Some text here.

+ +

Tags: + {%for t in all_tags%} + {{t[0]}}{{", " if not loop.last else ""}} + {%endfor%} +

+ +

Articles

+ + + diff --git a/pyssg.xyz/plt/blog/page.html b/pyssg.xyz/plt/blog/page.html new file mode 100644 index 0000000..d7f5e43 --- /dev/null +++ b/pyssg.xyz/plt/blog/page.html @@ -0,0 +1,25 @@ + + + + + + {{page.title}} -- {{config['title']}} + + +

{{page.title}}

+

By {{page.author}}

+

Created: {{page.cdate}}

+ {%if page.mdate is not none%} +

Modified: {{page.mdate}}

+ {%endif%} + + {{page.content}} + +

Tags: + {%for t in page.tags%} + {{t[0]}}{{", " if not loop.last else ""}} + {%endfor%} +

+ + + diff --git a/pyssg.xyz/plt/blog/tag.html b/pyssg.xyz/plt/blog/tag.html new file mode 100644 index 0000000..59cbdf1 --- /dev/null +++ b/pyssg.xyz/plt/blog/tag.html @@ -0,0 +1,26 @@ + + + + + + Posts filtered by {{tag[0]}} -- {{config['title']}} + + +

Posts filtered by {{tag[0]}}

+

Some text here.

+ +

Articles

+ + + diff --git a/pyssg.xyz/plt/index.html b/pyssg.xyz/plt/index.html deleted file mode 100644 index 96d66ef..0000000 --- a/pyssg.xyz/plt/index.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - Index -- {{config['title']}} - - -

Index -- {{config['title']}}

-

Some text here.

- -

Tags: - {%for t in all_tags%} - {{t[0]}}{{", " if not loop.last else ""}} - {%endfor%} -

- -

Articles

- - - diff --git a/pyssg.xyz/plt/page.html b/pyssg.xyz/plt/page.html deleted file mode 100644 index d7f5e43..0000000 --- a/pyssg.xyz/plt/page.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - {{page.title}} -- {{config['title']}} - - -

{{page.title}}

-

By {{page.author}}

-

Created: {{page.cdate}}

- {%if page.mdate is not none%} -

Modified: {{page.mdate}}

- {%endif%} - - {{page.content}} - -

Tags: - {%for t in page.tags%} - {{t[0]}}{{", " if not loop.last else ""}} - {%endfor%} -

- - - diff --git a/pyssg.xyz/plt/tag.html b/pyssg.xyz/plt/tag.html deleted file mode 100644 index 59cbdf1..0000000 --- a/pyssg.xyz/plt/tag.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - Posts filtered by {{tag[0]}} -- {{config['title']}} - - -

Posts filtered by {{tag[0]}}

-

Some text here.

- -

Articles

- - - diff --git a/pyssg.xyz/src/blog/first.md b/pyssg.xyz/src/blog/first.md new file mode 100644 index 0000000..567ea3e --- /dev/null +++ b/pyssg.xyz/src/blog/first.md @@ -0,0 +1,10 @@ +title: First blog post for testing purposes +author: David Luévano +lang: en +summary: This is just a post used for testing. +tags: test + english + short + update + +Even though I have this "blog" subdomain and page setup, doesn't mean I'll be blogging for pyssg, this is just to serve as an example for the types of sites that pyssg can be used for. \ No newline at end of file diff --git a/src/pyssg/pyssg.py b/src/pyssg/pyssg.py index d158caa..e9cf28c 100644 --- a/src/pyssg/pyssg.py +++ b/src/pyssg/pyssg.py @@ -72,46 +72,49 @@ def main() -> None: log.debug('reading config files') config_all: list[dict] = get_parsed_config(config_path) static_config: dict = get_static_config() - - # easier to add static into config than changing existing code - config: dict = config_all[0] - config['fmt']['rss_date'] = static_config['fmt']['rss_date'] - config['fmt']['sitemap_date'] = static_config['fmt']['sitemap_date'] - config['info'] = dict() - config['info']['version'] = static_config['info']['version'] - config['info']['debug'] = str(args['debug']) + log.debug('applying static_config for each config document') + for config in config_all: + config['fmt']['rss_date'] = static_config['fmt']['rss_date'] + config['fmt']['sitemap_date'] = static_config['fmt']['sitemap_date'] + config['info'] = dict() + config['info']['version'] = static_config['info']['version'] + config['info']['debug'] = str(args['debug']) if args['init']: log.info('initializing the directory structure and copying over templates') - create_dir(config['path']['src']) - # dst gets created on builder - # create_dir(config['path']['dst']) - create_dir(config['path']['plt']) - files: list[str] = ['index.html', - 'page.html', - 'tag.html', - 'rss.xml', - 'sitemap.xml'] - log.debug('list of files to copy over: (%s)', ', '.join(files)) - for f in files: - plt_file: str = os.path.join(config['path']['plt'], f) - with rpath('pyssg.plt', f) as p: - copy_file(str(p), plt_file) + for config in config_all: + log.info('initializing directories for "%s"', config['title']) + create_dir(config['path']['src']) + # dst gets created on builder + # create_dir(config['path']['dst']) + create_dir(config['path']['plt']) + files: list[str] = ['index.html', + 'page.html', + 'tag.html', + 'rss.xml', + 'sitemap.xml'] + log.debug('list of files to copy over: (%s)', ', '.join(files)) + for f in files: + plt_file: str = os.path.join(config['path']['plt'], f) + with rpath('pyssg.plt', f) as p: + copy_file(str(p), plt_file) log.info('finished initialization') sys.exit(0) if args['build']: log.info('building the html files') - db: Database = Database(config['path']['db']) - db.read() - - log.debug('building all dir_paths found in config') - for dir_path in config['dirs'].keys(): - log.debug('building for "%s"', dir_path) - builder: Builder = Builder(config, db, dir_path) - builder.build() - - db.write() + for config in config_all: + log.info('building html for "%s"', config['title']) + db: Database = Database(config['path']['db']) + db.read() + + log.debug('building all dir_paths found in config') + for dir_path in config['dirs'].keys(): + log.debug('building for "%s"', dir_path) + builder: Builder = Builder(config, db, dir_path) + builder.build() + + db.write() log.info('finished building the html files') sys.exit(0) -- cgit v1.2.3-70-g09d2