generated from hjess/PythonTemplateProject
Loads of boiler plating
Some checks failed
Build, Push, and Deploy to Nomad / docker-nomad (push) Has been cancelled
Some checks failed
Build, Push, and Deploy to Nomad / docker-nomad (push) Has been cancelled
This commit is contained in:
16
app.py
16
app.py
@@ -20,17 +20,29 @@ with open("mock_data.json") as file:
|
||||
# Index route
|
||||
@app.get("/", response_class=HTMLResponse)
|
||||
async def get_index(request: Request):
|
||||
return templates.TemplateResponse("index.html", {"request": request, "data": data})
|
||||
return templates.TemplateResponse(
|
||||
"index.html",
|
||||
{"request": request, "data": data, "page_title": "Forside", "author": "Henrik"}
|
||||
)
|
||||
|
||||
# Category route
|
||||
@app.get("/category/{category_name}", response_class=HTMLResponse)
|
||||
async def get_category(request: Request, category_name: str):
|
||||
# Find den korrekte kategori
|
||||
category = next((cat for cat in data["categories"] if cat["path"] == category_name), None)
|
||||
if category:
|
||||
category_file = f"data/{category_name}/index.html"
|
||||
if os.path.exists(category_file):
|
||||
with open(category_file) as file:
|
||||
category_content = file.read()
|
||||
return templates.TemplateResponse(
|
||||
"category.html",
|
||||
{"request": request, "category_name": category_name, "content": category_content}
|
||||
{
|
||||
"request": request,
|
||||
"data": data,
|
||||
"page_title": category["name"],
|
||||
"author": category["author"],
|
||||
"content": category_content
|
||||
},
|
||||
)
|
||||
return HTMLResponse("Kategori ikke fundet", status_code=404)
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"categories": [
|
||||
{"name": "SKAT", "path": "skat"},
|
||||
{"name": "Skole", "path": "skole"},
|
||||
{"name": "Bolig", "path": "bolig"},
|
||||
{"name": "Job", "path": "job"}
|
||||
{"name": "SKAT", "path": "skat", "author": "Henrik"},
|
||||
{"name": "Skole", "path": "skole", "author": "Erika"},
|
||||
{"name": "Bolig", "path": "bolig", "author": "Henrik"},
|
||||
{"name": "Job", "path": "job", "author": "Henrik"}
|
||||
],
|
||||
"favorites": [
|
||||
{"name": "SKAT", "image": "images/pic07.jpg", "description": "Farvorit Kategori"},
|
||||
{"name": "Skole", "image": "images/pic08.jpg", "description": "Skole info"},
|
||||
{"name": "SKAT", "image": "images/pic07.jpg", "description": "Favorit Kategori"},
|
||||
{"name": "Skole", "image": "images/pic08.jpg", "description": "Skole information"},
|
||||
{"name": "Bolig", "image": "images/pic09.jpg", "description": "Bolig detaljer"}
|
||||
]
|
||||
}
|
||||
48
templates/base_template.html
Normal file
48
templates/base_template.html
Normal file
@@ -0,0 +1,48 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>{% block title %}PortugalFAQ{% endblock %}</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
|
||||
<link rel="stylesheet" href="{{ url_for('static', path='css/main.css') }}" />
|
||||
</head>
|
||||
<body class="is-preload">
|
||||
<!-- Wrapper -->
|
||||
<div id="wrapper">
|
||||
<!-- Main -->
|
||||
<div id="main">
|
||||
<div class="inner">
|
||||
<!-- Header -->
|
||||
<header id="header">
|
||||
<a href="/" class="logo">
|
||||
<strong>{{ page_title }}</strong> af {{ author }}
|
||||
</a>
|
||||
</header>
|
||||
|
||||
<!-- Content -->
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Sidebar -->
|
||||
<div id="sidebar">
|
||||
<div class="inner">
|
||||
{% include 'navigation.html' %}
|
||||
<!-- Footer -->
|
||||
<footer id="footer">
|
||||
<p class="copyright">
|
||||
© Henriks lille hjørne: <a href="https://lifefaq.i80.dk">LifeFAQ</a>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="{{ url_for('static', path='js/jquery.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', path='js/browser.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', path='js/breakpoints.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', path='js/util.js') }}"></script>
|
||||
<script src="{{ url_for('static', path='js/main.js') }}"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,14 +1,12 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>{{ category_name }} - PortugalFAQ</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', path='css/main.css') }}" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="main">
|
||||
{% extends "base_template.html" %}
|
||||
|
||||
{% block title %}{{ category_name }} - PortugalFAQ{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<header class="main">
|
||||
<h1>{{ category_name }}</h1>
|
||||
<div>{{ content | safe }}</div>
|
||||
<a href="/">Tilbage til forsiden</a>
|
||||
</header>
|
||||
<div>
|
||||
{{ content | safe }}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
@@ -1,26 +1,8 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>PortugalFAQ - Henriks og Erikas lille side</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
|
||||
<link rel="stylesheet" href="{{ url_for('static', path='css/main.css') }}" />
|
||||
</head>
|
||||
<body class="is-preload">
|
||||
<!-- Wrapper -->
|
||||
<div id="wrapper">
|
||||
<!-- Main -->
|
||||
<div id="main">
|
||||
<div class="inner">
|
||||
<!-- Header -->
|
||||
<header id="header">
|
||||
<a href="/" class="logo"><strong>Forside</strong> af Henrik</a>
|
||||
<ul class="icons">
|
||||
<li><a href="#" class="icon brands fa-facebook-f"><span class="label">Facebook</span></a></li>
|
||||
</ul>
|
||||
</header>
|
||||
{% extends "base_template.html" %}
|
||||
|
||||
<!-- Content -->
|
||||
{% block title %}PortugalFAQ - Henriks og Erikas lille side{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section>
|
||||
<header class="main">
|
||||
<h1>Min Drøm om Portugal</h1>
|
||||
@@ -59,77 +41,4 @@
|
||||
</p>
|
||||
<hr class="major" />
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Sidebar -->
|
||||
<div id="sidebar">
|
||||
<div class="inner">
|
||||
<!-- Menu -->
|
||||
<nav id="menu">
|
||||
<header class="major">
|
||||
<h2>Menu</h2>
|
||||
</header>
|
||||
<ul>
|
||||
<li><a href="/">Forside</a></li>
|
||||
<li>
|
||||
<span class="opener">Kategorier</span>
|
||||
<ul>
|
||||
{% for category in data.categories %}
|
||||
<li>
|
||||
<a href="/category/{{ category.path }}">{{ category.name }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#">Fotobog</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<!-- Highlights (favoritter) -->
|
||||
<section>
|
||||
<header class="major">
|
||||
<h2>Highlights</h2>
|
||||
</header>
|
||||
<div class="mini-posts">
|
||||
{% for favorite in data.favorites %}
|
||||
<article>
|
||||
<a href="#" class="image">
|
||||
<img src="{{ url_for('static', path=favorite.image) }}" alt="{{ favorite.name }}" />
|
||||
</a>
|
||||
<p>{{ favorite.description }}</p>
|
||||
</article>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Kontakt -->
|
||||
<section>
|
||||
<header class="major">
|
||||
<h2>Kontakt os</h2>
|
||||
</header>
|
||||
<ul class="contact">
|
||||
<li class="icon solid fa-envelope"><a href="#">henrik@i80.dk</a></li>
|
||||
<li class="icon solid fa-phone">(+45) 60214417</li>
|
||||
<li class="icon solid fa-home">Skovstræde 3<br />Stensved, 4773</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer id="footer">
|
||||
<p class="copyright">
|
||||
© Henriks lille hjørne: <a href="https://lifefaq.i80.dk">LifeFAQ</a>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="{{ url_for('static', path='js/jquery.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', path='js/browser.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', path='js/breakpoints.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', path='js/util.js') }}"></script>
|
||||
<script src="{{ url_for('static', path='js/main.js') }}"></script>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
47
templates/navigation.html
Normal file
47
templates/navigation.html
Normal file
@@ -0,0 +1,47 @@
|
||||
<!-- Navigation -->
|
||||
<nav id="menu">
|
||||
<header class="major">
|
||||
<h2>Menu</h2>
|
||||
</header>
|
||||
<ul>
|
||||
<li><a href="/">Forside</a></li>
|
||||
<li>
|
||||
<span class="opener">Kategorier</span>
|
||||
<ul>
|
||||
{% for category in data.categories %}
|
||||
<li><a href="/category/{{ category.path }}">{{ category.name }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#">Fotobog</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<!-- Highlights -->
|
||||
<section>
|
||||
<header class="major">
|
||||
<h2>Highlights</h2>
|
||||
</header>
|
||||
<div class="mini-posts">
|
||||
{% for favorite in data.favorites %}
|
||||
<article>
|
||||
<a href="#" class="image">
|
||||
<img src="{{ url_for('static', path=favorite.image) }}" alt="{{ favorite.name }}" />
|
||||
</a>
|
||||
<p>{{ favorite.description }}</p>
|
||||
</article>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Kontakt -->
|
||||
<section>
|
||||
<header class="major">
|
||||
<h2>Kontakt os</h2>
|
||||
</header>
|
||||
<ul class="contact">
|
||||
<li class="icon solid fa-envelope"><a href="#">henrik@i80.dk</a></li>
|
||||
<li class="icon solid fa-phone">(+45) 60214417</li>
|
||||
<li class="icon solid fa-home">Skovstræde 3<br />Stensved, 4773</li>
|
||||
</ul>
|
||||
</section>
|
||||
Reference in New Issue
Block a user