summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2022-12-27 02:14:36 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2022-12-27 02:14:36 -0600
commit903211371ec1ea6354f3aff0ccb09baf3ed6d33a (patch)
tree9658cd4f9b15ef8852add3bb818fedd2d9e6516d /src
parent6ec12d94c1b25883e3588afcadd686d3dc157675 (diff)
remove unnecessary variables for page objectv0.8.2
removed some of the unnecessary variables for dates on the page object, as well as from the mandatory config
Diffstat (limited to 'src')
-rw-r--r--src/pyssg/builder.py4
-rw-r--r--src/pyssg/page.py23
-rw-r--r--src/pyssg/plt/index.html8
-rw-r--r--src/pyssg/plt/mandatory_config.yaml2
-rw-r--r--src/pyssg/plt/page.html6
-rw-r--r--src/pyssg/plt/tag.html8
-rw-r--r--src/pyssg/utils.py6
7 files changed, 18 insertions, 39 deletions
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 @@
<ul>
{%for p in all_pages%}
{%if loop.previtem%}
- {%if loop.previtem.cdate_list_sep !=p.cdate_list_sep%}
- <h3>{{p.cdate_list_sep}}</h3>
+ {%if loop.previtem.cdatetime.strftime(config['fmt']['list_sep_date']) != p.cdatetime.strftime(config['fmt']['list_sep_date'])%}
+ <h3>{{p.cdatetime.strftime(config['fmt']['list_sep_date'])}}</h3>
{%endif%}
{%else%}
- <h3>{{p.cdate_list_sep}}</h3>
+ <h3>{{p.cdatetime.strftime(config['fmt']['list_sep_date'])}}</h3>
{%endif%}
- <li>{{p.cdate_list}} - <a href="{{p.url}}">{{p.title}}</a></li>
+ <li>{{p.cdatetime.strftime(config['fmt']['list_date'])}} - <a href="{{p.url}}">{{p.title}}</a></li>
{%endfor%}
</ul>
</body>
diff --git a/src/pyssg/plt/mandatory_config.yaml b/src/pyssg/plt/mandatory_config.yaml
index c1ce9f2..4b4acac 100644
--- a/src/pyssg/plt/mandatory_config.yaml
+++ b/src/pyssg/plt/mandatory_config.yaml
@@ -10,8 +10,6 @@ url:
main:
fmt:
date:
- list_date:
- list_sep_date:
dirs:
/:
...
diff --git a/src/pyssg/plt/page.html b/src/pyssg/plt/page.html
index d7f5e43..08e92f1 100644
--- a/src/pyssg/plt/page.html
+++ b/src/pyssg/plt/page.html
@@ -8,9 +8,9 @@
<body>
<h1>{{page.title}}</h1>
<p>By {{page.author}}</p>
- <p>Created: {{page.cdate}}</p>
- {%if page.mdate is not none%}
- <p>Modified: {{page.mdate}}</p>
+ <p>Created: {{page.cdatetime.strftime(config['fmt']['date'])}}</p>
+ {%if page.mdatetime is not none%}
+ <p>Modified: {{page.mdatetime.strftime(config['fmt']['date'])}}</p>
{%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 @@
<ul>
{%for p in tag_pages%}
{%if loop.previtem%}
- {%if loop.previtem.cdate_list_sep !=p.cdate_list_sep%}
- <h3>{{p.cdate_list_sep}}</h3>
+ {%if loop.previtem.cdatetime.strftime(config['fmt']['list_sep_date']) != p.cdatetime.strftime(config['fmt']['list_sep_date'])%}
+ <h3>{{p.cdatetime.strftime(config['fmt']['list_sep_date'])}}</h3>
{%endif%}
{%else%}
- <h3>{{p.cdate_list_sep}}</h3>
+ <h3>{{p.cdatetime.strftime(config['fmt']['list_sep_date'])}}</h3>
{%endif%}
- <li>{{p.cdate_list}} - <a href="{{p.url}}">{{p.title}}</a></li>
+ <li>{{p.cdatetime.strftime(config['fmt']['list_date'])}} - <a href="{{p.url}}">{{p.title}}</a></li>
{%endfor%}
</ul>
</body>
diff --git a/src/pyssg/utils.py b/src/pyssg/utils.py
index e63ee08..8300a5c 100644
--- a/src/pyssg/utils.py
+++ b/src/pyssg/utils.py
@@ -12,9 +12,7 @@ def get_file_list(path: str,
exts: tuple[str],
exclude_dirs: list[str] = []) -> list[str]:
log.debug('retrieving file list in path "%s" that contain file'
- ' extensions (%s) except directories (%s)',
- path, ', '.join(exts),
- ', '.join(exclude_dirs))
+ ' extensions %s except directories %s', path, exts, exclude_dirs)
file_list: list[str] = []
for root, dirs, files in os.walk(path):
if exclude_dirs != []:
@@ -29,7 +27,7 @@ def get_file_list(path: str,
file, path, file_name)
else:
log.debug('ignoring file "%s" as it doesn\'t contain'
- ' any of the extensions (%s)', file, ', '.join(exts))
+ ' any of the extensions %s', file, exts)
return file_list