Skip to content

Commit

Permalink
Minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
syeopite committed Dec 19, 2023
1 parent e3a9817 commit 3ccb83c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
6 changes: 5 additions & 1 deletion src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ def create_image_client(url, timeout):

app.ext.environment.globals["translate"] = helpers.translate
app.ext.environment.globals["url_handler"] = helpers.url_handler
app.ext.environment.globals["format_npf"] = format_npf
app.ext.environment.globals["format_npf"] = functools.partial(
format_npf,
url_handler=helpers.url_handler,
skip_cropped_images=True
)

# Initialize locales
gettext_instances = {"en": gettext.translation("priviblur", localedir="locales", languages=["en"])}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/components/blog_header.jinja
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% if blog.blog_info.description_npf -%}
{% set contains_errors, content_tag = format_npf(blog.blog_info.description_npf, url_handler=url_handler, skip_cropped_images=True) -%}
{% set contains_errors, content_tag = format_npf(blog.blog_info.description_npf) -%}
{% else -%}
{% set content_tag = "" %}
{% endif -%}
Expand Down
19 changes: 7 additions & 12 deletions src/templates/components/post.jinja
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
{% from 'macros/post_header.jinja' import create_post_header %}
<div class="post">
{%- if element.content -%}
{% set contains_errors, content_tag = format_npf(element.content, element.layout, url_handler=url_handler, skip_cropped_images=True) -%}
{% set contains_errors, content_tag = format_npf(element.content, element.layout) -%}
{%- endif -%}

{{ create_post_header(element) }}
{%- if element.trail -%}
{# Start post trails div #}
<div class="post-trails">
{%- endif -%}

{%- if element.trail -%}
{%- set current_element = element -%}

{%- for element in element.trail -%}
{%- for trail_element in element.trail -%}
<div class="trail-post">
{{create_post_header(element)}}
{% set trail_contains_errors, trail_content_tag = format_npf(element.content, element.layout, url_handler=url_handler, skip_cropped_images=True) -%}
{{create_post_header(trail_element)}}
{% set trail_contains_errors, trail_content_tag = format_npf(trail_element.content, trail_element.layout) -%}
{{- trail_content_tag -}}
</div>

{%- endfor -%}

{%- set element = current_element -%}
{%- endif -%}

{# If the post contains content in addition the the trail then it is the author replying #}
{# If the post contains content in addition to the trail then it is the reblogger replying #}
{%- if element.trail and element.content -%}
<div class="trail-post">
{{create_post_header(element, skip_reblog=True)}}
{% set trail_contains_errors, trail_content_tag = format_npf(element.content, element.layout, url_handler=url_handler, skip_cropped_images=True) -%}
{{- content_tag -}}
</div>
{%- else -%}
{{- content_tag -}}
{%- endif -%}

{%- if element.trail -%}
{# End post-trails div #}
</div>
{%- endif -%}

Expand Down Expand Up @@ -71,7 +67,6 @@
<path fill="#d1d1d1" d="M309.8 480.3c-13.6 14.5-50 31.7-97.4 31.7-120.8 0-147-88.8-147-140.6v-144H17.9c-5.5 0-10-4.5-10-10v-68c0-7.2 4.5-13.6 11.3-16 62-21.8 81.5-76 84.3-117.1.8-11 6.5-16.3 16.1-16.3h70.9c5.5 0 10 4.5 10 10v115.2h83c5.5 0 10 4.4 10 9.9v81.7c0 5.5-4.5 10-10 10h-83.4V360c0 34.2 23.7 53.6 68 35.8 4.8-1.9 9-3.2 12.7-2.2 3.5.9 5.8 3.4 7.4 7.9l22 64.3c1.8 5 3.3 10.6-.4 14.5z"/>
</svg>
</a>

</div>
</div>
</footer>
Expand Down

0 comments on commit 3ccb83c

Please sign in to comment.