[ckan-changes] commit/ckanext-pdeu: 3 new changesets

Bitbucket commits-noreply at bitbucket.org
Tue Jun 7 19:04:52 UTC 2011


3 new changesets in ckanext-pdeu:

http://bitbucket.org/okfn/ckanext-pdeu/changeset/2f96cc606dc2/
changeset:   2f96cc606dc2
user:        pudo
date:        2011-06-07 19:53:43
summary:     redirect tag pages to package search and fix search facet theming
affected #:  4 files (745 bytes)

--- a/ckanext/pdeu/harvesters.py	Tue Jun 07 13:36:32 2011 +0100
+++ b/ckanext/pdeu/harvesters.py	Tue Jun 07 19:53:43 2011 +0200
@@ -470,9 +470,10 @@
                 package_dict['extras']['temporal_coverage'] = elem.xpath("string()")
             elif key == 'Aktualisierung':
                 package_dict['extras']['temporal_granularity'] = elem.xpath("string()")
-            elif key == 'Kategorien':
-                package_dict['extras']['categories'] = elem.xpath("string()")
-            elif key == 'Typ':
+            elif key == 'Kategorien': 
+                categories = elem.xpath("string()").split(',')
+                package_dict['extras']['categories'] = [c.strip() for c in categories]
+            elif key == 'Typ': 
                 package_dict['extras']['type'] = elem.xpath("string()")
             elif key == u'Attribute':
                 elem.tag = 'span'


--- a/ckanext/pdeu/plugin.py	Tue Jun 07 13:36:32 2011 +0100
+++ b/ckanext/pdeu/plugin.py	Tue Jun 07 19:53:43 2011 +0200
@@ -1,15 +1,27 @@
 from ckan.plugins import implements, IRoutes, SingletonPlugin
 
+from ckan.lib.base import BaseController
+from ckan.lib.base import abort, redirect, h
+
+class RewiringController(BaseController):
+
+    def tag(self, tags):
+        redirect(h.url_for(controller='package', action='search', tags=tags))
+
 class DCatApi(SingletonPlugin):
     implements(IRoutes)
-        
+
     def before_map(self, route_map):
-        controller = "ckanext.pdeu.controllers:DCatApiController"
+        dcat_controller = "ckanext.pdeu.controllers:DCatApiController"
+        route_map.connect("/package/{id}.rdf", controller=dcat_controller,
+                          action="show")
 
-        route_map.connect("/package/{id}.rdf", controller=controller,
-                          action="show")
+        wire_controller = "ckanext.pdeu.plugin:RewiringController"
+        route_map.connect("/tag/{tags}", controller=wire_controller,
+                          action="tag")
 
         return route_map
 
     def after_map(self, route_map):
         return route_map
+


--- a/theme/public/css/style.css	Tue Jun 07 13:36:32 2011 +0100
+++ b/theme/public/css/style.css	Tue Jun 07 19:53:43 2011 +0200
@@ -209,6 +209,7 @@
   border-right: 1px solid #e0e0e0;
   margin-right: -10px;
   padding-right: 9px;
+  overflow: hidden;
 }
 
 #sidebar h2, #sidebar h3 {
@@ -257,11 +258,9 @@
 
 }
 
-.facet-box h2 {
+#sidebar .facet-box h2 {
     color: #000;
     font-size: 1.2em;
-    font-weight: bold;
-    margin-top: 1em;
 }
 
 .facet-options {
@@ -270,7 +269,6 @@
 
 .facet-options li {
     padding-top: 0.2em;
-    font-size: 1.2em; 
     color: #000; 
 }
 
@@ -299,14 +297,22 @@
     display: inline-block;
     margin-right: 5px;
     margin-bottom: 10px;
-    padding: 1px 1px 3px 2px;
+    padding: 2px 2px 4px 3px;
     font-size: 14px;
-    background-color: #eee;
+    background-color: #E5ECF9;
+    -moz-border-radius: 3px;
+    -webkit-border-radius: 3px;
+    border-radius: 3px;
     line-height: 16px;
+    /*
     -moz-box-shadow: 1px 1px 3px #bbb;
     -webkit-box-shadow: 1px 1px 3px #bbb;
     box-shadow: 1px 1px 3px #bbb;
-    
+    */
+}
+
+.search-field img {
+    margin-bottom: -3px;
 }
 
 .search-field-name::after {
@@ -511,6 +517,16 @@
     margin-bottom: 1px !important;
 }
 
+.package-search-filters {
+  margin-top: 1em;
+  margin-bottom: 1em;
+  color: #888;
+}
+
+.package-search-filters label {
+  padding-left: 1em;
+}
+
 /* =================== */
 /* = Package listing = */
 /* =================== */


--- a/theme/templates/layout_base.html	Tue Jun 07 13:36:32 2011 +0100
+++ b/theme/templates/layout_base.html	Tue Jun 07 19:53:43 2011 +0200
@@ -73,7 +73,7 @@
       </header></div><py:with vars="messages = list(h._flash.pop_messages())">
-    <div class="class flash-banner-box" py:if="len(messages)">
+    <div class="class container flash-banner-box" py:if="len(messages)"><div class="flash-banner ${m.category}" py:for="m in messages">
         ${m.message}
       </div>


http://bitbucket.org/okfn/ckanext-pdeu/changeset/0711cccc049d/
changeset:   0711cccc049d
user:        pudo
date:        2011-06-07 19:58:35
summary:     Basic soup to sense scripts to normalize content
affected #:  4 files (2.7 KB)

--- a/.hgignore	Tue Jun 07 19:53:43 2011 +0200
+++ b/.hgignore	Tue Jun 07 19:58:35 2011 +0200
@@ -10,3 +10,5 @@
 development.ini
 *.swp
 *.swo
+CREDENTIALS.py
+


--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/CREDENTIALS.py.tmpl	Tue Jun 07 19:58:35 2011 +0200
@@ -0,0 +1,6 @@
+
+HOST = 'http://localhost:5000/api'
+API_KEY = ''
+
+GOOGLE_USER = 'okfn.admin'
+GOOGLE_PASS = ''


--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/normalization.py	Tue Jun 07 19:58:35 2011 +0200
@@ -0,0 +1,51 @@
+from datautil.normalization.table_based import Formats, Licenses
+from datautil.normalization.table_based import Normalizer, NormalizerJoin
+from CREDENTIALS import GOOGLE_USER, GOOGLE_PASS
+from traverse import traverse
+
+from pprint import pprint
+
+def Categories(username, password):
+    doc_id = 'tE-DPw3k0uXxgNUk1Q8_U_w'
+    first = Normalizer(username, password, doc_id, 'Mapping', 'category')
+    second = Normalizer(username, password, doc_id, 'Groups', 'group_name')
+    return NormalizerJoin(first, second)
+
+
+class formats(object):
+
+    def __init__(self):
+        self.normalizer = Formats(GOOGLE_USER, GOOGLE_PASS)
+        self.categories = set()
+
+    def __call__(self, client, pkg):
+        out_res = []
+        for res in pkg.get('resources', []):
+            if res.get('format') is not None:
+                data = self.normalizer.get(res.get('format'),
+                                           source_hint=pkg.get('ckan_url'))
+                if data.get('mimetype'):
+                    res['format'] = data.get('mimetype')
+            out_res.append(res)
+        pkg['resources'] = out_res
+        return pkg
+
+class categories(object):
+
+    def __init__(self):
+        self.normalizer = Categories(GOOGLE_USER, GOOGLE_PASS)
+
+    def __call__(self, client, pkg):
+        cats = pkg.get('extras', {}).get('categories', [])
+        if not isinstance(cats, (list, tuple)):
+            cats = [cats]
+        for cat in cats:
+            data = self.normalizer.get(cat, source_hint=pkg.get('ckan_url'))
+            if data.get('group_name'):
+                pprint(data)
+        #return pkg
+
+if __name__ == '__main__':
+    traverse(categories())
+
+


--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/traverse.py	Tue Jun 07 19:58:35 2011 +0200
@@ -0,0 +1,32 @@
+from pprint import pprint 
+from ckanclient import CkanClient
+from itertools import count
+from CREDENTIALS import API_KEY, HOST
+
+PAGE_SIZE = 50
+
+def traverse(pkg_func, query='*:*'):
+    client = CkanClient(base_location=HOST, api_key=API_KEY)
+    for page in count(1):
+        results_page = client.package_search(query, search_options={
+            'offset': page*PAGE_SIZE, 'limit': PAGE_SIZE})
+        #pprint(results_page)
+        if not len(results_page.get('results', [])): 
+            break
+        for pkg_name in results_page.get('results', []):
+            print "Traversing", pkg_name
+            pkg = client.package_entity_get(pkg_name)
+            ret = pkg_func(client, pkg)
+            if ret is not None:
+                client.package_entity_put(ret, package_name=pkg_name)
+
+
+def test_write(client, pkg):
+    pkg['extras']['traversed'] = True
+    #pprint(pkg)
+    return pkg
+
+if __name__ == '__main__':
+    traverse(test_write)
+
+


http://bitbucket.org/okfn/ckanext-pdeu/changeset/28dd506ddf26/
changeset:   28dd506ddf26
user:        pudo
date:        2011-06-07 21:04:45
summary:     remove dcat controller as now lives in ckanext-rdf
affected #:  2 files (187 bytes)

--- a/ckanext/pdeu/controllers.py	Tue Jun 07 19:58:35 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-import logging
-from pylons import response
-from ckan import model
-from ckan.model import Package
-
-from ckan.controllers.api import ApiController
-from ckan.lib.base import abort
-
-from ckanext.rdf.produce import pkg_produce
-
-
-log = logging.getLogger(__name__)
-
-class DCatApiController(ApiController):
-
-    def show(self,id):
-        package = Package.get(id)
-        if package:
-            graph = pkg_produce(package)
-            
-            doc = graph.serialize(format='pretty-xml')
-            response.content_type = 'application/rdf+xml'
-            response.headers['Content-Length'] = len(doc)
-
-            return doc
-        else:
-            abort(404)
-


--- a/ckanext/pdeu/plugin.py	Tue Jun 07 19:58:35 2011 +0200
+++ b/ckanext/pdeu/plugin.py	Tue Jun 07 21:04:45 2011 +0200
@@ -8,14 +8,11 @@
     def tag(self, tags):
         redirect(h.url_for(controller='package', action='search', tags=tags))
 
+
 class DCatApi(SingletonPlugin):
     implements(IRoutes)
 
     def before_map(self, route_map):
-        dcat_controller = "ckanext.pdeu.controllers:DCatApiController"
-        route_map.connect("/package/{id}.rdf", controller=dcat_controller,
-                          action="show")
-
         wire_controller = "ckanext.pdeu.plugin:RewiringController"
         route_map.connect("/tag/{tags}", controller=wire_controller,
                           action="tag")

Repository URL: https://bitbucket.org/okfn/ckanext-pdeu/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.




More information about the ckan-changes mailing list