Skip to content

Commit

Permalink
Merge pull request #34 from lblod/GN-4435
Browse files Browse the repository at this point in the history
GN-4435: Use `cool-uri` to create permalink for `zitting`
  • Loading branch information
abeforgit authored Oct 16, 2023
2 parents 8e37814 + d764a0b commit 587e4df
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-toys-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-gn-publicatie": minor
---

GN-4435: Use `cool-uri` to create permalink for `zitting`
23 changes: 23 additions & 0 deletions config/dispatcher/dispatcher.ex
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,29 @@ defmodule Dispatcher do
send_resp( conn, 404, "" )
end

###############
# PERMALINKS
###############

# This will catch calls to pages {HOST}/Aalst/Gemeente/zitting/b2f47ed1-3534-11e9-a984-7db43f975d75
# and redirect them to {HOST}/Aalst/Gemeente/zittingen/b2f47ed1-3534-11e9-a984-7db43f975d75
# Note "zitting" vs "zittingen
match "/:bestuurseenheid_naam/:bestuurseenheid_classificatie_code_label/zitting/*path", @any do
conn = Plug.Conn.put_resp_header( conn, "location", "/" <> bestuurseenheid_naam <> "/" <> bestuurseenheid_classificatie_code_label <> "/zittingen/" <> Enum.join( path, "/") )
conn = send_resp( conn, 301, "" )
end

match "/permalink", @any do
conn = Plug.Conn.fetch_query_params(conn)
uri = conn.query_params["uri"]

if !uri || uri == "" do
send_resp( conn, 404, "" )
else
Proxy.forward conn, [], "http://cooluri" <> "?uri=" <> uri
end
end

match "/*path", @html do
# *_path allows a path to be supplied, but will not yield
# an error that we don't use the path variable.
Expand Down
26 changes: 26 additions & 0 deletions config/migrations/20231005111514-zitting-permalink.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX mandaat: <http://data.vlaanderen.be/ns/mandaat#>
PREFIX besluit: <http://data.vlaanderen.be/ns/besluit#>
PREFIX mu: <http://mu.semte.ch/vocabularies/core/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

INSERT {
GRAPH <http://mu.semte.ch/graphs/public> {
?session foaf:page ?redirectUrl.
}
}
WHERE {
?session rdf:type besluit:Zitting ;
mu:uuid ?zittingUuid ;
(besluit:isGehoudenDoor/mandaat:isTijdspecialisatieVan) ?administrativeUnit .
?administrativeUnit besluit:bestuurt ?bestuurseenheid .
?bestuurseenheid skos:prefLabel ?administrativeUnitName ;
(besluit:classificatie/skos:prefLabel) ?administrativeUnitTypeName .
BIND(
CONCAT("/", ?administrativeUnitName, "/", ?administrativeUnitTypeName, "/zittingen/", ?zittingUuid)
AS ?redirectUrl
)
}


5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,8 @@ services:
environment:
BACKEND_HOST: database
restart: always
cooluri:
image: nvdk/cool-uris:1.0.0
environment:
SPARQL_ENDPOINT: "http://virtuoso:8890/sparql"
PORT: 80

0 comments on commit 587e4df

Please sign in to comment.