Fix: login/signup forms. Update: code formating

This commit is contained in:
hyzen
2026-06-04 23:38:05 +05:30
parent cb0d929f7a
commit 16255bb690
63 changed files with 1544 additions and 1146 deletions

View File

@@ -1,99 +1,52 @@
{{ define "main" }}
{{ $semesterRaw := .Params.semester }}
{{ $subjectcodeRaw := .Params.subjectcode }}
{{ $semester := "" }}
{{ if reflect.IsSlice $semesterRaw }}
{{ $semester = index $semesterRaw 0 }}
{{ else }}
{{ $semester = $semesterRaw }}
{{ end }}
{{ $subjectcode := "" }}
{{ if reflect.IsSlice $subjectcodeRaw }}
{{ $subjectcode = index $subjectcodeRaw 0 }}
{{ else }}
{{ $subjectcode = $subjectcodeRaw }}
{{ end }}
{{ define "main" }} {{ $semesterRaw := .Params.semester }} {{ $subjectcodeRaw := .Params.subjectcode
}} {{ $semester := "" }} {{ if reflect.IsSlice $semesterRaw }} {{ $semester = index $semesterRaw 0
}} {{ else }} {{ $semester = $semesterRaw }} {{ end }} {{ $subjectcode := "" }} {{ if
reflect.IsSlice $subjectcodeRaw }} {{ $subjectcode = index $subjectcodeRaw 0 }} {{ else }} {{
$subjectcode = $subjectcodeRaw }} {{ end }}
<nav class="uninotes-breadcrumbs breadcrumbs">
<a href="/uninotes/">UniNotes</a>
{{ if $semester }}
{{ $semPage := site.GetPage (printf "/semester/%s" ($semester | urlize)) }}
{{ if $semPage }}
<a href="{{ $semPage.RelPermalink }}">{{ $semester }}</a>
{{ end }}
{{ end }}
{{ if $subjectcode }}
{{ $subPage := site.GetPage (printf "/subjectcode/%s" ($subjectcode | urlize)) }}
{{ if $subPage }}
<a href="{{ $subPage.RelPermalink }}">{{ $subjectcode }}</a>
{{ end }}
{{ end }}
<a href="{{ .Params.uniturl }}">{{ .Params.unit | default .Title }}</a>
<span>{{ .Params.notecategory | default "Notes" }}</span>
<a href="/uninotes/">UniNotes</a>
{{ if $semester }} {{ $semPage := site.GetPage (printf "/semester/%s" ($semester | urlize)) }}
{{ if $semPage }} <a href="{{ $semPage.RelPermalink }}">{{ $semester }}</a> {{ end }} {{ end
}} {{ if $subjectcode }} {{ $subPage := site.GetPage (printf "/subjectcode/%s" ($subjectcode |
urlize)) }} {{ if $subPage }} <a href="{{ $subPage.RelPermalink }}">{{ $subjectcode }}</a> {{
end }} {{ end }} <a href="{{ .Params.uniturl }}">{{ .Params.unit | default .Title }}</a>
<span>{{ .Params.notecategory | default "Notes" }}</span>
</nav>
<div class="uninotes-meta">
{{ with $semester }}<span class="uninotes-meta__pill">{{ . }}</span>{{ end }}
{{ with $subjectcode }}<span class="uninotes-meta__pill">{{ . }}</span>{{ end }}
{{ with .Params.notecategory }}
<span class="uninotes-meta__pill uninotes-meta__pill--{{ . | lower }}">{{ . }}</span>
{{ end }}
{{ with $semester }}<span class="uninotes-meta__pill">{{ . }}</span>{{ end }} {{ with
$subjectcode }}<span class="uninotes-meta__pill">{{ . }}</span>{{ end }} {{ with
.Params.notecategory }}
<span class="uninotes-meta__pill uninotes-meta__pill--{{ . | lower }}">{{ . }}</span>
{{ end }}
</div>
<h1>{{ .Params.unit | default .Title }}</h1>
{{ partial "page/toc.html" . }}
{{ .Content }}
{{ partial "page/terms.html" (dict "taxonomy" "tags" "page" .) }}
{{ partial "page/terms.html" (dict "taxonomy" "categories" "page" .) }}
{{/* Next/prev among sibling UNITS in the same subjectcode — sorted numerically */}}
{{ if $subjectcode }}
{{ $subPage := site.GetPage (printf "/subjectcode/%s" ($subjectcode | urlize)) }}
{{ if $subPage }}
{{/* Build deduplicated unit list with numeric sort key */}}
{{ $seenUnits := slice }}
{{ $unitDicts := slice }}
{{ range $subPage.Pages }}
{{ $unitLabel := (.Params.unit | default .Title) }}
{{ if not (in $seenUnits $unitLabel) }}
{{ $seenUnits = $seenUnits | append $unitLabel }}
{{/* Extract unit number for numeric sort, e.g. "Unit 11" → 11 */}}
{{ $uParts := split $unitLabel " " }}
{{ $uLast := index $uParts (sub (len $uParts) 1) }}
{{ $uNumStr := "" }}
{{ range (split $uLast "") }}
{{ if ge . "0" }}{{ if le . "9" }}{{ $uNumStr = printf "%s%s" $uNumStr . }}{{ end }}{{ end }}
{{ end }}
{{ $uNum := int ($uNumStr | default "0") }}
{{ $unitDicts = $unitDicts | append (dict "label" $unitLabel "page" . "num" $uNum) }}
{{ end }}
{{ end }}
{{ $sortedUnitDicts := sort $unitDicts "num" }}
{{ $currentUnit := (.Params.unit | default .Title) }}
{{ $currentIdx := 0 }}
{{ range $i, $d := $sortedUnitDicts }}
{{ if eq $d.label $currentUnit }}{{ $currentIdx = $i }}{{ end }}
{{ end }}
{{ if gt (len $sortedUnitDicts) 1 }}
<nav class="page-nav">
{{ if gt $currentIdx 0 }}
{{ $prev := (index $sortedUnitDicts (sub $currentIdx 1)) }}
<a class="page-nav__previous-link" href="{{ $prev.page.Params.uniturl }}">← {{ $prev.label }}</a>
{{ end }}
{{ if lt $currentIdx (sub (len $sortedUnitDicts) 1) }}
{{ $next := (index $sortedUnitDicts (add $currentIdx 1)) }}
<a class="page-nav__next-link" href="{{ $next.page.Params.uniturl }}">{{ $next.label }} →</a>
{{ end }}
</nav>
{{ end }}
{{ end }}
{{ end }}
{{ partial "page/page-end.html" . }}
{{ end }}
{{ partial "page/toc.html" . }} {{ .Content }} {{ partial "page/terms.html" (dict "taxonomy" "tags"
"page" .) }} {{ partial "page/terms.html" (dict "taxonomy" "categories" "page" .) }} {{/* Next/prev
among sibling UNITS in the same subjectcode — sorted numerically */}} {{ if $subjectcode }} {{
$subPage := site.GetPage (printf "/subjectcode/%s" ($subjectcode | urlize)) }} {{ if $subPage }}
{{/* Build deduplicated unit list with numeric sort key */}} {{ $seenUnits := slice }} {{ $unitDicts
:= slice }} {{ range $subPage.Pages }} {{ $unitLabel := (.Params.unit | default .Title) }} {{ if not
(in $seenUnits $unitLabel) }} {{ $seenUnits = $seenUnits | append $unitLabel }} {{/* Extract unit
number for numeric sort, e.g. "Unit 11" → 11 */}} {{ $uParts := split $unitLabel " " }} {{ $uLast :=
index $uParts (sub (len $uParts) 1) }} {{ $uNumStr := "" }} {{ range (split $uLast "") }} {{ if ge .
"0" }}{{ if le . "9" }}{{ $uNumStr = printf "%s%s" $uNumStr . }}{{ end }}{{ end }} {{ end }} {{
$uNum := int ($uNumStr | default "0") }} {{ $unitDicts = $unitDicts | append (dict "label"
$unitLabel "page" . "num" $uNum) }} {{ end }} {{ end }} {{ $sortedUnitDicts := sort $unitDicts "num"
}} {{ $currentUnit := (.Params.unit | default .Title) }} {{ $currentIdx := 0 }} {{ range $i, $d :=
$sortedUnitDicts }} {{ if eq $d.label $currentUnit }}{{ $currentIdx = $i }}{{ end }} {{ end }} {{ if
gt (len $sortedUnitDicts) 1 }}
<nav class="page-nav">
{{ if gt $currentIdx 0 }} {{ $prev := (index $sortedUnitDicts (sub $currentIdx 1)) }}
<a class="page-nav__previous-link" href="{{ $prev.page.Params.uniturl }}"
>← {{ $prev.label }}</a
>
{{ end }} {{ if lt $currentIdx (sub (len $sortedUnitDicts) 1) }} {{ $next := (index
$sortedUnitDicts (add $currentIdx 1)) }}
<a class="page-nav__next-link" href="{{ $next.page.Params.uniturl }}">{{ $next.label }} →</a>
{{ end }}
</nav>
{{ end }} {{ end }} {{ end }} {{ partial "page/page-end.html" . }} {{ end }}

View File

@@ -1,4 +1,5 @@
{{ define "main" }}
{{/* Get semester and subjectcode from child pages since _index.md doesn't carry taxonomy params */}}
{{ $semester := "" }}
{{ $subjectcode := "" }}
@@ -12,6 +13,7 @@
{{ $subjectcode = cond (reflect.IsSlice $raw) (index $raw 0) $raw }}
{{ end }}
{{ end }}
<nav class="uninotes-breadcrumbs breadcrumbs">
<a href="/uninotes/">UniNotes</a>
{{ if $semester }}
@@ -28,36 +30,32 @@
{{ end }}
<span>{{ .Params.unit | default .Title }}</span>
</nav>
<div class="uninotes-meta">
{{ with $semester }}<span class="uninotes-meta__pill">{{ . }}</span>{{ end }}
{{ with $subjectcode }}<span class="uninotes-meta__pill">{{ . }}</span>{{ end }}
</div>
<h1>{{ .Params.unit | default .Title }}</h1>
<p class="unit-choice__subtitle">Choose type:</p>
{{/* Check if self/live pages exist */}}
{{ $hasSelf := false }}
{{/* Check if a live page exists at the expected URL */}}
{{ $hasLive := false }}
{{ range .Pages }}
{{ if eq (lower .Params.notecategory) "self" }}{{ $hasSelf = true }}{{ end }}
{{ if eq (lower .Params.notecategory) "live" }}{{ $hasLive = true }}{{ end }}
{{ end }}
<div class="unit-choice__options">
{{ if $hasSelf }}
<a class="unit-choice__card unit-choice__card--self" href="{{ .RelPermalink }}self/">
{{ else }}
<div class="unit-choice__card unit-choice__card--self unit-choice__card--unavailable">
{{ end }}
<div class="unit-choice__icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="32" height="32" fill="currentColor">
<path d="M12 3L1 9l4 2.18v6L12 21l7-3.82v-6l2-1.09V17h2V9L12 3zm6.82 6L12 12.72 5.18 9 12 5.28 18.82 9zM17 15.99l-5 2.73-5-2.73v-3.72L12 15l5-2.73v3.72z"/>
</svg>
</div>
<div class="unit-choice__label">Self</div>
<div class="unit-choice__desc">
{{ if $hasSelf }}Self-study notes
{{ else }}Not available{{ end }}
</div>
{{ if $hasSelf }}</a>{{ else }}</div>{{ end }}
<div class="unit-choice__desc">Self-study notes</div>
</a>
{{ if $hasLive }}
<a class="unit-choice__card unit-choice__card--live" href="{{ .RelPermalink }}live/">
@@ -76,4 +74,5 @@
</div>
{{ if $hasLive }}</a>{{ else }}</div>{{ end }}
</div>
{{ end }}