From e60c93e5ad3ad808d5559ba590ece57987d23782 Mon Sep 17 00:00:00 2001 From: Dmitry Ilvokhin Date: Mon, 26 Dec 2022 17:34:02 +0000 Subject: Remove drafts logic --- Makefile | 4 +-- blog/blog.py | 13 +++---- blog/post.py | 3 -- posts/drafts/hello-world/hello-world.md | 60 --------------------------------- posts/drafts/hello-world/metadata.txt | 3 -- posts/hello-world/hello-world.md | 60 +++++++++++++++++++++++++++++++++ posts/hello-world/metadata.txt | 2 ++ share/style.css | 4 --- templates/feed.html | 4 --- 9 files changed, 68 insertions(+), 85 deletions(-) delete mode 100644 posts/drafts/hello-world/hello-world.md delete mode 100644 posts/drafts/hello-world/metadata.txt create mode 100644 posts/hello-world/hello-world.md create mode 100644 posts/hello-world/metadata.txt diff --git a/Makefile b/Makefile index 8eb3cb2..f491bc0 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,12 @@ SHARE := $(shell find share -name '*' 2> /dev/null) POSTS := $(shell find posts -name '*' 2> /dev/null) CODE := $(shell find blog -name '*.py' 2> /dev/null) -.PHONY: clean httpserver +.PHONY: clean server remote: $(TEMPLATES) $(SHARE) $(POSTS) python3 blog/blog.py -httpserver: remote +server: remote python3 -m http.server --directory remote clean: diff --git a/blog/blog.py b/blog/blog.py index 8af9589..b682afc 100644 --- a/blog/blog.py +++ b/blog/blog.py @@ -3,6 +3,7 @@ import os import shutil +import argparse from jinja2 import Environment, FileSystemLoader, select_autoescape @@ -31,17 +32,11 @@ def copy_share(workdir): shutil.copy(source, destination) -def generate_blog(include_drafts=False): +def generate_blog(): env = Environment(loader=FileSystemLoader(searchpath="templates"), autoescape=select_autoescape()) - posts = find_posts(env.get_template("post.html"), - os.path.join("posts", "public")) - - if include_drafts: - drafts = find_posts(env.get_template("post.html"), - os.path.join("posts", "drafts")) - posts.extend(drafts) + posts = find_posts(env.get_template("post.html"), "posts") workdir = "remote" recreate_workdir(workdir) @@ -56,7 +51,7 @@ def generate_blog(include_drafts=False): def main(): - generate_blog(include_drafts=True) + generate_blog() if __name__ == "__main__": diff --git a/blog/post.py b/blog/post.py index eab9d0d..ebf2e4c 100644 --- a/blog/post.py +++ b/blog/post.py @@ -43,9 +43,6 @@ class Post(object): return Metadata(title, date, status) - def is_draft(self): - return self.metadata.status == "draft" - def generate(self, basedir): postdir = os.path.basename(self.directory) workdir = os.path.join(basedir, postdir) diff --git a/posts/drafts/hello-world/hello-world.md b/posts/drafts/hello-world/hello-world.md deleted file mode 100644 index 06639ae..0000000 --- a/posts/drafts/hello-world/hello-world.md +++ /dev/null @@ -1,60 +0,0 @@ -This is a post to demonstrate and test content generation code. I am not a -writing master, so I am going just enumerate features I am going to use to see -how they are rendered. - -And I want to know how multiple paragraphs are rendered. - - -## Code - -Standalone code block like this one. - -``` -#include - -int main() { - std::cout << "Hello, World" << std::endl; - return 0; -} -``` - -And embedded code like `this` and `this`. - - -## Lists -* I -* like -* itemized -* lists - -Also, sometimes I use enumerated lists like this one. - -1. One. -2. Two. -3. Three. - - -## Formatting - -This is a **bold** text. And this is _italic_. - - -## Quotes -> I don't know what's the matter with people: they don't learn by -> understanding; they learn by some other way — by rote or something. -> Their knowledge is so fragile! - - -## Footnotes - -Oh, some it would nice to have footnotes like this one[^1]. - -[^1]: This should work. - - -## URLs - -Here is the url to [website][1]. And the same [url](https://ilvokhin.com), but -embedded into the text. - -[1]: https://ilvokhin.com diff --git a/posts/drafts/hello-world/metadata.txt b/posts/drafts/hello-world/metadata.txt deleted file mode 100644 index 800612c..0000000 --- a/posts/drafts/hello-world/metadata.txt +++ /dev/null @@ -1,3 +0,0 @@ -Title: Hello, World! -Date: 2022-12-23 -Status: draft diff --git a/posts/hello-world/hello-world.md b/posts/hello-world/hello-world.md new file mode 100644 index 0000000..06639ae --- /dev/null +++ b/posts/hello-world/hello-world.md @@ -0,0 +1,60 @@ +This is a post to demonstrate and test content generation code. I am not a +writing master, so I am going just enumerate features I am going to use to see +how they are rendered. + +And I want to know how multiple paragraphs are rendered. + + +## Code + +Standalone code block like this one. + +``` +#include + +int main() { + std::cout << "Hello, World" << std::endl; + return 0; +} +``` + +And embedded code like `this` and `this`. + + +## Lists +* I +* like +* itemized +* lists + +Also, sometimes I use enumerated lists like this one. + +1. One. +2. Two. +3. Three. + + +## Formatting + +This is a **bold** text. And this is _italic_. + + +## Quotes +> I don't know what's the matter with people: they don't learn by +> understanding; they learn by some other way — by rote or something. +> Their knowledge is so fragile! + + +## Footnotes + +Oh, some it would nice to have footnotes like this one[^1]. + +[^1]: This should work. + + +## URLs + +Here is the url to [website][1]. And the same [url](https://ilvokhin.com), but +embedded into the text. + +[1]: https://ilvokhin.com diff --git a/posts/hello-world/metadata.txt b/posts/hello-world/metadata.txt new file mode 100644 index 0000000..3333eb3 --- /dev/null +++ b/posts/hello-world/metadata.txt @@ -0,0 +1,2 @@ +Title: Hello, World! +Date: 2022-12-23 diff --git a/share/style.css b/share/style.css index 8dec075..0dc2450 100644 --- a/share/style.css +++ b/share/style.css @@ -34,10 +34,6 @@ h1, h2, h3, h4, h5, h6 { color: var(--heading-color); } -/*time { - color: #00000090; -}*/ - a { color: var(--link-color); cursor: pointer; diff --git a/templates/feed.html b/templates/feed.html index 86013bb..f8800bc 100644 --- a/templates/feed.html +++ b/templates/feed.html @@ -24,7 +24,6 @@ {% if posts %}