fix: copyright license logic for derivatives

Attempts to align logic with that used at https://chooser-beta.creativecommons.org/

Fix b4901e3
Fix 1729
Close #1730
This commit is contained in:
George Cushen 2020-06-03 12:20:30 +01:00
commit ff252a6a74

View file

@ -9,14 +9,14 @@
{{ $allow_derivatives := .Params.copyright_license.allow_derivatives | default site.Params.copyright_license.allow_derivatives }}
{{ $share_alike := .Params.copyright_license.share_alike | default site.Params.copyright_license.share_alike }}
{{$cc_code := "by"}}
{{ if not $allow_commercial }}{{ $cc_code = printf "%s-nc" $cc_code}}{{end}}
{{ if not $allow_derivatives }}
{{ if $share_alike }}
{{ $cc_code = printf "%s-sa" $cc_code}}
{{else}}
{{ $cc_code = printf "%s-nd" $cc_code}}
{{end}}
{{ $cc_code := "by" }}
{{ if not $allow_commercial }}
{{ $cc_code = printf "%s-nc" $cc_code }}
{{end}}
{{ if and $allow_derivatives $share_alike }}
{{ $cc_code = printf "%s-sa" $cc_code }}
{{ else if not $allow_derivatives }}
{{ $cc_code = printf "%s-nd" $cc_code }}
{{end}}
{{ $license_url := printf "https://creativecommons.org/licenses/%s/4.0" ($cc_code | urlize) }}
@ -31,12 +31,13 @@
<a href="{{$license_url}}" rel="noopener noreferrer" target="_blank">
<img src="https://search.creativecommons.org/static/img/cc_icon.svg" alt="CC icon">
<img src="https://search.creativecommons.org/static/img/cc-by_icon.svg" alt="CC by icon">
{{ if not $allow_commercial }}<img src="https://search.creativecommons.org/static/img/cc-nc_icon.svg" alt="CC NC icon">{{end}}
{{ if not $allow_derivatives }}
{{ if not $allow_commercial }}
<img src="https://search.creativecommons.org/static/img/cc-nc_icon.svg" alt="CC NC icon">
{{end}}
{{ if and $allow_derivatives $share_alike }}
<img src="https://search.creativecommons.org/static/img/cc-sa_icon.svg" alt="CC SA icon">
{{ else if not $allow_derivatives }}
<img src="https://search.creativecommons.org/static/img/cc-nd_icon.svg" alt="CC ND icon">
{{ if $share_alike }}
<img src="https://search.creativecommons.org/static/img/cc-sa_icon.svg" alt="CC SA icon">
{{end}}
{{end}}
</a>
</p>