From 6f848893afbef5698e7deed4fdd86fb6d6e1b610 Mon Sep 17 00:00:00 2001 From: alvaro <alvaro@alia.(none)> Date: Thu, 23 Feb 2012 10:15:03 -0800 Subject: [PATCH] Adding examples to doc/ --- doc/README | 11 ++++++ .../components/services/people/html.template | 18 +++++++++ .../services/people/queries/main.query | 10 +++++ .../services/peopleByName/html.template | 18 +++++++++ .../services/peopleByName/json.template | 11 ++++++ .../services/peopleByName/queries/main.query | 11 ++++++ .../types/foaf:Person/html.template | 38 +++++++++++++++++++ .../types/foaf:Person/queries/attendees.query | 12 ++++++ .../foaf:Person/queries/birthplace.query | 8 ++++ .../queries/endpoint.dbpedia/geo.query | 9 +++++ .../queries/endpoint.dbpedia/location.query | 7 ++++ .../types/foaf:Person/queries/main.query | 10 +++++ .../foaf:Person/queries/personalDetails.query | 12 ++++++ 13 files changed, 175 insertions(+) create mode 100644 doc/README create mode 100644 doc/examples/components/services/people/html.template create mode 100644 doc/examples/components/services/people/queries/main.query create mode 100644 doc/examples/components/services/peopleByName/html.template create mode 100644 doc/examples/components/services/peopleByName/json.template create mode 100644 doc/examples/components/services/peopleByName/queries/main.query create mode 100644 doc/examples/components/types/foaf:Person/html.template create mode 100644 doc/examples/components/types/foaf:Person/queries/attendees.query create mode 100644 doc/examples/components/types/foaf:Person/queries/birthplace.query create mode 100644 doc/examples/components/types/foaf:Person/queries/endpoint.dbpedia/geo.query create mode 100644 doc/examples/components/types/foaf:Person/queries/endpoint.dbpedia/location.query create mode 100644 doc/examples/components/types/foaf:Person/queries/main.query create mode 100644 doc/examples/components/types/foaf:Person/queries/personalDetails.query diff --git a/doc/README b/doc/README new file mode 100644 index 00000000..604e9e25 --- /dev/null +++ b/doc/README @@ -0,0 +1,11 @@ +## Documentation + +The latest version of the documentation is available at + +https://github.com/alangrafu/lodspeakr/wiki + +## Examples + +Some real-world examples are provided under example/components to show how components are used + + diff --git a/doc/examples/components/services/people/html.template b/doc/examples/components/services/people/html.template new file mode 100644 index 00000000..43c17e2c --- /dev/null +++ b/doc/examples/components/services/people/html.template @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" + "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" {% for i, ns in base.ns %}xmlns:{{i}}="{{ns}}" + {%endfor%}version="XHTML+RDFa 1.0" xml:lang="en"> + <head> + <title>TWC People directory</title> + <link href="{{lodspk.baseUrl}}css/basic.css" rel="stylesheet" type="text/css" media="screen" /> + </head> + <body> + <h1>People</h1> + <ul> + {% for row in models.main %} + <li><a href="{{row.people.value}}">{{row.name.value}} - {{row.email.value}}</a></li> + {% endfor %} + </ul> + </body> +</html> diff --git a/doc/examples/components/services/people/queries/main.query b/doc/examples/components/services/people/queries/main.query new file mode 100644 index 00000000..3fcb2fac --- /dev/null +++ b/doc/examples/components/services/people/queries/main.query @@ -0,0 +1,10 @@ +PREFIX foaf: <http://xmlns.com/foaf/0.1/> +PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> + +SELECT DISTINCT ?person ?email ?name WHERE { + GRAPH ?g { + ?person a foaf:Person ; + foaf:name ?name ; + foaf:mbox ?email . + } +}order by ?name diff --git a/doc/examples/components/services/peopleByName/html.template b/doc/examples/components/services/peopleByName/html.template new file mode 100644 index 00000000..982cdd8d --- /dev/null +++ b/doc/examples/components/services/peopleByName/html.template @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" + "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" {% for i, ns in base.ns %}xmlns:{{i}}="{{ns}}" + {%endfor%}version="XHTML+RDFa 1.0" xml:lang="en"> + <head> + <title>TWC People directory</title> + <link href="{{lodspk.baseUrl}}css/basic.css" rel="stylesheet" type="text/css" media="screen" /> + </head> + <body> + <h1>People</h1> + <ul> + {% for row in models.main %} + <li><a href="{{row.person.value}}">{{row.name.value}} - {{row.email.value}}</a></li> + {% endfor %} + </ul> + </body> +</html> diff --git a/doc/examples/components/services/peopleByName/json.template b/doc/examples/components/services/peopleByName/json.template new file mode 100644 index 00000000..9aae3026 --- /dev/null +++ b/doc/examples/components/services/peopleByName/json.template @@ -0,0 +1,11 @@ +{ + "people": [ + {% for row in models.main %} + { + "uri": "{{row.person.value}}", + "name": "{{row.name.value}}", + "email": "{{row.email.value}}" + }{%if ! forloop.last%},{%endif%} + {% endfor %} + ] +} diff --git a/doc/examples/components/services/peopleByName/queries/main.query b/doc/examples/components/services/peopleByName/queries/main.query new file mode 100644 index 00000000..e1d9d71e --- /dev/null +++ b/doc/examples/components/services/peopleByName/queries/main.query @@ -0,0 +1,11 @@ +PREFIX foaf: <http://xmlns.com/foaf/0.1/> +PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> + +SELECT DISTINCT ?person ?email ?name WHERE { + GRAPH ?g { + ?person a foaf:Person ; + foaf:name ?name ; + foaf:mbox ?email . + FILTER(regex(?name, "^{{lodspk.args.arg0}}", "i" )) + } +}order by ?name diff --git a/doc/examples/components/types/foaf:Person/html.template b/doc/examples/components/types/foaf:Person/html.template new file mode 100644 index 00000000..5d3b254b --- /dev/null +++ b/doc/examples/components/types/foaf:Person/html.template @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" + "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" version="XHTML+RDFa 1.0" xml:lang="en"> + <head> + <title>Page about {{lodspk.this.value}}</title> + <link href="{{lodspk.baseUrl}}css/basic.css" rel="stylesheet" type="text/css" media="screen" /> + <link rel="alternate" type="application/rdf+xml" title="RDF/XML Version" href="{{lodspk.this.value}}.rdf" /> + <link rel="alternate" type="text/turtle" title="Turtle Version" href="{{lodspk.this.value}}.ttl" /> + <link rel="alternate" type="text/plain" title="N-Triples Version" href="{{lodspk.this.value}}.nt" /> + <link rel="alternate" type="application/json" title="RDFJSON Version" href="{{lodspk.this.value}}.json" /> + </head> + <body> + <img style='float:right;width:200px' src='{{first.personalDetails.pic.mirroredUri}}'/> + <h1>{{first.personalDetails.name.value}}</h1> + <p>{{first.personalDetails.desc.value}} + </p> + <div> + <h2>{{first.personalDetails.name.value}} has attended meetings with</h2> + <ul> + {% for row in models.attendees %} + <li><a href="{{row.attendee.value}}">{%if row.attendeeName.value%}{{row.attendeeName.value}}{%else%}{{row.attendee.curie}}{%endif%}</a></li> + {%endfor%} + </ul> + </div> + {%if first.dbpedia.bplace == null%} + <div> + {{first.dbpedia.birthplace.bplace.value}} + <h3>Born in: {{first.dbpedia.location.name.value}}</h3> + <div> + <div style="float:left"> + </div><p style="float:left">{{first.dbpedia.location.abstract.value}}</p> + {{models.dbpedia.geo|googlemaps:"lat,lon,name"}} + </div> + {%endif%} + </div> + </body> +</html> diff --git a/doc/examples/components/types/foaf:Person/queries/attendees.query b/doc/examples/components/types/foaf:Person/queries/attendees.query new file mode 100644 index 00000000..19b4390d --- /dev/null +++ b/doc/examples/components/types/foaf:Person/queries/attendees.query @@ -0,0 +1,12 @@ +PREFIX twc: <http://tw.rpi.edu/schema/> +PREFIX foaf: <http://xmlns.com/foaf/0.1/> +SELECT DISTINCT ?attendee ?attendeeName WHERE { + GRAPH <http://tw.rpi.edu:2020/books>{ + ?event twc:hasAttendee <{{uri}}> . + ?event twc:hasAttendee ?attendee . + OPTIONAL{ + ?attendee foaf:name ?attendeeName . + } + FILTER(str(?attendee) != "{{uri}}") + } +} diff --git a/doc/examples/components/types/foaf:Person/queries/birthplace.query b/doc/examples/components/types/foaf:Person/queries/birthplace.query new file mode 100644 index 00000000..526417f8 --- /dev/null +++ b/doc/examples/components/types/foaf:Person/queries/birthplace.query @@ -0,0 +1,8 @@ +PREFIX twc: <http://tw.rpi.edu/schema/> +PREFIX foaf: <http://xmlns.com/foaf/0.1/> +PREFIX dbp: <http://dbpedia.org/ontology/> +SELECT distinct ?bplace WHERE { + GRAPH <http://tw.rpi.edu:2020/books>{ + <{{uri}}> dbp:birthPlace ?bplace + } +} diff --git a/doc/examples/components/types/foaf:Person/queries/endpoint.dbpedia/geo.query b/doc/examples/components/types/foaf:Person/queries/endpoint.dbpedia/geo.query new file mode 100644 index 00000000..b895676d --- /dev/null +++ b/doc/examples/components/types/foaf:Person/queries/endpoint.dbpedia/geo.query @@ -0,0 +1,9 @@ +PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> +PREFIX dbp: <http://dbpedia.org/ontology/> +PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> + +SELECT distinct ?lat ?lon ?name WHERE { +<{{first.birthplace.bplace.value}}> rdfs:label ?name ; + geo:lat ?lat; + geo:long ?lon. +}limit 1 diff --git a/doc/examples/components/types/foaf:Person/queries/endpoint.dbpedia/location.query b/doc/examples/components/types/foaf:Person/queries/endpoint.dbpedia/location.query new file mode 100644 index 00000000..f76659a1 --- /dev/null +++ b/doc/examples/components/types/foaf:Person/queries/endpoint.dbpedia/location.query @@ -0,0 +1,7 @@ +PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> +PREFIX dbp: <http://dbpedia.org/ontology/> +SELECT distinct ?name ?abstract WHERE { +<{{first.birthplace.bplace.value}}> dbp:abstract ?abstract; +rdfs:label ?name . +FILTER(lang(?abstract) = "en") +}limit 1 diff --git a/doc/examples/components/types/foaf:Person/queries/main.query b/doc/examples/components/types/foaf:Person/queries/main.query new file mode 100644 index 00000000..1b878b62 --- /dev/null +++ b/doc/examples/components/types/foaf:Person/queries/main.query @@ -0,0 +1,10 @@ +PREFIX twc: <http://tw.rpi.edu/schema/> +PREFIX foaf: <http://xmlns.com/foaf/0.1/> +SELECT ?event ?eventName WHERE { + GRAPH <http://tw.rpi.edu:2020/books>{ + ?event twc:hasAttendee <{{uri}}> . + OPTIONAL{ + ?event foaf:name ?eventName . + } + } +} diff --git a/doc/examples/components/types/foaf:Person/queries/personalDetails.query b/doc/examples/components/types/foaf:Person/queries/personalDetails.query new file mode 100644 index 00000000..cf35f160 --- /dev/null +++ b/doc/examples/components/types/foaf:Person/queries/personalDetails.query @@ -0,0 +1,12 @@ +PREFIX twc: <http://tw.rpi.edu/schema/> +PREFIX foaf: <http://xmlns.com/foaf/0.1/> +PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> +PREFIX dcterms: <http://purl.org/dc/terms/> + +SELECT ?name ?desc ?pic WHERE { + GRAPH <http://tw.rpi.edu:2020/books>{ + <{{uri}}> foaf:name ?name ; + foaf:depiction ?pic ; + dcterms:description ?desc. + } +} -- GitLab