finished new-style skin template structure with main.pt and body.pt
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1304 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
689b6ca34a
commit
fd7c221a2d
8 changed files with 66 additions and 42 deletions
|
@ -40,6 +40,7 @@ from zope.schema.vocabulary import SimpleTerm
|
||||||
from zope.security import canAccess, canWrite
|
from zope.security import canAccess, canWrite
|
||||||
from zope.security.proxy import removeSecurityProxy
|
from zope.security.proxy import removeSecurityProxy
|
||||||
|
|
||||||
|
from cybertools.browser.view import GenericView
|
||||||
from cybertools.relation.interfaces import IRelationRegistry
|
from cybertools.relation.interfaces import IRelationRegistry
|
||||||
from cybertools.typology.interfaces import IType
|
from cybertools.typology.interfaces import IType
|
||||||
from loops.interfaces import IView
|
from loops.interfaces import IView
|
||||||
|
@ -80,13 +81,12 @@ class EditForm(BaseEditForm):
|
||||||
return parentUrl + '/contents.html'
|
return parentUrl + '/contents.html'
|
||||||
|
|
||||||
|
|
||||||
class BaseView(object):
|
class BaseView(GenericView):
|
||||||
|
|
||||||
def __init__(self, context, request):
|
def __init__(self, context, request):
|
||||||
#self.context = context
|
|
||||||
# TODO: get rid of removeSecurityProxy() call
|
# TODO: get rid of removeSecurityProxy() call
|
||||||
|
super(BaseView, self).__init__(context, request)
|
||||||
self.context = removeSecurityProxy(context)
|
self.context = removeSecurityProxy(context)
|
||||||
self.request = request
|
|
||||||
self.setSkin(self.loopsRoot.skinName)
|
self.setSkin(self.loopsRoot.skinName)
|
||||||
|
|
||||||
def setSkin(self, skinName):
|
def setSkin(self, skinName):
|
||||||
|
@ -97,16 +97,6 @@ class BaseView(object):
|
||||||
applySkin(self.request, skin)
|
applySkin(self.request, skin)
|
||||||
self.skin = skin
|
self.skin = skin
|
||||||
|
|
||||||
_controller = None
|
|
||||||
def setController(self, controller):
|
|
||||||
self._controller = controller
|
|
||||||
# this is also the place to register special macros with the controller
|
|
||||||
if getattr(controller, 'skinName', None):
|
|
||||||
self.setSkin(controller.skinName.value)
|
|
||||||
controller.skin = self.skin
|
|
||||||
def getController(self): return self._controller
|
|
||||||
controller = property(getController, setController)
|
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def modified(self):
|
def modified(self):
|
||||||
""" get date/time of last modification
|
""" get date/time of last modification
|
||||||
|
@ -186,18 +176,17 @@ class BaseView(object):
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def inlineEditingActive(self):
|
def inlineEditingActive(self):
|
||||||
|
return False
|
||||||
return self.request.principal.id == 'rootadmin'
|
return self.request.principal.id == 'rootadmin'
|
||||||
# this may depend on system and user settings...
|
# this may depend on system and user settings...
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def inlineEditable(self):
|
def inlineEditable(self):
|
||||||
if not self.inlineEditingActive:
|
return self.inlineEditingActive and canWrite(self.context, 'title')
|
||||||
return False
|
|
||||||
return canWrite(self.context, 'title')
|
|
||||||
|
|
||||||
def inlineEdit(self, id):
|
def inlineEdit(self, id):
|
||||||
return 'return inlineEdit("%s")' %id
|
return 'return inlineEdit("%s", "")' % id
|
||||||
|
|
||||||
|
|
||||||
class LoopsTerms(object):
|
class LoopsTerms(object):
|
||||||
|
|
|
@ -16,6 +16,15 @@
|
||||||
<resource name="loops.css" file="loops.css" />
|
<resource name="loops.css" file="loops.css" />
|
||||||
<resource name="loops.js" file="loops.js" />
|
<resource name="loops.js" file="loops.js" />
|
||||||
|
|
||||||
|
|
||||||
|
<!-- new style pages -->
|
||||||
|
|
||||||
|
<page for="loops.interfaces.INode"
|
||||||
|
name="main.html"
|
||||||
|
class="loops.browser.node.NodeView"
|
||||||
|
permission="zope.Public"
|
||||||
|
/>
|
||||||
|
|
||||||
<!-- macros -->
|
<!-- macros -->
|
||||||
|
|
||||||
<page
|
<page
|
||||||
|
@ -539,6 +548,14 @@
|
||||||
permission="zope.View"
|
permission="zope.View"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<page
|
||||||
|
name="inline_save"
|
||||||
|
for="loops.interfaces.INode"
|
||||||
|
class="loops.browser.node.InlineEdit"
|
||||||
|
attribute="save"
|
||||||
|
permission="zope.View"
|
||||||
|
/>
|
||||||
|
|
||||||
<!-- render file or image assigned to a node as target -->
|
<!-- render file or image assigned to a node as target -->
|
||||||
|
|
||||||
<page
|
<page
|
||||||
|
|
|
@ -22,10 +22,14 @@ function submitReplacing(targetId, formId, actionUrl) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function inlineEdit(id) {
|
function inlineEdit(id, saveUrl) {
|
||||||
var editor = dojo.widget.fromScript("Editor",
|
var editor = dojo.widget.fromScript("Editor",
|
||||||
{items: ["save", "|", "formatblock", "|",
|
{items: ["save", "|", "formatblock", "|",
|
||||||
"insertunorderedlist", "insertorderedlist", "|",
|
"insertunorderedlist", "insertorderedlist", "|",
|
||||||
"bold", "italic", "|", "createLink"]}, dojo.byId(id));
|
"bold", "italic", "|", "createLink", "insertimage"],
|
||||||
|
saveUrl: saveUrl,
|
||||||
|
closeOnSave: true,
|
||||||
|
onSave: function(){this.disableToolbar(true);},
|
||||||
|
}, dojo.byId(id));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
|
|
||||||
|
|
||||||
<metal:settings fill-slot="settings"
|
<metal:settings fill-slot="settings"
|
||||||
tal:define="dummy python:
|
tal:define="dummy python: controller.macros.register('css',
|
||||||
controller.macros.register('css', resourceName='loops.css', media='all');
|
identifier='loops.css', resourceName='loops.css', media='all');
|
||||||
dummy python:
|
dummy python: controller.macros.register('js',
|
||||||
controller.macros.register('js', resourceName='loops.js');
|
identifier='loops.js', resourceName='loops.js');
|
||||||
dummy python:
|
dummy python: controller.macros.register('js',
|
||||||
controller.macros.register('js', resourceName='ajax.dojo/dojo.js');" />
|
identifier='dojo.js', resourceName='ajax.dojo/dojo.js');" />
|
||||||
|
|
||||||
|
|
||||||
<metal:block fill-slot="ecmascript_slot"
|
<metal:block fill-slot="ecmascript_slot"
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
|
|
||||||
<metal:body fill-slot="body">
|
<metal:body fill-slot="body">
|
||||||
<tal:content define="item view/item;
|
<tal:content define="item nocall:view/item;
|
||||||
level level|python: 1;
|
level level|python: 1;
|
||||||
macro item/macro;">
|
macro item/macro;">
|
||||||
<metal:block use-macro="macro" />
|
<metal:block use-macro="macro" />
|
||||||
|
@ -35,9 +35,9 @@
|
||||||
|
|
||||||
<div class="box" metal:fill-slot="navigators">
|
<div class="box" metal:fill-slot="navigators">
|
||||||
<h4>Navigation</h4>
|
<h4>Navigation</h4>
|
||||||
<tal:menu define="item view/menu;
|
<tal:menu define="item nocall:view/menu;
|
||||||
level level|python: 1"
|
level level|python: 1"
|
||||||
condition="item">
|
condition="nocall:item">
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<metal:menu use-macro="views/node_macros/menu" />
|
<metal:menu use-macro="views/node_macros/menu" />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -41,6 +41,7 @@ from zope.security.proxy import removeSecurityProxy
|
||||||
|
|
||||||
from cybertools.ajax import innerHtml
|
from cybertools.ajax import innerHtml
|
||||||
from cybertools.browser import configurator
|
from cybertools.browser import configurator
|
||||||
|
from cybertools.browser.view import GenericView
|
||||||
from cybertools.typology.interfaces import ITypeManager
|
from cybertools.typology.interfaces import ITypeManager
|
||||||
from loops.interfaces import IConcept, IResource, IDocument, IMediaAsset, INode
|
from loops.interfaces import IConcept, IResource, IDocument, IMediaAsset, INode
|
||||||
from loops.interfaces import IViewConfiguratorSchema
|
from loops.interfaces import IViewConfiguratorSchema
|
||||||
|
@ -60,12 +61,19 @@ class NodeView(BaseView):
|
||||||
def macro(self):
|
def macro(self):
|
||||||
return self.template.macros['content']
|
return self.template.macros['content']
|
||||||
|
|
||||||
|
def setupController(self):
|
||||||
|
cm = self.controller.macros
|
||||||
|
cm.register('css', identifier='loops.css',
|
||||||
|
resourceName='loops.css', media='all')
|
||||||
|
cm.register('js', identifier='loops.js', resourceName='loops.js')
|
||||||
|
cm.register('js', identifier='dojo.js', resourceName='ajax.dojo/dojo.js')
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def view(self):
|
def view(self):
|
||||||
viewName = self.request.get('loops.viewName') or self.context.viewName
|
viewName = self.request.get('loops.viewName') or self.context.viewName
|
||||||
if viewName:
|
if viewName:
|
||||||
adapter = component.queryMultiAdapter((self.context, self.request),
|
adapter = component.queryMultiAdapter(
|
||||||
interface.Interface, name=viewName)
|
(self.context, self.request), name=viewName)
|
||||||
if adapter is not None:
|
if adapter is not None:
|
||||||
return adapter
|
return adapter
|
||||||
return self
|
return self
|
||||||
|
@ -265,11 +273,13 @@ class NodeView(BaseView):
|
||||||
target = self.virtualTarget
|
target = self.virtualTarget
|
||||||
return target and target.inlineEditable or False
|
return target and target.inlineEditable or False
|
||||||
|
|
||||||
|
def inlineEdit(self, id):
|
||||||
|
return 'return inlineEdit("%s", "%s/inline_save")' % (id, self.virtualTargetUrl)
|
||||||
|
|
||||||
# inner HTML views
|
# inner HTML views
|
||||||
|
|
||||||
class InlineEdit(NodeView):
|
class InlineEdit(NodeView):
|
||||||
""" Provides inline editor as inner HTML - OBSOLETE, use as an example only!"""
|
""" Provides inline editor as inner HTML"""
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def macro(self):
|
def macro(self):
|
||||||
|
@ -282,6 +292,10 @@ class InlineEdit(NodeView):
|
||||||
def body(self):
|
def body(self):
|
||||||
return self.virtualTargetObject.data
|
return self.virtualTargetObject.data
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
target = self.virtualTargetObject
|
||||||
|
target.data = self.request.form['editorContent']
|
||||||
|
|
||||||
|
|
||||||
# special (named) views for nodes
|
# special (named) views for nodes
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
tal:content="structure body">
|
tal:content="structure body">
|
||||||
The body
|
The body
|
||||||
</div>
|
</div>
|
||||||
<div tal:define="target item/target"
|
<div tal:define="target nocall:item/target"
|
||||||
tal:condition="target">
|
tal:condition="nocall:target">
|
||||||
<div class="subcolumn"
|
<div class="subcolumn"
|
||||||
tal:condition="item/xeditable | nothing">
|
tal:condition="item/xeditable | nothing">
|
||||||
<a href="#" title="Edit" style="padding: 5px"
|
<a href="#" title="Edit" style="padding: 5px"
|
||||||
|
@ -61,7 +61,7 @@
|
||||||
ondblclick python: item.openEditWindow('configure.html')">
|
ondblclick python: item.openEditWindow('configure.html')">
|
||||||
<span tal:content="structure body">Node Body</span>
|
<span tal:content="structure body">Node Body</span>
|
||||||
</div>
|
</div>
|
||||||
<tal:concepts define="item item/target;
|
<tal:concepts define="item nocall:item/target;
|
||||||
macro item/macro">
|
macro item/macro">
|
||||||
<div metal:use-macro="macro" />
|
<div metal:use-macro="macro" />
|
||||||
</tal:concepts>
|
</tal:concepts>
|
||||||
|
@ -131,7 +131,7 @@
|
||||||
Listing
|
Listing
|
||||||
</div><br />
|
</div><br />
|
||||||
<div tal:attributes="ondblclick python: target.openEditWindow('resources.html')"
|
<div tal:attributes="ondblclick python: target.openEditWindow('resources.html')"
|
||||||
tal:define="item item/target"
|
tal:define="item nocall:item/target"
|
||||||
tal:condition="nocall:target">
|
tal:condition="nocall:target">
|
||||||
<div tal:repeat="related item/resources">
|
<div tal:repeat="related item/resources">
|
||||||
<a href="#"
|
<a href="#"
|
||||||
|
|
|
@ -6,14 +6,14 @@
|
||||||
|
|
||||||
|
|
||||||
<div metal:fill-slot="body"
|
<div metal:fill-slot="body"
|
||||||
tal:define="target view/target">
|
tal:define="target nocall:view/target">
|
||||||
|
|
||||||
<h1 tal:content="context/title">Node Title</h1><br />
|
<h1 tal:content="context/title">Node Title</h1><br />
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<span i18n:translate=""
|
<span i18n:translate=""
|
||||||
tal:condition="not:target">No target assigned</span>
|
tal:condition="not:nocall:target">No target assigned</span>
|
||||||
<tal:target condition="target">
|
<tal:target condition="nocall:target">
|
||||||
<span i18n:translate="">Currently assigned target</span>:
|
<span i18n:translate="">Currently assigned target</span>:
|
||||||
<a href="#"
|
<a href="#"
|
||||||
tal:attributes="href string:${target/url}/@@configure.html"
|
tal:attributes="href string:${target/url}/@@configure.html"
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<metal:top define-slot="topActions" />
|
<metal:top define-slot="topActions" />
|
||||||
<form metal:define-macro="listing_form"
|
<form metal:define-macro="listing_form"
|
||||||
method="post" name="listing" action="."
|
method="post" name="listing" action="."
|
||||||
tal:define="target view/target"
|
tal:define="target nocall:view/target"
|
||||||
tal:condition="python: target or items"
|
tal:condition="python: target or items"
|
||||||
tal:attributes="action request/URL">
|
tal:attributes="action request/URL">
|
||||||
<input type="hidden" name="action" value="assign"
|
<input type="hidden" name="action" value="assign"
|
||||||
|
@ -28,8 +28,8 @@
|
||||||
type nothing">
|
type nothing">
|
||||||
<metal:none use-macro="views/target_macros/list_item_tr" />
|
<metal:none use-macro="views/target_macros/list_item_tr" />
|
||||||
</tal:none>
|
</tal:none>
|
||||||
<tal:current define="item target"
|
<tal:current define="item nocall:target"
|
||||||
condition="item">
|
condition="nocall:item">
|
||||||
<metal:current use-macro="views/target_macros/list_item" />
|
<metal:current use-macro="views/target_macros/list_item" />
|
||||||
</tal:current>
|
</tal:current>
|
||||||
<tal:items repeat="item items">
|
<tal:items repeat="item items">
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#"
|
<a href="#"
|
||||||
tal:omit-tag="not:item"
|
tal:omit-tag="not:nocall:item"
|
||||||
tal:content="title"
|
tal:content="title"
|
||||||
tal:attributes="href
|
tal:attributes="href
|
||||||
string:${item/url|nothing}/@@SelectedManagementView.html">
|
string:${item/url|nothing}/@@SelectedManagementView.html">
|
||||||
|
|
Loading…
Add table
Reference in a new issue