diff options
| author | Yuval Adam <_@yuv.al> | 2017-08-07 09:17:36 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2017-08-07 09:17:36 +0300 |
| commit | dd0cce923a29aee84f7050b7e0c886c8d32a84a7 (patch) | |
| tree | 620c8c963ecfdbce277aa79388d5fd42fca6e518 | |
| parent | 14958653b9bf92f56316511e8080baeeaf409b97 (diff) | |
Add wiki content
| -rw-r--r-- | .gitmodules | 3 | ||||
| -rw-r--r-- | README.md | 6 | ||||
| -rw-r--r-- | app.py | 20 | ||||
| m--------- | content/wiki | 0 | ||||
| -rw-r--r-- | templates/base.html | 2 | ||||
| -rw-r--r-- | templates/index.html | 16 | ||||
| -rw-r--r-- | templates/wiki-page.html | 6 | ||||
| -rw-r--r-- | templates/wiki.html | 9 |
8 files changed, 53 insertions, 9 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..bf0062c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "content/wiki"] + path = content/wiki + url = https://github.com/postmarketOS/pmbootstrap.wiki.git @@ -2,6 +2,12 @@ ## Dev +### Update Wiki Content + +```bash +$ git submodule update --recursive --remote +``` + ### Dev Server ```bash @@ -6,6 +6,7 @@ from os import listdir app = Flask(__name__) BLOG_CONTENT_DIR = 'content/blog' +WIKI_CONTENT_DIR = 'content/wiki' @app.route('/') def home(): @@ -33,3 +34,22 @@ def blog_post(y, m, d, title): title = h.split('title:')[0].strip() html = markdown.markdown(body, extensions=['markdown.extensions.extra', 'markdown.extensions.codehilite']) return render_template('post.html', title=title, html=html) + +def parse_page(page): + slug = page[:-3] + title = slug.replace('-', ' ') + return {'url': f'/wiki/{slug}/', 'title': title} + +@app.route('/wiki/') +def wiki(): + pages = sorted(listdir(WIKI_CONTENT_DIR), reverse=True) + pages = map(parse_page, pages) + return render_template('wiki.html', pages=pages) + +@app.route('/wiki/<slug>/') +def wiki_page(slug): + with open(f'{WIKI_CONTENT_DIR}/{slug}.md') as f: + text = f.read() + title = slug.replace('-', ' ') + html = markdown.markdown(text, extensions=['markdown.extensions.extra', 'markdown.extensions.codehilite']) + return render_template('wiki-page.html', title=title, html=html) diff --git a/content/wiki b/content/wiki new file mode 160000 +Subproject f1da865ec0a3132ccd2fb0129c732792cc30946 diff --git a/templates/base.html b/templates/base.html index 379b224..64d672f 100644 --- a/templates/base.html +++ b/templates/base.html @@ -19,7 +19,9 @@ </head> <body> + <div class="mw7 center"> {% block body %} {% endblock %} + </div> </body> </html> diff --git a/templates/index.html b/templates/index.html index e0067fb..6f6ea1a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,15 +1,13 @@ {% extends 'base.html' %} {% block body %} -<div class="mw7 center"> - <div class="cf ph2-ns"> - <h1 class="f2 lh-title">postmarketOS</h1> - <div class="fl w-100 w-50-ns pa2"> - <img src="{{ url_for('static', filename='img/banner.jpg') }}"></img> - </div> - <div class="fl w-100 w-50-ns pa2"> - <p class="intro">postmarketOS, or <i>pmOS</i> in short, is a touch-optimized, pre-configured <a href="https://alpinelinux.org">Alpine Linux</a> with own packages, that can be installed on smartphones (Not usable for most people yet!).</p> - </div> +<div class="cf ph2-ns"> + <h1 class="f2 lh-title">postmarketOS</h1> + <div class="fl w-100 w-50-ns pa2"> + <img src="{{ url_for('static', filename='img/banner.jpg') }}"></img> + </div> + <div class="fl w-100 w-50-ns pa2"> + <p class="intro">postmarketOS, or <i>pmOS</i> in short, is a touch-optimized, pre-configured <a href="https://alpinelinux.org">Alpine Linux</a> with own packages, that can be installed on smartphones (Not usable for most people yet!).</p> </div> </div> {% endblock %} diff --git a/templates/wiki-page.html b/templates/wiki-page.html index e69de29..7a24d02 100644 --- a/templates/wiki-page.html +++ b/templates/wiki-page.html @@ -0,0 +1,6 @@ +{% extends 'base.html' %} + +{% block body %} +<h1>{{ title }}</h1> +{{ html|safe }} +{% endblock %} diff --git a/templates/wiki.html b/templates/wiki.html index e69de29..66d870b 100644 --- a/templates/wiki.html +++ b/templates/wiki.html @@ -0,0 +1,9 @@ +{% extends 'base.html' %} + +{% block body %} +<ul> +{% for page in pages %} + <li><a href="{{ page.url }}">{{ page.title }}</a></li> +{% endfor %} +</ul> +{% endblock %} |
