-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mimics website setting from https://github.com/fair-ease/dataset-dema…
- Loading branch information
Showing
52 changed files
with
2,813 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lab.fairease.eu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import json | ||
import os | ||
import shutil | ||
from typing import Self | ||
|
||
|
||
class IndexItem: | ||
name: str | ||
path: str | ||
|
||
def __init__(self, name, path): | ||
self.name = name | ||
self.path = path | ||
|
||
def to_dict(self) -> dict: | ||
return { | ||
"type": "item", | ||
"name": self.name, | ||
"path": self.path, | ||
} | ||
|
||
|
||
class IndexGroup: | ||
name: str | ||
children: list[IndexItem | Self] | ||
|
||
def __init__(self, name, children): | ||
self.name = name | ||
self.children = children | ||
|
||
def to_dict(self) -> dict: | ||
return { | ||
"type": "group", | ||
"name": self.name, | ||
"children": list(map(lambda c: c.to_dict(), self.children)), | ||
} | ||
|
||
|
||
def index_registry() -> IndexGroup: | ||
children = find_children("./registry") | ||
return IndexGroup("registry", children) | ||
|
||
|
||
def find_children(registry, path="") -> list[IndexItem | IndexGroup]: | ||
children = [] | ||
with os.scandir(os.path.join(registry, path)) as it: | ||
for entry in it: | ||
if entry.is_file() and entry.name.endswith(".ttl"): | ||
name = os.path.splitext(entry.name)[0] | ||
children.append(IndexItem(name, path + name)) | ||
elif entry.is_dir(): | ||
entry_children = find_children(registry, path + entry.name + "/") | ||
children.append(IndexGroup(entry.name, entry_children)) | ||
return children | ||
|
||
|
||
def create_registry_files(base: str, registry: list[IndexItem | IndexGroup]): | ||
for item in registry: | ||
if isinstance(item, IndexItem): | ||
create_registry_item_files(base, item) | ||
else: | ||
print(f"group {item.name}") | ||
os.makedirs(os.path.join(base, item.name)) | ||
create_registry_files(os.path.join(base, item.name), item.children) | ||
|
||
|
||
def create_registry_item_files(path, item: IndexItem): | ||
srcpath = os.path.join("registry", item.path) + ".ttl" | ||
dstpath = os.path.join(path, item.name) + ".ttl" | ||
dstdir = path # os.path.dirname(dstpath) | ||
# copy turtle file | ||
shutil.copyfile(srcpath, dstpath) | ||
# create web page | ||
querypath = os.path.relpath(os.path.splitext(dstpath)[0], "./web") | ||
webname = item.name + ".md" | ||
with open(os.path.join(dstdir, webname), "w") as f: | ||
f.write( | ||
"---\n" | ||
"layout: page\n" | ||
"css:\n" | ||
" - query.css\n" | ||
"js:\n" | ||
" - rdflib.min.js\n" | ||
" - turtle.js\n" | ||
" - query.js\n" | ||
"preload:\n" | ||
f" - {item.name}.ttl\n" | ||
f"permalink: {querypath}.html\n" | ||
"---\n" | ||
) | ||
f.write(f'{{% include query.html query="{item.path}" %}}\n') | ||
|
||
|
||
def filter_turtle(base, items: list[str]) -> list[str]: | ||
|
||
def isdir(item): | ||
return os.path.isdir(os.path.join(base, item)) | ||
|
||
def isturtle(item): | ||
filepath = os.path.join(base, item) | ||
return os.path.isfile(filepath) and item.endswith(".ttl") | ||
|
||
return list(filter(lambda item: not (isdir(item) or isturtle(item)), items)) | ||
|
||
|
||
if __name__ == "__main__": | ||
# generate registry index | ||
index = index_registry() | ||
os.makedirs("./web/_data", exist_ok=True) | ||
with open("./web/_data/registry.json", "w") as f: | ||
f.write(json.dumps([index.to_dict()])) | ||
# clean up the registry directory in the website, in case it already exists | ||
try: | ||
shutil.rmtree("./web/registry") | ||
except: | ||
pass | ||
create_registry_files("./web", [index]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
permalink: /404.html | ||
layout: default | ||
--- | ||
|
||
<style type="text/css" media="screen"> | ||
.container { | ||
margin: 10px auto; | ||
max-width: 600px; | ||
text-align: center; | ||
} | ||
h1 { | ||
margin: 30px 0; | ||
font-size: 4em; | ||
line-height: 1; | ||
letter-spacing: -1px; | ||
} | ||
</style> | ||
|
||
<div class="container"> | ||
<h1>404</h1> | ||
|
||
<p><strong>Page not found :(</strong></p> | ||
<p>The requested page could not be found.</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
source "https://rubygems.org" | ||
# Hello! This is where you manage which Jekyll version is used to run. | ||
# When you want to use a different version, change it below, save the | ||
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so: | ||
# | ||
# bundle exec jekyll serve | ||
# | ||
# This will help ensure the proper Jekyll version is running. | ||
# Happy Jekylling! | ||
# gem "jekyll", "~> 4.3.3" | ||
# This is the default theme for new Jekyll sites. You may change this to anything you like. | ||
gem "minima", "~> 2.5" | ||
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and | ||
# uncomment the line below. To upgrade, run `bundle update github-pages`. | ||
gem "github-pages", "~> 232", group: :jekyll_plugins | ||
# If you have any plugins, put them here! | ||
group :jekyll_plugins do | ||
gem "jekyll-feed", "~> 0.17" | ||
end | ||
|
||
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem | ||
# and associated library. | ||
platforms :mingw, :x64_mingw, :mswin, :jruby do | ||
gem "tzinfo", ">= 1", "< 3" | ||
gem "tzinfo-data" | ||
end | ||
|
||
# Performance-booster for watching directories on Windows | ||
gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin] | ||
|
||
# Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem | ||
# do not have a Java counterpart. | ||
gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby] | ||
|
||
gem "webrick", "~> 1.8" |
Oops, something went wrong.