initial commit

This commit is contained in:
Colmaris 2025-02-12 22:47:22 +01:00
parent 2012aa8834
commit 9ddfa58ace
2289 changed files with 11217 additions and 0 deletions

View file

@ -0,0 +1,20 @@
{{- $settings := partial "func/getFontAwesomeSettings.html" (dict "style" .style "arg1" .arg1 "arg2" .arg2) -}}
<span style="line-height:1em; vertical-align:middle;">
{{- $fname:=print "/assets/svg/" .style "/" .icon ".svg" -}}
{{- if (fileExists $fname) -}}
{{- $svg := readFile $fname -}}
{{- $svg = replace $svg " 512\"><!--" (print " 512\" style=\"height:" $settings.size "; width:" $settings.size "\"><!--") -}}
{{- $svg = replaceRE "<!--[^>]*-->" "" $svg -}}
{{- if eq .style "duotone" -}}
{{- $svg = replace $svg "class=\"fa-primary\"" (print "class=\"fa-primary\" style=\"fill:" $settings.primaryColor "; opacity:" $settings.primaryOpacity "\"") -}}
{{- $svg = replace $svg "class=\"fa-secondary\"" (print "class=\"fa-secondary\" style=\"fill:" $settings.secondaryColor "; opacity:" $settings.secondaryOpacity "\"") -}}
{{- $svg = replace $svg "<defs><style>.fa-secondary{opacity:.4}</style></defs>" "" -}}
{{- else -}}
{{- $svg = replace $svg "<path" (print "<path fill=\"" $settings.primaryColor "\" opacity=\"" $settings.primaryOpacity "\"") -}}
{{- end -}}
{{- $svg | safeHTML -}}
{{- else -}}
<span class="sc-fontawesome-missing" title="Could not find &quot;{{.icon}}&quot; icon with &quot;{{.style}}&quot; style">&#xFFFD;</span>
{{- warnf "Could not find \"%s\" icon with \"%s\" style." .icon .style -}}
{{- end -}}
</span>{{- "" -}}

View file

@ -0,0 +1,7 @@
{{ $result := 0 }}
{{ $parts := split (index . 0) "/" }}
{{ with (index $parts (index . 1)) }}
{{ $result = trim . " \t\n" }}
{{ end }}
{{- return $result -}}

View file

@ -0,0 +1,30 @@
{{ $lengthPattern := "^[\\d\\.]+(?i)(?:cm|in|mm|pc|pt|px|q|%|ch|em|ex|lh|rem|vh|vmax|vmin|vw)(?-i)$" }}
{{ $data := newScratch }}
{{ $data.Set "size" "1em" }}
{{ $data.Set "primaryColor" "currentColor" }}
{{ $data.Set "primaryOpacity" "1" }}
{{ $data.Set "secondaryColor" "currentColor" }}
{{ $data.Set "secondaryOpacity" "0.4" }}
{{ $args := slice .arg1 .arg2 }}
{{ range $args }}
{{ $length := findRE $lengthPattern . }}
{{ with $length }}
{{ $data.Set "size" (delimit $length "") }}
{{ else }}
{{ with . }}
{{ $parts := split . ";" }}
{{ with (index $parts 0) }}
{{ $data.Set "primaryColor" ((partial "func/getFontAwesomeColorOpacity.html" (slice . 0)) | default "currentColor") -}}) }}
{{ $data.Set "primaryOpacity" ((partial "func/getFontAwesomeColorOpacity.html" (slice . 1)) | default "1") -}}) }}
{{ end }}
{{ with (index $parts 1) }}
{{ $data.Set "secondaryColor" ((partial "func/getFontAwesomeColorOpacity.html" (slice . 0)) | default "currentColor") -}}) }}
{{ $data.Set "secondaryOpacity" ((partial "func/getFontAwesomeColorOpacity.html" (slice . 1)) | default "0.4") -}}) }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{- return (dict "size" ($data.Get "size") "primaryColor" ($data.Get "primaryColor") "primaryOpacity" ($data.Get "primaryOpacity") "secondaryColor" ($data.Get "secondaryColor") "secondaryOpacity" ($data.Get "secondaryOpacity") ) -}}