Commit 839bbd17 authored by Cyrille Chopelet's avatar Cyrille Chopelet

[License] Adapt license to handle copyrights

parent 599ed3ab
{{ $license := split ( lower .license ) " " -}}
{{ $licenseFamily := index $license 0 -}}
{{ $license := split .license " " -}}
{{ $licenseFamily := lower (index $license 0) -}}
{{- if eq "cc" $licenseFamily -}}
{{ $terms := index $license 1 -}}
{{ $terms := lower (index $license 1) -}}
{{ $valid := slice "by" "by-sa" "by-nd" "by-nc" "by-nc-sa" "by-nc-nd" -}}
{{ if in $valid $terms -}}
{{ $version := index $license 2 -}}
......@@ -27,6 +27,8 @@
{{- partial "utils/icon.html" (dict "icon" "unsplash" "title" "Unsplash") -}}
{{ .license -}}
</a>
{{- else if eq "copyright" $licenseFamily -}}
&copy;&nbsp;{{ delimit (last (sub (len $license) 1) $license) " " }}
{{- else -}}
{{ errorf "Not a known license: <%q> (compact + icons)" .license }}
{{- end -}}
{{ $license := split ( lower .license ) " " -}}
{{ $licenseFamily := index $license 0 -}}
{{ $license := split .license " " -}}
{{ $licenseFamily := lower (index $license 0) -}}
{{- if eq "cc" $licenseFamily -}}
{{ $terms := index $license 1 -}}
{{ $terms := lower (index $license 1) -}}
{{ $valid := slice "by" "by-sa" "by-nd" "by-nc" "by-nc-sa" "by-nc-nd" -}}
{{ if in $valid $terms -}}
{{ $version := index $license 2 -}}
......@@ -21,6 +21,8 @@
<a href="https://unsplash.com/license" title="{{ .license }}" rel="license">
{{- .license -}}
</a>
{{- else if eq "copyright" $licenseFamily -}}
&copy;&nbsp;{{ delimit (last (sub (len $license) 1) $license) " " }}
{{- else -}}
{{ errorf "Not a known license: <%q> (compact)" .license }}
{{- end -}}
{{ $license := split ( lower .license ) " " -}}
{{ $licenseFamily := index $license 0 -}}
{{ $license := split .license " " -}}
{{ $licenseFamily := lower (index $license 0) -}}
{{- if eq "cc" $licenseFamily -}}
{{ $terms := index $license 1 }}
{{ $terms := lower (index $license 1) }}
{{ $valid := slice "by" "by-sa" "by-nd" "by-nc" "by-nc-sa" "by-nc-nd" }}
{{ if in $valid $terms -}}
{{ $version := index $license 2 -}}
{{ $licenseUrl := printf "https://creativecommons.org/licenses/%s/%s/deed.%s" $terms $version .Lang -}}
{{ $version := index $license 2 -}}
{{ $licenseUrl := printf "https://creativecommons.org/licenses/%s/%s/deed.%s" $terms $version .Lang -}}
<a href="{{ $licenseUrl }}" title="{{ .license }}" rel="license">
{{- partial "utils/icon.html" (dict "icon" "cc" "title" "CC") -}}
{{ range ( split $terms "-" ) -}}
{{ partial "utils/icon.html" (dict "icon" (printf "cc-%s" .) "title" (upper .)) -}}
{{ end -}}
{{- partial "utils/icon.html" (dict "icon" "cc" "title" "CC") -}}
{{ range ( split $terms "-" ) -}}
{{ partial "utils/icon.html" (dict "icon" (printf "cc-%s" .) "title" (upper .)) -}}
{{ end -}}
</a>
{{ else -}}
{{ errorf "Invalid CC license <%q>" .license }}
......@@ -24,6 +24,8 @@
<a href="https://unsplash.com/license" title="{{ .license }}" rel="license">
{{- partial "utils/icon.html" (dict "icon" "unsplash" "title" "Unsplash") -}}
</a>
{{- else if eq "copyright" $licenseFamily -}}
<span title="{{ delimit (last (sub (len $license) 1) $license) " " }}">&copy;</span>
{{- else -}}
{{ errorf "Not a known license: <%q> (icons)" .license }}
{{- end -}}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment