[FIX] wrap the wrapper in order to allow RTE on all of the page (except the toolbar)

CKEditor does not work directly on body, and it's a bad idea anyway
(editing the edition toolbar won't end well). 

A big wrapper around all of the page's content can be used as RTE hook
to give access to the body as well as the header and footers.

bzr revid: xmo@openerp.com-20130918145028-6ppi9sro2un0quh5
This commit is contained in:
Xavier Morel 2013-09-18 16:50:28 +02:00
parent fe630f7f93
commit e0662b11d0
15 changed files with 131 additions and 125 deletions

View File

@ -1,4 +1,3 @@
@charset "utf-8";
/* THIS CSS FILE IS FOR WEBSITE THEMING CUSTOMIZATION ONLY
*
* css for editor buttons, openerp widget included in the website and other
@ -97,12 +96,12 @@
}
/* ----- BOOTSTRAP HACK FOR STICKY FOOTER ----- */
html, body {
html, body, #wrapwrap {
box-sizing: border-box;
height: 100%;
}
body {
#wrapwrap {
display: table;
width: 100%;
}

View File

@ -64,11 +64,11 @@
/* ----- BOOTSTRAP HACK FOR STICKY FOOTER ----- */
html,body
html,body, #wrapwrap
box-sizing: border-box
height: 100%
body
#wrapwrap
display: table
width: 100%
@ -110,9 +110,8 @@ footer
.nav-hierarchy
padding-left: 16px
div#wrap
.carousel
top: -20px
div#wrap .carousel
top: -20px
/* -- Hack for removing double scrollbar from mobile preview -- */
div#mobile-preview.modal
@ -122,9 +121,8 @@ div#mobile-preview.modal
ul.nav-stacked > li > a
padding: 2px 15px
#customize-menu
.dropdown-header
text-transform: uppercase
#customize-menu .dropdown-header
text-transform: uppercase
/* ---- PUBLISH ---- */
a[data-publish]
@ -157,4 +155,4 @@ a[data-publish]
top: -10px
display: none
/*&:hover > [data-publish]*/
/* display: block*/
/* display: block*/

View File

@ -310,8 +310,7 @@
start_edition: function ($elements) {
var self = this;
// create a single editor for the whole page
// FIXME: is not the whole page, ckeditor can't handle body
var root = document.getElementById('wrap');
var root = document.getElementById('wrapwrap');
root.setAttribute('data-cke-editable', 'true');
this.editor = CKEDITOR.inline(root, self._config());
this.editor.on('instanceReady', function () {

View File

@ -16,4 +16,4 @@
<t t-name="website.ace_view_option">
<option t-att-value="widget.view_id"><t t-esc="widget.view_name"/></option>
</t>
</templates>
</templates>

View File

@ -55,34 +55,42 @@ class view(osv.osv):
def extract_embedded_fields(self, cr, uid, arch, context=None):
return arch.xpath('//*[@data-oe-model != "ir.ui.view"]')
def convert_embedded_field(self, cr, uid, el, column, context=None):
def convert_embedded_field(self, cr, uid, el, column,
type_override=None, context=None):
""" Converts the content of an embedded field to a value acceptable
for writing in the column
:param etree._Element el: embedded field being saved
:param fields._column column: column object corresponding to the field
:param type type_override: column type to dispatch on instead of the
column's actual type (for proxy column types
e.g. relateds)
:return: converted value
"""
if isinstance(column, fields.html):
column_type = type_override or type(column)
if issubclass(column_type, fields.html):
# FIXME: multiple children?
return html.tostring(el[0])
elif isinstance(column, fields.integer):
elif issubclass(column_type, fields.integer):
return int(el.text_content())
elif isinstance(column, fields.float):
elif issubclass(column_type, fields.float):
return float(el.text_content())
elif isinstance(column, (fields.char, fields.text,
fields.date, fields.datetime)):
elif issubclass(column_type, (fields.char, fields.text,
fields.date, fields.datetime)):
return el.text_content()
# TODO: fields.selection
# TODO: fields.many2one
elif isinstance(column, fields.function):
elif issubclass(column_type, fields.function):
# FIXME: special-case selection as in get_pg_type?
return self.convert_embedded_field(
cr, uid, el, getattr(fields, column._type), context=context)
cr, uid, el, column,
type_override=getattr(fields, column._type),
context=context)
# TODO?: fields.many2many, fields.one2many
# TODO?: fields.reference
else:
raise TypeError("Un-convertable column type %s" % column)
raise TypeError("Un-convertable column type %s" % column_type)
def save_embedded_field(self, cr, uid, el, context=None):
Model = self.pool[el.get('data-oe-model')]

View File

@ -57,99 +57,101 @@
<link rel='stylesheet' href='/web/static/lib/fontawesome/css/font-awesome.css'/>
</head>
<body>
<header>
<div class="navbar navbar-default navbar-static-top">
<div id="wrapwrap">
<header>
<div class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-top-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/page/website.homepage"><em>Open</em><b>ERP</b></a>
</div>
<div class="collapse navbar-collapse navbar-top-collapse">
<ul class="nav navbar-nav navbar-right" id="top_menu">
<li><a href="/page/website.contactus">Contact us</a></li>
<li><a href="/admin">Sign in</a></li>
<li t-if="len(website.language_ids) &gt; 1" class="dropdown">
<!-- TODO: use flags for language selection -->
<t t-set="lang_selected" t-value="[lg for lg in website.language_ids if lg.code == lang]"/>
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<t t-esc="lang_selected[0]['name']"/> <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li t-foreach="website.language_ids" t-as="lg">
<a href="#" role="menuitem">
<strong t-att-class="'icon-check' if lg.code == lang
else 'icon-check-empty'"></strong>
<t t-esc="lg.name"/>
</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</header>
<div t-raw="0" id="wrap">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-top-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/page/website.homepage"><em>Open</em><b>ERP</b></a>
</div>
<div class="collapse navbar-collapse navbar-top-collapse">
<ul class="nav navbar-nav navbar-right" id="top_menu">
<li><a href="/page/website.contactus">Contact us</a></li>
<li><a href="/admin">Sign in</a></li>
<li t-if="len(website.language_ids) &gt; 1" class="dropdown">
<!-- TODO: use flags for language selection -->
<t t-set="lang_selected" t-value="[lg for lg in website.language_ids if lg.code == lang]"/>
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<t t-esc="lang_selected[0]['name']"/> <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li t-foreach="website.language_ids" t-as="lg">
<a href="#" role="menuitem">
<strong t-att-class="'icon-check' if lg.code == lang
else 'icon-check-empty'"></strong>
<t t-esc="lg.name"/>
</a>
</li>
</ul>
</li>
</ul>
</div>
<h1>Main Layout</h1>
</div>
</div>
</header>
<div t-raw="0" id="wrap">
<div class="container">
<h1>Main Layout</h1>
</div>
<footer>
<div class="container" id="footer_container">
<div class="row">
<div class="col-md-3" name="product">
<h4>Our products &amp; Services</h4>
<ul class="list-unstyled" name="products">
<li><a href="/">Home</a></li>
</ul>
</div>
<div class="col-md-3" name="info">
<h4 name="info_title">Connect with us</h4>
<ul class="list-unstyled">
<li><a href="/page/website.contactus">Contact us</a></li>
</ul>
<ul class="list-unstyled">
<li><i class="icon-phone"></i> <span t-field="res_company.phone"></span></li>
<li><i class="icon-envelope"></i> <span t-field="res_company.email"></span></li>
</ul>
<h1>
<a href="http://twitter.com/openerp"><i class="icon-twitter-sign"></i></a>
<a href="http://facebook.com/OpenERP"><i class="icon-facebook-sign"></i></a>
<a href="https://plus.google.com/+openerp/posts"><i class="icon-google-plus-sign"></i></a>
</h1>
</div>
<div class="col-md-5 col-lg-offset-1" name="about_us">
<h4 t-field="res_company.name">About us</h4>
<ul class="list-unstyled">
<li><a href="/page/website.aboutus">About us</a></li>
</ul>
<p>
We are a team of passionated people whose goal is to improve everyone's
life through disruptive products. We build great products to solve your
business problems.
</p>
<p>
Our products are designed for small to medium companies willing to optimize
their performance.
</p>
</div>
</div>
</div>
<div class="container mt16">
<div class="pull-right" t-ignore="1">
Create a <a href="http://openerp.com/apps/website">free website</a> with
<a class="label label-danger" href="https://openerp.com/apps/website">OpenERP</a>
</div>
<div class="pull-left text-muted">
Copyright &amp;copy; <span t-field="res_company.name">Company name</span> - <a href="/sitemap">Sitemap</a>
</div>
</div>
</footer>
</div>
<footer>
<div class="container" id="footer_container">
<div class="row">
<div class="col-md-3" name="product">
<h4>Our products &amp; Services</h4>
<ul class="list-unstyled" name="products">
<li><a href="/">Home</a></li>
</ul>
</div>
<div class="col-md-3" name="info">
<h4 name="info_title">Connect with us</h4>
<ul class="list-unstyled">
<li><a href="/page/website.contactus">Contact us</a></li>
</ul>
<ul class="list-unstyled">
<li><i class="icon-phone"></i> <span t-field="res_company.phone"></span></li>
<li><i class="icon-envelope"></i> <span t-field="res_company.email"></span></li>
</ul>
<h1>
<a href="http://twitter.com/openerp"><i class="icon-twitter-sign"></i></a>
<a href="http://facebook.com/OpenERP"><i class="icon-facebook-sign"></i></a>
<a href="https://plus.google.com/+openerp/posts"><i class="icon-google-plus-sign"></i></a>
</h1>
</div>
<div class="col-md-5 col-lg-offset-1" name="about_us">
<h4 t-field="res_company.name">About us</h4>
<ul class="list-unstyled">
<li><a href="/page/website.aboutus">About us</a></li>
</ul>
<p>
We are a team of passionated people whose goal is to improve everyone's
life through disruptive products. We build great products to solve your
business problems.
</p>
<p>
Our products are designed for small to medium companies willing to optimize
their performance.
</p>
</div>
</div>
</div>
<div class="container mt16">
<div class="pull-right" t-ignore="1">
Create a <a href="http://openerp.com/apps/website">free website</a> with
<a class="label label-danger" href="https://openerp.com/apps/website">OpenERP</a>
</div>
<div class="pull-left text-muted">
Copyright &amp;copy; <span t-field="res_company.name">Company name</span> - <a href="/sitemap">Sitemap</a>
</div>
</div>
</footer>
</body>
</html>
</template>

View File

@ -6,7 +6,7 @@
<!-- Layout add nav and footer -->
<template id="footer_custom" inherit_id="website.layout" name="Custom Footer">
<xpath expr="//body/footer//div[@name='info']/ul" position="inside">
<xpath expr="//footer//div[@name='info']/ul" position="inside">
<li><a href="/references/">References</a></li>
</xpath>
</template>

View File

@ -6,7 +6,7 @@
<!-- Layout add nav and footer -->
<template id="footer_custom" inherit_id="website.layout" name="Custom Footer">
<xpath expr="//body/footer//div[@name='info']/ul" position="inside">
<xpath expr="//footer//div[@name='info']/ul" position="inside">
<li><a href="/partners/">Partners</a></li>
</xpath>
</template>

View File

@ -5,10 +5,10 @@
<!-- Layout add nav and footer -->
<template id="header_footer" inherit_id="website_sale.header_footer">
<xpath expr="//body/header//ul[@id='top_menu']/li" position="before">
<xpath expr="//header//ul[@id='top_menu']/li" position="before">
<li><a href="/event">Events</a></li>
</xpath>
<xpath expr="//body/footer//ul[@name='products']/li" position="after">
<xpath expr="//footer//ul[@name='products']/li" position="after">
<li><a href="/event">Events</a></li>
</xpath>
</template>

View File

@ -39,4 +39,4 @@
</template>
</data>
</openerp>
</openerp>

View File

@ -13,7 +13,7 @@
<!-- Layout add nav and footer -->
<template id="footer_custom" inherit_id="website.layout" name="Custom Footer">
<xpath expr="//body/footer//div[@name='info']/ul" position="inside">
<xpath expr="//footer//div[@name='info']/ul" position="inside">
<li><a href="/blog/%(website_hr.website_mail_job)d/">Jobs</a></li>
</xpath>
</template>

View File

@ -13,10 +13,10 @@
<!-- Layout add nav and footer -->
<template id="header_footer_custom" inherit_id="website.layout">
<xpath expr="//body/header//ul[@id='top_menu']/li[last()]" position="before">
<xpath expr="//header//ul[@id='top_menu']/li[last()]" position="before">
<li><a href="/blog/%(website_mail.website_mail_blog)d/">News</a></li>
</xpath>
<xpath expr="//body/footer//div[@name='info']/ul" position="inside">
<xpath expr="//footer//div[@name='info']/ul" position="inside">
<li><a href="/blog/%(website_mail.website_mail_blog)d/">News</a></li>
</xpath>
</template>

View File

@ -6,7 +6,7 @@
<!-- Layout add nav and footer -->
<template id="footer_custom" inherit_id="website.layout" name="Custom Footer">
<xpath expr="//body/footer//div[@name='info']/ul" position="inside">
<xpath expr="//footer//div[@name='info']/ul" position="inside">
<li><a href="/members/">Members</a></li>
</xpath>
</template>

View File

@ -6,7 +6,7 @@
<!-- Layout add nav and footer -->
<template id="footer_custom" inherit_id="website.layout" name="Custom Footer">
<xpath expr="//body/footer//ul[@name='products']" position="inside">
<xpath expr="//footer//ul[@name='products']" position="inside">
<li t-foreach="website_project_ids" t-as="project"><a t-attf-href="/project/#{ project.id }/"><t t-esc="project.name"/></a></li>
</xpath>
</template>

View File

@ -43,7 +43,7 @@
<!-- Layout add nav and footer -->
<template id="header_footer" inherit_id="website.layout" name="Custom Footer">
<xpath expr="//body/header//ul[@id='top_menu']/li" position="before">
<xpath expr="//header//ul[@id='top_menu']/li" position="before">
<li><a href="/shop/">Shop</a></li>
<li>
<a href="/shop/mycart/">
@ -53,7 +53,7 @@
</a>
</li>
</xpath>
<xpath expr="//body/footer//ul[@name='products']" position="inside">
<xpath expr="//footer//ul[@name='products']" position="inside">
<li><a href="/shop/">Shop</a></li>
<li>
<a href="/shop/mycart/">