mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Added FAQ
This commit is contained in:
parent
5f4980e49e
commit
1769fb5ab1
@ -1,5 +1,4 @@
|
||||
{% from 'base/macros.jinja2' import external_link, is_active_page, nav_item, defer_css with context %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
||||
26
docs/content/pages/faq.jinja2
Normal file
26
docs/content/pages/faq.jinja2
Normal file
@ -0,0 +1,26 @@
|
||||
{#~ Title:FAQ ~#}
|
||||
{#~ Sort-Priority:95 ~#}
|
||||
|
||||
|
||||
{% macro faq(id, q, a) %}
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header">
|
||||
<button id="{{ id }}-heading" class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#{{ id }}" aria-expanded="false" aria-controls="{{ id }}">
|
||||
Q: {{ q }}
|
||||
</button>
|
||||
</h2>
|
||||
<div id="{{ id }}" class="accordion-collapse collapse" aria-labelledby="{{ id }}-heading" data-bs-parent="#accordionFAQ">
|
||||
<div class="accordion-body">
|
||||
{{ ("A: " + a)|simple_md|replace('p', 'p class="my-0 ms-2" ')|safe }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
<h1 class="text-center pb-2">FAQ</h1>
|
||||
|
||||
<div class="accordion" id="accordionFAQ">
|
||||
{{ faq("jammer", "Will Jammer Be Added?", "Yes! Check **your front door**") }}
|
||||
{{ faq("rails", "Will Rails Be Added?", "No") }}
|
||||
</div>
|
||||
|
||||
@ -20,3 +20,17 @@ pre > code {
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #555;
|
||||
}
|
||||
|
||||
.accordion-button:not(.collapsed) {
|
||||
color: #effff7;
|
||||
background-color: #2b2b2b;
|
||||
}
|
||||
|
||||
.accordion-button:not(.collapsed)::after {
|
||||
color: #effff7;
|
||||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
|
||||
}
|
||||
|
||||
.accordion-item {
|
||||
border: 1px solid rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
@ -14,20 +14,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
.accordion-button:not(.collapsed) {
|
||||
color: #effff7;
|
||||
background-color: #2b2b2b;
|
||||
}
|
||||
|
||||
.accordion-button:not(.collapsed)::after {
|
||||
color: #effff7;
|
||||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
|
||||
}
|
||||
|
||||
.accordion-item {
|
||||
border: 1px solid rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.bg-warning {
|
||||
color: #131313;
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ from pathlib import Path
|
||||
from shutil import rmtree
|
||||
|
||||
from jinja2 import Environment, select_autoescape, FileSystemLoader
|
||||
from markdown import Markdown
|
||||
|
||||
from lib.Content.CSSStaticItem import CSSStaticItem
|
||||
from lib.Content.HTMLPage import HTMLPage
|
||||
@ -42,12 +43,16 @@ meta_files = [MinifiedMetaItem(Path('browserconfig.jinja2'), '.xml'),
|
||||
|
||||
router = {}
|
||||
|
||||
filter_md = Markdown(extensions=['extra'], output_format='html5')
|
||||
|
||||
env.filters.update({
|
||||
'upper_first': lambda x: x[0].upper() + x[1:],
|
||||
'static': lambda path: str(Path(OUT_DIR, path).as_posix()),
|
||||
'route': lambda title: router.get(title.lower(), "#"),
|
||||
'full_url': lambda relative: BASE_URL + (relative[1:] if relative[0] == "/" else relative),
|
||||
'gen_time': lambda x: GEN_TIME
|
||||
'gen_time': lambda x: GEN_TIME,
|
||||
'simple_md': lambda s: filter_md.convert(s),
|
||||
'inline_md': lambda s: filter_md.convert(s)[3:-4].replace("<em>", "<span style=\"font-style: italic;\">").replace("</em>", "</span>")
|
||||
})
|
||||
|
||||
MetaItem.initialize(env)
|
||||
|
||||
@ -1,58 +0,0 @@
|
||||
from abc import ABC
|
||||
from pathlib import Path
|
||||
|
||||
from htmlmin import minify
|
||||
from jinja2 import Environment
|
||||
|
||||
|
||||
class AbstractContentItem(ABC):
|
||||
|
||||
output_ext: str = '.html'
|
||||
env: Environment
|
||||
in_path: Path
|
||||
out_path: Path
|
||||
root_dir: Path
|
||||
|
||||
def __init__(self, in_path: Path, ext: str = None):
|
||||
self.env = None
|
||||
if ext is not None:
|
||||
self.output_ext = ext
|
||||
self.in_path = in_path
|
||||
self.out_path = Path('out/', in_path.name).with_suffix(self.output_ext)
|
||||
|
||||
@classmethod
|
||||
def initialize(cls, env: Environment) -> list:
|
||||
raise NotImplementedError()
|
||||
|
||||
def render(self, **context) -> str:
|
||||
raise NotImplementedError()
|
||||
|
||||
def _save(self, rendered: str):
|
||||
self.out_path.parent.mkdir(mode=511, parents=True, exist_ok=True)
|
||||
with self.out_path.open(mode='w+', encoding='utf-8') as file:
|
||||
file.write(rendered)
|
||||
|
||||
def generate(self, **context) -> None:
|
||||
print("Building:", self.in_path, "->", self.out_path)
|
||||
self._save(self.render(**context))
|
||||
|
||||
def add_route(self, routes, out_dir):
|
||||
pass
|
||||
|
||||
|
||||
class MinifyMixin(AbstractContentItem, ABC):
|
||||
|
||||
MINIFY_SETTINGS = {
|
||||
'remove_empty_space': True,
|
||||
'keep_pre': True,
|
||||
'remove_optional_attribute_quotes': False
|
||||
}
|
||||
|
||||
def _save(self, rendered: str):
|
||||
rendered = minify(rendered, **self.MINIFY_SETTINGS)
|
||||
super(MinifyMixin, self)._save(rendered)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -14,14 +14,16 @@ class AbstractTemplatedItem(MinifyMixin, AbstractItem, ABC):
|
||||
sort_priority: int = None
|
||||
render_toc: bool = False
|
||||
table_of_contents: dict = {}
|
||||
meta: dict = {
|
||||
'title': None,
|
||||
'description': None,
|
||||
'sort_priority': 10
|
||||
}
|
||||
|
||||
def load_metadata(self):
|
||||
if self.title is None:
|
||||
self.title = self.in_path.stem
|
||||
if self.description is None:
|
||||
self.description = None
|
||||
if self.sort_priority is None:
|
||||
self.sort_priority = 10
|
||||
self.title = self.meta['title'] if self.meta['title'] is not None else self.in_path.stem
|
||||
self.description = self.meta['description']
|
||||
self.sort_priority = int(self.meta['sort_priority'])
|
||||
|
||||
@classmethod
|
||||
def initialize(cls, env: Environment):
|
||||
|
||||
@ -1,8 +1,19 @@
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
from lib.Content.AbstractTemplatedItem import AbstractTemplatedItem
|
||||
|
||||
|
||||
class HTMLPage(AbstractTemplatedItem):
|
||||
|
||||
def load_metadata(self):
|
||||
with self.in_path.open(mode='r', encoding='utf-8') as file:
|
||||
content = file.read()
|
||||
for match in re.findall(r"{#~(.*?)~#}", content, re.MULTILINE):
|
||||
seperated = match.strip().split(':')
|
||||
print(match.strip())
|
||||
self.meta[seperated[0].lower().replace('-', '_')] = seperated[1]
|
||||
super(HTMLPage, self).load_metadata()
|
||||
|
||||
root_dir = Path("pages/")
|
||||
extensions = ('html', 'jinja2', 'jinja')
|
||||
|
||||
@ -29,10 +29,10 @@ class JSONSchema(AbstractSchemaItem):
|
||||
extensions = ('json',)
|
||||
|
||||
def load_metadata(self):
|
||||
self.sort_priority = 10
|
||||
self.meta['sort_priority'] = 10
|
||||
with self.in_path.open(mode='r', encoding='utf-8') as file:
|
||||
self.title = json.load(file).get('title', self.in_path.stem)
|
||||
self.description = "Schema for a " + self.title + " in New Horizons"
|
||||
self.meta['title'] = json.load(file).get('title', self.in_path.stem)
|
||||
self.meta['description'] = "Schema for a " + self.meta['title'] + " in New Horizons"
|
||||
super(JSONSchema, self).load_metadata()
|
||||
|
||||
def render(self, **context):
|
||||
|
||||
@ -11,7 +11,8 @@ class MDPage(AbstractTemplatedItem):
|
||||
extensions = ('md', 'markdown')
|
||||
|
||||
MARKDOWN_SETTINGS = {
|
||||
'extensions': ['extra', 'toc', 'meta', BootstrapExtension()]
|
||||
'extensions': ['extra', 'toc', 'meta', BootstrapExtension()],
|
||||
'output-format': 'html5'
|
||||
}
|
||||
|
||||
def load_metadata(self):
|
||||
@ -19,14 +20,14 @@ class MDPage(AbstractTemplatedItem):
|
||||
with self.in_path.open(mode='r', encoding='utf-8') as file:
|
||||
md.convert(file.read())
|
||||
|
||||
self.title = md.Meta.get('title')[0]
|
||||
self.description = md.Meta.get('description', [None])[0]
|
||||
self.meta['title'] = md.Meta.get('title')[0]
|
||||
self.meta['description'] = md.Meta.get('description', [None])[0]
|
||||
self.render_toc = md.Meta.get('toc', ['True'])[0].strip().lower() == "true"
|
||||
if self.render_toc:
|
||||
self.table_of_contents = md.toc_tokens
|
||||
raw_priority = md.Meta.get('sort-priority')
|
||||
if raw_priority is not None:
|
||||
self.sort_priority = int(raw_priority[0])
|
||||
self.meta['sort_priority'] = int(raw_priority[0])
|
||||
out_name = md.Meta.get('out-file', None)
|
||||
if out_name is not None:
|
||||
self.out_path = self.out_path.with_stem(out_name[0])
|
||||
|
||||
@ -70,7 +70,7 @@ class XMLSchema(AbstractSchemaItem):
|
||||
file.readline()
|
||||
line = file.readline()
|
||||
if len(line.strip()) != 0 and '<!--' in line and '-->' in line:
|
||||
self.title = line.replace('<!--', '').replace('-->', '').strip()
|
||||
self.meta['title'] = line.replace('<!--', '').replace('-->', '').strip()
|
||||
super(XMLSchema, self).load_metadata()
|
||||
|
||||
def render(self, **context):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user