[IMP] Blogs better views hierarchies
authorFabien Pinckaers <fp@tinyerp.com>
Fri, 15 Nov 2013 08:56:32 +0000 (09:56 +0100)
committerFabien Pinckaers <fp@tinyerp.com>
Fri, 15 Nov 2013 08:56:32 +0000 (09:56 +0100)
bzr revid: fp@tinyerp.com-20131115085632-aj2cqpwp712599jx

addons/website_blog/controllers/main.py
addons/website_blog/static/src/css/website_blog.css
addons/website_blog/static/src/css/website_blog.sass
addons/website_blog/views/website_blog_templates.xml

index 6334481..c95787d 100644 (file)
@@ -74,10 +74,10 @@ class WebsiteBlog(http.Controller):
         """
         cr, uid, context = request.cr, request.uid, request.context
         blog_post_obj = request.registry['blog.post']
-        category_obj = request.registry['blog.category']
 
         blog_posts = None
 
+        category_obj = request.registry['blog.category']
         category_ids = category_obj.search(cr, uid, [], context=context)
         categories = category_obj.browse(cr, uid, category_ids, context=context)
 
@@ -117,7 +117,7 @@ class WebsiteBlog(http.Controller):
         elif category:
             values['main_object'] = category
 
-        return request.website.render("website_blog.index", values)
+        return request.website.render("website_blog.blog_post_short", values)
 
     @website.route([
         '/blog/<model("blog.post"):blog_post>/',
@@ -154,15 +154,20 @@ class WebsiteBlog(http.Controller):
         pager_end = page * self._post_comment_per_page
         blog_post.website_message_ids = blog_post.website_message_ids[pager_begin:pager_end]
 
+        cr, uid, context = request.cr, request.uid, request.context
+        category_obj = request.registry['blog.category']
+        category_ids = category_obj.search(cr, uid, [], context=context)
+        categories = category_obj.browse(cr, uid, category_ids, context=context)
+
         values = {
             'category': blog_post.category_id,
+            'categories': categories,
             'blog_post': blog_post,
             'pager': pager,
             'nav_list': self.nav_list(),
             'enable_editor': enable_editor,
         }
-
-        return request.website.render("website_blog.index", values)
+        return request.website.render("website_blog.blog_post_complete", values)
 
     # TODO: Refactor (used in website_blog.js for archive links)
     # => the archive links should be generated server side
index 171f13c..96045ad 100644 (file)
@@ -1,4 +1,5 @@
-@charset "UTF-8";
+@charset "utf-8";
+@import url(compass/css3.css);
 .css_website_mail .has-error {
   border-color: red;
 }
@@ -20,16 +21,3 @@ p.post-meta {
   position: relative;
   top: -5px;
 }
-
-.js_website_blog div#right_column section {
-  filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=60);
-  opacity: 0.6;
-}
-.js_website_blog div#right_column section:hover {
-  filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
-  opacity: 1;
-  -webkit-transition: all 0.2s ease-out;
-  -moz-transition: all 0.2s ease-out;
-  -o-transition: all 0.2s ease-out;
-  transition: all 0.2s ease-out;
-}
index d467df2..4691dde 100644 (file)
@@ -20,10 +20,3 @@ p.post-meta
     position: relative
     top: -5px
 
-.js_website_blog
-    div#right_column
-        section
-            +opacity(0.6)
-        section:hover
-            +opacity(1)
-            @include transition(all 0.2s ease-out)
index 1c26386..86669ea 100644 (file)
 
     <!-- Blog Post Summary -->
     <template id="blog_post_short" name="Blog Post Summary">
-        <div>
-            <div class="pull-right">
-                <t t-call="website.publish_management">
-                    <t t-set="object" t-value="blog_post"/>
-                    <t t-set="publish_edit" t-value="True"/>
-                    <li>
-                        <a href="#" t-attf-data-href="/blog/#{blog_post.id}/duplicate">Duplicate</a>
-                        <script>
-                            var $a=$("[data-href$='/duplicate']");
-                            $a.attr("href", $a.data('href')).removeAttr('data-href');
-                            $a.next("script").remove();
-                        </script>
-                    </li>
-                </t>
-            </div>
+        <t t-call="website_blog.index">
+        <div t-foreach="blog_posts" t-as="blog_post" data-publish="">
             <h2 class="text-center">
                 <a t-href="/blog/#{blog_post.id}" t-field="blog_post.name"></a>
             </h2>
@@ -48,6 +35,7 @@
             <hr/>
 
         </div>
+        </t>
     </template>
 
     <!-- Options: Blog Post Summary: hide author -->
@@ -81,6 +69,7 @@
 
     <!-- Blog Post Complete -->
     <template id="blog_post_complete" name="Blog Post">
+        <t t-call="website_blog.index">
         <div>
             <t t-call="website.publish_management">
                 <t t-set="object" t-value="blog_post"/>
         <hr class="mb32"/>
 
         <a id="comments"/>
-        <h4 t-if="len(blog_post.website_message_ids)" class="mb16">
-            <t t-if="len(blog_post.website_message_ids) &lt;= 1">
-                1 Comment
-            </t>
-            <t t-if="len(blog_post.website_message_ids) > 1">
-                <t t-esc="len(blog_post.website_message_ids)"/> Comments
-            </t>
-        </h4>
-        <ul class="media-list">
+        <ul class="media-list" id="comments-list">
             <li t-foreach="blog_post.website_message_ids" t-as="message" class="media">
                 <div class="media-body">
                     <img class="media-object pull-left" t-att-src="'/website/image?model=res.partner&amp;field=image_small&amp;id='+str(message.author_id.id)" style="width: 50px; margin-right: 10px;"/>
                 </div>
             </li>
         </ul>
+        </t>
     </template>
 
     <!-- Options: Blog Post: user can reply -->
     <template id="opt_blog_post_complete_comment" name="Comment Form"
             inherit_option_id="website_blog.blog_post_complete" inherit_id="website_blog.blog_post_complete">
-        <xpath expr="//ul[last()]" position="after">
+        <xpath expr="//ul[@id='comments-list']" position="after">
             <t t-if="not is_public_user">
                 <section groups="group_website_blog_reply" class="mb32">
-                    <h4>Leave a Comment</h4>
                     <form id="comment" t-attf-action="/blog/#{blog_post.id}/comment"
                             method="POST">
                         <img class="img pull-left img-rounded" t-att-src="'/website/image?model=res.partner&amp;field=image_small&amp;id='+str(user_id.partner_id.id)" style="width: 50px; margin-right: 10px;"/>
             <div id="wrap">
                 <div class="container mt16 js_website_blog">
                     <div class="row">
-                        <div class="col-lg-12 col-sm-12" t-if="not blog_post" id="blog_post">
-                            <t t-if="category and editable">
-                                <div class="row hidden-xs">
-                                    <a t-href="/blog/#{category.id}/new" class="btn btn-primary pull-right">New Blog Post</a>
-                                </div>
-                            </t>
-                            <t t-foreach="blog_posts" t-as="blog_post" data-publish="">
-                                <t t-call="website_blog.blog_post_short"/>
-                            </t>
-                            <div class="pull-right" t-call="website.pager"/>
-                        </div>
-                        <div class="col-lg-12 col-sm-12" t-if="blog_post" id="blog_posts_summary">
-                            <t t-call="website_blog.blog_post_complete">
-                                <t t-set="blog_post" t-value="blog_post"/>
-                            </t>
+                        <div class="col-lg-12 col-sm-12" id="blog_left_column">
+                            <t t-raw="0"/>
                         </div>
+                        <div class="col-lg-3 col-lg-offset-1 col-sm-4" id="blog_right_column"/>
                     </div>
                 </div>
             </div>
         </t>
     </template>
 
-    <!-- Option: Blog: Right Column -->
-    <template id="blog_right_column" name="Right Column"
-             inherit_option_id="website_blog.index" inherit_id="website_blog.index">
-        <xpath expr="//div[@class='row']" position="inside">
-            <div class="col-lg-3 col-sm-3 hidden-xs col-lg-offset-1 mb32" id="right_column">
-            </div>
-        </xpath>
-        <xpath expr="//div[@id='blog_post']" position="attributes">
-            <attribute name="class">col-lg-8 col-sm-8</attribute>
-        </xpath>
-        <xpath expr="//div[@id='blog_posts_summary']" position="attributes">
-            <attribute name="class">col-lg-8 col-sm-8</attribute>
-        </xpath>
-    </template>
-
     <!-- Option: Right Column: archives -->
     <template id="opt_blog_rc_history" name="Archives"
-            inherit_option_id="website_blog.blog_right_column" inherit_id="website_blog.blog_right_column">
-        <xpath expr="//div[@id='right_column']" position="inside">
-            <section>
+            inherit_option_id="website_blog.index" inherit_id="website_blog.index">
+        <xpath expr="//div[@id='blog_left_column']" position="attributes">
+            <attribute name="class">col-lg-8 col-sm-8</attribute>
+        </xpath>
+        <xpath expr="//div[@id='blog_right_column']" position="inside">
+            <section class="mt32">
             <h4>Archives</h4>
             <ul class="nav nav-pills nav-stacked">
                 <li t-foreach="nav_list" t-as="year" class="js_nav_year">
 
     <!-- Option: Right Column: about us -->
     <template id="opt_blog_rc_about_us" name="About Us" priority="4"
-            inherit_option_id="website_blog.blog_right_column" inherit_id="website_blog.blog_right_column">
-        <xpath expr="//div[@id='right_column']" position="inside">
-            <section class="mb16">
+            inherit_option_id="website_blog.index" inherit_id="website_blog.index">
+        <xpath expr="//div[@id='blog_left_column']" position="attributes">
+            <attribute name="class">col-lg-8 col-sm-8</attribute>
+        </xpath>
+        <xpath expr="//div[@id='blog_right_column']" position="inside">
+            <section class="mt32">
             <h4>About us</h4>
             <p>
                 Write here a small text for <b>new visitors</b> finding your website
 
     <!-- Option: Right Column: follow us -->
     <template id="opt_blog_rc_follow_us" name="Follow us" priority="2"
-            inherit_option_id="website_blog.blog_right_column" inherit_id="website_blog.blog_right_column">
-        <xpath expr="//div[@id='right_column']" position="inside">
-            <section class="mb16">
+            inherit_option_id="website_blog.index" inherit_id="website_blog.index">
+        <xpath expr="//div[@id='blog_left_column']" position="attributes">
+            <attribute name="class">col-lg-8 col-sm-8</attribute>
+        </xpath>
+        <xpath expr="//div[@id='blog_right_column']" position="inside">
+            <section class="mt32">
                 <h4>Follow us</h4>
                 <t t-if="category">
                     <p class="text-muted">
-                        Be notified of new blog posts in <t t-esc="category.name"/>
+                        Subscribe to: <t t-esc="category.name"/>
                     </p>
                     <t t-call="website_mail.follow">
                         <t t-set="email" t-value="user_id.email"/>
                         <t t-set="object" t-value="category"/>
                     </t>
                 </t>
-                <p class="text-muted">
+                <p class="text-muted mb0">
                     Participate on our social stream.
                 </p>
-                <h2>
+                <h2 class="mt4">
                     <a t-att-href="website.social_facebook" t-if="website.social_facebook"><i class="icon-facebook-sign"/></a>
                     <a t-att-href="website.social_twitter" t-if="website.social_twitter"><i class="icon-twitter-sign"/></a>
                     <a t-att-href="website.social_linkedin" t-if="website.social_linkedin"><i class="icon-linkedin-sign"/></a>
     </template>
 
     <!-- Option: Right Column: categories -->
-    <template id="opt_blog_rc_categories" name="Other Blogs" priority="6"
-            inherit_option_id="website_blog.blog_right_column">
-        <xpath expr="//div[@id='right_column']" position="inside">
-            <section class="mb16">
-            <h4>Other Blogs</h4>
+    <template id="opt_blog_rc_categories" name="Our Blogs" priority="6"
+            inherit_option_id="website_blog.index">
+        <xpath expr="//div[@id='blog_left_column']" position="attributes">
+            <attribute name="class">col-lg-8 col-sm-8</attribute>
+        </xpath>
+        <xpath expr="//div[@id='blog_right_column']" position="inside">
+            <section class="mt32">
+            <h4>Our Blogs</h4>
             <ul class="nav nav-pills nav-stacked">
                 <t t-foreach="categories" t-as="nav_category">
                     <li>