-
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.
Merge pull request #1 from open223/gtf-new-site-build
New site build
- Loading branch information
Showing
10 changed files
with
36,838 additions
and
14,276 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,39 @@ | ||
import requests | ||
import zipfile | ||
import io | ||
import json | ||
import os | ||
|
||
# Define the URL and headers | ||
url = "https://bas-im.emcs.cornell.edu/api/v4/projects/3/jobs/artifacts/master/download?job=document" | ||
headers = { | ||
"PRIVATE-TOKEN": os.environ.get('GITLAB_TOKEN'), | ||
} | ||
|
||
# Download the ZIP file | ||
response = requests.get(url, headers=headers) | ||
|
||
# Check if the request was successful | ||
if response.status_code == 200: | ||
print("Download successful. Unpacking the ZIP file...") | ||
|
||
# Unpack the ZIP file | ||
with zipfile.ZipFile(io.BytesIO(response.content)) as z: | ||
# Extract all files to the current directory or specify a different path | ||
z.extractall() | ||
print("Unpacking completed.") | ||
|
||
# Check if 'constraints.json' is in the extracted files | ||
if 'constraints.json' in z.namelist(): | ||
# Read 'constraints.json' | ||
with open('constraints.json', 'r') as json_file: | ||
data = json.load(json_file) | ||
print("Contents of 'constraints.json':") | ||
print(json.dumps(data, indent=4)) # Pretty print the JSON data | ||
# save the json data to a file | ||
with open('constraints_data.json', 'w') as json_file: | ||
json.dump(data, json_file, indent=4) | ||
else: | ||
print("'constraints.json' not found in the extracted files.") | ||
else: | ||
print(f"Failed to download file. Status code: {response.status_code}") |
Large diffs are not rendered by default.
Oops, something went wrong.
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,49 @@ | ||
import json | ||
from jinja2 import Environment, FileSystemLoader, select_autoescape | ||
from rdflib import Namespace, BNode, RDF, RDFS, Graph | ||
|
||
class SiteBuilder: | ||
def __init__(self, constraints_json_file: str): | ||
with open(constraints_json_file, 'r') as f: | ||
self.constraints = json.load(f) | ||
|
||
def build_definitions(self): | ||
# list of dictionaries, each with: | ||
# - class (concept URI) | ||
# - name | ||
# - label | ||
# - immediate_subgraph (cbd) | ||
# - see also (all constraints and rules) | ||
definitions = [] | ||
for concept, defn in self.constraints.items(): | ||
print(concept) | ||
print(json.dumps(defn, indent=2)) | ||
print('---') | ||
definitions.append({ | ||
"class": concept, | ||
"name": defn["stable_id"], | ||
"label": defn["label"], | ||
"immediate_subgraph": defn["cbd"], | ||
}) | ||
return definitions | ||
|
||
def build(self): | ||
env = Environment( | ||
loader=FileSystemLoader('templates'), | ||
autoescape=select_autoescape() | ||
) | ||
template = env.get_template("index.html") | ||
|
||
definitions = self.build_definitions() | ||
#prop_defns = self.build_property_shapes() | ||
|
||
# Now render the template | ||
with open("index.html", "w") as f: | ||
f.write(template.render( | ||
concepts=definitions, | ||
#property_shapes=[d.to_dict() for d in prop_defns], | ||
)) | ||
|
||
if __name__ == "__main__": | ||
builder = SiteBuilder("constraints.json") | ||
builder.build() |
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
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
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
Oops, something went wrong.