refactor: simplify html page building
This commit is contained in:
+10
-5
@@ -89,9 +89,13 @@ class Build:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# cached
|
# cached
|
||||||
def __build_page(self, content, course_wrapper=False) :
|
def __build_page(self, content, course_wrapper=False, sidebar=None) :
|
||||||
page_template = self.env.get_template("page.html")
|
page_template = self.env.get_template("page.html")
|
||||||
return page_template.render(content=content, course_wrapper=course_wrapper)
|
return page_template.render(
|
||||||
|
content=content,
|
||||||
|
course_wrapper=course_wrapper,
|
||||||
|
sidebar=sidebar
|
||||||
|
)
|
||||||
|
|
||||||
def __picture_handler(self, id):
|
def __picture_handler(self, id):
|
||||||
os.makedirs("build/pictures", exist_ok=True)
|
os.makedirs("build/pictures", exist_ok=True)
|
||||||
@@ -220,11 +224,12 @@ class Build:
|
|||||||
|
|
||||||
def __build_html_page(self, contents, page):
|
def __build_html_page(self, contents, page):
|
||||||
for content in contents:
|
for content in contents:
|
||||||
template = self.env.get_template("html.html")
|
|
||||||
if content["url_part"] == page:
|
if content["url_part"] == page:
|
||||||
result = template.render({"content": content})
|
|
||||||
with open(f"build/{page}.html", "w") as file:
|
with open(f"build/{page}.html", "w") as file:
|
||||||
result = self.__build_page(result)
|
result = self.__build_page(
|
||||||
|
content=content["content"],
|
||||||
|
sidebar=content["sidebar"]
|
||||||
|
)
|
||||||
file.write(result)
|
file.write(result)
|
||||||
|
|
||||||
def build_website(self):
|
def build_website(self):
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
{% if content["sidebar"] == None %}
|
|
||||||
{{ content["content"] }}
|
|
||||||
{% else %}
|
|
||||||
<div class="fiftyohm-content-2cols">
|
|
||||||
<div>{{ content["content"] }}</div>
|
|
||||||
<div>{{ content["sidebar"] }}</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
@@ -104,11 +104,18 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if sidebar == None %}
|
||||||
{% if course_wrapper == True %}
|
{% if course_wrapper == True %}
|
||||||
<div class="course">
|
<div class="course">
|
||||||
{% endif %}
|
|
||||||
{{ content }}
|
{{ content }}
|
||||||
{% if course_wrapper == True %}
|
</div>
|
||||||
|
{% else %}
|
||||||
|
{{ content }}
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
<div class="fiftyohm-content-2cols">
|
||||||
|
<div>{{ content }}</div>
|
||||||
|
<div>{{ sidebar }}</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user