-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutil.html
More file actions
237 lines (212 loc) · 17.5 KB
/
Copy pathutil.html
File metadata and controls
237 lines (212 loc) · 17.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
{{define "effecter" -}}
{{$e := . -}}
{{$expcls := list (dict "Name" "Physical effects" "Effects" (list "stamina enhancement" "stimulation" "appetite enhancement" "increased libido" "bodily control enhancement" "sedation" "motor control loss" "orgasm suppression" "appetite suppression" "cough suppression" "pain relief" "decreased libido" "nausea suppression" "seizure suppression" "physical disconnection" "spontaneous physical movements" "spatial disorientation" "body odour alteration" "changes in felt gravity" "excessive yawning" "mouth numbing" "perception of bodily heaviness" "pupil dilation" "muscle relaxation" "physical autonomy" "physical euphoria" "pupil constriction" "bronchodilation" "laughter fits" "perception of bodily lightness" "changes in felt bodily form" "gait alteration" "bodily pressures" "dehydration" "water intoxication" "runny nose" "watery eyes" "teeth chattering" "difficulty urinating" "dry mouth" "restless legs" "increased perspiration" "muscle tension" "optical sliding" "respiratory depression" "teeth grinding" "vibrating vision" "shakiness" "frequent urination" "increased salivation" "skin flushing" "stomach cramp" "nausea" "vomiting" "muscle cramp" "physical fatigue" "back pain" "constipation" "diarrhea" "increased phlegm production" "itchiness" "muscle twitching" "photophobia" "stomach bloating" "temporary erectile dysfunction" "headache" "seizure" "serotonin syndrome" "increased bodily temperature" "brain zaps" "dizziness" "temperature regulation suppression" "decreased heart rate" "vasoconstriction" "increased heart rate" "vasodilation" "abnormal heartbeat" "increased blood pressure" "decreased blood pressure" ) "Matches" (list) ) -}}
{{range $es := $e -}}
{{$esp := lower $es | replace "_" " "}}
{{range $cl := $expcls -}}
{{$match := false}}
{{range .Effects -}}
{{if contains . $esp -}}
{{$match = true -}}
{{break -}}
{{- end}}
{{- end}}
{{if eq $match true -}}
{{$_ := set $cl "Matches" (append $cl.Matches $es)}}
{{break -}}
{{- end}}
{{- end}}
{{- end}}
<li><strong>Effects:</strong>{{range $cl := $expcls}}<ul class=trdeffects><li>{{$cl.Name}}</li><ul>{{range $cl.Matches}}<li>{{template "user" .}}</li>{{end}}</ul></ul>{{end -}}
{{- end}}
{{define "severity" -}}
<span class='severity-{{.}}'>{{.}}</span>
{{- end}}
{{define "rev" -}}
<span class=reverse>reverse</span>
{{- end}}
{{define "stime" -}}
{{. | replace "days" "d" | replace "day" "d" | replace "hours" "h" | replace "hour" "h" | replace "minutes" "m" | replace "minute" "m" | replace "seconds" "s" | replace "second" "s" | replace "-" " - " | replace "~" "~ "}}
{{- end}}
{{define "sl" -}}
{{if typeIs "dict" .}}{{template "sb" .}}{{else}}{{$st := printf "substituted/%s.json" . | replace " " "_"}}{{with fileExists $st}}{{template "sb" (include $st | fromJson)}}{{end}}{{end}}
{{- end}}
{{define "rco" -}}
{{initial . | join ", "}}{{if gt (len .) 1}} or {{end}}{{last .}}
{{- end}}
{{define "srco" -}}
{{with . | join "|" | stripHTML | splitList "|"}}<strong>{{initial . | join "</strong>, <strong>"}}</strong>{{if gt (len .) 1}} or <strong>{{last .}}</strong>{{else}}<strong>{{first .}}</strong>{{end}}{{end}}
{{- end}}
{{define "rcc" -}}
{{. | join ", "}}
{{- end}}
{{define "rce" -}}
<em>{{. | join "</em>, <em>"}}</em>
{{- end}}
{{define "rca" -}}
{{initial . | join ", "}}{{if gt (len .) 1}} and {{end}}{{last .}}
{{- end}}
{{define "rcad" -}}
{{initial . | join ", " | lower}}{{if gt (len .) 1}} and {{end}}{{last . | lower}}
{{- end}}
{{define "srca" -}}
{{with . | join "|" | stripHTML | splitList "|"}}<strong>{{initial . | join "</strong>, <strong>"}}</strong>{{if gt (len .) 1}} and {{end}}<strong>{{last .}}</strong>{{end}}
{{- end}}
{{define "lrca" -}}
{{$prefix := .prefix}}{{$list := list}}{{range .list}}{{$list = append $list (printf "<a href='/%s/%s'>%s</a>" $prefix (pathEscape . | lower) (lower .))}}{{end}}{{template "rca" $list}}
{{- end}}
{{define "rcal" -}}
{{$ns := len .}}{{range $i, $name := .}}{{if eq $i 0 | not}}{{if sub $ns 1 | eq $i | not}}, {{else}} and {{end}}{{end}}<a href='/substance/{{pathEscape (lower $name)}}'>{{$name}}</a>{{end}}
{{- end}}
{{define "ref" -}}
<a href="#cite_note-{{.}}"><sup>[{{.}}]</sup></a>
{{- end}}
{{define "refi" -}}
<a href=#cite_note-{{.RefCount}}><sup>[{{.RefCount}}]</sup></a>{{$_ := set . "RefCount" (add1 .RefCount)}}{{$_ := set . "Refs" (append .Refs .RefCur)}}
{{- end}}
{{define "refg" -}}
{{$v := .}}{{range $refi, $ref := $v.refs}}{{if $ref | lower | contains $v.grep}}{{template "ref" (add1 $refi)}}{{break}}{{end}}{{end}}
{{- end}}
{{define "tree" -}}
{{$stn := .}}{{$st := fromJson (include (printf "/substituted/%s.json" ($stn | replace " " "_")))}}{{template "sb" $st}}{{if $st.Children}}<ul style="margin-left: 1.0em;">{{range sortAlpha $st.Children}}<li>{{template "tree" .}}</li>{{end}}</ul>{{end}}
{{- end}}
{{define "exnd" -}}
[<label><input name=CollapseCheck type="checkbox" class='{{if eq . "all"}}expand{{else}}collapse{{end}}'></label>]
{{- end}}
{{define "cexnd" -}}
{{template "exnd" "all"}}
{{- end}}
{{define "pexnd" -}}
<span class=collapseButton style="padding-left: 10px; margin-bottom: 0px;"> [<label><input name="CollapseCheck" type="checkbox" class="collapse"></label>]</span>
{{- end}}
{{define "rexnd" -}}
<span class="collapseButton float-right"> [<label><input name=CollapseCheck type="checkbox" class='{{if eq . "all"}}expand{{else}}collapse{{end}}'></label>]</span>
{{- end}}
{{define "rimgbox" -}}
<table style="margin-bottom: 0.5em;"><!--<table style="float: right; clear: right; max-width: 300px; margin: 0.5em 0 0 1em;">--><tr><td class=InfoboxImage style="background-color: {{if .background}}{{.background}}{{else}}white{{end}};"><img style="height: 100%;{{if .width}}width: {{.width}};{{end}} {{if .padding}}padding: {{.padding}};{{end}} max-width: 300px;" src="{{.src}}"></td></tr>{{with .desc}}<tr><td class=InfoboxData><span style="background-color: var(--background-color-base);">{{template "user" .}}</span></td></tr>{{end}}</table>
{{- end}}
<div style="max-width: 258px;" class=Infobox>
{{define "imgbox" -}}
<div class="infobox float-right">{{template "rimgbox" .}}</div>
{{- end}}
</div>
{{define "lpr" -}}
<a{{with .cls}} class={{.}}{{end}} href={{printf "%s%s/%s" (hasPrefix "http" .pre | ternary " " "/") (.pre | replace " " "_") (.src | replace " " "_" | trimPrefix "/" )}}>{{.alias}}</a>
{{- end}}
{{define "lu" -}}
{{template "lpr" (kindIs "string" . | ternary (dict "alias" . "src" .) . | merge (dict "pre" "user"))}}
{{- end}}
{{define "lc" -}}
{{template "lpr" (kindIs "string" . | ternary (dict "alias" . "src" .) . | merge (dict "pre" "class"))}}
{{- end}}
{{define "lsb" -}}
{{template "lpr" (kindIs "string" . | ternary (dict "alias" . "src" .) . | merge (dict "pre" "substituted"))}}
{{- end}}
{{define "lsu" -}}
{{template "lpr" (kindIs "string" . | ternary (dict "alias" . "src" .) . | merge (dict "pre" "substance"))}}
{{- end}}
{{define "lsa" -}}
{{template "lpr" (kindIs "string" . | ternary (dict "alias" . "src" .) . | merge (dict "pre" "salt"))}}
{{- end}}
{{define "lroa" -}}
{{template "lpr" (kindIs "string" . | ternary (dict "alias" . "src" .) . | merge (dict "pre" "administration"))}}
{{- end}}
{{define "wkp" -}}
{{template "lpr" (kindIs "string" . | ternary (dict "alias" . "src" .) . | merge (dict "cls" "logo" "pre" "https://en.wikipedia.org/wiki"))}}
{{- end}}
{{define "xeff" -}}
{{if not (kindIs "string" .)}}<a class=logo href=https://www.effectindex.com/effects/{{pathEscape .src}}>{{.alias}}</a>{{else}}<a class=logo href=https://www.effectindex.com/effects/{{kebabcase .}}>{{.}}</a>{{end}}
{{- end}}
{{define "ieff" -}}
{{if not (kindIs "string" .)}}<a href=/effect/{{pathEscape .src}}>{{.alias}}</a>{{else}}<a href=/effect/{{kebabcase .}}>{{.}}</a>{{end}}
{{- end}}
{{define "sb" -}}
{{$subst := "Substituted"}}{{if .Position}}{{$subst = printf "%s-Substituted" .Position}}{{end}}{{template "lpr" (dict "src" (.Name | lower) "alias" (hasSuffix "x" .Name | ternary "es" "s" | printf "%s %s%s" $subst .Name) "pre" "substituted")}}{{if .Abr}}{{if typeIs "string" .Abr}}{{printf " (%s)" .Abr}}{{else}}{{end}}{{end}}
{{- end}}
{{define "user" -}}
{{- $out := html . }}
{{- range list "b" "p" "ul" "s" "i" "br" "sub"}}
{{- $out = ($out | replace (printf "{%s}" .) (printf "<%s>" .) | replace (printf "{E%s}" .) (printf "</%s>" .))}}
{{- end}}
{{- $out = (regexReplaceAll `\*([^*]+)\*` $out `<em>${1}</em>`) }}
{{- range $org := regexFindAll `\{xeff\s+'[^&]+'\}` $out -1 -}}
{{$src := regexReplaceAll `\{xeff\s+'([^&]+)'\}` $org `${1}` -}}
{{$new := printf `<a class=logo href='https://www.effectindex.com/effects/%s'>%s</a>` ($src | replace " " "-") ($src | replace "-" " ") -}}
{{$out = $out | replace $org $new -}}
{{end -}}
{{- range list (list "a" "a" "/") (list "sub" "a" "/substance/" ) (list "wkp" "a" "https://en.wikipedia.org/wiki/" "logo") (list "roa" "a" "/administration/") (list "subst" "a" "/substituted/") (list "class" "a" "/class/") (list "user" "a" "/user/" ) (list "xeff" "a" "https://www.effectindex.com/effects/" "logo") (list "ieff" "a" "/effect/")}}
{{- $class := "" -}}
{{if len . | eq 4 -}}
{{$class = last . | printf "class=%s " -}}
{{end -}}
{{$out = (printf `<%s %shref='%s${1}'>${2}</%s>` (rest . | first) $class (rest . | rest | first) (rest . | first) ) | regexReplaceAll (first . | printf `\{%s\s+'([^&]+)'\s+'([^&]+)'\}`) $out -}}
{{$out = (printf `<%s %shref='%s${1}'>${1}</%s>` (rest . | first) $class (rest . | rest | first) (rest . | first) ) | regexReplaceAll (first . | printf `\{%s\s+'([^&]+)'\}`) $out -}}
{{end -}}
{{range list "gt" "lt" "apos" -}}
{{- $out = (replace (printf "{%s}" .) (printf "&%s;" .) $out) -}}
{{end -}}
{{$out = regexReplaceAll `\{sev\s+'([^&#]+)'\}` $out `<span class='severity-${1}'>${1}</span>` -}}
{{$out = regexReplaceAll `\{rev\}` $out `<span class=reverse>reverse</span>` -}}
{{$out -}}
{{end}}
{{define "stripuser" -}}
{{- $out := html . }}
{{- range list "b" "p" "ul" "s" "i" "br" "sub"}}
{{- $out = ($out | replace (printf "{%s}" .) (printf "<%s>" .) | replace (printf "{E%s}" .) (printf "</%s>" .))}}
{{- end}}
{{- $out = (regexReplaceAll `\*([^*]+)\*` $out `<em>${1}</em>`) }}
{{- range list (list "a" "a" "/") (list "sub" "a" "/substance/" ) (list "wkp" "a" "https://en.wikipedia.org/wiki/" "logo") (list "roa" "a" "/administration/") (list "subst" "a" "/substituted/") (list "class" "a" "/class/") (list "user" "a" "/user/" ) (list "xeff" "a" "https://www.effectindex.com/effects/" "logo") (list "ieff" "a" "/effect/")}}
{{- $class := "" -}}
{{if len . | eq 4 -}}
{{$class = last . | printf "class=%s " -}}
{{end -}}
{{$out = (printf `<%s %shref='%s${1}'>${2}</%s>` (rest . | first) $class (rest . | rest | first) (rest . | first) ) | regexReplaceAll (first . | printf `\{%s\s+'([^&#]+)'\s+'([^&#]+)'\}`) $out -}}
{{$out = (printf `<%s %shref='%s${1}'>${1}</%s>` (rest . | first) $class (rest . | rest | first) (rest . | first) ) | regexReplaceAll (first . | printf `\{%s\s+'([^&#]+)'\}`) $out -}}
{{end -}}
{{range list "gt" "lt" "apos" -}}
{{- $out = (replace (printf "{%s}" .) (printf "&%s;" .) $out) -}}
{{end -}}
{{$out = regexReplaceAll `\{sev\s+'([^&#]+)'\}` $out `<span class='severity-${1}'>${1}</span>` -}}
{{$out | stripHTML | replace "<" "<" | replace ">" ">" -}}
{{end}}
{{define "whint" -}}
{{if eq .hint "wiki"}}{{template "wkp" .user}}{{else}}{{.user}}{{end}}
{{- end}}
{{/*{{define "help"}}you are not alone, you will get through this, you are loved, even if only by me, run if you need to run.{{end}}*/}}
{{define "input" -}}
<input type=text min=1 id="Form{{.f}}" name="Form{{.f}}" class=FormField placeholder="{{default .d .v}}" value="{{default .d .v}}"></input>
{{- end}}
{{define "froa"}}{{$roa := .}}{{$rn := "" -}}
{{if kindIs "spring" $roa}}{{$rn = $roa -}}
{{else -}}{{with $roa.Name}}
{{$rn = default "" (. | title) -}}
{{with $roa.Dosage}}{{$rn = printf "%s (%s)" ($roa.Name | title) (. | replace "-" " - " | replace "~" "~ ")}}{{end}}{{end -}}
{{end}}{{$rn}}
{{- if or $roa.Onset $roa.Comeup $roa.Duration}}<div class=times>{{with $roa.Onset}}<div class=time style="flex-grow: 2; border-bottom: 1px solid cyan;"><strong>Onset:</strong> {{template "stime" .}}</div>{{end}}{{with $roa.Comeup}}<div class=time style="flex-grow: 2; border-bottom: 1px solid yellow;"><strong>Comeup:</strong> {{template "stime" .}}</div>{{end}}<div class=time style="{{if or $roa.Onset $roa.Comeup}}max-width: 50%;{{end}} border-bottom: 1px solid orange; flex-grow: 3;"><div><strong>Duration:</strong> {{with $roa.Duration}}{{template "stime" .}}{{else}}?{{end}}</div></div>{{end}}{{end}}
{{define "fnoterow"}}{{$v := .v -}}
{{with $utrd := .utrd -}}
<div class=collapser><table class=trd {{if contains "user" $v.Prefix | not}} style="width: calc(100vw - 400px);"{{end}}><tr><th colspan=2 class=InfoboxLabel>{{if contains "user" $v.Prefix | not -}}
<a contenteditable={{$v.Editable}} href='/user/{{$utrd.User}}'>{{$utrd.User}}</a> / {{end}}{{if contains "substance" $v.Prefix}}<strong>{{$utrd.trd.Name}}</strong>{{else -}}
<a contenteditable={{$v.Editable}} class=trdname href='/{{if $utrd.trd.Composite}}composite{{else}}substance{{end}}/{{$utrd.trd.Name}}'>{{$utrd.trd.Name}}</a>{{end}}{{template "rexnd" $v.Collapse -}}
</th></tr><div class=collapserContent><tr>{{if contains "user" $v.Prefix}}<td class=svg {{if and (printf "/structure/%s.svg" (lower $utrd.trd.Name | replace " " "_") | fileExists | not) (printf "/structure/%s.jpg" (lower $utrd.trd.Name | replace " " "_") | fileExists | not) -}} style="display: none;"{{end}}><img class=trdimg src='/structure/{{lower $utrd.trd.Name | replace " " "_"}}{{if printf "/structure/%s.svg" (lower $utrd.trd.Name | replace " " "_") | fileExists}}.svg{{else if printf "/structure/%s.jpg" (lower $utrd.trd.Name | replace " " "_") | fileExists}}.jpg{{else}}{{end}}' /></td>{{end}}<td style="vertical-align: top">
{{- if empty $utrd.trd.Routes | not}}<strong>Routes:</strong><ul class=trdroutes>{{range $utrd.trd.Routes -}}
<li><span class=keepclip contenteditable={{$v.Editable}}>{{template "froa" .}}</span></li>{{end}}</ul>{{else if eq $v.Editable "true"}}<strong>Routes:</strong><ul class=trdroutes><li contenteditable=true></li></ul>{{end -}}
{{with $utrd.trd.Dosages -}}
at {{template "srca" . -}}
{{end -}}
{{with $utrd.trd.Salts -}}<strong>Salts:</strong><ul class=trdsalts>{{range . -}}
<li>{{title .}}</li>{{end}}</ul>{{else}}{{if eq $v.Editable "true"}}<strong>Salts:</strong><ul class=trdsalts><li contenteditable=true></li></ul>{{end}}{{end -}}
{{with $utrd.trd.Sources}}<strong>Source:</strong><ul class=trdsource>{{range .}}<li><span class=keepclip contenteditable={{$v.Editable}}>{{.}}</span></li>{{end}}</ul>{{else}}{{if eq $v.Editable "true"}}<strong>Source:</strong><ul class=trdsource><li contenteditable=true></li></ul>{{end}}{{end -}}
{{with $utrd.trd.Indication}}<strong>Indication:</strong><ul>{{if kindIs "string" .}}<li><span contenteditable={{$v.Editable}}>{{template "user" .}}</span></li>{{else}}{{range .}}<li><span contenteditable={{$v.Editable}}>{{template "user" .}}</span></li>{{end}}{{end}}</ul>{{end -}}
{{with $utrd.trd.Effects}}<strong>Effects:</strong><ul class=trdeffects>{{range .}}<li><span class=keepclip contenteditable={{$v.Editable}}>{{if eq $v.Editable "true"}}{{.}}{{else}}{{template "user" .}}{{end}}</span></li>{{end}}{{if not $utrd.trd.Adverse}}</ul>{{end}}{{end -}}
{{with $utrd.trd.Adverse}}{{if not $utrd.trd.Effects}}<strong>Effects:</strong><ul>{{end}}{{range .}}<li><span class=keepclip contenteditable={{$v.Editable}}>{{if eq $v.Editable "true"}}{{.}}{{else}}{{template "user" .}}{{end}}</span></li>{{end}}</ul>{{end -}}
{{with $utrd.trd.DEffects}}{{if not $utrd.trd.Effects}}<strong>Effects:</strong>{{end}}<ul>{{range $d := .}}<li><strong>{{with $d.Route}}{{.}}{{if $d.Dose}} {{end}}{{end}}{{with $d.Dose}}{{.}}{{end}}</strong></li><ul>{{range .Effects}}<li><span class=keepclip contenteditable={{$v.Editable}}>{{if eq $v.Editable "true"}}{{.}}{{else}}{{template "user" .}}{{end}}</span></li>{{end}}</ul></li>{{end}}</ul>{{end -}}
{{if and (eq $v.Editable "true") (not $utrd.trd.Effects) (not $utrd.trd.Adverse) (not $utrd.trd.DEffects)}}<strong>Effects:</strong><ul class=trdeffects><li contenteditable=true></li></ul>{{end -}}
{{with $utrd.trd.After}}<strong>After Effects:</strong><ul>{{range .}}<li><span class=keepclip contenteditable={{$v.Editable}}>{{if eq $v.Editable "true"}}{{.}}{{else}}{{template "user" .}}{{end}}</span></li>{{end}}</ul>{{end -}}
{{with $utrd.trd.Odor}}<strong>Odor:</strong><ul class=trdodor>{{if kindIs "string" .}}<li><span contenteditable={{$v.Editable}}>{{if eq $v.Editable "true"}}{{.}}{{else}}{{template "user" .}}{{end}}</span></li>{{else}}{{range .}}<li><span contenteditable={{$v.Editable}}>{{if eq $v.Editable "true"}}{{.}}{{else}}{{template "user" .}}{{end}}</span></li>{{end}}{{end}}</ul>{{else}}{{if eq $v.Editable "true"}}<strong>Odor:</strong><ul class=trdodor><li contenteditable=true></li></ul>{{end}}{{end -}}
{{with $utrd.trd.Notes}}<strong>Notes:</strong><ul class=trdnotes>{{if kindIs "string" .}}<li><span contenteditable={{$v.Editable}}>{{if eq $v.Editable "true"}}{{.}}{{else}}{{template "user" .}}{{end}}</span></li>{{else}}{{range .}}<li><span contenteditable={{$v.Editable}}>{{if eq $v.Editable "true"}}{{.}}{{else}}{{template "user" .}}{{end}}</span></li>{{end}}{{end}}</ul>{{else}}{{if eq $v.Editable "true"}}<strong>Notes:</strong><ul class=trdnotes><li contenteditable=true></li></ul>{{end}}{{end -}}
</td></tr></div></table></div>{{end -}}
{{end}}
{{define "logo" -}}
<span style="word-break: keep-all; font-family: Inter, sans-serif; font-weight: 600;">Anodyne<span style="font-weight: 200">Wiki</span></span>
{{- end}}