| .vscode/custom-dictionary.txt | ●●●●● patch | view | raw | blame | history | |
| config/_default/params.toml | ●●●●● patch | view | raw | blame | history | |
| layouts/_partials/func/hooks/collector-dump.html | ●●●●● patch | view | raw | blame | history | |
| layouts/_partials/func/hooks/collector.html | ●●●●● patch | view | raw | blame | history | |
| layouts/_partials/func/hooks/debug-cli.html | ●●●●● patch | view | raw | blame | history | |
| layouts/_partials/hook.html | ●●●●● patch | view | raw | blame | history | |
| layouts/_partials/hooks/article/section-link.html | ●●●●● patch | view | raw | blame | history | |
| layouts/baseof.html | ●●●●● patch | view | raw | blame | history | |
| layouts/single.html | ●●●●● patch | view | raw | blame | history |
.vscode/custom-dictionary.txt
@@ -1,6 +1,8 @@ Ananke demosite Disqus Errorf Kitchensink licenselink Philibert Philibert Warnf config/_default/params.toml
@@ -255,3 +255,6 @@ color = "#cd201f" profile = "https://www.youtube.com/@%s" icon = "youtube" # font awesome brand icon name [ananke.hooks] verbosity = "debug" # debug, warning, error layouts/_partials/func/hooks/collector-dump.html
New file @@ -0,0 +1,8 @@ {{- $scratch := page.Scratch.Get "dnb.hooks" -}} {{- partials.Include "func/hooks/debug-cli.html" (collections.Dictionary "message" "Hooks Collector") -}} {{- partials.Include "func/hooks/debug-cli.html" (collections.Dictionary "message" (printf "%#v" $scratch)) -}} {{/* {{ partials.Include "func/hooks/collector-dump.html" . }} @todo must use stored instead of stashed and must be post processed. */}} layouts/_partials/func/hooks/collector.html
New file @@ -0,0 +1,6 @@ {{ $scratch := page.Scratch.Get "ananke.hooks" }} {{ if eq $scratch "" }} {{ $scratch = slice }} {{ end }} {{- page.Scratch.Add "ananke.hooks" (slice .hook) -}} layouts/_partials/func/hooks/debug-cli.html
New file @@ -0,0 +1,60 @@ {{- $config := site.Params.ananke.hooks -}} {{/* $config.namespace $config.ignoreErrors $config.verbosity */}} {{/* @todo add and document hook verbosity suppression setting via config [ananke.hooks] verbosity = "warning" # debug, warning, error @todo add and document hook ignoreErrors setting via config */}} {{/* | Primary | `#AA99FF` | `170, 153, 255` | | Ananke | `#FF80BF` | `255, 128, 191` | | Comment | `#708CA9` | `112, 140, 169` | | Error | `#CC7766` | `204, 119, 102` | | Warning | `#CCCC66` | `204, 204, 102` | | Info | `#6ECC66` | `110, 204, 102` | */}} {{- $colourPrimary := "\033[38;2;170;153;255m" -}} {{- $colourAnanke := "\033[38;2;255;128;191m" -}} {{- $colourComment := "\033[38;2;112;140;169m" -}} {{- $colourError := "\033[38;2;204;119;102m" -}} {{- $colourWarning := "\033[38;2;204;204;102m" -}} {{- $colourInfo := "\033[38;2;110;204;102m" -}} {{- $colourReset := "\033[0m" -}} {{- if collections.In $config.ignoreErrors .slug -}} {{- return -}} {{- end -}} {{- $namespace := $config.namespace | compare.Default "ananke" -}} {{- $severity := .severity | compare.Default "info" -}} {{- $colourLevel := $colourInfo -}} {{- $severityLabel := "INFO" -}} {{- if compare.Eq $severity "warning" -}} {{- $colourLevel = $colourWarning -}} {{- $severityLabel = "WARN" -}} {{- else if compare.Eq $severity "error" -}} {{- $colourLevel = $colourError -}} {{- $severityLabel = "!ERR" -}} {{- end -}} {{- if collections.IsSet . "level" -}} {{- $level = (cast.ToInt .level) -}} {{- end -}} {{- if compare.Le $severity "error" -}} {{- fmt.Errorf (fmt.Printf "%s%s%s/%s%s %s%s%s" $colourAnanke $namespace $colourComment $colourLevel $severityLabel $colourComment .message $colourReset) -}} {{- else -}} {{- fmt.Warnf (fmt.Printf "%s%s%s/%s%s %s%s%s" $colourAnanke $namespace $colourComment $colourLevel $severityLabel $colourComment .message $colourReset) -}} {{- end -}} layouts/_partials/hook.html
New file @@ -0,0 +1,70 @@ {{- $context := collections.Dictionary -}} {{- $config := site.Params.ananke.hooks -}} {{- $colourHook := "\033[38;2;170;153;255m" -}} {{- $colourUnused := "\033[38;2;204;119;102m" -}} {{- $colourReset := "\033[0m" -}} {{- /* create context from extended or simple hook */ -}} {{- if reflect.IsMap . -}} {{- /* extended use case with map */ -}} {{- $context = collections.Merge $context . }} {{- $context = collections.Merge $context (collections.Dictionary "type" "full") }} {{ partials.Include "func/hooks/debug-cli.html" (collections.Dictionary "message" (fmt.Printf "%s>>> HOOK: %s%s" $colourHook $context.hook $colourReset)) }} {{ partials.Include "func/hooks/debug-cli.html" (collections.Dictionary "message" "hook is extended") }} {{- /* extended use case */ -}} {{- $context = collections.Merge $context . }} {{- $context = collections.Merge $context (collections.Dictionary "type" "full") }} {{- else -}} {{ partials.Include "func/hooks/debug-cli.html" (collections.Dictionary "message" (fmt.Printf "%s>>> HOOK: %s%s" $colourHook $context $colourReset)) }} {{ partials.Include "func/hooks/debug-cli.html" (collections.Dictionary "message" "hook is simple") }} {{- /* simple use case */ -}} {{- $context = collections.Merge $context (collections.Dictionary "hook" . "context" collections.Dictionary) -}} {{- $context = collections.Merge $context (collections.Dictionary "type" "simple") }} {{- end -}} {{/** $context.hook = hook name $context.cache = whether to cache the hook (optional, default: false, if used this is used as cache indicator) $context.context = context of the hook (e.g. page, section, etc.) $context.type = type of the hook (e.g. full, simple) context is empty for simple hooks **/}} {{- /* add hook to collector */ -}} {{- partials.Include "func/hooks/collector.html" (collections.Dictionary "hook" $context.hook "context" $context ) -}} {{- $loaded := false -}} {{- $partialName := fmt.Printf "hooks/%s.html" $context.hook -}} {{- $partialHook := fmt.Printf "_partials/%s" $partialName -}} {{ partials.Include "func/hooks/debug-cli.html" (collections.Dictionary "message" (fmt.Printf "partial Name: %s" $partialName)) }} {{- if templates.Exists $partialHook -}} {{- if compare.Eq true (.cached | compare.Default false) -}} {{- partials.IncludeCached $partialName $context.context -}} {{ partials.Include "func/hooks/debug-cli.html" (collections.Dictionary "message" "included") }} {{- $loaded = true -}} {{- else -}} {{- partials.Include $partialName $context.context -}} {{ partials.Include "func/hooks/debug-cli.html" (collections.Dictionary "message" "included uncached") }} {{- $loaded = true -}} {{- end -}} {{- end -}} {{- if compare.Eq $loaded false -}} {{- if not (collections.In $config.disable_messages "unused_hooks") -}} {{- partials.Include "func/hooks/debug-cli.html" (collections.Dictionary "message" (fmt.Printf "%s<<< HOOK `%s` %sunused%s" $colourHook $context.hook $colourUnused $colourReset) "context" . "severity" "info" ) -}} {{- end -}} {{ else }} {{ partials.Include "func/hooks/debug-cli.html" (collections.Dictionary "message" (fmt.Printf "%s<<< HOOK: %s done%s" $colourHook $context.hook $colourReset)) }} {{- end -}} layouts/_partials/hooks/article/section-link.html
New file @@ -0,0 +1,3 @@ <aside class="instapaper_ignoref b helvetica tracked ttu"> {{ .CurrentSection.Title }} </aside> layouts/baseof.html
@@ -78,4 +78,4 @@ </main> {{ block "footer" . }}{{ partials.IncludeCached "site-footer.html" . }}{{ end }} </body> </html> </html> layouts/single.html
@@ -17,13 +17,8 @@ <article class="{{ $post_class }} flex-l {{ if $needs_aside }}mw8{{ else }}mw7{{ end }} center ph3 flex-wrap justify-between"> <header class="mt4 w-100"> <aside class="instapaper_ignoref b helvetica tracked ttu"> {{/* CurrentSection allows us to use the section title instead of inferring from the folder. https://gohugo.io/variables/page/#section-variables-and-methods */}} {{ .CurrentSection.Title }} </aside> {{- partials.Include "hook.html" ( dict "hook" "article/section-link" "context" . ) -}} {{- partials.Include "hook.html" ( dict "hook" "article/section-link222" "context" . ) -}} {{- partials.IncludeCached "social/share.html" . . -}} <h1 class="f1 athelas mt3 mb1"> {{- .Title -}}