first commit
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
pages/
|
||||||
|
venv/
|
||||||
|
static/
|
||||||
29
app.py
Normal file
29
app.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
from flask import Flask, render_template
|
||||||
|
from flask_flatpages import FlatPages
|
||||||
|
|
||||||
|
DEBUG = True
|
||||||
|
FLATPAGES_AUTO_RELOAD = DEBUG
|
||||||
|
FLATPAGES_EXTENSION = '.md'
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
app.config.from_object(__name__)
|
||||||
|
pages = FlatPages(app)
|
||||||
|
FLATPAGES_MARKDOWN_EXTENSIONS = ['fenced_code', 'tables']
|
||||||
|
app.config['FLATPAGES_MARKDOWN_EXTENSIONS'] = FLATPAGES_MARKDOWN_EXTENSIONS
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def index():
|
||||||
|
posts = sorted(pages, key=lambda p: p.meta.get('date'), reverse=True)
|
||||||
|
return render_template('index.html', posts=posts)
|
||||||
|
|
||||||
|
@app.route('/<path:path>/')
|
||||||
|
def post(path):
|
||||||
|
page = pages.get_or_404(path)
|
||||||
|
return render_template('post.html', page=page)
|
||||||
|
|
||||||
|
@app.route('/about')
|
||||||
|
def about():
|
||||||
|
return render_template('about.html')
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run(port=5001)
|
||||||
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
flask
|
||||||
|
flask-flatpages
|
||||||
8
templates/about.html
Normal file
8
templates/about.html
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<section class="hero">
|
||||||
|
<h2 style="color: #2563eb">What is this site?</h2>
|
||||||
|
</section>
|
||||||
|
I write articles about Arduino, STM32 and self-hosting. The articles are short and conceptual. It is not tutorials but more high level descriptions and general guidelines for reproducing the various things i tinker with.
|
||||||
|
{% endblock %}
|
||||||
34
templates/base.html
Normal file
34
templates/base.html
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>{% block title %}RasmusBendtsen.dk{% endblock %}</title>
|
||||||
|
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<nav class="container">
|
||||||
|
<a href="/" class="logo">RasmusBendtsen.dk</a>
|
||||||
|
<ul class="nav-links">
|
||||||
|
<li><a href="/">Home</a></li>
|
||||||
|
<li><a href="/about">About</a></li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main class="container">
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
20
templates/index.html
Normal file
20
templates/index.html
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<section class="hero">
|
||||||
|
<h2 style="color: #2563eb; margin-bottom : 10%">I write about Self-hosting, Arduino, STM32 and various tech stupidity.</h2>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="post-list">
|
||||||
|
{% for post in posts %}
|
||||||
|
<article class="post-item">
|
||||||
|
<h3><a href="{{ url_for('post', path=post.path) }}">{{ post.title }}</a></h3>
|
||||||
|
<span class="date">{{ post.date }}</span>
|
||||||
|
<p>{{ post.meta.get('description', 'Read more...') }}</p>
|
||||||
|
<p>{{ post.meta.get('tag', 'no tag') }}</p>
|
||||||
|
</article>
|
||||||
|
{% else %}
|
||||||
|
<p>No posts yet. Time to write something!</p>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
9
templates/post.html
Normal file
9
templates/post.html
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% block content %}
|
||||||
|
<article>
|
||||||
|
<h1>{{ page.title }}</h1>
|
||||||
|
<p class="date">{{ page.date }}</p>
|
||||||
|
<div class="post-body">
|
||||||
|
{{ page.html|safe }} </div>
|
||||||
|
</article>
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user