Solve problems, and use redirection in makefile
This commit is contained in:
parent
24a41ca958
commit
ccabcf657f
2 changed files with 11 additions and 12 deletions
6
makefile
6
makefile
|
@ -7,11 +7,11 @@ PYTHON ::= venv/bin/python
|
|||
|
||||
.PHONY: all clean public
|
||||
|
||||
all: $(BUILD_DIR)/index.html $(BUILD_DIR)/feed.xml $(BUILD_DIR)/syntax.css public $(BLOG_HTML)
|
||||
all: $(BUILD_DIR)/index.html $(BUILD_DIR)/rss.xml $(BUILD_DIR)/syntax.css public $(BLOG_HTML)
|
||||
|
||||
$(BUILD_DIR)/index.html: templates/index.html $(BLOG) page.py
|
||||
@mkdir -p "$(@D)"
|
||||
$(PYTHON) page.py --index "$<" "$@" $(BLOG)
|
||||
$(PYTHON) page.py --index "$<" $(BLOG) > "$@"
|
||||
|
||||
$(BUILD_DIR)/rss.xml: $(BLOG) rss.py page.py
|
||||
@mkdir -p "$(@D)"
|
||||
|
@ -19,7 +19,7 @@ $(BUILD_DIR)/rss.xml: $(BLOG) rss.py page.py
|
|||
|
||||
$(BUILD_DIR)/blog/%.html: blog/%.md templates/blog.html page.py
|
||||
@mkdir -p "$(@D)"
|
||||
$(PYTHON) page.py "$<" "$@"
|
||||
$(PYTHON) page.py "$<" > "$@"
|
||||
|
||||
$(BUILD_DIR)/syntax.css: makefile
|
||||
@mkdir -p "$(@D)"
|
||||
|
|
17
page.py
17
page.py
|
@ -63,29 +63,28 @@ def safe_metadata(metadata):
|
|||
def main():
|
||||
if sys.argv[1] == "--index":
|
||||
blog_post_list = (
|
||||
ipo(sys.argv[4:]) |
|
||||
ipo(sys.argv[3:]) |
|
||||
p(map, blog_page_metadata) |
|
||||
p(sorted, key=lambda x: x["published"]) |
|
||||
p(map, safe_metadata) |
|
||||
p(map, lambda metadata: LIST_ITEM_TEMPLATE.format(**metadata)) |
|
||||
"".join
|
||||
)
|
||||
).data
|
||||
|
||||
with open(sys.argv[2]) as file_in, open(sys.argv[3], "w") as file_out:
|
||||
with open(sys.argv[2]) as file_in:
|
||||
print(
|
||||
file_in.read().format(blog_posts=blog_post_list),
|
||||
end="", file=file_out
|
||||
end=""
|
||||
)
|
||||
|
||||
else:
|
||||
metadata = safe_metadata(blog_page_metadata(sys.argv[1]))
|
||||
body = blog_page_body(sys.argv[1])
|
||||
|
||||
with open(sys.argv[2], "w") as file_out:
|
||||
print(
|
||||
blog_page_template().format(**metadata, body=body),
|
||||
end="", file=file_out
|
||||
)
|
||||
print(
|
||||
blog_page_template().format(**metadata, body=body),
|
||||
end=""
|
||||
)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Reference in a new issue