Move blog templates to a separate 'blog' directory. Split 'blog_layout' into two parts, 'layout' and 'utils'.
authorPavel Sviderski <pavel@psviderski.name>
Tue, 21 Aug 2012 22:42:59 +0200
changeset 1723805f03d03259
parent 1722 02c0e90cbb0b
child 1724 5068b69bfb0c
Move blog templates to a separate 'blog' directory. Split 'blog_layout' into two parts, 'layout' and 'utils'.
MoinMoin/items/blog.py
MoinMoin/templates/blog.html
MoinMoin/templates/blog/entry.html
MoinMoin/templates/blog/layout.html
MoinMoin/templates/blog/main.html
MoinMoin/templates/blog/modify_entry_meta.html
MoinMoin/templates/blog/modify_main_meta.html
MoinMoin/templates/blog/utils.html
MoinMoin/templates/blog_entry.html
MoinMoin/templates/blog_layout.html
MoinMoin/templates/modify_blog_entry_meta.html
MoinMoin/templates/modify_blog_meta.html
     1.1 --- a/MoinMoin/items/blog.py	Tue Aug 21 22:35:55 2012 +0200
     1.2 +++ b/MoinMoin/items/blog.py	Tue Aug 21 22:42:59 2012 +0200
     1.3 @@ -42,7 +42,7 @@
     1.4  
     1.5      class _ModifyForm(Default._ModifyForm):
     1.6          meta_form = BlogMetaForm
     1.7 -        meta_template = 'modify_blog_meta.html'
     1.8 +        meta_template = 'blog/modify_main_meta.html'
     1.9  
    1.10      def do_show(self, revid):
    1.11          """
    1.12 @@ -66,7 +66,7 @@
    1.13          query = And(terms)
    1.14          revs = flaskg.storage.search(query, sortedby=[PTIME], reverse=True, limit=None)
    1.15          blog_entry_items = [Item.create(rev.meta[NAME], rev_id=rev.revid) for rev in revs]
    1.16 -        return render_template('blog.html',
    1.17 +        return render_template('blog/main.html',
    1.18                                 item_name=self.name,
    1.19                                 blog_item=self,
    1.20                                 blog_entry_items=blog_entry_items,
    1.21 @@ -79,7 +79,7 @@
    1.22  
    1.23      class _ModifyForm(Default._ModifyForm):
    1.24          meta_form = BlogEntryMetaForm
    1.25 -        meta_template = 'modify_blog_entry_meta.html'
    1.26 +        meta_template = 'blog/modify_entry_meta.html'
    1.27  
    1.28          @classmethod
    1.29          def from_item(cls, item):
    1.30 @@ -98,7 +98,7 @@
    1.31          if not isinstance(blog_item, Blog):
    1.32              # The parent item of this blog entry item is not a Blog item.
    1.33              abort(403)
    1.34 -        return render_template('blog_entry.html',
    1.35 +        return render_template('blog/entry.html',
    1.36                                 item_name=self.name,
    1.37                                 blog_item=blog_item,
    1.38                                 blog_entry_item=self,
     2.1 --- a/MoinMoin/templates/blog.html	Tue Aug 21 22:35:55 2012 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,29 +0,0 @@
     2.4 -{% extends theme("blog_layout.html") %}
     2.5 -
     2.6 -{% set no_entries_msg = _("There are no entries in this blog.") %}
     2.7 -{% if tag %}
     2.8 -    {% set no_entries_msg = _("There are no entries in the '%(tag)s' blog category.", tag=tag) %}
     2.9 -{% endif %}
    2.10 -
    2.11 -{% block pagepath %}
    2.12 -    {{ super() }}
    2.13 -    {% if tag %}
    2.14 -        <span class="sep">/</span>
    2.15 -        {{ _("Category:") }}
    2.16 -        {% if blog_name %}
    2.17 -            <a href="{{ url_for('frontend.show_item', item_name=blog_name, tag=tag) }}">{{ tag }}</a>
    2.18 -        {% else %}
    2.19 -            {{ tag }}
    2.20 -        {% endif %}
    2.21 -    {% endif %}
    2.22 -{% endblock %}
    2.23 -
    2.24 -{% block blog_content %}
    2.25 -    {% if blog_entry_items %}
    2.26 -        {% for entry_item in blog_entry_items %}
    2.27 -            {{ show_blog_entry(entry_item) }}
    2.28 -        {% endfor %}
    2.29 -    {% else %}
    2.30 -        {{ no_entries_msg }}
    2.31 -    {% endif %}
    2.32 -{% endblock %}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/MoinMoin/templates/blog/entry.html	Tue Aug 21 22:42:59 2012 +0200
     3.3 @@ -0,0 +1,8 @@
     3.4 +{% extends theme("blog/layout.html") %}
     3.5 +{% import theme("blog/utils.html") as blog_utils %}
     3.6 +
     3.7 +{% block blog_content %}
     3.8 +    {% if blog_entry_item %}
     3.9 +        {{ blog_utils.show_blog_entry(blog_entry_item) }}
    3.10 +    {% endif %}
    3.11 +{% endblock %}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/MoinMoin/templates/blog/layout.html	Tue Aug 21 22:42:59 2012 +0200
     4.3 @@ -0,0 +1,51 @@
     4.4 +{% extends theme("layout.html") %}
     4.5 +{% import theme("blog/utils.html") as blog_utils %}
     4.6 +{% import "utils.html" as utils %}
     4.7 +{% import "itemviews.html" as itemviews with context %}
     4.8 +
     4.9 +{% if blog_item %}
    4.10 +    {% set blog_header = blog_item.content._render_data()|safe %}
    4.11 +    {% set blog_name = blog_item.name %}
    4.12 +    {% set supertags = blog_item.meta['supertags'] %}
    4.13 +{% endif %}
    4.14 +
    4.15 +{% if blog_name %}
    4.16 +    {% macro header_search(form) %}
    4.17 +        {{ blog_utils.header_search(blog_name, form) }}
    4.18 +    {% endmacro %}
    4.19 +{% endif %}
    4.20 +
    4.21 +{% block theme_stylesheets %}
    4.22 +    {{ super() }}
    4.23 +    <link media="all" rel="stylesheet" href="{{ theme_static('css/blog.css') }}" />
    4.24 +{% endblock %}
    4.25 +
    4.26 +{% block header_itemviews %}
    4.27 +    {{ itemviews }}
    4.28 +{% endblock %}
    4.29 +
    4.30 +{% block content %}
    4.31 +    {% block content_data %}
    4.32 +        <div id="moin-content-data">
    4.33 +            <div id="moin-blog-header">
    4.34 +                {% if blog_header %}
    4.35 +                    {{ blog_header }}
    4.36 +                {% endif %}
    4.37 +            </div>
    4.38 +            <div id="moin-blog-body">
    4.39 +                <div id="moin-blog-content">
    4.40 +                {% block blog_content %}<br />{% endblock %}
    4.41 +                </div>
    4.42 +                {% if blog_name and supertags %}
    4.43 +                    <div id="moin-blog-sidebar">
    4.44 +                        {{ blog_utils.widget_supertags(blog_name, supertags) }}
    4.45 +                    </div>
    4.46 +                {% endif %}
    4.47 +            </div>
    4.48 +        </div>
    4.49 +    {% endblock %}
    4.50 +{% endblock %}
    4.51 +
    4.52 +{% block footer_itemviews %}
    4.53 +    {{ itemviews }}
    4.54 +{% endblock %}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/MoinMoin/templates/blog/main.html	Tue Aug 21 22:42:59 2012 +0200
     5.3 @@ -0,0 +1,30 @@
     5.4 +{% extends theme("blog/layout.html") %}
     5.5 +{% import theme("blog/utils.html") as blog_utils %}
     5.6 +
     5.7 +{% set no_entries_msg = _("There are no entries in this blog.") %}
     5.8 +{% if tag %}
     5.9 +    {% set no_entries_msg = _("There are no entries in the '%(tag)s' blog category.", tag=tag) %}
    5.10 +{% endif %}
    5.11 +
    5.12 +{% block pagepath %}
    5.13 +    {{ super() }}
    5.14 +    {% if tag %}
    5.15 +        <span class="sep">/</span>
    5.16 +        {{ _("Category:") }}
    5.17 +        {% if blog_name %}
    5.18 +            <a href="{{ url_for('frontend.show_item', item_name=blog_name, tag=tag) }}">{{ tag }}</a>
    5.19 +        {% else %}
    5.20 +            {{ tag }}
    5.21 +        {% endif %}
    5.22 +    {% endif %}
    5.23 +{% endblock %}
    5.24 +
    5.25 +{% block blog_content %}
    5.26 +    {% if blog_entry_items %}
    5.27 +        {% for entry_item in blog_entry_items %}
    5.28 +            {{ blog_utils.show_blog_entry(entry_item) }}
    5.29 +        {% endfor %}
    5.30 +    {% else %}
    5.31 +        {{ no_entries_msg }}
    5.32 +    {% endif %}
    5.33 +{% endblock %}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/MoinMoin/templates/blog/modify_entry_meta.html	Tue Aug 21 22:42:59 2012 +0200
     6.3 @@ -0,0 +1,16 @@
     6.4 +{% import "forms.html" as forms %}
     6.5 +
     6.6 +{% macro meta_editor(form) %}
     6.7 +    <h2>Blog entry metadata</h2>
     6.8 +    <dl>
     6.9 +        {% for e in [
    6.10 +            'itemtype',
    6.11 +            'contenttype',
    6.12 +            'summary',
    6.13 +            'tags',
    6.14 +            'ptime',
    6.15 +            ] %}
    6.16 +            {{ forms.render(form[e]) }}
    6.17 +        {% endfor %}
    6.18 +    </dl>
    6.19 +{% endmacro %}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/MoinMoin/templates/blog/modify_main_meta.html	Tue Aug 21 22:42:59 2012 +0200
     7.3 @@ -0,0 +1,16 @@
     7.4 +{% import "forms.html" as forms %}
     7.5 +
     7.6 +{% macro meta_editor(form) %}
     7.7 +    <h2>Blog metadata</h2>
     7.8 +    <dl>
     7.9 +        {% for e in [
    7.10 +            'itemtype',
    7.11 +            'contenttype',
    7.12 +            'summary',
    7.13 +            'tags',
    7.14 +            'supertags',
    7.15 +            ] %}
    7.16 +            {{ forms.render(form[e]) }}
    7.17 +        {% endfor %}
    7.18 +    </dl>
    7.19 +{% endmacro %}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/MoinMoin/templates/blog/utils.html	Tue Aug 21 22:42:59 2012 +0200
     8.3 @@ -0,0 +1,72 @@
     8.4 +{% import "forms.html" as forms %}
     8.5 +{% import "utils.html" as utils %}
     8.6 +
     8.7 +{% macro show_blog_entry(entry_item) %}
     8.8 +    {% if entry_item.meta['summary'] %}
     8.9 +        {% set title = entry_item.meta['summary'] %}
    8.10 +    {% else %}
    8.11 +        {% set title = entry_item.name %}
    8.12 +    {% endif %}
    8.13 +    <h1><a href="{{ url_for('frontend.show_item', item_name=entry_item.name) }}"
    8.14 +        title="{{ title }}" class="moin-blog-entry-link">{{ title }}</a></h1>
    8.15 +    {% if user.may.write(entry_item.name) %}
    8.16 +        <div class="moin-blog-entry-modify">
    8.17 +            <span class="moin-blog-icon">&#x2710;</span>
    8.18 +            <a href="{{ url_for('frontend.modify_item', item_name=entry_item.name) }}">{{ _("Modify entry") }}</a>
    8.19 +        </div>
    8.20 +    {% endif %}
    8.21 +    <div class="moin-blog-entry-info">
    8.22 +        {% set publish_time = entry_item.meta['ptime'] %}
    8.23 +        {% if publish_time %}
    8.24 +            {{ _("Published on") }} {{ entry_item.meta['ptime']|datetimeformat }}
    8.25 +            {{ _("by") }} {{ utils.editor_info(entry_item.meta) }}
    8.26 +        {% else %}
    8.27 +            {{ _("Not published yet.") }}
    8.28 +        {% endif %}
    8.29 +    </div>
    8.30 +    <div class="moin-blog-entry-content">
    8.31 +        {{ entry_item.content._render_data()|safe }} {# rendered blog entry content #}
    8.32 +    </div>
    8.33 +    <div class="moin-blog-entry-bottominfo">
    8.34 +        {% set tags = entry_item.meta['tags']|sort %}
    8.35 +        {% if tags %} {# display blog entry's tags as a list if it is not empty #}
    8.36 +            <div class="moin-blog-entry-tags">
    8.37 +                {{ _("Tags:") }}
    8.38 +                <ul class="moin-blog-entry-tags">
    8.39 +                    {% for tag in tags %}
    8.40 +                        <li><a href="{{ url_for('frontend.tagged_items', tag=tag) }}">{{ tag }}</a></li>
    8.41 +                    {% endfor %}
    8.42 +                </ul>
    8.43 +            </div>
    8.44 +        {% endif %}
    8.45 +        <div class="moin-blog-entry-comments">
    8.46 +            {% set discussion_item_name = '{0}/{1}'.format(entry_item.name, cfg.supplementation_item_names[0]) %}
    8.47 +            <a href="{{ url_for('frontend.show_item', item_name=discussion_item_name) }}">{{ _("Discussion page") }}</a>
    8.48 +        </div>
    8.49 +    </div>
    8.50 +{% endmacro %}
    8.51 +
    8.52 +{% macro widget_supertags(blog_name, supertags) %}
    8.53 +    <div id="moin-blog-categories">
    8.54 +        {{ _("Categories") }}
    8.55 +        <ul>
    8.56 +            {% for supertag in supertags %}
    8.57 +                <li><a href="{{ url_for('frontend.show_item', item_name=blog_name, tag=supertag) }}">{{ supertag }}</a></li>
    8.58 +            {% endfor %}
    8.59 +        </ul>
    8.60 +    </div>
    8.61 +{% endmacro %}
    8.62 +
    8.63 +{% macro header_search(blog_name, form) %}
    8.64 +    {{ gen.form.open(form, id='moin-searchform', method='get', action=url_for('frontend.search')) }}
    8.65 +        <div>
    8.66 +            {{ forms.render(form['q']) }}
    8.67 +            {{ gen.button(form['submit'], type='submit', id='moin-search-submit') }}
    8.68 +            {{ forms.render_errors(form) }}
    8.69 +            <br />
    8.70 +            <input type="checkbox" id="moin-blog-search-this"
    8.71 +            onclick="$('#moin-searchform').attr('action', this.checked ? '{{ url_for('frontend.search', item_name=blog_name) }}' : '{{ url_for('frontend.search') }}' );" />
    8.72 +            {{ _("only this blog") }}
    8.73 +        </div>
    8.74 +    {{ gen.form.close() }}
    8.75 +{% endmacro %}
     9.1 --- a/MoinMoin/templates/blog_entry.html	Tue Aug 21 22:35:55 2012 +0200
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,7 +0,0 @@
     9.4 -{% extends theme("blog_layout.html") %}
     9.5 -
     9.6 -{% block blog_content %}
     9.7 -    {% if blog_entry_item %}
     9.8 -        {{ show_blog_entry(blog_entry_item) }}
     9.9 -    {% endif %}
    9.10 -{% endblock %}
    10.1 --- a/MoinMoin/templates/blog_layout.html	Tue Aug 21 22:35:55 2012 +0200
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,117 +0,0 @@
    10.4 -{% extends theme("layout.html") %}
    10.5 -{% import "forms.html" as forms %}
    10.6 -{% import "utils.html" as utils %}
    10.7 -{% import "itemviews.html" as itemviews with context %}
    10.8 -
    10.9 -{% macro show_blog_entry(entry_item) %}
   10.10 -    {% if entry_item.meta['summary'] %}
   10.11 -        {% set title = entry_item.meta['summary'] %}
   10.12 -    {% else %}
   10.13 -        {% set title = entry_item.name %}
   10.14 -    {% endif %}
   10.15 -    <h1><a href="{{ url_for('frontend.show_item', item_name=entry_item.name) }}"
   10.16 -        title="{{ title }}" class="moin-blog-entry-link">{{ title }}</a></h1>
   10.17 -    {% if user.may.write(entry_item.name) %}
   10.18 -        <div class="moin-blog-entry-modify">
   10.19 -            <span class="moin-blog-icon">&#x2710;</span>
   10.20 -            <a href="{{ url_for('frontend.modify_item', item_name=entry_item.name) }}">{{ _("Modify entry") }}</a>
   10.21 -        </div>
   10.22 -    {% endif %}
   10.23 -    <div class="moin-blog-entry-info">
   10.24 -        {% set publish_time = entry_item.meta['ptime'] %}
   10.25 -        {% if publish_time %}
   10.26 -            {{ _("Published on") }} {{ entry_item.meta['ptime']|datetimeformat }}
   10.27 -            {{ _("by") }} {{ utils.editor_info(entry_item.meta) }}
   10.28 -        {% else %}
   10.29 -            {{ _("Not published yet.") }}
   10.30 -        {% endif %}
   10.31 -    </div>
   10.32 -    <div class="moin-blog-entry-content">
   10.33 -        {{ entry_item.content._render_data()|safe }} {# rendered blog entry content #}
   10.34 -    </div>
   10.35 -    <div class="moin-blog-entry-bottominfo">
   10.36 -        {% set tags = entry_item.meta['tags']|sort %}
   10.37 -        {% if tags %} {# display blog entry's tags as a list if it is not empty #}
   10.38 -            <div class="moin-blog-entry-tags">
   10.39 -                {{ _("Tags:") }}
   10.40 -                <ul class="moin-blog-entry-tags">
   10.41 -                    {% for tag in tags %}
   10.42 -                        <li><a href="{{ url_for('frontend.tagged_items', tag=tag) }}">{{ tag }}</a></li>
   10.43 -                    {% endfor %}
   10.44 -                </ul>
   10.45 -            </div>
   10.46 -        {% endif %}
   10.47 -        <div class="moin-blog-entry-comments">
   10.48 -            {% set discussion_item_name = '{0}/{1}'.format(entry_item.name, cfg.supplementation_item_names[0]) %}
   10.49 -            <a href="{{ url_for('frontend.show_item', item_name=discussion_item_name) }}">{{ _("Discussion page") }}</a>
   10.50 -        </div>
   10.51 -    </div>
   10.52 -{% endmacro %}
   10.53 -
   10.54 -{% macro widget_supertags(blog_name, supertags) %}
   10.55 -    <div id="moin-blog-categories">
   10.56 -        <h2>{{ _("Categories") }}</h2>
   10.57 -        <ul>
   10.58 -            {% for supertag in supertags %}
   10.59 -                <li><a href="{{ url_for('frontend.show_item', item_name=blog_name, tag=supertag) }}">{{ supertag }}</a></li>
   10.60 -            {% endfor %}
   10.61 -        </ul>
   10.62 -    </div>
   10.63 -{% endmacro %}
   10.64 -
   10.65 -{% if blog_item %}
   10.66 -    {% set blog_header = blog_item.content._render_data()|safe %}
   10.67 -    {% set blog_name = blog_item.name %}
   10.68 -    {% set supertags = blog_item.meta['supertags'] %}
   10.69 -{% endif %}
   10.70 -
   10.71 -{% if blog_name %}
   10.72 -    {% macro header_search(form) %}
   10.73 -        {{ gen.form.open(form, id='moin-searchform', method='get', action=url_for('frontend.search')) }}
   10.74 -            <div>
   10.75 -                {{ forms.render(form['q']) }}
   10.76 -                {{ gen.button(form['submit'], type='submit', id='moin-search-submit') }}
   10.77 -                {{ forms.render_errors(form) }}
   10.78 -                <br />
   10.79 -                <input type="checkbox" id="moin-blog-search-this"
   10.80 -                onclick="$('#moin-searchform').attr('action', this.checked ? '{{ url_for('frontend.search', item_name=blog_name) }}' : '{{ url_for('frontend.search') }}' );" />
   10.81 -                {{ _("only this blog") }}
   10.82 -            </div>
   10.83 -        {{ gen.form.close() }}
   10.84 -    {% endmacro %}
   10.85 -{% endif %}
   10.86 -
   10.87 -{% block theme_stylesheets %}
   10.88 -    {{ super() }}
   10.89 -    <link media="all" rel="stylesheet" href="{{ theme_static('css/blog.css') }}" />
   10.90 -{% endblock %}
   10.91 -
   10.92 -{% block header_itemviews %}
   10.93 -    {{ itemviews }}
   10.94 -{% endblock %}
   10.95 -
   10.96 -{% block content %}
   10.97 -    {% block content_data %}
   10.98 -        <div id="moin-content-data">
   10.99 -            <div id="moin-blog-header">
  10.100 -                {% if blog_header %}
  10.101 -                    {{ blog_header }}
  10.102 -                {% endif %}
  10.103 -            </div>
  10.104 -            <div id="moin-blog-body">
  10.105 -                <div id="moin-blog-content">
  10.106 -                {% block blog_content %}<br />{% endblock %}
  10.107 -                </div>
  10.108 -                {% if blog_name and supertags %}
  10.109 -                    <div id="moin-blog-sidebar">
  10.110 -                        {{ widget_supertags(blog_name, supertags) }}
  10.111 -                    </div>
  10.112 -                {% endif %}
  10.113 -            </div>
  10.114 -        </div>
  10.115 -    {% endblock %}
  10.116 -{% endblock %}
  10.117 -
  10.118 -{% block footer_itemviews %}
  10.119 -    {{ itemviews }}
  10.120 -{% endblock %}
    11.1 --- a/MoinMoin/templates/modify_blog_entry_meta.html	Tue Aug 21 22:35:55 2012 +0200
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,16 +0,0 @@
    11.4 -{% import "forms.html" as forms %}
    11.5 -
    11.6 -{% macro meta_editor(form) %}
    11.7 -    <h2>Blog entry metadata</h2>
    11.8 -    <dl>
    11.9 -        {% for e in [
   11.10 -            'itemtype',
   11.11 -            'contenttype',
   11.12 -            'summary',
   11.13 -            'tags',
   11.14 -            'ptime',
   11.15 -            ] %}
   11.16 -            {{ forms.render(form[e]) }}
   11.17 -        {% endfor %}
   11.18 -    </dl>
   11.19 -{% endmacro %}
    12.1 --- a/MoinMoin/templates/modify_blog_meta.html	Tue Aug 21 22:35:55 2012 +0200
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,16 +0,0 @@
    12.4 -{% import "forms.html" as forms %}
    12.5 -
    12.6 -{% macro meta_editor(form) %}
    12.7 -    <h2>Blog metadata</h2>
    12.8 -    <dl>
    12.9 -        {% for e in [
   12.10 -            'itemtype',
   12.11 -            'contenttype',
   12.12 -            'summary',
   12.13 -            'tags',
   12.14 -            'supertags',
   12.15 -            ] %}
   12.16 -            {{ forms.render(form[e]) }}
   12.17 -        {% endfor %}
   12.18 -    </dl>
   12.19 -{% endmacro %}