Best template

This commit is contained in:
Andros Fenollosa 2021-11-12 20:54:20 +01:00
parent c8fbf9fb4a
commit ae59910bb7
5 changed files with 23 additions and 13 deletions

View File

@ -4,7 +4,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>htmx demo</title> <title>htmx demo</title>
<link rel="icon" type="image/png" href="favicon.png"> <link rel="icon" type="image/png" href="{% static "img/favicon.png" %}">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
<meta name="author" content="Andros Fenollosa"> <meta name="author" content="Andros Fenollosa">
<meta name="generator" content="Django"> <meta name="generator" content="Django">
@ -17,7 +17,7 @@
<script defer src="{% static "js/htmx.min.js" %}"></script> <script defer src="{% static "js/htmx.min.js" %}"></script>
</head> </head>
<body> <body>
<div class="container"> <div class="container" hx-ws="connect:ws:{{ DOMAIN }}/ws/pages/{{ room_random }}/">
<header> <header>
<nav> <nav>
<ul> <ul>
@ -30,7 +30,7 @@
</ul> </ul>
</nav> </nav>
</header> </header>
<main hx-ws="connect:ws:{{ DOMAIN }}/ws/pages/{{ room_random }}/" id="page"></main> <main id="main"></main>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,3 +1,3 @@
<main id="page"> <main id="main">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Corporis dignissimos dolor inventore laudantium libero optio quo reprehenderit repudiandae sapiente similique. Delectus dolorum enim fuga fugiat ipsam nam recusandae sequi sint. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Corporis dignissimos dolor inventore laudantium libero optio quo reprehenderit repudiandae sapiente similique. Delectus dolorum enim fuga fugiat ipsam nam recusandae sequi sint.
</main> </main>

View File

@ -1,9 +1,20 @@
<main id="page"> <main id="main">
{% for talk in talks %} {% for talk in talks %}
<article> <a href="#">
<header>{{ talk.title }}</header> <article>
<p></p> <header>
<footer>Author {{ talk.author.full_name }} - {{ talk.category.name }}</footer> <div class="grid">
</article> <p>
<img width="200" src="{{ talk.image.url }}">
</p>
<h2>{{ talk.title }}</h2>
</div>
</header>
<p>
{{ talk.content|truncatechars:100 }}
</p>
<footer>Author {{ talk.author.full_name }} - {{ talk.category.name }}</footer>
</article>
</a>
{% endfor %} {% endfor %}
</main> </main>

View File

@ -13,6 +13,7 @@ def index(request):
"DOMAIN": settings.DOMAIN, "DOMAIN": settings.DOMAIN,
}) })
def page_talks(): def page_talks():
return render_to_string("pages/talks.html", { return render_to_string("pages/talks.html", {
"talks": Talk.objects.order_by("title")[:5] "talks": Talk.objects.order_by("title")[:5]

View File

@ -19,9 +19,7 @@ def run():
category=Category.objects.order_by("?")[0], category=Category.objects.order_by("?")[0],
author=Profile.objects.order_by("?")[0], author=Profile.objects.order_by("?")[0],
is_draft=False, is_draft=False,
content="<p>" content=fake.paragraph(nb_sentences=randint(20, 100)),
+ "</p><p>".join(fake.paragraph(nb_sentences=randint(5, 10)))
+ "</p>",
) )
my_talk.save() my_talk.save()