links page
This commit is contained in:
parent
1ec6813323
commit
e8df977bed
|
@ -4,7 +4,7 @@
|
|||
{% block languagecode %}{{ LANGUAGE_CODE }}{% endblock languagecode %}
|
||||
{% block title %}{% translate "cscherr.de" %} - {% translate "Blog" %}{% endblock title %}
|
||||
{% block nav %}
|
||||
{% include 'blog/nav.html' %}
|
||||
{% include 'nav.html' %}
|
||||
{% endblock nav %}
|
||||
{% block headscripts %}
|
||||
<script type="text/javascript" id="MathJax-script" async
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<h4 class="">{% trans "Featured" %}</h4>
|
||||
<div class="row my-4">
|
||||
{% for post in featured_posts %}
|
||||
<div class="card m-2 p-0" style="width: 18rem;">
|
||||
<div class="card col m-2 p-0" style="width: 18rem;">
|
||||
<a class="text-reset link-offset-2 link-underline link-underline-opacity-0" href=" {% url 'blog:post' post.category.slug post.slug %}">
|
||||
<img src="{{ post.thumbnail.url }}" class="card-img-top img-fluid" style="max-height: 150px;" alt="thumbnail">
|
||||
<div class="card-body" style="height: 100px;">
|
||||
|
@ -16,7 +16,7 @@
|
|||
<p class="card-text">{{ post.desc_en }}</p>
|
||||
{% else %}
|
||||
<h5 class="card-title">{{ post.title_en }}<small class="text-body-secondary">{{ post.subtitle }}</small></h5>
|
||||
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
|
||||
<p class="card-text">{{ post.desc_en }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="container pt-5">
|
||||
|
|
|
@ -35,3 +35,12 @@ class SearchableAdmin(admin.ModelAdmin):
|
|||
ordering = ['title_de', 'title_en']
|
||||
actions = [regenerate]
|
||||
|
||||
|
||||
@admin.register(Link)
|
||||
class LinkAdmin(admin.ModelAdmin):
|
||||
"""
|
||||
Admin Interface for Links
|
||||
"""
|
||||
list_display = ["title_en", "title_de", "url", "suburl"]
|
||||
ordering = ['title_de', 'title_en']
|
||||
actions = [regenerate]
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
# Generated by Django 3.2.19 on 2023-06-05 16:15
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('start', '0004_auto_20230604_2312'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Link',
|
||||
fields=[
|
||||
('searchable_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, to='start.searchable')),
|
||||
('url', models.URLField(primary_key=True, serialize=False, unique=True)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Link',
|
||||
'verbose_name_plural': 'Links',
|
||||
},
|
||||
bases=('start.searchable',),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.19 on 2023-06-05 16:18
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('start', '0005_link'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='searchable',
|
||||
name='title_en',
|
||||
field=models.CharField(default='title EN', max_length=50),
|
||||
),
|
||||
]
|
|
@ -1,3 +1,4 @@
|
|||
from enum import unique
|
||||
from django.db import models
|
||||
from django.db.models.options import override
|
||||
from django.utils.translation import gettext as _
|
||||
|
@ -27,7 +28,7 @@ class Searchable(models.Model):
|
|||
This class is not a real abstract class, I need to query it in the main search, so thats impossible
|
||||
"""
|
||||
title_de = models.CharField(max_length=50, default="Titel DE")
|
||||
title_en = models.CharField(max_length=50, default="title en")
|
||||
title_en = models.CharField(max_length=50, default="title EN")
|
||||
subtitle_de = models.CharField(max_length=50, blank=True)
|
||||
subtitle_en = models.CharField(max_length=50, blank=True)
|
||||
desc_de = models.CharField(max_length=250, unique=False, default="Beschreibung DE")
|
||||
|
@ -81,3 +82,28 @@ class StaticSite(Searchable):
|
|||
class Meta:
|
||||
verbose_name = _("static site")
|
||||
verbose_name_plural = _("static sites")
|
||||
|
||||
class Link(Searchable):
|
||||
"""
|
||||
contains all my interesting links
|
||||
"""
|
||||
|
||||
# the actual link
|
||||
url = models.URLField(unique=True, null=False, primary_key=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"{{<{self.__class__.__name__}>\"{self.title_en}\"}}"
|
||||
|
||||
def regenerate(self):
|
||||
"""
|
||||
regenerate a object
|
||||
|
||||
Implements the abstract method of Searchable
|
||||
"""
|
||||
logger.info(f"regenerating {self.__class__.__name__} object: {self}")
|
||||
self.suburl = f"/links#{self.title_en}"
|
||||
self.save()
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("Link")
|
||||
verbose_name_plural = _("Links")
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
</head>
|
||||
<body>
|
||||
{% block nav %}
|
||||
{% include 'start/nav.html' %}
|
||||
{% include 'nav.html' %}
|
||||
{% endblock nav %}
|
||||
<main class="m-5" style="min-height: 80vh;">
|
||||
{% block main %}{% endblock main %}
|
||||
|
|
|
@ -11,11 +11,37 @@
|
|||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" aria-current="page" href="{% url 'start:index' %}">{% translate "Start" %}</a>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
{% translate "Start" %}
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="{% url 'start:index' %}">{% translate "Start" %}</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'start:professional' %}">{% translate "Professionell" %}</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'start:links' %}">{% translate "Links" %}</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="{% url 'start:legal' %}">{% translate "Legal Info" %}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="{% url 'blog:index' %}">{% translate "Blog" %}</a>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
{% translate "Blog" %}
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="{% url 'blog:index' %}">{% translate "Start" %}</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'blog:category_list' %}">{% translate "category list" %}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Debug
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="http://localhost:8082" target="_blank">DB</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'admin:index' %}" target="_blank">Admin</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
@ -0,0 +1,113 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
{% block languagecode %}{{ LANGUAGE_CODE }}{% endblock languagecode %}
|
||||
{% block title %}{% translate "cscherr.de" %} - {% translate "Links" %}{% endblock title %}
|
||||
{% block main %}
|
||||
<div class="container-xl">
|
||||
<div class="jumbotron text-center">
|
||||
<h1>{% translate "cscherr.de" %}</h1>
|
||||
<p>Untertitel</p>
|
||||
</div>
|
||||
<div class="row text-center">
|
||||
<h4>
|
||||
{% translate "Wer bin ich?" %}
|
||||
<small class="text-body-secondary">{% translate "Professionell" %}</small>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="row my-4">
|
||||
{% for link in links %}
|
||||
<a href="{{ link.url }}" class="text-reset link-offset-2 link-underline link-underline-opacity-0" target="_blank">
|
||||
<div class="card col m-2 p-0" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
{% if LANGUAGE_CODE == "de" %}
|
||||
<h5 class="card-title">{{ link.title_de }}<small class="text-body-secondary">{{ link.subtitle }}</small></h5>
|
||||
<hr>
|
||||
<p class="card-text">{{ link.desc_de }}</p>
|
||||
{% elif LANGUAGE_CODE == "en" %}
|
||||
<h5 class="card-title">{{ link.title_en }}<small class="text-body-secondary">{{ link.subtitle }}</small></h5>
|
||||
<hr>
|
||||
<p class="card-text">{{ link.desc_en }}</p>
|
||||
{% else %}
|
||||
<h5 class="card-title">{{ link.title_en }}<small class="text-body-secondary">{{ link.subtitle }}</small></h5>
|
||||
<hr>
|
||||
<p class="card-text">{{ link.desc_en }}</p>
|
||||
{% endif %}
|
||||
<div class="m-2"></div>
|
||||
<i class="bi-box-arrow-up-right"></i>
|
||||
<a href="{{ link.url }}" class="">{% translate "visit" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="row my-4">
|
||||
<div class="card col m-2 p-0" style="width: 18rem;">
|
||||
<div class="card-body" style="height: 100px;">
|
||||
<h5 class="card-title">sus<small class="text-body-secondary">amog</small></h5>
|
||||
<p class="card-text">sus</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card col m-2 p-0" style="width: 18rem;">
|
||||
<div class="card-body" style="height: 100px;">
|
||||
<h5 class="card-title">sus<small class="text-body-secondary">amog</small></h5>
|
||||
<p class="card-text">sus</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card col m-2 p-0" style="width: 18rem;">
|
||||
<div class="card-body" style="height: 100px;">
|
||||
<h5 class="card-title">sus<small class="text-body-secondary">amog</small></h5>
|
||||
<p class="card-text">sus</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card col m-2 p-0" style="width: 18rem;">
|
||||
<div class="card-body" style="height: 100px;">
|
||||
<h5 class="card-title">sus<small class="text-body-secondary">amog</small></h5>
|
||||
<p class="card-text">sus</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card col m-2 p-0" style="width: 18rem;">
|
||||
<div class="card-body" style="height: 100px;">
|
||||
<h5 class="card-title">sus<small class="text-body-secondary">amog</small></h5>
|
||||
<p class="card-text">sus</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card col m-2 p-0" style="width: 18rem;">
|
||||
<div class="card-body" style="height: 100px;">
|
||||
<h5 class="card-title">sus<small class="text-body-secondary">amog</small></h5>
|
||||
<p class="card-text">sus</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card col m-2 p-0" style="width: 18rem;">
|
||||
<div class="card-body" style="height: 100px;">
|
||||
<h5 class="card-title">sus<small class="text-body-secondary">amog</small></h5>
|
||||
<p class="card-text">sus</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card col m-2 p-0" style="width: 18rem;">
|
||||
<div class="card-body" style="height: 100px;">
|
||||
<h5 class="card-title">sus<small class="text-body-secondary">amog</small></h5>
|
||||
<p class="card-text">sus</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card col m-2 p-0" style="width: 18rem;">
|
||||
<div class="card-body" style="height: 100px;">
|
||||
<h5 class="card-title">sus<small class="text-body-secondary">amog</small></h5>
|
||||
<p class="card-text">sus</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card col m-2 p-0" style="width: 18rem;">
|
||||
<div class="card-body" style="height: 100px;">
|
||||
<h5 class="card-title">sus<small class="text-body-secondary">amog</small></h5>
|
||||
<p class="card-text">sus</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card col m-2 p-0" style="width: 18rem;">
|
||||
<div class="card-body" style="height: 100px;">
|
||||
<h5 class="card-title">sus<small class="text-body-secondary">amog</small></h5>
|
||||
<p class="card-text">sus</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock main %}
|
|
@ -1,74 +0,0 @@
|
|||
{% load i18n %}
|
||||
{% load helper_tags %}
|
||||
<nav class="sticky-top navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="{% url 'start:index' %}">
|
||||
<img src="https://static.cscherr.de/images/profile/profile-margin.png" alt="Logo" height="30" class="d-inline-block align-text-top">
|
||||
{% translate "cscherr.de" noop %}
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="{% url 'start:index' %}">{% translate "Start" %}</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'blog:index' %}">{% translate "Blog" %}</a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Debug
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="http://localhost:8082" target="_blank">DB</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'admin:index' %}" target="_blank">Admin</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
{% get_available_languages as languages %}
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
{{ LANGUAGE_CODE }}
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
{% for lang_code, lang_name in languages %}
|
||||
<li><a class="dropdown-item"
|
||||
href="{{ request.scheme }}://{{ request.META.HTTP_HOST }}{% change_lang lang_code %}?{{ request.GET.urlencode }}">
|
||||
{{ lang_name }}</a></li>
|
||||
{% endfor %}
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
{% include 'dark_light_switch.html' %}
|
||||
</li>
|
||||
</ul>
|
||||
{% include 'main_search_form.html' %}
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
'use strict'
|
||||
document.getElementById("toggleThemeButton").onclick = function () {
|
||||
const storedTheme = localStorage.getItem('theme');
|
||||
if (storedTheme == null) {
|
||||
localStorage.setItem("theme", "dark");
|
||||
document.getElementById("toggleThemeIcon").className = "bi bi-sun";
|
||||
setTheme("dark");
|
||||
}
|
||||
else if (storedTheme == "dark") {
|
||||
localStorage.setItem("theme", "light");
|
||||
document.getElementById("toggleThemeIcon").className = "bi bi-sun-fill";
|
||||
setTheme("light");
|
||||
}
|
||||
else if (storedTheme == "light") {
|
||||
localStorage.setItem("theme", "dark");
|
||||
document.getElementById("toggleThemeIcon").className = "bi bi-sun";
|
||||
setTheme("dark");
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</nav>
|
|
@ -7,6 +7,7 @@ urlpatterns = [
|
|||
path("", views.Index.as_view(), name="index"),
|
||||
path("search/", views.MainSearch.as_view(), name="search"),
|
||||
path("legal/", views.LegalInfo.as_view(), name="legal"),
|
||||
path("links/", views.Links.as_view(), name="links"),
|
||||
path("professional/", views.LegalInfo.as_view(), name="professional"),
|
||||
path('language/activate/<language_code>/', views.ActivateLanguage.as_view(), name='activate_language'),
|
||||
]
|
||||
|
|
|
@ -15,7 +15,7 @@ from django.views.generic.list import QuerySet
|
|||
from django.db.models import Q
|
||||
|
||||
from .forms import MainSearchForm
|
||||
from .models import Searchable
|
||||
from .models import Link, Searchable
|
||||
|
||||
from abc import ABC
|
||||
|
||||
|
@ -94,3 +94,11 @@ class MainSearch(ListView):
|
|||
if not form.is_valid():
|
||||
return render(request, "errors/bad_request.html")
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
||||
class Links(ListView):
|
||||
"""
|
||||
This View contains links to various interesting sites.
|
||||
"""
|
||||
model = Link
|
||||
context_object_name = "links"
|
||||
template_name = "start/links.html"
|
||||
|
|
Loading…
Reference in New Issue