Skip to content

Commit

Permalink
Display archived links if available
Browse files Browse the repository at this point in the history
  • Loading branch information
zner0L committed Nov 22, 2023
1 parent 1173eb6 commit 39861ae
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions assets/_custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ table.data-table {
&.icon-information {
vertical-align: -2px;
}

&.icon-archive {
vertical-align: -2px;
}
}

/* Make the body the size of the viewport or the page to position the footer */
Expand Down
3 changes: 3 additions & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
"tracker-single-transmitted-data-table-reasoning-link-desc": {
"other": "More details on how we identified this property"
},
"tracker-single-transmitted-data-table-reasoning-link-archive": {
"other": "Archived version of the link"
},
"tracker-single-operated-by": { "other": "operated by:" },

"tracker-list-datenanfragen-link": { "other": "get company information on datarequests.org" },
Expand Down
18 changes: 18 additions & 0 deletions layouts/partials/archived-urls.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{ $urls := getCSV "," "content/en/research/archived-urls.csv"}}
{{ $urlToArchivedUrl := dict }}
{{ range $urls }}
{{ $originalUrl := index . 0 }}
{{ $archivedUrl := index . 1 }}
{{ $timestamp := index . 2 }}
{{ $dataPathToArchivedUrl := dict }}
{{ range strings.Split (index . 3) ";" }}
<!-- Apparently, the containedDataPaths are loaded in lowercase in the adapter template, so we need to lowercase the ID here, too, so that the URLs are read correctly. -->
{{ $property := (lower .)}}
<!-- We might have older changes in the table that we do not want to overwrite -->
{{ if le (index (index $urlToArchivedUrl $originalUrl) $property).timestamp $timestamp }}
{{ $dataPathToArchivedUrl = merge $dataPathToArchivedUrl (dict $property (dict "archivedUrl" $archivedUrl "timestamp" $timestamp )) }}
{{ end }}
{{ end }}
{{ $urlToArchivedUrl = merge $urlToArchivedUrl (dict $originalUrl $dataPathToArchivedUrl) }}
{{ end }}
{{ return $urlToArchivedUrl}}
6 changes: 6 additions & 0 deletions layouts/trackers/single.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{{ define "main" }}
{{ $urlToArchivedUrl := partialCached "archived-urls.html" "" }}

<article class="markdown">
<h1>{{ .Title }}</h1>

Expand Down Expand Up @@ -93,6 +95,10 @@ <h2>{{ T "tracker-single-transmitted-data-heading" }}</h2>
-->
{{ if or (strings.HasPrefix .reasoning "https://") (strings.HasPrefix .reasoning "http://") }}
<a href="{{ .reasoning }}"><img src="/svg/information.svg" class="inline-icon icon-information" alt="{{ T "tracker-single-transmitted-data-table-reasoning-link-desc" }}" title="{{ T "tracker-single-transmitted-data-table-reasoning-link-desc" }}"></a>
{{ if isset $urlToArchivedUrl .reasoning }}
{{ $archivedUrl := index (index $urlToArchivedUrl .reasoning) (printf "%s/%s#%s" $.Params.tracker.slug $.Params.slug $property) }}
<a href="{{ $archivedUrl.archivedUrl }}"><img src="/svg/archive.svg" class="inline-icon icon-archive" alt="{{ T "tracker-single-transmitted-data-table-reasoning-link-archive" }}" title="{{ T "tracker-single-transmitted-data-table-reasoning-link-archive" }}"></a>
{{ end }}
{{ else if (strings.HasSuffix .reasoning ".md") }}
{{ $path := .reasoning }}
{{ if not (strings.HasSuffix .reasoning "index.md") }}
Expand Down
1 change: 1 addition & 0 deletions static/svg/archive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 39861ae

Please sign in to comment.