[Checkins] SVN: Grokstar/trunk/src/grokstar/ Added a macro for
common basic page layout.
Robert Marianski
rmarianski at openplans.org
Thu Feb 7 19:46:19 EST 2008
Log message for revision 83659:
Added a macro for common basic page layout.
Add a stub for an about page.
Add ability to add a post in the published state.
Changed:
U Grokstar/trunk/src/grokstar/blog.py
A Grokstar/trunk/src/grokstar/blog_templates/blogabout.pt
A Grokstar/trunk/src/grokstar/blog_templates/blogedit.pt
U Grokstar/trunk/src/grokstar/blog_templates/blogindex.pt
A Grokstar/trunk/src/grokstar/blog_templates/blogmacros.pt
D Grokstar/trunk/src/grokstar/blog_templates/breadcrumbs.pt
U Grokstar/trunk/src/grokstar/blog_templates/draftsindex.pt
A Grokstar/trunk/src/grokstar/blog_templates/entriesindex.pt
U Grokstar/trunk/src/grokstar/calendar_templates/dateindex.pt
U Grokstar/trunk/src/grokstar/entry.py
A Grokstar/trunk/src/grokstar/entry_templates/add.pt
A Grokstar/trunk/src/grokstar/entry_templates/edit.pt
U Grokstar/trunk/src/grokstar/entry_templates/index.pt
-=-
Modified: Grokstar/trunk/src/grokstar/blog.py
===================================================================
--- Grokstar/trunk/src/grokstar/blog.py 2008-02-08 00:27:06 UTC (rev 83658)
+++ Grokstar/trunk/src/grokstar/blog.py 2008-02-08 00:46:19 UTC (rev 83659)
@@ -47,12 +47,6 @@
def entries(self):
return allEntries(10)
-class Breadcrumbs(grok.View):
- grok.context(Interface)
- def parents(self):
- return getParents(self.context)
-
-
class Entries(grok.Container):
pass
@@ -63,6 +57,9 @@
def entries(self):
return lastEntries(10)
+class BlogMacros(grok.View):
+ grok.context(Interface)
+
class BlogEdit(grok.EditForm):
grok.context(Blog)
grok.name('edit')
@@ -72,12 +69,16 @@
self.applyData(self.context, **data)
self.redirect(self.url(self.context))
+class BlogAbout(grok.View):
+ grok.context(Blog)
+ grok.name('about')
+
class EntriesIndex(grok.View):
grok.context(Entries)
grok.name('index')
- def render(self):
- return "Entries: %s" % ' '.join(self.context.keys())
+ def entries(self):
+ return lastEntries(10)
def lastEntries(amount):
entries = Query().searchResults(
Added: Grokstar/trunk/src/grokstar/blog_templates/blogabout.pt
===================================================================
--- Grokstar/trunk/src/grokstar/blog_templates/blogabout.pt (rev 0)
+++ Grokstar/trunk/src/grokstar/blog_templates/blogabout.pt 2008-02-08 00:46:19 UTC (rev 83659)
@@ -0,0 +1,11 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" metal:use-macro="context/@@blogmacros/macros/blogpage">
+ <head>
+ <title metal:fill-slot="title">About</title>
+ </head>
+ <body>
+ <div metal:fill-slot="main-content">
+ Me explain GrokStar!
+ </div>
+ </body>
+</html>
Added: Grokstar/trunk/src/grokstar/blog_templates/blogedit.pt
===================================================================
--- Grokstar/trunk/src/grokstar/blog_templates/blogedit.pt (rev 0)
+++ Grokstar/trunk/src/grokstar/blog_templates/blogedit.pt 2008-02-08 00:46:19 UTC (rev 83659)
@@ -0,0 +1,72 @@
+<html metal:use-macro="context/@@blogmacros/macros/blogpage">
+<head>
+<title metal:fill-slot="title">Edit blog</title>
+</head>
+
+<body>
+ <div metal:fill-slot="main-content">
+ <form action="." tal:attributes="action request/URL" method="post"
+ class="edit-form" enctype="multipart/form-data">
+
+ <h1 i18n:translate=""
+ tal:condition="view/label"
+ tal:content="view/label">Label</h1>
+
+ <div class="form-status"
+ tal:define="status view/status"
+ tal:condition="status">
+
+ <div i18n:translate="" tal:content="view/status">
+ Form status summary
+ </div>
+
+ <ul class="errors" tal:condition="view/errors">
+ <li tal:repeat="error view/error_views">
+ <span tal:replace="structure error">Error Type</span>
+ </li>
+ </ul>
+ </div>
+
+ <table class="form-fields">
+ <tbody>
+ <tal:block repeat="widget view/widgets">
+ <tr>
+ <td class="label" tal:define="hint widget/hint">
+ <label tal:condition="python:hint"
+ tal:attributes="for widget/name">
+ <span class="required" tal:condition="widget/required"
+ >*</span><span i18n:translate=""
+ tal:content="widget/label">label</span>
+ </label>
+ <label tal:condition="python:not hint"
+ tal:attributes="for widget/name">
+ <span class="required" tal:condition="widget/required"
+ >*</span><span i18n:translate=""
+ tal:content="widget/label">label</span>
+ </label>
+ </td>
+ <td class="field">
+ <div class="widget" tal:content="structure widget">
+ <input type="text" />
+ </div>
+ <div class="error" tal:condition="widget/error">
+ <span tal:replace="structure widget/error">error</span>
+ </div>
+ </td>
+ </tr>
+ </tal:block>
+ </tbody>
+ </table>
+
+ <div id="actionsView">
+ <span class="actionButtons" tal:condition="view/availableActions">
+ <input tal:repeat="action view/actions"
+ tal:replace="structure action/render"
+ />
+ </span>
+ </div>
+ </form>
+
+ </div>
+</body>
+</html>
Modified: Grokstar/trunk/src/grokstar/blog_templates/blogindex.pt
===================================================================
--- Grokstar/trunk/src/grokstar/blog_templates/blogindex.pt 2008-02-08 00:27:06 UTC (rev 83658)
+++ Grokstar/trunk/src/grokstar/blog_templates/blogindex.pt 2008-02-08 00:46:19 UTC (rev 83659)
@@ -1,15 +1,19 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" metal:use-macro="context/@@blogmacros/macros/blogpage">
<head>
- <title tal:content="context/title"/>
+ <title metal:fill-slot="title" tal:content="context/title"/>
</head>
<body>
- <h1 tal:content="context/title"/>
- <h2 tal:content="context/tagline"/>
- <a href="./drafts" tal:attributes="href string:${view/application_url}/drafts">Unplublished Entries</a><br />
- <a tal:attributes="href python:view.url('add')">Add Blog Entry</a><br />
-
- <div class="entries">
+ <div metal:fill-slot="main-content"
+ tal:define="title context/title;
+ tagline context/tagline"
+ >
+ <h1 tal:content="python:title and title or default">Untitled</h1>
+ <h2 tal:content="python:tagline and tagline or default">No tagline</h2>
+ <p>
+ <a href="edit" tal:attributes="href python:view.url('edit')">Edit</a>
+ blog title/tagline
+ </p>
<tal:block repeat="entry view/entries">
<tal:block content="structure entry/@@item"/>
</tal:block>
Added: Grokstar/trunk/src/grokstar/blog_templates/blogmacros.pt
===================================================================
--- Grokstar/trunk/src/grokstar/blog_templates/blogmacros.pt (rev 0)
+++ Grokstar/trunk/src/grokstar/blog_templates/blogmacros.pt 2008-02-08 00:46:19 UTC (rev 83659)
@@ -0,0 +1,29 @@
+<html metal:define-macro="blogpage">
+ <head>
+ <title metal:define-slot="title" tal:content="python:view.__name__" />
+ <div metal:define-slot="headers" />
+ </head>
+ <body>
+ <div id="header">
+ <h1>GrokStar!</h1>
+ <h2>Me need logo! And cool caveman saying! Ooga Booga!</h2>
+ <div id="menu">
+ <ul>
+ <li><a href="#" tal:attributes="href view/application_url">Home</a></li>
+ <li><a href="#" tal:attributes="href python:view.application_url('add')">Post</a></li>
+ <li><a href="#" tal:attributes="href python:view.application_url('drafts')">Drafts</a></li>
+ <li><a href="#" tal:attributes="href python:view.application_url('entries')">Published</a></li>
+ <li><a href="#" tal:attributes="href python:view.application_url('about')">About</a></li>
+ </ul>
+ </div>
+ </div>
+ <div id="content">
+ <div metal:define-slot="main-content" />
+ </div>
+ <div id="footer">
+ <a href="http://grok.zope.org">GROK</a>
+ <a href="http://www.zope.org">Zope</a>
+ <a href="http://www.python.org">Python</a>
+ </div>
+ </body>
+</html>
Deleted: Grokstar/trunk/src/grokstar/blog_templates/breadcrumbs.pt
===================================================================
--- Grokstar/trunk/src/grokstar/blog_templates/breadcrumbs.pt 2008-02-08 00:27:06 UTC (rev 83658)
+++ Grokstar/trunk/src/grokstar/blog_templates/breadcrumbs.pt 2008-02-08 00:46:19 UTC (rev 83659)
@@ -1,3 +0,0 @@
-<span tal:repeat="obj view/parents" tal:omit-tag="">
- <a href="" tal:attributes="href python: view.url(obj)" tal:content="obj/__name__" />
-</span>
Modified: Grokstar/trunk/src/grokstar/blog_templates/draftsindex.pt
===================================================================
--- Grokstar/trunk/src/grokstar/blog_templates/draftsindex.pt 2008-02-08 00:27:06 UTC (rev 83658)
+++ Grokstar/trunk/src/grokstar/blog_templates/draftsindex.pt 2008-02-08 00:46:19 UTC (rev 83659)
@@ -1,14 +1,20 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
- <head>
- </head>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" metal:use-macro="context/@@blogmacros/macros/blogpage">
<body>
- <div class="" tal:content="structure context/@@breadcrumbs" />
- <a href="../add">Add Blog Entry</a><br />
- <div class="entries">
- <tal:block repeat="entry view/entries">
- <tal:block content="structure entry/@@item"/>
- </tal:block>
+ <div metal:fill-slot="main-content">
+ <div class="entries"
+ tal:define="entries view/entries">
+ <tal:block condition="entries" repeat="entry view/entries">
+ <tal:block content="structure entry/@@item"/>
+ </tal:block>
+ <tal:block condition="not:entries">
+ No drafts.
+ <a href="#"
+ tal:attributes="href python:view.application_url('add')">
+ Post?
+ </a>
+ </tal:block>
+ </div>
</div>
</body>
</html>
Added: Grokstar/trunk/src/grokstar/blog_templates/entriesindex.pt
===================================================================
--- Grokstar/trunk/src/grokstar/blog_templates/entriesindex.pt (rev 0)
+++ Grokstar/trunk/src/grokstar/blog_templates/entriesindex.pt 2008-02-08 00:46:19 UTC (rev 83659)
@@ -0,0 +1,12 @@
+<html metal:use-macro="context/@@blogmacros/macros/blogpage">
+<head>
+<title metal:fill-slot="title">Blog Entries</title>
+</head>
+<body>
+<div metal:fill-slot="main-content">
+ <tal:block repeat="entry view/entries">
+ <tal:block content="structure entry/@@item"/>
+ </tal:block>
+</div>
+</body>
+</html>
Modified: Grokstar/trunk/src/grokstar/calendar_templates/dateindex.pt
===================================================================
--- Grokstar/trunk/src/grokstar/calendar_templates/dateindex.pt 2008-02-08 00:27:06 UTC (rev 83658)
+++ Grokstar/trunk/src/grokstar/calendar_templates/dateindex.pt 2008-02-08 00:46:19 UTC (rev 83659)
@@ -1,14 +1,15 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" metal:use-macro="context/@@blogmacros/macros/blogpage">
<head>
- <title>blog title</title>
+ <title metal:fill-slot="title">blog title</title>
</head>
<body>
- <h1>blog index</h1>
+ <div metal:fill-slot="main-content">
+ <h1>blog index</h1>
- <tal:block repeat="entry view/entries">
- <tal:block content="structure entry/@@item"/>
- </tal:block>
-
+ <tal:block repeat="entry view/entries">
+ <tal:block content="structure entry/@@item"/>
+ </tal:block>
+ </div>
</body>
</html>
Modified: Grokstar/trunk/src/grokstar/entry.py
===================================================================
--- Grokstar/trunk/src/grokstar/entry.py 2008-02-08 00:27:06 UTC (rev 83658)
+++ Grokstar/trunk/src/grokstar/entry.py 2008-02-08 00:46:19 UTC (rev 83659)
@@ -42,8 +42,10 @@
class Add(grok.AddForm):
grok.context(Blog)
+ # add the url that the user wants
form_fields = grok.Fields(
- id=schema.TextLine(title=u"id"))
+ id=schema.TextLine(title=u"Url name"))
+ # don't show them these timestamps
form_fields += grok.AutoFields(RestructuredTextEntry).omit(
'published', 'updated')
@@ -54,7 +56,15 @@
IWorkflowInfo(new_entry).fireTransition('create')
self.redirect(self.url(self.context))
+ @grok.action('Add published entry')
+ def add_published(self, id, **data):
+ new_entry = RestructuredTextEntry(**data)
+ self.context['entries'][id] = new_entry
+ IWorkflowInfo(new_entry).fireTransition('create')
+ IWorkflowInfo(new_entry).fireTransitionToward(interfaces.PUBLISHED)
+ self.redirect(self.url(self.context))
+
class Edit(grok.EditForm):
form_fields = grok.AutoFields(RestructuredTextEntry).omit(
'published', 'updated')
Added: Grokstar/trunk/src/grokstar/entry_templates/add.pt
===================================================================
--- Grokstar/trunk/src/grokstar/entry_templates/add.pt (rev 0)
+++ Grokstar/trunk/src/grokstar/entry_templates/add.pt 2008-02-08 00:46:19 UTC (rev 83659)
@@ -0,0 +1,71 @@
+<html metal:use-macro="context/@@blogmacros/macros/blogpage" >
+<head>
+<title metal:fill-slot="title">Add Entry</title>
+</head>
+
+<body>
+<div metal:fill-slot="main-content">
+<form action="." tal:attributes="action request/URL" method="post"
+ class="edit-form" enctype="multipart/form-data">
+
+ <h1 i18n:translate=""
+ tal:condition="view/label"
+ tal:content="view/label">Label</h1>
+
+ <div class="form-status"
+ tal:define="status view/status"
+ tal:condition="status">
+
+ <div i18n:translate="" tal:content="view/status">
+ Form status summary
+ </div>
+
+ <ul class="errors" tal:condition="view/errors">
+ <li tal:repeat="error view/error_views">
+ <span tal:replace="structure error">Error Type</span>
+ </li>
+ </ul>
+ </div>
+
+ <table class="form-fields">
+ <tbody>
+ <tal:block repeat="widget view/widgets">
+ <tr>
+ <td class="label" tal:define="hint widget/hint">
+ <label tal:condition="python:hint"
+ tal:attributes="for widget/name">
+ <span class="required" tal:condition="widget/required"
+ >*</span><span i18n:translate=""
+ tal:content="widget/label">label</span>
+ </label>
+ <label tal:condition="python:not hint"
+ tal:attributes="for widget/name">
+ <span class="required" tal:condition="widget/required"
+ >*</span><span i18n:translate=""
+ tal:content="widget/label">label</span>
+ </label>
+ </td>
+ <td class="field">
+ <div class="widget" tal:content="structure widget">
+ <input type="text" />
+ </div>
+ <div class="error" tal:condition="widget/error">
+ <span tal:replace="structure widget/error">error</span>
+ </div>
+ </td>
+ </tr>
+ </tal:block>
+ </tbody>
+ </table>
+
+ <div id="actionsView">
+ <span class="actionButtons" tal:condition="view/availableActions">
+ <input tal:repeat="action view/actions"
+ tal:replace="structure action/render"
+ />
+ </span>
+ </div>
+</form>
+</div>
+</body>
+</html>
Added: Grokstar/trunk/src/grokstar/entry_templates/edit.pt
===================================================================
--- Grokstar/trunk/src/grokstar/entry_templates/edit.pt (rev 0)
+++ Grokstar/trunk/src/grokstar/entry_templates/edit.pt 2008-02-08 00:46:19 UTC (rev 83659)
@@ -0,0 +1,72 @@
+<html metal:use-macro="context/@@blogmacros/macros/blogpage">
+<head>
+<title metal:fill-slot="title">Edit entry</title>
+</head>
+
+<body>
+ <div metal:fill-slot="main-content">
+ <form action="." tal:attributes="action request/URL" method="post"
+ class="edit-form" enctype="multipart/form-data">
+
+ <h1 i18n:translate=""
+ tal:condition="view/label"
+ tal:content="view/label">Label</h1>
+
+ <div class="form-status"
+ tal:define="status view/status"
+ tal:condition="status">
+
+ <div i18n:translate="" tal:content="view/status">
+ Form status summary
+ </div>
+
+ <ul class="errors" tal:condition="view/errors">
+ <li tal:repeat="error view/error_views">
+ <span tal:replace="structure error">Error Type</span>
+ </li>
+ </ul>
+ </div>
+
+ <table class="form-fields">
+ <tbody>
+ <tal:block repeat="widget view/widgets">
+ <tr>
+ <td class="label" tal:define="hint widget/hint">
+ <label tal:condition="python:hint"
+ tal:attributes="for widget/name">
+ <span class="required" tal:condition="widget/required"
+ >*</span><span i18n:translate=""
+ tal:content="widget/label">label</span>
+ </label>
+ <label tal:condition="python:not hint"
+ tal:attributes="for widget/name">
+ <span class="required" tal:condition="widget/required"
+ >*</span><span i18n:translate=""
+ tal:content="widget/label">label</span>
+ </label>
+ </td>
+ <td class="field">
+ <div class="widget" tal:content="structure widget">
+ <input type="text" />
+ </div>
+ <div class="error" tal:condition="widget/error">
+ <span tal:replace="structure widget/error">error</span>
+ </div>
+ </td>
+ </tr>
+ </tal:block>
+ </tbody>
+ </table>
+
+ <div id="actionsView">
+ <span class="actionButtons" tal:condition="view/availableActions">
+ <input tal:repeat="action view/actions"
+ tal:replace="structure action/render"
+ />
+ </span>
+ </div>
+ </form>
+
+ </div>
+</body>
+</html>
Modified: Grokstar/trunk/src/grokstar/entry_templates/index.pt
===================================================================
--- Grokstar/trunk/src/grokstar/entry_templates/index.pt 2008-02-08 00:27:06 UTC (rev 83658)
+++ Grokstar/trunk/src/grokstar/entry_templates/index.pt 2008-02-08 00:46:19 UTC (rev 83659)
@@ -1,16 +1,16 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<html metal:use-macro="context/@@blogmacros/macros/blogpage" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
- <title tal:content="context/title"/>
+ <title metal:fill-slot="title" tal:content="context/title"/>
</head>
<body>
- <a href="" tal:attributes="href view/application_url">home</a>
- <div class="" tal:content="structure context/@@breadcrumbs" />
- <h1>
- <tal:block content="context/title"/>
- (<span class="published" tal:content="context/published"/>)
- </h1>
- <a tal:attributes="href python:view.url('edit')">edit...</a>
- <tal:block content="structure context/@@renderedcontent" />
+ <div metal:fill-slot="main-content">
+ <a tal:attributes="href python:view.url('edit')">edit</a>
+ <p>
+ <tal:block content="context/title"/>
+ (<span class="published" tal:content="context/published"/>)
+ </p>
+ <tal:block content="structure context/@@renderedcontent" />
+ </div>
</body>
</html>
More information about the Checkins
mailing list