Skip to content

Commit

Permalink
Changes to capitol nb workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-aravind committed Aug 27, 2024
1 parent d68d6a9 commit 6eb9550
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/capitolnb-events.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ jobs:
false \
true
- name: Replace location
run: |
FILE="output/capitolnb-events.jsonld"
sed -i 's/"@value": "Capitol Theatre"/"@id": "http:\/\/kg.artsdata.ca\/resource\/K11-116"/g' "$FILE"
sed -i 's/"@value": "Empress Theatre"/"@id": "http:\/\/kg.artsdata.ca\/resource\/K11-116"/g' "$FILE"
- name: Commit and Push Changes
run: |
git config --local user.email "[email protected]"
Expand All @@ -52,7 +58,7 @@ jobs:
- name: Action setup
uses: culturecreates/[email protected]
with:
artifact: capitolnb-ca
artifact: capitol-nb-ca
publisher: "${{ secrets.PUBLISHER_URI_GREGORY }}"
downloadUrl: https://raw.githubusercontent.com/culturecreates/artsdata-orion/${{ needs.fetch-and-commit-data.outputs.commit-hash }}/output/capitolnb-events.jsonld

6 changes: 5 additions & 1 deletion src/lib/headless_browser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module HeadlessBrowser
def self.fetch_json_ld_objects(entity_urls, base_url)
browser = Ferrum::Browser.new(headless: true, pending_connection_errors: false)
graph = RDF::Graph.new
add_url_sparql_file = File.read('./sparql/add_derived_from.sparql')
entity_urls.each do |entity_url|
begin
puts "Processing #{entity_url} in headless mode"
Expand All @@ -15,7 +16,10 @@ def self.fetch_json_ld_objects(entity_urls, base_url)
json_ld_scripts = browser.css("script[type='application/ld+json']")
json_ld_scripts.each do |script|
begin
graph << JSON::LD::API.toRdf(JSON.parse(script.text))
loaded_graph = RDF::Graph.new << JSON::LD::API.toRdf(JSON.parse(script.text))
sparql_file_with_url = add_url_sparql_file.gsub("subject_url", entity_url)
loaded_graph.query(SPARQL.parse(sparql_file_with_url, update: true))
graph << loaded_graph
rescue JSON::ParserError => e
puts "Error parsing JSON-LD: #{e.message}"
end
Expand Down

0 comments on commit 6eb9550

Please sign in to comment.