Browse Source

adding whitespace/new_lines control to manage.py & continuing definition of macros for templating

Axolotle 2 years ago
parent
commit
7e53310442
3 changed files with 42 additions and 30 deletions
  1. 26
    5
      app/templates/_macros.html
  2. 13
    25
      app/templates/main_pages/podcasts.html
  3. 3
    0
      manage.py

+ 26
- 5
app/templates/_macros.html View File

@@ -1,4 +1,5 @@
1 1
 # macro pagination_widget(pagination, endpoint)
2
+<div class="pagination">
2 3
 <ul class="pagination">
3 4
     <li{% if not pagination.has_prev %} class="disabled"{% endif %}>
4 5
         <a class="content-link" href="{% if pagination.has_prev %}{{ url_for(endpoint,
@@ -27,15 +28,30 @@
27 28
     </a>
28 29
     </li>
29 30
 </ul>
31
+</div>
32
+# endmacro
33
+
34
+# macro podcast_box(elem)
35
+<div class="flex">
36
+    <a class="picto content-link" href="{{ url_for('main.play', id=elem.id) }}">
37
+        {%- include 'svg/small_play.svg' -%}
38
+    </a>
39
+    <div class="bloc name">
40
+        <h3>{{ elem.name }}</h3>
41
+        # if elem.channel.name
42
+        <h3><a class="content-link" href="{{ url_for('main.channel', id=elem.channel.id) }}">{{ elem.channel.name|upper }}</a></h3>
43
+        # endif
44
+    </div>
45
+</div>
30 46
 # endmacro
31 47
 
32 48
 # macro link_list(group, route, word, cssClass)
33 49
 # if group|length > 0
34 50
 <p class="marg {% if cssClass %}{{ cssClass }}{% endif %}">{{ word }}
35 51
 # for elem in group
36
-<a class="content-link" href="{{ url_for(route, id=elem.id)
37
-    }}">{{ elem.name }}</a>
38
-{%- if not loop.last %}, {% endif %}
52
+    <a class="content-link" href="{{ url_for(route, id=elem.id)
53
+        }}">{{ elem.name }}</a>
54
+    {%- if not loop.last %}, {% endif %}
39 55
 # endfor
40 56
 </p>
41 57
 # endif
@@ -45,10 +61,15 @@
45 61
 # if desc
46 62
 <div class="marg2 decal">
47 63
 # if truncate_value
48
-{{ desc|safe|truncate(truncate_value, False) }}
64
+{{ desc|safe|truncate(truncate_value, False) -}}
49 65
 # else
50
-{{ desc.description|safe|truncate(100, False) }}
66
+{{ desc.description|safe|truncate(100, False) -}}
51 67
 # endif
52 68
 </div>
53 69
 # endif
54 70
 # endmacro
71
+
72
+# macro more_button(route, route_id)
73
+<p class="more"><a class="content-link" href="{{ url_for(route, id=route_id)
74
+    }}">more</a></p>
75
+# endmacro

+ 13
- 25
app/templates/main_pages/podcasts.html View File

@@ -1,33 +1,21 @@
1
-{% import "_macros.html" as macros %}
1
+{% import "_macros.html" as gen %}
2
+
2 3
 <section class="solo">
3 4
     <div class="title">
4 5
         {% include 'svg/title_podcasts.svg' %}
5 6
     </div>
7
+    # for elem in podcasts
8
+    <article class="widgetBis">
9
+        {{ gen.podcast_box(elem) }}
10
+        <span class="license">{{ elem.date|format_date }}</span>
11
+        {{ gen.link_list(elem.collectives, 'main.collective', 'Par', 'decal') -}}
6 12
 
7
-{% for elem in podcasts %}
8
-<article class="widgetBis">
9
-    <div class="flex">
10
-        <a class="picto content-link" href="{{ url_for('main.play', id=elem.id) }}">
11
-            {% include 'svg/small_play.svg' -%}
12
-        </a>
13
-        <div class="bloc name">
14
-            <h3> {{ elem.name }} </h3>
15
-            {% if elem.channel.name %}
16
-            <h3><a class="content-link" href="{{ url_for('main.channel', id=elem.channel.id) }}">{{ elem.channel.name|upper }}</a></h3>
17
-            {% endif %}
18
-        </div>
19
-    </div>
20
-    <span class="license">{{ elem.date|format_date }}</span>
21
-    {{ macros.link_list(elem.collectives, 'main.collective', 'Par', 'decal') -}}
22
-    {{ macros.link_list(elem.contributors, 'main.contributor', 'Avec', 'decal') }}
23
-    {{ macros.description(elem.description, 100) }}
24
-</article>
25
-<p class="more"><a class="content-link" href="{{ url_for('main.podcast', id=elem.id) }}">more</a></p>
26
-{% endfor %}
27
-
13
+        {{ gen.link_list(elem.contributors, 'main.contributor', 'Avec', 'decal') -}}
28 14
 
29
-<div class="pagination">
30
-{{ macros.pagination_widget(pagination, 'main.podcasts') }}
31
-</div>
15
+        {{ gen.description(elem.description, 100) -}}
16
+    </article>
17
+    {{ gen.more_button('main.podcast', elem.id) }}
18
+    # endfor
32 19
 
20
+{{ gen.pagination_widget(pagination, 'main.podcasts') }}
33 21
 </section>

+ 3
- 0
manage.py View File

@@ -11,6 +11,9 @@ alchemydumps = AlchemyDumps(app,db)
11 11
 
12 12
 # allow jinja statements to be wrote without '{% %}' syntax
13 13
 app.jinja_env.line_statement_prefix = '#'
14
+# remove some whitespaces and new lines
15
+app.jinja_env.trim_blocks = True
16
+app.jinja_env.lstrip_blocks = True
14 17
 
15 18
 def make_shell_context():
16 19
     return dict(app=app, db=db)

Loading…
Cancel
Save