Compare commits

...

3 Commits

Author SHA1 Message Date
a139594863 Fixin Partial and Set Tag 2021-04-06 19:15:22 +02:00
f2eb048f0b Small check is this partial is used within place 2021-04-06 19:14:58 +02:00
120e63808a Replace include with partial tag 2021-04-06 19:14:36 +02:00
6 changed files with 44 additions and 20 deletions

View File

@ -1,5 +1,6 @@
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
{% load lostplaces%}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
@ -87,7 +88,7 @@
</div> </div>
{% block footer %} {% block footer %}
{% include 'partials/nav/footer.html' %} {% partial 'nav/footer' %}
{% endblock footer %} {% endblock footer %}
</body> </body>

View File

@ -2,6 +2,7 @@
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
{% load lostplaces %}
{% block additional_head %} {% block additional_head %}
<link rel="stylesheet" href="{% static 'maps/ol.css' %}" type="text/css"> <link rel="stylesheet" href="{% static 'maps/ol.css' %}" type="text/css">
<script src="{% static 'maps/ol.js' %}"></script> <script src="{% static 'maps/ol.js' %}"></script>
@ -11,11 +12,13 @@
{% block maincontent %} {% block maincontent %}
{% include 'partials/welcome.html' %} {% partial 'welcome' %}
<article class="LP-TextSection"> <article class="LP-TextSection">
</article> </article>
{% partial 'osm_map' %}
{% include 'partials/osm_map.html' with config=mapping_config modifier='wide' %} {% set config mapping_config %}
{% set modifier 'wide' %}
{% endpartial %}
<div class="LP-PlaceGrid"> <div class="LP-PlaceGrid">
<h1 class="LP-Headline LP-Headline">{% translate 'Explore the latest places' %}</h1> <h1 class="LP-Headline LP-Headline">{% translate 'Explore the latest places' %}</h1>
<ul class="LP-PlaceGrid__Grid"> <ul class="LP-PlaceGrid__Grid">
@ -26,5 +29,4 @@
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>
{% endblock maincontent %} {% endblock maincontent %}

View File

@ -1,11 +1,12 @@
{% extends 'global.html'%} {% extends 'global.html'%}
{% load i18n %} {% load i18n %}
{% load lostplaces%}
# {% block title %}Start{% endblock %} # {% block title %}Start{% endblock %}
{% block maincontent %} {% block maincontent %}
{% include 'partials/welcome.html' %} {% partial 'welcome' %}
<article class="LP-TextSection"> <article class="LP-TextSection">
<p class="LP-Paragraph"> <p class="LP-Paragraph">
{% blocktranslate %}You can create, view and share your lost places with other members of this site. You can upload photos, place links to your web galleries and contribute your knowledge by tagging other places or commenting on them. You will find detailed information on where these locations are, how to get there and what to expect from them. This might even include detailed information on the surroundings or the history of a lost place.{% endblocktranslate %} {% blocktranslate %}You can create, view and share your lost places with other members of this site. You can upload photos, place links to your web galleries and contribute your knowledge by tagging other places or commenting on them. You will find detailed information on where these locations are, how to get there and what to expect from them. This might even include detailed information on the surroundings or the history of a lost place.{% endblocktranslate %}
@ -24,7 +25,9 @@
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link"> <a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
<article class="LP-PlaceTeaser"> <article class="LP-PlaceTeaser">
<div class="LP-PlaceTeaser__Image"> <div class="LP-PlaceTeaser__Image">
{% include 'partials/image.html' with source_url=place.placeimages.first.filename.thumbnail.url %} {% partial 'image' %}
{% source_url source_url=place.placeimages.first.filename.thumbnail.url %}
{% endpartial %}
</div> </div>
<div class="LP-PlaceTeaser__Meta"> <div class="LP-PlaceTeaser__Meta">
<div class="LP-PlaceTeaser__Info"> <div class="LP-PlaceTeaser__Info">

View File

@ -33,10 +33,12 @@
</div> </div>
</li> </li>
{% endfor %} {% endfor %}
{% if place %}
<li class="LP-ImageGrid__Item LP-ImageGrid__Item--add" title="Bild hinzufügen"> <li class="LP-ImageGrid__Item LP-ImageGrid__Item--add" title="Bild hinzufügen">
<a class="LP-Link" href="{% url 'place_image_create' place_id=place.id %}"> <a class="LP-Link" href="{% url 'place_image_create' place_id=place.id %}">
<img class="LP-Icon" src="{% static 'icons/plus.svg' %}" /> <img class="LP-Icon" src="{% static 'icons/plus.svg' %}" />
</a> </a>
</li> </li>
{% endif %}
</ul> </ul>
</div> </div>

View File

@ -5,7 +5,9 @@
{% if place.placeimages.all|length > 0 %} {% if place.placeimages.all|length > 0 %}
{% include 'partials/image.html' with source_url=place.placeimages.first.filename.thumbnail.url link_url=place.get_absolute_url%} {% include 'partials/image.html' with source_url=place.placeimages.first.filename.thumbnail.url link_url=place.get_absolute_url%}
{% else %} {% else %}
<a href="{{place.get_absolute_url}}">
<img class="LP-Image" src="{% static 'images/missing_image.png' %}" /> <img class="LP-Image" src="{% static 'images/missing_image.png' %}" />
</a>
{% endif %} {% endif %}
</div> </div>
</a> </a>

View File

@ -7,6 +7,7 @@ from django.http import request
register = template.Library() register = template.Library()
def remove_formatting(string): def remove_formatting(string):
if type(string) is str:
for to_strip in ["'", '"', ' ']: for to_strip in ["'", '"', ' ']:
string = string.strip(to_strip) string = string.strip(to_strip)
@ -50,11 +51,12 @@ class VariableNode(template.Node):
def render(self, context): def render(self, context):
if type(self.content) is not str: if type(self.content) is not str:
self.content = self.content.render(context) self.content = self.content.render(context)
try:
self.content = template.Variable(self.content).resolve(context)
except template.VariableDoesNotExist:
pass
self.content = remove_formatting(self.content) self.content = remove_formatting(self.content)
self.content = template.Variable(self.content).resolve(context)
context[self.name] = self.content context[self.name] = self.content
return '' return ''
@ -100,8 +102,20 @@ def partial(parser, token):
raise template.TemplateSyntaxError('%r expects a partial name' % split[0]) raise template.TemplateSyntaxError('%r expects a partial name' % split[0])
if len(split) == 2: if len(split) == 2:
block_tag = False
for token in reversed(parser.tokens):
if 'end%s'%split[0] in token.contents:
block_tag = True
break
if split[0] in token.contents:
break
if block_tag:
nodeList = parser.parse(('end%s'%split[0],)) nodeList = parser.parse(('end%s'%split[0],))
parser.delete_first_token() parser.delete_first_token()
else:
nodeList = template.NodeList()
return PartialNode(partial_name, nodeList) return PartialNode(partial_name, nodeList)
else: else:
nodeList = template.NodeList() nodeList = template.NodeList()