pysocha 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. {pysocha-0.1.0 → pysocha-0.2.0}/PKG-INFO +1 -1
  2. {pysocha-0.1.0 → pysocha-0.2.0}/pyproject.toml +1 -1
  3. {pysocha-0.1.0 → pysocha-0.2.0}/requirements-dev.lock +0 -1
  4. {pysocha-0.1.0 → pysocha-0.2.0}/requirements.lock +0 -1
  5. pysocha-0.2.0/src/pysocha/atom.py +32 -0
  6. {pysocha-0.1.0 → pysocha-0.2.0}/src/pysocha/build.py +35 -2
  7. {pysocha-0.1.0 → pysocha-0.2.0}/src/pysocha/config.py +2 -1
  8. {pysocha-0.1.0 → pysocha-0.2.0}/.gitignore +0 -0
  9. {pysocha-0.1.0 → pysocha-0.2.0}/.python-version +0 -0
  10. {pysocha-0.1.0 → pysocha-0.2.0}/README.md +0 -0
  11. {pysocha-0.1.0 → pysocha-0.2.0}/example/content/blog_posts/filenames_are_ignored.md +0 -0
  12. {pysocha-0.1.0 → pysocha-0.2.0}/example/content/blog_posts/first_post.md +0 -0
  13. {pysocha-0.1.0 → pysocha-0.2.0}/example/content/blog_posts/second_post.md +0 -0
  14. {pysocha-0.1.0 → pysocha-0.2.0}/example/content/blog_posts/some_random_name.md +0 -0
  15. {pysocha-0.1.0 → pysocha-0.2.0}/example/content/blog_posts/unlisted_post.md +0 -0
  16. {pysocha-0.1.0 → pysocha-0.2.0}/example/content/extra_files/download_me.txt +0 -0
  17. {pysocha-0.1.0 → pysocha-0.2.0}/example/content/extra_files/extra.css +0 -0
  18. {pysocha-0.1.0 → pysocha-0.2.0}/example/content/extra_files/extra.js +0 -0
  19. {pysocha-0.1.0 → pysocha-0.2.0}/example/content/extra_files/logo.png +0 -0
  20. {pysocha-0.1.0 → pysocha-0.2.0}/example/content/extra_files/main.css +0 -0
  21. {pysocha-0.1.0 → pysocha-0.2.0}/example/content/extra_files/main.js +0 -0
  22. {pysocha-0.1.0 → pysocha-0.2.0}/example/content/extra_files/readme.md +0 -0
  23. {pysocha-0.1.0 → pysocha-0.2.0}/example/content/extra_files/sub_dirs/download_me2.txt +0 -0
  24. {pysocha-0.1.0 → pysocha-0.2.0}/example/content/extra_files/zips.gif +0 -0
  25. {pysocha-0.1.0 → pysocha-0.2.0}/example/content/pages/index.md +0 -0
  26. {pysocha-0.1.0 → pysocha-0.2.0}/example/content/pages/test.md +0 -0
  27. {pysocha-0.1.0 → pysocha-0.2.0}/example/example-config.yaml +0 -0
  28. {pysocha-0.1.0 → pysocha-0.2.0}/example/templates/author.jinja2 +0 -0
  29. {pysocha-0.1.0 → pysocha-0.2.0}/example/templates/authors.jinja2 +0 -0
  30. {pysocha-0.1.0 → pysocha-0.2.0}/example/templates/base.jinja2 +0 -0
  31. {pysocha-0.1.0 → pysocha-0.2.0}/example/templates/blog.jinja2 +0 -0
  32. {pysocha-0.1.0 → pysocha-0.2.0}/example/templates/listing.jinja2 +0 -0
  33. {pysocha-0.1.0 → pysocha-0.2.0}/example/templates/page.jinja2 +0 -0
  34. {pysocha-0.1.0 → pysocha-0.2.0}/example/templates/tag.jinja2 +0 -0
  35. {pysocha-0.1.0 → pysocha-0.2.0}/example/templates/tags.jinja2 +0 -0
  36. {pysocha-0.1.0 → pysocha-0.2.0}/src/pysocha/__init__.py +0 -0
  37. {pysocha-0.1.0 → pysocha-0.2.0}/src/pysocha/__main__.py +0 -0
  38. {pysocha-0.1.0 → pysocha-0.2.0}/src/pysocha/markdown.py +0 -0
  39. {pysocha-0.1.0 → pysocha-0.2.0}/src/pysocha/preview.py +0 -0
  40. {pysocha-0.1.0 → pysocha-0.2.0}/tools.sh +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pysocha
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Extremely simple static site generator
5
5
  Author-email: Tod Hansmann <githubpub@todandlorna.com>
6
6
  Requires-Python: >=3.8
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pysocha"
3
- version = "0.1.0"
3
+ version = "0.2.0"
4
4
  description = "Extremely simple static site generator"
5
5
  authors = [
6
6
  { name = "Tod Hansmann", email = "githubpub@todandlorna.com" }
@@ -6,7 +6,6 @@
6
6
  # features: []
7
7
  # all-features: false
8
8
  # with-sources: false
9
- # generate-hashes: false
10
9
 
11
10
  -e file:.
12
11
  blinker==1.8.2
@@ -6,7 +6,6 @@
6
6
  # features: []
7
7
  # all-features: false
8
8
  # with-sources: false
9
- # generate-hashes: false
10
9
 
11
10
  -e file:.
12
11
  blinker==1.8.2
@@ -0,0 +1,32 @@
1
+
2
+
3
+
4
+ ATOM_HEADER="""<?xml version="1.0" encoding="utf-8"?>
5
+ <feed xmlns="http://www.w3.org/2005/Atom">
6
+ """
7
+ ATOM_FEED_ELEMENTS="""
8
+ <title>{siteTitle}</title>
9
+ <link href="{siteAddress}"/>
10
+ <updated>{updatedDate}</updated>
11
+ <author>
12
+ <name>{author}</name>
13
+ </author>
14
+ <id>{siteAddress}</id>
15
+ """
16
+ ATOM_ENTRY="""
17
+ <entry>
18
+ <title>{Title}</title>
19
+ <author>
20
+ <name>{authorName}</name>
21
+ </author>
22
+ <link href="{siteAddress}{blogBaseDir}/{slugify}"/>
23
+ <id>{siteAddress}{blogBaseDir}/{slugify}</id>
24
+ <updated>{updatedDate}</updated>
25
+ <summary>{hook}</summary>
26
+ </entry>
27
+ """
28
+ ATOM_FOOTER="""
29
+ </feed>
30
+ """
31
+
32
+
@@ -1,3 +1,4 @@
1
+ from datetime import timezone
1
2
  import dateutil.parser
2
3
  import jinja2
3
4
  import math
@@ -7,7 +8,9 @@ import shutil
7
8
 
8
9
  from slugify import slugify
9
10
 
10
- from .markdown import parseCommonMark
11
+ from pysocha.atom import ATOM_ENTRY, ATOM_FEED_ELEMENTS, ATOM_FOOTER, ATOM_HEADER
12
+
13
+ from pysocha.markdown import parseCommonMark
11
14
 
12
15
 
13
16
  def get_markdown_files(directory):
@@ -41,7 +44,7 @@ def generate_blog_posts(config: dict):
41
44
  file = f.read()
42
45
  mark = parseCommonMark(file)
43
46
  post_data = mark['frontmatter']
44
- post_data['PostedDate'] = dateutil.parser.parse(post_data['PostedDate'])
47
+ post_data['PostedDate'] = dateutil.parser.parse(post_data['PostedDate']).replace(tzinfo=timezone.utc)
45
48
  post_template = template
46
49
  # If we override the template for that page, here it gets invoked
47
50
  if 'Template' in mark['frontmatter']:
@@ -136,9 +139,12 @@ def generate_blog_posts(config: dict):
136
139
  'total_pages': total_pages}))
137
140
 
138
141
  output_filename = os.path.join(output_dir, 'authors' + file_ext)
142
+ first_author = None
139
143
  with open(output_filename, 'w+') as f:
140
144
  f.write(authors_template.render({'authors': authors, 'title': 'Authors', 'all_posts': sorted_posts}))
141
145
  for author, posts in authors.items():
146
+ if first_author is None:
147
+ first_author = author
142
148
  if 'authorPaginationNum' in blog_config:
143
149
  page_limit = blog_config['authorPaginationNum']
144
150
  total_pages = int(math.floor(len(posts) / page_limit) + 1)
@@ -164,6 +170,33 @@ def generate_blog_posts(config: dict):
164
170
  'title': 'Posts for author: ' + author,
165
171
  'posts': posts}))
166
172
 
173
+ sorted_posts.sort(key=lambda post: post['PostedDate'], reverse=True)
174
+ if blog_config['atomFeeds']:
175
+ atom_feed = ""
176
+ atom_feed += ATOM_HEADER
177
+ atom_elements = {
178
+ 'siteTitle': config['siteTitle'],
179
+ 'siteAddress': config['siteAddress'],
180
+ 'author': first_author,
181
+ 'updatedDate': sorted_posts[0]['PostedDate'].isoformat(),
182
+ }
183
+ atom_feed += ATOM_FEED_ELEMENTS.format(**atom_elements)
184
+ for post in sorted_posts:
185
+ entry = {
186
+ 'Title': post['Title'],
187
+ 'siteAddress': config['siteAddress'],
188
+ 'blogBaseDir': blog_config['blogBaseDir'],
189
+ 'slugify': post['slugify'],
190
+ 'updatedDate': post['PostedDate'].isoformat(),
191
+ 'hook': post.get('hook', post.get('summary', post['Title'])),
192
+ 'authorName': post['Author'],
193
+ }
194
+ atom_feed += ATOM_ENTRY.format(**entry)
195
+ atom_feed += ATOM_FOOTER
196
+ output_filename = os.path.join(config['outputDir'], blog_config['blogBaseDir'], 'atom.xml')
197
+ with open(output_filename, 'w+') as f:
198
+ f.write(atom_feed)
199
+
167
200
  def generate_pages(config: dict):
168
201
  """
169
202
  We go through all the possibilities for generating any page related details
@@ -5,6 +5,7 @@ contentDir: "content"
5
5
  outputDir: "generated"
6
6
  templatesDir: "templates"
7
7
  siteTitle: "Example dot Com!"
8
+ siteAddress: "https://example.changeme.tld/"
8
9
  descending: True
9
10
  defaultExtension: ".html"
10
11
  startPage: "index.html"
@@ -18,7 +19,7 @@ blogConfig:
18
19
  listingTemplate: "listing.jinja2"
19
20
  listingPagination_num: 5
20
21
  listingKeysNeeded: ['hook']
21
- atomFeed: True
22
+ atomFeeds: True
22
23
  tagsTemplate: "tags.jinja2"
23
24
  tagTemplate: "tag.jinja2"
24
25
  tagPaginationNum: 5
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes