From d94953e72fad8e3259e69761744f60a325e63984 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Sat, 11 Jun 2022 20:16:47 +1000 Subject: Add links to cc-license pages --- src/components/TileInfoModal.vue | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/components/TileInfoModal.vue b/src/components/TileInfoModal.vue index 5f28dbd..45b3192 100644 --- a/src/components/TileInfoModal.vue +++ b/src/components/TileInfoModal.vue @@ -84,6 +84,36 @@ export default defineComponent({ height: this.uiOpts.infoModalImgSz + 'px', }; }, + licenseToUrl(license: string){ + license = license.toLowerCase().replaceAll('-', ' '); + if (license == 'cc0'){ + return 'https://creativecommons.org/publicdomain/zero/1.0/'; + } else if (license == 'cc publicdomain'){ + return 'https://creativecommons.org/licenses/publicdomain/'; + } else { + const regex = /cc by( nc)?( sa)?( ([0-9.]+)( [a-z]+)?)?/; + let results = regex.exec(license); + if (results != null){ + let url = 'https://creativecommons.org/licenses/by'; + if (results[1] != null){ + url += '-nc'; + } + if (results[2] != null){ + url += '-sa'; + } + if (results[4] != null){ + url += '/' + results[4]; + } else { + url += '/4.0'; + } + if (results[5] != null){ + url += '/' + results[5].substring(1); + } + return url; + } + return "[INVALID LICENSE]"; + } + }, }, created(){ let url = new URL(window.location.href); @@ -135,7 +165,7 @@ export default defineComponent({