[IMP] /blog controler and simplification of dates navigation

bzr revid: fp@openerp.com-20131117101657-m3ybugh98ts92d6p
This commit is contained in:
Fabien Pinckaers 2013-11-17 11:16:57 +01:00
parent d44934a050
commit f84c936bc1
4 changed files with 116 additions and 13 deletions

View File

@ -47,8 +47,28 @@ class WebsiteBlog(http.Controller):
return nav
@website.route([
'/blog/',
'/blog',
'/blog/page/<int:page>/',
], type='http', auth="public", multilang=True)
def blogs(self, page=1):
BYPAGE = 60
cr, uid, context = request.cr, request.uid, request.context
blog_obj = request.registry['blog.post']
total = blog_obj.search(cr, uid, [], count=True, context=context)
pager = request.website.pager(
url='/blog/',
total=total,
page=page,
step=BYPAGE,
)
bids = blog_obj.search(cr, uid, [], offset=(page-1)*BYPAGE, limit=BYPAGE, context=context)
blogs = blog_obj.browse(cr, uid, bids, context=context)
return request.website.render("website_blog.blogs", {
'blogs': blogs,
'pager': pager
})
@website.route([
'/blog/cat/<model("blog.category"):category>/',
'/blog/cat/<model("blog.category"):category>/page/<int:page>/',
'/blog/tag/<model("blog.tag"):tag>/',

View File

@ -23,6 +23,8 @@
<field name="category_id" ref="blog_category_1"/>
<field name="tag_ids" eval="[(6, 0, [ref('blog_tag_1')])]"/>
<field name="website_published" eval="True"/>
<field name="website_meta_keywords">OpenERP, Point of Sale, Hardware, Interface, Payment Terminal, Store</field>
<field name="website_meta_description">Open source Point of Sale with no installation required that runs online and offline.</field>
<field name="content"><![CDATA[
<section data-snippet-id='image-text'>
<div class="container">
@ -235,6 +237,8 @@
<field name="name">Touchscreen Point of Sale</field>
<field name="category_id" ref="blog_category_1"/>
<field name="tag_ids" eval="[(6, 0, [ref('blog_tag_1'), ref('blog_tag_2')])]"/>
<field name="website_meta_keywords">Point of Sale, Hardware, Interface, Payment Terminal, Store</field>
<field name="website_meta_description">Point of Sale with no installation required that runs online and offline.</field>
<field name="content">
<![CDATA[<p>The brand new OpenERP touchscreen point of sale available with 6.1 allows you
to manage your shop sales very easily. It's fully web based so that you don't
@ -272,6 +276,8 @@ Think of it as an out-of-the-box solution to boost your business' productivity.
<field name="category_id" ref="blog_category_1"/>
<field name="tag_ids" eval="[(6, 0, [ref('blog_tag_1')])]"/>
<field name="website_published" eval="True"/>
<field name="website_meta_keywords">OpenERP, Partnership, News, Accounting</field>
<field name="website_meta_description">Our company partners with OpenERP to develop accounting best practices.</field>
<field name="content"><![CDATA[
<section data-snippet-id='image-text'>
<div class="container">

View File

@ -1,9 +1,4 @@
$(document).ready(function () {
$('.js_nav_year a:first').on('click', function (e) {
e.preventDefault();
$(this).next("ul").toggle();
});
$('.js_nav_month a:first').on('click', function (e) {
e.preventDefault();
var $ul = $(this).next("ul");
@ -25,4 +20,4 @@ $(document).ready(function () {
}
});
});
});

View File

@ -14,6 +14,84 @@
</xpath>
</template>
<!-- Blog Post Summary -->
<template id="blogs" name="All Blogs">
<t t-call="website.layout">
<div id="wrap">
<div class="oe_structure"/>
<section t-if="editable">
<div class="container text-center mt16">
<div class="alert alert-warning alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&amp;times;</button>
<p>
This page is great to improve your <strong>Search Engine Optimization</strong>;
You can review titles, keywords and descriptions of all blogs at once.
</p><p>
You should <strong>add a banner on the top</strong> as it is a frequent landing page for new visitors.
<span class="text-muted">This information will not be visible to your visitors.</span>
</p>
</div>
</div>
</section>
<section class="container">
<t t-call="website.pager" >
<t t-set="classname">pull-right</t>
</t>
</section>
<section data-snippet-id="title" class="container">
<div class="row">
<div class="col-md-12 text-center">
<h1>Latest Blogs</h1>
</div>
</div>
</section>
<section class="container">
<div class="row">
<t t-set="count" t-value="0"/>
<t t-foreach="blogs" t-as="blog">
<div class="col-md-4">
<h4>
<a t-href="/blog/#{blog.id}" t-field="blog.name"></a>
<span t-if="not blog.website_published" class="text-warning">
&amp;nbsp;
<span class="icon-warning-sign" title="Not published"/>
</span>
</h4>
<div class="text-muted">
<span class="icon-calendar"> <span t-field="blog.create_date"/> &amp;nbsp;</span>
<span class="icon-folder-open"> In
<a t-href="/blog/cat/#{blog.category_id.id}">
<span t-field="blog.category_id"/>
</a> &amp;nbsp;
</span>
</div>
<div class="text-muted icon-tags">
<span t-field="blog.website_meta_keywords"/>
<span t-if="editable and not blog.website_meta_keywords" class="label label-danger">
No keywords defined!
</span>
</div>
<div class="text-muted" t-if="len(blog.message_ids) &gt; 0">
<span class="icon-comment">
<a t-href="/blog/#{blog.id}/#comment">
<t t-if="len(blog.message_ids) &lt;= 1" ><t t-esc="len(blog.message_ids)"/> comment</t>
<t t-if="len(blog.message_ids) > 1"><t t-esc="len(blog.message_ids)"/> comments</t>
</a>
</span>
</div>
<div class="text-muted mb16" t-field="blog.website_meta_description"/>
</div>
<t t-set="count" t-value="count+1"/>
<div class="clearfix" t-if="(count % 3) == 0"/>
</t>
</div>
</section>
<div class="oe_structure"/>
</div>
</t>
</template>
<!-- Blog Post Summary -->
<template id="blog_post_short" name="Blog Post Summary">
<t t-call="website_blog.index">
@ -209,14 +287,18 @@
<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">
<ul class="list-unstyled">
<li t-foreach="nav_list" t-as="year">
<t t-set="year" t-value="nav_list[year]"/>
<a href="#"><t t-esc="year['name']"/> <small>(<t t-esc="year['create_date_count']"/>)</small></a>
<ul class="nav list-group css_nav_month nav-stacked nav-hierarchy">
<t t-esc="year['name']"/>
<ul class="css_nav_month">
<t t-foreach="year['months']">
<li class="js_nav_month"><a href="#" t-att-data-domain="__domain"><t t-esc="create_date"/> <small>(<t t-esc="create_date_count"/>)</small></a>
<ul class="nav list-group nav-stacked nav-hierarchy"/>
<li class="js_nav_month">
<a href="#" t-att-data-domain="__domain">
<t t-esc="create_date"/>
<span class="pull-right badge" t-esc="create_date_count"/>
</a>
<ul class="list-unstyled"/>
</li>
</t>
</ul>