# HG changeset patch # User cavaliet # Date 1362079139 -3600 # Node ID 2a51570e986b09768c53f3e6cc09af827426dc6a # Parent 67d3fb0e54a68106f778ad005ff536f3e9c0371a Efficiant template code factorization. diff -r 67d3fb0e54a6 -r 2a51570e986b src/egonomy/templates/egonomy_all_fragments.html --- a/src/egonomy/templates/egonomy_all_fragments.html Thu Feb 28 17:56:27 2013 +0100 +++ b/src/egonomy/templates/egonomy_all_fragments.html Thu Feb 28 20:18:59 2013 +0100 @@ -29,29 +29,9 @@
- {% with frgmt=frg.object|default:frg %}{# frg.object in search case, frg otherwise #} - {% with image=frgmt.image.info.image_file %} - {% if image %} - - - - - - - - - - {% else %} - - - - - - - - - - {% endif %} + {% with fragment=frg.object|default:frg %}{# frg.object in search case, frg otherwise #} + {% with image=fragment.image.info.image_file %} + {% include "partial/fragment_only.html" %} {% endwith %} {% endwith %}
diff -r 67d3fb0e54a6 -r 2a51570e986b src/egonomy/templates/egonomy_annotate_picture.html --- a/src/egonomy/templates/egonomy_annotate_picture.html Thu Feb 28 17:56:27 2013 +0100 +++ b/src/egonomy/templates/egonomy_annotate_picture.html Thu Feb 28 20:18:59 2013 +0100 @@ -90,37 +90,16 @@

{% trans "Fragments from this picture" %}

diff -r 67d3fb0e54a6 -r 2a51570e986b src/egonomy/templates/egonomy_create_fragment.html --- a/src/egonomy/templates/egonomy_create_fragment.html Thu Feb 28 17:56:27 2013 +0100 +++ b/src/egonomy/templates/egonomy_create_fragment.html Thu Feb 28 20:18:59 2013 +0100 @@ -149,39 +149,18 @@
-

{% trans 'Fragments from this picture' %}

+

{% trans "Fragments from this picture" %}

diff -r 67d3fb0e54a6 -r 2a51570e986b src/egonomy/templates/egonomy_home.html --- a/src/egonomy/templates/egonomy_home.html Thu Feb 28 17:56:27 2013 +0100 +++ b/src/egonomy/templates/egonomy_home.html Thu Feb 28 20:18:59 2013 +0100 @@ -47,38 +47,19 @@

{% trans "Last created fragments" %} {% trans "All fragments" %}

diff -r 67d3fb0e54a6 -r 2a51570e986b src/egonomy/templates/egonomy_view_fragment.html --- a/src/egonomy/templates/egonomy_view_fragment.html Thu Feb 28 17:56:27 2013 +0100 +++ b/src/egonomy/templates/egonomy_view_fragment.html Thu Feb 28 20:18:59 2013 +0100 @@ -14,80 +14,18 @@ {% if fragment_only %}
{% with fragment.image.info.image_file as image %} - {% if image %} - - - - - - - - - - {% else %} - - - - - - - - - - {% endif %} + {% include "partial/fragment_only.html" %} {% endwith %}
{% else %}
- {% with fragment.image.info.image_file as image %} - {% if image|ratio > 0.8 %} - {% thumbnail image "476" format="PNG" crop="center" as im %} - - - - - - - - - - {% empty %} - - - - - - - - - - {% endthumbnail %} - {% else %} - {% thumbnail image "x600" format="PNG" crop="center" as im %} - - - - - - - - - {% empty %} - - - - - - - - - - {% endthumbnail %} - {% endif %} - {% endwith %} - + {% with 0.8 as ratio %} + {% with "476" as w_size %} + {% with "x600" as h_size %} + {% include "partial/picture_and_fragment.html" %} + {% endwith %} + {% endwith %} + {% endwith %}
{% endif %}
@@ -127,55 +65,13 @@ {% trans "See the fragment in its full picture" %} :
- {% with fragment.image.info.image_file as image %} - {% if image|is_portrait %} - {% thumbnail image "110" format="PNG" crop="center" as im %} - - - - - - - - - - {% empty %} - - - - - - - - - - {% endthumbnail %} - {% else %} - {% thumbnail image "x110" format="PNG" crop="center" as im %} - - - - - - - - - {% empty %} - - - - - - - - - - {% endthumbnail %} - {% endif %} + {% with 1 as ratio %} + {% with "110" as w_size %} + {% with "x110" as h_size %} + {% include "partial/picture_and_fragment.html" %} {% endwith %} - + {% endwith %} + {% endwith %}
{% else %} @@ -183,27 +79,7 @@ {% trans "See the fragment only" %} :
{% with image=fragment.image.info.image_file %} - {% if image %} - - - - - - - - - - {% else %} - - - - - - - - - - {% endif %} + {% include "partial/fragment_only.html" %} {% endwith %}
@@ -215,37 +91,16 @@

{% trans "Fragments from this picture" %}

diff -r 67d3fb0e54a6 -r 2a51570e986b src/egonomy/templates/partial/fragment_only.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/egonomy/templates/partial/fragment_only.html Thu Feb 28 20:18:59 2013 +0100 @@ -0,0 +1,22 @@ +{% load static %} +{% if image %} + + + + + + + + + +{% else %} + + + + + + + + + +{% endif %} \ No newline at end of file diff -r 67d3fb0e54a6 -r 2a51570e986b src/egonomy/templates/partial/picture_and_fragment.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/egonomy/templates/partial/picture_and_fragment.html Thu Feb 28 20:18:59 2013 +0100 @@ -0,0 +1,52 @@ +{% load static %} +{% load thumbnail %} +{% load egonomy_thumbnail %} +{% with fragment.image.info.image_file as image %} +{% if image|ratio > ratio %} + {% thumbnail image w_size format="PNG" crop="center" as im %} + + + + + + + + + + {% empty %} + + + + + + + + + + {% endthumbnail %} +{% else %} + {% thumbnail image h_size format="PNG" crop="center" as im %} + + + + + + + + + {% empty %} + + + + + + + + + + {% endthumbnail %} +{% endif %} +{% endwith %} + \ No newline at end of file diff -r 67d3fb0e54a6 -r 2a51570e986b src/egonomy/templates/partial/picture_and_red_fragment.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/egonomy/templates/partial/picture_and_red_fragment.html Thu Feb 28 20:18:59 2013 +0100 @@ -0,0 +1,24 @@ +{% load static %} +{% load thumbnail %} +{% if fragment.image %} + {% with fragment.image.info.image_file as image %} + {% if image|is_portrait %} + {% thumbnail image "x110" format="PNG" crop="center" as im %} + + {% empty %} + + {% endthumbnail %} + {% else %} + {% thumbnail image "110" format="PNG" crop="center" as im %} + + {% empty %} + + {% endthumbnail %} + {% endif %} + {% endwith %} +{% else %} + +{% endif %} + + + \ No newline at end of file