-
Notifications
You must be signed in to change notification settings - Fork 15
Filters in LODSPeaKr
The [LODSPeaKr templating system](Templating system in LODSPeaKr) comprises model queries that feed view templates.
Filters preprocess result values before inserting it into the view template. LODSPeaKr provides a way to embed javascript objects using Haanga filters.
Lets say we have a model and view for foaf:Person
components/types/foaf:Person/ # This directory contains queries for instances of class foaf:Person
|->queries/
| |-> personalDetails.query # This file contains a SPARQL query
| |-> friends.query # This file contains a SPARQL query
|->html.template
In friends
we have the following query
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?lastname WHERE{
<{{uri}}> foaf:knows [ foaf:firstName ?name;
foaf:lastName ?lastname
].
}
In the view foaf:Person.view.html
we can do the following
<html>
<head>
<title>My Page</title>
</head>
<body>
My friends {{models.friends|GoogleVizTable:"name,lastname"}}
</body>
</html>
The whole array is passed to the filter, and the parameters and passed after it in quotes and separated by commas. The result (assuming there is data that matches the query) is something like this:
Besides the existing filters in Haanga, LODSPeaKr have a few (but soon the list should increase)
TODO: The arguments should be more consistent!
-
Explode
, returns an array based on a string and a delimiter-
{{first.myModel.myString.value|explode:" "|length}}
returns the number of words (separated by " ") in the variable
-
-
Pop
, returns the last value in an array{{first.myModel.myString.value|explode:" "|pop}}
-
Date
(look at the php documentation for formatting options){{first.myModel.myDate.value|date:"l jS \of F Y h:i:s A"}}
{{first.myModel.myDate.value|date:"H:i l F jS \o"}}
-
hostname
, returns which hostname (e.g.,www.example.org
) from a URI -
URIScheme
, returns which scheme (e.g., http, https) is used in the URI-
{{first.myModel.myUri.value|urischeme}}
returnshttps
-
-
URIPath
, returns the path (without the hostname or URI fragment) of a URI-
{{first.myModel.myUri.value|uripath}}
returns something like/my/path/foo/bar.html
-
-
URIFragment
, returns the fragment after a#
in a URI. If no#
is found, returns the whole URI{{first.myModel.myDate.value|urifragment}}
-
http://www.w3.org/2004/02/skos/core#Concept
will returnConcept
-
http://xmlns.com/foaf/0.1/Group
will returnhttp://xmlns.com/foaf/0.1/Group
-
Urifier
, converts an URI in a set of segments so it can be used as arguments by a service. A details example is available at Example: how to pass uris as arguments -
Deurifier
, translates a set of segments (e.g,{{lodspk.args.all|deurifier}}
) and translate into a proper URI. A details example is available at Example: how to pass uris as arguments
###Visualization filters A special category of filters provides javascript-based visualizations
- CirclePacking
{{D3CirclePacking|childNode,parentNode}}
- D3Dendrogram
{{D3Dendrogram|childNode,parentNode}}
- D3ForceGraph
{{D3ForceGraph|sourceNode,TargetNode}}
- D3ParallelCoordinates
{{D3ParallelCoordinates|label,value1,value2,...,valueN}}
- D3WordCloud
{{D3WordCloud|variableWithFreeText}}
{{D3WordCloud|phraseVariable,sizeOfPhrase}}
{{D3WordCloud|phraseVariable,sizeOfPhrase,linkOnEachPhrase}}
- D3RadarChart
{{D3RadarChart|value1,value2,value3,...,valueN}}
- Timeknots
{{Timeknots|date,label[,image]}}
- GoogleMaps
{{GoogleMaps|latitude,longitude,label}}
- GoogleVizBarChart
{{GoogleVizBarChart|valuesInAxisX,valuesInAxisY}}
- GoogleVizColumnChart
{{GoogleVizColumnChart|valuesInAxisX,valuesInAxisY}}
- GoogleVizLineChart
{{GoogleVizLineChart|valuesInAxisX,valuesInAxisY}}
- GoogleVizPieChart
{{GoogleVizPieChart|valuesInAxisX,valuesInAxisY}}
- GoogleVizScatterChart
{{GoogleVizScatterChart|valuesInAxisX,valuesInAxisY}}
- GoogleVizTable
{{GoogleVizTable|column1,column2,...,columnN}}
To get an abbreviated URL like https://raw.github.com...golfers.xls.zip
from https://raw.github.com/timrdf/csv2rdf4lod-automation/master/doc/examples/source/lebot/golfers/version/original/manual/golfers.xls.zip
, use either of the following:
http://{{row.resource.value|hostname}}...{{row.resource.value|explode:"/"|pop}}
- if your URLs don't have a URI fragment:
http://{{row.resource.value|hostname}}...{{row.resource.value|path|explode:"/"|pop}}
- Learn about how to create custom Status pages