diff --git a/.gitignore b/.gitignore index 9fe2c23..364fdec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1 @@ -output/ -bin/ -lib/ -lib64 -pyvenv.cfg +public/ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0028f63 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.insertFinalNewline": true, + "files.trimTrailingWhitespace": true, + "editor.insertSpaces": false +} diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..1beee40 --- /dev/null +++ b/config.toml @@ -0,0 +1,11 @@ +base_url = "https://pizzawednes.day" +title = "Pizza Wednesday" + +# Features +compile_sass = false +build_search_index = true + +[markdown] +highlight_code = true + +[extra] diff --git a/content/_index.md b/content/_index.md new file mode 100644 index 0000000..8504ee0 --- /dev/null +++ b/content/_index.md @@ -0,0 +1,3 @@ ++++ +title = "Hello world" ++++ diff --git a/content/feed/_index.md b/content/feed/_index.md new file mode 100644 index 0000000..22440c5 --- /dev/null +++ b/content/feed/_index.md @@ -0,0 +1,5 @@ ++++ +title = "Feed" +generate_feed = true +template = "feed.html" ++++ diff --git a/posts/2023-08-16-hello-world.md b/content/feed/hello-world.md similarity index 96% rename from posts/2023-08-16-hello-world.md rename to content/feed/hello-world.md index 2da9971..021dd92 100644 --- a/posts/2023-08-16-hello-world.md +++ b/content/feed/hello-world.md @@ -1,3 +1,8 @@ ++++ +title = "hello world" +date = 2023-08-16 ++++ + # Hello, World This is a test of the new announcement feed system. diff --git a/publish.py b/publish.py deleted file mode 100644 index ecb099b..0000000 --- a/publish.py +++ /dev/null @@ -1,84 +0,0 @@ -import datetime -import jinja2 -import markdown -import os -import strip_markdown -import typing - -class Post(typing.NamedTuple): - title: str - path: str - pub_date: datetime.datetime - -base_url = "https://pizzawednes.day/" -cwd_path = os.getcwd() -output_path = os.path.join(cwd_path, "output") - -if not os.path.exists(output_path): - os.mkdir(output_path) - -feed_path = os.path.join(output_path, "feed") - -if not os.path.exists(feed_path): - os.mkdir(feed_path) - -jinja_env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.join(cwd_path, "templates"))) -posts_path = os.path.join(cwd_path, "posts") -post_template = jinja_env.get_template("site_post.html") -datetime_format_len = 10 -markdown_extension = ".md" -posts: list[Post] = [] - -for filename in os.listdir(posts_path): - if not filename.endswith(markdown_extension): - continue - - if len(filename) < datetime_format_len: - continue - - pub_date = datetime.datetime.min - - try: - pub_date = datetime.datetime.strptime(filename[0:datetime_format_len], "%Y-%m-%d").replace( - hour=0, - minute=0, - second=0, - microsecond=0, - ) - except ValueError: - pass - - with open(os.path.join(posts_path, filename)) as source_file: - content = source_file.read() - title = "" - - try: - first_newline_index = content.index('\n') - title = strip_markdown.strip_markdown(content[0:first_newline_index]) - except ValueError: - pass - - slug = filename[:-len(markdown_extension)] - - posts.append(Post( - title=title, - path=os.path.join("feed", slug), - pub_date=pub_date, - )) - - with open(f"{os.path.join(feed_path, slug)}.html", "w") as output_file: - output_file.write(post_template.render( - title = title, - content = markdown.markdown(content), - )) - -with open(f"{feed_path}.rss", "w") as file: - file.write(jinja_env.get_template("rss_feed.rss").render( - base_url = base_url, - posts = posts, - )) - -with open(f"{feed_path}.html", "w") as file: - file.write(jinja_env.get_template("site_feed.html").render( - posts = posts, - )) \ No newline at end of file diff --git a/readme.md b/readme.md index ea5258a..44b4f2e 100644 --- a/readme.md +++ b/readme.md @@ -1,17 +1,15 @@ # Pizza Wednesday Site -This repo contains the scripts, templates, and blog posts necessary to build the Pizza Wednesday landing site from scratch. +This repo contains the templates, assets, and blog posts necessary to build the Pizza Wednesday landing site. -While only intended to be used by contributors for publishing new articles and changes to the website, the source files are publicly viewable for transparency and posterity. +While only intended to be used by contributors for publishing new articles and changes to the website, the source files are publicly viewable for posterity. + +## Building + +The website uses the [Zola static site generator](https://www.getzola.org/) for building. Though it is available in most package managers across the various Unix-like systems, the project maintainers also provide pre-built binaries on their [Github relases page](https://github.com/getzola/zola/releases). + +Once installed, executing the `zola build` terminal command from within the repository root builds the website. Alternatively, `zola serve` launches a live testing server with hot-reloading of changes for local development. ## Publishing -Being a python script that is doing somewhat non-trivial stuff, `publish.py` will require some non-standard dependencies to run properly. - - * `markdown` for parsing the markdown source files into HTML. - * `strip_markdown` for converting markdown source file content into plain text. - * `jinja2` for template generation of the site contents. Without tools like it, creating static websites is a fairly miserable experience - -And of course a Python interpreter will be required - specifically any compatible with CPython libraries like the ones listed above. - -Once these dependencies are satisifed, generating the website should be as simple as running `publish.py`. If it does fail to run at this point, please file a bug report. \ No newline at end of file +Any changes merged into the main branch of the Sauce Control repository are published to the live server. diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..24d8bb2 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,31 @@ + + + + + + + {% block title %}{{ config.title }}{% endblock %} + + {% block links %} + {% endblock %} + + + +
+
Pizza Wednesday
+ + +
+ +
+ {% block content %}{% endblock %} +
+ + + + diff --git a/templates/feed.html b/templates/feed.html new file mode 100644 index 0000000..735e6d4 --- /dev/null +++ b/templates/feed.html @@ -0,0 +1,20 @@ +{% extends "base.html" %} + +{% block links %} + +{% endblock %} + +{% block content %} +

Feed

+ +{% for page in section.pages %} + +
+

{{ page.title }}

+
{{ page.date }}
+

{{ page.content | striptags | truncate(length=255) }}

+
+
+{% endfor %} + +{% endblock %} diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..b519434 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,20 @@ +{% extends "base.html" %} + +{% block content %} +{{ section.content | safe }} + +

Latest

+ +{% set feed_section = get_section(path="feed/_index.md") %} + +{% for page in feed_section.pages %} + +
+

{{ page.title }}

+
{{ page.date }}
+

{{ page.content | striptags | truncate(length=255) }}

+
+
+{% endfor %} + +{% endblock %} diff --git a/templates/page.html b/templates/page.html new file mode 100644 index 0000000..e73c8f3 --- /dev/null +++ b/templates/page.html @@ -0,0 +1,5 @@ +{% extends "base.html" %} + +{% block content %} +{{ page.content | safe }} +{% endblock %} diff --git a/templates/rss_feed.rss b/templates/rss_feed.rss deleted file mode 100644 index 7e2581d..0000000 --- a/templates/rss_feed.rss +++ /dev/null @@ -1,16 +0,0 @@ - - - - Pizza Wednesday Feed - {{ base_url }} - Announcements regarding pizzawednes.day and related services - - {% for post in posts %} - - {{ post.title }} - {{ base_url }}{{ post.path }} - {{ post.pub_date.strftime('%a, %d %b %Y %H:%M:%S %z') }} - - {% endfor %} - - diff --git a/templates/site_base.html b/templates/site_base.html deleted file mode 100644 index 288511f..0000000 --- a/templates/site_base.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - {% block title %}Pizza Wednesday{% endblock %} - - - -
Pizza Wednesday
- - - -
- {% block content %}{% endblock %} -
- - diff --git a/templates/site_feed.html b/templates/site_feed.html deleted file mode 100644 index 45b81d6..0000000 --- a/templates/site_feed.html +++ /dev/null @@ -1,13 +0,0 @@ -{% extends "site_base.html" %} - -{% block title %}Pizza Wednesday Feed{% endblock %} - -{% block content %} -{% for post in posts %} -
-
{{ post.title }}
-
{{ base_url }}{{ post.path }}
-
{{ post.pub_date.strftime('%a, %d %b %Y %H:%M:%S %z') }}
-
-{% endfor %} -{% endblock %} \ No newline at end of file diff --git a/templates/site_post.html b/templates/site_post.html deleted file mode 100644 index ae5b532..0000000 --- a/templates/site_post.html +++ /dev/null @@ -1,7 +0,0 @@ -{% extends "site_base.html" %} - -{% block title %}{{ title }} - Pizza Wednesday Feed{% endblock %} - -{% block content %} - {{ content }} -{% endblock %} \ No newline at end of file