[Checkins] SVN: Grokstar/trunk/src/grokstar/ Add total number of
posts to footer. Needed to introduce new view base class
Robert Marianski
rmarianski at openplans.org
Mon Feb 18 03:33:37 EST 2008
Log message for revision 84006:
Add total number of posts to footer. Needed to introduce new view base class
for method to calculate number of posts.
Changed:
A Grokstar/trunk/src/grokstar/base.py
U Grokstar/trunk/src/grokstar/blog.py
U Grokstar/trunk/src/grokstar/blog_templates/blogmacros.pt
U Grokstar/trunk/src/grokstar/calendar.py
U Grokstar/trunk/src/grokstar/entry.py
U Grokstar/trunk/src/grokstar/static/grokstar.css
-=-
Added: Grokstar/trunk/src/grokstar/base.py
===================================================================
--- Grokstar/trunk/src/grokstar/base.py (rev 0)
+++ Grokstar/trunk/src/grokstar/base.py 2008-02-18 08:33:37 UTC (rev 84006)
@@ -0,0 +1,18 @@
+import grok
+from hurry.query.query import Query
+from hurry import query
+from zope.interface import Interface
+from grokstar.interfaces import IBlog
+
+class ViewBase(grok.View):
+ """contain common view methods"""
+ grok.context(Interface)
+
+ def numPosts(self):
+ # @@ is there a better way to get all entries through the catalog?
+ obj = self.context
+ while obj is not None:
+ if IBlog.providedBy(obj):
+ return len(obj['entries'])
+ obj = obj.__parent__
+ return 0
Modified: Grokstar/trunk/src/grokstar/blog.py
===================================================================
--- Grokstar/trunk/src/grokstar/blog.py 2008-02-18 07:14:04 UTC (rev 84005)
+++ Grokstar/trunk/src/grokstar/blog.py 2008-02-18 08:33:37 UTC (rev 84006)
@@ -13,6 +13,7 @@
from grok import index
from grokstar.interfaces import IRestructuredTextEntry, IBlog
from grokstar.interfaces import PUBLISHED, CREATED
+from grokstar.base import ViewBase
class Blog(grok.Container, grok.Application):
interface.implements(IBlog)
@@ -44,7 +45,7 @@
class Drafts(grok.Model):
pass
-class DraftsIndex(grok.View):
+class DraftsIndex(ViewBase):
grok.context(Drafts)
grok.name('index')
@@ -54,17 +55,17 @@
class Entries(grok.Container):
pass
-class BlogIndex(grok.View):
+class BlogIndex(ViewBase):
grok.context(Blog)
grok.name('index')
def entries(self):
return lastEntries(10)
-class BlogMacros(grok.View):
+class BlogMacros(ViewBase):
grok.context(Interface)
-class BlogEdit(grok.EditForm):
+class BlogEdit(grok.EditForm, ViewBase):
grok.context(Blog)
grok.name('edit')
@@ -73,11 +74,11 @@
self.applyData(self.context, **data)
self.redirect(self.url(self.context))
-class BlogAbout(grok.View):
+class BlogAbout(ViewBase):
grok.context(Blog)
grok.name('about')
-class Search(grok.View):
+class Search(ViewBase):
grok.context(Blog)
def update(self, q=None):
@@ -95,7 +96,7 @@
query.Text(('entry_catalog', 'content'), q))))
self.results = list(islice(entries, 10))
-class EntriesIndex(grok.View):
+class EntriesIndex(ViewBase):
grok.context(Entries)
grok.name('index')
Modified: Grokstar/trunk/src/grokstar/blog_templates/blogmacros.pt
===================================================================
--- Grokstar/trunk/src/grokstar/blog_templates/blogmacros.pt 2008-02-18 07:14:04 UTC (rev 84005)
+++ Grokstar/trunk/src/grokstar/blog_templates/blogmacros.pt 2008-02-18 08:33:37 UTC (rev 84006)
@@ -32,11 +32,16 @@
<div metal:define-slot="main-content" />
</div>
<div id="ft">
- <ul>
- <li><a href="http://grok.zope.org">GROK</a></li>
- <li><a href="http://www.zope.org">Zope</a></li>
- <li><a href="http://www.python.org">Python</a></li>
- </ul>
+ <span id="num-posts">
+ Me grok <tal:posts replace="view/numPosts" /> posts!
+ </span>
+ <div id="external-links">
+ <ul>
+ <li><a href="http://grok.zope.org">GROK</a></li>
+ <li><a href="http://www.zope.org">Zope</a></li>
+ <li><a href="http://www.python.org">Python</a></li>
+ </ul>
+ </div>
</div>
</body>
</html>
Modified: Grokstar/trunk/src/grokstar/calendar.py
===================================================================
--- Grokstar/trunk/src/grokstar/calendar.py 2008-02-18 07:14:04 UTC (rev 84005)
+++ Grokstar/trunk/src/grokstar/calendar.py 2008-02-18 08:33:37 UTC (rev 84006)
@@ -6,6 +6,7 @@
from hurry import query
from grokstar.interfaces import PUBLISHED
+from grokstar.base import ViewBase
class Year(grok.Model):
def __init__(self, year):
@@ -20,7 +21,7 @@
return None
return Month(self.year, month)
-class YearIndex(grok.View):
+class YearIndex(ViewBase):
grok.name('index')
grok.context(Year)
grok.template('dateindex')
@@ -43,7 +44,7 @@
# XXX should check whether day is acceptable
return Day(self.year, self.month, day)
-class MonthIndex(grok.View):
+class MonthIndex(ViewBase):
grok.name('index')
grok.context(Month)
grok.template('dateindex')
@@ -66,7 +67,7 @@
self.month = month
self.day = day
-class DayIndex(grok.View):
+class DayIndex(ViewBase):
grok.name('index')
grok.context(Day)
grok.template('dateindex')
Modified: Grokstar/trunk/src/grokstar/entry.py
===================================================================
--- Grokstar/trunk/src/grokstar/entry.py 2008-02-18 07:14:04 UTC (rev 84005)
+++ Grokstar/trunk/src/grokstar/entry.py 2008-02-18 08:33:37 UTC (rev 84006)
@@ -10,6 +10,7 @@
from grokstar.blog import Blog
from grokstar import interfaces
+from grokstar.base import ViewBase
class Entry(grok.Model):
interface.implements(interfaces.IEntry, IAttributeAnnotatable)
@@ -31,16 +32,16 @@
grok.context(RestructuredTextEntry)
-class Index(grok.View):
+class Index(ViewBase):
pass
-class Item(grok.View):
+class Item(ViewBase):
def format_published(self, published_date):
return published_date.strftime('%Y-%m-%d')
-class Add(grok.AddForm):
+class Add(grok.AddForm, ViewBase):
grok.context(Blog)
# add the url that the user wants
@@ -66,7 +67,7 @@
self.redirect(self.url(self.context))
-class Edit(grok.EditForm):
+class Edit(grok.EditForm, ViewBase):
form_fields = grok.AutoFields(RestructuredTextEntry).omit(
'published', 'updated')
@@ -82,7 +83,7 @@
self.redirect(self.url(self.context))
-class RenderedContent(grok.View):
+class RenderedContent(ViewBase):
def render(self):
return renderRest(self.context.content)
Modified: Grokstar/trunk/src/grokstar/static/grokstar.css
===================================================================
--- Grokstar/trunk/src/grokstar/static/grokstar.css 2008-02-18 07:14:04 UTC (rev 84005)
+++ Grokstar/trunk/src/grokstar/static/grokstar.css 2008-02-18 08:33:37 UTC (rev 84006)
@@ -49,12 +49,16 @@
font-weight: bold;
}
-#menu li, #ft li {
+#menu li {
display: inline;
line-height: 250%;
margin: 0 .25em;
}
+#menu li, #ft li {
+ display: inline;
+}
+
#menu li a, #ft li a {
text-decoration: none;
}
@@ -90,3 +94,17 @@
bottom: 1em;
right: 2em;
}
+
+#ft {
+ position: relative;
+}
+
+#ft li {
+ margin: 0 .25em;
+}
+
+#external-links {
+ position: absolute;
+ right: 1em;
+ bottom: 0;
+}
More information about the Checkins
mailing list