Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
white-gecko committed Feb 28, 2022
2 parents 48189df + d290a9d commit 61b5914
Show file tree
Hide file tree
Showing 118 changed files with 1,746 additions and 331 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
*.rbc
*.swp
.sass-cache/
.jekyll-cache/
.vendor/
/.config
/coverage/
/InstalledFiles
Expand Down
15 changes: 9 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
sudo: required
language: ruby
services:
- docker
rvm:
- 2.2.4
- 2.3.0
- 2.3.8
- 2.5.3
- 2.7.0
- ruby-head
matrix:
allow_failures:
- rvm: ruby-head
before_install:
- docker pull stain/jena-fuseki
- docker build -t remote_sparql .
- docker run -p 3030:3030 -e ADMIN_PASSWORD=admin -d remote_sparql:latest
- docker run -p 3030:3030 -d stain/jena-fuseki:latest ./fuseki-server --mem /remote
- cd test/theme-gem
- bundle install
- cd ../..
script:
- bundle exec rake test
deploy:
Expand All @@ -21,10 +22,12 @@ deploy:
secure: D8rx4lfdlvWFjXPrHTOXudIrUpjBHu++4ebWzNcXNdk8ccNtRbkWCqK7vOp7BAXu8NXGQOT/XoHmcwuzOpaLMiPL6B+eNTPWnC2wqeQUlZcZak6btFXwMivKXRT5oyIP/UjciucLDN9jq+54fdr5M7+nJ+3D7upUA2P3ymb+69U0l0bXl9WA+c92LRi/wXXeyxdpImHym8PxBagS6GPiHswcHoeRRq5vNEmo/E9RYV5F0Kzyj8vOchO/83cDeqeQEPX969AtO0AKZczWfNx2qOBgcYcUmxfOdAooOnFYjw3A9QZgI3B/T7LC1137mCLQCcb/e0cFPiwQYxDXS8SEEd1t4t/4Tw/zUh+TFuSAbCPJz1tG91KYhcVBDzsvQh1dU0WY7TDXRrasvNU7HJ+TMGIq7nC+QvSRJ1SyKsI89aLKA8fAO06DwI/7LodG+G/0MAxFO5XLu1EBJ8k+mxdkbSqoZxSdtvvWkAUkdjWXtOtGNUhYtuVTJrzjrWUOM2YuhmnGAwJg8UgUKzDvjNCQ0Zm2q5TiYZT5nsv8FwE6zjSK7ETnp+ofW/RwxbZs7DNTDTShKAyoy2NEKrPfFvkFkoUSP3yR+e8hJpRo2hJFC/3GxgnTr4bdI814Y5UOBfGjVXUKsodMhtk0uhJCIQMm8Jri1o5600szSW+lG20KSkg=
gem: jekyll-rdf
on:
condition: $TRAVIS_RUBY_VERSION = 2.7.0
branch: master
- provider: rubygems
api_key:
secure: D8rx4lfdlvWFjXPrHTOXudIrUpjBHu++4ebWzNcXNdk8ccNtRbkWCqK7vOp7BAXu8NXGQOT/XoHmcwuzOpaLMiPL6B+eNTPWnC2wqeQUlZcZak6btFXwMivKXRT5oyIP/UjciucLDN9jq+54fdr5M7+nJ+3D7upUA2P3ymb+69U0l0bXl9WA+c92LRi/wXXeyxdpImHym8PxBagS6GPiHswcHoeRRq5vNEmo/E9RYV5F0Kzyj8vOchO/83cDeqeQEPX969AtO0AKZczWfNx2qOBgcYcUmxfOdAooOnFYjw3A9QZgI3B/T7LC1137mCLQCcb/e0cFPiwQYxDXS8SEEd1t4t/4Tw/zUh+TFuSAbCPJz1tG91KYhcVBDzsvQh1dU0WY7TDXRrasvNU7HJ+TMGIq7nC+QvSRJ1SyKsI89aLKA8fAO06DwI/7LodG+G/0MAxFO5XLu1EBJ8k+mxdkbSqoZxSdtvvWkAUkdjWXtOtGNUhYtuVTJrzjrWUOM2YuhmnGAwJg8UgUKzDvjNCQ0Zm2q5TiYZT5nsv8FwE6zjSK7ETnp+ofW/RwxbZs7DNTDTShKAyoy2NEKrPfFvkFkoUSP3yR+e8hJpRo2hJFC/3GxgnTr4bdI814Y5UOBfGjVXUKsodMhtk0uhJCIQMm8Jri1o5600szSW+lG20KSkg=
gem: jekyll-rdf
on:
condition: $TRAVIS_RUBY_VERSION = 2.7.0
branch: develop
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [3.2.0] - 2022-02-28
### Added
- Support for Ruby 3
- New `resource.rendered` attribute to check if a page is rendered in the present site for this resource.

### Changed
- Repository moved from https://github.com/white-gecko/jekyll-rdf/ to https://github.com/AKSW/jekyll-rdf/
- Add possibility to specify the default graph on a SPARQL endpoint
- Update class-template selection to be straightforward
- Update dependencies
- Minor code cleanup
- Some updates in the test/build system
- Remove some warnings

## [3.1.0] - 2018-11-27
### Added
- Allow building sites from a (remote) SPARQL endpoint by setting `remote:\n endpoint: <endpointuri>` in the `_config.yml`. (Currently only querying the default default-graph ;-). Specifying the default graph, with `FROM` resp. `default-graph-uri` will come in the future, https://github.com/white-gecko/jekyll-rdf/pull/220.)
Expand Down
4 changes: 0 additions & 4 deletions Dockerfile

This file was deleted.

3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
source 'https://rubygems.org'


gem "theme-gem", :path => 'test/theme-gem'
gemspec

1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
MIT License

Copyright (c) 2016-2019 Sebastian Zänker, Natanael Arndt
Copyright (c) 2016 Elias Saalmann, Christian Frommert, Simon Jakobi,
Arne Jonas Präger, Maxi Bornmann, Georg Hackel, Eric Füg

Expand Down
60 changes: 38 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# jekyll-rdf
# Jekyll RDF

A [Jekyll plugin](https://jekyllrb.com/docs/plugins/) for including RDF data in your static site.

[![Gem Version](https://badge.fury.io/rb/jekyll-rdf.svg)](https://badge.fury.io/rb/jekyll-rdf)
[![Build Status](https://travis-ci.org/white-gecko/jekyll-rdf.svg?branch=develop)](https://travis-ci.org/white-gecko/jekyll-rdf)
[![Coverage Status](https://coveralls.io/repos/github/white-gecko/jekyll-rdf/badge.svg?branch=develop)](https://coveralls.io/github/white-gecko/jekyll-rdf?branch=develop)
[![Build Status](https://travis-ci.org/AKSW/jekyll-rdf.svg?branch=develop)](https://travis-ci.org/AKSW/jekyll-rdf)
[![Coverage Status](https://coveralls.io/repos/github/AKSW/jekyll-rdf/badge.svg?branch=develop)](https://coveralls.io/github/AKSW/jekyll-rdf?branch=develop)

The API Documentation is available at [RubyDoc.info](http://www.rubydoc.info/gems/jekyll-rdf/).

Expand All @@ -27,15 +27,12 @@ The API Documentation is available at [RubyDoc.info](http://www.rubydoc.info/gem
As a prerequisite for *Jekyll RDF* you of course need to install [*Jekyll*](https://jekyllrb.com/).
Please take a look at the installations instructions at https://jekyllrb.com/docs/installation/.

If you already have a working Jekyll installation you can add the the Jekyll-RDF plugin.
If you already have a working Jekyll installation you can add the Jekyll-RDF plugin.
Probably you already using [Bundler](https://bundler.io/) and there is a [`Gemfile`](https://bundler.io/gemfile.html) in your Jekyll directory.
Add Jekyll-RDF to the plugins section:

```
group :jekyll_plugins do
gem "jekyll-rdf", '~> 3.0.0.pre.a'
end
gem "jekyll-rdf", "~> 3.2"
```

Replace the version string with the currently available stable release as listed on [rubygems.org](https://rubygems.org/gems/jekyll-rdf).
Expand Down Expand Up @@ -66,7 +63,7 @@ jekyll new my_page
cd my_page
```

Further there are some parameters required in your `_config.yml` for `jekyll-rdf`. I.e. the `url` and `baseurl` parameters are used for including the resource pages into the root of the site, the plug-in has to be configured, and the path to the RDF file has to be present.
Further, there are some parameters required in your `_config.yml` for `jekyll-rdf`. I.e. the `url` and `baseurl` parameters are used for including the resource pages into the root of the site, the plug-in has to be configured, and the path to the RDF file has to be present.

```yaml
baseurl: "/simpsons"
Expand All @@ -85,6 +82,20 @@ jekyll_rdf:
"http://example.org/simpsons/Abraham": "abraham.html"
```
### Base Path Specification
The `url` + `baseurl` are used by Jekyll RDF to identify relative to which URL it should build the RDF resource pages.
In the example above this means that a resource with the IRI `<http://example.org/simpsons/Bart>` is rendered to the path `/Bart.html`.
Also other features and plugins for Jekyll depend on these two parameters.
If for any case the two parameters differ from the base path that Jekyll RDF should assume, it is possible to set the parameter `baseiri` in the `jekyll_rdf` section.

```yaml
baseurl: "/simpsons"
url: "https://beispiel.com"
jekyll_rdf:
baseiri: "http://example.org/"
```

### Map resources to templates
It is possible to map a specific class (resp. RDF-type) or individual resources to a template.
```yaml
Expand All @@ -110,7 +121,7 @@ You can restrict the resources selected to be built by adding a SPARQL query as
restriction: "SELECT ?resourceUri WHERE { ?resourceUri <http://www.ifi.uio.no/INF3580/family#hasFather> <http://www.ifi.uio.no/INF3580/simpsons#Homer> }"
```

There are 3 pre-defined keywords for restrictions implemented:
There are 3 predefined keywords for restrictions implemented:
* `subjects` will load all subject URIs
* `predicates` will load all predicate URIs
* `objects` will load all object URIs
Expand All @@ -127,7 +138,7 @@ A file `_data/restriction.txt` cool have the following content:
```

In the `_config.yml` you specify the file with the key `restriction_file`.
If both, a `restriction_file` and a `restriction`, are specified JekyllRDF will build pages for the union of the both.
If both, a `restriction_file` and a `restriction`, are specified Jekyll RDF will build pages for the union of the both.

### Blank Nodes
Furthermore you can decide if you want to render blank nodes or not. You just need to add `include_blank`to `_config.yml`:
Expand All @@ -146,7 +157,7 @@ jekyll_rdf:
## Building the Jekyll Site

Running `jekyll build` will render the RDF resources to the `_site/…` directory. Running `jekyll serve` will render the RDF resources and provide you with an instant HTTP-Server usually accessible at `http://localhost:4000/`.
RDF resources whose IRIs don't start with the configured jekyll `url` and `baseurl` are rendered to the `_site/rdfsites/…` subdirectory.
RDF resources whose IRIs don't start with the configured Jekyll `url` and `baseurl` (resp. `baseiri`) are rendered to the `_site/rdfsites/…` sub directory.

## Defining Templates
To make use of the RDF data, create one or more files (e.g `rdf_index.html` or `person.html`) in the `_layouts`-directory. For each resource a page will be rendered. See example below:
Expand Down Expand Up @@ -271,8 +282,8 @@ The template for `ex:Resource`:
```

### Custom SPARQL Query
We implemented a liquid filter `sparql_query` to run custom SPARQL queries. Each occurence of `?resourceUri` gets replaced with the current URI.
*Caution:* You have to separate query and resultset variables because of Liquids concepts. Example:
We implemented a liquid filter `sparql_query` to run custom SPARQL queries. Each occurrence of `?resourceUri` gets replaced with the current URI.
*Caution:* You have to separate query and result set variables because of Liquids concepts. Example:
```html
{% assign query = 'SELECT ?sub ?pre WHERE { ?sub ?pre ?resourceUri }' %}
{% assign resultset = page.rdf | sparql_query: query %}
Expand Down Expand Up @@ -342,8 +353,12 @@ Return the URL of the page representing this RdfResource.
Return the path to the page representing this RdfResource. Use it with care.

### Resource.covered
This method is relevant for rendering pages for IRIs containing a fragment identifier (`http://superresource#anchor`).
This method returns true for the super-resource (`http://superresource`) if it is actually described in the given knowledgebase.
This attribute is relevant for rendering pages for IRIs containing a fragment identifier (`http://superresource#anchor`).
This attribute is true for the super-resource (`http://superresource`) if it is actually described in the given knowledge base.

### Resource.rendered
This attribute tells if the respective instance of a resource is rendered within the context of the current site generation.
Usage: `{% if resource.rendered? %}…{% endif %}`.

### Resource.inspect
Returns a verbose String representing this resource.
Expand Down Expand Up @@ -379,7 +394,7 @@ http://www.ifi.uio.no/INF3580/simpsons
- `<list>` is a boolean value (`true`, `false`).

**Description:** Returns the object, of the triple `<rdf_resource> <predicate> ?object`.
The returned object can by any of the kind, resource, literal, or blanknode.
The returned object can by any of the kind, resource, literal, or blank node.

**Example (default):**
```
Expand Down Expand Up @@ -436,7 +451,7 @@ The returned object can by any of the kind, resource, literal, or blanknode.

**Description:** Same as rdf_property, but in inverse direction.
It returns the subject, of the triple `?subject <predicate> <rdf_resource>`.
The returned object can by any of the kind, resource, or blanknode.
The returned object can by any of the kind, resource, or blank node.

**Examples (default):**
```
Expand Down Expand Up @@ -489,7 +504,7 @@ You can use `?resourceUri` inside the query to reference the resource which is g
```
<!--Rendering the page of resource Lisa -->
{% assign query = 'SELECT ?sub ?pre WHERE { ?sub ?pre ?resourceUri }' %}
{% assign resultset = page | sparql_query: query %}
{% assign resultset = page.rdf | sparql_query: query %}
<table>
{% for result in resultset %}
<tr><td>{{ result.sub }}</td><td>{{ result.pre }}</td></tr>
Expand Down Expand Up @@ -649,8 +664,9 @@ http://www.ifi.uio.no/INF3580/simpsons#Maggie
|Name|Parameter|Default|Description|Example|
|--- |--- |--- |--- |--- |
|path|Relative path to the RDF-File|no default|Specifies the path to the RDF file from where you want to render the website|```path: "rdf-data/simpsons.ttl"```|
|remote|Section to specify a remote data source|no default|Has to contain the `endpoint` key. The `remote` paramter overrides the `path` parameter.||
|remote|Section to specify a remote data source|no default|Has to contain the `endpoint` key. The `remote` parameter overrides the `path` parameter.||
|remote > endpoint|SPARQL endpoint to get the data from|no default|Specifies the URL to the SPARQL endpoint from where you want to render the website|```remote: endpoint: "http://localhost:5000/sparql/"```|
|remote > default_graph|Select a named graph on the endpoint to use in place of the endpoint default graph|no default|Specifies the IRI to the named graph to select from the SPARQL endpoint|```remote: endpoint: "http://localhost:5000/sparql/" default_graph: "http://example.org/"```|
|language|Language-Tag as String|no default|Specifies the preferred language when you select objects using our Liquid filters|```language: "en"```|
|include_blank|Boolean-Expression|false|Specifies whether blank nodes should also be rendered or not|```include_blank: true```|
|restriction|SPARQL-Query as String or subjects/objects/predicates|no default|Restricts the resource-selection with a given SPARQL-Query to the results bound to the special variable `?resourceUri` or the three keywords `subjects` (only subject URIs), `objects`, `predicates`|```restriction: "SELECT ?resourceUri WHERE { ?resourceUri <http://www.ifi.uio.no/INF3580/family#hasFather> <http://www.ifi.uio.no/INF3580/simpsons#Homer> }"```|
Expand All @@ -664,7 +680,7 @@ http://www.ifi.uio.no/INF3580/simpsons#Maggie
## Installation from source
To install the project with the git-repository you will need `git` on your system. The first step is just cloning the repository:
```
git clone [email protected]:white-gecko/jekyll-rdf.git
git clone [email protected]:AKSW/jekyll-rdf.git
```
A folder named `jekyll-rdf` will be automatically generated. You need to switch into this folder and compile the ruby gem to finish the installation:
```
Expand All @@ -679,7 +695,7 @@ bundle exec rake test
```

## Test page
Everytime the tests are executed, the Jekyll page inside of `test/source` gets processed. Start a slim web server to watch the results in web browser, e.g. Pythons `SimpleHTTPServer` (Python 2, for Python 3 it's `http.server`):
Every time the tests are executed, the Jekyll page inside of `test/source` gets processed. Start a slim web server to watch the results in web browser, e.g. Pythons `SimpleHTTPServer` (Python 2, for Python 3 it's `http.server`):
```
cd test/source/_site
python -m SimpleHTTPServer 8000
Expand Down
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ require 'rdoc/task'
RDoc::Task.new do |rdoc|
rdoc.rdoc_files.include("lib/**/*.rb")
end

18 changes: 10 additions & 8 deletions jekyll-rdf.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
VERSION = '3.1.0'
# coding: utf-8
VERSION = '3.2.0'
RELEASE_VERSION = case
when ENV['TRAVIS'] && ENV['TRAVIS_BRANCH'].match(/^master$/i) then "#{VERSION}"
when ENV['TRAVIS'] && ENV['TRAVIS_BRANCH'].match(/^develop$/i) then "#{VERSION}-#{ENV['TRAVIS_BRANCH']}.#{ENV['TRAVIS_BUILD_NUMBER']}"
Expand All @@ -13,18 +14,19 @@ Gem::Specification.new do |s|
s.authors = ['Elias Saalmann', 'Christian Frommert', 'Simon Jakobi', 'Arne Jonas Präger', 'Maxi Bornmann', 'Georg Hackel', 'Eric Füg', 'Sebastian Zänker', 'Natanael Arndt', 'Simon Bin', 'Jan Beckert']
s.email = '[email protected]'
s.files = Dir['lib/**/*.rb']
s.homepage = 'https://github.com/white-gecko/jekyll-rdf'
s.homepage = 'https://github.com/AKSW/jekyll-rdf'
s.license = 'MIT'
s.add_runtime_dependency 'net-http-persistent', '~> 2.9' # https://github.com/white-gecko/jekyll-rdf/issues/197
s.add_runtime_dependency 'linkeddata', '~> 2.0'
s.add_runtime_dependency 'sparql', '~> 2.2', '>= 2.2.1'
s.add_runtime_dependency 'jekyll', '~> 3.1'
s.add_development_dependency 'rake', '~> 10.4'
s.add_development_dependency 'rest-client', '~> 1.8'
s.add_runtime_dependency 'linkeddata', '~> 3.2', '>= 3.2.0'
s.add_runtime_dependency 'sparql-client', '~> 3.2', '>= 3.2.0'
s.add_runtime_dependency 'jekyll', '>= 3.1'
s.add_development_dependency 'rake', '~> 13.0'
s.add_development_dependency 'rest-client', '~> 2.0', '>= 2.0.1'
s.add_development_dependency 'coveralls', '~> 0.8'
s.add_development_dependency 'test-unit', '~> 3.0'
s.add_development_dependency 'shoulda-context', '~> 1.1'
s.add_development_dependency 'rspec', '~> 3.0'
s.add_development_dependency 'pry-byebug', '~> 3.4'
s.add_development_dependency 'rdoc', '~> 6.2', '>= 6.2.1'
s.add_development_dependency 'jekyll-theme-jod', '~> 0.1.5'
s.add_development_dependency 'kramdown-parser-gfm', '~> 1.1'
end
5 changes: 3 additions & 2 deletions lib/jekyll-rdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
require 'jekyll/drops/rdf_literal'
require 'jekyll/drops/rdf_resource'
require 'jekyll/drops/rdf_resource_class'
require 'jekyll/drops/rdf_graph'
require 'jekyll/exceptions/NoPrefixMapped'
require 'jekyll/exceptions/NoPrefixesDefined'
require 'jekyll/exceptions/UnMarkedUri'
Expand All @@ -51,15 +52,15 @@
require 'jekyll/helper/rdf_class_extraction'
require 'jekyll/helper/rdf_page_helper'
require 'jekyll/helper/rdf_generator_helper'
require 'jekyll/helper/rdf_filter_helper'
require 'jekyll/helper/rdf_hook_helper'
require 'jekyll/hooks/rdf_page_pointer'
require 'jekyll/filters/rdf_resolve_prefix'
require 'jekyll/filters/rdf_sparql_query'
require 'jekyll/filters/rdf_property'
require 'jekyll/filters/rdf_collection'
require 'jekyll/filters/rdf_container'
require 'jekyll/filters/rdf_get'
require 'jekyll/filters/rdf_debug_message'
require 'jekyll/filters/rdf_page_to_resource'


Liquid::Template.register_filter(Jekyll::JekyllRdf::Filter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,34 @@
# SOFTWARE.
#

module Jekyll
module JekyllRdf
module ResolvePrefixes
private
def rdf_resolve_prefix(predicate)
if(predicate[0] == "<" && predicate[-1] == ">")
# iri
return predicate
module Jekyll #:nodoc:
module JekyllRdf #:nodoc:
module Drops #:nodoc:
class RdfGraph < Liquid::Drop
attr_reader :graph

def initialize(graph)
@graph = graph
end
# qname
arr = predicate.split(":", 2)
if((arr[1].include? (":")) || (arr[1][0..1].eql?("//")))
raise UnMarkedUri.new(predicate, Jekyll::JekyllRdf::Helper::RdfHelper::page.data['template']) #TODO .data['template'] is only defined on RdfPages

def to_s
to_nquads
end
if(!Jekyll::JekyllRdf::Helper::RdfHelper::prefixes["rdf_prefixes"].nil?)
if(!Jekyll::JekyllRdf::Helper::RdfHelper::prefixes["rdf_prefix_map"][arr[0]].nil?)
return "<#{arr[1].prepend(Jekyll::JekyllRdf::Helper::RdfHelper::prefixes["rdf_prefix_map"][arr[0]])}>"
else
raise NoPrefixMapped.new(predicate, Jekyll::JekyllRdf::Helper::RdfHelper::page.data['template'], arr[0]) #TODO .data['template'] is only defined on RdfPages
end
else
raise NoPrefixesDefined.new(predicate, Jekyll::JekyllRdf::Helper::RdfHelper::page.data['template']) #TODO .data['template'] is only defined on RdfPages

def to_nquads
result = @graph.statements.map{|state|
state.to_nquads
}.join("")
return result
end
end
end
end
end

module Jekyll
module JekyllRdf
module Filter
include Jekyll::JekyllRdf::ResolvePrefixes
def to_ntriples
result = @graph.statements.map{|state|
state.to_ntriples
}.join("")
return result
end
end
end
end
end
Loading

0 comments on commit 61b5914

Please sign in to comment.