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

View File

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

View File

@ -1,11 +1,12 @@
{% extends 'global.html'%}
{% load i18n %}
{% load lostplaces%}
# {% block title %}Start{% endblock %}
{% block maincontent %}
{% include 'partials/welcome.html' %}
{% partial 'welcome' %}
<article class="LP-TextSection">
<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 %}
@ -24,7 +25,9 @@
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
<article class="LP-PlaceTeaser">
<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 class="LP-PlaceTeaser__Meta">
<div class="LP-PlaceTeaser__Info">

View File

@ -33,10 +33,12 @@
</div>
</li>
{% endfor %}
{% if place %}
<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 %}">
<img class="LP-Icon" src="{% static 'icons/plus.svg' %}" />
</a>
</li>
{% endif %}
</ul>
</div>

View File

@ -5,7 +5,9 @@
{% 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%}
{% else %}
<a href="{{place.get_absolute_url}}">
<img class="LP-Image" src="{% static 'images/missing_image.png' %}" />
</a>
{% endif %}
</div>
</a>

View File

@ -7,6 +7,7 @@ from django.http import request
register = template.Library()
def remove_formatting(string):
if type(string) is str:
for to_strip in ["'", '"', ' ']:
string = string.strip(to_strip)
@ -50,11 +51,12 @@ class VariableNode(template.Node):
def render(self, context):
if type(self.content) is not str:
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 = template.Variable(self.content).resolve(context)
context[self.name] = self.content
return ''
@ -100,8 +102,20 @@ def partial(parser, token):
raise template.TemplateSyntaxError('%r expects a partial name' % split[0])
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],))
parser.delete_first_token()
else:
nodeList = template.NodeList()
return PartialNode(partial_name, nodeList)
else:
nodeList = template.NodeList()