├── .coveralls.yml ├── .dockerignore ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ └── build.yml ├── .gitignore ├── CHANGELOG.md ├── CITATION.cff ├── Dockerfile ├── Gemfile ├── LICENSE ├── README.md ├── Rakefile ├── Taskfile.yml ├── docker-resources └── entrypoint.sh ├── jekyll-rdf.gemspec ├── lib ├── jekyll-rdf.rb └── jekyll │ ├── drops │ ├── rdf_graph.rb │ ├── rdf_literal.rb │ ├── rdf_resource.rb │ ├── rdf_resource_class.rb │ ├── rdf_statement.rb │ └── rdf_term.rb │ ├── exceptions │ ├── NoPrefixMapped.rb │ ├── NoPrefixesDefined.rb │ └── UnMarkedUri.rb │ ├── filters │ ├── rdf_collection.rb │ ├── rdf_container.rb │ ├── rdf_debug_message.rb │ ├── rdf_get.rb │ ├── rdf_property.rb │ └── rdf_sparql_query.rb │ ├── helper │ ├── rdf_class_extraction.rb │ ├── rdf_filter_helper.rb │ ├── rdf_general_helper.rb │ ├── rdf_generator_helper.rb │ ├── rdf_hook_helper.rb │ ├── rdf_page_helper.rb │ ├── rdf_prefix_helper.rb │ └── rdf_types.rb │ ├── hooks │ └── rdf_page_pointer.rb │ ├── rdf_main_generator.rb │ ├── rdf_template_mapper.rb │ └── types │ ├── XsdBoolean.rb │ ├── XsdDecimal.rb │ ├── XsdDouble.rb │ └── XsdInteger.rb └── test ├── RdfTestUtility.rb ├── ResourceHelper.rb ├── cases ├── Jekyll │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ └── knowledge-base.ttl │ └── _layouts │ │ ├── default.html │ │ ├── exampleInstance.html │ │ └── person.html ├── LinkTag │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ └── knowledge-base.ttl │ ├── _layouts │ │ └── default.html │ └── links.html ├── MergeFeatureLayoutRoute │ ├── Bart.html │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ └── knowledge-base.ttl │ └── _layouts │ │ ├── bart_layout.html │ │ ├── default.html │ │ ├── default_bart.html │ │ └── person.html ├── MergeFeaturePageRoute │ ├── Bart.html │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ └── knowledge-base.ttl │ └── _layouts │ │ ├── bart_layout.html │ │ ├── default.html │ │ ├── default_bart.html │ │ └── person.html ├── _presets │ ├── Prefixes.pref │ └── knowledge-base.ttl ├── classHierarchy │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ └── knowledge-base.ttl │ ├── _layouts │ │ ├── breathingAir.html │ │ ├── foodFromWater.html │ │ ├── landBorn.html │ │ └── layingEggs.html │ └── test_class_hierarchy.rb ├── constructQueries │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ └── knowledge-base.ttl │ ├── _layouts │ │ └── default.html │ ├── constructs.html │ └── test_construct_queries.rb ├── dontFailIfLayoutNoFound │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ └── knowledge-base.ttl │ ├── _posts │ │ └── 2019-02-12-Blogpost.md │ ├── blog.html │ └── test_prefixes.rb ├── drops │ └── test_rdf_drops.rb ├── easyMWE.sh ├── emptyLinePrefixFile │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ └── knowledge-base.ttl │ ├── _layouts │ │ ├── default.html │ │ └── person.html │ └── test_empty_line_prefix_file.rb ├── extraction │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ └── knowledge-base.ttl │ ├── _layouts │ │ └── default.html │ └── test_extraction.rb ├── filter │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ └── knowledge-base.ttl │ ├── _layouts │ │ ├── default.html │ │ ├── exampleInstance.html │ │ └── person.html │ └── test_rdf_filters.rb ├── generalTest │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ └── knowledge-base.ttl │ ├── _layouts │ │ ├── default.html │ │ ├── exampleInstance.html │ │ └── multipleResources.html │ ├── covered.html │ ├── prefixes.html │ └── test_general.rb ├── listExtraction │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ ├── knowledge-base.ttl │ │ └── restriction.txt │ ├── _layouts │ │ ├── default.html │ │ ├── exampleInstance.html │ │ └── person.html │ └── test_list_restriction.rb ├── mainGenerator │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ └── knowledge-base.ttl │ ├── _layouts │ │ └── default.html │ └── test_main_generator.rb ├── mainPrefixFile │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ └── knowledge-base.ttl │ ├── mainPrefixTest.html │ └── test_main_prefix_file.rb ├── missingConfig │ ├── Gemfile │ ├── _config.yml │ └── test_missing_config.rb ├── multipleWarnings │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ └── knowledge-base.ttl │ ├── _layouts │ │ ├── default.html │ │ ├── layout1.html │ │ ├── layout10.html │ │ ├── layout11.html │ │ ├── layout12.html │ │ ├── layout2.html │ │ ├── layout3.html │ │ ├── layout4.html │ │ ├── layout5.html │ │ ├── layout6.html │ │ ├── layout7.html │ │ ├── layout8.html │ │ └── layout9.html │ └── test_multiple_warnings.rb ├── noElongatedPageNames │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ └── knowledge-base.ttl │ ├── page.html │ └── test_url_elongation.rb ├── pages │ ├── Gemfile │ ├── PrefixDemo.html │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ └── knowledge-base.ttl │ ├── _layouts │ │ ├── default.html │ │ ├── exampleInstance.html │ │ ├── firstClassTemplate.html │ │ ├── firstInstanceTemplate.html │ │ ├── person.html │ │ ├── secondClassTemplate.html │ │ └── secondInstanceTemplate.html │ └── test_pages.rb ├── pagesFaultyPrefixAcess │ ├── FaultyPrefixDemo.html │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ └── knowledge-base.ttl │ └── test_pages_faulty_prefix_access.rb ├── pagesMissingTemplate │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ └── knowledge-base.ttl │ └── test_missing_template.rb ├── prefixes │ ├── Gemfile │ ├── PrefixDemo.html │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ └── knowledge-base.ttl │ └── test_prefixes.rb ├── prefixesInPosts │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ └── knowledge-base.ttl │ ├── _layouts │ │ └── post.html │ ├── _posts │ │ └── 2019-02-12-Blogpost.md │ └── test_prefixes.rb ├── prefixesInPostsWithGemTheme │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ └── knowledge-base.ttl │ ├── _posts │ │ └── 2019-02-12-Blogpost.md │ ├── blog.html │ └── test_prefixes.rb ├── remoteGraphs │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ └── knowledge-base.ttl │ ├── _layouts │ │ ├── default.html │ │ └── exampleInstance.html │ ├── remoteCollectionTest.html │ ├── remoteContainerTest.html │ ├── remoteMainTest.html │ ├── remoteQueryTest.html │ └── test_remote.rb ├── remoteSPARQL │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ └── knowledge-base.ttl │ ├── _layouts │ │ ├── default.html │ │ └── exampleInstance.html │ ├── remoteCollectionTest.html │ ├── remoteContainerTest.html │ ├── remoteMainTest.html │ ├── remoteQueryTest.html │ └── test_remote.rb ├── renderedAttribute │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ └── knowledge-base.ttl │ ├── _layouts │ │ └── default.html │ ├── rendered.html │ └── test_rendered_attribute.rb ├── resetSite │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ └── knowledge-base.ttl │ ├── _layouts │ │ ├── default-resource.html │ │ ├── default.html │ │ ├── exampleInstance.html │ │ └── person.html │ ├── reset-page.html │ └── test_reset.rb ├── restrictions │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ ├── knowledge-base.ttl │ │ └── restriction-file.rf │ ├── _layouts │ │ └── default.html │ └── test_restriction.rb ├── sciMath │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ └── knowledge-base.ttl │ ├── _layouts │ │ └── math_filters.html │ ├── math_filters.html │ └── test_sci_math.rb ├── shortcutCollections │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ └── knowledge-base.ttl │ ├── _layouts │ │ ├── default.html │ │ ├── exampleInstance.html │ │ └── person.html │ ├── collections.html │ └── test_shortcut_collections.rb ├── shortcutContainers │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ └── knowledge-base.ttl │ ├── _layouts │ │ ├── default.html │ │ ├── exampleInstance.html │ │ └── person.html │ ├── container.html │ └── test_shortcut_container.rb ├── showConfig │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ ├── Prefixes.pref │ │ └── knowledge-base.ttl │ ├── _layouts │ │ ├── default.html │ │ └── exampleInstance.html │ └── test_show_config.rb ├── types │ ├── Gemfile │ ├── _config.yml │ ├── _data │ │ └── knowledge-base.ttl │ ├── _layouts │ │ └── types.html │ └── test_types.rb └── uniqueResources │ ├── Gemfile │ ├── _config.yml │ ├── _data │ ├── Prefixes.pref │ └── knowledge-base.ttl │ ├── _layouts │ └── default.html │ ├── test_unique_resources.rb │ └── uniqueResources.html ├── test_helper.rb └── theme-gem ├── Gemfile ├── _data └── prefixes.sparql ├── _layouts └── ontology.html └── theme-gem.gemspec /.coveralls.yml: -------------------------------------------------------------------------------- 1 | service_name: travis-ci 2 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !docker-resources 3 | !lib 4 | !Gemfile 5 | !jekyll-rdf.gemspec 6 | !LICENSE 7 | !README.md 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Do this '....' 16 | 2. See error 17 | 18 | Provide an MWE, minimum (not) working example 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Log** 24 | If applicable, add log output to help explain your problem. 25 | 26 | **Additional context** 27 | Add any other context about the problem here. 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. E.g. refer to an issue. 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - 'develop' 8 | tags: 9 | - '*' 10 | 11 | jobs: 12 | test: 13 | runs-on: ubuntu-latest 14 | strategy: 15 | fail-fast: false 16 | matrix: 17 | ruby: ['3.2', '3.3'] 18 | steps: 19 | - uses: actions/checkout@v4 20 | with: 21 | fetch-depth: 0 22 | - name: Set up Ruby 23 | uses: ruby/setup-ruby@v1 24 | with: 25 | ruby-version: ${{ matrix.ruby }} 26 | - uses: arduino/setup-task@v2 27 | with: 28 | repo-token: ${{ secrets.GITHUB_TOKEN }} 29 | - name: Show repository information 30 | run: task info 31 | - name: Run tests 32 | run: task test 33 | - name: Coveralls 34 | uses: coverallsapp/github-action@v2 35 | 36 | release: 37 | if: github.ref == 'refs/heads/develop' || ${{ startsWith(github.ref, 'refs/tags/') }} 38 | runs-on: ubuntu-latest 39 | needs: test 40 | env: 41 | GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }} 42 | steps: 43 | - uses: actions/checkout@v4 44 | with: 45 | fetch-depth: 0 46 | - name: Set up Ruby 47 | uses: ruby/setup-ruby@v1 48 | with: 49 | ruby-version: '3.2' 50 | - uses: arduino/setup-task@v2 51 | with: 52 | repo-token: ${{ secrets.GITHUB_TOKEN }} 53 | - name: Build and release gem 54 | run: task gem:build gem:push 55 | 56 | docker: 57 | if: github.ref == 'refs/heads/develop' || ${{ startsWith(github.ref, 'refs/tags/') }} 58 | runs-on: ubuntu-latest 59 | needs: test 60 | steps: 61 | - name: Git describe 62 | id: ghd 63 | uses: proudust/gh-describe@v2 64 | - name: Check outputs 65 | run: | 66 | echo "describe: ${{ steps.ghd.outputs.describe }}" 67 | - name: Set up QEMU 68 | uses: docker/setup-qemu-action@v3 69 | - name: Set up Docker Buildx 70 | uses: docker/setup-buildx-action@v3 71 | - name: Login to DockerHub 72 | uses: docker/login-action@v3 73 | with: 74 | username: ${{ secrets.DOCKERHUB_USERNAME }} 75 | password: ${{ secrets.DOCKERHUB_TOKEN }} 76 | - name: Login to GitHub Container Registry 77 | uses: docker/login-action@v3 78 | with: 79 | registry: ghcr.io 80 | username: ${{ github.actor }} 81 | password: ${{ secrets.GITHUB_TOKEN }} 82 | - name: Extract metadata (tags, labels) for Docker 83 | id: meta 84 | uses: docker/metadata-action@v5 85 | with: 86 | images: | 87 | docker.io/aksw/jekyll-rdf 88 | ghcr.io/aksw/jekyll-rdf 89 | - name: Build and push 90 | uses: docker/build-push-action@v5 91 | with: 92 | push: true 93 | platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/arm64/v8 94 | build-args: VERSION=${{ steps.ghd.outputs.describe }} 95 | tags: ${{ steps.meta.outputs.tags }} 96 | labels: ${{ steps.meta.outputs.labels }} 97 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | *.swp 4 | .sass-cache/ 5 | .jekyll-cache/ 6 | .vendor/ 7 | /.config 8 | /coverage/ 9 | /InstalledFiles 10 | /pkg/ 11 | /spec/reports/ 12 | /spec/examples.txt 13 | /test/tmp/ 14 | /test/version_tmp/ 15 | /tmp/ 16 | 17 | ## Specific to RubyMotion: 18 | .dat* 19 | .repl_history 20 | build/ 21 | 22 | ## Documentation cache and generated files: 23 | */.yardoc/ 24 | */_yardoc/ 25 | */doc/ 26 | */rdoc/ 27 | */html/ 28 | test/**/_site/ 29 | 30 | ## Environment normalization: 31 | /.bundle/ 32 | /vendor/bundle 33 | /lib/bundler/man/ 34 | /bin/ 35 | 36 | # for a library or gem, you might want to ignore these files since the code is 37 | # intended to run in multiple environments; otherwise, check them in: 38 | Gemfile.lock 39 | .ruby-version 40 | .ruby-gemset 41 | 42 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: 43 | .rvmrc 44 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | cff-version: 1.2.0 2 | message: "If you use this software, please cite it as below." 3 | authors: 4 | - family-names: "Arndt" 5 | given-names: "Natanael" 6 | orcid: "https://orcid.org/0000-0002-8130-8677" 7 | - family-names: "Zänker" 8 | given-names: "Sebastian" 9 | - family-names: "Saalmann" 10 | given-names: "Elias" 11 | - family-names: "Frommert" 12 | given-names: "Christian" 13 | - family-names: "Jakobi" 14 | given-names: "Simon" 15 | - family-names: "Präger" 16 | given-names: "Arne Jonas" 17 | - family-names: "Bornmann" 18 | given-names: "Maxi" 19 | - family-names: "Hackel" 20 | given-names: "Georg" 21 | - family-names: "Füg" 22 | given-names: "Eric" 23 | - family-names: "Bin" 24 | given-names: "Simon" 25 | - family-names: "Beckert" 26 | given-names: "Jan" 27 | title: "Jekyll RDF" 28 | version: 3.2.0 29 | date-released: 2022-02-28 30 | url: "https://github.com/AKSW/jekyll-rdf" 31 | preferred-citation: 32 | type: conference-paper 33 | authors: 34 | - family-names: "Arndt" 35 | given-names: "Natanael" 36 | orcid: "https://orcid.org/0000-0002-8130-8677" 37 | - family-names: "Zänker" 38 | given-names: "Sebastian" 39 | - family-names: "Sejdiu" 40 | given-names: "Gezim" 41 | orcid: "https://orcid.org/0000-0002-3441-1372" 42 | - family-names: "Tramp" 43 | given-names: "Sebastian" 44 | orcid: "https://orcid.org/0000-0003-4707-2864" 45 | doi: 10.1007/978-3-030-19274-7_24 46 | journal: "Proceedings of the 19th International Conference on Web Engineering (ICWE 2019)" 47 | month: 6 48 | start: 331 # First page number 49 | end: 346 # Last page number 50 | title: "Jekyll RDF: Template-Based Linked Data Publication with Minimized Effort and Maximum Scalability" 51 | volume: 11496 52 | year: 2019 53 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM docker.io/library/ruby:3.3-slim AS builder 2 | 3 | RUN apt-get update && apt-get -y install build-essential && rm -rf /var/lib/apt/lists/* 4 | WORKDIR jekyll-rdf 5 | 6 | ADD . . 7 | ARG VERSION 8 | RUN gem build jekyll-rdf.gemspec && \ 9 | gem install jekyll-rdf-*.gem mustache 10 | 11 | FROM docker.io/library/ruby:3.3-slim AS slim 12 | COPY --from=builder /usr/local/bundle/ /usr/local/bundle/ 13 | 14 | WORKDIR /data 15 | 16 | CMD /usr/local/bundle/bin/jekyll build 17 | 18 | FROM docker.io/library/ruby:3.3-slim 19 | COPY --from=builder /jekyll-rdf/docker-resources/ /docker-resources 20 | COPY --from=builder /usr/local/bundle/ /usr/local/bundle/ 21 | RUN apt-get update && apt-get -y install build-essential git && rm -rf /var/lib/apt/lists/* 22 | 23 | WORKDIR /data 24 | 25 | ENTRYPOINT ["/docker-resources/entrypoint.sh"] 26 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | 4 | gem "theme-gem", :path => 'test/theme-gem' 5 | gemspec 6 | 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2019 Sebastian Zänker, Natanael Arndt 4 | Copyright (c) 2016 Elias Saalmann, Christian Frommert, Simon Jakobi, 5 | Arne Jonas Präger, Maxi Bornmann, Georg Hackel, Eric Füg 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'bundler/setup' 3 | 4 | require 'rake' 5 | 6 | ############################################################################# 7 | # 8 | # Standard tasks 9 | # 10 | ############################################################################# 11 | 12 | require 'rake/testtask' 13 | Rake::TestTask.new(:test) do |test| 14 | test.libs << 'test' 15 | test.pattern = 'test/cases/*/test_*.rb' 16 | test.verbose = true 17 | end 18 | 19 | require 'rdoc/task' 20 | RDoc::Task.new do |rdoc| 21 | rdoc.rdoc_files.include("lib/**/*.rb") 22 | end 23 | -------------------------------------------------------------------------------- /Taskfile.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | env: 4 | BUNDLE_PATH: .vendor 5 | 6 | vars: 7 | GIT_DESCRIBE: 8 | sh: git describe --tags --dirty --always 9 | GEM_VERSION: 10 | sh: ruby -e "if Gem::Version.new(ARGV[0]).prerelease? then puts Gem::Version.new(Gem::Version.new(ARGV[0].split('-')[0]).bump().to_s + '-' + ARGV[0].split('-')[1..].join('.')) else puts Gem::Version.new(ARGV[0]) end" {{.GIT_DESCRIBE}} 11 | GEM_NAME: jekyll-rdf 12 | DOCKER_IMAGE: aksw/jekyll-rdf 13 | 14 | tasks: 15 | 16 | default: 17 | desc: The list of all defined tasks 18 | cmds: 19 | - task -a 20 | 21 | info: 22 | desc: Output some variables 23 | cmds: 24 | - | 25 | echo "GIT_DESCRIBE: {{.GIT_DESCRIBE}}" 26 | echo "GEM_VERSION: {{.GEM_VERSION}}" 27 | echo "GEM_NAME: {{.GEM_NAME}}" 28 | echo "DOCKER_IMAGE: {{.DOCKER_IMAGE}}" 29 | 30 | install: 31 | desc: Install jekyll rdf and its dependencies with bundle 32 | cmds: 33 | - bundle install 34 | 35 | gem:build: 36 | desc: Build the ruby gem 37 | cmds: 38 | - gem build {{.GEM_NAME}}.gemspec 39 | 40 | gem:push: 41 | desc: Push the gem to rubygems.org 42 | cmds: 43 | - gem push {{.GEM_NAME}}-{{.GEM_VERSION}}.gem 44 | 45 | image:build: 46 | desc: Build the docker image for the current version 47 | aliases: [podman:build, docker:build] 48 | cmds: 49 | - docker build --no-cache --build-arg VERSION={{.GEM_VERSION}} -t {{.DOCKER_IMAGE}}:{{.GEM_VERSION}} . 50 | 51 | test: 52 | desc: Run the tests 53 | deps: 54 | - task: test:setup 55 | cmds: 56 | - bundle exec rake test 57 | 58 | test:setup: 59 | desc: Setup the test environment 60 | cmds: 61 | - task: test:setup:endpoint-container 62 | - | 63 | cd test/theme-gem 64 | bundle install 65 | - bundle install 66 | 67 | test:setup:endpoint-container: 68 | desc: Start a saprql endpoint for the tests 69 | cmds: 70 | - docker run --rm -d -p 3030:3030 --name jekyll_rdf_test_endpoint stain/jena-fuseki:4.8.0 ./fuseki-server --mem /remote 71 | status: 72 | - '[ "$( docker inspect --format "{{`{{.State.Running}}`}}" jekyll_rdf_test_endpoint )" = "true" ]' 73 | -------------------------------------------------------------------------------- /docker-resources/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$NO_BUNDLER" ] 4 | then 5 | bundle install 6 | if [ $# -eq 0 ] 7 | then 8 | bundle exec jekyll build 9 | else 10 | bundle exec $@ 11 | fi 12 | else 13 | $@ 14 | fi 15 | -------------------------------------------------------------------------------- /jekyll-rdf.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | RELEASE_VERSION = case 3 | when ENV['VERSION'] then ENV['VERSION'] 4 | else 5 | version = `git describe --tags --dirty --always` 6 | # if Gem::Version.new(ARGV[0]).prerelease? then puts Gem::Version.new(Gem::Version.new(ARGV[0].split('-')[0]).bump().to_s + '-' + ARGV[0].split('-')[1..].join('.')) else puts Gem::Version.new(ARGV[0]) end 7 | if Gem::Version.new(version).prerelease? then 8 | Gem::Version.new(Gem::Version.new(version.split('-')[0]).bump().to_s + '-' + version.split('-')[1..].join('.')) 9 | else 10 | Gem::Version.new(version) 11 | end 12 | end 13 | 14 | Gem::Specification.new do |s| 15 | s.name = 'jekyll-rdf' 16 | s.version = RELEASE_VERSION.to_s 17 | s.summary = 'Hypertext Publication System for Templated Resource Rendering' 18 | s.description = 'Generate static sites with Jekyll based on RDF data' 19 | 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'] 20 | s.email = 'arndt@informatik.uni-leipzig.de' 21 | s.files = Dir['lib/**/*.rb'] 22 | s.homepage = 'https://github.com/AKSW/jekyll-rdf' 23 | s.license = 'MIT' 24 | s.add_runtime_dependency 'linkeddata', '~> 3.2', '>= 3.2.0' 25 | s.add_runtime_dependency 'sparql-client', '~> 3.2', '>= 3.2.0' 26 | s.add_runtime_dependency 'jekyll', '>= 4.2', '>= 4.2.1' 27 | s.add_runtime_dependency 'logger', '~> 1.5.0' 28 | s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6' 29 | s.add_development_dependency 'rest-client', '~> 2.0', '>= 2.0.1' 30 | s.add_development_dependency 'simplecov', '~> 0.22.0' 31 | s.add_development_dependency 'test-unit', '~> 3.0' 32 | s.add_development_dependency 'shoulda-context', '~> 1.1' 33 | s.add_development_dependency 'rspec', '~> 3.0' 34 | s.add_development_dependency 'pry-byebug', '~> 3.4' 35 | s.add_development_dependency 'rdoc', '~> 6.2', '>= 6.2.1' 36 | s.add_development_dependency 'jekyll-theme-jod', '~> 0.3' 37 | s.add_development_dependency 'kramdown-parser-gfm', '~> 1.1' 38 | end 39 | -------------------------------------------------------------------------------- /lib/jekyll-rdf.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # MIT License 3 | # 4 | # Copyright (c) 2016 Elias Saalmann, Christian Frommert, Simon Jakobi, 5 | # Arne Jonas Präger, Maxi Bornmann, Georg Hackel, Eric Füg 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # 25 | ## 26 | # JekyllRdf converts RDF data into static websites 27 | # 28 | # 29 | require 'jekyll' 30 | require 'linkeddata' 31 | require 'sparql' 32 | require 'set' 33 | require 'addressable/uri' 34 | require 'pp' 35 | 36 | require 'jekyll/helper/rdf_types' 37 | require 'jekyll/types/XsdInteger' 38 | require 'jekyll/types/XsdDecimal' 39 | require 'jekyll/types/XsdDouble' 40 | require 'jekyll/types/XsdBoolean' 41 | require 'jekyll/drops/rdf_term' 42 | require 'jekyll/drops/rdf_statement' 43 | require 'jekyll/drops/rdf_literal' 44 | require 'jekyll/drops/rdf_resource' 45 | require 'jekyll/drops/rdf_resource_class' 46 | require 'jekyll/drops/rdf_graph' 47 | require 'jekyll/exceptions/NoPrefixMapped' 48 | require 'jekyll/exceptions/NoPrefixesDefined' 49 | require 'jekyll/exceptions/UnMarkedUri' 50 | require 'jekyll/helper/rdf_prefix_helper' 51 | require 'jekyll/helper/rdf_general_helper' 52 | require 'jekyll/helper/rdf_class_extraction' 53 | require 'jekyll/helper/rdf_page_helper' 54 | require 'jekyll/helper/rdf_generator_helper' 55 | require 'jekyll/helper/rdf_filter_helper' 56 | require 'jekyll/helper/rdf_hook_helper' 57 | require 'jekyll/hooks/rdf_page_pointer' 58 | require 'jekyll/filters/rdf_sparql_query' 59 | require 'jekyll/filters/rdf_property' 60 | require 'jekyll/filters/rdf_collection' 61 | require 'jekyll/filters/rdf_container' 62 | require 'jekyll/filters/rdf_get' 63 | require 'jekyll/filters/rdf_debug_message' 64 | 65 | 66 | Liquid::Template.register_filter(Jekyll::JekyllRdf::Filter) 67 | require 'jekyll/rdf_main_generator' 68 | require 'jekyll/rdf_template_mapper' 69 | -------------------------------------------------------------------------------- /lib/jekyll/drops/rdf_graph.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # MIT License 3 | # 4 | # Copyright (c) 2016 Elias Saalmann, Christian Frommert, Simon Jakobi, 5 | # Arne Jonas Präger, Maxi Bornmann, Georg Hackel, Eric Füg 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # 25 | 26 | module Jekyll #:nodoc: 27 | module JekyllRdf #:nodoc: 28 | module Drops #:nodoc: 29 | class RdfGraph < Liquid::Drop 30 | attr_reader :graph 31 | 32 | def initialize(graph) 33 | @graph = graph 34 | end 35 | 36 | def to_s 37 | to_nquads 38 | end 39 | 40 | def to_nquads 41 | result = @graph.statements.map{|state| 42 | state.to_nquads 43 | }.join("") 44 | return result 45 | end 46 | 47 | def to_ntriples 48 | result = @graph.statements.map{|state| 49 | state.to_ntriples 50 | }.join("") 51 | return result 52 | end 53 | end 54 | end 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /lib/jekyll/drops/rdf_literal.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # MIT License 3 | # 4 | # Copyright (c) 2016 Elias Saalmann, Christian Frommert, Simon Jakobi, 5 | # Arne Jonas Präger, Maxi Bornmann, Georg Hackel, Eric Füg 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # 25 | 26 | module Jekyll 27 | module JekyllRdf 28 | module Drops 29 | 30 | ## 31 | # Represents an RDF literal to the Liquid template engine 32 | # 33 | class RdfLiteral < RdfTerm 34 | 35 | ## 36 | # Return a user-facing string representing this RdfLiteral 37 | # 38 | def literal 39 | term.to_s 40 | end 41 | 42 | ## 43 | # Return literal value to allow liquid filters to compute 44 | # rdf literals as well 45 | # source: https://github.com/eccenca/jekyll-rdf/commit/704dd98c5e457a81e97fcd011562f1f39fc3f813 46 | # 47 | def to_liquid 48 | # Convert scientific notation 49 | 50 | term_str = term.to_s 51 | if(term.has_datatype?) 52 | custom_type = Jekyll::JekyllRdf::Helper::Types::find(term.datatype) 53 | return custom_type.to_type term_str if (!custom_type.nil?) && (custom_type.match? term_str) 54 | end 55 | return term.to_s 56 | end 57 | 58 | end 59 | end 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /lib/jekyll/drops/rdf_resource_class.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # MIT License 3 | # 4 | # Copyright (c) 2016 Elias Saalmann, Christian Frommert, Simon Jakobi, 5 | # Arne Jonas Präger, Maxi Bornmann, Georg Hackel, Eric Füg 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # 25 | 26 | module Jekyll #:nodoc: 27 | module JekyllRdf #:nodoc: 28 | module Drops #:nodoc: 29 | 30 | ## 31 | # Represents an RDF resource class to the Liquid template engine 32 | # 33 | class RdfResourceClass < RdfResource 34 | attr_accessor :lock 35 | attr_reader :distance #distance to next class with template 36 | attr_accessor :template 37 | attr_accessor :path 38 | attr_accessor :base # important for template mapping 39 | # true if _config.yml assigned this class a template 40 | 41 | def initialize(term, base = false) 42 | super(term) 43 | @base = base 44 | @lock = -1 45 | @lockNumber = 0 46 | @distance = 0 47 | end 48 | 49 | ## 50 | # Returns all classes from which +term+ directly inherited 51 | # 52 | def find_direct_superclasses 53 | return @superclasses unless @superclasses.nil? 54 | query = "SELECT ?s WHERE{ #{@term.to_ntriples} ?s }" 55 | selection = Jekyll::JekyllRdf::Helper::RdfHelper::sparql. 56 | query(query).map{ |solution| solution.s.to_s} 57 | @superclasses = selection 58 | return selection 59 | end 60 | 61 | ## 62 | # Propagate the current template to the parent of the breadth-first search 63 | # in RdfClassExtraction.request_class_template. 64 | # 65 | def propagate_template(distance) 66 | @distance = distance 67 | return if @path.nil? 68 | return unless @path.template.nil? 69 | @path.template = @template 70 | @path.propagate_template(distance + 1) 71 | end 72 | 73 | ## 74 | # Returns the beginning of the path leading to the found template 75 | # 76 | def get_path_root 77 | return self if @path.nil? 78 | @path.get_path_root 79 | end 80 | 81 | ## 82 | # Checks if this instance was already added to the breadth-first search 83 | # in RdfClassExtraction.request_class_template. 84 | # 85 | def add? lock_number 86 | if @lock_number != lock_number 87 | # used to recognize different searchpasses of request_class_template 88 | @lock_number = lock_number 89 | @lock = -1 90 | true 91 | else 92 | false 93 | end 94 | end 95 | end #RdfResourceClass 96 | end 97 | end 98 | end 99 | -------------------------------------------------------------------------------- /lib/jekyll/drops/rdf_statement.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # MIT License 3 | # 4 | # Copyright (c) 2016 Elias Saalmann, Christian Frommert, Simon Jakobi, 5 | # Arne Jonas Präger, Maxi Bornmann, Georg Hackel, Eric Füg 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # 25 | 26 | module Jekyll 27 | module JekyllRdf 28 | module Drops 29 | 30 | ## 31 | # Represents an RDF statement to the Liquid template engine 32 | # 33 | class RdfStatement < Liquid::Drop 34 | 35 | ## 36 | # The subject RdfTerm of this RDF statement 37 | # 38 | attr_reader :subject 39 | 40 | ## 41 | # The predicate RdfTerm of this RDF statement 42 | # 43 | attr_reader :predicate 44 | 45 | ## 46 | # The object RdfTerm of this RDF statement 47 | # 48 | attr_reader :object 49 | 50 | ## 51 | # Create a new Jekyll::Drops::RdfStatement 52 | # 53 | # * +statement+ - The statement to be represented 54 | # * +sparql+ - The SPARQL::Client which contains the +statement+ 55 | # * +site+ - The Jekyll::Site to be enriched 56 | def initialize(statement, site) 57 | @subject ||= Jekyll::JekyllRdf::Drops::RdfTerm.build_term_drop(statement.subject, site, true) 58 | @predicate ||= Jekyll::JekyllRdf::Drops::RdfTerm.build_term_drop(statement.predicate, site, true) 59 | @object ||= Jekyll::JekyllRdf::Drops::RdfTerm.build_term_drop(statement.object, site, true) 60 | end 61 | 62 | def inspect 63 | obj_id = ('%x' % (self.object_id << 1)).to_s 64 | return "#" 65 | end 66 | end 67 | end 68 | end 69 | end 70 | -------------------------------------------------------------------------------- /lib/jekyll/exceptions/NoPrefixMapped.rb: -------------------------------------------------------------------------------- 1 | class NoPrefixMapped < StandardError 2 | attr_accessor :prefix, :property 3 | def initialize property, layout, prefix 4 | @prefix, @property = prefix, property 5 | super("Their is no mapping defined for #{prefix} in context to #{property}\n in layout: '#{layout}'.") 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/jekyll/exceptions/NoPrefixesDefined.rb: -------------------------------------------------------------------------------- 1 | class NoPrefixesDefined < StandardError 2 | def initialize x, layout 3 | super("No Prefixes are defined when #{x} gets passed in \n layout: '#{layout}'.") 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /lib/jekyll/exceptions/UnMarkedUri.rb: -------------------------------------------------------------------------------- 1 | class UnMarkedUri < StandardError 2 | def initialize uri, layout 3 | super("The URI #{uri} is not correctly marked. Pls use the form <#{uri}> instead.\nFound in layout: '#{layout}'.") 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /lib/jekyll/filters/rdf_collection.rb: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | ## 3 | # MIT License 4 | # 5 | # Copyright (c) 2016 Elias Saalmann, Christian Frommert, Simon Jakobi, 6 | # Arne Jonas Präger, Maxi Bornmann, Georg Hackel, Eric Füg 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in all 16 | # copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | # SOFTWARE. 25 | # 26 | 27 | module Jekyll 28 | module JekyllRdf 29 | module Filter 30 | def rdf_collection(input, predicate = nil) 31 | input = rdf_page_to_resource(input) 32 | return unless valid_resource?(input) 33 | input = to_string_wrap(input) 34 | query = "SELECT ?f WHERE{ #{input} " << 35 | (predicate.nil? ? "" : " #{rdf_resolve_prefix(predicate)} ?coll . ?coll ") << 36 | " * ?r. ?r ?f}" 37 | results = [] 38 | Jekyll::JekyllRdf::Helper::RdfHelper::sparql.query(query).each{ |solution| 39 | results.push Jekyll::JekyllRdf::Drops::RdfTerm.build_term_drop(solution.f, Jekyll::JekyllRdf::Helper::RdfHelper::site, true).add_necessities(Jekyll::JekyllRdf::Helper::RdfHelper::site, Jekyll::JekyllRdf::Helper::RdfHelper::page) 40 | } 41 | return results 42 | end 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /lib/jekyll/filters/rdf_container.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # MIT License 3 | # 4 | # Copyright (c) 2016 Elias Saalmann, Christian Frommert, Simon Jakobi, 5 | # Arne Jonas Präger, Maxi Bornmann, Georg Hackel, Eric Füg 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # 25 | 26 | module Jekyll 27 | module JekyllRdf 28 | module Filter 29 | def rdf_container(input, predicate = nil) 30 | input = rdf_page_to_resource(input) 31 | return unless valid_resource?(input) 32 | sparql_client = Jekyll::JekyllRdf::Helper::RdfHelper::sparql 33 | n_triples = to_string_wrap(input) 34 | query = "SELECT ?p ?o WHERE{ #{n_triples} " << 35 | (predicate.nil? ? "" : " #{rdf_resolve_prefix(predicate)} ?container . ?container ") << 36 | " ?p ?o #{query_additions()}" 37 | solutions = sparql_client.query(query).each_with_object([]) {|solution, array| 38 | if(/^http:\/\/www\.w3\.org\/1999\/02\/22-rdf-syntax-ns#_\d+$/.match(solution.p.to_s)) 39 | array << Jekyll::JekyllRdf::Drops::RdfTerm.build_term_drop(solution.o, Jekyll::JekyllRdf::Helper::RdfHelper::site, true).add_necessities(Jekyll::JekyllRdf::Helper::RdfHelper::site, Jekyll::JekyllRdf::Helper::RdfHelper::page) 40 | end 41 | } 42 | return solutions 43 | end 44 | 45 | private 46 | def query_additions() 47 | return "BIND(((SUBSTR(str(?p), 45))) AS ?order) } ORDER BY ASC(?order)" 48 | end 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /lib/jekyll/filters/rdf_debug_message.rb: -------------------------------------------------------------------------------- 1 | module Jekyll 2 | 3 | module JekyllRdf 4 | 5 | ## 6 | # Internal module to hold the medthod #rdf_message 7 | # 8 | module Filter 9 | def rdf_debug_message(message, logLevel = "info") #:nodoc: 10 | case logLevel 11 | when "info" 12 | Jekyll.logger.info message 13 | when "warn" 14 | Jekyll.logger.warn message 15 | when "error" 16 | Jekyll.logger.error message 17 | when "debug" 18 | Jekyll.logger.debug message 19 | else 20 | Jekyll.logger.info "NoLevel: #{message}" 21 | end 22 | end 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/jekyll/filters/rdf_get.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # MIT License 3 | # 4 | # Copyright (c) 2016 Elias Saalmann, Christian Frommert, Simon Jakobi, 5 | # Arne Jonas Präger, Maxi Bornmann, Georg Hackel, Eric Füg 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # 25 | 26 | module Jekyll 27 | 28 | module JekyllRdf 29 | 30 | ## 31 | # Internal module to hold the method #rdf_get 32 | # 33 | module Filter 34 | def rdf_get(request_uri) 35 | return request_uri if request_uri.class <= Jekyll::JekyllRdf::Drops::RdfResource 36 | request_uri = to_string_wrap(rdf_page_to_resource(request_uri)) 37 | return unless valid_resource?(request_uri) && (!request_uri[0..1].eql? "_:") 38 | request_uri = rdf_resolve_prefix(request_uri) 39 | Jekyll::JekyllRdf::Helper::RdfHelper.resources(request_uri[1..-2]) 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /lib/jekyll/filters/rdf_sparql_query.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # MIT License 3 | # 4 | # Copyright (c) 2016 Elias Saalmann, Christian Frommert, Simon Jakobi, 5 | # Arne Jonas Präger, Maxi Bornmann, Georg Hackel, Eric Füg 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # 25 | 26 | module Jekyll 27 | module JekyllRdf 28 | ## 29 | # Internal module to hold the medthod #sparql_query 30 | # 31 | module Filter 32 | 33 | ## 34 | # Executes a SPARQL query. The supplied query is augmented by replacing each occurence of '?resourceUri' by the URI of the context RDF resource. 35 | # Returns an Array of bindings. Each binding is a Hash mapping variables to their values. 36 | # 37 | # * +input+ - the context RDF resource 38 | # * +query+ - the SPARQL query 39 | # 40 | def sparql_query(resource = nil, query) 41 | query = prepare_query(resource, query) 42 | return if query.nil? 43 | begin 44 | result = Jekyll::JekyllRdf::Helper::RdfHelper::sparql.query(query) 45 | if (result.class == RDF::Graph) 46 | return Jekyll::JekyllRdf::Drops::RdfGraph.new(result) 47 | end 48 | result.map! do |solution| 49 | hsh = solution.to_h 50 | hsh.update(hsh){ |k,v| Jekyll::JekyllRdf::Drops::RdfTerm.build_term_drop(v, Jekyll::JekyllRdf::Helper::RdfHelper::site, true).add_necessities(Jekyll::JekyllRdf::Helper::RdfHelper::site, Jekyll::JekyllRdf::Helper::RdfHelper::page)} 51 | hsh.collect{|k,v| [k.to_s, v]}.to_h 52 | end 53 | return result 54 | rescue SPARQL::Client::ClientError => ce 55 | Jekyll.logger.error("client error experienced: \n #{query} \n Error Message: #{ce.message}") 56 | raise if Jekyll.env.eql? "development" 57 | rescue SPARQL::MalformedQuery => mq 58 | Jekyll.logger.error("malformed query found: \n #{query} \n Error Message: #{mq.message}") 59 | raise if Jekyll.env.eql? "development" 60 | rescue Exception => e 61 | Jekyll.logger.error("unknown Exception of class: #{e.class} in sparql_query \n Query: #{query} \nMessage: #{e.message} \nTrace #{e.backtrace.drop(1).map{|s| "\t#{s}"}.join("\n")}") 62 | raise if Jekyll.env.eql? "development" 63 | end 64 | return [] 65 | end 66 | 67 | end 68 | end 69 | end 70 | -------------------------------------------------------------------------------- /lib/jekyll/helper/rdf_prefix_helper.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # MIT License 3 | # 4 | # Copyright (c) 2017 Sebastian Zänker 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to deal 8 | # in the Software without restriction, including without limitation the rights 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | # copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in all 14 | # copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | # SOFTWARE. 23 | # 24 | 25 | module Jekyll 26 | module JekyllRdf 27 | module Helper 28 | ## 29 | # Internal module to hold support for functionalities like submitting sparql queries 30 | # 31 | module RdfPrefixHelper 32 | ## 33 | # loads the prefix data passed in the layout yaml-frontmatter or in _config.yml into page.data["rdf_prefixes"] and page.data["rdf_prefix_map"] 34 | def load_prefixes(path, prefHolder) 35 | Jekyll::JekyllRdf::Helper::RdfHelper.load_prefixes(path, prefHolder) 36 | rescue Errno::ENOENT 37 | Jekyll.logger.error("--> context resource: #{@resource} template: #{@template}") unless self.data["rdf"].nil? 38 | raise if Jekyll.env.eql? "development" 39 | end 40 | end 41 | 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/jekyll/helper/rdf_types.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # MIT License 3 | # 4 | # Copyright (c) 2017 Sebastian Zänker 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to deal 8 | # in the Software without restriction, including without limitation the rights 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | # copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in all 14 | # copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | # SOFTWARE. 23 | # 24 | 25 | module Jekyll 26 | module JekyllRdf 27 | module Helper 28 | 29 | ## 30 | # Internal module for registering custom types 31 | # 32 | module Types 33 | @@types = [] 34 | def self.register type 35 | @@types.push type 36 | end 37 | 38 | def self.find type 39 | index = @@types.find_index {|x| x === type.to_s} 40 | return @@types[index] unless index.nil? 41 | return nil 42 | end 43 | end 44 | end 45 | end 46 | end 47 | 48 | -------------------------------------------------------------------------------- /lib/jekyll/hooks/rdf_page_pointer.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # MIT License 3 | # 4 | # Copyright (c) 2017 Sebastian Zänker 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to deal 8 | # in the Software without restriction, including without limitation the rights 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | # copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in all 14 | # copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | # SOFTWARE. 23 | # 24 | 25 | Jekyll::Hooks.register :site, :after_reset do |site| 26 | Jekyll::JekyllRdf::Helper::RdfHelper::reinitialize 27 | end 28 | 29 | Jekyll::Hooks.register :documents, :post_init do |page| 30 | if(page.data["rdf_prefix_path"].nil?) 31 | page.data["rdf_prefix_set?"] = false 32 | else 33 | page.data["rdf_prefix_set?"] = true 34 | end 35 | end 36 | 37 | Jekyll::Hooks.register :pages, :post_init do |page| 38 | if(page.data["rdf_prefix_path"].nil?) 39 | page.data["rdf_prefix_set?"] = false 40 | else 41 | page.data["rdf_prefix_set?"] = true 42 | end 43 | end 44 | 45 | Jekyll::Hooks.register :posts, :post_init do |page| 46 | if(page.data["rdf_prefix_path"].nil?) 47 | page.data["rdf_prefix_set?"] = false 48 | else 49 | page.data["rdf_prefix_set?"] = true 50 | end 51 | end 52 | 53 | 54 | Jekyll::Hooks.register :pages, :pre_render do |page, payload| 55 | unless(page.data['rdf'].nil?) 56 | payload["content"] = "" 57 | end 58 | include Jekyll::JekyllRdf::Helper::RdfHookHelper 59 | backload_prefixes page, payload if page.data["rdf_prefixes"].nil? 60 | Jekyll::JekyllRdf::Helper::RdfHelper::page = page 61 | end 62 | 63 | Jekyll::Hooks.register :documents, :pre_render do |page, payload| 64 | Jekyll::JekyllRdf::Helper::RdfHelper::page = page 65 | end 66 | 67 | Jekyll::Hooks.register :posts, :pre_render do |page, payload| 68 | include Jekyll::JekyllRdf::Helper::RdfHookHelper 69 | backload_prefixes page, payload 70 | Jekyll::JekyllRdf::Helper::RdfHelper::page = page 71 | end 72 | -------------------------------------------------------------------------------- /lib/jekyll/rdf_template_mapper.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # MIT License 3 | # 4 | # Copyright (c) 2016 Elias Saalmann, Christian Frommert, Simon Jakobi, 5 | # Arne Jonas Präger, Maxi Bornmann, Georg Hackel, Eric Füg 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # 25 | 26 | module Jekyll 27 | 28 | ## 29 | # Jekyll::RdfTemplateMapper maps resources to templates 30 | # 31 | class RdfTemplateMapper 32 | 33 | include Jekyll::JekyllRdf::Helper::RdfClassExtraction 34 | 35 | ## 36 | # Create a new Jekyll::RdfTemplateMapper 37 | # 38 | # * +resources_to_templates+ - A Hash mapping a type resource to a template name 39 | # * +default_template+ - Default template name 40 | def initialize(resources_to_templates, classes_to_templates, default_template) 41 | @resources_to_templates = resources_to_templates 42 | @default_template = default_template 43 | @classResources = {} 44 | @consistence = {} #ensures that the same template is chosen for each combination of templates 45 | @template_cache = {} 46 | @stop_object = StopObject.new 47 | 48 | create_resource_class(classes_to_templates) 49 | end 50 | 51 | ## 52 | # Maps a resource to a template name. 53 | # 54 | # Returns the template name of one of the +resource+'s types, if available. Returns the default template name otherwise. 55 | def map(resource) 56 | tmpl = @resources_to_templates ? @resources_to_templates[resource.term.to_s] : nil 57 | tmpl = request_class_template(resource) if tmpl.nil? 58 | return tmpl unless tmpl.nil? 59 | return @default_template 60 | end 61 | 62 | ## 63 | # outputs all warnings prepared by RdfClassExtraction.consistence_templates 64 | # 65 | def print_warnings 66 | @consistence.each{ |key, template_class_store| 67 | Jekyll.logger.warn("Warning: multiple possible templates for resources #{template_class_store[1].join(", ")}\nPossible Templates: #{key}") 68 | true 69 | } 70 | end 71 | end # RdfTemplateMapper 72 | end #Jekyll 73 | -------------------------------------------------------------------------------- /lib/jekyll/types/XsdBoolean.rb: -------------------------------------------------------------------------------- 1 | module Jekyll 2 | module JekyllRdf 3 | module Types 4 | class XsdBoolean 5 | @@class_uri = "http://www.w3.org/2001/XMLSchema#boolean" 6 | 7 | def self.match? string 8 | return regex.match string 9 | end 10 | 11 | def self.regex 12 | @@regex ||= /^\b1|\b0|\btrue|\bfalse$/ 13 | return @@regex 14 | end 15 | 16 | def self.to_type string 17 | return "TRUE".eql?(string).to_s 18 | end 19 | 20 | def self.=== other 21 | return other.to_s.eql? @@class_uri 22 | end 23 | 24 | def self.to_s 25 | return @@class_uri 26 | end 27 | end 28 | 29 | Jekyll::JekyllRdf::Helper::Types::register XsdBoolean 30 | end 31 | end 32 | 33 | end 34 | -------------------------------------------------------------------------------- /lib/jekyll/types/XsdDecimal.rb: -------------------------------------------------------------------------------- 1 | module Jekyll 2 | module JekyllRdf 3 | module Types 4 | class XsdDecimal 5 | @@class_uri = "http://www.w3.org/2001/XMLSchema#decimal" 6 | 7 | def self.match? string 8 | return regex.match string 9 | end 10 | 11 | def self.regex 12 | @@regex ||= /^[+-]?[0-9]*\.[0-9]+$/ 13 | return @@regex 14 | end 15 | 16 | def self.to_type string 17 | return string.to_f.to_s 18 | end 19 | 20 | def self.=== other 21 | return other.to_s.eql? @@class_uri 22 | end 23 | 24 | def self.to_s 25 | return @@class_uri 26 | end 27 | end 28 | 29 | Jekyll::JekyllRdf::Helper::Types::register XsdDecimal 30 | end 31 | end 32 | 33 | end 34 | -------------------------------------------------------------------------------- /lib/jekyll/types/XsdDouble.rb: -------------------------------------------------------------------------------- 1 | module Jekyll 2 | module JekyllRdf 3 | module Types 4 | class XsdDouble 5 | @@class_uri = "http://www.w3.org/2001/XMLSchema#double" 6 | 7 | def self.match? string 8 | return regex.match string.upcase 9 | end 10 | 11 | def self.regex 12 | @@regex ||= /^[+-]?[0-9]+\.(\d+)E[+-]?(\d+)$/ 13 | return @@regex 14 | end 15 | 16 | def self.to_type string 17 | string = string.upcase 18 | number = string.to_f 19 | negative = number < 0 20 | if negative 21 | number = number * (-1) 22 | end 23 | e = [-1 * (Math.log10(number).floor - (string.to_s.index('E') - string.to_s.index('.'))), 0].max 24 | vz = "" 25 | if negative 26 | vz = "-" 27 | end 28 | 29 | result = vz.to_s + sprintf("%." + e.to_s + "f", number) 30 | return result 31 | end 32 | 33 | def self.=== other 34 | return other.to_s.eql? @@class_uri 35 | end 36 | 37 | def self.to_s 38 | return @@class_uri 39 | end 40 | end 41 | 42 | Jekyll::JekyllRdf::Helper::Types::register XsdDouble 43 | end 44 | end 45 | 46 | end 47 | -------------------------------------------------------------------------------- /lib/jekyll/types/XsdInteger.rb: -------------------------------------------------------------------------------- 1 | module Jekyll 2 | module JekyllRdf 3 | module Types 4 | class XsdInteger 5 | @@class_uri = "http://www.w3.org/2001/XMLSchema#integer" 6 | 7 | def self.match? string 8 | return regex.match string 9 | end 10 | 11 | def self.regex 12 | @@regex ||= /^[+-]?[0-9]+$/ 13 | return @@regex 14 | end 15 | 16 | def self.to_type string 17 | return string.to_i.to_s 18 | end 19 | 20 | def self.=== other 21 | return other.to_s.eql? @@class_uri 22 | end 23 | 24 | def self.to_s 25 | return @@class_uri 26 | end 27 | end 28 | 29 | Jekyll::JekyllRdf::Helper::Types::register XsdInteger 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /test/RdfTestUtility.rb: -------------------------------------------------------------------------------- 1 | module RdfTestUtility 2 | def setup_jekyll path 3 | @source = path 4 | config = Jekyll.configuration(YAML.load_file(File.join(@source, '_config.yml')).merge!({'source' => @source, 'destination' => File.join(@source, "_site")})) 5 | site = Jekyll::Site.new(config) 6 | Jekyll::JekyllRdf::Helper::RdfHelper.reinitialize 7 | site.process 8 | end 9 | 10 | def setup_site_jekyll path 11 | @source = path 12 | config = Jekyll.configuration(YAML.load_file(File.join(@source, '_config.yml')).merge!({'source' => @source, 'destination' => File.join(@source, "_site")})) 13 | @site = Jekyll::Site.new(config) 14 | Jekyll::JekyllRdf::Helper::RdfHelper.reinitialize 15 | @site.process 16 | end 17 | end -------------------------------------------------------------------------------- /test/cases/Jekyll/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/Jekyll/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" 2 | url: "http://example.org/" 3 | plugins: 4 | - jekyll-rdf 5 | jekyll_rdf: 6 | path: "_data/knowledge-base.ttl" 7 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 8 | default_template: "default" 9 | class_template_mappings: 10 | "http://xmlns.com/foaf/0.1/Person": "person" 11 | instance_template_mappings: 12 | "http://example.org/instance/resource": "exampleInstance" 13 | -------------------------------------------------------------------------------- /test/cases/Jekyll/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX foaf: 2 | PREFIX eg: 3 | -------------------------------------------------------------------------------- /test/cases/Jekyll/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix xsd: . 2 | @prefix foaf: . 3 | @prefix eg: . 4 | 5 | eg:resource eg:predicate eg:object . 6 | eg:person a foaf:Person . 7 | eg:person foaf:age "28"^^xsd:int . 8 | eg:person foaf:name "Jeanne Doe" . 9 | -------------------------------------------------------------------------------- /test/cases/Jekyll/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
8 |

This is made with jekyll-rdf

9 | {{content}} 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cases/Jekyll/_layouts/exampleInstance.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
This page is mapped to:
7 | {{page.rdf}} 8 |
9 | -------------------------------------------------------------------------------- /test/cases/Jekyll/_layouts/person.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/LinkTag/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/LinkTag/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" # the subpath of your site, e.g. /blog 2 | url: "http://example.org/" # the base hostname & protocol for your site 3 | # Build settings 4 | markdown: kramdown 5 | plugins: 6 | - jekyll-rdf 7 | jekyll_rdf: 8 | path: "_data/knowledge-base.ttl" 9 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 10 | default_template: "default" 11 | -------------------------------------------------------------------------------- /test/cases/LinkTag/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix eg: . 2 | 3 | eg:resource eg:predicate eg:object . 4 | 5 | eg:predicate eg:object . 6 | eg:predicate eg:object . 7 | 8 | -------------------------------------------------------------------------------- /test/cases/LinkTag/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
8 |

This is made with jekyll-rdf

9 | {{content}} 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cases/LinkTag/links.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | Links 7 | 8 | 9 | 10 | 11 |
12 | {% link http://example.org/instance/resource %} 13 |
14 | {% link http://example.org/instance/xorg/l/memonic %} 15 |
16 | {% link http://example.org/outside/xorg/l/menonic %} 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /test/cases/MergeFeatureLayoutRoute/Bart.html: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Barts Skating page" 3 | --- 4 | 5 | I really like skating 6 | -------------------------------------------------------------------------------- /test/cases/MergeFeatureLayoutRoute/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/MergeFeatureLayoutRoute/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" 2 | url: "http://example.org/" 3 | # Build settings 4 | 5 | plugins: 6 | - jekyll-rdf 7 | jekyll_rdf: 8 | path: "_data/knowledge-base.ttl" 9 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 10 | default_template: "default" 11 | class_template_mappings: 12 | "http://xmlns.com/foaf/0.1/Person": "person" 13 | 14 | -------------------------------------------------------------------------------- /test/cases/MergeFeatureLayoutRoute/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX xsd: 2 | PREFIX foaf: 3 | PREFIX eg: 4 | -------------------------------------------------------------------------------- /test/cases/MergeFeatureLayoutRoute/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix xsd: . 2 | @prefix foaf: . 3 | @prefix eg: . 4 | 5 | eg:Bart a foaf:Person . 6 | eg:Bart foaf:age "15"^^xsd:int . 7 | eg:Bart foaf:name "Bart" . 8 | -------------------------------------------------------------------------------- /test/cases/MergeFeatureLayoutRoute/_layouts/bart_layout.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default_bart 3 | --- 4 | 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | 17 |
18 | begin bart content 19 | {{ content }} 20 | end bart content 21 |
22 | -------------------------------------------------------------------------------- /test/cases/MergeFeatureLayoutRoute/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | Default: {{ page.title }} 7 | 8 | 9 |
10 |

This is made with jekyll-rdf

11 | begin default content 12 | {{content}} 13 | end default content 14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /test/cases/MergeFeatureLayoutRoute/_layouts/default_bart.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | {{ page.title }} 7 | 8 | 9 |
10 |

This is made with jekyll-rdf

11 | begin default_bart content 12 | {{content}} 13 | end default_bart content 14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /test/cases/MergeFeatureLayoutRoute/_layouts/person.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | 17 |
18 | begin person content 19 | {{content}} 20 | end person content 21 |
22 | -------------------------------------------------------------------------------- /test/cases/MergeFeaturePageRoute/Bart.html: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Barts Skating page" 3 | layout: bart_layout 4 | --- 5 | 6 | I really like skating 7 | -------------------------------------------------------------------------------- /test/cases/MergeFeaturePageRoute/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/MergeFeaturePageRoute/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" 2 | url: "http://example.org/" 3 | plugins: 4 | - jekyll-rdf 5 | jekyll_rdf: 6 | path: "_data/knowledge-base.ttl" 7 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 8 | default_template: "default" 9 | class_template_mappings: 10 | "http://xmlns.com/foaf/0.1/Person": "person" 11 | 12 | -------------------------------------------------------------------------------- /test/cases/MergeFeaturePageRoute/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX rdf: 2 | PREFIX rdfs: 3 | PREFIX xsd: 4 | PREFIX foaf: 5 | PREFIX eg: 6 | -------------------------------------------------------------------------------- /test/cases/MergeFeaturePageRoute/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix xsd: . 2 | @prefix foaf: . 3 | @prefix eg: . 4 | 5 | eg:Bart a foaf:Person . 6 | eg:Bart foaf:age "15"^^xsd:int . 7 | eg:Bart foaf:name "Bart" . 8 | -------------------------------------------------------------------------------- /test/cases/MergeFeaturePageRoute/_layouts/bart_layout.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default_bart 3 | --- 4 | 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | 17 |
18 | begin bart content 19 | {{ content }} 20 | end bart content 21 |
22 | -------------------------------------------------------------------------------- /test/cases/MergeFeaturePageRoute/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | Default: {{ page.title }} 7 | 8 | 9 |
10 |

This is made with jekyll-rdf

11 | begin default content 12 | {{content}} 13 | end default content 14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /test/cases/MergeFeaturePageRoute/_layouts/default_bart.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | {{ page.title }} 7 | 8 | 9 |
10 |

This is made with jekyll-rdf

11 | begin default_bart content 12 | {{content}} 13 | end default_bart content 14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /test/cases/MergeFeaturePageRoute/_layouts/person.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | 17 |
18 | begin person content 19 | {{content}} 20 | end person content 21 |
22 | -------------------------------------------------------------------------------- /test/cases/_presets/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX rdf: 2 | PREFIX rdfs: 3 | PREFIX xsd: 4 | PREFIX foaf: 5 | PREFIX eg: 6 | -------------------------------------------------------------------------------- /test/cases/_presets/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix rdf: . 2 | @prefix rdfs: . 3 | @prefix xsd: . 4 | @prefix foaf: . 5 | @prefix eg: . 6 | 7 | eg:resource eg:predicate eg:object . 8 | eg:person a foaf:Person . 9 | eg:person foaf:age "28"^^xsd:int . 10 | eg:person foaf:name "Jeanne Doe" . 11 | -------------------------------------------------------------------------------- /test/cases/classHierarchy/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/classHierarchy/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance/" # the subpath of your site, e.g. /blog 2 | url: "http://animals.org" # the base hostname & protocol for your site 3 | plugins: 4 | - jekyll-rdf 5 | jekyll_rdf: 6 | path: "_data/knowledge-base.ttl" 7 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?o}" 8 | class_template_mappings: 9 | "http://animals.org/classification/landBorn": "landBorn" 10 | "http://animals.org/classification/layingEggs": "layingEggs" 11 | "http://animals.org/classification/foodFromWater": "foodFromWater" 12 | "http://animals.org/classification/breathingAir": "breathingAir" 13 | -------------------------------------------------------------------------------- /test/cases/classHierarchy/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix rdfs: . 2 | @prefix an: . 3 | @prefix ani: . 4 | 5 | an:landBorn rdfs:subClassOf an:animal . 6 | an:birds rdfs:subClassOf an:animal . 7 | an:swimming rdfs:subClassOf an:animal . 8 | 9 | an:4orMoreLimbs rdfs:subClassOf an:landBorn . 10 | an:walkingUpright rdfs:subClassOf an:4orMoreLimbs . 11 | 12 | an:layingEggs rdfs:subClassOf an:birds . 13 | an:scalyFeets rdfs:subClassOf an:layingEggs . 14 | an:keratinousScalyFeets rdfs:subClassOf an:scalyFeets . 15 | 16 | an:foodFromWater rdfs:subClassOf an:swimming . 17 | an:waterFiltering rdfs:subClassOf an:foodFromWater . 18 | an:waterHunting rdfs:subClassOf an:foodFromWater . 19 | an:landWaterLiving rdfs:subClassOf an:waterHunting . 20 | 21 | an:breathingAir rdfs:subClassOf an:foodFromWater . 22 | 23 | ani:ape a an:walkingUpright . 24 | ani:Lizard a an:4orMoreLimbs . 25 | ani:Lizard a an:keratinousScalyFeets . 26 | ani:Lizard a an:landWaterLiving . 27 | ani:Penguins a an:keratinousScalyFeets . 28 | ani:Penguins a an:landWaterLiving . 29 | ani:Fish a an:waterHunting . 30 | ani:Fish a an:waterFiltering . 31 | ani:Whale a an:breathingAir . 32 | ani:Whale a an:foodFromWater . 33 | -------------------------------------------------------------------------------- /test/cases/classHierarchy/_layouts/breathingAir.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
{{page.rdf}}
11 | breathingAir 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /test/cases/classHierarchy/_layouts/foodFromWater.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
{{page.rdf}}
11 | foodFromWater 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /test/cases/classHierarchy/_layouts/landBorn.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
{{page.rdf}}
11 | landBorn 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /test/cases/classHierarchy/_layouts/layingEggs.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
{{page.rdf}}
11 | layingEggs 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /test/cases/classHierarchy/test_class_hierarchy.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestClassHierarchy < Test::Unit::TestCase 4 | include RdfTestUtility 5 | context "the class-template-mapping system" do 6 | should "map the right template to the right class in consideration to its super classes" do 7 | error_holder = $stderr 8 | Jekyll.logger.log_level = :warn 9 | $stderr = StringIO.new 10 | setup_jekyll File.dirname(__FILE__) 11 | Jekyll.logger.log_level = :error 12 | $stderr = error_holder 13 | 14 | content = [] 15 | file = File.read(File.join(@source, "_site/Fish.html")) 16 | content = file[/\
(.|\s)*\<\/div>/][21..-7].strip.split("
").map do |entry| 17 | entry.strip 18 | end 19 | assert_equal "http://animals.org/instance/Fish", content[0] 20 | assert_equal "foodFromWater", content[1] 21 | 22 | content = [] 23 | file = File.read(File.join(@source, "_site/Lizard.html")) 24 | content = file[/\
(.|\s)*\<\/div>/][21..-7].strip.split("
").map do |entry| 25 | entry.strip 26 | end 27 | assert_equal "http://animals.org/instance/Lizard", content[0] 28 | assert_equal "landBorn", content[1] 29 | 30 | content = [] 31 | file = File.read(File.join(@source, "_site/Penguins.html")) 32 | content = file[/\
(.|\s)*\<\/div>/][21..-7].strip.split("
").map do |entry| 33 | entry.strip 34 | end 35 | assert_equal "http://animals.org/instance/Penguins", content[0] 36 | assert (("foodFromWater".eql? content[1]) || ("layingEggs".eql? content[1])) 37 | 38 | content = [] 39 | file = File.read(File.join(@source, "_site/Whale.html")) 40 | content = file[/\
(.|\s)*\<\/div>/][21..-7].strip.split("
").map do |entry| 41 | entry.strip 42 | end 43 | assert_equal "http://animals.org/instance/Whale", content[0] 44 | assert_equal "breathingAir", content[1] 45 | 46 | content = [] 47 | file = File.read(File.join(@source, "_site/ape.html")) 48 | content = file[/\
(.|\s)*\<\/div>/][21..-7].strip.split("
").map do |entry| 49 | entry.strip 50 | end 51 | assert_equal "http://animals.org/instance/ape", content[0] 52 | assert_equal "landBorn", content[1] 53 | 54 | assert Jekyll.logger.messages.any? {|message| !!(message =~ /.*Warning: multiple possible templates for resources.*Penguins.*/)}, "This warning should have been thrown >>>Warning: multiple possible templates for resources http://animals.org/instance/Penguins Possible Templates: foodFromWater, layingEggs<<<" 55 | assert !Jekyll.logger.messages.any? {|message| !!(message =~ /.*Warning: multiple possible templates for resources.*Fish.*/)}, "This warning should not have been thrown >>>Warning: multiple possible templates for resources http://animals.org/instance/Fish Possible Templates: ***<<<" 56 | end 57 | end 58 | end 59 | -------------------------------------------------------------------------------- /test/cases/constructQueries/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/constructQueries/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" # the subpath of your site, e.g. /blog 2 | url: "http://example.org/" # the base hostname & protocol for your site 3 | # Build settings 4 | markdown: kramdown 5 | plugins: 6 | - jekyll-rdf 7 | jekyll_rdf: 8 | path: "_data/knowledge-base.ttl" 9 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p }" 10 | default_template: "default" 11 | 12 | -------------------------------------------------------------------------------- /test/cases/constructQueries/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix eg: . 2 | 3 | eg:resource1 eg:construct eg:goConstruct . 4 | eg:resource2 eg:construct eg:goConstruct . 5 | eg:resource3 eg:construct eg:goConstruct . 6 | 7 | eg:resource4 eg:construct eg:noConstruct . 8 | eg:resource5 eg:construct eg:noConstruct . 9 | eg:resource6 eg:construct eg:noConstruct . 10 | -------------------------------------------------------------------------------- /test/cases/constructQueries/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
8 |

This is made with jekyll-rdf

9 | {{content}} 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cases/constructQueries/constructs.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | A demonstration of Construct queries 7 | 8 | 9 | 10 | 11 | {%- assign cquery = "CONSTRUCT {?x } where {?x }" -%} 12 | {%- assign test = cquery | sparql_query -%} 13 |
14 | {{ test }} 15 |
16 | {%- assign nquads = test.to_nquads -%} 17 | {{ nquads }} 18 |
19 | {%- assign ntriples = test.to_ntriples -%} 20 | {{ ntriples }} 21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /test/cases/constructQueries/test_construct_queries.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestSciMath < Test::Unit::TestCase 4 | include RdfTestUtility 5 | context "cases/constructQueries" do 6 | setup do 7 | setup_jekyll File.dirname(__FILE__) 8 | end 9 | 10 | should "work with construction queries" do 11 | content = [] 12 | file = File.read(File.join(@source, "_site/constructs.html")) 13 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 14 | entry.strip 15 | end 16 | assert_equal 3, content.length 17 | nquads = content[0].split("\n") 18 | assert (nquads.include? " ."), "the return graph should contain >>> <<<" 19 | assert (nquads.include? " ."), "the return graph should contain >>> <<<" 20 | assert (nquads.include? " ."), "the return graph should contain >>> <<<" 21 | nquads = content[1].split("\n") 22 | assert (nquads.include? " ."), "the return graph should contain >>> <<<" 23 | assert (nquads.include? " ."), "the return graph should contain >>> <<<" 24 | assert (nquads.include? " ."), "the return graph should contain >>> <<<" 25 | ntriples = content[2].split("\n") 26 | assert (ntriples.include? " ."), "the return graph should contain >>> <<<" 27 | assert (ntriples.include? " ."), "the return graph should contain >>> <<<" 28 | assert (ntriples.include? " ."), "the return graph should contain >>> <<<" 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /test/cases/dontFailIfLayoutNoFound/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/dontFailIfLayoutNoFound/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "" 2 | url: "http://example.org/" 3 | 4 | plugins: 5 | - jekyll-rdf 6 | jekyll_rdf: 7 | path: "_data/knowledge-base.ttl" 8 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 9 | default_template: "ontology" 10 | -------------------------------------------------------------------------------- /test/cases/dontFailIfLayoutNoFound/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AKSW/jekyll-rdf/1a182a1030f582cd2b63db3037ae78a50a2e639b/test/cases/dontFailIfLayoutNoFound/_data/knowledge-base.ttl -------------------------------------------------------------------------------- /test/cases/dontFailIfLayoutNoFound/_posts/2019-02-12-Blogpost.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: ontology 3 | --- 4 | 5 | This is a Blogpost 6 | -------------------------------------------------------------------------------- /test/cases/dontFailIfLayoutNoFound/blog.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: special 3 | --- 4 | 5 | A page 6 | -------------------------------------------------------------------------------- /test/cases/dontFailIfLayoutNoFound/test_prefixes.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestPrefixes < Test::Unit::TestCase 4 | context "load_prefixes from RdfPrefixHelper" do 5 | include RdfTestUtility 6 | should "check that the prefix search doesnot fail if an undefined layout is specified" do 7 | setup_jekyll File.dirname(__FILE__) 8 | 9 | blogfile = File.read(File.join(@source, "_site/2019/02/12/Blogpost.html")) 10 | page = File.read(File.join(@source, "_site/blog.html")) 11 | 12 | #TODO This test case has to be completed once jekyll runs successfull 13 | 14 | assert_equal "

This is a Blogpost

", blogfile.strip() 15 | assert_equal "A page", page.strip() 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /test/cases/emptyLinePrefixFile/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/emptyLinePrefixFile/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" # the subpath of your site, e.g. /blog 2 | url: "http://example.org/" # the base hostname & protocol for your site 3 | plugins: 4 | - jekyll-rdf 5 | jekyll_rdf: 6 | path: "_data/knowledge-base.ttl" 7 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 8 | class_template_mappings: 9 | "http://xmlns.com/foaf/0.1/Person": "person" 10 | 11 | -------------------------------------------------------------------------------- /test/cases/emptyLinePrefixFile/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX xsd: 2 | 3 | PREFIX foaf: 4 | 5 | PREFIX eg: 6 | 7 | -------------------------------------------------------------------------------- /test/cases/emptyLinePrefixFile/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix xsd: . 2 | @prefix foaf: . 3 | @prefix eg: . 4 | 5 | eg:person a foaf:Person . 6 | eg:person foaf:age "15"^^xsd:int . 7 | eg:person foaf:name "Bart" . 8 | -------------------------------------------------------------------------------- /test/cases/emptyLinePrefixFile/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
8 |

This is made with jekyll-rdf

9 | {{content}} 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cases/emptyLinePrefixFile/_layouts/person.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/emptyLinePrefixFile/test_empty_line_prefix_file.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | require 'yaml' 3 | 4 | class TestEmptyLinePrefixFile < Test::Unit::TestCase 5 | context "cases/emptyLinePrefixFile" do 6 | should "not raise an exception on encountering an empty line in the prefix file" do 7 | @source = File.dirname(__FILE__) 8 | config = Jekyll.configuration(YAML.load_file(File.join(@source, '_config.yml')).merge!({'source' => @source, 'destination' => File.join(@source, "_site")})) 9 | assert_nothing_raised do 10 | Jekyll::Site.new(config) 11 | end 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /test/cases/extraction/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/extraction/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" 2 | url: "http://example.org/" 3 | 4 | plugins: 5 | - jekyll-rdf 6 | jekyll_rdf: 7 | path: "_data/knowledge-base.ttl" 8 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 9 | default_template: "default" 10 | 11 | -------------------------------------------------------------------------------- /test/cases/extraction/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/cases/extraction/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix eg: . 2 | 3 | eg:resource1 eg:predicate1 eg:object1 . 4 | eg:resource2 eg:predicate1 eg:object1 . 5 | eg:resource3 eg:predicate2 eg:object1 . 6 | eg:resource4 eg:predicate2 eg:object1 . 7 | -------------------------------------------------------------------------------- /test/cases/extraction/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
8 |

This is made with jekyll-rdf

9 | {{content}} 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cases/filter/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/filter/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" # the subpath of your site, e.g. /blog 2 | url: "http://example.org/" # the base hostname & protocol for your site 3 | # Build settings 4 | markdown: kramdown 5 | plugins: 6 | - jekyll-rdf 7 | jekyll_rdf: 8 | path: "_data/knowledge-base.ttl" 9 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 10 | default_template: "default" 11 | class_template_mappings: 12 | "http://xmlns.com/foaf/0.1/Person": "person" 13 | instance_template_mappings: 14 | "http://example.org/instance/resource": "exampleInstance" 15 | -------------------------------------------------------------------------------- /test/cases/filter/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX rdf: 2 | PREFIX rdfs: 3 | PREFIX eg: 4 | -------------------------------------------------------------------------------- /test/cases/filter/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix rdf: . 2 | @prefix rdfs: . 3 | @prefix eg: . 4 | 5 | eg:resource eg:predicate eg:object . 6 | 7 | eg:resource eg:prelist eg:object1 . 8 | eg:resource eg:prelist eg:object2 . 9 | eg:resource eg:prelist eg:object3 . 10 | eg:resource eg:prelist eg:object4 . 11 | 12 | eg:resource eg:literals "unknown"@en . 13 | eg:resource eg:literals "unknown 2"@en . 14 | eg:resource eg:literals "unbekannt"@de . 15 | eg:resource eg:literals "unbekannt 2"@de . 16 | 17 | eg:resource1 eg:predicate eg:object . 18 | eg:resource2 eg:predicate eg:object . 19 | 20 | eg:collection a rdf:List . 21 | eg:collection rdf:first eg:colItem1 . 22 | eg:collection rdf:rest eg:colHolder1 . 23 | eg:colHolder1 rdf:first eg:colItem2 . 24 | eg:colHolder1 rdf:rest eg:colHolder2 . 25 | eg:colHolder2 rdf:first eg:colItem3 . 26 | eg:colHolder2 rdf:rest eg:colHolder3 . 27 | eg:colHolder3 rdf:first eg:colItem4 . 28 | eg:colHolder3 rdf:rest eg:colHolder4 . 29 | eg:colHolder4 rdf:first eg:colItem5 . 30 | eg:colHolder4 rdf:rest rdf:nil . 31 | 32 | eg:colPointer eg:collect eg:collection . 33 | 34 | eg:Seq a rdf:Seq . 35 | eg:Seq rdf:_1 eg:conItem1 . 36 | eg:Seq rdf:_2 eg:conItem2 . 37 | eg:Seq rdf:_3 eg:conItem3 . 38 | eg:Seq rdf:_4 eg:conItem4 . 39 | eg:Seq rdf:_5 eg:conItem5 . 40 | 41 | eg:Container a rdfs:Container . 42 | eg:Container rdf:_1 eg:conItem1 . 43 | eg:Container rdf:_2 eg:conItem2 . 44 | eg:Container rdf:_3 eg:conItem3 . 45 | eg:Container rdf:_4 eg:conItem4 . 46 | eg:Container rdf:_5 eg:conItem5 . 47 | 48 | eg:ContainerClass rdfs:subClassOf eg:ContainmentClass . 49 | eg:ContainmentClass rdfs:subClassOf rdfs:Container . 50 | 51 | eg:CustomContainer a eg:ContainerClass . 52 | eg:CustomContainer rdf:_1 eg:conItem1 . 53 | eg:CustomContainer rdf:_2 eg:conItem2 . 54 | eg:CustomContainer rdf:_3 eg:conItem3 . 55 | eg:CustomContainer rdf:_4 eg:conItem4 . 56 | eg:CustomContainer rdf:_5 eg:conItem5 . 57 | -------------------------------------------------------------------------------- /test/cases/filter/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
8 |

This is made with jekyll-rdf

9 | {{content}} 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cases/filter/_layouts/exampleInstance.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
This page is mapped to:
7 | {{page.rdf}} 8 |
9 | -------------------------------------------------------------------------------- /test/cases/filter/_layouts/person.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/generalTest/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/generalTest/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" 2 | url: "http://example.org/" 3 | 4 | plugins: 5 | - jekyll-rdf 6 | jekyll_rdf: 7 | path: "_data/knowledge-base.ttl" 8 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 9 | default_template: "default" 10 | instance_template_mappings: 11 | "http://example.org/instance/resource": "exampleInstance" 12 | "http://example.org/instance" : "multipleResources" 13 | -------------------------------------------------------------------------------- /test/cases/generalTest/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX rdf: 2 | PREFIX rdfs: 3 | PREFIX xsd: 4 | PREFIX foaf: 5 | PREFIX eg: 6 | -------------------------------------------------------------------------------- /test/cases/generalTest/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix eg: . 2 | @prefix egh: . 3 | @prefix xsd: . 4 | @prefix foaf: . 5 | 6 | eg:resource eg:predicate eg:object . 7 | eg:person a foaf:Person . 8 | eg:person foaf:age "28"^^xsd:int . 9 | eg:person foaf:name "Jeanne Doe" . 10 | egh:resource1 eg:description "describes resource1"@en . 11 | egh:resource2 eg:description "describes resource2"@en . 12 | a foaf:Document . 13 | eg:coveredResource a foaf:Document . 14 | eg:predicate eg:object . 15 | -------------------------------------------------------------------------------- /test/cases/generalTest/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
8 |

This is made with jekyll-rdf

9 | {{page.rdf}} 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cases/generalTest/_layouts/exampleInstance.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
This page is mapped to:
7 | {{page.rdf}} 8 |
9 | -------------------------------------------------------------------------------- /test/cases/generalTest/_layouts/multipleResources.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | Sub Resources 7 | 8 | 9 | 10 | 11 |
This resource {{page.rdf}} has multiple resource
12 |
13 |
{{page.rdf}}
14 | {%- for resource in page.sub_rdf -%} 15 |
{{resource}} +++ {%- assign description = resource | rdf_property: "" -%} {{description}}

16 | {%- endfor -%} 17 |
18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /test/cases/generalTest/covered.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 9 | 10 | 11 | TODO supply a title 12 | 13 | 14 | 15 | 16 |
17 |
18 | {%- assign covered = "" | rdf_get -%} {{covered}} || {{covered.covered}} 19 |
20 | 21 |
22 | {%- assign uncovered = "" | rdf_get -%} {{uncovered}} || {{uncovered.covered}} 23 |
24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /test/cases/generalTest/prefixes.html: -------------------------------------------------------------------------------- 1 | --- 2 | rdf_prefix_path: _data/Prefixes.pref 3 | --- 4 | 5 | 6 | 11 | 12 | 13 | TODO supply a title 14 | 15 | 16 | 17 | 18 |
19 |
Prefix foaf:Person

20 | {{"foaf:Person" | rdf_get}}
21 |
Prefix rdf:type

22 | {{"rdf:type" | rdf_get}}
23 |
Prefix rdfs:Container

24 | {{"rdfs:Container" | rdf_get}} 25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /test/cases/generalTest/test_general.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestGeneral < Test::Unit::TestCase 4 | include RSpec::Matchers 5 | include RdfTestUtility 6 | context "Jekyll-Rdf" do 7 | setup do 8 | setup_jekyll File.dirname(__FILE__) 9 | end 10 | 11 | should "create a file which contains http://example.org/instance#resource1" do 12 | s = File.read(File.join(@source,"_site/index.html")) # read static file 13 | expect(s).to include 'http://example.org/instance#resource1' 14 | end 15 | 16 | should "create a file which shows descriptions as property" do 17 | s = File.read(File.join(@source,"_site/index.html")) # read static file 18 | expect(s).to include "describes resource1" 19 | end 20 | 21 | should "create a file for http://outside.org/resource" do 22 | s = File.read(File.join(@source,"_site/rdfsites/http/outside.org/resource.html")) # read static file 23 | expect(s).to include "http://outside.org/resource" 24 | assert true 25 | end 26 | 27 | should "correctly distinguish between resources supported by the knowledgebase and not supported resources" do 28 | c = File.read(File.join(@source, "_site/covered.html")) 29 | expect(c).to include "
http://example.org/instance/coveredResource || true" 30 | expect(c).to include "
http://example.org/instance/uncoveredResource || false" 31 | end 32 | 33 | should "create a page with a main resource and sub resources" do 34 | s = File.read(File.join(@source,"_site/index.html")) # read static file 35 | expect(s).to include "http://example.org/instance" 36 | expect(s).to include "http://example.org/instance#resource1" 37 | expect(s).to include "http://example.org/instance#resource2" 38 | end 39 | 40 | should "support prefixes on non RdfPages too" do 41 | file = File.read(File.join(@source, "_site/prefixes.html")) 42 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 43 | entry.strip 44 | end 45 | assert "
Prefix foaf:Person
".eql?(content[0]), "Headline should be
Prefix foaf:Person
\nIt was: #{content[0]}" 46 | assert "http://xmlns.com/foaf/0.1/Person".eql?(content[1]), "This line should be >>>http://xmlns.com/foaf/0.1/Person<<< \nIt was :#{content[1]}" 47 | assert "
Prefix rdf:type
".eql?(content[2]), "Headline should be
Prefix rdf:type
\nIt was: #{content[2]}" 48 | assert "http://www.w3.org/1999/02/22-rdf-syntax-ns#type".eql?(content[3]), "This line should be >>>http://www.w3.org/1999/02/22-rdf-syntax-ns#type<<< \nIt was :#{content[3]}" 49 | assert "
Prefix rdfs:Container
".eql?(content[4]), "Headline should be
Prefix rdf:type
\nIt was: #{content[4]}" 50 | assert "http://www.w3.org/2000/01/rdf-schema#Container".eql?(content[5]), "This line should be >>>http://www.w3.org/2000/01/rdf-schema#Container<<< \nIt was :#{content[5]}" 51 | end 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /test/cases/listExtraction/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/listExtraction/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" # the subpath of your site, e.g. /blog 2 | url: "http://example.org/" # the base hostname & protocol for your site 3 | # Build settings 4 | markdown: kramdown 5 | plugins: 6 | - jekyll-rdf 7 | jekyll_rdf: 8 | path: "_data/knowledge-base.ttl" 9 | restriction_file: "_data/restriction.txt" 10 | default_template: "default" 11 | class_template_mappings: 12 | "http://xmlns.com/foaf/0.1/Person": "person" 13 | instance_template_mappings: 14 | "http://example.org/instance/resource": "exampleInstance" 15 | -------------------------------------------------------------------------------- /test/cases/listExtraction/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX eg: 2 | -------------------------------------------------------------------------------- /test/cases/listExtraction/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix eg: . 2 | 3 | eg:resource eg:predicate eg:object . 4 | eg:listResource1 eg:predicate eg:object . 5 | eg:resource eg:listResource2 eg:object . 6 | eg:resource eg:predicate eg:listResource3 . 7 | 8 | eg:unlistResource1 eg:predicate eg:object . 9 | eg:resource eg:unlistResource2 eg:object . 10 | eg:resource eg:predicate eg:unlistResource3 . 11 | -------------------------------------------------------------------------------- /test/cases/listExtraction/_data/restriction.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /test/cases/listExtraction/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
8 |

This is made with jekyll-rdf

9 | {{content}} 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cases/listExtraction/_layouts/exampleInstance.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
This page is mapped to:
7 | {{page.rdf}} 8 |
9 | -------------------------------------------------------------------------------- /test/cases/listExtraction/_layouts/person.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/listExtraction/test_list_restriction.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestGeneral < Test::Unit::TestCase 4 | include RSpec::Matchers 5 | include RdfTestUtility 6 | context "Jekyll-Rdf" do 7 | setup do 8 | setup_jekyll File.dirname(__FILE__) 9 | end 10 | 11 | should "only render the resources given in _data/restrictions.txt" do 12 | assert File.exist?(File.join(File.dirname(__FILE__),'_site/listResource1.html')), "listResource1 was in the render list _data/restriction.txt, but wasn't rendered" 13 | assert File.exist?(File.join(File.dirname(__FILE__),'_site/listResource2.html')), "listResource2 was in the render list _data/restriction.txt, but wasn't rendered" 14 | assert File.exist?(File.join(File.dirname(__FILE__),'_site/listResource3.html')), "listResource3 was in the render list _data/restriction.txt, but wasn't rendered" 15 | assert !File.exist?(File.join(File.dirname(__FILE__),'_site/unlistResource1.html')), "unlistResource1 wasn't in the render list _data/restriction.txt, but was rendered" 16 | assert !File.exist?(File.join(File.dirname(__FILE__),'_site/unlistResource2.html')), "unlistResource2 wasn't in the render list _data/restriction.txt, but was rendered" 17 | assert !File.exist?(File.join(File.dirname(__FILE__),'_site/unlistResource3.html')), "unlistResource3 wasn't in the render list _data/restriction.txt, but was rendered" 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /test/cases/mainGenerator/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/mainGenerator/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" 2 | url: "http://example.org/" 3 | plugins: 4 | - jekyll-rdf 5 | jekyll_rdf: 6 | path: "_data/knowledge-base.ttl" 7 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 8 | default_template: "default" 9 | 10 | -------------------------------------------------------------------------------- /test/cases/mainGenerator/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix eg: . 2 | 3 | eg:resource eg:predicate eg:object . 4 | 5 | -------------------------------------------------------------------------------- /test/cases/mainGenerator/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
8 |

This is made with jekyll-rdf

9 | {{content}} 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cases/mainGenerator/test_main_generator.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestMainGenerator < Test::Unit::TestCase 4 | include RdfTestUtility 5 | context "load_config from RdfMainGenerator" do 6 | should "load baseiri if available" do 7 | setup_site_jekyll File.dirname(__FILE__) 8 | assert_equal "http://example.org/", Jekyll::JekyllRdf::Helper::RdfHelper::domainiri 9 | assert_equal "/instance", Jekyll::JekyllRdf::Helper::RdfHelper::pathiri 10 | end 11 | 12 | should "fail if template_mapping is defined in _config.yml" do 13 | TestHelper::setErrOutput 14 | @source = File.dirname(__FILE__) 15 | config = Jekyll.configuration(YAML.load_file(File.join(@source, '_config.yml')).merge!({'source' => @source, 'destination' => File.join(@source, "_site"), 'jekyll_rdf' => {'template_mapping' => ''}})) 16 | site = Jekyll::Site.new(config) 17 | site.process 18 | assert Jekyll.logger.messages.any? {|message| !!(message =~ /Outdated format in _config\.yml:\n 'template_mapping' detected but the following keys must be used now instead:\n instance_template_mappings -> maps single resources to single layouts\n class_template_mappings -> maps entire classes of resources to layouts\nJekyll-RDF wont render any pages for .*/)}, "The generate process should exit with the error message: \nOutdated format in _config.yml:\n 'template_mapping' detected but the following keys must be used now instead:\n instance_template_mappings -> maps single resources to single layouts\n class_template_mappings -> maps entire classes of resources to layouts\nJekyll-RDF wont render any pages for \*\*\*\*" 19 | TestHelper::resetErrOutput 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /test/cases/mainPrefixFile/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/mainPrefixFile/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" # the subpath of your site, e.g. /blog 2 | url: "http://example.org/" # the base hostname & protocol for your site 3 | # Build settings 4 | markdown: kramdown 5 | plugins: 6 | - jekyll-rdf 7 | jekyll_rdf: 8 | path: "_data/knowledge-base.ttl" 9 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p }" 10 | prefixes: "_data/Prefixes.pref" 11 | 12 | -------------------------------------------------------------------------------- /test/cases/mainPrefixFile/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX rdf: 2 | PREFIX rdfs: 3 | PREFIX xsd: 4 | PREFIX foaf: 5 | PREFIX eg: 6 | -------------------------------------------------------------------------------- /test/cases/mainPrefixFile/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix eg: . 2 | 3 | eg:resource eg:predicate eg:object . 4 | -------------------------------------------------------------------------------- /test/cases/mainPrefixFile/mainPrefixTest.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | Test the main prefix file 6 | 7 | 8 | 9 | 10 |
11 | {%- assign foaf = "foaf:resource" | rdf_get -%} 12 | {{ foaf }}
13 | {%- assign eg = "eg:resource" | rdf_get -%} 14 | {{ eg }}
15 | {%- assign xsd = "xsd:resource" | rdf_get -%} 16 | {{ xsd }}
17 | {%- assign rdfs = "rdfs:resource" | rdf_get -%} 18 | {{ rdfs }}
19 | {%- assign rdf = "rdf:resource" | rdf_get -%} 20 | {{ rdf }} 21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /test/cases/mainPrefixFile/test_main_prefix_file.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestMainPrefixFile < Test::Unit::TestCase 4 | include RSpec::Matchers 5 | include RdfTestUtility 6 | 7 | context "The main prefix file" do 8 | should "support prefixes on non RdfPages too" do 9 | setup_jekyll File.dirname(__FILE__) 10 | file = File.read(File.join(@source, "_site/mainPrefixTest.html")) 11 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 12 | entry.strip 13 | end 14 | assert_equal "http://xmlns.com/foaf/0.1/resource", content[0] 15 | assert_equal "http://example.org/instance/resource", content[1] 16 | assert_equal "http://www.w3.org/2001/XMLSchema#resource", content[2] 17 | assert_equal "http://www.w3.org/2000/01/rdf-schema#resource", content[3] 18 | assert_equal "http://www.w3.org/1999/02/22-rdf-syntax-ns#resource", content[4] 19 | end 20 | end 21 | 22 | end 23 | -------------------------------------------------------------------------------- /test/cases/missingConfig/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/missingConfig/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" # the subpath of your site, e.g. /blog 2 | url: "http://example.org/" # the base hostname & protocol for your site 3 | # Build settings 4 | markdown: kramdown 5 | plugins: 6 | - jekyll-rdf 7 | 8 | -------------------------------------------------------------------------------- /test/cases/missingConfig/test_missing_config.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestMainGeneratorMissingConfig < Test::Unit::TestCase 4 | include RdfTestUtility 5 | context "load_config from RdfMainGenerator" do 6 | should "fail if jekyll-rdf is included but not configured" do 7 | TestHelper::setErrOutput 8 | @source = File.dirname(__FILE__) 9 | config = Jekyll.configuration(YAML.load_file(File.join(@source, '_config.yml')).merge!({'source' => @source, 'destination' => File.join(@source, "_site")})) 10 | site = Jekyll::Site.new(config) 11 | site.process 12 | assert Jekyll.logger.messages.any? {|message| !!(message =~ /You've included Jekyll-RDF, but it is not configured. Aborting the jekyll-rdf plugin./)}, "The should exit with the error message: ''You've included Jekyll-RDF, but it is not configured. Aborting the jekyll-rdf plugin.''" 13 | TestHelper::resetErrOutput 14 | end 15 | end 16 | end -------------------------------------------------------------------------------- /test/cases/multipleWarnings/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/multipleWarnings/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" # the subpath of your site, e.g. /blog 2 | url: "http://example.org/" # the base hostname & protocol for your site 3 | # Build settings 4 | markdown: kramdown 5 | plugins: 6 | - jekyll-rdf 7 | jekyll_rdf: 8 | path: "_data/knowledge-base.ttl" 9 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 10 | default_template: "default" 11 | class_template_mappings: 12 | "http://example.org/class/group1/temp1": "layout1" 13 | "http://example.org/class/group1/temp2": "layout2" 14 | "http://example.org/class/group1/temp3": "layout3" 15 | "http://example.org/class/group1/temp4": "layout4" 16 | "http://example.org/class/group2/temp1": "layout5" 17 | "http://example.org/class/group2/temp2": "layout6" 18 | "http://example.org/class/group2/temp3": "layout7" 19 | "http://example.org/class/group2/temp4": "layout8" 20 | "http://example.org/class/group3/temp1": "layout9" 21 | "http://example.org/class/group3/temp2": "layout10" 22 | "http://example.org/class/group3/temp3": "layout11" 23 | "http://example.org/class/group3/temp4": "layout12" 24 | "http://example.org/class/group4/temp1": "layout9" 25 | "http://example.org/class/group4/temp2": "layout10" 26 | "http://example.org/class/group4/temp3": "layout11" 27 | "http://example.org/class/group4/temp4": "layout12" 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /test/cases/multipleWarnings/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX rdf: 2 | PREFIX rdfs: 3 | PREFIX xsd: 4 | PREFIX foaf: 5 | PREFIX eg: 6 | -------------------------------------------------------------------------------- /test/cases/multipleWarnings/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix rdf: . 2 | @prefix rdfs: . 3 | @prefix xsd: . 4 | @prefix foaf: . 5 | @prefix eg: . 6 | @prefix egc1: . 7 | @prefix egc2: . 8 | @prefix egc3: . 9 | @prefix egc4: . 10 | 11 | eg:main1 a egc1:main . 12 | eg:main2 a egc2:main . 13 | eg:main3 a egc3:main . 14 | eg:main4 a egc4:main . 15 | 16 | egc1:main rdfs:subClassOf egc1:temp1 , 17 | egc1:temp2 , 18 | egc1:temp3 , 19 | egc1:temp4 . 20 | 21 | egc2:main rdfs:subClassOf egc2:temp1 , 22 | egc2:temp2 , 23 | egc2:temp3 , 24 | egc2:temp4 . 25 | 26 | egc3:main rdfs:subClassOf egc3:temp1 , 27 | egc3:temp2 , 28 | egc3:temp3 , 29 | egc3:temp4 . 30 | 31 | egc4:main rdfs:subClassOf egc4:temp1 , 32 | egc4:temp2 , 33 | egc4:temp3 , 34 | egc4:temp4 . -------------------------------------------------------------------------------- /test/cases/multipleWarnings/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
8 |

This is made with jekyll-rdf

9 | {{content}} 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cases/multipleWarnings/_layouts/layout1.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/multipleWarnings/_layouts/layout10.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/multipleWarnings/_layouts/layout11.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/multipleWarnings/_layouts/layout12.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/multipleWarnings/_layouts/layout2.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/multipleWarnings/_layouts/layout3.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/multipleWarnings/_layouts/layout4.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/multipleWarnings/_layouts/layout5.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/multipleWarnings/_layouts/layout6.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/multipleWarnings/_layouts/layout7.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/multipleWarnings/_layouts/layout8.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/multipleWarnings/_layouts/layout9.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/multipleWarnings/test_multiple_warnings.rb: -------------------------------------------------------------------------------- 1 | class TestGeneral < Test::Unit::TestCase 2 | include RSpec::Matchers 3 | include RdfTestUtility 4 | context "Jekyll-Rdf template mapping" do 5 | setup do 6 | std_dummy = $stderr 7 | $stderr = StringIO.new 8 | log_level = Jekyll.logger.level 9 | Jekyll.logger.log_level = :warn 10 | setup_jekyll File.dirname(__FILE__) 11 | Jekyll.logger.log_level = log_level 12 | $stderr = std_dummy 13 | end 14 | 15 | should "send warnings only once per " do 16 | assert Jekyll.logger.messages.any? {|message| 17 | (message.include? "Warning: multiple possible templates for resources")&& 18 | (message.include? "http://example.org/instance/main4")&& 19 | (message.include? "http://example.org/instance/main3")&& 20 | (message.include? "Possible Templates:")&& 21 | (message.include? "layout9")&& 22 | (message.include? "layout10")&& 23 | (message.include? "layout11")&& 24 | (message.include? "layout12") 25 | } 26 | assert Jekyll.logger.messages.any? {|message| 27 | (message.include? "Warning: multiple possible templates for resources")&& 28 | (message.include? "http://example.org/instance/main1")&& 29 | (message.include? "Possible Templates:")&& 30 | (message.include? "layout1")&& 31 | (message.include? "layout2")&& 32 | (message.include? "layout3")&& 33 | (message.include? "layout4") 34 | } 35 | assert Jekyll.logger.messages.any? {|message| 36 | (message.include? "Warning: multiple possible templates for resources")&& 37 | (message.include? "http://example.org/instance/main2")&& 38 | (message.include? "Possible Templates:")&& 39 | (message.include? "layout5")&& 40 | (message.include? "layout6")&& 41 | (message.include? "layout7")&& 42 | (message.include? "layout8") 43 | } 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /test/cases/noElongatedPageNames/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/noElongatedPageNames/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" # the subpath of your site, e.g. /blog 2 | url: "http://example.org/" # the base hostname & protocol for your site 3 | # Build settings 4 | markdown: kramdown 5 | plugins: 6 | - jekyll-rdf 7 | jekyll_rdf: 8 | path: "_data/knowledge-base.ttl" 9 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p }" 10 | 11 | -------------------------------------------------------------------------------- /test/cases/noElongatedPageNames/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix eg: . 2 | 3 | eg:resource eg:predicate eg:object . 4 | 5 | -------------------------------------------------------------------------------- /test/cases/noElongatedPageNames/page.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | Page 6 | 7 | 8 | 9 | 10 |
11 | {% assign resource = "" | rdf_get %} 12 | {% assign url = resource.page_url %} 13 | {{ url }} 14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /test/cases/noElongatedPageNames/test_url_elongation.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestNoNameElongation < Test::Unit::TestCase 4 | include RSpec::Matchers 5 | include RdfTestUtility 6 | context "Jekyll-Rdf" do 7 | setup do 8 | setup_jekyll File.dirname(__FILE__) 9 | end 10 | 11 | should "support prefixes on non RdfPages too" do 12 | file = File.read(File.join(@source, "_site/page.html")) 13 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 14 | entry.strip 15 | end 16 | # there should be no .html attached to the url, since urls work without it 17 | assert_equal "/resource", content[0] 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /test/cases/pages/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/pages/PrefixDemo.html: -------------------------------------------------------------------------------- 1 | --- 2 | rdf_prefix_path: _data/Prefixes.pref 3 | --- 4 | 5 | 6 | 7 | Prefixes Demo 8 | 9 | 10 | 11 | 12 |
TODO write content
13 | 14 | 15 | -------------------------------------------------------------------------------- /test/cases/pages/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" 2 | url: "http://example.org/" 3 | plugins: 4 | - jekyll-rdf 5 | jekyll_rdf: 6 | path: "_data/knowledge-base.ttl" 7 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 8 | default_template: "default" 9 | class_template_mappings: 10 | "http://xmlns.com/foaf/0.1/Person" : "firstClassTemplate" 11 | "http://example.org/instance/superClass" : "secondClassTemplate" 12 | instance_template_mappings: 13 | "http://example.org/instance/instance1": "firstInstanceTemplate" 14 | "http://example.org/instance/instance2": "secondInstanceTemplate" 15 | -------------------------------------------------------------------------------- /test/cases/pages/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX foaf: 2 | PREFIX eg: 3 | -------------------------------------------------------------------------------- /test/cases/pages/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix rdf: . 2 | @prefix rdfs: . 3 | @prefix xsd: . 4 | @prefix foaf: . 5 | @prefix eg: . 6 | 7 | eg:resource eg:predicate eg:object . 8 | 9 | eg:instance1 eg:predicate eg:object . 10 | eg:instance2 eg:predicate eg:object . 11 | 12 | eg:person a foaf:Person . 13 | eg:classShow a eg:class . 14 | eg:class rdfs:subClassOf eg:superClass . 15 | 16 | eg:predicate eg:object . 17 | eg:predicate eg:object . 18 | eg:predicate eg:object . 19 | 20 | eg:predicate eg:object . 21 | eg:predicate eg:object . 22 | eg:predicate eg:object . 23 | -------------------------------------------------------------------------------- /test/cases/pages/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
Default
8 | 9 | 10 | -------------------------------------------------------------------------------- /test/cases/pages/_layouts/exampleInstance.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | --- 4 |
5 |
This page is mapped to:
6 | {{page.rdf}} 7 |
8 | -------------------------------------------------------------------------------- /test/cases/pages/_layouts/firstClassTemplate.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | First Class Template 10 | 11 | 12 | 13 | 14 |
First Class Template
15 | 16 | 17 | -------------------------------------------------------------------------------- /test/cases/pages/_layouts/firstInstanceTemplate.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | First Instance Template 6 | 7 | 8 | 9 | 10 |
First Instance Template
11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cases/pages/_layouts/person.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/pages/_layouts/secondClassTemplate.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Second Class Template 10 | 11 | 12 | 13 | 14 |
Second Class Template
15 | 16 | 17 | -------------------------------------------------------------------------------- /test/cases/pages/_layouts/secondInstanceTemplate.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | Second Instance Template 6 | 7 | 8 | 9 | 10 |
Second Instance Template
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/cases/pages/test_pages.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestPages < Test::Unit::TestCase 4 | include RdfTestUtility 5 | context "template mapper from RdfPageHelper" do 6 | setup do 7 | setup_jekyll File.dirname(__FILE__) 8 | end 9 | 10 | should "create pages with the correct instance template" do 11 | file = File.read(File.join(@source, "_site/instance1.html")) 12 | content = file[/\
(.|\s)*\<\/div>/][17..-7] 13 | assert_equal("First Instance Template", content) 14 | 15 | file = File.read(File.join(@source, "_site/instance2.html")) 16 | content = file[/\
(.|\s)*\<\/div>/][17..-7] 17 | assert_equal("Second Instance Template", content) 18 | end 19 | 20 | should "create pages with the correct class template" do 21 | file = File.read(File.join(@source, "_site/person.html")) 22 | content = file[/\
(.|\s)*\<\/div>/][17..-7] 23 | assert_equal("First Class Template", content) 24 | 25 | file = File.read(File.join(@source, "_site/classShow.html")) 26 | content = file[/\
(.|\s)*\<\/div>/][17..-7] 27 | assert_equal("Second Class Template", content) 28 | end 29 | 30 | should "create pages with the default template if no template was found" do 31 | file = File.read(File.join(@source, "_site/resource.html")) 32 | content = file[/\
(.|\s)*\<\/div>/][17..-7] 33 | assert_equal("Default", content) 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /test/cases/pagesFaultyPrefixAcess/FaultyPrefixDemo.html: -------------------------------------------------------------------------------- 1 | --- 2 | rdf_prefix_path: _data/Faulty.pref 3 | --- 4 | -------------------------------------------------------------------------------- /test/cases/pagesFaultyPrefixAcess/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/pagesFaultyPrefixAcess/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" # the subpath of your site, e.g. /blog 2 | url: "http://example.org/" # the base hostname & protocol for your site 3 | plugins: 4 | - jekyll-rdf 5 | jekyll_rdf: 6 | path: "_data/knowledge-base.ttl" 7 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 8 | 9 | -------------------------------------------------------------------------------- /test/cases/pagesFaultyPrefixAcess/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/cases/pagesFaultyPrefixAcess/test_pages_faulty_prefix_access.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestPagesFaultyPrefixAccess < Test::Unit::TestCase 4 | include RdfTestUtility 5 | context "load_prefixes form RdfPageHelper" do 6 | should "raise an error if the given prefixfile is not accessible" do 7 | TestHelper::setErrOutput 8 | notFound = false 9 | begin 10 | setup_site_jekyll File.dirname(__FILE__) 11 | rescue Errno::ENOENT 12 | notFound = true 13 | end 14 | assert notFound, "Faulty.pref should not have been found since it doesn't exist." 15 | assert Jekyll.logger.messages.any?{|message| !!(message=~ /\s*file not found: .*\s*/)}, "missing error message: file not found: ****" 16 | TestHelper::resetErrOutput 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /test/cases/pagesMissingTemplate/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/pagesMissingTemplate/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" 2 | url: "http://example.org/" 3 | plugins: 4 | - jekyll-rdf 5 | jekyll_rdf: 6 | path: "_data/knowledge-base.ttl" 7 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 8 | instance_template_mappings: 9 | "http://example.org/instance/instance1": "firstInstanceTemplate" 10 | 11 | -------------------------------------------------------------------------------- /test/cases/pagesMissingTemplate/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix eg: . 2 | 3 | eg:instance1 eg:predicate eg:object . 4 | 5 | -------------------------------------------------------------------------------- /test/cases/pagesMissingTemplate/test_missing_template.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestMissingTemplate < Test::Unit::TestCase 4 | include RdfTestUtility 5 | context "load_data from RdfPageHelper" do 6 | should "exit page generation if Jekyll did not load its mapped layout" do #We can't recreate this case with MWE 7 | TestHelper::setErrOutput 8 | setup_jekyll File.dirname(__FILE__) 9 | assert Jekyll.logger.messages.any?{|message| !!(message=~ /\s*Template .* was not loaded by Jekyll for .*\n\s*Skipping Page.\s*/)}, "missing error message: file not found: ****" 10 | TestHelper::resetErrOutput 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /test/cases/prefixes/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/prefixes/PrefixDemo.html: -------------------------------------------------------------------------------- 1 | --- 2 | rdf_prefix_path: _data/Prefixes.pref 3 | --- 4 | 5 | 6 | 7 | 8 | 9 |
10 | {%- assign res = "eg:_" | rdf_get -%} 11 | eg: {{res}}
12 | {%- assign res = "rdf:_" | rdf_get -%} 13 | rdf: {{res}}
14 | {%- assign res = "rdfs:_" | rdf_get -%} 15 | rdfs: {{res}}
16 | {%- assign res = "xsd:_" | rdf_get -%} 17 | xsd: {{res}}
18 | {%- assign res = "foaf:_" | rdf_get -%} 19 | foaf: {{res}} 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /test/cases/prefixes/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" 2 | url: "http://example.org/" 3 | 4 | plugins: 5 | - jekyll-rdf 6 | jekyll_rdf: 7 | path: "_data/knowledge-base.ttl" 8 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 9 | 10 | -------------------------------------------------------------------------------- /test/cases/prefixes/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX rdf: 2 | PREFIX rdfs: 3 | PREFIX xsd: 4 | PREFIX foaf: 5 | PREFIX eg: 6 | -------------------------------------------------------------------------------- /test/cases/prefixes/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/cases/prefixes/test_prefixes.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestPrefixes < Test::Unit::TestCase 4 | context "load_prefixes form RdfPageHelper" do 5 | include RdfTestUtility 6 | should "should map prefixes from the file given through rdf_prefix_path in target templates frontmatter" do 7 | setup_jekyll File.dirname(__FILE__) 8 | 9 | content = [] 10 | file = File.read(File.join(@source, "_site/PrefixDemo.html")) 11 | content = file[/\(.|\s)*\<\/div\>/][22..-7].strip.split("
").map do |entry| 12 | entry.strip 13 | end 14 | 15 | assert_equal "eg: http://example.org/instance/_", content[0] 16 | assert_equal "rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#_", content[1] 17 | assert_equal "rdfs: http://www.w3.org/2000/01/rdf-schema#_", content[2] 18 | assert_equal "xsd: http://www.w3.org/2001/XMLSchema#_", content[3] 19 | assert_equal "foaf: http://xmlns.com/foaf/0.1/_", content[4] 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /test/cases/prefixesInPosts/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/prefixesInPosts/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" 2 | url: "http://example.org/" 3 | 4 | plugins: 5 | - jekyll-rdf 6 | jekyll_rdf: 7 | path: "_data/knowledge-base.ttl" 8 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 9 | instance_template_mappings: 10 | "http://example.org/blog" : "post" 11 | 12 | -------------------------------------------------------------------------------- /test/cases/prefixesInPosts/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX rdf: 2 | PREFIX rdfs: 3 | PREFIX xsd: 4 | PREFIX foaf: 5 | PREFIX eg: 6 | PREFIX dc: 7 | -------------------------------------------------------------------------------- /test/cases/prefixesInPosts/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix rdf: . 2 | @prefix rdfs: . 3 | @prefix dc: . 4 | 5 | dc:title "My Jekyll RDF Blog" . 6 | -------------------------------------------------------------------------------- /test/cases/prefixesInPosts/_layouts/post.html: -------------------------------------------------------------------------------- 1 | --- 2 | rdf_prefix_path: _data/Prefixes.pref 3 | --- 4 | 5 | 6 | {% assign root = "" | rdf_get %} 7 |

{{ root | rdf_property: "dc:title" }}

8 |
9 | {{ content }} 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cases/prefixesInPosts/_posts/2019-02-12-Blogpost.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: post 3 | --- 4 | 5 | This is a Blogpost 6 | -------------------------------------------------------------------------------- /test/cases/prefixesInPosts/test_prefixes.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestPrefixes < Test::Unit::TestCase 4 | context "load_prefixes form RdfPageHelper" do 5 | include RdfTestUtility 6 | should "map prefixes from the file given through rdf_prefix_path in template frontmatter also for posts" do 7 | setup_jekyll File.dirname(__FILE__) 8 | 9 | content = [] 10 | file = File.read(File.join(@source, "_site/2019/02/12/Blogpost.html")) 11 | content = file[/\(.|\s)*\<\/body\>/][6..-6].strip.split("\n").map do |entry| 12 | entry.strip 13 | end 14 | 15 | assert_equal "

My Jekyll RDF Blog

", content[0] 16 | assert_equal "

This is a Blogpost

", content[2] 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /test/cases/prefixesInPostsWithGemTheme/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem "theme-gem", :path => '../../theme-gem' 4 | gem 'jekyll-rdf', :path => '../../../' 5 | end 6 | -------------------------------------------------------------------------------- /test/cases/prefixesInPostsWithGemTheme/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "" 2 | url: "http://example.org/" 3 | 4 | theme: theme-gem 5 | plugins: 6 | - jekyll-rdf 7 | jekyll_rdf: 8 | path: "_data/knowledge-base.ttl" 9 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 10 | default_template: "ontology" 11 | -------------------------------------------------------------------------------- /test/cases/prefixesInPostsWithGemTheme/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix rdfs: . 2 | @prefix owl: . 3 | 4 | a owl:Ontology ; 5 | rdfs:label "My Jekyll RDF Blog" . 6 | 7 | a owl:Ontology ; 8 | rdfs:label "My Jekyll RDF Blogpost" . 9 | -------------------------------------------------------------------------------- /test/cases/prefixesInPostsWithGemTheme/_posts/2019-02-12-Blogpost.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: ontology 3 | --- 4 | 5 | This is a Blogpost 6 | -------------------------------------------------------------------------------- /test/cases/prefixesInPostsWithGemTheme/blog.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: ontology 3 | --- 4 | 5 | A page 6 | -------------------------------------------------------------------------------- /test/cases/prefixesInPostsWithGemTheme/test_prefixes.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestPrefixes < Test::Unit::TestCase 4 | context "load_prefixes form RdfPageHelper" do 5 | include RdfTestUtility 6 | should "map prefixes for posts also when using a gem theme" do 7 | setup_jekyll File.dirname(__FILE__) 8 | 9 | content = [] 10 | file = File.read(File.join(@source, "_site/2019/02/12/Blogpost.html")) 11 | content = file[/\(.|\s)*\<\/body\>/][6..-6].strip.split("
").map do |entry| 12 | entry.strip 13 | end 14 | 15 | assert_equal "

My Jekyll RDF Blog

", content[0] 16 | assert_equal "

This is a Blogpost

", content[1] 17 | # this line has to be uncommented once page.rdf is set in posts 18 | #assert_equal "My Jekyll RDF Blogpost", content[2] 19 | assert_equal "My Jekyll RDF Blog", content[3] 20 | 21 | content = [] 22 | file = File.read(File.join(@source, "_site/blog.html")) 23 | content = file[/\(.|\s)*\<\/body\>/][6..-6].strip.split("
").map do |entry| 24 | entry.strip 25 | end 26 | 27 | assert_equal "

My Jekyll RDF Blog

", content[0] 28 | assert_equal "A page", content[1] 29 | assert_equal "My Jekyll RDF Blog", content[2] 30 | assert_equal "My Jekyll RDF Blog", content[3] 31 | end 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /test/cases/remoteGraphs/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/remoteGraphs/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" # the subpath of your site, e.g. /blog 2 | url: "http://remote-endpoint.org/" # the base hostname & protocol for your site 3 | # Build settings 4 | markdown: kramdown 5 | plugins: 6 | - jekyll-rdf 7 | jekyll_rdf: 8 | remote: 9 | endpoint: "http://localhost:3030/remote/query" 10 | default_graph: "http://localhost:3030/remote/data/graph1" 11 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p }" 12 | instance_template_mappings: 13 | "http://remote-endpoint.org/instance/resource": "exampleInstance" 14 | -------------------------------------------------------------------------------- /test/cases/remoteGraphs/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX rdf: 2 | PREFIX rdfs: 3 | PREFIX remote: 4 | -------------------------------------------------------------------------------- /test/cases/remoteGraphs/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix rdf: . 2 | @prefix rdfs: . 3 | @prefix remote: . 4 | 5 | remote:resource remote:predicate remote:render . 6 | remote:resource remote:predicate2 remote:queryItem0 , 7 | remote:queryItem1 , 8 | remote:queryItem2 . 9 | 10 | remote:collection a rdf:List . 11 | remote:collection rdf:first remote:colItem1 . 12 | remote:collection rdf:rest remote:colHolder1 . 13 | remote:colHolder1 rdf:first remote:colItem2 . 14 | remote:colHolder1 rdf:rest remote:colHolder2 . 15 | remote:colHolder2 rdf:first remote:colItem3 . 16 | remote:colHolder2 rdf:rest remote:colHolder3 . 17 | remote:colHolder3 rdf:first remote:colItem4 . 18 | remote:colHolder3 rdf:rest remote:colHolder4 . 19 | remote:colHolder4 rdf:first remote:colItem5 . 20 | remote:colHolder4 rdf:rest rdf:nil . 21 | 22 | remote:Container a rdfs:Container . 23 | remote:Container rdf:_1 remote:conItem1 . 24 | remote:Container rdf:_2 remote:conItem2 . 25 | remote:Container rdf:_3 remote:conItem3 . 26 | remote:Container rdf:_4 remote:conItem4 . 27 | remote:Container rdf:_5 remote:conItem5 . 28 | -------------------------------------------------------------------------------- /test/cases/remoteGraphs/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
8 |

This is made with jekyll-rdf

9 | {{content}} 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cases/remoteGraphs/_layouts/exampleInstance.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
This page is mapped to:
7 | {{page.rdf}} 8 |
9 | -------------------------------------------------------------------------------- /test/cases/remoteGraphs/remoteCollectionTest.html: -------------------------------------------------------------------------------- 1 | --- 2 | rdf_prefix_path: _data/Prefixes.pref 3 | --- 4 | 5 | 6 | 7 | Remote Collection Test 8 | 9 | 10 | 11 | 12 |
13 | {%- assign contain = "remote:collection" | rdf_collection -%} 14 | {%- for item in contain -%} 15 | {{ item }}
16 | {%- endfor -%} 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /test/cases/remoteGraphs/remoteContainerTest.html: -------------------------------------------------------------------------------- 1 | --- 2 | rdf_prefix_path: _data/Prefixes.pref 3 | --- 4 | 5 | 6 | 7 | Remote Container Test 8 | 9 | 10 | 11 | 12 |
13 | {%- assign contain = "remote:Container" | rdf_container -%} 14 | {%- for item in contain -%} 15 | {{ item }}
16 | {%- endfor -%} 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /test/cases/remoteGraphs/remoteMainTest.html: -------------------------------------------------------------------------------- 1 | --- 2 | rdf_prefix_path: _data/Prefixes.pref 3 | --- 4 | 5 | 6 | 7 | Remote SPARQL Endpoint Test 8 | 9 | 10 | 11 | 12 |
13 | {%- assign resource = "remote:resource" | rdf_get -%} 14 | {{resource}}
15 | {%- assign result = resource | rdf_property: "remote:predicate" -%} 16 | {{result}} 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /test/cases/remoteGraphs/remoteQueryTest.html: -------------------------------------------------------------------------------- 1 | --- 2 | rdf_prefix_path: _data/Prefixes.pref 3 | --- 4 | 5 | 6 | 7 | Remote Query Test 8 | 9 | 10 | 11 | 12 |
13 | {%- assign results = "SELECT ?o WHERE { remote:resource remote:predicate2 ?o }" | sparql_query -%} 14 | {%- for item in results -%} 15 | {{ item.o }}
16 | {%- endfor -%} 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /test/cases/remoteGraphs/test_remote.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | require 'rest_client' 3 | require 'uri' 4 | 5 | class TestGeneral < Test::Unit::TestCase 6 | include RSpec::Matchers 7 | include RdfTestUtility 8 | graph_param = URI::encode_www_form("graph" => "http://localhost:3030/remote/data/graph1") 9 | RestClient.put("http://localhost:3030/remote/?" + graph_param, File.read(File.join(File.dirname(__FILE__), "_data/knowledge-base.ttl")), :content_type => "text/turtle;charset=utf-8") 10 | context "A remote sparql endpoint on a specified default graph" do 11 | should "keep rdf_get and rdf_property usable" do 12 | setup_jekyll File.dirname(__FILE__) 13 | file = File.read(File.join(@source, "_site/remoteMainTest.html")) 14 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 15 | entry.strip 16 | end 17 | 18 | assert_equal "http://remote-endpoint.org/instance/resource", content[0] 19 | assert_equal "http://remote-endpoint.org/instance/render", content[1] 20 | end 21 | 22 | should "keep rdf_container usable" do 23 | setup_jekyll File.dirname(__FILE__) 24 | file = File.read(File.join(@source, "_site/remoteContainerTest.html")) 25 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 26 | entry.strip 27 | end 28 | 29 | assert_equal "http://remote-endpoint.org/instance/conItem1", content[0] 30 | assert_equal "http://remote-endpoint.org/instance/conItem2", content[1] 31 | assert_equal "http://remote-endpoint.org/instance/conItem3", content[2] 32 | assert_equal "http://remote-endpoint.org/instance/conItem4", content[3] 33 | assert_equal "http://remote-endpoint.org/instance/conItem5", content[4] 34 | end 35 | 36 | should "keep rdf_collection usable" do 37 | setup_jekyll File.dirname(__FILE__) 38 | file = File.read(File.join(@source, "_site/remoteCollectionTest.html")) 39 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 40 | entry.strip 41 | end 42 | 43 | assert_equal "http://remote-endpoint.org/instance/colItem1", content[0] 44 | assert_equal "http://remote-endpoint.org/instance/colItem2", content[1] 45 | assert_equal "http://remote-endpoint.org/instance/colItem3", content[2] 46 | assert_equal "http://remote-endpoint.org/instance/colItem4", content[3] 47 | assert_equal "http://remote-endpoint.org/instance/colItem5", content[4] 48 | end 49 | 50 | should "keep sparql_query usable" do 51 | setup_jekyll File.dirname(__FILE__) 52 | file = File.read(File.join(@source, "_site/remoteQueryTest.html")) 53 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 54 | entry.strip 55 | end 56 | 57 | assert(content.any? {|resource| resource.to_s.eql? "http://remote-endpoint.org/instance/queryItem0"}, "answerset does not contain 'http://remote-endpoint.org/instance/queryItem0'") 58 | assert(content.any? {|resource| resource.to_s.eql? "http://remote-endpoint.org/instance/queryItem1"}, "answerset does not contain 'http://remote-endpoint.org/instance/queryItem1'") 59 | assert(content.any? {|resource| resource.to_s.eql? "http://remote-endpoint.org/instance/queryItem2"}, "answerset does not contain 'http://remote-endpoint.org/instance/queryItem2'") 60 | end 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /test/cases/remoteSPARQL/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/remoteSPARQL/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" # the subpath of your site, e.g. /blog 2 | url: "http://remote-endpoint.org/" # the base hostname & protocol for your site 3 | # Build settings 4 | markdown: kramdown 5 | plugins: 6 | - jekyll-rdf 7 | jekyll_rdf: 8 | remote: 9 | endpoint: "http://localhost:3030/remote/query" 10 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p }" 11 | instance_template_mappings: 12 | "http://remote-endpoint.org/instance/resource": "exampleInstance" 13 | -------------------------------------------------------------------------------- /test/cases/remoteSPARQL/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX rdf: 2 | PREFIX rdfs: 3 | PREFIX remote: 4 | -------------------------------------------------------------------------------- /test/cases/remoteSPARQL/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix rdf: . 2 | @prefix rdfs: . 3 | @prefix remote: . 4 | 5 | remote:resource remote:predicate remote:render . 6 | remote:resource remote:predicate2 remote:queryItem0 , 7 | remote:queryItem1 , 8 | remote:queryItem2 . 9 | 10 | remote:collection a rdf:List . 11 | remote:collection rdf:first remote:colItem1 . 12 | remote:collection rdf:rest remote:colHolder1 . 13 | remote:colHolder1 rdf:first remote:colItem2 . 14 | remote:colHolder1 rdf:rest remote:colHolder2 . 15 | remote:colHolder2 rdf:first remote:colItem3 . 16 | remote:colHolder2 rdf:rest remote:colHolder3 . 17 | remote:colHolder3 rdf:first remote:colItem4 . 18 | remote:colHolder3 rdf:rest remote:colHolder4 . 19 | remote:colHolder4 rdf:first remote:colItem5 . 20 | remote:colHolder4 rdf:rest rdf:nil . 21 | 22 | remote:Container a rdfs:Container . 23 | remote:Container rdf:_1 remote:conItem1 . 24 | remote:Container rdf:_2 remote:conItem2 . 25 | remote:Container rdf:_3 remote:conItem3 . 26 | remote:Container rdf:_4 remote:conItem4 . 27 | remote:Container rdf:_5 remote:conItem5 . 28 | -------------------------------------------------------------------------------- /test/cases/remoteSPARQL/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
8 |

This is made with jekyll-rdf

9 | {{content}} 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cases/remoteSPARQL/_layouts/exampleInstance.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
This page is mapped to:
7 | {{page.rdf}} 8 |
9 | -------------------------------------------------------------------------------- /test/cases/remoteSPARQL/remoteCollectionTest.html: -------------------------------------------------------------------------------- 1 | --- 2 | rdf_prefix_path: _data/Prefixes.pref 3 | --- 4 | 5 | 6 | 7 | Remote Collection Test 8 | 9 | 10 | 11 | 12 |
13 | {%- assign contain = "remote:collection" | rdf_collection -%} 14 | {%- for item in contain -%} 15 | {{ item }}
16 | {%- endfor -%} 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /test/cases/remoteSPARQL/remoteContainerTest.html: -------------------------------------------------------------------------------- 1 | --- 2 | rdf_prefix_path: _data/Prefixes.pref 3 | --- 4 | 5 | 6 | 7 | Remote Container Test 8 | 9 | 10 | 11 | 12 |
13 | {%- assign contain = "remote:Container" | rdf_container -%} 14 | {%- for item in contain -%} 15 | {{ item }}
16 | {%- endfor -%} 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /test/cases/remoteSPARQL/remoteMainTest.html: -------------------------------------------------------------------------------- 1 | --- 2 | rdf_prefix_path: _data/Prefixes.pref 3 | --- 4 | 5 | 6 | 7 | Remote SPARQL Endpoint Test 8 | 9 | 10 | 11 | 12 |
13 | {%- assign resource = "remote:resource" | rdf_get -%} 14 | {{resource}}
15 | {%- assign result = resource | rdf_property: "remote:predicate" -%} 16 | {{result}} 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /test/cases/remoteSPARQL/remoteQueryTest.html: -------------------------------------------------------------------------------- 1 | --- 2 | rdf_prefix_path: _data/Prefixes.pref 3 | --- 4 | 5 | 6 | 7 | Remote Query Test 8 | 9 | 10 | 11 | 12 |
13 | {%- assign results = "SELECT ?o WHERE { remote:resource remote:predicate2 ?o }" | sparql_query -%} 14 | {%- for item in results -%} 15 | {{ item.o }}
16 | {%- endfor -%} 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /test/cases/remoteSPARQL/test_remote.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | require 'rest_client' 3 | 4 | class TestGeneral < Test::Unit::TestCase 5 | include RSpec::Matchers 6 | include RdfTestUtility 7 | RestClient.put("http://localhost:3030/remote/?default", File.read(File.join(File.dirname(__FILE__), "_data/knowledge-base.ttl")), :content_type => "text/turtle;charset=utf-8") 8 | context "A remote sparql endpoint" do 9 | should "keep rdf_get and rdf_property usable" do 10 | setup_jekyll File.dirname(__FILE__) 11 | file = File.read(File.join(@source, "_site/remoteMainTest.html")) 12 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 13 | entry.strip 14 | end 15 | 16 | assert_equal "http://remote-endpoint.org/instance/resource", content[0] 17 | assert_equal "http://remote-endpoint.org/instance/render", content[1] 18 | end 19 | 20 | should "keep rdf_container usable" do 21 | setup_jekyll File.dirname(__FILE__) 22 | file = File.read(File.join(@source, "_site/remoteContainerTest.html")) 23 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 24 | entry.strip 25 | end 26 | 27 | assert_equal "http://remote-endpoint.org/instance/conItem1", content[0] 28 | assert_equal "http://remote-endpoint.org/instance/conItem2", content[1] 29 | assert_equal "http://remote-endpoint.org/instance/conItem3", content[2] 30 | assert_equal "http://remote-endpoint.org/instance/conItem4", content[3] 31 | assert_equal "http://remote-endpoint.org/instance/conItem5", content[4] 32 | end 33 | 34 | should "keep rdf_collection usable" do 35 | setup_jekyll File.dirname(__FILE__) 36 | file = File.read(File.join(@source, "_site/remoteCollectionTest.html")) 37 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 38 | entry.strip 39 | end 40 | 41 | assert_equal "http://remote-endpoint.org/instance/colItem1", content[0] 42 | assert_equal "http://remote-endpoint.org/instance/colItem2", content[1] 43 | assert_equal "http://remote-endpoint.org/instance/colItem3", content[2] 44 | assert_equal "http://remote-endpoint.org/instance/colItem4", content[3] 45 | assert_equal "http://remote-endpoint.org/instance/colItem5", content[4] 46 | end 47 | 48 | should "keep sparql_query usable" do 49 | setup_jekyll File.dirname(__FILE__) 50 | file = File.read(File.join(@source, "_site/remoteQueryTest.html")) 51 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 52 | entry.strip 53 | end 54 | 55 | assert(content.any? {|resource| resource.to_s.eql? "http://remote-endpoint.org/instance/queryItem0"}, "answerset does not contain 'http://remote-endpoint.org/instance/queryItem0'") 56 | assert(content.any? {|resource| resource.to_s.eql? "http://remote-endpoint.org/instance/queryItem1"}, "answerset does not contain 'http://remote-endpoint.org/instance/queryItem1'") 57 | assert(content.any? {|resource| resource.to_s.eql? "http://remote-endpoint.org/instance/queryItem2"}, "answerset does not contain 'http://remote-endpoint.org/instance/queryItem2'") 58 | end 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /test/cases/renderedAttribute/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/renderedAttribute/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" # the subpath of your site, e.g. /blog 2 | url: "http://example.org/" # the base hostname & protocol for your site 3 | # Build settings 4 | markdown: kramdown 5 | plugins: 6 | - jekyll-rdf 7 | jekyll_rdf: 8 | path: "_data/knowledge-base.ttl" 9 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p }" 10 | default_template: "default" 11 | 12 | -------------------------------------------------------------------------------- /test/cases/renderedAttribute/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX eg: 2 | PREFIX egs: 3 | -------------------------------------------------------------------------------- /test/cases/renderedAttribute/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix eg: . 2 | @prefix egs: . 3 | 4 | eg:resource1 eg:predicate eg:rendered . 5 | eg:resource2 eg:predicate eg:rendered . 6 | eg:resource3 eg:predicate eg:rendered . 7 | 8 | eg:resource4 eg:predicate eg:notRendered . 9 | eg:resource5 eg:predicate eg:notRendered . 10 | eg:resource6 eg:predicate eg:notRendered . 11 | 12 | egs:resource7 eg:predicate eg:rendered . 13 | egs:resource8 eg:predicate eg:notRendered . 14 | -------------------------------------------------------------------------------- /test/cases/renderedAttribute/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
8 |

This is made with jekyll-rdf

9 | {{page.rdf}} 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cases/renderedAttribute/rendered.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | TODO supply a title 7 | 8 | 9 | 10 | 11 |
12 | {%- assign resource1 = "" | rdf_get -%} 13 | {%- assign resource2 = "" | rdf_get -%} 14 | {%- assign resource3 = "" | rdf_get -%} 15 | {%- assign resource4 = "" | rdf_get -%} 16 | {%- assign resource5 = "" | rdf_get -%} 17 | {%- assign resource6 = "" | rdf_get -%} 18 | {%- assign resource7 = "" | rdf_get -%} 19 | {%- assign resource8 = "" | rdf_get -%} 20 | {%- if resource1.rendered? -%} 21 | true 22 | {%- else -%} 23 | false 24 | {%- endif -%} 25 |
26 | {%- if resource2.rendered? -%} 27 | true 28 | {%- else -%} 29 | false 30 | {%- endif -%} 31 |
32 | {%- if resource3.rendered? -%} 33 | true 34 | {%- else -%} 35 | false 36 | {%- endif -%} 37 |
38 | {%- if resource4.rendered? -%} 39 | true 40 | {%- else -%} 41 | false 42 | {%- endif -%} 43 |
44 | {%- if resource5.rendered? -%} 45 | true 46 | {%- else -%} 47 | false 48 | {%- endif -%} 49 |
50 | {%- if resource6.rendered? -%} 51 | true 52 | {%- else -%} 53 | false 54 | {%- endif -%} 55 |
56 | {%- if resource7.rendered? -%} 57 | true 58 | {%- else -%} 59 | false 60 | {%- endif -%} 61 |
62 | {%- if resource8.rendered? -%} 63 | true 64 | {%- else -%} 65 | false 66 | {%- endif -%} 67 |
68 | 69 | 70 | -------------------------------------------------------------------------------- /test/cases/renderedAttribute/test_rendered_attribute.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestRenderedAttribute < Test::Unit::TestCase 4 | include RdfTestUtility 5 | context "cases/renderedAttribute" do 6 | setup do 7 | setup_jekyll File.dirname(__FILE__) 8 | end 9 | 10 | should "" do 11 | content = [] 12 | file = File.read(File.join(@source, "_site/rendered.html")) 13 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 14 | entry.strip 15 | end 16 | assert "true".eql?(content[0]), "Resource 1 should be true, but it is #{content[0]}" 17 | assert "true".eql?(content[1]), "Resource 2 should be true, but it is #{content[1]}" 18 | assert "true".eql?(content[2]), "Resource 3 should be true, but it is #{content[2]}" 19 | assert "false".eql?(content[3]), "Resource 4 should be false, but it is #{content[3]}" 20 | assert "false".eql?(content[4]), "Resource 5 should be false, but it is #{content[4]}" 21 | assert "false".eql?(content[5]), "Resource 6 should be false, but it is #{content[5]}" 22 | assert "true".eql?(content[6]), "Resource 7 should be false, but it is #{content[6]}" 23 | assert "false".eql?(content[7]), "Resource 8 should be false, but it is #{content[7]}" 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /test/cases/resetSite/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/resetSite/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" # the subpath of your site, e.g. /blog 2 | url: "http://example.org/" # the base hostname & protocol for your site 3 | # Build settings 4 | markdown: kramdown 5 | plugins: 6 | - jekyll-rdf 7 | jekyll_rdf: 8 | path: "_data/knowledge-base.ttl" 9 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 10 | default_template: "default-resource" 11 | 12 | -------------------------------------------------------------------------------- /test/cases/resetSite/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX eg: 2 | 3 | -------------------------------------------------------------------------------- /test/cases/resetSite/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix eg: . 2 | 3 | eg:resource1 eg:predicate eg:object . 4 | eg:resource2 eg:predicate eg:object . 5 | 6 | -------------------------------------------------------------------------------- /test/cases/resetSite/_layouts/default-resource.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | --- 4 |
This is a resource

5 | {{ page.rdf }} 6 | 7 | -------------------------------------------------------------------------------- /test/cases/resetSite/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
8 |

This is made with jekyll-rdf


9 | {{content}} 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cases/resetSite/_layouts/exampleInstance.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
This page is mapped to:
7 | {{page.rdf}} 8 |
9 | -------------------------------------------------------------------------------- /test/cases/resetSite/_layouts/person.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/resetSite/reset-page.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | --- 4 | 5 |
This is a page

6 | Test-Page 7 | -------------------------------------------------------------------------------- /test/cases/resetSite/test_reset.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestGeneral < Test::Unit::TestCase 4 | include RSpec::Matchers 5 | include RdfTestUtility 6 | context "Jekyll-Rdf after reinitialization" do 7 | setup do 8 | setup_site_jekyll File.dirname(__FILE__) 9 | end 10 | 11 | should "render content completly" do 12 | file = File.read(File.join(@source, "_site/reset-page.html")) 13 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 14 | entry.strip 15 | end 16 | assert_equal "

This is made with jekyll-rdf

", content[0] 17 | assert_equal "
This is a page
", content[1] 18 | assert_equal "Test-Page", content[2] 19 | file = File.read(File.join(@source, "_site/resource1.html")) 20 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 21 | entry.strip 22 | end 23 | assert_equal "

This is made with jekyll-rdf

", content[0] 24 | assert_equal "
This is a resource
", content[1] 25 | assert_equal "http://example.org/instance/resource1", content[2] 26 | file = File.read(File.join(@source, "_site/resource2.html")) 27 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 28 | entry.strip 29 | end 30 | assert_equal "

This is made with jekyll-rdf

", content[0] 31 | assert_equal "
This is a resource
", content[1] 32 | assert_equal "http://example.org/instance/resource2", content[2] 33 | # Jekyll::JekyllRdf::Helper::RdfHelper.reinitialize 34 | @site.process 35 | file = File.read(File.join(@source, "_site/reset-page.html")) 36 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 37 | entry.strip 38 | end 39 | assert File.exist?(File.join(@source, "_site/resource1.html")), "resource1.html was in the render list but wasn't rendered after reset" 40 | assert_equal "

This is made with jekyll-rdf

", content[0] 41 | assert_equal "
This is a page
", content[1] 42 | assert_equal "Test-Page", content[2] 43 | file = File.read(File.join(@source, "_site/resource1.html")) 44 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 45 | entry.strip 46 | end 47 | assert_equal "

This is made with jekyll-rdf

", content[0] 48 | assert_equal "
This is a resource
", content[1] 49 | assert_equal "http://example.org/instance/resource1", content[2] 50 | file = File.read(File.join(@source, "_site/resource2.html")) 51 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 52 | entry.strip 53 | end 54 | assert_equal "

This is made with jekyll-rdf

", content[0] 55 | assert_equal "
This is a resource
", content[1] 56 | assert_equal "http://example.org/instance/resource2", content[2] 57 | end 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /test/cases/restrictions/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/restrictions/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" # the subpath of your site, e.g. /blog 2 | url: "http://example.org/" # the base hostname & protocol for your site 3 | # Build settings 4 | markdown: kramdown 5 | plugins: 6 | - jekyll-rdf 7 | jekyll_rdf: 8 | path: "_data/knowledge-base.ttl" 9 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p }" 10 | default_template: "default" 11 | 12 | -------------------------------------------------------------------------------- /test/cases/restrictions/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX rdf: 2 | PREFIX rdfs: 3 | PREFIX xsd: 4 | PREFIX foaf: 5 | PREFIX eg: 6 | -------------------------------------------------------------------------------- /test/cases/restrictions/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix eg: . 2 | 3 | eg:resource1 eg:predicate eg:object1 . 4 | eg:resource2 eg:predicate eg:object2 . 5 | 6 | -------------------------------------------------------------------------------- /test/cases/restrictions/_data/restriction-file.rf: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /test/cases/restrictions/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
8 | {{ page.rdf }} 9 |
10 | 11 | 12 | -------------------------------------------------------------------------------- /test/cases/restrictions/test_restriction.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestRestriction < Test::Unit::TestCase 4 | include RSpec::Matchers 5 | include RdfTestUtility 6 | context "Jekyll-Rdf restriction model" do 7 | should "render all resources from the restriction query" do 8 | @source = File.dirname(__FILE__) 9 | config = Jekyll.configuration(YAML.load_file(File.join(@source, '_config.yml')).merge!({'source' => @source, 'destination' => File.join(@source, "_site")})) 10 | site = Jekyll::Site.new(config) 11 | Jekyll::JekyllRdf::Helper::RdfHelper.reinitialize 12 | site.process 13 | 14 | file = File.read(File.join(@source, "_site/resource1.html")) 15 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 16 | entry.strip 17 | end 18 | assert_equal "http://example.org/instance/resource1", content[0] 19 | assert_equal 2, Dir[File.join(@source, '_site/**/*')].length 20 | end 21 | 22 | should "render all resources from the restriction file" do 23 | @source = File.dirname(__FILE__) 24 | config = Jekyll.configuration(YAML.load_file(File.join(@source, '_config.yml')).merge!({'source' => @source, 'destination' => File.join(@source, "_site")})) 25 | config["jekyll_rdf"].delete("restriction") 26 | config["jekyll_rdf"]["restriction_file"] = "_data/restriction-file.rf" 27 | site = Jekyll::Site.new(config) 28 | Jekyll::JekyllRdf::Helper::RdfHelper.reinitialize 29 | site.process 30 | 31 | file = File.read(File.join(@source, "_site/resource2.html")) 32 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 33 | entry.strip 34 | end 35 | assert_equal "http://example.org/instance/resource2", content[0] 36 | assert_equal 2, Dir[File.join(@source, '_site/**/*')].length 37 | end 38 | 39 | should "render all resources if neither a restriction file nor a restriction query is given" do 40 | @source = File.dirname(__FILE__) 41 | config = Jekyll.configuration(YAML.load_file(File.join(@source, '_config.yml')).merge!({'source' => @source, 'destination' => File.join(@source, "_site")})) 42 | config["jekyll_rdf"].delete("restriction") 43 | site = Jekyll::Site.new(config) 44 | Jekyll::JekyllRdf::Helper::RdfHelper.reinitialize 45 | site.process 46 | 47 | file = File.read(File.join(@source, "_site/resource1.html")) 48 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 49 | entry.strip 50 | end 51 | assert_equal "http://example.org/instance/resource1", content[0] 52 | 53 | file = File.read(File.join(@source, "_site/resource2.html")) 54 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 55 | entry.strip 56 | end 57 | assert_equal "http://example.org/instance/resource2", content[0] 58 | assert_equal 6, Dir[File.join(@source, '_site/**/*')].length 59 | end 60 | 61 | should "render no resources if the restriction query returns no resources" do 62 | @source = File.dirname(__FILE__) 63 | config = Jekyll.configuration(YAML.load_file(File.join(@source, '_config.yml')).merge!({'source' => @source, 'destination' => File.join(@source, "_site")})) 64 | config["jekyll_rdf"]["restriction"] = "SELECT ?resourceUri WHERE {?resourceUri ?p }" 65 | site = Jekyll::Site.new(config) 66 | Jekyll::JekyllRdf::Helper::RdfHelper.reinitialize 67 | site.process 68 | 69 | assert_equal 1, Dir[File.join(@source, '_site/**/*')].length 70 | end 71 | end 72 | end 73 | -------------------------------------------------------------------------------- /test/cases/sciMath/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/sciMath/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" 2 | url: "http://example.org/" 3 | plugins: 4 | - jekyll-rdf 5 | jekyll_rdf: 6 | path: "_data/knowledge-base.ttl" 7 | restriction: 'SELECT ?resourceUri WHERE {?resourceUri ?p ?o . FILTER( ?resourceUri != )}' 8 | instance_template_mappings: 9 | "http://example.org/instance/math": "math_filters.html" 10 | -------------------------------------------------------------------------------- /test/cases/sciMath/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix xsd: . 2 | @prefix eg: . 3 | 4 | eg:math eg:mInteger "7"^^xsd:integer . 5 | eg:math eg:mFloat "8.9"^^xsd:decimal . 6 | eg:math eg:mDouble "4.2E9"^^xsd:double . 7 | eg:math eg:mDoubleNE "2.0E-2"^^xsd:double . 8 | eg:math eg:nInteger "-7"^^xsd:integer . 9 | eg:math eg:nFloat "-8.9"^^xsd:decimal . 10 | eg:math eg:nDouble "-4.2E9"^^xsd:double . 11 | eg:math eg:nDoubleNE "-2.0E-2"^^xsd:double . 12 | 13 | eg:math "10"^^xsd:int . 14 | eg:math "7.25"^^xsd:float . 15 | eg:math "-3"^^xsd:int . 16 | 17 | eg:date "12:45"^^xsd:time . 18 | eg:date "2018-06-12"^^xsd:date . 19 | eg:date "2018-06-12T12:42+02:00"^^xsd:dateTime . 20 | eg:date "2018-06-12T12:42Z"^^xsd:dateTime . 21 | eg:date "2018-06-12T12:42:55+02:00"^^xsd:dateTime . 22 | 23 | -------------------------------------------------------------------------------- /test/cases/sciMath/math_filters.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | This tests math filters 7 | 8 | 9 | 10 | 11 |
12 | {%- assign number = "" | rdf_get | rdf_property: "" -%} 13 | {%- assign fnumber = "" | rdf_get | rdf_property: "" -%} 14 | {%- assign nnumber = "" | rdf_get | rdf_property: "" -%} 15 | {%- assign time = "" | rdf_get | rdf_property: "" -%} 16 | {%- assign date = "" | rdf_get | rdf_property: "" -%} 17 | {%- assign dateTime = "" | rdf_get | rdf_property: "" -%} 18 | {%- assign datetimeZ = "" | rdf_get | rdf_property: "" -%} 19 | {%- assign datetimeSec = "" | rdf_get | rdf_property: "" -%} 20 | {{ number | plus: 5 }}
21 | {{ number | minus: 5 }}
22 | {{ number | times: 5 }}
23 | {{ number | divided_by: 3 }}
24 | {{ number | modulo: 5 }}
25 | {{ number | modulo: 3 }}
26 | {{ fnumber | round }}
27 | {{ fnumber | ceil }}
28 | {{ fnumber | floor }}
29 | {{ number | at_most: 5 }}
30 | {{ number | at_most: 12 }}
31 | {{ number | at_least: 12 }}
32 | {{ number | at_least: 8 }}
33 | {{ nnumber | abs }}
34 | {{ time | date: "%H" }}
35 | {{ time | date: "%M" }}
36 | {{ date | date: "%Y" }}
37 | {{ date | date: "%m" }}
38 | {{ dateTime | date: "%Y" }}
39 | {{ dateTime | date: "%m" }}
40 | {{ dateTime | date: "%H" }}
41 | {{ datetimeZ | date: "%Y" }}
42 | {{ datetimeZ | date: "%H" }}
43 | {{ datetimeZ | date: "%M" }}
44 | {{ datetimeSec | date: "%Y" }}
45 | {{ datetimeSec | date: "%H" }}
46 | {{ datetimeSec | date: "%M" }} 47 |
48 | 49 | 50 | -------------------------------------------------------------------------------- /test/cases/shortcutCollections/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/shortcutCollections/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" # the subpath of your site, e.g. /blog 2 | url: "http://example.org/" # the base hostname & protocol for your site 3 | # Build settings 4 | markdown: kramdown 5 | plugins: 6 | - jekyll-rdf 7 | jekyll_rdf: 8 | path: "_data/knowledge-base.ttl" 9 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p }" #no resources required 10 | -------------------------------------------------------------------------------- /test/cases/shortcutCollections/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX rdf: 2 | PREFIX rdfs: 3 | PREFIX eg: 4 | -------------------------------------------------------------------------------- /test/cases/shortcutCollections/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix rdf: . 2 | @prefix rdfs: . 3 | @prefix eg: . 4 | 5 | eg:colPointer eg:collect eg:collection . 6 | eg:collection a rdf:List . 7 | eg:collection rdf:first eg:colItem1 . 8 | eg:collection rdf:rest eg:colHolder1 . 9 | eg:colHolder1 rdf:first eg:colItem2 . 10 | eg:colHolder1 rdf:rest eg:colHolder2 . 11 | eg:colHolder2 rdf:first eg:colItem3 . 12 | eg:colHolder2 rdf:rest eg:colHolder3 . 13 | eg:colHolder3 rdf:first eg:colItem4 . 14 | eg:colHolder3 rdf:rest eg:colHolder4 . 15 | eg:colHolder4 rdf:first eg:colItem5 . 16 | eg:colHolder4 rdf:rest rdf:nil . 17 | -------------------------------------------------------------------------------- /test/cases/shortcutCollections/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
8 |

This is made with jekyll-rdf

9 | {{content}} 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cases/shortcutCollections/_layouts/exampleInstance.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
This page is mapped to:
7 | {{page.rdf}} 8 |
9 | -------------------------------------------------------------------------------- /test/cases/shortcutCollections/_layouts/person.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/shortcutCollections/collections.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | Collections shortcut test 6 | 7 | 8 | 9 | 10 | {% assign result = "" | rdf_collection: "" %} 11 |
12 | {%- for item in result -%} 13 | {{item}}
14 | {%- endfor -%} 15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /test/cases/shortcutCollections/test_shortcut_collections.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestShortcutCollections < Test::Unit::TestCase 4 | include RdfTestUtility 5 | context "rdf_collection" do 6 | should "accept a resource predicate tupel as pointer (shortcut) to a collection" do 7 | setup_site_jekyll File.dirname(__FILE__) 8 | file = File.read(File.join(@source, "_site/collections.html")) 9 | answer = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 10 | entry.strip 11 | end 12 | assert(answer.any? {|resource| resource.to_s.eql? "http://example.org/instance/colItem1"}, "answerset does not contain 'http://example.org/instance/colItem1'") 13 | assert(answer.any? {|resource| resource.to_s.eql? "http://example.org/instance/colItem2"}, "answerset does not contain 'http://example.org/instance/colItem2'") 14 | assert(answer.any? {|resource| resource.to_s.eql? "http://example.org/instance/colItem3"}, "answerset does not contain 'http://example.org/instance/colItem3'") 15 | assert(answer.any? {|resource| resource.to_s.eql? "http://example.org/instance/colItem4"}, "answerset does not contain 'http://example.org/instance/colItem4'") 16 | assert(answer.any? {|resource| resource.to_s.eql? "http://example.org/instance/colItem5"}, "answerset does not contain 'http://example.org/instance/colItem5'") 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /test/cases/shortcutContainers/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/shortcutContainers/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" # the subpath of your site, e.g. /blog 2 | url: "http://example.org/" # the base hostname & protocol for your site 3 | # Build settings 4 | markdown: kramdown 5 | plugins: 6 | - jekyll-rdf 7 | jekyll_rdf: 8 | path: "_data/knowledge-base.ttl" 9 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p }" #no resources required 10 | -------------------------------------------------------------------------------- /test/cases/shortcutContainers/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX rdf: 2 | PREFIX rdfs: 3 | PREFIX eg: 4 | -------------------------------------------------------------------------------- /test/cases/shortcutContainers/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix rdf: . 2 | @prefix rdfs: . 3 | @prefix eg: . 4 | 5 | eg:conPointer eg:contain eg:Container . 6 | eg:Container a rdfs:Container . 7 | eg:Container rdf:_1 eg:conItem1 . 8 | eg:Container rdf:_2 eg:conItem2 . 9 | eg:Container rdf:_3 eg:conItem3 . 10 | eg:Container rdf:_4 eg:conItem4 . 11 | eg:Container rdf:_5 eg:conItem5 . 12 | -------------------------------------------------------------------------------- /test/cases/shortcutContainers/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
8 |

This is made with jekyll-rdf

9 | {{content}} 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cases/shortcutContainers/_layouts/exampleInstance.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
This page is mapped to:
7 | {{page.rdf}} 8 |
9 | -------------------------------------------------------------------------------- /test/cases/shortcutContainers/_layouts/person.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | rdf_prefix_path: _data/Prefixes.pref 4 | --- 5 |
6 |
7 | name: 8 |
9 | {{page.rdf | rdf_property: "foaf:name"}} 10 |
11 |
12 | age: 13 |
14 | {{page.rdf | rdf_property: "foaf:age"}} 15 |
16 | -------------------------------------------------------------------------------- /test/cases/shortcutContainers/container.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | Collections shortcut test 6 | 7 | 8 | 9 | 10 | {% assign result = "" | rdf_container: "" %} 11 |
12 | {%- for item in result -%} 13 | {{item}}
14 | {%- endfor -%} 15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /test/cases/shortcutContainers/test_shortcut_container.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestShortcutContainer < Test::Unit::TestCase 4 | include RdfTestUtility 5 | context "rdf_container" do 6 | should "accept a resource predicate tupel as pointer (shortcut) to a container" do 7 | setup_site_jekyll File.dirname(__FILE__) 8 | file = File.read(File.join(@source, "_site/container.html")) 9 | answer = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 10 | entry.strip 11 | end 12 | assert(answer.any? {|resource| resource.to_s.eql? "http://example.org/instance/conItem1"}, "answerset does not contain 'http://example.org/instance/conItem1'") 13 | assert(answer.any? {|resource| resource.to_s.eql? "http://example.org/instance/conItem2"}, "answerset does not contain 'http://example.org/instance/conItem2'") 14 | assert(answer.any? {|resource| resource.to_s.eql? "http://example.org/instance/conItem3"}, "answerset does not contain 'http://example.org/instance/conItem3'") 15 | assert(answer.any? {|resource| resource.to_s.eql? "http://example.org/instance/conItem4"}, "answerset does not contain 'http://example.org/instance/conItem4'") 16 | assert(answer.any? {|resource| resource.to_s.eql? "http://example.org/instance/conItem5"}, "answerset does not contain 'http://example.org/instance/conItem5'") 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /test/cases/showConfig/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/showConfig/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" # the subpath of your site, e.g. /blog 2 | url: "http://example.org/" # the base hostname & protocol for your site 3 | 4 | plugins: 5 | - jekyll-rdf 6 | jekyll_rdf: 7 | path: "_data/knowledge-base.ttl" 8 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 9 | instance_template_mappings: 10 | "http://example.org/instance/resource": "exampleInstance" 11 | -------------------------------------------------------------------------------- /test/cases/showConfig/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX eg: 2 | -------------------------------------------------------------------------------- /test/cases/showConfig/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix eg: . 2 | 3 | eg:resource eg:predicate eg:object . 4 | 5 | eg:predicate eg:object . 6 | eg:predicate eg:object . 7 | eg:predicate eg:object . 8 | 9 | -------------------------------------------------------------------------------- /test/cases/showConfig/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/cases/showConfig/_layouts/exampleInstance.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
8 | {{page.rdf}}
9 | {% for sub in page.sub_rdf %} 10 | {{sub}}
11 | {% endfor %} 12 |
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/cases/showConfig/test_show_config.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestShowConfig < Test::Unit::TestCase 4 | include RdfTestUtility 5 | context "load_data form RdfPageHelper" do 6 | should "load data correctly into the file" do 7 | setup_jekyll File.dirname(__FILE__) 8 | 9 | content = [] 10 | file = File.read(File.join(@source, "_site/resource.html")) 11 | content = file[/\(.|\s)*\<\/div>/][22..-7].strip.split("
").map do |entry| 12 | entry.strip 13 | end 14 | 15 | assert_equal "http://example.org/instance/resource", content[0] 16 | assert content.include? "http://example.org/instance/resource#subResource1" 17 | assert content.include? "http://example.org/instance/resource#subResource2" 18 | assert content.include? "http://example.org/instance/resource#subResource3" 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /test/cases/types/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/types/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" 2 | url: "http://example.org/" 3 | plugins: 4 | - jekyll-rdf 5 | jekyll_rdf: 6 | path: "_data/knowledge-base.ttl" 7 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 8 | default_template: "default" 9 | instance_template_mappings: 10 | "http://example.org/instance/types": "types" 11 | -------------------------------------------------------------------------------- /test/cases/types/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix eg: . 2 | 3 | eg:types eg:value1 "28.07.2018"^^eg:replace . 4 | eg:types eg:value2 "detrever"^^eg:revert . 5 | eg:types eg:value3 "this was all lower case"^^eg:uppercase . 6 | -------------------------------------------------------------------------------- /test/cases/types/_layouts/types.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | This tests math filters 7 | 8 | 9 | 10 | 11 |
12 | {%- assign replace = page.rdf | rdf_property: "" -%} 13 | {%- assign revert = page.rdf | rdf_property: "" -%} 14 | {%- assign upperCase = page.rdf | rdf_property: "" -%} 15 |
Replace

16 | {{replace}}
17 |
Revert

18 | {{revert}}
19 |
Upper Case

20 | {{upperCase}} 21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /test/cases/types/test_types.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestRdfTypes < Test::Unit::TestCase 4 | context "cases/types" do 5 | setup do 6 | @source = File.dirname(__FILE__) 7 | config = Jekyll.configuration(YAML.load_file(File.join(@source, '_config.yml')).merge!({'source' => @source, 'destination' => File.join(@source, "_site")})) 8 | site = Jekyll::Site.new(config) 9 | class Replace 10 | @@class_uri = "http://example.org/instance/replace" 11 | 12 | def self.match? string 13 | return regex.match string 14 | end 15 | 16 | def self.regex 17 | @@regex ||= /^.*$/ 18 | return @@regex 19 | end 20 | 21 | def self.to_type string 22 | return string.gsub(".", "--") 23 | end 24 | 25 | def self.=== other 26 | return other.to_s.eql? @@class_uri 27 | end 28 | end 29 | 30 | class Revert 31 | @@class_uri = "http://example.org/instance/revert" 32 | 33 | def self.match? string 34 | return regex.match string 35 | end 36 | 37 | def self.regex 38 | @@regex ||= /^.*$/ 39 | return @@regex 40 | end 41 | 42 | def self.to_type string 43 | return string.reverse 44 | end 45 | 46 | def self.=== other 47 | return other.to_s.eql? @@class_uri 48 | end 49 | end 50 | 51 | class Uppercase 52 | @@class_uri = "http://example.org/instance/uppercase" 53 | 54 | def self.match? string 55 | return regex.match string 56 | end 57 | 58 | def self.regex 59 | @@regex ||= /^.*$/ 60 | return @@regex 61 | end 62 | 63 | def self.to_type string 64 | return string.upcase 65 | end 66 | 67 | def self.=== other 68 | return other.to_s.eql? @@class_uri 69 | end 70 | end 71 | Jekyll::JekyllRdf::Helper::Types::register Replace 72 | Jekyll::JekyllRdf::Helper::Types::register Revert 73 | Jekyll::JekyllRdf::Helper::Types::register Uppercase 74 | site.process 75 | end 76 | 77 | should "evalueate different types" do 78 | content = [] 79 | file = File.read("#{@source}/_site/types.html") 80 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 81 | entry.strip 82 | end 83 | 84 | assert_equal "28--07--2018", content[1] 85 | assert_equal "reverted", content[3] 86 | assert_equal "THIS WAS ALL LOWER CASE", content[5] 87 | end 88 | end 89 | end 90 | -------------------------------------------------------------------------------- /test/cases/uniqueResources/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | group :jekyll_plugins do 3 | gem 'jekyll-rdf', :path => '../../../' 4 | end 5 | -------------------------------------------------------------------------------- /test/cases/uniqueResources/_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: "/instance" # the subpath of your site, e.g. /blog 2 | url: "http://example.org/" # the base hostname & protocol for your site 3 | # Build settings 4 | markdown: kramdown 5 | plugins: 6 | - jekyll-rdf 7 | jekyll_rdf: 8 | path: "_data/knowledge-base.ttl" 9 | restriction: "SELECT ?resourceUri WHERE {?resourceUri ?p ?o}" 10 | default_template: "default" 11 | 12 | -------------------------------------------------------------------------------- /test/cases/uniqueResources/_data/Prefixes.pref: -------------------------------------------------------------------------------- 1 | PREFIX eg: 2 | 3 | -------------------------------------------------------------------------------- /test/cases/uniqueResources/_data/knowledge-base.ttl: -------------------------------------------------------------------------------- 1 | @prefix eg: . 2 | 3 | eg:resource eg:predicate eg:object . 4 | 5 | -------------------------------------------------------------------------------- /test/cases/uniqueResources/_layouts/default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 |
8 |

This is made with jekyll-rdf

9 | {{content}} 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cases/uniqueResources/test_unique_resources.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestRenderedAttribute < Test::Unit::TestCase 4 | include RdfTestUtility 5 | context "cases/uniqueResources" do 6 | setup do 7 | setup_jekyll File.dirname(__FILE__) 8 | end 9 | 10 | should "create only one resource" do 11 | content = [] 12 | file = File.read(File.join(@source, "_site/uniqueResources.html")) 13 | content = file[/\(.|\s)*\<\/div>/][5..-7].strip.split("
").map do |entry| 14 | entry.strip 15 | end 16 | assert_equal "http://example.org/instance/resource", content[0] 17 | assert_equal "http://example.org/instance/resource", content[1] 18 | assert_equal "http://example.org/instance/resource", content[2] 19 | resources = Jekyll::JekyllRdf::Helper::RdfHelper.class_variable_get(:@@resources) 20 | assert_equal 3, resources.length # 3 because the template mapping creates additional resources 21 | end 22 | end 23 | end -------------------------------------------------------------------------------- /test/cases/uniqueResources/uniqueResources.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | This Resource should be instantiated only once! 7 | 8 | 9 | 10 | 11 | {%- assign resource1 = "" | rdf_get -%} 12 | {%- assign resource2 = "" | rdf_get -%} 13 | {%- assign resource3 = "" | rdf_get -%} 14 |
15 | {{resource1}} 16 |
17 | {{resource2}} 18 |
19 | {{resource3}} 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | require 'test-unit' 2 | require 'shoulda-context' 3 | require 'rspec/expectations' 4 | require 'simplecov' 5 | require 'ResourceHelper' 6 | require 'RdfTestUtility' 7 | 8 | SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([ 9 | SimpleCov::Formatter::HTMLFormatter, 10 | ]) 11 | SimpleCov.start do 12 | add_filter ["/.vendor", "/vendor", "/test"] 13 | end 14 | require_relative '../lib/jekyll-rdf' 15 | 16 | Jekyll.logger.log_level = :error 17 | class TestHelper 18 | DUMMY_STDERR = StringIO.new 19 | 20 | def self.setErrOutput 21 | @@old_stderr = $stderr 22 | $stderr = DUMMY_STDERR 23 | end 24 | 25 | def self.resetErrOutput 26 | $stderr = @@old_stderr 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /test/theme-gem/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | 5 | -------------------------------------------------------------------------------- /test/theme-gem/_data/prefixes.sparql: -------------------------------------------------------------------------------- 1 | PREFIX ex: 2 | PREFIX jb: 3 | PREFIX rdfs: 4 | -------------------------------------------------------------------------------- /test/theme-gem/_layouts/ontology.html: -------------------------------------------------------------------------------- 1 | --- 2 | rdf_prefix_path: "_data/prefixes.sparql" 3 | --- 4 | 5 | 6 | ontology layout 7 | 8 | 9 | 10 | 11 |

My Jekyll RDF Blog


12 | {{content}}
13 | {{ page.rdf | rdf_property: "rdfs:label" }}
14 | {{ "" | rdf_get | rdf_property: "rdfs:label" }}
15 | 16 | 17 | -------------------------------------------------------------------------------- /test/theme-gem/theme-gem.gemspec: -------------------------------------------------------------------------------- 1 | Gem::Specification.new do |s| 2 | s.name = 'theme-gem' 3 | s.version = '1.0.0' 4 | s.summary = '' 5 | s.description = '' 6 | s.authors = [''] 7 | s.email = '' 8 | s.files = Dir['**/*'] 9 | s.homepage = '' 10 | s.license = '' 11 | 12 | end 13 | 14 | --------------------------------------------------------------------------------