Skip to content

Commit

Permalink
Use frontend URL in DCAT URLs (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpolidori authored Nov 11, 2024
1 parent f791022 commit 740fa43
Show file tree
Hide file tree
Showing 6 changed files with 396 additions and 13 deletions.
35 changes: 23 additions & 12 deletions ckanext/portalopendatadk/dcat_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def graph_from_dataset(self, dataset_dict, dataset_ref):

# Landing page
frontend_site_url = config.get(
"ckanext.portalopendatadk.frontend_site_url", "https://opendata.dk"
"ckanext.portalopendatadk.frontend_site_url", config.get("ckan.site_url")
)
g.add(
(
Expand Down Expand Up @@ -505,7 +505,7 @@ def graph_from_dataset(self, dataset_dict, dataset_ref):
# g.add((dataset_ref, DCAT.theme, theme_uri))

# Conforms to
g.add((dataset_ref, DCT.conformsTo, URIRef(CONFORMS_TO)))
#g.add((dataset_ref, DCT.conformsTo, URIRef(CONFORMS_TO)))

# Language
# titles_translated = dataset_dict.get('title_translated')
Expand Down Expand Up @@ -581,10 +581,20 @@ def graph_from_dataset(self, dataset_dict, dataset_ref):
[
self._get_dataset_value(dataset_dict, "publisher_uri"),
self._get_dataset_value(dataset_dict, "publisher_name"),
dataset_dict.get("organization"),
(dataset_dict.get("organization") and dataset_dict["organization"].get("name")),
]
):
publisher_uri = publisher_uri_from_dataset_dict(dataset_dict)
publisher = dataset_dict.get("organization", {})
publisher_slug = publisher.get("name") if publisher else None

if not publisher_slug:
publisher_uri = publisher_uri_from_dataset_dict(dataset_dict)
else:
publisher_uri = "{frontend_site_url}/{organization_name}".format(
frontend_site_url=frontend_site_url,
organization_name=publisher_slug,
)

if publisher_uri:
publisher_details = CleanedURIRef(publisher_uri)
else:
Expand Down Expand Up @@ -690,13 +700,14 @@ def graph_from_dataset(self, dataset_dict, dataset_ref):
dcat_formats = oddk_helpers.formats_from_file()

if fmt and fmt in dcat_formats:
distribution = CleanedURIRef(
"{}/dataset/{}/resource/{}".format(
config.get("ckan.site_url"),
dataset_dict.get("name"),
resource_dict.get("id"),
)
)
#distribution = CleanedURIRef(
# "{}/dataset/{}/resource/{}".format(
# config.get("ckan.site_url"),
# dataset_dict.get("name"),
# resource_dict.get("id"),
# )
#)
distribution = URIRef(resource_dict.get("url"))

g.add((dataset_ref, DCAT.distribution, distribution))

Expand Down Expand Up @@ -817,7 +828,7 @@ def graph_from_dataset(self, dataset_dict, dataset_ref):
self._add_list_triples_from_dict(resource_dict, distribution, items)

# Conforms to
g.add((distribution, DCT.conformsTo, URIRef(CONFORMS_TO)))
#g.add((distribution, DCT.conformsTo, URIRef(CONFORMS_TO)))

if fmt:
fmt_uri = URIRef(FORMAT_BASE_URI + fmt)
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -1013,3 +1013,179 @@ msgstr ""
#: EUROGEO_2022
msgid "EuroGeographics Open Data Licence v.2022"
msgstr ""

#: Manually added
msgid "UNKNOWN"
msgstr "Ubekendt"

#: Manually added
msgid "TRIENNIAL"
msgstr "Treårlig (hvert tredje år)"

#: Manually added
msgid "BIENNIAL"
msgstr "Toårig (hvert andet år)"

#: Manually added
msgid "ANNUAL"
msgstr "Årlig (hvert år)"

#: Manually added
msgid "ANNUAL_2"
msgstr "Halvårlig (to gange om året)"

#: Manually added
msgid "ANNUAL_3"
msgstr "Tre gange årligt"

#: Manually added
msgid "QUARTERLY"
msgstr "Kvartalsvis (hvert tredje måned)"

#: Manually added
msgid "BIMONTHLY"
msgstr "Hver anden måned"

#: Manually added
msgid "MONTHLY"
msgstr "Månedlig (en gang om måneden)"

#: Manually added
msgid "MONTHLY_2"
msgstr "To gange månedligt"

#: Manually added
msgid "BIWEEKLY"
msgstr "Hver fjortende dag"

#: Manually added
msgid "MONTHLY_3"
msgstr "Tre gange månedligt"

#: Manually added
msgid "WEEKLY"
msgstr "Ugentlig (en gang om ugen)"

#: Manually added
msgid "WEEKLY_2"
msgstr "To gange ugentligt"

#: Manually added
msgid "WEEKLY_3"
msgstr "Tre gange ugentligt"

#: Manually added
msgid "DAILY"
msgstr "Daglig (en gang om dagen)"

#: Manually added
msgid "UPDATE_CONT"
msgstr "Opdateres løbende"

#: Manually added
msgid "IRREG"
msgstr "Uregelmæssig"

#: Manually added
msgid "OTHER"
msgstr "Andet"

#: Manually added
msgid "DAILY_2"
msgstr "To gange om dagen"

#: Manually added
msgid "CONTINOUOUS"
msgstr "Kontinuerlig"

#: Manually added
msgid "NEVER"
msgstr "Aldrig"

#: Manually added
msgid "QUADRENNIAL"
msgstr "Hvert fjerde år"

#: Manually added
msgid "QUINQUENNIAL"
msgstr "Hvert femte år"

#: Manually added
msgid "HOURLY"
msgstr "Hver time"

#: Manually added
msgid "DECENNIAL"
msgstr "Hvert tiende år"

#: Manually added
msgid "BIHOURLY"
msgstr "Hver anden time"

#: Manually added
msgid "TRIHOURLY"
msgstr "Hver tredje time"

#: Manually added
msgid "BIDECENNIAL"
msgstr "Hvert tyvende år"

#: Manually added
msgid "TRIDECENNIAL"
msgstr "Hvert tredive år"

#: Manually added
msgid "ECON"
msgstr "Økonomi og finans"

#: Manually added
msgid "GOVE"
msgstr "Regering og offentlig sektor"

#: Manually added
msgid "AGRI"
msgstr "Landbrug, fiskeri, skovbrug og fødevarer"

#: Manually added
msgid "ENVI"
msgstr "Miljø"

#: Manually added
msgid "ENER"
msgstr "Energi"

#: Manually added
msgid "EDUC"
msgstr "Uddannelse, kultur og sport"

#: Manually added
msgid "JUST"
msgstr "Retfærdighed, retssystem og offentlig sikkerhed"

#: Manually added
msgid "REGI"
msgstr "Regioner og byer"

#: Manually added
msgid "INTR"
msgstr "Internationale spørgsmål"

#: Manually added
msgid "SOCI"
msgstr "Befolkning og samfund"

#: Manually added
msgid "OP_DATPRO"
msgstr "Provisoriske data"

#: Manually added
msgid "TECH"
msgstr "Videnskab og teknologi"

#: Manually added
msgid "HEAL"
msgstr "Health"

#: Manually added
msgid "TRAN"
msgstr "Transport"
Binary file not shown.
Loading

0 comments on commit 740fa43

Please sign in to comment.