Difference between revisions of "Planet Venus"

From Creative Commons
Jump to: navigation, search
(New page: Creative Commmons uses feed aggregation software to collect in one place CC blogs, jurisdictions blogs, and also blogs of people and organizations that are closely associated with or activ...)
 
Line 3: Line 3:
 
The software we are using to do this is called [http://www.intertwingly.net/blog/2006/08/16/Venus-Rising Planet Venus], which is a major rewrite of [http://www.planetplanet.org Planet] done by [http://en.wikipedia.org/wiki/Sam_Ruby San Ruby].  For more information and documentation on Planet Venus, please see the [http://intertwingly.net/code/venus/ project's page].
 
The software we are using to do this is called [http://www.intertwingly.net/blog/2006/08/16/Venus-Rising Planet Venus], which is a major rewrite of [http://www.planetplanet.org Planet] done by [http://en.wikipedia.org/wiki/Sam_Ruby San Ruby].  For more information and documentation on Planet Venus, please see the [http://intertwingly.net/code/venus/ project's page].
  
CC has slightly extended Planet Venus via a few plugins.  First of all, as licensing information is eminently important to CC, we have created a plugin that will pull license information from the feeds and make it available to the HTML templates.  For an example of the output, take a look at the [http://planet.creativecommons.org CC Planet].  The plugin name is get_license_name.plugin and can be [http://cctools.svn.sourceforge.net/viewvc/cctools/planet/branches/production/software/filters/get_license_name.plugin?revision=9156&view=markup viewed/downloaded] at the [http://cctools.svn.sourceforge.net/viewvc/cctools/ cctools] subversion repository at sourceforge.net.
+
CC has slightly extended Planet Venus via a few plugins.  First of all, as licensing information is eminently important to CC, we have created a plugin that will pull license information from the feeds and make it available to the HTML templates.  For an example of the output, take a look at the [http://planet.creativecommons.org CC Planet].  The plugin is a pythong script named get_license_name.plugin and can be [http://cctools.svn.sourceforge.net/viewvc/cctools/planet/branches/production/software/filters/get_license_name.plugin?revision=9156&view=markup viewed/downloaded] at the [http://cctools.svn.sourceforge.net/viewvc/cctools/ cctools] subversion repository at sourceforge.net.
  
 
<div style="border: 1px dashed blue; padding: 1ex;">
 
<div style="border: 1px dashed blue; padding: 1ex;">
 
'''NOTE''': the plugin only works for [http://htmltmpl.sourceforge.net/ HTMLTMPL] templates.  XSLT and Genshi templates have full access to every feed element and therefore can extract licensing data directly.
 
'''NOTE''': the plugin only works for [http://htmltmpl.sourceforge.net/ HTMLTMPL] templates.  XSLT and Genshi templates have full access to every feed element and therefore can extract licensing data directly.
 
</div>
 
</div>
 +
 +
The get_license_name.plugin requires a couple of semi-non-standard Python modules: [ http://www.crummy.com/software/BeautifulSoup/ Beautiful Soup] and [http://wiki.creativecommons.org/RdfaDict rdfadict].  The plugin self documents to some extent via comments and in any case is not so big.
 +
 +
'''In order for the plugin to work''', a small patch much also be applied to the Planet Venus code iteslf -- to a single file: planet/shell/tmpl.py.  Most of the patch below is context and comments.
 +
 +
<pre>
 +
--- venus/planet/shell/tmpl.py  2007-12-21 19:24:02.000000000 -0800
 +
+++ branches/production/software/planet/shell/tmpl.py  2008-02-22 15:35:18.000000000 -0800
 +
@@ -120,6 +120,8 @@
 +
    ['published', PlanetDate, 'published_parsed'],
 +
    ['published_822', Rfc822, 'published_parsed'],
 +
    ['published_iso', Rfc3399, 'published_parsed'],
 +
+    ['license', String, 'source', 'links', {'rel': 'license'}, 'href'],
 +
+    ['default_license', String, 'source', 'planet_default_license']
 +
]
 +
 +
# Add additional rules for source information
 +
@@ -141,6 +143,15 @@
 +
                    elif node.get('type','')=='application/xhtml+xml':
 +
                        node['value'] = empty.sub(r"<\1 />", node['value'])
 +
                node = node[path]
 +
+                     
 +
+            # This is a special-case elif needed to grab license info from the
 +
+            # feed data.  Normally node will be a simple list or dict, but in
 +
+            # the case of license information, node is a list of lists, so we
 +
+            # need to look inside the first item, which is where the license
 +
+            # data seems to always be.
 +
+            elif isinstance(path, str) and isinstance(node, list) and \
 +
+                    path in node[0]:
 +
+                node = node[0][path]
 +
            elif isinstance(path, int):
 +
                node = node[path]
 +
            elif isinstance(path, dict):
 +
@@ -155,8 +166,20 @@
 +
            else:
 +
                break
 +
        else:
 +
-            if node: output[rule[0]] = rule[1](node)
 +
-       
 +
+            # If this node contains license information, indicated by rule[0]
 +
+            # being 'license' or 'default_license' (from list Items), then
 +
+            # drop the the license URI into a variable that will be accessible
 +
+            # by the template.  'default_license' is specified in the config
 +
+            # of each blog, and can be used if no other license data is found
 +
+            # in the feed itself.
 +
+            if node:
 +
+                if rule[0] == 'license' or rule[0] == 'default_license':
 +
+                    output[rule[0]] = '<a about="%s" rel="license" \
 +
+                        href="%s" title="License information">License</a>' \
 +
+                        % (source.link, node)
 +
+                else:
 +
+                    output[rule[0]] = rule[1](node)
 +
+
 +
    # copy over all planet namespaced elements from parent source
 +
    for name,value in source.items():
 +
        if name.startswith('planet_'):
 +
</pre>

Revision as of 20:11, 29 February 2008

Creative Commmons uses feed aggregation software to collect in one place CC blogs, jurisdictions blogs, and also blogs of people and organizations that are closely associated with or actively involved in the CC community.

The software we are using to do this is called Planet Venus, which is a major rewrite of Planet done by San Ruby. For more information and documentation on Planet Venus, please see the project's page.

CC has slightly extended Planet Venus via a few plugins. First of all, as licensing information is eminently important to CC, we have created a plugin that will pull license information from the feeds and make it available to the HTML templates. For an example of the output, take a look at the CC Planet. The plugin is a pythong script named get_license_name.plugin and can be viewed/downloaded at the cctools subversion repository at sourceforge.net.

NOTE: the plugin only works for HTMLTMPL templates. XSLT and Genshi templates have full access to every feed element and therefore can extract licensing data directly.

The get_license_name.plugin requires a couple of semi-non-standard Python modules: [ http://www.crummy.com/software/BeautifulSoup/ Beautiful Soup] and rdfadict. The plugin self documents to some extent via comments and in any case is not so big.

In order for the plugin to work, a small patch much also be applied to the Planet Venus code iteslf -- to a single file: planet/shell/tmpl.py. Most of the patch below is context and comments.

--- venus/planet/shell/tmpl.py  2007-12-21 19:24:02.000000000 -0800
+++ branches/production/software/planet/shell/tmpl.py   2008-02-22 15:35:18.000000000 -0800
@@ -120,6 +120,8 @@
     ['published', PlanetDate, 'published_parsed'],
     ['published_822', Rfc822, 'published_parsed'],
     ['published_iso', Rfc3399, 'published_parsed'],
+    ['license', String, 'source', 'links', {'rel': 'license'}, 'href'],
+    ['default_license', String, 'source', 'planet_default_license']
 ]
 
 # Add additional rules for source information
@@ -141,6 +143,15 @@
                     elif node.get('type','')=='application/xhtml+xml':
                         node['value'] = empty.sub(r"<\1 />", node['value'])
                 node = node[path]
+                      
+            # This is a special-case elif needed to grab license info from the
+            # feed data.  Normally node will be a simple list or dict, but in
+            # the case of license information, node is a list of lists, so we
+            # need to look inside the first item, which is where the license
+            # data seems to always be.
+            elif isinstance(path, str) and isinstance(node, list) and \
+                    path in node[0]:
+                node = node[0][path]
             elif isinstance(path, int):
                 node = node[path]
             elif isinstance(path, dict):
@@ -155,8 +166,20 @@
             else:
                 break
         else:
-            if node: output[rule[0]] = rule[1](node)
-        
+            # If this node contains license information, indicated by rule[0]
+            # being 'license' or 'default_license' (from list Items), then
+            # drop the the license URI into a variable that will be accessible
+            # by the template.  'default_license' is specified in the config
+            # of each blog, and can be used if no other license data is found
+            # in the feed itself.
+            if node:
+                if rule[0] == 'license' or rule[0] == 'default_license':
+                    output[rule[0]] = '<a about="%s" rel="license" \
+                        href="%s" title="License information">License</a>' \
+                        % (source.link, node)
+                else:
+                    output[rule[0]] = rule[1](node)
+
     # copy over all planet namespaced elements from parent source
     for name,value in source.items():
         if name.startswith('planet_'):