Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GN-4435: Use cool-uri to create permalink for zitting #34

Merged
merged 3 commits into from
Oct 16, 2023
Merged

Conversation

dkozickis
Copy link
Contributor

@dkozickis dkozickis commented Oct 6, 2023

Overview

GN-4435: Use cool-uri to create permalink for zitting

Setup cool-uri service to provide permalinks for zitting (and other entities via /permalink)

connected issues and PRs:

https://binnenland.atlassian.net/browse/GN-4435
lblod/besluit-publicatie-publish-service#11

Setup

  1. Checkout
  2. Checkout this PR GN-4435: Insert permalink for Zitting besluit-publicatie-publish-service#11 for besluit-publicatie-publish-service
  3. Add following to docker-compose.override.yml
     version: "3.4"
     services:
       besluit-publicatie:
         image: mu-javascript-template:latest
         environment:
           NODE_ENV: "development"
         volumes:
           - ./data/files/:/share/
           - /<LOCATION_OF_BESLUIT_SERVICE>/:/app/
    

Where <LOCATION_OF_BESLUIT_SERVICE> is folder where the besluit-publicatie-publish-service is checked out

  1. docker compose -f docker-compose.yml -f docker-compose.dev.yml -f docker-compose.override.yml up

How to test/reproduce

Confirm that migration was executed by running below query at http://localhost:8080/sparql

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT * WHERE {
  ?permalink foaf:page ?redirect .
} LIMIT 10
  1. Try to access http://localhost:8080/Huldenberg/Gemeente/zitting/b2f47ed1-3534-11e9-a984-7db43f975d75, confirm you are redirected to http://localhost:8080/Huldenberg/Gemeente/zittingen/b2f47ed1-3534-11e9-a984-7db43f975d75 (note zitting vs zittingen in URL)
  2. Try to access http://localhost:8080/permalink?uri=http://data.lblod.info/id/zittingen/8c93d2cc-f4ba-4444-b09e-b7495e336ff8, confirm you are redirected to http://localhost:8080/Huldenberg/Gemeente/zittingen/b2f47ed1-3534-11e9-a984-7db43f975d75
  3. Call curl -v http://localhost:8080/permalink?uri=http://data.lblod.info/id/zittingen/8c93d2cc-f4ba-4444-b09e-b7495e336ff8, confirm you get HTTP/1.1 303 See Other and location: /Huldenberg/Gemeente/zittingen/b2f47ed1-3534-11e9-a984-7db43f975d75 in the response headers

Confirm that besluit service is inserting permalink by either publishing something from GN, if you have it setup, or going to http://localhost:8080/sparql and executing following query

PREFIX sign: <http://mu.semte.ch/vocabularies/ext/signing/>

INSERT DATA {
GRAPH <http://mu.semte.ch/graphs/public> {
    <http://data.lblod.info/published-resources/0cf4b620-45f9-11ec-99f4-b935d359b4a5> a sign:PublishedResource ;
        <http://purl.org/dc/terms/created> "2023-10-04T09:47:30.818Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
        sign:text """<div class="au-c-template au-c-template--treatment behandeling"
     prefix="eli: http://data.europa.eu/eli/ontology# prov: http://www.w3.org/ns/prov# mandaat: http://data.vlaanderen.be/ns/mandaat# besluit: http://data.vlaanderen.be/ns/besluit# ext: http://mu.semte.ch/vocabularies/ext/ person: http://www.w3.org/ns/person# persoon: http://data.vlaanderen.be/ns/persoon# dateplugin: http://say.data.gift/manipulators/insertion/ besluittype: https://data.vlaanderen.be/id/concept/BesluitType/ dct: http://purl.org/dc/terms/ mobiliteit: https://data.vlaanderen.be/ns/mobiliteit# lblodmow: http://data.lblod.info/vocabularies/mobiliteit/">
    <div about="http://data.lblod.info/id/zittingen/6515CDF42C0D037764237179" typeof="besluit:Zitting"><span
            property="http://data.vlaanderen.be/ns/besluit#isGehoudenDoor"
            resource="http://data.lblod.info/id/bestuursorganen/28dca2b0f60eb33cdb72e8398fa63e19352f8fa67dfaa3a7784d83498d521bcf"></span>
        <span property="http://data.vlaanderen.be/ns/besluit#geplandeStart" content="2023-09-28T17:00:51.870Z"
              datatype="http://www.w3.org/2001/XMLSchema#dateTime"></span> <span
                property="http://www.w3.org/ns/prov#startedAtTime" content="2023-09-28T17:00:51.870Z"
                datatype="http://www.w3.org/2001/XMLSchema#dateTime" class="is-required"></span> <span
                property="http://www.w3.org/ns/prov#endedAtTime" content="2023-09-28T19:05:26.580Z"
                datatype="http://www.w3.org/2001/XMLSchema#dateTime"></span>
        <div class="au-c-template au-c-template--treatment" typeof="besluit:BehandelingVanAgendapunt"
             resource="http://data.lblod.info/id/behandelingen-van-agendapunten/6515CE5F2C0D03776423717A"><p
                content="true" datatype="xsd:boolean" property="besluit:openbaar"><span class="au-c-template-public">Openbare behandeling van agendapunt</span>
        </p>
            <h3 resource="http://data.lblod.info/id/agendapunten/6515CE602C0D03776423717B" property="dc:subject"><span
                    property="dc:title">besluit mbt vastgoedinformatieplatform</span> (<span
                    property="besluit:Agendapunt.type"
                    resource="http://lblod.data.gift/concepts/bdf68a65-ce15-42c8-ae1b-19eeb39e20d0"
                    typeof="skos:Concept">gepland</span>) </h3> <h4>Aanwezigen bij agendapunt</h4>

            <h4>Stemmingen bij agendapunt</h4>
            <div class="c-template-content c-template-content--treatment"></div>
        </div>
    </div>
</div>
""" .
}
}

Then after running

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT * WHERE {
  <http://data.lblod.info/id/zittingen/6515CDF42C0D037764237179> foaf:page ?redirect .
} LIMIT 10

You should be able to observe something like this, note that the ID part of the URL will be different

CleanShot 2023-10-09 at 11 14 09@2x

Checks PR readiness

  • UI: works on smaller screen sizes
  • UI: feedback for any loading/error states
  • Check cancel/go-back flows
  • Check database state correct when deleting/updating (especially regarding relationships)
  • changelog
  • no new deprecations

config/dispatcher/dispatcher.ex Outdated Show resolved Hide resolved
Proxy.forward conn, ["?uri=http://permalink", "zitting", id], "http://cooluri"
end

match "/permalink/*path", @any do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see the actual uri of the requested resource used here, as discussed on rocket (if possible)
this means any visitor could visit https://publicatie.gelinkt-notuleren.vlaanderen.be/permalink?uri=<uri> and get the content for that resource

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we can use actual URI, why I got confused is because I've first approached this from the point of using it just for redirecting access to {HOST}/Aalst/Gemeente/zitting/b2f47ed1-3534-11e9-a984-7db43f975d75, in that case we only have mu:uuid of zitting, which does not correspond to uh the uh ... letter/number combination in the URI, so cannot be referenced to the correct URI via cool-uri service directly

CleanShot 2023-10-06 at 14 28 10@2x

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to work via /permalink?uri=<uri>

Copy link
Contributor Author

@dkozickis dkozickis Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated PR description as well

  1. Try to access http://localhost:8080/Huldenberg/Gemeente/zitting/b2f47ed1-3534-11e9-a984-7db43f975d75, confirm you are redirected to http://localhost:8080/Huldenberg/Gemeente/zittingen/b2f47ed1-3534-11e9-a984-7db43f975d75 (note zitting vs zittingen in URL)
  2. Try to access http://localhost:8080/permalink?uri=http://data.lblod.info/id/zittingen/8c93d2cc-f4ba-4444-b09e-b7495e336ff8, confirm you are redirected to http://localhost:8080/Huldenberg/Gemeente/zittingen/b2f47ed1-3534-11e9-a984-7db43f975d75
  3. Call curl -v http://localhost:8080/permalink?uri=http://data.lblod.info/id/zittingen/8c93d2cc-f4ba-4444-b09e-b7495e336ff8, confirm you get HTTP/1.1 303 See Other and location: /Huldenberg/Gemeente/zittingen/b2f47ed1-3534-11e9-a984-7db43f975d75 in the response headers

Copy link
Contributor

@piemonkey piemonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I right in thinking the behaviour after the initial redirect isn't defined yet? Locally I get a strange 307 redirect after the first one (using httpie), e.g.

http :8080/Huldenberg/Gemeente/zitting/4b60e8f1-3532-11e9-a984-7db43f975d75
# HTTP/1.1 303 See Other
# location: /Langemark-Poelkapelle/Gemeente/zittingen/4b60e8f1-3532-11e9-a984-7db43f975d75
http :8080/Langemark-Poelkapelle/Gemeente/zittingen/4b60e8f1-3532-11e9-a984-7db43f975d75
# HTTP/1.1 307 Temporary Redirect
# location: //localhost:8080/Langemark-Poelkapelle/Gemeente

###############

# This will catch calls to links like {HOST}/Aalst/Gemeente/zitting/b2f47ed1-3534-11e9-a984-7db43f975d75
match "/:bestuurseenheid_naam/:bestuurseenheid_classificatie_code_label/zitting/:id", @any do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I missing something about how mu-dispatcher matches paths, or would this cause problems if we ever had a route in the UI which had 2 parts and then the word zitting? I feel like there should be a literal first part of the path to avoid collisions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it would. Current FE also has similar capture route (https://github.com/lblod/frontend-gelinkt-notuleren-publicatie/blob/master/app/router.js#L13), so it kinda works in the same way 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# HTTP/1.1 307 Temporary Redirect
# location: //localhost:8080/Langemark-Poelkapelle/Gemeente

I am not exactly sure but that looks like the Ember intercepting and redirecting when there is no actual zitting with that ID

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that was for an id I got from the triplestore though, so I thought it should exist, unless I managed to use the wrong id.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I for one can't reproduce your issue @piemonkey
I get a 301, which is correct, and --follow can follow nicely

* Redirect calls like `{HOST}/Aalst/Gemeente/zitting/b2f47ed1-3534-11e9-a984-7db43f975d75` directly to "zitting" instead of using `cool-uri`
* Update `/permalink` endpoint to expect `uri` query param
also redirects all further paths after /zitting, not just /zitting/:id
@abeforgit abeforgit merged commit 587e4df into master Oct 16, 2023
@abeforgit abeforgit deleted the GN-4435 branch October 16, 2023 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants