From 32efd3010417f3b10b04d4548e5080cf71234d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Thu, 28 May 2020 14:00:39 +0200 Subject: [PATCH] tag2link: convert tag2link info into dist/tag2link.json --- bin/download_dependencies | 1 + bin/tag2link-converter | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 bin/tag2link-converter diff --git a/bin/download_dependencies b/bin/download_dependencies index 24d42ef9..3fb150ba 100755 --- a/bin/download_dependencies +++ b/bin/download_dependencies @@ -2,6 +2,7 @@ curl -H "Accept: application/json" -H "Content-Type: application/sparql-query" -H "User-Agent: OpenStreetBrowser" -XPOST -d @'lib/tag2link-wikidata.qry' https://query.wikidata.org/sparql > data/tag2link-wikidata.json curl -H "Accept: application/json" -H "Content-Type: application/sparql-query" -H "User-Agent: OpenStreetBrowser" -XPOST -d @'lib/tag2link-sophox.qry' https://sophox.org/sparql > data/tag2link-sophox.json +bin/tag2link-converter mkdir -p data/GeoIP cd data/GeoIP diff --git a/bin/tag2link-converter b/bin/tag2link-converter new file mode 100755 index 00000000..401c56d8 --- /dev/null +++ b/bin/tag2link-converter @@ -0,0 +1,39 @@ +#!/usr/bin/php + array(), + ); + } + + $formatter = array( + 'link' => $link, + ); + + if (preg_match("/^https?:\/\/([^\/]*)(\/.*|)$/", $link, $m)) { + $formatter['operator'] = $m[1]; + } + + $tag2link[$key]['formatter'][] = $formatter; + } +} + +file_put_contents('dist/tag2link.json', json_encode($tag2link, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE));