diff --git a/addons/website/__openerp__.py b/addons/website/__openerp__.py index aa0f5dbf64f..15285124666 100644 --- a/addons/website/__openerp__.py +++ b/addons/website/__openerp__.py @@ -13,6 +13,7 @@ OpenERP Website CMS 'installable': True, 'data': [ 'views/views.xml', + 'views/themes.xml', 'views/res_config.xml', 'website_data.xml', ], diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index 0199c3cc1c5..b81bd25a01c 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -66,6 +66,26 @@ class Website(openerp.addons.web.controllers.main.Home): }) return werkzeug.utils.redirect("/page/%s" % path) + @http.route('/website/theme_change', type='http', auth="admin") + def theme_change(self, theme_id=False, **kwargs): + imd = request.registry['ir.model.data'] + view = request.registry['ir.ui.view'] + + view_model, view_option_id = imd.get_object_reference(request.cr, request.uid, 'website', 'theme') + views = view.search(request.cr, request.uid, [('inherit_id','=',view_option_id)]) + view.write(request.cr, request.uid, views, {'inherit_id': False}) + + if theme_id: + module, xml_id = theme_id.split('.') + view_model, view_id = imd.get_object_reference(request.cr, request.uid, module, xml_id) + view.write(request.cr, request.uid, [view_id], {'inherit_id':view_option_id}) + + website = request.registry.get("website") + values = website.get_rendering_context({ + 'theme_changed': True + }) + return website.render('website.themes', values) + @http.route('/page/', type='http', auth="admin") def page(self, path, **kwargs): website = request.registry.get("website") @@ -83,25 +103,25 @@ class Website(openerp.addons.web.controllers.main.Home): view_obj = request.registry.get("ir.ui.view") view = view_obj.browse(request.cr, request.uid, int(view_id), context=request.context) if view.inherit_id: - print '*', view.inherit_id value = False else: value = view.inherit_option_id and view.inherit_option_id.id or False - print '*', view.inherit_id, 'no', value, view view_obj.write(request.cr, request.uid, [view_id], { 'inherit_id': value }, context=request.context) - print 'Wrote', value, 'on', view_id return True @http.route('/website/customize_template_get', type='json', auth='admin') # FIXME: auth def customize_template_get(self, xml_id): + imd = request.registry['ir.model.data'] + view_model, view_theme_id = imd.get_object_reference(request.cr, request.uid, 'website', 'theme') + view = request.registry.get("ir.ui.view") views = view._views_get(request.cr, request.uid, xml_id, request.context) done = {} result = [] for v in views: - if v.inherit_option_id: + if v.inherit_option_id and v.inherit_option_id.id<>view_theme_id: if v.inherit_option_id.id not in done: result.append({ 'name': v.inherit_option_id.name, diff --git a/addons/website/static/src/css/editor.css b/addons/website/static/src/css/editor.css index 8a20e94bec0..00d3127e286 100644 --- a/addons/website/static/src/css/editor.css +++ b/addons/website/static/src/css/editor.css @@ -1,3 +1,4 @@ +@charset "utf-8"; .oe_hidden { display: none !important; } @@ -220,7 +221,7 @@ overflow: hidden; } -#mobile-preview.modal { +.oe_mobile_preview.modal { height: 660px; background-color: black; border: 2px solid; @@ -233,22 +234,22 @@ right: 0; max-width: 330px; } -#mobile-preview.modal .modal-header { +.oe_mobile_preview.modal .modal-header { background-color: black; border-bottom: 0; border-top-left-radius: 10px; border-top-right-radius: 10px; } -#mobile-preview.modal .modal-header .oe_mobile_preview_title { +.oe_mobile_preview.modal .modal-header .oe_mobile_preview_title { color: #1a1a1a; } -#mobile-preview.modal .modal-body { +.oe_mobile_preview.modal .modal-body { background-color: black; max-height: 600px; padding: 0; margin: 0; } -#mobile-preview.modal .modal-footer { +.oe_mobile_preview.modal .modal-footer { background-color: black; } @@ -267,3 +268,24 @@ color: #e00101; opacity: 1; } + +.oe_seo_configuration input { + width: inherit; +} +.oe_seo_configuration textarea { + width: inherit; +} +.oe_seo_configuration ul { + list-style: none; +} +.oe_seo_configuration .oe_remove { + color: #e00101; +} + +.oe_seo_keywords_list { + width: 39em; +} +.oe_seo_keywords_list li { + float: left; + width: 12em; +} diff --git a/addons/website/static/src/css/editor.sass b/addons/website/static/src/css/editor.sass index 29621f95e4b..c75946d7c6b 100644 --- a/addons/website/static/src/css/editor.sass +++ b/addons/website/static/src/css/editor.sass @@ -194,8 +194,8 @@ $mobile_preview_background: #000000 $mobile_preview_border: #1A1A1A -$mobile_preview_close: #E00101 -#mobile-preview.modal +$icon_close: #E00101 +.oe_mobile_preview.modal height: 660px background-color: $mobile_preview_background border: 2px solid @@ -233,5 +233,21 @@ $mobile_preview_close: #E00101 color: lightgrey opacity: 1 .close:hover - color: $mobile_preview_close + color: $icon_close opacity: 1 + +.oe_seo_configuration + input + width: inherit + textarea + width: inherit + ul + list-style: none + .oe_remove + color: $icon_close + +.oe_seo_keywords_list + width: 39em + li + float: left + width: 12em \ No newline at end of file diff --git a/addons/website/static/src/js/website.js b/addons/website/static/src/js/website.js index 784b027ef50..bc3caaeeecd 100644 --- a/addons/website/static/src/js/website.js +++ b/addons/website/static/src/js/website.js @@ -46,6 +46,7 @@ 'click button[data-action=cancel]': 'cancel', 'click button[data-action=snippet]': 'snippet', 'click a[data-action=show-mobile-preview]': 'mobilePreview', + 'click a[data-action=promote-current-page]': 'promotePage', }, container: 'body', customize_setup: function() { @@ -64,6 +65,8 @@ item.id, item.active ? '' : '-empty', item.name)); } }); + // Adding Static Menus + menu.append('
  • Change Theme
  • '); } ); }); @@ -75,12 +78,6 @@ window.location.reload(); }); }); - $('#mobile-preview').on('hidden', function () { - $('body').removeClass('oe_stop_scrolling'); - }); - $('.oe_mobile_preview_header button').click(function (){ - $("#mobile-preview").addClass('hide'); - }); }, start: function() { var self = this; @@ -200,11 +197,98 @@ this.snippets.toggle(); }, mobilePreview: function () { + (new website.MobilePreview()).appendTo($('body')); + }, + promotePage: function () { + (new website.seo.Configurator()).appendTo($('body')); + }, + }); + + /* ----- MOBILE PREVIEW ---- */ + website.MobilePreview = openerp.Widget.extend({ + template: 'website.mobile_preview', + events: { + 'hidden': 'close' + }, + start: function () { $('body').addClass('oe_stop_scrolling'); $('body').addClass('oe_stop_scrolling'); $("#mobile-preview").removeClass('hide'); document.getElementById("mobile-viewport").src = window.location.href + "?mobile-preview=true"; + this.$el.modal(); + }, + close: function () { + $('body').removeClass('oe_stop_scrolling'); + this.destroy(); + }, + }); + /* ----- SEO TOOLS ---- */ + website.seo = {}; + website.seo.Keyword = openerp.Widget.extend({ + template: 'website.seo_keyword', + events: { + 'click a[data-action=remove-keyword]': 'destroy', + }, + init: function (parent, options) { + this._super(parent); + this.keyword = options.keyword; + }, + }); + website.seo.Configurator = openerp.Widget.extend({ + template: 'website.seo_configuration', + events: { + 'keypress input[name=seo_page_keywords]': 'confirmKeyword', + 'click button[data-action=add]': 'addKeyword', + 'click a[data-action=update]': 'update', + 'hidden': 'close' + }, + start: function () { + $('body').addClass('oe_stop_scrolling'); + + this.$el.find('input[name=seo_page_url]').val(window.location.href); + this.$el.find('input[name=seo_page_title]').val($('title').text()); + + this.$el.modal(); + }, + keywords: function () { + var result = []; + this.$el.find('.js_seo_keyword').each(function () { + result.push($(this).text()); + }) + return _.uniq(result); + }, + isExistingKeyword: function (word) { + return _.contains(this.keywords(), word); + }, + isKeywordListFull: function () { + return this.keywords().length >= 10; + }, + confirmKeyword: function (e) { + if (e.keyCode == 13) { + this.addKeyword(); + this.$el.find('input[name=seo_page_keywords]').val(""); + } + }, + addKeyword: function () { + var word = this.$el.find('input[name=seo_page_keywords]').val().trim(); + if (word && !this.isKeywordListFull() && !this.isExistingKeyword(word)) { + new website.seo.Keyword(this, { + keyword: word + }).appendTo(this.$el.find('.js_seo_keywords_list')); + var $body = this.$el.find('.modal-body'); + $body.animate({ + scrollTop: $body[0].scrollHeight + }, 500); + } + }, + update: function () { + console.log(this.keywords()); + // TODO: Persist changes + }, + close: function () { + $('body').removeClass('oe_stop_scrolling'); + this.destroy(); }, }); @@ -321,14 +405,14 @@ } }, vomify: function($el){ - var hue=0; + var hue=0; var beat = false; - var a = setInterval(function(){ + var a = setInterval(function(){ $el.css({'-webkit-filter':'hue-rotate('+hue+'deg)'}); hue += 5; }, 10); setTimeout(function(){ clearInterval(a); - setInterval(function(){ + setInterval(function(){ var filter = 'hue-rotate('+hue+'deg)'+ (beat ? ' invert()' : ''); $('html').css({'-webkit-filter': filter}); hue += 5; if(hue % 35 === 0){ @@ -372,7 +456,7 @@ // setup widget and drag and drop start_snippets: function(){ var self = this; - + this.$('.oe_snippet').draggable({ helper: 'clone', zIndex: '1000', @@ -497,7 +581,7 @@ activate_overlay_zones: function(selector){ var $targets = $(selector); - + function is_visible($el){ return $el.css('display') != 'none' && $el.css('opacity') != '0' @@ -512,7 +596,7 @@ var parents = $(this).parents().filter(function(){ return !is_visible($(this)); }); return parents.length === 0; }); - + var zone_template = "
    "; $('.oe_drop_zone').remove(); @@ -536,7 +620,7 @@ var self = this; this.activate_overlay_zones('#wrap .container'); var $snippets = $('.oe_drop_zone'); - + for(var i = 0, len = $snippets.length; i < len; i++){ var $snippet = $snippets.eq(i); var $manipulator = $(openerp.qweb.render('website.snippet_manipulator')); @@ -558,10 +642,10 @@ var y = event.pageY; var pt = $snippet.css('padding-top'); - var pb = $snippet.css('padding-bottom'); + var pb = $snippet.css('padding-bottom'); pt = Number(pt.slice(0,pt.length - 2)) || 0; //FIXME something cleaner to remove 'px' pb = Number(pb.slice(0,pb.length - 2)) || 0; - + $manipulator.addClass('oe_hover'); event.preventDefault(); @@ -573,7 +657,7 @@ $snippet.css('padding-top',pt-dy+'px'); self.cover_target($manipulator,$snippet); }else if($handle.hasClass('s') || $handle.hasClass('sw') || $handle.hasClass('se')){ - + $snippet.css('padding-bottom',pb+dy+'px'); self.cover_target($manipulator,$snippet); } @@ -585,7 +669,7 @@ self.activate_snippet_manipulators(); }); }); - + } }, deactivate_snippet_manipulators: function(){ diff --git a/addons/website/static/src/xml/website.xml b/addons/website/static/src/xml/website.xml index 6e36dc06c62..0761f92ea0a 100644 --- a/addons/website/static/src/xml/website.xml +++ b/addons/website/static/src/xml/website.xml @@ -9,9 +9,9 @@ + - + + +