From 903211371ec1ea6354f3aff0ccb09baf3ed6d33a Mon Sep 17 00:00:00 2001
From: David Luevano Alvarado
Date: Tue, 27 Dec 2022 02:14:36 -0600
Subject: remove unnecessary variables for page object
removed some of the unnecessary variables for dates on the page object, as well as from the mandatory config
---
ChangeLog | 9 +++++++++
README.md | 6 ------
pyssg.xyz/db.psv | 2 +-
pyssg.xyz/live/blog/rss.xml | 2 +-
pyssg.xyz/live/pyssg.xyz/index.html | 2 +-
pyssg.xyz/live/pyssg.xyz/rss.xml | 4 ++--
pyssg.xyz/live/pyssg.xyz/sitemap.xml | 2 +-
pyssg.xyz/plt/blog/index.html | 8 ++++----
pyssg.xyz/plt/blog/page.html | 6 +++---
pyssg.xyz/plt/blog/tag.html | 8 ++++----
pyssg.xyz/src/pyssg.xyz/index.md | 2 +-
src/pyssg/builder.py | 4 ++--
src/pyssg/page.py | 23 +++--------------------
src/pyssg/plt/index.html | 8 ++++----
src/pyssg/plt/mandatory_config.yaml | 2 --
src/pyssg/plt/page.html | 6 +++---
src/pyssg/plt/tag.html | 8 ++++----
src/pyssg/utils.py | 6 ++----
18 files changed, 45 insertions(+), 63 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 951aed1..813b24b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,15 @@
CHANGES
=======
+v0.8.1
+------
+
+* add more files, fixed bugs related to multiple documents in yaml config
+* add new files for pyssg.xyz, add multiple document support
+* add pyssg.xyz configs and templates
+* update pyssg.xyz site files
+* fix for twine upload to pypi
+
v0.8.0
------
diff --git a/README.md b/README.md
index 4d1c574..c12e356 100644
--- a/README.md
+++ b/README.md
@@ -194,15 +194,9 @@ These variables are exposed to use within the templates. The below list is displ
- `summary` (`str`): summary of the page, as specified in the `*.md` file.
- `content` (`str`): actual content of the page, this is the `html`.
- `cdatetime` (`str`): creation datetime object of the page.
- - `cdate` (`str`): formatted `cdatetime` as the config option `fmt/date`.
- - `cdate_list` (`str`): formatted `cdatetime` as the config option `fmt/list_date`.
- - `cdate_list_sep` (`str`): formatted `cdatetime` as the config option `fmt/list_sep_date`.
- `cdate_rss` (`str`): formatted `cdatetime` as required by rss.
- `cdate_sitemap` (`str`): formatted `cdatetime` as required by sitemap.
- `mdatetime` (`str`): modification datetime object of the page. Defaults to `None`.
- - `mdate` (`str`): formatted `mdatetime` as the config option `fmt/date`. Defaults to `None`.
- - `mdate_list` (`str`): formatted `mdatetime` as the config option `fmt/list_date`.
- - `mdate_list_sep` (`str`): formatted `mdatetime` as the config option `fmt/list_sep_date`.
- `mdate_rss` (`str`): formatted `mdatetime` as required by rss.
- `mdate_sitemap` (`str`): formatted `mdatetime` as required by sitemap.
- `tags` (`list(tuple(str))`): list of tuple of tags of the page, containing the name and the url of the tag, in that order. Defaults to empty list.
diff --git a/pyssg.xyz/db.psv b/pyssg.xyz/db.psv
index 6e25b3e..ed24daa 100644
--- a/pyssg.xyz/db.psv
+++ b/pyssg.xyz/db.psv
@@ -1,4 +1,4 @@
test.md|1670227510.7104242|1670481891.6152065|21ef9b29a3a7b73718b244c9f32ef576|-
subdir/test2.md|1670237921.0787709|0.0|309bd695d912634400f1d50b65d51ba3|-
-index.md|1670906223.8776777|1671077575.953031|4bb24fb729562b6793486b503d8b9e5c|-
+index.md|1670906223.8776777|1672126402.9697309|010d046f05dd9bb794ad76c7ddcc36a5|-
404.md|1670985271.2221887|0.0|184dcb50b5aeba89d98679f29f7b6d9e|-
diff --git a/pyssg.xyz/live/blog/rss.xml b/pyssg.xyz/live/blog/rss.xml
index 20b4c4e..bb30671 100644
--- a/pyssg.xyz/live/blog/rss.xml
+++ b/pyssg.xyz/live/blog/rss.xml
@@ -14,7 +14,7 @@
david@luevano.xyz (David Luévano Alvarado)
- pyssg v0.8.0
+ pyssg v0.8.1
https://validator.w3.org/feed/docs/rss2.html
30
diff --git a/pyssg.xyz/live/pyssg.xyz/index.html b/pyssg.xyz/live/pyssg.xyz/index.html
index 4c8d4d7..5a291a8 100644
--- a/pyssg.xyz/live/pyssg.xyz/index.html
+++ b/pyssg.xyz/live/pyssg.xyz/index.html
@@ -60,7 +60,7 @@
Welcome to the official pyssg website. This is as of now serving as a testing ground when I’m making changes to it.
Blog
-You can find the blog (actually just a mock) here.
+You can find the blog (actually just a mock) here.
Get the RSS feed: https://pyssg.xyz/rss.xml
diff --git a/pyssg.xyz/live/pyssg.xyz/rss.xml b/pyssg.xyz/live/pyssg.xyz/rss.xml
index b1269cf..b039e25 100644
--- a/pyssg.xyz/live/pyssg.xyz/rss.xml
+++ b/pyssg.xyz/live/pyssg.xyz/rss.xml
@@ -14,7 +14,7 @@
david@luevano.xyz (David Luévano Alvarado)
- pyssg v0.8.0
+ pyssg v0.8.1
https://validator.w3.org/feed/docs/rss2.html
30
@@ -38,7 +38,7 @@
Welcome to the official pyssg website. This is as of now serving as a testing ground when I’m making changes to it.
Blog
-You can find the blog (actually just a mock) here.
+You can find the blog (actually just a mock) here.
Get the RSS feed: https://pyssg.xyz/rss.xml
]]>
diff --git a/pyssg.xyz/live/pyssg.xyz/sitemap.xml b/pyssg.xyz/live/pyssg.xyz/sitemap.xml
index bbf8a85..8d5df21 100644
--- a/pyssg.xyz/live/pyssg.xyz/sitemap.xml
+++ b/pyssg.xyz/live/pyssg.xyz/sitemap.xml
@@ -10,7 +10,7 @@
https://pyssg.xyz/index.html
- 2022-12-15
+ 2022-12-27
weekly
1.0
diff --git a/pyssg.xyz/plt/blog/index.html b/pyssg.xyz/plt/blog/index.html
index 9086232..057cd79 100644
--- a/pyssg.xyz/plt/blog/index.html
+++ b/pyssg.xyz/plt/blog/index.html
@@ -48,13 +48,13 @@
{%for p in all_pages%}
{%if loop.previtem%}
- {%if loop.previtem.cdate_list_sep !=p.cdate_list_sep%}
- {{p.cdate_list_sep}}
+ {%if loop.previtem.cdatetime.strftime(config['fmt']['list_sep_date']) != p.cdatetime.strftime(config['fmt']['list_sep_date'])%}
+ {{p.cdatetime.strftime(config['fmt']['list_sep_date'])}}
{%endif%}
{%else%}
- {{p.cdate_list_sep}}
+ {{p.cdatetime.strftime(config['fmt']['list_sep_date'])}}
{%endif%}
- - {{p.cdate_list}} - {{p.title}}
+ - {{p.cdatetime.strftime(config['fmt']['list_date'])}} - {{p.title}}
{%endfor%}
{%endblock body_content%}
diff --git a/pyssg.xyz/plt/blog/page.html b/pyssg.xyz/plt/blog/page.html
index bd79b15..06746ba 100644
--- a/pyssg.xyz/plt/blog/page.html
+++ b/pyssg.xyz/plt/blog/page.html
@@ -38,9 +38,9 @@
{{page.title}}
By {{', '.join(page.author)}}
- Created: {{page.cdate}}
- {%if page.mdate is not none%}
- Modified: {{page.mdate}}
+ Created: {{page.cdatetime.strftime(config['fmt']['date'])}}
+ {%if page.mdatetime is not none%}
+ Modified: {{page.mdatetime.strftime(config['fmt']['date'])}}
{%endif%}
{{page.content}}
diff --git a/pyssg.xyz/plt/blog/tag.html b/pyssg.xyz/plt/blog/tag.html
index 53499b1..5b05d7f 100644
--- a/pyssg.xyz/plt/blog/tag.html
+++ b/pyssg.xyz/plt/blog/tag.html
@@ -42,13 +42,13 @@
{%for p in tag_pages%}
{%if loop.previtem%}
- {%if loop.previtem.cdate_list_sep !=p.cdate_list_sep%}
- {{p.cdate_list_sep}}
+ {%if loop.previtem.cdatetime.strftime(config['fmt']['list_sep_date']) != p.cdatetime.strftime(config['fmt']['list_sep_date'])%}
+ {{p.cdatetime.strftime(config['fmt']['list_sep_date'])}}
{%endif%}
{%else%}
- {{p.cdate_list_sep}}
+ {{p.cdatetime.strftime(config['fmt']['list_sep_date'])}}
{%endif%}
- - {{p.cdate_list}} - {{p.title}}
+ - {{p.cdatetime.strftime(config['fmt']['list_date'])}} - {{p.title}}
{%endfor%}
{%endblock body_content%}
diff --git a/pyssg.xyz/src/pyssg.xyz/index.md b/pyssg.xyz/src/pyssg.xyz/index.md
index 27371cd..ef30baa 100644
--- a/pyssg.xyz/src/pyssg.xyz/index.md
+++ b/pyssg.xyz/src/pyssg.xyz/index.md
@@ -4,6 +4,6 @@ Welcome to the official pyssg website. This is as of now serving as a testing gr
## Blog
-You can find the blog (actually just a mock) [here](https://blog.luevano.xyz).
+You can find the blog (actually just a mock) [here](https://blog.pyssg.xyz).
Get the RSS feed: [https://pyssg.xyz/rss.xml](https://pyssg.xyz/rss.xml)
\ No newline at end of file
diff --git a/src/pyssg/builder.py b/src/pyssg/builder.py
index 582eb74..c70994d 100644
--- a/src/pyssg/builder.py
+++ b/src/pyssg/builder.py
@@ -74,10 +74,10 @@ class Builder:
self.dirs = get_dir_structure(self.dir_cfg['src'],
self.dir_cfg['exclude_dirs'])
self.md_files = get_file_list(self.dir_cfg['src'],
- tuple('.md'),
+ ('.md',),
self.dir_cfg['exclude_dirs'])
self.html_files = get_file_list(self.dir_cfg['src'],
- tuple('.html'),
+ ('.html',),
self.dir_cfg['exclude_dirs'])
self.__create_dir_structure()
diff --git a/src/pyssg/page.py b/src/pyssg/page.py
index 32caadb..0161f25 100644
--- a/src/pyssg/page.py
+++ b/src/pyssg/page.py
@@ -22,7 +22,6 @@ class Page:
self.mtimestamp: float = mtime
self.content: str = html
self.meta: dict = meta
- # TODO: need to fix this to use the dir_config stuff
self.config: dict = config
self.dir_config: dict = dir_config
@@ -32,21 +31,14 @@ class Page:
self.summary: str
self.lang: str
self.cdatetime: datetime
- self.mdatetime: datetime
+ self.mdatetime: datetime | None = None
self.tags: list[tuple[str, str]] = []
# constructed
self.url: str
self.image_url: str
- self.cdate: str
- self.cdate_list: str
- self.cdate_list_sep: str
self.cdate_rss: str
self.cdate_sitemap: str
-
- self.mdate: str | None = None
- self.mdate_list: str | None = None
- self.mdate_list_sep: str | None = None
self.mdate_rss: str | None = None
self.mdate_sitemap: str | None = None
@@ -77,24 +69,15 @@ class Page:
self.lang = self.__get_meta('lang', ['en'])[0]
log.debug('parsing timestamp')
- self.cdatetime = datetime.fromtimestamp(self.ctimestamp,
- tz=timezone.utc)
- # these could be actual function
+ self.cdatetime = datetime.fromtimestamp(self.ctimestamp, tz=timezone.utc)
cdate = lambda x : self.cdatetime.strftime(self.config['fmt'][x])
- mdate = lambda x : self.mdatetime.strftime(self.config['fmt'][x])
-
- self.cdate = cdate('date')
- self.cdate_list = cdate('list_date')
- self.cdate_list_sep = cdate('list_sep_date')
self.cdate_rss = cdate('rss_date')
self.cdate_sitemap = cdate('sitemap_date')
if self.mtimestamp != 0.0:
log.debug('parsing modified timestamp')
self.mdatetime = datetime.fromtimestamp(self.mtimestamp, tz=timezone.utc)
- self.mdate = mdate('date')
- self.mdate_list = mdate('list_date')
- self.mdate_list_sep = mdate('list_sep_date')
+ mdate = lambda x : self.mdatetime.strftime(self.config['fmt'][x]) # type: ignore
self.mdate_rss = mdate('rss_date')
self.mdate_sitemap = mdate('sitemap_date')
else:
diff --git a/src/pyssg/plt/index.html b/src/pyssg/plt/index.html
index 96d66ef..c33fd37 100644
--- a/src/pyssg/plt/index.html
+++ b/src/pyssg/plt/index.html
@@ -19,13 +19,13 @@
{%for p in all_pages%}
{%if loop.previtem%}
- {%if loop.previtem.cdate_list_sep !=p.cdate_list_sep%}
- {{p.cdate_list_sep}}
+ {%if loop.previtem.cdatetime.strftime(config['fmt']['list_sep_date']) != p.cdatetime.strftime(config['fmt']['list_sep_date'])%}
+ {{p.cdatetime.strftime(config['fmt']['list_sep_date'])}}
{%endif%}
{%else%}
- {{p.cdate_list_sep}}
+ {{p.cdatetime.strftime(config['fmt']['list_sep_date'])}}
{%endif%}
- - {{p.cdate_list}} - {{p.title}}
+ - {{p.cdatetime.strftime(config['fmt']['list_date'])}} - {{p.title}}
{%endfor%}
{{page.title}}
By {{page.author}}
- Created: {{page.cdate}}
- {%if page.mdate is not none%}
- Modified: {{page.mdate}}
+ Created: {{page.cdatetime.strftime(config['fmt']['date'])}}
+ {%if page.mdatetime is not none%}
+ Modified: {{page.mdatetime.strftime(config['fmt']['date'])}}
{%endif%}
{{page.content}}
diff --git a/src/pyssg/plt/tag.html b/src/pyssg/plt/tag.html
index 59cbdf1..2dd7177 100644
--- a/src/pyssg/plt/tag.html
+++ b/src/pyssg/plt/tag.html
@@ -13,13 +13,13 @@
{%for p in tag_pages%}
{%if loop.previtem%}
- {%if loop.previtem.cdate_list_sep !=p.cdate_list_sep%}
- {{p.cdate_list_sep}}
+ {%if loop.previtem.cdatetime.strftime(config['fmt']['list_sep_date']) != p.cdatetime.strftime(config['fmt']['list_sep_date'])%}
+ {{p.cdatetime.strftime(config['fmt']['list_sep_date'])}}
{%endif%}
{%else%}
- {{p.cdate_list_sep}}
+ {{p.cdatetime.strftime(config['fmt']['list_sep_date'])}}
{%endif%}
- - {{p.cdate_list}} - {{p.title}}
+ - {{p.cdatetime.strftime(config['fmt']['list_date'])}} - {{p.title}}
{%endfor%}