[Zope3-checkins] CVS: Products3/demo/messageboard/step2/browser - add.pt:1.1 details.pt:1.1 message.png:1.1 message.py:1.1 messageboard.png:1.1 messageboard.py:1.1 subthread.pt:1.1 thread.pt:1.1 thread.py:1.1 configure.zcml:1.2
Stephan Richter
srichter@cosmos.phy.tufts.edu
Sun, 8 Jun 2003 20:45:20 -0400
Update of /cvs-repository/Products3/demo/messageboard/step2/browser
In directory cvs.zope.org:/tmp/cvs-serv4188/step2/browser
Modified Files:
configure.zcml
Added Files:
add.pt details.pt message.png message.py messageboard.png
messageboard.py subthread.pt thread.pt thread.py
Log Message:
Completed step 2. The corresponding recipe is at
http://dev.zope.org/Zope3/ComponentViews
We now have:
- Contents views.
- Threaded view.
- Message detail view.
- Icons
- Custom Adding menus.
=== Added File Products3/demo/messageboard/step2/browser/add.pt ===
<html metal:use-macro="views/standard_macros/dialog">
<body>
<div metal:fill-slot="body">
<form action="action.html" method="POST">
<table class="TypeListing" cellpadding="3">
<caption>Add Content</caption>
<tbody tal:repeat="info view/addingInfo">
<tr>
<td class="Selector">
<input type="radio" name="type_name"
tal:attributes="value info/action; id info/action" />
</td>
<td class="TypeName">
<label style="font-weight: bold;"
tal:attributes="for info/action">
<span tal:replace="info/title" >Folder</span>
</label>
<div class="TypeDescription" tal:content="info/description">
Folders are generic containers for content, including other
folders.
</div>
</td>
</tr>
</tbody>
<tbody tal:condition="nothing">
<tr>
<td class="Selector">
<input type="radio" name="type_name" value="" />
</td>
<td class="TypeName">
<img alt="Folder" src="../../ZMI/www/document_icon.gif" />
Document
</td>
</tr>
<tr>
<td class="Selector"><br /></td>
<td class="TypeDescription">
Documents are simple textual content.
</td>
</tr>
</tbody>
<tr>
<td><br/></td>
<td>
<input type="text" name="id"
tal:condition="view/namesAccepted"
tal:attributes="value request/id | nothing"
/>
<input type="submit" value=" Add " />
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
=== Added File Products3/demo/messageboard/step2/browser/details.pt ===
<html metal:use-macro="views/standard_macros/page">
<body>
<div metal:fill-slot="body">
<h1>Message Details</h1>
<div class="row">
<div class="label">Title</div>
<div class="field" tal:content="context/title" />
</div>
<div class="row">
<div class="label">Author</div>
<div class="field" tal:content="view/author"/>
</div>
<div class="row">
<div class="label">Date/Time</div>
<div class="field" tal:content="view/modified"/>
</div>
<div class="row">
<div class="label">Parent</div>
<div class="field" tal:define="info view/parent_info">
<a href="../"
tal:condition="info"
tal:content="info/title" />
</div>
</div>
<div class="row">
<div class="label">Body</div>
<div class="field" tal:content="context/body"/>
</div>
</div>
</body>
</html>
=== Added File Products3/demo/messageboard/step2/browser/message.png ===
<Binary-ish file>
=== Added File Products3/demo/messageboard/step2/browser/message.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Browser Views for IMessage
$Id: message.py,v 1.1 2003/06/09 00:45:19 srichter Exp $
"""
from zope.app.interfaces.dublincore import ICMFDublinCore
from zopeproducts.messageboard.interfaces import IMessage
from zope.component import getAdapter
from zope.app.traversing import getParent, objectName
from zope.app.browser.container.adding import Adding
class MessageDetails:
def author(self):
"""Get user who last modified the Wiki Page."""
creators = getAdapter(self.context, ICMFDublinCore).creators
if not creators:
return 'unknown'
return creators[0]
def modified(self):
"""Get last modification date."""
date = getAdapter(self.context, ICMFDublinCore).modified
if date is None:
date = getAdapter(self.context, ICMFDublinCore).created
if date is None:
return ''
return date.strftime('%d/%m/%Y %H:%M:%S')
def parent_info(self):
"""Get the parent of the message"""
parent = getParent(self.context)
if not IMessage.isImplementedBy(parent):
return None
return {'name': objectName(parent), 'title': parent.title}
class MessageAdding(Adding):
"""Custom adding view for Message objects."""
menu_id = "add_message"
=== Added File Products3/demo/messageboard/step2/browser/messageboard.png ===
<Binary-ish file>
=== Added File Products3/demo/messageboard/step2/browser/messageboard.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Browser Views for IMessageBoard
$Id: messageboard.py,v 1.1 2003/06/09 00:45:19 srichter Exp $
"""
from zope.app.browser.container.adding import Adding
class MessageBoardAdding(Adding):
"""Custom adding view for MessageBoard objects."""
menu_id = "add_messageboard"
=== Added File Products3/demo/messageboard/step2/browser/subthread.pt ===
<ul>
<li tal:repeat="item view/listContentInfo">
<a href=""
tal:attributes="href item/url"
tal:content="item/title">Message 1</a>
<div tal:replace="structure item/thread"/>
</li>
</ul>
=== Added File Products3/demo/messageboard/step2/browser/thread.pt ===
<html metal:use-macro="views/standard_macros/page">
<body>
<div metal:fill-slot="body">
<h1>Discussion Thread</h1>
<div tal:replace="structure view/subthread" />
</div>
</body>
</html>
=== Added File Products3/demo/messageboard/step2/browser/thread.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Browser View for the sub-thread of a Message or MessageBoard
$Id: thread.py,v 1.1 2003/06/09 00:45:19 srichter Exp $
"""
from zopeproducts.messageboard.interfaces import IMessage
from zope.app.context import ContextWrapper
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
class Thread:
def __init__(self, context, request, base_url=''):
self.context = context
self.request = request
self.base_url = base_url
def listContentInfo(self):
children = []
for name, child in self.context.items():
if IMessage.isImplementedBy(child):
wrapped = ContextWrapper(child, self.context, name=name)
info = {}
info['title'] = child.title
url = self.base_url + name + '/'
info['url'] = url + '@@thread.html'
thread = Thread(wrapped, self.request, url)
info['thread'] = thread.subthread()
children.append(info)
return children
subthread = ViewPageTemplateFile('subthread.pt')
=== Products3/demo/messageboard/step2/browser/configure.zcml 1.1 => 1.2 ===
--- Products3/demo/messageboard/step2/browser/configure.zcml:1.1 Sat Jun 7 07:24:51 2003
+++ Products3/demo/messageboard/step2/browser/configure.zcml Sun Jun 8 20:45:19 2003
@@ -2,6 +2,25 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser">
+ <!-- IMessageBoard Views -->
+
+ <browser:menu
+ id="add_messageboard"
+ title="Menu of objects to be added to Message Boards."/>
+
+ <browser:view
+ name="+"
+ for="zopeproducts.messageboard.interfaces.IMessageBoard"
+ class=".messageboard.MessageBoardAdding"
+ permission="zope.ManageContent"
+ allowed_attributes="addingInfo"
+ menu="zmi_actions"
+ title="Add"
+ >
+ <browser:page name="index.html" template="add.pt" />
+ <browser:page name="action.html" attribute="action" />
+ </browser:view>
+
<browser:addform
label="Add Message Board"
name="AddMessageBoard"
@@ -18,13 +37,54 @@
permission="zope.ManageContent"
menu="zmi_views" title="Edit" />
+ <browser:page
+ name="thread.html"
+ for="zopeproducts.messageboard.interfaces.IMessageBoard"
+ class=".thread.Thread"
+ template="thread.pt"
+ permission="zope.View"
+ menu="zmi_views" title="Thread"/>
+
+ <browser:menuItems menu="zmi_views"
+ for="zopeproducts.messageboard.interfaces.IMessageBoard">
+ <browser:menuItem title="Contents" action="@@contents.html" />
+ </browser:menuItems>
+
+ <browser:defaultView
+ for="zopeproducts.messageboard.interfaces.IMessageBoard"
+ name="thread.html"/>
+
+ <browser:icon
+ name="zmi_icon"
+ for="zopeproducts.messageboard.interfaces.IMessageBoard"
+ file="messageboard.png" />
+
+ <!-- IMessage Views -->
+
+ <browser:menu
+ id="add_message"
+ title="Menu of objects to be added to Messages."/>
+
+ <browser:view
+ name="+"
+ for="zopeproducts.messageboard.interfaces.IMessage"
+ class=".message.MessageAdding"
+ permission="zope.ManageContent"
+ allowed_attributes="addingInfo"
+ menu="zmi_actions"
+ title="Add"
+ >
+ <browser:page name="index.html" template="add.pt" />
+ <browser:page name="action.html" attribute="action" />
+ </browser:view>
+
<browser:addform
label="Add Message"
name="AddMessage"
schema="zopeproducts.messageboard.interfaces.IMessage"
content_factory="zopeproducts.messageboard.message.Message"
permission="zope.ManageContent"
- menu="add_content" title="Message"/>
+ menu="add_messageboard" title="Message"/>
<browser:editform
schema="zopeproducts.messageboard.interfaces.IMessage"
@@ -33,5 +93,53 @@
name="edit.html"
permission="zope.ManageContent"
menu="zmi_views" title="Edit" />
+
+ <browser:page
+ name="details.html"
+ for="zopeproducts.messageboard.interfaces.IMessage"
+ class=".message.MessageDetails"
+ template="details.pt"
+ permission="zope.View"
+ menu="zmi_views" title="Preview"/>
+
+ <browser:page
+ name="thread.html"
+ for="zopeproducts.messageboard.interfaces.IMessage"
+ class=".thread.Thread"
+ template="thread.pt"
+ permission="zope.View"
+ menu="zmi_views" title="Thread"/>
+
+ <browser:menuItem
+ menu="add_message"
+ for="zope.app.interfaces.container.IAdding"
+ action="AddMessage"
+ title="Message"/>
+
+ <browser:menuItem
+ menu="add_message"
+ for="zope.app.interfaces.container.IAdding"
+ action="Image"
+ title="Image" />
+
+ <browser:menuItem
+ menu="add_message"
+ for="zope.app.interfaces.container.IAdding"
+ action="File"
+ title="File" />
+
+ <browser:menuItems menu="zmi_views"
+ for="zopeproducts.messageboard.interfaces.IMessage">
+ <browser:menuItem title="Contents" action="@@contents.html" />
+ </browser:menuItems>
+
+ <browser:defaultView
+ for="zopeproducts.messageboard.interfaces.IMessage"
+ name="details.html"/>
+
+ <browser:icon
+ name="zmi_icon"
+ for="zopeproducts.messageboard.interfaces.IMessage"
+ file="message.png" />
</zopeConfigure>