[MERGE] from upstream

bzr revid: fva@openerp.com-20130730184923-at0b7xbs9gc50g10
This commit is contained in:
Frédéric van der Essen
2013-07-30 20:49:23 +02:00
10 changed files with 218 additions and 49 deletions
+78 -8
View File
@@ -42,11 +42,22 @@ instance.website.EditorBar = instance.web.Widget.extend({
.add(this.$buttons.save)
.parent().show();
// TODO: span edition changing edition state (save button)
this.rte.start_edition(
$('[data-oe-model]')
.not('link, script')
.prop('contentEditable', true)
.addClass('oe_editable'));
var $editables = $('[data-oe-model]')
.not('link, script').prop('contentEditable', true)
.addClass('oe_editable');
var $rte_ables = $editables.filter('div, p, li').not('[data-oe-type]');
var $raw_editables = $editables.not($rte_ables);
this.rte.start_edition($rte_ables);
$raw_editables.on('keydown keypress cut paste', function (e) {
var $target = $(e.target);
if ($target.hasClass('oe_dirty')) {
return;
}
$target.addClass('oe_dirty');
this.$buttons.save.prop('disabled', false);
}.bind(this));
},
rte_changed: function () {
this.$buttons.save.prop('disabled', false);
@@ -215,9 +226,12 @@ instance.website.RTE = instance.web.Widget.extend({
[Command, "\uf12c", 'subscript'],
[Command, "\uf0c1", 'link'],
[Command, "\uf127", 'unlink'],
[Command, "\uf10d", 'blockquote'],
[Group, "\uf0ca", [
[Command, "\uf0ca", 'bulletedlist'],
[Command, "\uf0cb", 'numberedlist']
[Command, "\uf0cb", 'numberedlist'],
[Command, "\uf03b", 'outdent'],
[Command, "\uf03c", 'indent']
]],
[Group, _lt("Heading"), [
[Style, _lt('H1'), { element: 'h1' }],
@@ -226,6 +240,12 @@ instance.website.RTE = instance.web.Widget.extend({
[Style, _lt('H4'), { element: 'h4', }],
[Style, _lt('H5'), { element: 'h5', }],
[Style, _lt('H6'), { element: 'h6', }]
]],
[Group, "\uf039", [
[Command, "\uf039", 'justifyblock'],
[Command, "\uf036", 'justifyleft'],
[Command, "\uf038", 'justifyright'],
[Command, "\uf037", 'justifycenter']
]]
],
// editor.ui.items -> possible commands &al
@@ -253,6 +273,7 @@ instance.website.RTE = instance.web.Widget.extend({
var self = this;
this.$el.show();
this.disable();
this.snippet_carousel();
CKEDITOR.on('currentInstance', this.proxy('_change_focused_editor'));
$elements
.not('span, [data-oe-type]')
@@ -308,6 +329,57 @@ instance.website.RTE = instance.web.Widget.extend({
allowedContent: true,
};
},
// TODO clean
snippet_carousel: function () {
var self = this;
$(".carousel").each(function() {
var $carousel = new instance.website.snippet.carousel(self, this);
$carousel.insertAfter(self.$el);
});
}
});
instance.website.snippet = {};
instance.website.snippet.carousel = instance.web.Widget.extend({
template: 'Website.Snipped.carousel',
events: {
'click .add': 'add_page',
'click .remove': 'remove_page',
},
instances: [],
init: function (parent, carousel) {
this._super(parent);
this.parent = parent;
var index = instance.website.snippet.carousel.index || 0;
instance.website.snippet.carousel.index = index++;
this.index = index;
$(carousel).addClass("carousel-index-"+index);
this.offset = $(carousel).offset();
},
start: function () {
var self = this;
this.$el.css({position: 'absolute', top: this.offset.top+'px', left: this.offset.left+'px'});
},
destroy: function () {
return this._super();
},
get_carousel: function() {
return $(".carousel.carousel-index-"+this.index);
},
add_page: function() {
var $c = this.get_carousel();
var cycle = $c.find(".carousel-inner .item").size();
$c.find(".carousel-inner").append(this.$(".item").clone());
$c.carousel(cycle);
},
remove_page: function() {
var $c = this.get_carousel();
var cycle = $c.find(".carousel-inner .item.active").remove();
$c.find(".carousel-inner .item:first").addClass("active");
$c.carousel(0);
this.parent.trigger('change', this.parent, null);
}
});
$(function(){
@@ -366,8 +438,6 @@ $(function(){
});
}
function append_snippet(event){
console.log('click',this,event.button);
if(event.button === 0){
+19
View File
@@ -18,4 +18,23 @@
<ul class="dropdown-menu" role="menu"/>
</div>
</t>
<t t-name="Website.Snipped.carousel">
<div style="position: absolute; top: -4px;">
<button class="add"><t t-esc="'Add a new banner\'s page'"/></button>
<button class="remove"><t t-esc="'Remove this banner\'s page'"/></button>
<div style="display: none;">
<div class="item">
<div style="border:1px solid #eee; width: 992px; height: 210px; overflow: hidden;">
<img src="//cleancanvas.herokuapp.com/img/backgrounds/color-splash.jpg"/>
</div>
<div class="css_titlebox" style="position: absolute; top: 25px; right: 80px;">
<div style="text-align: right; background: #f6f6f6; padding: 7px 20px; border-radius: 5px;">
<h1>Please edit me !</h1>
<h4>text text text exampletext text text </h4>
</div>
</div>
</div>
</div>
</div>
</t>
</templates>
+66 -31
View File
@@ -21,7 +21,7 @@
<template id="footer">
<div class="container">
<div class="row">
<div class="span4">
<div class="span4" name="product">
<h5>Product and services</h5>
<ul class='unstyled'>
<li><a href="https://www.openerp.com/start?download">Download</a></li>
@@ -29,7 +29,7 @@
<li><a href="http://runbot.openerp.com">Automated Tests</a></li>
</ul>
</div>
<div class="span4">
<div class="span4" name="social">
<h5>Social</h5>
<ul class='unstyled'>
<li><a href="http://twitter.com/openerp"><i class="icon-twitter-sign"></i>Twitter</a></li>
@@ -192,6 +192,41 @@
</div>
</section>
<section class="container mt64">
<div class="row">
<div class="span12">
<div id="myCarousel" class="carousel slide">
<!-- Carousel items -->
<div class="carousel-inner" style="height: 300px; overflow: hidden;">
<div class="item">
<img src="/website/static/src/img/greenfields.jpg"/>
<div class="css_titlebox" style="position: absolute; top: 25px; right: 80px;">
<div style="text-align: right; background: #f6f6f6; padding: 7px 20px; border-radius: 5px;">
<h1>OpenDays</h1>
<h4>1000+ participants.<br/>A success thanks to you !</h4>
<a class="btn btn-info" href="https://www.openerp.com/news/post/133-OpenERP-Open-Days-2013-wrap-up-">More Info</a>
</div>
</div>
</div>
<div class="item active">
<img src="/website/static/src/img/fields.jpg"/>
<div class="css_titlebox" style="position: absolute; top: 25px; right: 80px;">
<div style="text-align: right;">
<h1>OpenERP</h1>
<h4>Beautiful Business Applications<br/>Powerful, Integrated, Open Source</h4>
<a class="btn btn-primary" href="https://www.openerp.com/start">Start your free trial</a>
</div>
</div>
</div>
</div>
<!-- Carousel nav -->
<a class="carousel-control left" href="#myCarousel" data-slide="prev">&amp;lsaquo;</a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">&amp;rsaquo;</a>
</div>
</div>
</div>
</section>
<div class='dark mt64'>
<section class="container">
<div class="row">
@@ -307,38 +342,38 @@
</template>
<template id="contactus">
<t t-call="website.layout">
<t t-set="title">Contact us - <t t-esc="res_company.name"/></t>
<div class="container">
<div class="row">
<h2>Contact us</h2>
<t t-call="website.layout">
<t t-set="title">Contact us - <t t-esc="res_company.name"/></t>
<div class="container">
<div class="row">
<h2>Contact us</h2>
</div>
<div class="row">
<div class="span8">
<p>
Contact us about anything related to our company or services.
</p><p>
We'll do our best to get back to you as soon as possible.
</p>
<div class="text-center oe_mt32" name="mail_button">
<a t-att-href="'mailto:'+res_company.email" class="btn btn-primary">Send us an email</a>
</div>
</div>
<div class="row">
<div class="span8">
<p>
Contact us about anything related to our company or services.
</p><p>
We'll do our best to get back to you as soon as possible.
</p>
<div class="oe_centeralign oe_mt32" name="mail_button">
<a t-att-href="'mailto:'+res_company.email" class="oe_button oe_big oe_tacky">Send us an email</a>
</div>
</div>
<div class="span4">
<address>
<strong t-record="res_company" t-field="name">Name</strong><br/>
<span t-record="res_company" t-field="street"/><br/>
<span t-record="res_company" t-field="city"/>, <span t-record="res_company" t-field="zip"/><br/>
<span t-record="res_company" t-field="country_id"/><br/>
<br/>
&amp;#x2706; <t t-esc="res_company.phone"/><br/>
<i class="icon-envelope"></i> <t t-esc="res_company.email"/>
</address>
<img class="oe_screenshot" t-att-src="google_map_url"/>
</div>
<div class="span4">
<address>
<strong t-record="res_company" t-field="name">Name</strong><br/>
<span t-record="res_company" t-field="street"/><br/>
<span t-record="res_company" t-field="city"/>, <span t-record="res_company" t-field="zip"/><br/>
<span t-record="res_company" t-field="country_id"> </span><br/>
<br/>
<span>&amp;#x2706; <t t-esc="res_company.phone"/></span><br/>
<i class="icon-envelope"></i> <t t-esc="res_company.email"/>
</address>
<img class="thumbnail" t-att-src="google_map_url"/>
</div>
</div>
</t>
</div>
</t>
</template>
</data>
+1
View File
@@ -28,6 +28,7 @@ class website(http.Controller):
script = "\n".join(['<script type="text/javascript" src="%s"></script>' % i for i in main.manifest_list('js', db=request.db)])
css = "\n".join('<link rel="stylesheet" href="%s">' % i for i in main.manifest_list('css', db=request.db))
_values = {
'editable': self.isloggued(),
'request': request,
'registry': request.registry,
'cr': cr,
+1 -1
View File
@@ -24,7 +24,7 @@
<t t-set="title">Thank You!</t>
<div class="container">
<div class="oe_row">
<h2 class="oe_slogan">Thanks for your message.</h2>
<h2 class="oe_slogan">Thanks for your message.</h2>
</div>
</div>
</t>
+15
View File
@@ -24,6 +24,7 @@ class website_mail(website):
'nav_list': dict(),
'prev_date': None,
'next_date': None,
'mail_group_id': mail_group_id,
}
domain = mail_group_id and [("res_id", "=", mail_group_id)] or []
@@ -83,6 +84,8 @@ class website_mail(website):
body=request.session.body,
parent_id=blog_id,
website_published=blog_id and True or False,
type='comment',
subtype='mt_comment',
context={'mail_create_nosubscribe': True},
)
request.session.body = False
@@ -91,3 +94,15 @@ class website_mail(website):
return '%s/blog/%s/%s' % (url, mail_group_id, blog_id)
else:
return werkzeug.utils.redirect("/blog/%s/%s" % (mail_group_id, blog_id))
@website.route(['/blog/<int:mail_group_id>/new'], type='http', auth="admin")
def new_blog_post(self, cr, uid, mail_group_id=None, **post):
blog_id = request.registry['mail.group'].message_post(cr, uid, mail_group_id,
body=_("Blog content.<br/>Please edit this content then you can publish this blog."),
subject=_("Blog title"),
website_published=False,
type='comment',
subtype='mt_comment',
context={'mail_create_nosubscribe': True},
)
return werkzeug.utils.redirect("/blog/%s/%s" % (mail_group_id, blog_id))
@@ -31,3 +31,9 @@
.css_website_mail .css_newer {
float: left;
}
.css_website_mail .css_nav_month {
display: none;
}
.css_website_mail .css_nav_month:first-of-type {
display: block;
}
+5 -1
View File
@@ -25,4 +25,8 @@
.css_older
float: right
.css_newer
float: left
float: left
.css_nav_month
display: none
&:first-of-type
display: block
+2 -2
View File
@@ -1,9 +1,9 @@
$(document).ready(function () {
$('.js_website_mail').on('click', '.js_publish', function (e) {
e.preventDefault();
var $media = $link.parent();
var $media = $(this).parent();
$media.toggleClass('css_published');
$.post('/blog/publish/', {'message_id': $link.data('id')}, function (result) {
$.post('/blog/publish/', {'message_id': $(this).data('id')}, function (result) {
if (+result) $media.addClass('css_published');
else $media.removeClass('css_published');
});
+25 -6
View File
@@ -2,6 +2,14 @@
<openerp>
<data>
<!-- Mail group for the company's news -->
<record id="website_mail_blog" model="mail.group">
<field name="name">News</field>
<field name="public">public</field>
<field name="description">News displayed on your website</field>
</record>
<!-- Layout add nav and footer -->
<record id="header_website_mail" model="ir.ui.view">
@@ -9,14 +17,25 @@
<field name="inherit_id" ref="website.header"/>
<field name="arch" type="xml">
<data>
<xpath expr="(//li)[last()]" position="after">
<li class="pull-right"><a href="/blog">Blog</a></li>
<xpath expr="//li[last()]" position="after">
<li class="pull-right"><a href="/blog/%(website_mail.website_mail_blog)d">News</a></li>
</xpath>
</data>
</field>
</record>
<record id="footer_website_mail" model="ir.ui.view">
<field name="name">footer_website_mail</field>
<field name="inherit_id" ref="website.footer"/>
<field name="arch" type="xml">
<data>
<xpath expr="//a[@href='/page/website.news']" position="replace">
<a href="/blog/%(website_mail.website_mail_blog)d">News</a>
</xpath>
</data>
</field>
</record>
<!-- Page Shop -->
<!-- Page -->
<template id="index">
<t t-call="website.layout">
@@ -30,12 +49,13 @@
<div class="row">
<div class="span4">
<ul class="nav nav-list">
<a t-if="mail_group_id" t-att-href="'/blog/%%s/new' %% mail_group_id" class="btn" groups="group_website_mail_manager">Add a new Blog</a>
<li class="nav-header">BLOG ARCHIVE</li>
<!-- TODO: check qweb iteration -->
<t t-foreach="nav_list" t-as="year">
<t t-set="year" t-value="nav_list[year]"/>
<li class="js_nav_year"><a href="#"><t t-esc="year['name']"/> <small>(<t t-esc="year['date_count']"/>)</small></a>
<ul class="nav nav-list" style="display: none">
<ul class="nav nav-list css_nav_month">
<t t-foreach="year['months']">
<li class="js_nav_month"><a href="#" t-att-data-domain="__domain"><t t-esc="date"/> <small>(<t t-esc="date_count"/>)</small></a>
<ul class="nav nav-list"/>
@@ -95,7 +115,7 @@
<i class="icon-ok-circle css_publish"></i>
<i class="icon-remove-sign css_unpublish"></i>
</a>
<h4 class="media-heading"><t t-esc="blog.subject"/></h4>
<a t-att-href="'/blog/%%s/%%s' %% (blog.res_id, blog.id)"><h4 class="media-heading"><t t-esc="blog.subject"/></h4></a>
<div class="media">
<t t-raw="blog.body"/>
<small class="pull-right muted text-right">
@@ -115,6 +135,5 @@
</div>
</t>
</template>
</data>
</openerp>