Commits

psviderski committed 805f03d

Move blog templates to a separate 'blog' directory. Split 'blog_layout' into two parts, 'layout' and 'utils'.

Comments (0)

Files changed (12)

MoinMoin/items/blog.py

 
     class _ModifyForm(Default._ModifyForm):
         meta_form = BlogMetaForm
-        meta_template = 'modify_blog_meta.html'
+        meta_template = 'blog/modify_main_meta.html'
 
     def do_show(self, revid):
         """
         query = And(terms)
         revs = flaskg.storage.search(query, sortedby=[PTIME], reverse=True, limit=None)
         blog_entry_items = [Item.create(rev.meta[NAME], rev_id=rev.revid) for rev in revs]
-        return render_template('blog.html',
+        return render_template('blog/main.html',
                                item_name=self.name,
                                blog_item=self,
                                blog_entry_items=blog_entry_items,
 
     class _ModifyForm(Default._ModifyForm):
         meta_form = BlogEntryMetaForm
-        meta_template = 'modify_blog_entry_meta.html'
+        meta_template = 'blog/modify_entry_meta.html'
 
         @classmethod
         def from_item(cls, item):
         if not isinstance(blog_item, Blog):
             # The parent item of this blog entry item is not a Blog item.
             abort(403)
-        return render_template('blog_entry.html',
+        return render_template('blog/entry.html',
                                item_name=self.name,
                                blog_item=blog_item,
                                blog_entry_item=self,

MoinMoin/templates/blog.html

-{% extends theme("blog_layout.html") %}
-
-{% set no_entries_msg = _("There are no entries in this blog.") %}
-{% if tag %}
-    {% set no_entries_msg = _("There are no entries in the '%(tag)s' blog category.", tag=tag) %}
-{% endif %}
-
-{% block pagepath %}
-    {{ super() }}
-    {% if tag %}
-        <span class="sep">/</span>
-        {{ _("Category:") }}
-        {% if blog_name %}
-            <a href="{{ url_for('frontend.show_item', item_name=blog_name, tag=tag) }}">{{ tag }}</a>
-        {% else %}
-            {{ tag }}
-        {% endif %}
-    {% endif %}
-{% endblock %}
-
-{% block blog_content %}
-    {% if blog_entry_items %}
-        {% for entry_item in blog_entry_items %}
-            {{ show_blog_entry(entry_item) }}
-        {% endfor %}
-    {% else %}
-        {{ no_entries_msg }}
-    {% endif %}
-{% endblock %}

MoinMoin/templates/blog/entry.html

+{% extends theme("blog/layout.html") %}
+{% import theme("blog/utils.html") as blog_utils %}
+
+{% block blog_content %}
+    {% if blog_entry_item %}
+        {{ blog_utils.show_blog_entry(blog_entry_item) }}
+    {% endif %}
+{% endblock %}

MoinMoin/templates/blog/layout.html

+{% extends theme("layout.html") %}
+{% import theme("blog/utils.html") as blog_utils %}
+{% import "utils.html" as utils %}
+{% import "itemviews.html" as itemviews with context %}
+
+{% if blog_item %}
+    {% set blog_header = blog_item.content._render_data()|safe %}
+    {% set blog_name = blog_item.name %}
+    {% set supertags = blog_item.meta['supertags'] %}
+{% endif %}
+
+{% if blog_name %}
+    {% macro header_search(form) %}
+        {{ blog_utils.header_search(blog_name, form) }}
+    {% endmacro %}
+{% endif %}
+
+{% block theme_stylesheets %}
+    {{ super() }}
+    <link media="all" rel="stylesheet" href="{{ theme_static('css/blog.css') }}" />
+{% endblock %}
+
+{% block header_itemviews %}
+    {{ itemviews }}
+{% endblock %}
+
+{% block content %}
+    {% block content_data %}
+        <div id="moin-content-data">
+            <div id="moin-blog-header">
+                {% if blog_header %}
+                    {{ blog_header }}
+                {% endif %}
+            </div>
+            <div id="moin-blog-body">
+                <div id="moin-blog-content">
+                {% block blog_content %}<br />{% endblock %}
+                </div>
+                {% if blog_name and supertags %}
+                    <div id="moin-blog-sidebar">
+                        {{ blog_utils.widget_supertags(blog_name, supertags) }}
+                    </div>
+                {% endif %}
+            </div>
+        </div>
+    {% endblock %}
+{% endblock %}
+
+{% block footer_itemviews %}
+    {{ itemviews }}
+{% endblock %}

MoinMoin/templates/blog/main.html

+{% extends theme("blog/layout.html") %}
+{% import theme("blog/utils.html") as blog_utils %}
+
+{% set no_entries_msg = _("There are no entries in this blog.") %}
+{% if tag %}
+    {% set no_entries_msg = _("There are no entries in the '%(tag)s' blog category.", tag=tag) %}
+{% endif %}
+
+{% block pagepath %}
+    {{ super() }}
+    {% if tag %}
+        <span class="sep">/</span>
+        {{ _("Category:") }}
+        {% if blog_name %}
+            <a href="{{ url_for('frontend.show_item', item_name=blog_name, tag=tag) }}">{{ tag }}</a>
+        {% else %}
+            {{ tag }}
+        {% endif %}
+    {% endif %}
+{% endblock %}
+
+{% block blog_content %}
+    {% if blog_entry_items %}
+        {% for entry_item in blog_entry_items %}
+            {{ blog_utils.show_blog_entry(entry_item) }}
+        {% endfor %}
+    {% else %}
+        {{ no_entries_msg }}
+    {% endif %}
+{% endblock %}

MoinMoin/templates/blog/modify_entry_meta.html

+{% import "forms.html" as forms %}
+
+{% macro meta_editor(form) %}
+    <h2>Blog entry metadata</h2>
+    <dl>
+        {% for e in [
+            'itemtype',
+            'contenttype',
+            'summary',
+            'tags',
+            'ptime',
+            ] %}
+            {{ forms.render(form[e]) }}
+        {% endfor %}
+    </dl>
+{% endmacro %}

MoinMoin/templates/blog/modify_main_meta.html

+{% import "forms.html" as forms %}
+
+{% macro meta_editor(form) %}
+    <h2>Blog metadata</h2>
+    <dl>
+        {% for e in [
+            'itemtype',
+            'contenttype',
+            'summary',
+            'tags',
+            'supertags',
+            ] %}
+            {{ forms.render(form[e]) }}
+        {% endfor %}
+    </dl>
+{% endmacro %}

MoinMoin/templates/blog/utils.html

+{% import "forms.html" as forms %}
+{% import "utils.html" as utils %}
+
+{% macro show_blog_entry(entry_item) %}
+    {% if entry_item.meta['summary'] %}
+        {% set title = entry_item.meta['summary'] %}
+    {% else %}
+        {% set title = entry_item.name %}
+    {% endif %}
+    <h1><a href="{{ url_for('frontend.show_item', item_name=entry_item.name) }}"
+        title="{{ title }}" class="moin-blog-entry-link">{{ title }}</a></h1>
+    {% if user.may.write(entry_item.name) %}
+        <div class="moin-blog-entry-modify">
+            <span class="moin-blog-icon">&#x2710;</span>
+            <a href="{{ url_for('frontend.modify_item', item_name=entry_item.name) }}">{{ _("Modify entry") }}</a>
+        </div>
+    {% endif %}
+    <div class="moin-blog-entry-info">
+        {% set publish_time = entry_item.meta['ptime'] %}
+        {% if publish_time %}
+            {{ _("Published on") }} {{ entry_item.meta['ptime']|datetimeformat }}
+            {{ _("by") }} {{ utils.editor_info(entry_item.meta) }}
+        {% else %}
+            {{ _("Not published yet.") }}
+        {% endif %}
+    </div>
+    <div class="moin-blog-entry-content">
+        {{ entry_item.content._render_data()|safe }} {# rendered blog entry content #}
+    </div>
+    <div class="moin-blog-entry-bottominfo">
+        {% set tags = entry_item.meta['tags']|sort %}
+        {% if tags %} {# display blog entry's tags as a list if it is not empty #}
+            <div class="moin-blog-entry-tags">
+                {{ _("Tags:") }}
+                <ul class="moin-blog-entry-tags">
+                    {% for tag in tags %}
+                        <li><a href="{{ url_for('frontend.tagged_items', tag=tag) }}">{{ tag }}</a></li>
+                    {% endfor %}
+                </ul>
+            </div>
+        {% endif %}
+        <div class="moin-blog-entry-comments">
+            {% set discussion_item_name = '{0}/{1}'.format(entry_item.name, cfg.supplementation_item_names[0]) %}
+            <a href="{{ url_for('frontend.show_item', item_name=discussion_item_name) }}">{{ _("Discussion page") }}</a>
+        </div>
+    </div>
+{% endmacro %}
+
+{% macro widget_supertags(blog_name, supertags) %}
+    <div id="moin-blog-categories">
+        {{ _("Categories") }}
+        <ul>
+            {% for supertag in supertags %}
+                <li><a href="{{ url_for('frontend.show_item', item_name=blog_name, tag=supertag) }}">{{ supertag }}</a></li>
+            {% endfor %}
+        </ul>
+    </div>
+{% endmacro %}
+
+{% macro header_search(blog_name, form) %}
+    {{ gen.form.open(form, id='moin-searchform', method='get', action=url_for('frontend.search')) }}
+        <div>
+            {{ forms.render(form['q']) }}
+            {{ gen.button(form['submit'], type='submit', id='moin-search-submit') }}
+            {{ forms.render_errors(form) }}
+            <br />
+            <input type="checkbox" id="moin-blog-search-this"
+            onclick="$('#moin-searchform').attr('action', this.checked ? '{{ url_for('frontend.search', item_name=blog_name) }}' : '{{ url_for('frontend.search') }}' );" />
+            {{ _("only this blog") }}
+        </div>
+    {{ gen.form.close() }}
+{% endmacro %}

MoinMoin/templates/blog_entry.html

-{% extends theme("blog_layout.html") %}
-
-{% block blog_content %}
-    {% if blog_entry_item %}
-        {{ show_blog_entry(blog_entry_item) }}
-    {% endif %}
-{% endblock %}

MoinMoin/templates/blog_layout.html

-{% extends theme("layout.html") %}
-{% import "forms.html" as forms %}
-{% import "utils.html" as utils %}
-{% import "itemviews.html" as itemviews with context %}
-
-{% macro show_blog_entry(entry_item) %}
-    {% if entry_item.meta['summary'] %}
-        {% set title = entry_item.meta['summary'] %}
-    {% else %}
-        {% set title = entry_item.name %}
-    {% endif %}
-    <h1><a href="{{ url_for('frontend.show_item', item_name=entry_item.name) }}"
-        title="{{ title }}" class="moin-blog-entry-link">{{ title }}</a></h1>
-    {% if user.may.write(entry_item.name) %}
-        <div class="moin-blog-entry-modify">
-            <span class="moin-blog-icon">&#x2710;</span>
-            <a href="{{ url_for('frontend.modify_item', item_name=entry_item.name) }}">{{ _("Modify entry") }}</a>
-        </div>
-    {% endif %}
-    <div class="moin-blog-entry-info">
-        {% set publish_time = entry_item.meta['ptime'] %}
-        {% if publish_time %}
-            {{ _("Published on") }} {{ entry_item.meta['ptime']|datetimeformat }}
-            {{ _("by") }} {{ utils.editor_info(entry_item.meta) }}
-        {% else %}
-            {{ _("Not published yet.") }}
-        {% endif %}
-    </div>
-    <div class="moin-blog-entry-content">
-        {{ entry_item.content._render_data()|safe }} {# rendered blog entry content #}
-    </div>
-    <div class="moin-blog-entry-bottominfo">
-        {% set tags = entry_item.meta['tags']|sort %}
-        {% if tags %} {# display blog entry's tags as a list if it is not empty #}
-            <div class="moin-blog-entry-tags">
-                {{ _("Tags:") }}
-                <ul class="moin-blog-entry-tags">
-                    {% for tag in tags %}
-                        <li><a href="{{ url_for('frontend.tagged_items', tag=tag) }}">{{ tag }}</a></li>
-                    {% endfor %}
-                </ul>
-            </div>
-        {% endif %}
-        <div class="moin-blog-entry-comments">
-            {% set discussion_item_name = '{0}/{1}'.format(entry_item.name, cfg.supplementation_item_names[0]) %}
-            <a href="{{ url_for('frontend.show_item', item_name=discussion_item_name) }}">{{ _("Discussion page") }}</a>
-        </div>
-    </div>
-{% endmacro %}
-
-{% macro widget_supertags(blog_name, supertags) %}
-    <div id="moin-blog-categories">
-        <h2>{{ _("Categories") }}</h2>
-        <ul>
-            {% for supertag in supertags %}
-                <li><a href="{{ url_for('frontend.show_item', item_name=blog_name, tag=supertag) }}">{{ supertag }}</a></li>
-            {% endfor %}
-        </ul>
-    </div>
-{% endmacro %}
-
-{% if blog_item %}
-    {% set blog_header = blog_item.content._render_data()|safe %}
-    {% set blog_name = blog_item.name %}
-    {% set supertags = blog_item.meta['supertags'] %}
-{% endif %}
-
-{% if blog_name %}
-    {% macro header_search(form) %}
-        {{ gen.form.open(form, id='moin-searchform', method='get', action=url_for('frontend.search')) }}
-            <div>
-                {{ forms.render(form['q']) }}
-                {{ gen.button(form['submit'], type='submit', id='moin-search-submit') }}
-                {{ forms.render_errors(form) }}
-                <br />
-                <input type="checkbox" id="moin-blog-search-this"
-                onclick="$('#moin-searchform').attr('action', this.checked ? '{{ url_for('frontend.search', item_name=blog_name) }}' : '{{ url_for('frontend.search') }}' );" />
-                {{ _("only this blog") }}
-            </div>
-        {{ gen.form.close() }}
-    {% endmacro %}
-{% endif %}
-
-{% block theme_stylesheets %}
-    {{ super() }}
-    <link media="all" rel="stylesheet" href="{{ theme_static('css/blog.css') }}" />
-{% endblock %}
-
-{% block header_itemviews %}
-    {{ itemviews }}
-{% endblock %}
-
-{% block content %}
-    {% block content_data %}
-        <div id="moin-content-data">
-            <div id="moin-blog-header">
-                {% if blog_header %}
-                    {{ blog_header }}
-                {% endif %}
-            </div>
-            <div id="moin-blog-body">
-                <div id="moin-blog-content">
-                {% block blog_content %}<br />{% endblock %}
-                </div>
-                {% if blog_name and supertags %}
-                    <div id="moin-blog-sidebar">
-                        {{ widget_supertags(blog_name, supertags) }}
-                    </div>
-                {% endif %}
-            </div>
-        </div>
-    {% endblock %}
-{% endblock %}
-
-{% block footer_itemviews %}
-    {{ itemviews }}
-{% endblock %}

MoinMoin/templates/modify_blog_entry_meta.html

-{% import "forms.html" as forms %}
-
-{% macro meta_editor(form) %}
-    <h2>Blog entry metadata</h2>
-    <dl>
-        {% for e in [
-            'itemtype',
-            'contenttype',
-            'summary',
-            'tags',
-            'ptime',
-            ] %}
-            {{ forms.render(form[e]) }}
-        {% endfor %}
-    </dl>
-{% endmacro %}

MoinMoin/templates/modify_blog_meta.html

-{% import "forms.html" as forms %}
-
-{% macro meta_editor(form) %}
-    <h2>Blog metadata</h2>
-    <dl>
-        {% for e in [
-            'itemtype',
-            'contenttype',
-            'summary',
-            'tags',
-            'supertags',
-            ] %}
-            {{ forms.render(form[e]) }}
-        {% endfor %}
-    </dl>
-{% endmacro %}