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.proxy import removeSecurityProxy
|
||||
|
||||
from cybertools.browser.view import GenericView
|
||||
from cybertools.relation.interfaces import IRelationRegistry
|
||||
from cybertools.typology.interfaces import IType
|
||||
from loops.interfaces import IView
|
||||
|
@ -80,13 +81,12 @@ class EditForm(BaseEditForm):
|
|||
return parentUrl + '/contents.html'
|
||||
|
||||
|
||||
class BaseView(object):
|
||||
class BaseView(GenericView):
|
||||
|
||||
def __init__(self, context, request):
|
||||
#self.context = context
|
||||
# TODO: get rid of removeSecurityProxy() call
|
||||
super(BaseView, self).__init__(context, request)
|
||||
self.context = removeSecurityProxy(context)
|
||||
self.request = request
|
||||
self.setSkin(self.loopsRoot.skinName)
|
||||
|
||||
def setSkin(self, skinName):
|
||||
|
@ -97,16 +97,6 @@ class BaseView(object):
|
|||
applySkin(self.request, 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
|
||||
def modified(self):
|
||||
""" get date/time of last modification
|
||||
|
@ -186,18 +176,17 @@ class BaseView(object):
|
|||
|
||||
@Lazy
|
||||
def inlineEditingActive(self):
|
||||
return False
|
||||
return self.request.principal.id == 'rootadmin'
|
||||
# this may depend on system and user settings...
|
||||
return True
|
||||
|
||||
@Lazy
|
||||
def inlineEditable(self):
|
||||
if not self.inlineEditingActive:
|
||||
return False
|
||||
return canWrite(self.context, 'title')
|
||||
return self.inlineEditingActive and canWrite(self.context, 'title')
|
||||
|
||||
def inlineEdit(self, id):
|
||||
return 'return inlineEdit("%s")' %id
|
||||
return 'return inlineEdit("%s", "")' % id
|
||||
|
||||
|
||||
class LoopsTerms(object):
|
||||
|
|
|
@ -16,6 +16,15 @@
|
|||
<resource name="loops.css" file="loops.css" />
|
||||
<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 -->
|
||||
|
||||
<page
|
||||
|
@ -539,6 +548,14 @@
|
|||
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 -->
|
||||
|
||||
<page
|
||||
|
|
|
@ -22,10 +22,14 @@ function submitReplacing(targetId, formId, actionUrl) {
|
|||
return false;
|
||||
}
|
||||
|
||||
function inlineEdit(id) {
|
||||
function inlineEdit(id, saveUrl) {
|
||||
var editor = dojo.widget.fromScript("Editor",
|
||||
{items: ["save", "|", "formatblock", "|",
|
||||
"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;
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
|
||||
|
||||
<metal:settings fill-slot="settings"
|
||||
tal:define="dummy python:
|
||||
controller.macros.register('css', resourceName='loops.css', media='all');
|
||||
dummy python:
|
||||
controller.macros.register('js', resourceName='loops.js');
|
||||
dummy python:
|
||||
controller.macros.register('js', resourceName='ajax.dojo/dojo.js');" />
|
||||
tal:define="dummy python: controller.macros.register('css',
|
||||
identifier='loops.css', resourceName='loops.css', media='all');
|
||||
dummy python: controller.macros.register('js',
|
||||
identifier='loops.js', resourceName='loops.js');
|
||||
dummy python: controller.macros.register('js',
|
||||
identifier='dojo.js', resourceName='ajax.dojo/dojo.js');" />
|
||||
|
||||
|
||||
<metal:block fill-slot="ecmascript_slot"
|
||||
|
@ -25,7 +25,7 @@
|
|||
|
||||
|
||||
<metal:body fill-slot="body">
|
||||
<tal:content define="item view/item;
|
||||
<tal:content define="item nocall:view/item;
|
||||
level level|python: 1;
|
||||
macro item/macro;">
|
||||
<metal:block use-macro="macro" />
|
||||
|
@ -35,9 +35,9 @@
|
|||
|
||||
<div class="box" metal:fill-slot="navigators">
|
||||
<h4>Navigation</h4>
|
||||
<tal:menu define="item view/menu;
|
||||
<tal:menu define="item nocall:view/menu;
|
||||
level level|python: 1"
|
||||
condition="item">
|
||||
condition="nocall:item">
|
||||
<div class="body">
|
||||
<metal:menu use-macro="views/node_macros/menu" />
|
||||
</div>
|
||||
|
|
|
@ -41,6 +41,7 @@ from zope.security.proxy import removeSecurityProxy
|
|||
|
||||
from cybertools.ajax import innerHtml
|
||||
from cybertools.browser import configurator
|
||||
from cybertools.browser.view import GenericView
|
||||
from cybertools.typology.interfaces import ITypeManager
|
||||
from loops.interfaces import IConcept, IResource, IDocument, IMediaAsset, INode
|
||||
from loops.interfaces import IViewConfiguratorSchema
|
||||
|
@ -60,12 +61,19 @@ class NodeView(BaseView):
|
|||
def macro(self):
|
||||
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
|
||||
def view(self):
|
||||
viewName = self.request.get('loops.viewName') or self.context.viewName
|
||||
if viewName:
|
||||
adapter = component.queryMultiAdapter((self.context, self.request),
|
||||
interface.Interface, name=viewName)
|
||||
adapter = component.queryMultiAdapter(
|
||||
(self.context, self.request), name=viewName)
|
||||
if adapter is not None:
|
||||
return adapter
|
||||
return self
|
||||
|
@ -265,11 +273,13 @@ class NodeView(BaseView):
|
|||
target = self.virtualTarget
|
||||
return target and target.inlineEditable or False
|
||||
|
||||
def inlineEdit(self, id):
|
||||
return 'return inlineEdit("%s", "%s/inline_save")' % (id, self.virtualTargetUrl)
|
||||
|
||||
# inner HTML views
|
||||
|
||||
class InlineEdit(NodeView):
|
||||
""" Provides inline editor as inner HTML - OBSOLETE, use as an example only!"""
|
||||
""" Provides inline editor as inner HTML"""
|
||||
|
||||
@Lazy
|
||||
def macro(self):
|
||||
|
@ -282,6 +292,10 @@ class InlineEdit(NodeView):
|
|||
def body(self):
|
||||
return self.virtualTargetObject.data
|
||||
|
||||
def save(self):
|
||||
target = self.virtualTargetObject
|
||||
target.data = self.request.form['editorContent']
|
||||
|
||||
|
||||
# special (named) views for nodes
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
tal:content="structure body">
|
||||
The body
|
||||
</div>
|
||||
<div tal:define="target item/target"
|
||||
tal:condition="target">
|
||||
<div tal:define="target nocall:item/target"
|
||||
tal:condition="nocall:target">
|
||||
<div class="subcolumn"
|
||||
tal:condition="item/xeditable | nothing">
|
||||
<a href="#" title="Edit" style="padding: 5px"
|
||||
|
@ -61,7 +61,7 @@
|
|||
ondblclick python: item.openEditWindow('configure.html')">
|
||||
<span tal:content="structure body">Node Body</span>
|
||||
</div>
|
||||
<tal:concepts define="item item/target;
|
||||
<tal:concepts define="item nocall:item/target;
|
||||
macro item/macro">
|
||||
<div metal:use-macro="macro" />
|
||||
</tal:concepts>
|
||||
|
@ -131,7 +131,7 @@
|
|||
Listing
|
||||
</div><br />
|
||||
<div tal:attributes="ondblclick python: target.openEditWindow('resources.html')"
|
||||
tal:define="item item/target"
|
||||
tal:define="item nocall:item/target"
|
||||
tal:condition="nocall:target">
|
||||
<div tal:repeat="related item/resources">
|
||||
<a href="#"
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
|
||||
|
||||
<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 />
|
||||
|
||||
<div>
|
||||
<span i18n:translate=""
|
||||
tal:condition="not:target">No target assigned</span>
|
||||
<tal:target condition="target">
|
||||
tal:condition="not:nocall:target">No target assigned</span>
|
||||
<tal:target condition="nocall:target">
|
||||
<span i18n:translate="">Currently assigned target</span>:
|
||||
<a href="#"
|
||||
tal:attributes="href string:${target/url}/@@configure.html"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<metal:top define-slot="topActions" />
|
||||
<form metal:define-macro="listing_form"
|
||||
method="post" name="listing" action="."
|
||||
tal:define="target view/target"
|
||||
tal:define="target nocall:view/target"
|
||||
tal:condition="python: target or items"
|
||||
tal:attributes="action request/URL">
|
||||
<input type="hidden" name="action" value="assign"
|
||||
|
@ -28,8 +28,8 @@
|
|||
type nothing">
|
||||
<metal:none use-macro="views/target_macros/list_item_tr" />
|
||||
</tal:none>
|
||||
<tal:current define="item target"
|
||||
condition="item">
|
||||
<tal:current define="item nocall:target"
|
||||
condition="nocall:item">
|
||||
<metal:current use-macro="views/target_macros/list_item" />
|
||||
</tal:current>
|
||||
<tal:items repeat="item items">
|
||||
|
@ -46,7 +46,7 @@
|
|||
</td>
|
||||
<td>
|
||||
<a href="#"
|
||||
tal:omit-tag="not:item"
|
||||
tal:omit-tag="not:nocall:item"
|
||||
tal:content="title"
|
||||
tal:attributes="href
|
||||
string:${item/url|nothing}/@@SelectedManagementView.html">
|
||||
|
|
Loading…
Add table
Reference in a new issue