Create tag for css imports

This commit is contained in:
Edgar P. Burkhart 2023-12-30 10:54:01 +01:00
parent 7f3b9c7b5c
commit 47d8ff0382
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
9 changed files with 24 additions and 41 deletions

View file

@ -1,5 +1,6 @@
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
{% load main_extras %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="fr"> <html lang="fr">
<head> <head>
@ -10,8 +11,8 @@
</title> </title>
{% block link %} {% block link %}
<link rel="icon" href="{% static "main/svg/logo.svg" %}" type="image/svg+xml"> <link rel="icon" href="{% static "main/svg/logo.svg" %}" type="image/svg+xml">
<link rel="stylesheet" href="{% static "main/css/main.css" %}" type="text/css"> {% css "main/css/main.css" %}
<link rel="stylesheet" href="{% static "main/remixicon/remixicon.css" %}" type="text/css"> {% css "main/remixicon/remixicon.css" %}
{% endblock %} {% endblock %}
</head> </head>
<body> <body>

View file

@ -4,12 +4,8 @@
{% load i18n %} {% load i18n %}
{% block link %} {% block link %}
{{ block.super }} {{ block.super }}
<link rel="stylesheet" {% css "main/css/form.css" %}
href="{% static 'main/css/form.css' %}" {% css "main/css/table.css" %}
type="text/css" />
<link rel="stylesheet"
href="{% static 'main/css/table.css' %}"
type="text/css" />
{% endblock %} {% endblock %}
{% block body %} {% block body %}
{% spaceless %} {% spaceless %}

View file

@ -12,15 +12,9 @@
{% endblock %} {% endblock %}
{% block link %} {% block link %}
{{ block.super }} {{ block.super }}
<link rel="stylesheet" {% css "main/css/form.css" %}
href="{% static 'main/css/form.css' %}" {% css "main/css/table.css" %}
type="text/css" /> {% css "main/css/plot.css" %}
<link rel="stylesheet"
href="{% static 'main/css/table.css' %}"
type="text/css" />
<link rel="stylesheet"
href="{% static 'main/css/plot.css' %}"
type="text/css" />
{% endblock %} {% endblock %}
{% block body %} {% block body %}
{% with instance=form.instance %} {% with instance=form.instance %}

View file

@ -4,12 +4,8 @@
{% load i18n %} {% load i18n %}
{% block link %} {% block link %}
{{ block.super }} {{ block.super }}
<link rel="stylesheet" {% css "main/css/table.css" %}
href="{% static 'main/css/table.css' %}" {% css "main/css/plot.css" %}
type="text/css">
<link rel="stylesheet"
href="{% static 'main/css/plot.css' %}"
type="text/css">
{% endblock %} {% endblock %}
{% block body %} {% block body %}
<section> <section>

View file

@ -13,9 +13,7 @@
{% endblock %} {% endblock %}
{% block link %} {% block link %}
{{ block.super }} {{ block.super }}
<link rel="stylesheet" {% css "main/css/table.css" %}
href="{% static 'main/css/table.css' %}"
type="text/css" />
{% endblock %} {% endblock %}
{% block body %} {% block body %}
<h2> <h2>

View file

@ -3,12 +3,8 @@
{% load i18n %} {% load i18n %}
{% block link %} {% block link %}
{{ block.super }} {{ block.super }}
<link rel="stylesheet" {% css "main/css/table.css" %}
href="{% static 'main/css/table.css' %}" {% css "main/css/form.css" %}
type="text/css" />
<link rel="stylesheet"
href="{% static 'main/css/form.css' %}"
type="text/css" />
{% endblock %} {% endblock %}
{% block body %} {% block body %}
<h2>{% translate "Log in" %}</h2> <h2>{% translate "Log in" %}</h2>

View file

@ -1,4 +1,5 @@
from django import template from django import template
from django.templatetags.static import static
from django.utils import formats from django.utils import formats
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
@ -59,3 +60,10 @@ def verbose_name(obj):
@register.filter @register.filter
def adding(obj): def adding(obj):
return obj._state.adding return obj._state.adding
@register.simple_tag
def css(href):
return mark_safe(
f"""<link rel="stylesheet" href="{static(href)}" type="text/css">"""
)

View file

@ -7,12 +7,8 @@
{% endblock %} {% endblock %}
{% block link %} {% block link %}
{{ block.super }} {{ block.super }}
<link rel="stylesheet" {% css "main/css/form.css" %}
href="{% static 'main/css/form.css' %}" {% css "main/css/table.css" %}
type="text/css" />
<link rel="stylesheet"
href="{% static 'main/css/table.css' %}"
type="text/css" />
{% endblock %} {% endblock %}
{% block body %} {% block body %}
<h2>{% translate "Search" %}</h2> <h2>{% translate "Search" %}</h2>

View file

@ -2,9 +2,7 @@
{% load i18n static category %} {% load i18n static category %}
{% block link %} {% block link %}
{{ block.super }} {{ block.super }}
<link rel="stylesheet" {% css "main/css/plot.css" %}
href="{% static 'main/css/plot.css' %}"
type="text/css" />
{% endblock %} {% endblock %}
{% block h2 %}{{ month|date:"F Y"|capfirst }}{% endblock %} {% block h2 %}{{ month|date:"F Y"|capfirst }}{% endblock %}
{% block table %} {% block table %}