[Checkins] SVN: grok/trunk/doc/ Added the files that I had left out but commented on in the last commit

Darryl Cousins darryl at darrylcousins.net.nz
Thu Mar 29 09:47:00 EDT 2007


Log message for revision 73912:
  Added the files that I had left out but commented on in the last commit

Changed:
  A   grok/trunk/doc/grok2html.py
  A   grok/trunk/doc/index.txt
  A   grok/trunk/doc/template.pt

-=-
Added: grok/trunk/doc/grok2html.py
===================================================================
--- grok/trunk/doc/grok2html.py	2007-03-29 13:22:01 UTC (rev 73911)
+++ grok/trunk/doc/grok2html.py	2007-03-29 13:46:59 UTC (rev 73912)
@@ -0,0 +1,129 @@
+import os
+
+from zope.pagetemplate.pagetemplate import PageTemplate
+
+import docutils.core
+from docutils.writers.html4css1 import HTMLTranslator
+from docutils.writers.html4css1 import Writer
+
+class ZopeTranslator(HTMLTranslator):
+    """
+    The ZopeTranslator extends the base HTML processor for reST.  It
+    augments reST by:
+
+    - Outputs *only* the 'body' parts of the document tree, using the
+    internal docutils structure.
+    """
+
+    def astext(self):
+        """
+        This is where we join the document parts that we want in
+        the output.
+        """
+        # use the title, subtitle, author, date, etc., plus the content
+        body = self.body_pre_docinfo + self.docinfo + self.body
+        return u"".join(body)
+
+
+class ReStructuredTextToHTMLRenderer:
+    """convert from Restructured Text to HTML.
+
+    """
+
+    def __init__(self,content):
+        self.content = content 
+
+    def render(self):
+        settings_overrides = {
+            'halt_level': 6,
+            'output_encoding': 'utf8',
+            'initial_header_level': 2
+        }
+            # 'input_encoding': 'unicode',
+            # 'output_encoding': 'unicode',
+        writer = Writer()
+        writer.translator_class = ZopeTranslator
+        html = docutils.core.publish_string(
+        self.content,
+        writer=writer,settings_overrides=settings_overrides,)
+        return html
+
+
+Menu = [
+        {'href':'index.html','title':u'Home','klass':''},
+        {'href':'about.html','title':u'About','klass':''},
+        {'href':'tutorial.html','title':u'Tutorial','klass':''},
+        ]
+
+class Context:
+    """Set up the context for rendering the rest as html through zpt"""
+
+    id = u''
+    title = u''
+    menu = []
+    content = u''
+
+    def __init__(self, id, title=u''):
+        self.id = id
+        self.title = title
+
+    def restSource(self, source_file):
+        fp = open(source_file)
+        # try to locate a title for the document if not given
+        if not self.title:
+            self.title = fp.readline()
+            if self.title.startswith("="):
+                self.title = fp.readline()
+        fp.close()
+        #rest = codecs.open(source_file,"r",'utf8').read()
+        rest = open(source_file).read()
+        renderer = ReStructuredTextToHTMLRenderer(rest)
+        return renderer.render().strip()
+    
+    def setRestContent(self, source_file):
+        self.content = self.restSource(source_file)
+
+    @property
+    def menu(self):
+        for item in Menu:
+            if item.get('href').split('.')[0] == self.id:
+                item['klass'] = u'selected'
+            else:
+                item['klass'] = u''
+            if not item.get('description', None):
+                item['description'] = item['title']
+        return Menu
+
+def handler_html(pageid, restpath):
+
+# we could rename about_grok.txt to about.txt that we could use only 
+# a pageid to identify the source document and the html result.
+    if os.path.exists(restpath):
+        layout_file = os.path.join('template.pt')
+        layout = PageTemplate()
+        layout.write(open(layout_file,"r").read())
+
+        page = PageTemplate()
+        page.write("""<metal:block use-macro="here/layout/macros/pagelayout" />""")
+
+        context = Context(pageid)
+        context.setRestContent(restpath)
+
+        settings = {}
+        settings["here"] = { "layout": layout }
+        settings["context"] = context
+
+        content = page.pt_render(namespace=settings)
+
+        print content
+
+
+if __name__ == '__main__':
+    import sys
+    args = sys.argv
+
+    if len(args) < 2:
+      print """  Usage: ./grok2html.py pageid restsource > pageid.html
+      Prints to stdout the results of parsing restsource with grok template."""
+    else:
+        handler_html(args[1], args[2])


Property changes on: grok/trunk/doc/grok2html.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: grok/trunk/doc/index.txt
===================================================================
--- grok/trunk/doc/index.txt	2007-03-29 13:22:01 UTC (rev 73911)
+++ grok/trunk/doc/index.txt	2007-03-29 13:46:59 UTC (rev 73912)
@@ -0,0 +1,116 @@
+=============
+What is Grok?
+=============
+
+.. image:: ./resources/evencaveman.jpg
+   :alt: Now even cavemen can use Zope3
+   :class: right
+
+Grok is a web application framework for Python developers. It is aimed at both
+beginners and very experienced web developers. Grok has an emphasis on agile
+development. Grok is easy and powerful.
+
+You will likely have heard about many different web frameworks for Python as
+well as other languages. Why should you consider Grok?
+
+* Grok offers a *lot* of building blocks for your web application.
+* Grok is informed by a *lot* of hard-earned wisdom.
+
+Grok accomplishes this by being based on `Zope 3`_, an advanced
+object-oriented web framework. While Grok is based on Zope 3, and
+benefits a lot from it, you do not need to know Zope at all in order
+to get productive with Grok.
+
+`Read More`_
+
+.. _Zope 3: http://wiki.zope.org/zope3
+.. _read more: ./about.html
+
+
+Who is Grok?
+------------
+
+.. image:: ./resources/grok-standing.jpg
+   :alt: Grok!
+   :class: right
+
+Grok is a friendly caveman from the Stone Age. He has a big club that he hunts
+mammoths with. He will also use this club to smash anything he doesn't like.
+
+"ME GROK SMASH ZCML!"
+
+The word grok comes from the novel `Stranger in a Strange Land`_ by Robert A.
+Heinlein, and is defined in his book as:
+
+  Grok means to understand so thoroughly that the observer becomes part of the
+  observed - to merge, blend, intermarry, lose identity in group experience.
+
+.. _Stranger in a Strange Land: http://en.wikipedia.org/wiki/Stranger_in_a_Strange_Land
+
+Watch Grok in Action
+--------------------
+
+* `Simple ToDo`_ application is a tutorial-style introduction to Grok by Philipp von Weitershausen.
+* `Introduction to Grok`_ is a talk given by Philipp von Weitershausen to a group of Zope developers.
+
+.. _Simple ToDo: http://www.archive.org/details/grok_todo_part1 
+.. _Introduction to Grok: http://comlounge.tv/blog/archive/2007/02/11/cltv23-snow-sprint-2007-grok-presentation
+
+
+What does Grok code look like?
+------------------------------
+
+::
+
+    import grok
+
+    class HelloWorld(grok.Application, grok.Model):
+        pass
+
+        index = grok.PageTemplate("""
+        <html><body>
+            <p>ME GROK HELLO WORLD!</p>
+        </body></html>
+        """")
+
+* `Herd of Mammoths`_ is a very simple application that only goes a bit beyond "hello world".
+* `Grokstar`_ is a simple wiki application written with Grok.
+* `Grok Wiki`_ is a simple wiki application written with Grok.
+
+.. _Herd of Mammoths: http://www.z3lab.org/sections/blogs/philipp-weitershausen/2007_01_09_you-thought-zope-3-wasn
+.. _Grokstar: http://svn.zope.org/Grokstar/
+.. _Grok Wiki: http://svn.zope.org/grok/trunk/grokwiki/
+
+ME GROK HYPERLINKS!
+-------------------
+
+* Get the latest version in the form of a `Grok Python Package`_ from the Python Cheese Shop.
+* Feature requests and bugs are tracked in the `Grok Issue Tracker`_ at LaunchPad.
+* `Grok-dev mailing list`_ for discussing the development of Grok.
+* There is a `Grok IRC`_ channel on `freenode.net`_
+
+.. _Grok Python Package: http://cheeseshop.python.org/pypi/grok
+.. _Grok Issue Tracker: https://launchpad.net/grok
+.. _Grok-dev mailing list: http://mail.zope.org/mailman/listinfo/grok-dev
+.. _Grok IRC: irc://irc.freenode.net/grok
+.. _freenode.net: http://freenode.net/
+
+The source code to Grok is kept in the Zope SVN repository. You can do an
+anonymous check out of the latest version of Grok with the following command:::
+
+  svn co svn://svn.zope.org/repos/main/grok/trunk grok
+
+ME GROK SPRINTS AND BLOGS!
+--------------------------
+
+Grok development is often done in the form of sprints. A sprint is a when a
+group of developers get together in the same place and all work on a focused
+set of tasks.
+
+* `Martijn Faassen's blog entry`_ details the first Grok sprint.
+* `Jan-Wijbrand Kolman blogged`_ about the second Grok sprint, and `Martijn Faassen
+  blogged`_ about it as well.
+
+.. _Martijn Faassen's blog entry: http://faassen.n--tree.net/blog/view/weblog/2006/11/09/0
+.. _Jan-Wijbrand Kolman blogged: http://jw.n--tree.net/blog/dev/python/second-grok-sprint
+.. _Martijn Faassen blogged: http://faassen.n--tree.net/blog/view/weblog/2007/01/09/0


Property changes on: grok/trunk/doc/index.txt
___________________________________________________________________
Name: svn:keywords
   + Date Author

Added: grok/trunk/doc/template.pt
===================================================================
--- grok/trunk/doc/template.pt	2007-03-29 13:22:01 UTC (rev 73911)
+++ grok/trunk/doc/template.pt	2007-03-29 13:46:59 UTC (rev 73912)
@@ -0,0 +1,68 @@
+<metal:block define-macro="pagelayout">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+  <title tal:content="context/title" />
+  <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
+  <meta name="description" content="Grok - now even cavemen can use Zope3" />
+  <meta name="keywords" content="Grok, internet, zope, zope3, software, web apps, web applications, python" />
+	<style type="text/css"><!-- @import url(./resources/grok.css); --></style>
+</head>
+
+<body>
+<div class="header">
+	
+	<a href="http://grok.zope.org">
+	<img src="./resources/grok-header.jpg" alt="GROK"/></a>
+	<ul id="navigation">
+        <li tal:repeat="item context/menu">
+            <a tal:content="item/title"
+               tal:attributes="title item/description;
+                               class item/klass;
+                               href item/href">link</a></li>
+  </ul>
+</div>
+
+
+<div class="roundcont">
+	
+  <div class="roundtop">
+    <img src="./resources/corner-topleft.jpg" alt="" 
+           width="45" height="45" class="corner" 
+           style="display: none" />
+  </div>
+
+  <div class="content">
+
+          <tal:block replace="structure context/content" />
+
+  </div>
+
+  <div class="roundbottom">
+     <img src="./resources/corner-bottomleft.jpg" alt="" 
+     width="45" height="45" class="corner" 
+     style="display: none" />
+  </div>
+
+</div>
+
+<div class="footer">
+	
+	<table><tr><td>
+	Grok cooks around the campfire of <br />
+	<a href="http://wiki.zope.org/zope3/FrontPage"><img src="./resources/zopelogo.gif" alt="Zope" style="padding: 0.5em;" /></a>
+	</td><td>
+	 and roams free on the savannah of<br />
+	<a href="http://www.python.org"><img src="./resources/python-logo.gif" style="padding: 0.5em;" alt="Python" /></a>
+	</td></tr>
+	</table>
+
+	<p>Hosting provided by <a href="http://quintagroup.com/"><b>Quintagroup</b></a></p>
+</div>
+
+</body>
+</html>
+</metal:block>
+



More information about the Checkins mailing list