[IMP] better layout for documentation

bzr revid: fp@tinyerp.com-20140421144510-9qo1whru5u5ec721
This commit is contained in:
Fabien Pinckaers 2014-04-21 16:45:10 +02:00
parent 73b7926f78
commit cbf071a62c
8 changed files with 186 additions and 71 deletions

View File

@ -106,6 +106,15 @@
content: "Press The Top-Left Edit Button" !important;
}
[data-oe-type=html].oe_no_empty:empty:before {
content: "" !important;
}
[data-oe-type=html].oe_no_empty:empty {
background-image: none !important;
height: 16px !important;
}
/* ---- EDITOR BAR ---- {{{ */
table.editorbar-panel {
cursor: pointer;

View File

@ -86,6 +86,13 @@
.oe_structure.oe_empty:empty:before, [data-oe-type=html]:empty:before, .oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child:before, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child:before
content: 'Press The Top-Left Edit Button' !important
[data-oe-type=html].oe_no_empty:empty:before
content: '' !important
[data-oe-type=html].oe_no_empty:empty
background-image: none !important
height: 16px !important
// }}}
/* ---- EDITOR BAR ---- {{{ */

View File

@ -100,30 +100,6 @@
</div>
</div>
<div t-if="header.get('question_data')">
<div class="panel panel-default">
<div class="panel-heading text-center">
<h3 class="panel-title">Question tools</h3>
</div>
<div class="panel-body text-center">
<t t-call="website_mail.follow"><t t-set="object" t-value="question"/></t>
<div class="mt8">
<strong><t t-raw="len(question.message_follower_ids)"/></strong> follower(s)
</div>
</div>
<div class="panel-heading text-center">
<h3 class="panel-title ">Stats</h3>
</div>
<div class="panel-body">
<table class="table">
<thead><tr><td> Asked: <strong><span t-field="question.create_date" t-field-options='{"format":"short"}'/></strong></td></tr></thead>
<tr><td> Seen: <strong><t t-raw="question.views"/></strong>
<span t-if="question.views&gt;1">times</span>
<span t-if="question.views&lt;=1">time</span>
</td></tr>
<tr><td> Last updated: <strong><span t-field="question.write_date" t-field-options='{"format":"short"}'/></strong></td></tr>
</table>
</div>
</div>
</div>
</div>
</div>

View File

@ -18,28 +18,34 @@ from openerp.addons.website.models.website import slug
# controllers = controllers()
class WebsiteDoc(http.Controller):
@http.route(['/forum/how-to', '/forum/how-to/<model("documentation.toc"):toc>'], type='http', auth="public", website=True, multilang=True)
@http.route(['/forum/how-to', '/forum/how-to/<model("forum.documentation.toc"):toc>'], type='http', auth="public", website=True, multilang=True)
def toc(self, toc=None, **kwargs):
cr, uid, context, toc_id = request.cr, request.uid, request.context, False
if toc:
toc = [toc]
sections = toc.child_ids
forum = toc.forum_id
else:
toc_obj = request.registry['forum.documentation.toc']
obj_ids = toc_obj.search(cr, uid, [('parent_id', '=', False)], context=context)
toc = toc_obj.browse(cr, uid, obj_ids, context=context)
sections = toc_obj.browse(cr, uid, obj_ids, context=context)
forum = sections and sections[0].forum_id or False
value = {
'sections': toc,
'toc': toc,
'forum': forum,
'sections': sections,
}
return request.website.render("website_forum_doc.documentation", value)
@http.route(['/forum/how-to/<model("documentation.toc"):toc>/<model("forum.post"):post>'], type='http', auth="public", website=True, multilang=True)
def how_to(self, toc, post, **kwargs):
assert post.documentation_toc_id.id == toc.id, "Wrong post, should implement a redirect here"
@http.route(['/forum/how-to/<model("forum.documentation.toc"):toc>/<model("forum.post"):post>'], type='http', auth="public", website=True, multilang=True)
def post(self, toc, post, **kwargs):
# TODO: implement a redirect instead of crash
assert post.documentation_toc_id.id == toc.id, "Wrong post!"
value = {
'section': toc,
'post': post
'toc': toc,
'post': post,
'forum': post.forum_id
}
return request.website.render("website_forum_doc.documentation.post", value)
return request.website.render("website_forum_doc.documentation_post", value)
#---------------------

View File

@ -5,54 +5,79 @@
<!-- Table Of Content -->
<record id="toc_functional_doc" model="forum.documentation.toc">
<field name="name">Functional Documentation</field>
<field name="introduction" type="html">
<p class="text-muted">
This documentation is produced using the best posts from the
<a href="/forum">community forum</a>.
</p>
</field>
<field name="forum_id" ref="website_forum.forum_help"/>
</record>
<record id="toc_sale" model="forum.documentation.toc">
<field name="name">Sales Management</field>
<field name="parent_id" ref="toc_functional_doc"/>
<field name="introduction" type="html">
<p class="text-muted">
Tracks leads, boost opportunities and close deals.
This serie of how-to will help you develop your business.
</p>
</field>
<field name="forum_id" ref="website_forum.forum_help"/>
</record>
<record id="toc_sale_customer" model="forum.documentation.toc">
<field name="name">Customers</field>
<field name="parent_id" ref="toc_sale"/>
<field name="forum_id" ref="website_forum.forum_help"/>
</record>
<record id="toc_sale_so" model="forum.documentation.toc">
<field name="name">Sales orders</field>
<field name="parent_id" ref="toc_sale"/>
<field name="forum_id" ref="website_forum.forum_help"/>
</record>
<record id="toc_0" model="forum.documentation.toc">
<field name="name">Sales &amp; Warehouse</field>
<field name="parent_id" ref="toc_sale"/>
<field name="forum_id" ref="website_forum.forum_help"/>
</record>
<record id="toc_crm" model="forum.documentation.toc">
<field name="name">Customer Relationship Management</field>
<field name="parent_id" ref="toc_functional_doc"/>
<field name="forum_id" ref="website_forum.forum_help"/>
</record>
<record id="toc_crm_lead" model="forum.documentation.toc">
<field name="name">Lead &amp; Opportunity</field>
<field name="parent_id" ref="toc_crm"/>
<field name="forum_id" ref="website_forum.forum_help"/>
</record>
<record id="toc_crm_claim" model="forum.documentation.toc">
<field name="name">Claims</field>
<field name="parent_id" ref="toc_crm"/>
<field name="forum_id" ref="website_forum.forum_help"/>
</record>
<record id="toc_crm_after_sale" model="forum.documentation.toc">
<field name="name">After-sale communication</field>
<field name="parent_id" ref="toc_crm"/>
<field name="forum_id" ref="website_forum.forum_help"/>
</record>
<record id="toc_website" model="forum.documentation.toc">
<field name="name">Website</field>
<field name="parent_id" ref="toc_functional_doc"/>
<field name="forum_id" ref="website_forum.forum_help"/>
</record>
<record id="toc_cms_ecommerce" model="forum.documentation.toc">
<field name="name">CMS &amp; eCommerce</field>
<field name="parent_id" ref="toc_website"/>
<field name="forum_id" ref="website_forum.forum_help"/>
</record>
<record id="toc_hrm" model="forum.documentation.toc">
<field name="name">Human Resources Management</field>
<field name="parent_id" ref="toc_functional_doc"/>
<field name="forum_id" ref="website_forum.forum_help"/>
</record>
<record id="toc_hrm_contract" model="forum.documentation.toc">
<field name="name">Employee Contract</field>
<field name="parent_id" ref="toc_hrm"/>
<field name="forum_id" ref="website_forum.forum_help"/>
</record>
<!-- Questions -->

View File

@ -13,11 +13,13 @@ class Documentation(osv.Model):
_columns = {
'sequence': fields.integer('Sequence'),
'name': fields.char('Name', required=True, translate=True),
'introduction': fields.html('Introduction', translate=True),
'parent_id': fields.many2one('forum.documentation.toc', 'Parent Table Of Content'),
'child_ids': fields.one2many('forum.documentation.toc', 'parent_id', 'Children Table Of Content'),
'parent_left': fields.integer('Left Parent', select=True),
'parent_right': fields.integer('Right Parent', select=True),
'post_ids': fields.one2many('forum.post', 'documentation_toc_id', 'Posts'),
'forum_id': fields.many2one('forum.forum', 'Forum', required=True),
}
_constraints = [
(osv.osv._check_recursion, 'Error ! You cannot create recursive categories.', ['parent_id'])

View File

@ -11,6 +11,7 @@
<tree string="Documentation TOC" editable="bottom">
<field name="sequence" widget="handle"/>
<field name="name"/>
<field name="forum_id"/>
<field name="parent_id"/>
</tree>
</field>

View File

@ -11,52 +11,141 @@
</template>
<!-- Page Index -->
<template id="toc" name="Documentation Index">
<t t-set="level" t-value="level+1"/>
<t t-foreach="titles" t-as="title">
<div t-attf-class="h#{str(level) + (level&lt;3 and ' page-header' or '')}">
<t t-esc="title.name"/>
<small t-if="len(title.post_ids)">
<t t-esc="len(title.post_ids)"/>
<t t-if="len(title.post_ids)==1">essay</t>
<t t-if="len(title.post_ids)&gt;1">essays</t>
</small>
</div>
<ul t-if="title.post_ids" class="mt32">
<li t-foreach="title.post_ids" t-as="post">
<a t-attf-href="/forum/how-to/#{slug(title)}/#{slug(post)}" t-field="post.name"/>
</li>
</ul>
<t t-set="titles" t-value="title.child_ids"/>
<t t-call="website_forum_doc.toc"/>
</t>
</template>
<template id="breadcrumb" name="Documentation Breadcrumb">
<t t-if="toc.parent_id">
<t t-call="website_forum_doc.breadcrumb">
<t t-set="toc" t-value="toc.parent_id"/>
</t>
</t>
<li t-if="toc">
<a t-attf-href="/forum/how-to/#{ slug(toc) }" t-field="toc.name"/>
</li>
</template>
<template id="documentation" name="Documentation Index">
<t t-call="website.layout">
<t t-set="head">
<link rel='stylesheet' href='/website_forum_doc/static/src/css/website_doc.css'/>
<script type="text/javascript" src="/website_forum_doc/static/src/js/website_doc.js"/>
</t>
<div class="container mt16 document">
<div class="col-md-3 mt32 css_noprint bs-sidebar menu-tree">
<t t-call="website_doc.side_panel"><t t-set="documentation" t-value="documentaion_toc"/></t>
<section class="container mt16" t-if="toc">
<div class="row">
<div class="col-md-9">
<ol class="breadcrumb mb0">
<t t-call="website_forum_doc.breadcrumb">
<t t-set="toc" t-value="toc.parent_id"/>
</t>
<li class="active">
<span t-field="toc.name"/>
</li>
</ol>
</div>
<div class="col-md-3 text-right">
Search:
</div>
</div>
<div class="col-md-9 mt32 document_page">
<strong><h2 t-esc="topic.name" class="text-center"/></strong>
<div t-foreach="topic.post_ids" t-as="post">
<h2><p class="faq-question" t-esc="post.name"/></h2>
<div t-if="post.pertinent_answer_id">
<p><t t-raw="post.pertinent_answer_id.content"/></p>
</section>
<section class="container">
<t t-set="level" t-value="toc and 1 or 0"/>
<h1 class="page-header" t-if="toc">
<t t-esc="toc.name"/>
</h1>
<t t-set="titles" t-value="sections"/>
<t t-call="website_forum_doc.toc"/>
</section>
<div class="oe_structure"/>
</t>
</template>
<template id="documentation_post" name="Documentation Question">
<t t-call="website.layout">
<section class="container mt16" t-if="toc">
<div class="row">
<div class="col-sm-8">
<ol class="breadcrumb mb0">
<t t-call="website_forum_doc.breadcrumb">
<t t-set="toc" t-value="toc.parent_id"/>
</t>
<li>
<a t-attf-href="/forum/how-to/#{ slug(toc) }" t-field="toc.name"/>
</li>
</ol>
</div>
<div class="col-sm-4 text-right" t-if="forum">
<form class="navbar-form navbar-right mt0" role="search" t-attf-action="/forum/#{ slug(forum) }" method="get">
<div class="form-group">
<input type="search" class="form-control"
name="search" placeholder="Search..."
t-att-value="search or ''"/>
<button type="submit" class="btn btn-default">Search</button>
</div>
</form>
</div>
</div>
</section>
<section class="container">
<div class="row">
<div class="col-sm-9">
<h1 class="page-header" t-field="post.name"/>
<blockquote t-if="bool(post.content)">
<t t-raw="post.content"/>
</blockquote>
<t t-if="post.child_ids">
<t t-raw="post.child_ids[0].content"/>
</t>
<div t-if="len(toc.post_ids)&gt;1">
<h2 class="page-header">Related topics</h2>
<ul>
<t t-foreach="toc.post_ids" t-as="topic">
<li t-if="post.id != topic.id">
<a t-attf-href="/forum/how-to/#{slug(toc)}/#{slug(topic)}" t-field="post.name"/>
</li>
</t>
</ul>
</div>
<div class="pull-right">
<a t-attf-href="/forum/#{ slug(post.forum_id) }/question/#{ slug(post) }">Read More About This..</a>
</div><div class="col-sm-3">
<div class="panel panel-default mt48" id="about_doc">
<div class="panel-heading">
<h3 class="panel-title">Need more info?</h3>
</div>
<div class="panel-body">
<div class="text-muted">
This documentation page has been extracted
from the Q&amp;A section where you can
discuss it and get feedback.
</div>
&amp;nbsp; <a t-attf-href="/forum/#{slug(forum)}/question/#{slug(post)}" class="fa fa-arrow-right mt16"> Related question</a>
</div>
</div>
</div>
</div>
<div class="oe_structure"/>
</div>
</section>
<div class="oe_structure mt16 mb16"/>
</t>
</template>
<!--MENU LIST-->
<template id="side_panel">
<ul class="nav nav-pills nav-stacked">
<t t-foreach="documentation" t-as="toc">
<li t-attf-class="tree_toggler #{ topic==toc and 'active' or ''}">
<a t-attf-href="/forum/how-to/#{ slug(toc) }" t-if="not toc.child_ids">
<t t-esc="toc.name"/>
</a>
<a t-attf-href="" t-if="toc.child_ids">
<t t-esc="toc.name"/>
</a>
<t t-if="toc.child_ids">
<t t-call="website_doc.side_panel"><t t-set="documentation" t-value="toc.child_ids"/></t>
</t>
</li>
</t>
</ul>
</template>
<!--TOC ON FORUM POST-->
<template id="forum_question_right_column" inherit_id="website_forum.header" name="Table of Content">
<xpath expr="//script[@src='/website_forum/static/src/js/website_forum.js']" position="after">