[Checkins] SVN: gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/ Grok
Documentation portlet
Kevin Teague
kevin at bud.ca
Sun Jan 20 06:44:41 EST 2008
Log message for revision 82975:
Grok Documentation portlet
Changed:
U gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/configure.zcml
A gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/portlets/
A gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/portlets/__init__.py
A gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/portlets/configure.zcml
A gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/portlets/grokdoc.py
A gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/portlets/phc_grok.pt
A gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/profiles/default/portlets.xml
U gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/skins/smash_styles/gzo.plonesmashtheme.css.dtml
-=-
Modified: gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/configure.zcml
===================================================================
--- gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/configure.zcml 2008-01-20 11:42:47 UTC (rev 82974)
+++ gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/configure.zcml 2008-01-20 11:44:40 UTC (rev 82975)
@@ -14,5 +14,6 @@
/>
<include package=".browser" />
+ <include package=".portlets" />
</configure>
Property changes on: gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/portlets
___________________________________________________________________
Name: svn:ignore
+ *.pyc
Added: gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/portlets/__init__.py
===================================================================
--- gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/portlets/__init__.py (rev 0)
+++ gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/portlets/__init__.py 2008-01-20 11:44:40 UTC (rev 82975)
@@ -0,0 +1 @@
+# the sanest days are mad
\ No newline at end of file
Added: gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/portlets/configure.zcml
===================================================================
--- gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/portlets/configure.zcml (rev 0)
+++ gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/portlets/configure.zcml 2008-01-20 11:44:40 UTC (rev 82975)
@@ -0,0 +1,16 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ xmlns:plone="http://namespaces.plone.org/plone">
+
+ <include package="plone.app.portlets" />
+
+ <plone:portlet
+ name="gzo.GrokDoc"
+ interface=".grokdoc.IGrokDocPortlet"
+ assignment=".grokdoc.Assignment"
+ renderer=".grokdoc.Renderer"
+ addview=".grokdoc.AddForm"
+ editview=".grokdoc.EditForm"
+ />
+
+</configure>
\ No newline at end of file
Added: gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/portlets/grokdoc.py
===================================================================
--- gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/portlets/grokdoc.py (rev 0)
+++ gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/portlets/grokdoc.py 2008-01-20 11:44:40 UTC (rev 82975)
@@ -0,0 +1,103 @@
+from zope.interface import implements
+from zope.formlib import form
+
+from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
+from Products.CMFPlone import PloneMessageFactory as _
+from Products.CMFCore.utils import getToolByName
+from Products.PythonScripts.standard import url_quote_plus
+
+from plone.portlets.interfaces import IPortletDataProvider
+from plone.app.portlets.portlets import base
+from plone.app.portlets.cache import render_cachekey
+from plone.memoize import ram
+from plone.memoize.compress import xhtml_compress
+
+
+class IGrokDocPortlet(IPortletDataProvider):
+ "PHC Documentation Portlet By Topic"
+ # This portlet should probably be in PHC and then we just provide
+ # a custom template?
+
+class Assignment(base.Assignment):
+ implements(IGrokDocPortlet)
+
+class Renderer(base.Renderer):
+
+ _template = ViewPageTemplateFile('phc_grok.pt')
+
+ #@ram.cache(render_cachekey)
+ def render(self):
+ return xhtml_compress(self._template())
+
+ # duplicate of Products.PloneHelpCenter.browser.helpcenter.HelpCenterView.getSectionMap
+ def getSectionMap(self):
+ """
+ returns a complex list of section dicts
+ [{title:sectiontitle, subtopics:listOfSubTopics, url:urlOfSection, count:itemsInSection}, ...]
+ subtopics are each lists [{title:titleOfSubSection,url:urlOfSubSection}]
+ This is used in helpcenter_ploneorg.pt.
+ """
+
+ context = self.context
+ catalog = getToolByName(context, 'portal_catalog')
+ here_url = context.absolute_url()
+ phc = context.getPHCObject()
+
+ topics = phc.getSectionsVocab()
+
+ # dict to save counts
+ topicsDict = {}
+
+ for topic in topics:
+ if ':' not in topic:
+ items = catalog(portal_type=['HelpCenterReferenceManual','HelpCenterTutorial','HelpCenterHowTo'],
+ review_state='published',
+ getSections=[topic])
+ for item in items:
+ for section in item.getSections:
+ topicsDict[section] = topicsDict.get(section, 0) + 1
+
+ sections = []
+ currTitle = ''
+ for topic in topics:
+ count = topicsDict.get(topic)
+ if count:
+ # break into main topic, sub topic
+ cs = [s.strip() for s in topic.split(':')]
+ main = cs[0]
+ sub = ': '.join(cs[1:])
+
+ if main != currTitle:
+ # append a new topic dict
+ currTitle = main
+ currSubSections = []
+ sections.append(
+ {'title':currTitle,
+ 'subtopics':currSubSections,
+ 'url': here_url + '/phc_topic_area?topic=' + url_quote_plus(currTitle),
+ 'count':count
+ }
+ )
+ if sub:
+ # add to the subtopics list
+ id = sub.lower().replace(' ','-') # make HTML anchor ID
+ currSubSections.append(
+ {'title':sub,
+ 'url': "%s/phc_topic_area?topic=%s#%s" % (here_url, url_quote_plus(currTitle), id)
+ }
+ )
+
+ return sections
+
+class AddForm(base.AddForm):
+ form_fields = form.Fields(IGrokDocPortlet)
+ label = _(u"Add Grok Doc Portlet")
+ description = _(u"This portlet displays Help Center content by Topic.")
+
+ def create(self, data):
+ return Assignment()
+
+class EditForm(base.EditForm):
+ form_fields = form.Fields(IGrokDocPortlet)
+ label = _(u"Edit Grok Doc Portlet")
+ description = _(u"This portlet displays Help Center content by Topic.")
Added: gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/portlets/phc_grok.pt
===================================================================
--- gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/portlets/phc_grok.pt (rev 0)
+++ gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/portlets/phc_grok.pt 2008-01-20 11:44:40 UTC (rev 82975)
@@ -0,0 +1,64 @@
+<html xmlns:tal="http://xml.zope.org/namespaces/tal"
+ xmlns:metal="http://xml.zope.org/namespaces/metal"
+ i18n:domain="plone">
+<body>
+<div metal:define-macro="portlet" id="finddoc_portlet">
+
+ <div id="sidebarTop">
+ <p id="sidebarHeader">Grok Documentation</p>
+ </div>
+
+ <dl class="portlet">
+
+ <dd class="portletItem">
+
+ <p style="line-height: 1.5em; margin-bottom: 0;">
+ Brand new to Grok? The
+ <a href="#" tal:attributes="href string:${here/portal_url}/documentation/book/">
+ Grok Tutorial</a>
+ is place to start learning about Grok.
+ </p>
+
+ </dd>
+
+ <dd class="portletFooter">
+ <span class="portletBottomLeft" />
+ <span class="portletBottomRight" />
+ </dd>
+
+ </dl>
+
+ <dl class="portlet">
+
+ <dd class="portletItem">
+
+ <ul class="portletNavigationTree navTreeLevel0"
+ tal:repeat="section view/getSectionMap">
+ <li class="navTreeItem">
+ <a href="[section-url]" tal:attributes="href section/url"
+ tal:content="section/title" /></li>
+ <ul class="navTree navTreeLevel1"
+ tal:repeat="item section/subtopics">
+ <li class="navTreeItem">
+ <a href="[item url]" style="font-size: 80%;"
+ tal:attributes="href item/url;"
+ tal:content="python:item['title'].split(':')[-1]"
+ >[Title of start-here item]
+ </a>
+ </li>
+ </ul>
+ </ul>
+
+ <div class="visualClear"><!----></div>
+
+ </dd>
+
+ <dd class="portletFooter">
+ <span class="portletBottomLeft" />
+ <span class="portletBottomRight" />
+ </dd>
+ </dl>
+
+</div>
+</body>
+</html>
Added: gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/profiles/default/portlets.xml
===================================================================
--- gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/profiles/default/portlets.xml (rev 0)
+++ gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/profiles/default/portlets.xml 2008-01-20 11:44:40 UTC (rev 82975)
@@ -0,0 +1,9 @@
+<portlets>
+
+ <portlet
+ addview="gzo.GrokDoc"
+ title="Grok Documentation by Topic"
+ description=""
+ />
+
+</portlets>
\ No newline at end of file
Modified: gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/skins/smash_styles/gzo.plonesmashtheme.css.dtml
===================================================================
--- gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/skins/smash_styles/gzo.plonesmashtheme.css.dtml 2008-01-20 11:42:47 UTC (rev 82974)
+++ gzo.plonesmashtheme/trunk/gzo/plonesmashtheme/skins/smash_styles/gzo.plonesmashtheme.css.dtml 2008-01-20 11:44:40 UTC (rev 82975)
@@ -118,7 +118,7 @@
.documentContent p {
margin: 4px auto;
- margin-bottom: 0;
+ margin-bottom: 1em;
}
.documentContent p.download {
More information about the Checkins
mailing list