Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 15 commits
  • 39 files changed
  • 0 commit comments
  • 1 contributor
Showing with 532 additions and 576 deletions.
  1. +1 −0  .gitignore
  2. +1 −35 plone/app/deco/browser/browser.py
  3. +6 −0 plone/app/deco/browser/config.pt
  4. +61 −0 plone/app/deco/browser/config.py
  5. +20 −19 plone/app/deco/browser/configure.zcml
  6. +0 −415 plone/app/deco/browser/javascripts/deco.core.js
  7. +0 −1  plone/app/deco/browser/javascripts/tinymce/.gitignore
  8. +6 −0 plone/app/deco/configure.zcml
  9. +3 −2 plone/app/deco/interfaces.py
  10. +9 −12 plone/app/deco/profiles/default/controlpanel.xml
  11. +5 −12 plone/app/deco/profiles/default/cssregistry.xml
  12. +30 −70 plone/app/deco/profiles/default/jsregistry.xml
  13. +10 −0 plone/app/deco/profiles/default/viewlets.xml
  14. +2 −2 plone/app/deco/registry.py
  15. 0  plone/app/deco/{browser/stylesheets → resources/css}/authoring.css
  16. 0  plone/app/deco/{browser → resources}/images/deco_icon.gif
  17. 0  plone/app/deco/{browser → resources}/images/divider_horizontal.png
  18. 0  plone/app/deco/{browser → resources}/images/divider_vertical.png
  19. 0  plone/app/deco/{browser → resources}/images/files.png
  20. 0  plone/app/deco/{browser → resources}/images/icons.png
  21. 0  plone/app/deco/{browser → resources}/images/image-placeholder.png
  22. 0  plone/app/deco/{browser → resources}/images/label.png
  23. 0  plone/app/deco/{browser → resources}/images/loading.gif
  24. 0  plone/app/deco/{browser → resources}/images/toolbar.png
  25. 0  plone/app/deco/{browser → resources}/images/window.png
  26. 0  plone/app/deco/{browser/javascripts/tinymce → resources/js}/Makefile
  27. 0  plone/app/deco/{browser/javascripts/tinymce → resources/js}/build.xml
  28. 0  plone/app/deco/{browser/javascripts → resources/js}/deco.actions.js
  29. +370 −0 plone/app/deco/resources/js/deco.core.js
  30. 0  plone/app/deco/{browser/javascripts → resources/js}/deco.editor.js
  31. 0  plone/app/deco/{browser/javascripts → resources/js}/deco.layout.js
  32. 0  plone/app/deco/{browser/javascripts → resources/js}/deco.overlay.js
  33. 0  plone/app/deco/{browser/javascripts → resources/js}/deco.overlaytriggers.js
  34. 0  plone/app/deco/{browser/javascripts → resources/js}/deco.toolbar.js
  35. 0  plone/app/deco/{browser/javascripts → resources/js}/deco.undo.js
  36. 0  plone/app/deco/{browser/javascripts → resources/js}/deco.upload.js
  37. 0  plone/app/deco/{browser/javascripts/tinymce → resources/js}/tiny_mce_deco.js
  38. 0  plone/app/deco/{browser/javascripts/tinymce → resources/js}/tiny_mce_deco_src.js
  39. +8 −8 plone/app/deco/tests/test_decoregistry.py
View
1  .gitignore
@@ -4,3 +4,4 @@
plone.app.deco.egg-info/
build/
+plone/app/deco/resources/js/source/
View
36 plone/app/deco/browser/browser.py
@@ -6,7 +6,7 @@
import simplejson as json
from plone.registry.interfaces import IRegistry
-from plone.app.deco.interfaces import IDecoRegistryAdapter
+from plone.app.deco.interfaces import IDecoRegistry
from Products.CMFCore.utils import getToolByName
from plone.app.deco import PloneMessageFactory as _
@@ -110,37 +110,3 @@ def cleanupFilename(self, name):
and getattr(context, newid, None) is None:
return newid
count += 1
-
-
-class DecoConfigView(BrowserView):
-
- def obtainType(self):
- """
- Obtains the type of the context object or of the object we are adding
- """
- if 'type' in self.request.form:
- return self.request.form['type']
- else:
- if hasattr(self.context, 'portal_type'):
- return self.context.portal_type
- return None
-
- def __call__(self):
- self.request.response.setHeader('Content-Type', 'application/json')
- registry = getUtility(IRegistry)
- adapted = IDecoRegistryAdapter(registry)
- pm = getToolByName(self.context, 'portal_membership')
- kwargs = {
- 'type': self.obtainType(),
- 'context': self.context,
- 'request': self.request,
- }
- result = adapted(**kwargs)
- can_change_layout = pm.checkPermission('Plone: Change Deco Layout', self.context)
- result['can_change_layout'] = bool(can_change_layout)
- if not can_change_layout:
- if 'insert' in result['default_available_actions']:
- result['default_available_actions'].remove('insert')
- if 'add-tile' in result['default_available_actions']:
- result['default_available_actions'].remove('add-tile')
- return json.dumps(result)
View
6 plone/app/deco/browser/config.pt
@@ -0,0 +1,6 @@
+<script type="text/javascript"
+ tal:define="view context/@@deco-config"
+ tal:content="structure python:
+ '$.deco = $.deco || {};' +
+ '$.deco.options = ' + view.config + ';'">
+</script>
View
61 plone/app/deco/browser/config.py
@@ -0,0 +1,61 @@
+
+try:
+ import json
+except:
+ import simplejson as json
+
+from zope.component import getUtility
+from zope.publisher.browser import BrowserView
+from plone.registry.interfaces import IRegistry
+from plone.app.deco.interfaces import IDecoRegistry
+from Products.CMFCore.utils import getToolByName
+
+
+class DecoConfigView(BrowserView):
+
+ # TODO: this should move to DecoRegistry
+ def _type(self):
+ """ Obtains the type of the context object or of the object we are
+ adding.
+ """
+
+ if '++add++' in self.request.getURL():
+ return self.request.getURL().split('++add++')[1]
+
+ else:
+ if hasattr(self.context, 'portal_type'):
+ return self.context.portal_type
+
+ return None
+
+ @property
+ def config(self):
+ registry = IDecoRegistry(getUtility(IRegistry))
+ config = registry(**{
+ 'type': self._type(),
+ 'context': self.context,
+ 'request': self.request,
+ })
+
+ # does user have permission to change layout
+ membership = getToolByName(self.context, 'portal_membership')
+ can_change_layout = membership.checkPermission(
+ 'Plone: Change Deco Layout', self.context)
+
+ # remove add-tile and insert action from config if user doesn't have
+ # permission to change layout
+ config['can_change_layout'] = bool(can_change_layout)
+ if not can_change_layout:
+ if 'insert' in config['default_available_actions']:
+ config['default_available_actions'].remove('insert')
+ if 'add-tile' in config['default_available_actions']:
+ config['default_available_actions'].remove('add-tile')
+
+ return json.dumps(config)
+
+
+class DecoConfigJSONView(DecoConfigView):
+
+ def __call__(self):
+ self.request.response.setHeader('Content-Type', 'application/json')
+ return self.config
View
39 plone/app/deco/browser/configure.zcml
@@ -3,32 +3,22 @@
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:plone="http://namespaces.plone.org/plone"
i18n_domain="plone">
-
+
<include file="widget.zcml" />
-
- <!-- Resources -->
-
- <browser:resourceDirectory
- name="plone.app.deco.stylesheets"
- directory="stylesheets"
- />
- <browser:resourceDirectory
- name="plone.app.deco.images"
- directory="images"
- />
+ <!-- Deco support views -->
- <browser:resourceDirectory
- name="plone.app.deco.javascripts"
- directory="javascripts"
+ <browser:page
+ for="*"
+ name="deco-config"
+ class=".config.DecoConfigView"
+ permission="cmf.ModifyPortalContent"
/>
- <!-- Deco support views -->
-
<browser:page
for="*"
- name="deco-config"
- class=".browser.DecoConfigView"
+ name="deco-config.json"
+ class=".config.DecoConfigJSONView"
permission="cmf.ModifyPortalContent"
/>
@@ -39,4 +29,15 @@
permission="cmf.ModifyPortalContent"
/>
+ <!-- Viewlets -->
+
+ <browser:viewlet
+ name="plone.deco.config"
+ for="*"
+ manager="plone.app.layout.viewlets.interfaces.IPortalTop"
+ template="config.pt"
+ class="plone.app.layout.viewlets.common.ViewletBase"
+ permission="cmf.ModifyPortalContent"
+ />
+
</configure>
View
415 plone/app/deco/browser/javascripts/deco.core.js
@@ -1,415 +0,0 @@
-/**
- * This plugin is used to define the deco namespace
- *
- * @author Rob Gietema
- * @licstart The following is the entire license notice for the JavaScript
- * code in this page.
- *
- * Copyright (C) 2010 Plone Foundation
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * @licend The above is the entire license notice for the JavaScript code in
- * this page.
- * @version 0.1
- */
-"use strict";
-
-/*global tiledata: false, jQuery: false, window: false */
-/*jslint white: true, browser: true, onevar: true, undef: true, nomen: true,
-eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true,
-immed: true, strict: true, maxlen: 80, maxerr: 9999 */
-
-(function ($) {
-
- // Create the deco namespace
- $.deco = {
- "loaded": false,
- "nrOfTiles": 0,
- "tileInitCount": 0
- };
-
- /**
- * Called upon full initialization (that is: when all tiles have
- * been loaded).
- * @id jQuery.deco.initialized
- */
- $.deco.initialized = function () {
- if ($.deco.loaded) {
- return;
- }
- $.deco.loaded = true;
-
- // Take first snapshot
- $.deco.undo.snapshot();
- };
-
- /**
- * Initialize the Deco UI
- *
- * @id jQuery.deco.init
- * @param {Object} options Options used to initialize the UI
- */
- $.deco.init = function (options) {
- options = $.extend({
- url: window.parent.document.location.href,
- type: '',
- ignore_context: false
- }, options);
-
- // Set document
- $.deco.document = window.parent.document;
-
- // Local variables
- var match;
-
- // Initialize modules
- $.deco.initActions();
-
- // Get the url of the page
- match = options.url.match(/^([\w#!:.?+=&%@!\-\/]+)\/edit$/);
- if (match) {
- options.url = match[1];
- }
-
- // Chop add
- match = options.url.match(/^([\w#:.?=%@!\-\/]+)\/\+\+add\+\+([\w#!:.?+=&%@!\-\/]+)$/);
- if (match) {
- options.url = match[1];
- options.type = match[2];
- options.ignore_context = true;
- }
-
- // Get the configuration from the backend
- $.ajax({
- type: "GET",
- url: options.url + "/@@deco-config" +
- (options.type === '' ? '' : "?type=" + options.type),
- success: function (configdata) {
-
- // Local variables
- var content;
-
- // Add global options
- $.deco.options = configdata;
- $.deco.options.url = options.url;
- $.deco.options.ignore_context = options.ignore_context;
- $.deco.options.tileheadelements = [];
-
- // Get the layout
- $.deco.formdocument = document;
- content = $('#form-widgets-ILayoutAware-content').val();
- if (!content) {
- // try the parent frame
- $.deco.formdocument = $.deco.document;
- content = window.parent.jQuery('#form-widgets-ILayoutAware-content').val();
-
- if (content === '') {
- // Exit
- return;
- }
- }
-
- // Get dom tree
- content = $.deco.getDomTreeFromHtml(content);
- $.deco.options.layout = content.attr('data-layout');
- // Find panels
- content.find("[data-panel]").each(function () {
-
- // Local variables
- var panel_id = $(this).attr("data-panel"),
- target = $("[data-panel=" + panel_id + "]",
- $.deco.document);
-
- // If it's the content panel and the form is in the main frame,
- // create a new div to replace the form
- var content_panel = content.find("[data-panel=" + panel_id + "]");
- if (panel_id === 'content' && $.deco.document == $.deco.formdocument) {
- $("#content", $.deco.document).addClass('deco-original-content');
- $("#content", $.deco.document).before(
- $($.deco.document.createElement("div")).attr({
- 'id': 'content',
- 'data-panel': content_panel.attr("data-panel")
- }).addClass('deco-panel').html(content_panel.html()));
- } else {
- target.addClass('deco-panel');
- target.html(content_panel.html());
- }
- });
-
- // Init app tiles
- $.deco.options.panels = $(".deco-panel", $.deco.document);
- $.deco.nrOfTiles =
- $.deco.options.panels.find("[data-tile]").size();
-
- $.deco.options.panels.find("[data-tile]").each(function () {
-
- // Local variables
- var target, href, tile_content, tiletype, classes, url,
- tile_config, x, tile_group, y, fieldhtml, lines, i;
-
- href = $(this).attr("data-tile");
-
- // Get tile type
- tile_content = $(this).parent();
- tiletype = '';
- classes = tile_content.parents('.deco-tile').attr('class').split(" ");
- $(classes).each(function () {
-
- // Local variables
- var classname;
-
- classname = this.match(/^deco-([\w.\-]+)-tile$/);
- if (classname !== null) {
- if ((classname[1] !== 'selected') &&
- (classname[1] !== 'new') &&
- (classname[1] !== 'read-only') &&
- (classname[1] !== 'helper') &&
- (classname[1] !== 'original')) {
- tiletype = classname[1];
- }
- }
- });
-
- // Get tile config
- for (x = 0; x < $.deco.options.tiles.length; x += 1) {
- tile_group = $.deco.options.tiles[x];
- for (y = 0; y < tile_group.tiles.length; y += 1) {
-
- // Set settings value
- if (tile_group.tiles[y].tile_type === 'field') {
- switch (tile_group.tiles[y].widget) {
- case "z3c.form.browser.text.TextWidget":
- case "z3c.form.browser.text.TextFieldWidget":
- case "z3c.form.browser.textarea.TextAreaWidget":
- case "z3c.form.browser.textarea.TextAreaFieldWidget":
- case "plone.app.z3cform.wysiwyg.widget.WysiwygWidget":
- case "plone.app.z3cform.wysiwyg.widget.WysiwygFieldWidget":
- tile_group.tiles[y].settings = false;
- break;
- default:
- tile_group.tiles[y].settings = true;
- break;
- }
- }
- if (tile_group.tiles[y].name === tiletype) {
- tile_config = tile_group.tiles[y];
- }
- }
- }
-
- // Check if a field tile
- if (tile_config.tile_type === 'field') {
-
- fieldhtml = '';
-
- switch (tile_config.widget) {
- case "z3c.form.browser.text.TextWidget":
- case "z3c.form.browser.text.TextFieldWidget":
- fieldhtml = '<div>' +
- $("#" + tile_config.id, $.deco.formdocument).find('input').attr('value') + '</div>';
- break;
- case "z3c.form.browser.textarea.TextAreaWidget":
- case "z3c.form.browser.textarea.TextAreaFieldWidget":
- lines = $("#" + tile_config.id, $.deco.formdocument).find('textarea').attr('value').split('\n');
- for (i = 0; i < lines.length; i += 1) {
- fieldhtml += '<div>' + lines[i] + '</div>';
- }
- break;
- case "plone.app.z3cform.wysiwyg.widget.WysiwygWidget":
- case "plone.app.z3cform.wysiwyg.widget.WysiwygFieldWidget":
- fieldhtml = $("#" + tile_config.id, $.deco.formdocument).find('textarea').attr('value');
- break;
- default:
- fieldhtml = '<div class="discreet">Placeholder ' +
- 'for field:<br/><b>' + tile_config.label +
- '</b></div>';
- break;
- }
- tile_content.html(fieldhtml);
-
- // Get data from app tile
- } else {
- url = href;
- if (tile_config.name ===
- 'plone.app.deco.title' ||
- tile_config.name ===
- 'plone.app.deco.description') {
- url += '?ignore_context=' +
- $.deco.options.ignore_context;
- }
- $.ajax({
- type: "GET",
- url: url,
- success: function (value) {
-
- // Get dom tree
- value = $.deco.getDomTreeFromHtml(value);
-
- // Add head tags
- $.deco.addHeadTags(href, value);
-
- tile_content.html('<p class="hiddenStructure ' +
- 'tileUrl">' + href + '</p>' +
- value.find('.temp_body_tag').html());
-
- $.deco.tileInitCount += 1;
-
- if ($.deco.tileInitCount >= $.deco.nrOfTiles) {
- $.deco.initialized();
- }
- }
- });
- }
- });
-
- // Init overlay
- if ($.deco.document == $.deco.formdocument) {
- $('#content.deco-original-content',
- $.deco.document).decoOverlay().addClass('overlay');
- }
-
- // Hide toolbar
- // XXX: not really nice to hide it here
- $('.toolbar .toolbarleft > *').remove();
- $('.toolbar').removeClass('toolbarglobal').addClass('toolbarlocal');
-
- // Add toolbar div below menu
- $(".toolbar .toolbarleft").addClass("deco-toolbar");
-
- // Add the toolbar to the options
- $.deco.options.toolbar = $(".deco-toolbar");
-
- // Add page url to the options
- $.deco.options.url = options.url;
-
- // Init toolbar
- $.deco.options.toolbar.decoToolbar();
-
- // Init panel
- $.deco.options.panels.decoLayout();
-
- // Add blur to the rest of the content using jQT expose
- // XXX: window.parent.$ !== $; this may need refactoring
- window.parent.$($.deco.options.panels).expose({
- closeOnEsc: false,
- closeOnClick: false
- });
-
- // Init upload
- // $.deco.initUpload();
- $.deco.undo.init();
- }
- });
- };
-
- /**
- * Get the dom tree of the specified content
- *
- * @id jQuery.deco.getDomTreeFromHtml
- * @param {String} content Html content
- * @return {Object} Dom tree of the html
- */
- $.deco.getDomTreeFromHtml = function (content) {
-
- // Remove doctype and replace html, head and body tag since the are
- // stripped when converting to jQuery object
- content = content.replace(/<!DOCTYPE[\w\s\- .\/\":]+>/, '');
- content = content.replace(/<html/, "<div class=\"temp_html_tag\"");
- content = content.replace(/<\/html/, "</div");
- content = content.replace(/<head/, "<div class=\"temp_head_tag\"");
- content = content.replace(/<\/head/, "</div");
- content = content.replace(/<body/, "<div class=\"temp_body_tag\"");
- content = content.replace(/<\/body/, "</div");
- return $($(content)[0]);
- };
-
- /**
- * Remove head tags based on tile url
- *
- * @id jQuery.deco.removeHeadTags
- * @param {String} url Url of the tile
- */
- $.deco.removeHeadTags = function (url) {
-
- // Local variables
- var tile_type_id, html_id, headelements, i;
-
- // Calc delete url
- url = url.split('?')[0];
- url = url.split('@@');
- tile_type_id = url[1].split('/');
- url = url[0] + '@@delete-tile?type=' + tile_type_id[0] + '&id=' +
- tile_type_id[1] + '&confirm=true';
- html_id = tile_type_id[0].replace(/\./g, '-') + '-' + tile_type_id[1];
-
- // Remove head elements
- headelements = $.deco.options.tileheadelements[html_id];
- for (i = 0; i < headelements.length; i += 1) {
- $(headelements[i], $.deco.document).remove();
- }
- $.deco.options.tileheadelements[html_id] = [];
- };
-
- /**
- * Add head tags based on tile url and dom
- *
- * @id jQuery.deco.addHeadTags
- * @param {String} url Url of the tile
- * @param {Object} dom Dom object of the tile
- */
- $.deco.addHeadTags = function (url, dom) {
-
- // Local variables
- var tile_type_id, html_id;
-
- // Calc url
- url = url.split('?')[0];
- url = url.split('@@');
- tile_type_id = url[1].split('/');
- html_id = tile_type_id[0].replace(/\./g, '-') + '-' + tile_type_id[1];
- $.deco.options.tileheadelements[html_id] = [];
-
- // Get head items
- dom.find(".temp_head_tag").children().each(function () {
-
- // Add element
- $.deco.options.tileheadelements[html_id].push(this);
-
- // Add head elements
- $('head', $.deco.document).append(this);
- });
- };
-
-}(jQuery));
-
-
-// Deco initialization
-//
-// XXX: maybe this should be done outside this script
-(function() {
-
- var document = window.parent.document;
-
- $(document).ready(function () {
-
- var layout = $('#form-widgets-ILayoutAware-content', document);
-
- // Check if layout exists
- if (layout.length > 0) {
- $.deco.init();
- }
- });
-
-})();
View
1  plone/app/deco/browser/javascripts/tinymce/.gitignore
@@ -1 +0,0 @@
-/source/
View
6 plone/app/deco/configure.zcml
@@ -1,5 +1,6 @@
<configure
xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
i18n_domain="plone">
@@ -28,6 +29,11 @@
title="Plone: Change Deco Layout"
/>
+ <browser:resourceDirectory
+ name="plone.app.deco"
+ directory="resources"
+ />
+
<include package=".browser" />
<include package=".tiles" />
View
5 plone/app/deco/interfaces.py
@@ -4,8 +4,9 @@
from plone.app.deco import PloneMessageFactory as _
-class IDecoRegistryAdapter(Interface):
- """Marker interface for the registry adapter"""
+class IDecoRegistry(Interface):
+ """ Marker Interface for registry of deco, wrapper arounf plone.registry
+ """
class IWeightedDict(Interface):
View
21 plone/app/deco/profiles/default/controlpanel.xml
@@ -3,18 +3,15 @@
name="portal_controlpanel"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="plone">
-
- <configlet
- title="Deco"
- action_id="plone.app.deco"
- appId="plone.app.deco"
- category="Plone"
- condition_expr=""
- icon_expr="string:${portal_url}/++resource++plone.app.deco.images/deco_icon.gif"
+
+ <configlet title="Deco" action_id="plone.app.deco" appId="plone.app.deco"
+ category="Plone" condition_expr="" visible="False"
url_expr="string:${portal_url}/@@deco-controlpanel"
- visible="False"
+ icon_expr="string:${portal_url}/++resource++plone.app.deco/images/deco_icon.gif"
i18n:attributes="title">
- <permission>Manage portal</permission>
- </configlet>
-</object>
+ <permission>Manage portal</permission>
+
+ </configlet>
+
+</object>
View
17 plone/app/deco/profiles/default/cssregistry.xml
@@ -1,17 +1,10 @@
<?xml version="1.0"?>
<object name="portal_css">
- <stylesheet title=""
- id="++resource++plone.app.deco.stylesheets/authoring.css"
- bundle="default"
- applyPrefix="true"
- media="screen"
- rel="stylesheet"
- rendering="import"
- cacheable="True"
- compression="safe"
- cookable="True"
- enabled="1"
- expression=""/>
+ <!-- TODO: not sure we need this, for sure we can give it better name :P -->
+ <!--stylesheet title="" bundle="default" applyPrefix="true" media="screen"
+ rel="stylesheet" rendering="import" cacheable="True" compression="safe"
+ cookable="True" enabled="1" expression=""
+ id="++resource++plone.app.deco/css/authoring.css" /-->
</object>
View
100 plone/app/deco/profiles/default/jsregistry.xml
@@ -1,84 +1,44 @@
<?xml version="1.0"?>
<object name="portal_javascripts" meta_type="JavaScripts Registry">
- <javascript cacheable="False"
- compression="none"
- cookable="False"
- enabled="True"
- id="++resource++plone.app.deco.javascripts/deco.core.js"
- bundle="deco"
- inline="False"/>
+ <javascript cacheable="False" compression="none" cookable="False"
+ bundle="deco" inline="False" enabled="True"
+ id="++resource++plone.app.deco/js/deco.core.js" />
- <javascript cacheable="False"
- compression="none"
- cookable="False"
- enabled="True"
- id="++resource++plone.app.deco.javascripts/deco.overlay.js"
- bundle="deco"
- inline="False"/>
+ <javascript cacheable="False" compression="none" cookable="False"
+ enabled="True" bundle="deco" inline="False"
+ id="++resource++plone.app.deco/js/deco.overlay.js" />
- <javascript cacheable="False"
- compression="none"
- cookable="False"
- enabled="True"
- id="++resource++plone.app.deco.javascripts/deco.layout.js"
- bundle="deco"
- inline="False"/>
+ <javascript cacheable="False" compression="none" cookable="False"
+ enabled="True" bundle="deco" inline="False"
+ id="++resource++plone.app.deco/js/deco.layout.js"/>
- <javascript cacheable="False"
- compression="none"
- cookable="False"
- enabled="True"
- id="++resource++plone.app.deco.javascripts/deco.toolbar.js"
- bundle="deco"
- inline="False"/>
+ <javascript cacheable="False" compression="none" cookable="False"
+ enabled="True" bundle="deco" inline="False"
+ id="++resource++plone.app.deco/js/deco.toolbar.js"/>
- <javascript cacheable="False"
- compression="none"
- cookable="False"
- enabled="True"
- id="++resource++plone.app.deco.javascripts/deco.actions.js"
- bundle="deco"
- inline="False"/>
+ <javascript cacheable="False" compression="none" cookable="False"
+ enabled="True" bundle="deco" inline="False"
+ id="++resource++plone.app.deco/js/deco.actions.js"/>
- <javascript cacheable="False"
- compression="none"
- cookable="False"
- enabled="True"
- id="++resource++plone.app.deco.javascripts/deco.upload.js"
- bundle="deco"
- inline="False"/>
+ <javascript cacheable="False" compression="none" cookable="False"
+ enabled="True" bundle="deco" inline="False"
+ id="++resource++plone.app.deco/js/deco.upload.js"/>
- <javascript cacheable="False"
- compression="none"
- cookable="False"
- enabled="True"
- id="++resource++plone.app.deco.javascripts/deco.undo.js"
- bundle="deco"
- inline="False"/>
+ <javascript cacheable="False" compression="none" cookable="False"
+ enabled="True" bundle="deco" inline="False"
+ id="++resource++plone.app.deco/js/deco.undo.js"/>
- <javascript cacheable="False"
- compression="none"
- cookable="False"
- enabled="True"
- id="++resource++plone.app.deco.javascripts/deco.editor.js"
- bundle="deco"
- inline="False"/>
+ <javascript cacheable="False" compression="none" cookable="False"
+ enabled="True" bundle="deco" inline="False"
+ id="++resource++plone.app.deco/js/deco.editor.js"/>
- <javascript cacheable="False"
- compression="none"
- cookable="False"
- enabled="True"
- id="++resource++plone.app.deco.javascripts/deco.overlaytriggers.js"
- bundle="default"
- inline="False"/>
+ <javascript cacheable="False" compression="none" cookable="False"
+ enabled="True" bundle="default" inline="False"
+ id="++resource++plone.app.deco/js/deco.overlaytriggers.js"/>
- <javascript cacheable="False"
- compression="none"
- cookable="False"
- enabled="True"
- id="++resource++plone.app.deco.javascripts/tinymce/tiny_mce_deco_src.js"
- bundle="default"
- inline="False"/>
+ <javascript cacheable="False" compression="none" cookable="False"
+ enabled="True" bundle="default" inline="False"
+ id="++resource++plone.app.deco/js/tiny_mce_deco_src.js"/>
</object>
View
10 plone/app/deco/profiles/default/viewlets.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<object>
+
+ <order manager="plone.portaltop" skinname="Sunburst Theme">
+ <viewlet name="plone.toolbar.toolbarlink"/>
+ <viewlet name="plone.deco.config"/>
+ <viewlet name="plone.header"/>
+ </order>
+
+</object>
View
4 plone/app/deco/registry.py
@@ -2,7 +2,7 @@
from zope.i18n import translate
from zope.interface import implements
from plone.registry.interfaces import IRegistry
-from plone.app.deco.interfaces import IDecoRegistryAdapter
+from plone.app.deco.interfaces import IDecoRegistry
from plone.dexterity.utils import iterSchemataForType
from Products.CMFCore.interfaces._content import IFolderish
from operator import itemgetter
@@ -47,7 +47,7 @@ def weightedSort(x, y):
class DecoRegistry(object):
"""Adapts a registry object to parse the deco settings data"""
- implements(IDecoRegistryAdapter)
+ implements(IDecoRegistry)
adapts(IRegistry)
prefix = "plone.app.deco"
View
0  plone/app/deco/browser/stylesheets/authoring.css → plone/app/deco/resources/css/authoring.css
File renamed without changes
View
0  plone/app/deco/browser/images/deco_icon.gif → plone/app/deco/resources/images/deco_icon.gif
File renamed without changes
View
0  plone/app/deco/browser/images/divider_horizontal.png → .../app/deco/resources/images/divider_horizontal.png
File renamed without changes
View
0  plone/app/deco/browser/images/divider_vertical.png → plone/app/deco/resources/images/divider_vertical.png
File renamed without changes
View
0  plone/app/deco/browser/images/files.png → plone/app/deco/resources/images/files.png
File renamed without changes
View
0  plone/app/deco/browser/images/icons.png → plone/app/deco/resources/images/icons.png
File renamed without changes
View
0  plone/app/deco/browser/images/image-placeholder.png → ...e/app/deco/resources/images/image-placeholder.png
File renamed without changes
View
0  plone/app/deco/browser/images/label.png → plone/app/deco/resources/images/label.png
File renamed without changes
View
0  plone/app/deco/browser/images/loading.gif → plone/app/deco/resources/images/loading.gif
File renamed without changes
View
0  plone/app/deco/browser/images/toolbar.png → plone/app/deco/resources/images/toolbar.png
File renamed without changes
View
0  plone/app/deco/browser/images/window.png → plone/app/deco/resources/images/window.png
File renamed without changes
View
0  plone/app/deco/browser/javascripts/tinymce/Makefile → plone/app/deco/resources/js/Makefile
File renamed without changes
View
0  plone/app/deco/browser/javascripts/tinymce/build.xml → plone/app/deco/resources/js/build.xml
File renamed without changes
View
0  plone/app/deco/browser/javascripts/deco.actions.js → plone/app/deco/resources/js/deco.actions.js
File renamed without changes
View
370 plone/app/deco/resources/js/deco.core.js
@@ -0,0 +1,370 @@
+/**
+ * This plugin is used to define the deco namespace
+ *
+ * @author Rob Gietema
+ * @licstart The following is the entire license notice for the JavaScript
+ * code in this page.
+ *
+ * Copyright (C) 2010 Plone Foundation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * @licend The above is the entire license notice for the JavaScript code in
+ * this page.
+ * @version 0.1
+ */
+"use strict";
+
+/*global tiledata: false, jQuery: false, window: false */
+/*jslint white: true, browser: true, onevar: true, undef: true, nomen: true,
+eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true,
+immed: true, strict: true, maxlen: 80, maxerr: 9999 */
+
+(function ($) {
+
+ // # Namespace
+ $.deco = $.deco || {};
+
+ // TODO: docs needed what each variable does
+ $.deco.loaded = false;
+
+
+ /**
+ * Called upon full initialization (that is: when all tiles have
+ * been loaded).
+ * @id jQuery.deco.initialized
+ */
+ $.deco.initialized = function () {
+ if ($.deco.loaded) {
+ return;
+ }
+ $.deco.loaded = true;
+
+ // Take first snapshot
+ //$.deco.undo.snapshot();
+ };
+
+ // # Initialize the Deco UI
+ //
+ // @id jQuery.deco.init
+ // @param {Object} options Options used to initialize the UI
+ $.deco.init = function (layout_el, options) {
+
+ // merging options
+ $.deco.options = $.extend({
+ window: window.parent,
+ document: window.parent.document,
+ tileheadelements: []
+ }, options);
+
+
+ // ## Tiles - by name - and their configuration
+ // TODO: tiles passed in options should be flat list
+ $.deco.tiles = {};
+ $.deco.tiles_categories = {};
+ $.each($.deco.options.tiles, function(index, tile_category) {
+ $.deco.tiles_categories[tile_category.name] = tile_category;
+ $.each(tile_category.tiles, function(index, tile_options) {
+ $.deco.tiles[tile_options.name] = tile_options;
+ });
+ });
+
+
+ // ## Layout
+ $.deco.layout = {
+ raw_el: layout_el,
+ el: $.deco.utils.getDomTreeFromHtml(layout_el.val())
+ };
+
+ // ### Layout name
+ $.deco.layout.name = $.deco.layout.el.attr('data-layout');
+
+ // ### Layout panels
+ $.deco.layout.panels = {};
+ $.deco.layout.el.find("[data-panel]").each(function () {
+
+ var panel_id = $(this).attr("data-panel"),
+ panel_el = $("[data-panel=" + panel_id + "]", $.deco.options.document),
+ panel_content = $.deco.layout.el.find("[data-panel=" + panel_id + "]");
+
+ if (panel_el.length === 0) {
+ $.deco.layout.raw_el.hide();
+ panel_el = $('<div class="deco-panel" data-panel="' + panel_id + '"></div>');
+ panel_el.html(panel_content.html());
+ $.deco.layout.raw_el.after(panel_el);
+ // TODO: should this be initialized here?
+ // Init overlay
+ // if ($.deco.document == $.deco.formdocument) {
+ // $('#content.deco-original-content',
+ // $.deco.document).decoOverlay().addClass('overlay');
+ // }
+
+ } else {
+ panel_el.addClass('deco-panel');
+ panel_el.html(panel.html());
+ }
+
+ $.deco.layout.panels[panel_id] = {
+ el: panel_el,
+ tiles: []
+ };
+
+ // Panel Tiles
+ panel_el.find("[data-tile]").each(function () {
+
+ // Tile name
+ //
+ // TODO: tile name should be passed as "data-tile-name"
+ // attribute so we can avoid this magic.
+ var tile_name = '';
+ $($(this).parents('.deco-tile').attr('class').split(" ")).each(function (index, klass) {
+ var type_from_klass = klass.match(/^deco-([\w.\-]+)-tile$/);
+ if ((type_from_klass !== null) &&
+ (type_from_klass[1] !== 'selected') &&
+ (type_from_klass[1] !== 'new') &&
+ (type_from_klass[1] !== 'read-only') &&
+ (type_from_klass[1] !== 'helper') &&
+ (type_from_klass[1] !== 'original')) {
+ tile_name = type_from_klass[1];
+ }
+ });
+
+ // Tile configuration
+ var tile = $.extend({
+ label: '',
+ value: '',
+ url: $(this).attr("data-tile")
+ }, $.deco.tiles[tile_name]);
+
+ // Tile value / content
+ //
+ // TODO: below solution is not really nice, since we will need
+ // to change deco code for each new widget. also its impossible
+ // to use deco outside plone because of this specific
+ if ((tile.value === undefined) ||
+ tile.value === '') {
+
+ if (tile.tile_type === 'field') {
+
+ var tile_field = $("#" + tile.id, $.deco.document);
+
+ switch (tile.widget) {
+
+ case "z3c.form.browser.text.TextWidget":
+ case "z3c.form.browser.text.TextFieldWidget":
+ tile.value = tile_field.find('input').attr('value');
+ break;
+
+ case "z3c.form.browser.textarea.TextAreaWidget":
+ case "z3c.form.browser.textarea.TextAreaFieldWidget":
+ var lines = tile_field.find('textarea').attr('value').split('\n');
+ for (var i = 0; i < lines.length; i += 1) {
+ tile.value += '<p>' + lines[i] + '<p>';
+ }
+ break;
+
+ case "plone.app.z3cform.wysiwyg.widget.WysiwygWidget":
+ case "plone.app.z3cform.wysiwyg.widget.WysiwygFieldWidget":
+ tile.value = tile_field.find('textarea').attr('value');
+ break;
+
+ default:
+ tile_field = '' +
+ '<div class="discreet">' +
+ 'Placeholder for field:<br/>' +
+ '<b>' + tile.label + '</b>' +
+ '</div>';
+ break;
+ }
+
+ tile.value = '<div>' + tile.value + '</div>';
+
+ // Get data from app tile
+ } else {
+
+ var url = tile.url;
+ if ((tile.name === 'plone.app.deco.title') ||
+ (tile.name === 'plone.app.deco.description')) {
+ url += '?ignore_context=' + $.deco.options.ignore_context;
+ }
+
+ $.ajax({
+ type: "GET",
+ url: url,
+ success: function (value) {
+
+ // Get dom tree
+ var tile_domtree = $.deco.utils.getDomTreeFromHtml(value);
+
+ // Add head tags
+ $.deco.utils.addHeadTags(tile.url, tile_domtree);
+
+ // TODO: are we sure there is no better way to pass
+ // tileUrl?
+ tile.value = '' +
+ '<p class="hiddenStructure tileUrl">' +
+ tile.url +
+ '</p>' +
+ tile_domtree.find('.temp_body_tag').html();
+
+ }
+ });
+
+ }
+
+ }
+
+ // set value of tile
+ $(this).html(tile.value);
+
+ // add tile to panel list
+ $.deco.layout.panels[panel_id].tiles.push(tile);
+
+ });
+
+ });
+
+
+ // TODO: this should be part of deco.actions.js script
+ //$.deco.loaded(function(e) {
+ //
+ // // hide toolbar-left and show toolbar-deco
+ // $('.toolbar-left').hide();
+ // $('.toolbar-deco').show();
+
+ // // Add blur to the rest of the content using jQT expose
+ // // XXX: window.parent.$ !== $; this may need refactoring
+ // window.parent.$($.deco.options.panels).expose({
+ // closeOnEsc: false,
+ // closeOnClick: false
+ // });
+
+ //});
+
+ // TODO: at some point we have to call this this should trigger
+ // 'decoLoaded' event then other scripts could register to this event
+ // via $.deco.loaded
+ $.deco.initialized();
+
+ // Init panel
+ // TODO: need to check what this does
+ //$.deco.options.panels.decoLayout();
+ //$.deco.undo.init();
+
+ };
+
+
+
+ // # Utils
+
+ // ## Utils namespace
+ $.deco.utils = $.deco.utils || {};
+
+
+ // ## Get the dom tree of the specified content
+ //
+ // Remove doctype and replace html, head and body tag since the are
+ // stripped when converting to jQuery object
+ //
+ // @id jQuery.deco.getDomTreeFromHtml
+ // @param {String} content Html content
+ // @return {Object} Dom tree of the html
+ //
+ $.deco.utils.getDomTreeFromHtml = function (content) {
+ content = content.replace(/<!DOCTYPE[\w\s\- .\/\":]+>/, '');
+ content = content.replace(/<html/, "<div class=\"temp_html_tag\"");
+ content = content.replace(/<\/html/, "</div");
+ content = content.replace(/<head/, "<div class=\"temp_head_tag\"");
+ content = content.replace(/<\/head/, "</div");
+ content = content.replace(/<body/, "<div class=\"temp_body_tag\"");
+ content = content.replace(/<\/body/, "</div");
+ return $($(content)[0]);
+ };
+
+ // ## Remove head tags based on tile url
+ //
+ // @id jQuery.deco.removeHeadTags
+ // @param {String} url Url of the tile
+ //
+ $.deco.utils.removeHeadTags = function (url) {
+
+ // Local variables
+ var tile_type_id, html_id, headelements, i;
+
+ // Calc delete url
+ url = url.split('?')[0];
+ url = url.split('@@');
+ tile_type_id = url[1].split('/');
+ url = url[0] + '@@delete-tile?type=' + tile_type_id[0] + '&id=' +
+ tile_type_id[1] + '&confirm=true';
+ html_id = tile_type_id[0].replace(/\./g, '-') + '-' + tile_type_id[1];
+
+ // Remove head elements
+ headelements = $.deco.options.tileheadelements[html_id];
+ for (i = 0; i < headelements.length; i += 1) {
+ $(headelements[i], $.deco.document).remove();
+ }
+ $.deco.options.tileheadelements[html_id] = [];
+
+ };
+
+ // ## Add head tags based on tile url and dom
+ //
+ // @id jQuery.deco.addHeadTags
+ // @param {String} url Url of the tile
+ // @param {Object} dom Dom object of the tile
+ //
+ $.deco.utils.addHeadTags = function (url, dom) {
+
+ // Local variables
+ var tile_type_id, html_id;
+
+ // Calc url
+ url = url.split('?')[0];
+ url = url.split('@@');
+ tile_type_id = url[1].split('/');
+ html_id = tile_type_id[0].replace(/\./g, '-') + '-' + tile_type_id[1];
+ $.deco.options.tileheadelements[html_id] = [];
+
+ // Get head items
+ dom.find(".temp_head_tag").children().each(function () {
+
+ // Add element
+ $.deco.options.tileheadelements[html_id].push(this);
+
+ // Add head elements
+ $('head', $.deco.document).append(this);
+ });
+ };
+
+}(jQuery));
+
+
+// Deco initialization
+//
+// XXX: this should be done outside this script
+$(document).ready(function () {
+
+ var layout = $('#form-widgets-ILayoutAware-content',
+ window.parent.document);
+
+ // Check if layout exists
+ if (layout.length > 0) {
+
+ // initialize deco
+ $.deco.init(layout, window.parent.$.deco.options);
+
+ }
+
+});
View
0  plone/app/deco/browser/javascripts/deco.editor.js → plone/app/deco/resources/js/deco.editor.js
File renamed without changes
View
0  plone/app/deco/browser/javascripts/deco.layout.js → plone/app/deco/resources/js/deco.layout.js
File renamed without changes
View
0  plone/app/deco/browser/javascripts/deco.overlay.js → plone/app/deco/resources/js/deco.overlay.js
File renamed without changes
View
0  .../deco/browser/javascripts/deco.overlaytriggers.js → plone/app/deco/resources/js/deco.overlaytriggers.js
File renamed without changes
View
0  plone/app/deco/browser/javascripts/deco.toolbar.js → plone/app/deco/resources/js/deco.toolbar.js
File renamed without changes
View
0  plone/app/deco/browser/javascripts/deco.undo.js → plone/app/deco/resources/js/deco.undo.js
File renamed without changes
View
0  plone/app/deco/browser/javascripts/deco.upload.js → plone/app/deco/resources/js/deco.upload.js
File renamed without changes
View
0  ...deco/browser/javascripts/tinymce/tiny_mce_deco.js → plone/app/deco/resources/js/tiny_mce_deco.js
File renamed without changes
View
0  .../browser/javascripts/tinymce/tiny_mce_deco_src.js → plone/app/deco/resources/js/tiny_mce_deco_src.js
File renamed without changes
View
16 plone/app/deco/tests/test_decoregistry.py
@@ -2,7 +2,7 @@
from zope.component import getGlobalSiteManager
from plone.registry import Registry
from plone.registry.interfaces import IRegistry
-from plone.app.deco.interfaces import IDecoRegistryAdapter
+from plone.app.deco.interfaces import IDecoRegistry
from plone.app.deco.testing import DECO_INTEGRATION_TESTING
import plone.app.deco.tests.registry_testdata as td
@@ -30,14 +30,14 @@ def createRegistry(self, xml):
def test_format_categories(self):
registry = self.createRegistry(td.xml)
- adapted = IDecoRegistryAdapter(registry)
+ adapted = IDecoRegistry(registry)
settings = adapted.parseRegistry()
config = adapted.mapFormatCategories(settings, {})
self.assertEqual(config, td.parsed_format_categories_data)
def test_formats(self):
registry = self.createRegistry(td.xml)
- adapted = IDecoRegistryAdapter(registry)
+ adapted = IDecoRegistry(registry)
settings = adapted.parseRegistry()
config = adapted.mapFormatCategories(settings, {})
config = adapted.mapFormats(settings, config)
@@ -45,7 +45,7 @@ def test_formats(self):
def test_actions(self):
registry = self.createRegistry(td.xml)
- adapted = IDecoRegistryAdapter(registry)
+ adapted = IDecoRegistry(registry)
settings = adapted.parseRegistry()
config = adapted.mapActions(settings, {})
self.assertEqual(config['primary_actions'],
@@ -55,7 +55,7 @@ def test_actions(self):
def test_tiles_categories(self):
registry = self.createRegistry(td.xml)
- adapted = IDecoRegistryAdapter(registry)
+ adapted = IDecoRegistry(registry)
settings = adapted.parseRegistry()
config = adapted.mapTilesCategories(settings, {})
self.assertEqual(config, td.parsed_tiles_categories_data)
@@ -63,7 +63,7 @@ def test_tiles_categories(self):
def test_structure_tiles(self):
self.maxDiff = None
registry = self.createRegistry(td.xml)
- adapted = IDecoRegistryAdapter(registry)
+ adapted = IDecoRegistry(registry)
settings = adapted.parseRegistry()
config = adapted.mapTilesCategories(settings, {})
config = adapted.mapTiles(settings, config, 'structure_tiles')
@@ -73,7 +73,7 @@ def test_structure_tiles(self):
def test_application_tiles(self):
self.maxDiff = None
registry = self.createRegistry(td.xml)
- adapted = IDecoRegistryAdapter(registry)
+ adapted = IDecoRegistry(registry)
settings = adapted.parseRegistry()
config = adapted.mapTilesCategories(settings, {})
config = adapted.mapTiles(settings, config, 'app_tiles')
@@ -83,5 +83,5 @@ def test_application_tiles(self):
def test_config(self):
"""tests if the parsed registry data is correct"""
registry = self.createRegistry(td.xml)
- settings = IDecoRegistryAdapter(registry)()
+ settings = IDecoRegistry(registry)()
self.assertEqual(settings, td.parsed_data)

No commit comments for this range

Something went wrong with that request. Please try again.