Commit 14958653 authored by Yuval Adam's avatar Yuval Adam

Basic structure and initial homepage

parents
*.pyc
__pycache__
build/
\ No newline at end of file
# postmarketos.org
## Dev
### Dev Server
```bash
$ FLASK_DEBUG=1 FLASK_APP=app.py flask run
```
### Build
```bash
$ python freeze.py
```
import markdown
from flask import Flask, render_template
from os import listdir
app = Flask(__name__)
BLOG_CONTENT_DIR = 'content/blog'
@app.route('/')
def home():
return render_template('index.html')
def parse_post(post):
y, m, d, *title = post[:-3].split('-')
slug = '-'.join(title)
return {'url': f'/blog/{y}/{m}/{d}/{slug}/', 'title': ' '.join(title)}
@app.route('/blog/')
def blog():
posts = sorted(listdir(BLOG_CONTENT_DIR), reverse=True)
posts = map(parse_post, posts)
return render_template('blog.html', posts=posts)
@app.route('/blog/<y>/<m>/<d>/<title>/')
def blog_post(y, m, d, title):
post_path = f'{y}-{m}-{d}-{title}'
with open(f'{BLOG_CONTENT_DIR}/{post_path}.md', 'r') as f:
text = f.read()
_, header, body = text.split('---')
for h in header:
if h.startswith('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)
from flask_frozen import Freezer
from app import app
freezer = Freezer(app)
if __name__ == '__main__':
freezer.freeze()
click==6.7
Flask==0.12.2
Frozen-Flask==0.15
itsdangerous==0.24
Jinja2==2.9.6
Markdown==2.6.8
MarkupSafe==1.0
Werkzeug==0.12.2
p.intro {
font-size: 1.3em;
line-height: 1.3em;
}
This diff is collapsed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{% block title %}postmarketOS{% endblock %}</title>
<meta name="description" content="Aiming for a 10 year life-cycle for smartphones">
<meta name="keywords" content="postmarketOS">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="all">
<link rel="canonical" href="https://postmarketos.org{{ request.path }}">
<link href="{{ url_for('static', filename='css/tachyons.min.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='css/main.css') }}" rel="stylesheet">
</head>
<body>
{% block body %}
{% endblock %}
</body>
</html>
{% extends 'base.html' %}
{% block body %}
<h1>{{ title }}</h1>
{{ html|safe }}
{% endblock %}
{% extends 'base.html' %}
{% block body %}
<ul>
{% for post in posts %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
{% endblock %}
{% 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>
</div>
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment