Skip to content

Commit

Permalink
* Feature: Add visualizations column on sparql folder listing view
Browse files Browse the repository at this point in the history
  [voineali refs #5005]
* Bug fix: Include dependencies within zcml and profile metadata
  [voineali]
  • Loading branch information
voineali committed May 7, 2012
1 parent 30e5db8 commit d1d37a6
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 44 deletions.
4 changes: 4 additions & 0 deletions docs/HISTORY.txt
Expand Up @@ -3,6 +3,10 @@ Changelog

1.4-dev - (unreleased)
----------------------
* Feature: Add visualizations column on sparql folder listing view
[voineali refs #5005]
* Bug fix: Include dependencies within zcml and profile metadata
[voineali]

1.3 - (2012-04-26)
------------------
Expand Down
11 changes: 7 additions & 4 deletions eea/sparql/browser/css/view.css
Expand Up @@ -21,13 +21,16 @@ table.sparql-results {
border-collapse: collapse;
}

table.sparql-results th, table.sparql-results td {
padding: 3px;
}

table.sparql-results th {
border: 1px solid #999;
background: #ececec;
text-align: center;
}

table.sparql-results th, table.sparql-results td {
padding: 3px;
table.sparql-results td {
vertical-align: middle;
}

p.sparql-stats .number {
Expand Down
16 changes: 16 additions & 0 deletions eea/sparql/browser/sparql.py
Expand Up @@ -7,6 +7,7 @@
from Products.ZSPARQLMethod.Method import map_arg_values
from Products.ZSPARQLMethod.Method import parse_arg_spec
from eea.sparql.converter.sparql2json import sparql2json
from eea.versions import versions
from Products.CMFCore.utils import getToolByName
from time import time
import json
Expand Down Expand Up @@ -234,6 +235,21 @@ def syncQueries(self):
self.context.syncQueries()
self.request.response.redirect(self.context.absolute_url() + "/@@view")

def getVisualizations(self, title):
""" Get Daviz Visualizations for sparql object
"""
ob = None
for sparql in self.context.values():
if sparql.title == title:
ob = versions.get_versions_api(
sparql).latest_version()
break
if not ob:
return []

return ob.getBRefs('relatesTo')


class SparqlBookmarkFoldersSync(BrowserView):
""" Sync all Bookmark Folders """

Expand Down
88 changes: 48 additions & 40 deletions eea/sparql/browser/view-bookmarks.pt
Expand Up @@ -49,24 +49,38 @@
<input type="submit" value="Synchronize Queries with Bookmarks" class="context"/>
</form>

<table class="sparql-results" tal:condition="options/data">
<table class="listing sparql-results" tal:condition="options/data">
<thead>
<tr>
<th>
Label
</th>
<th>
<th style="width: 40%">
Bookmark
</th>
<th style="width: 50%">
Existing visualizations
</th>
<th></th>
</tr>
</thead>
<tbody>
<tr tal:repeat="row options/data">
<td tal:content="row/name">
</td>
<tal:row repeat="row options/data">
<tr tal:define="odd repeat/row/odd"
tal:attributes="class python: odd and 'odd' or 'even'">
<td>
<a tal:attributes="href python:bookmarks_url+'?uri='+row['bookmark']" tal:content="python: row['bookmark']">bookmark</a>
<a tal:attributes="href python:bookmarks_url+'?uri='+row['bookmark']"
tal:content="row/name" target="_blank">bookmark</a>
</td>
<td tal:define="name row/name">
<div tal:repeat="vis python:view.getVisualizations(name)">
<a tal:attributes="href vis/absolute_url; title vis/pretty_title_or_id">
<span tal:condition="exists:vis/image_tile">
<img tal:attributes="
title vis/pretty_title_or_id;
alt vis/pretty_title_or_id;
src string:${vis/absolute_url}/image_tile" />
</span>
<span tal:content="vis/pretty_title_or_id" />
</a>
</div>
</td>
<td>
<form action="addOrUpdateQueryFromBookmark" method="POST">
Expand All @@ -76,6 +90,7 @@
</form>
</td>
</tr>
</tal:row>
</tbody>
</table>

Expand All @@ -93,37 +108,30 @@
tal:content="options/error"/>

<br/>
<label>Downloads:</label>
<br/>
<a tal:attributes="href string:${context/absolute_url}/download.json">
JSON
</a>
<br/>
<a tal:attributes="href string:${context/absolute_url}/download.exhibit">
Exhibit JSON
</a>
<br/>
<a tal:attributes="href string:${context/absolute_url}/download.table">
HTML
</a>
<br/>
<a tal:attributes="href string:${context/absolute_url}/download.xml">
XML
</a>
<br/>
<a tal:attributes="href string:${context/absolute_url}/download.schema.xml">
XML with Schema
</a>
<br/>
<a tal:attributes="href string:${context/absolute_url}/download.csv">
CSV
</a>
<br/>
<a tal:attributes="href string:${context/absolute_url}/download.tsv">
TSV
</a>
<br/>

<h3>Downloads:</h3>
<div class="eea-sparql-downloads">
<a tal:attributes="href string:${context/absolute_url}/download.json">
JSON
</a>
<a tal:attributes="href string:${context/absolute_url}/download.exhibit">
Exhibit JSON
</a>
<a tal:attributes="href string:${context/absolute_url}/download.table">
HTML
</a>
<a tal:attributes="href string:${context/absolute_url}/download.xml">
XML
</a>
<a tal:attributes="href string:${context/absolute_url}/download.schema.xml">
XML with Schema
</a>
<a tal:attributes="href string:${context/absolute_url}/download.csv">
CSV
</a>
<a tal:attributes="href string:${context/absolute_url}/download.tsv">
TSV
</a>
</div>
</div>
</body>
</html>
3 changes: 3 additions & 0 deletions eea/sparql/configure.zcml
Expand Up @@ -5,8 +5,11 @@
xmlns:i18n="http://namespaces.zope.org/i18n"
i18n_domain="eea.sparql">

<includeDependencies package="." />

<five:registerPackage package="." initialize=".initialize" />


<include package=".browser" />
<include package=".cache" />
<include package=".content" />
Expand Down
3 changes: 3 additions & 0 deletions eea/sparql/profiles/default/metadata.xml
@@ -1,4 +1,7 @@
<?xml version="1.0"?>
<metadata>
<version>1001</version>
<dependencies>
<dependency>profile-eea.versions:default</dependency>
</dependencies>
</metadata>

0 comments on commit d1d37a6

Please sign in to comment.