- {{template "interwiki map"}}
{{$emojies := .Emojies}}
- {{if len .Entries}}
-
- {{range $i, $wiki := .Entries}}
+{{define "static map"}}{{$emojies := .Emojies}}
+ {{if len .Entries}}
+
+ {{range $i, $wiki := .Entries}}
-
- Names
- {{range .Names}}- {{.}}
{{end}}
+ {{range .Names}}- {{.}}
{{end}}
- Description
- {{.Description}}
@@ -21,14 +19,68 @@
- URL
- {{.URL}}
- - Link format
- - {{.LinkFormat}}
+ - Link href format
+ - {{.LinkHrefFormat}}
+
+ - Img src format
+ - {{.ImgSrcFormat}}
- {{end}}
-
+ {{end}}
+
+ {{else}}
+ No interwiki map set.
+ {{end}}
+{{end}}
+
+{{define "authorized map"}}
+ {{if .Error}}
+ {{.Error}}
+ {{end}}
+ {{template "static map" .}}
+
+{{end}}
+
+{{define "body"}}
+
+ {{template "interwiki map"}}
+ {{if .CanEdit}}
+ {{template "authorized map" .}}
{{else}}
- No interwiki map set.
+ {{template "static map" .}}
{{end}}
{{end}}
\ No newline at end of file
diff --git a/interwiki/web.go b/interwiki/web.go
index 21c4a14..7ced6cd 100644
--- a/interwiki/web.go
+++ b/interwiki/web.go
@@ -29,6 +29,7 @@ type interwikiData struct {
// Emojies contains emojies that represent wiki engines. Emojies[i] is an emoji for Entries[i].Engine
Emojies []string
CanEdit bool
+ Error string
}
func viewInterwiki(meta viewutil.Meta) {
@@ -37,6 +38,7 @@ func viewInterwiki(meta viewutil.Meta) {
Entries: theMap.list,
Emojies: emojiesForEngines(theMap.list),
CanEdit: meta.U.Group == "admin",
+ Error: "",
})
}
diff --git a/interwiki/wiki.go b/interwiki/wiki.go
index a2b33e0..87603c7 100644
--- a/interwiki/wiki.go
+++ b/interwiki/wiki.go
@@ -11,21 +11,20 @@ type WikiEngine int
const (
Mycorrhiza WikiEngine = iota
- OddMuse
- MediaWiki
- MoinMoin1
- MoinMoin2
- DokuWiki
+ Agora
// Generic is any website.
Generic
)
// EmojiWithName returns a Unicode emoji that kinda represents the engine and the engine name. One day we might move to actual images. OK for now.
+// TODO: reconsider
func (we WikiEngine) EmojiWithName() string {
switch we {
case Mycorrhiza:
return "๐ Mycorrhiza"
- case OddMuse:
+ case Agora:
+ return "แผ Agora"
+ /*case OddMuse: Might return them in the future
return "๐ซ OddMuse"
case MediaWiki:
return "๐ป MediaWiki"
@@ -34,7 +33,7 @@ func (we WikiEngine) EmojiWithName() string {
case MoinMoin2:
return "โ๏ธ MoinMoin 2.*"
case DokuWiki:
- return "๐ DokuWiki"
+ return "๐ DokuWiki"*/
default:
return "๐ Generic"
}
@@ -67,11 +66,7 @@ type Wiki struct {
var wikiEnginesLookup = map[string]WikiEngine{
"mycorrhiza": Mycorrhiza,
- "oddmuse": OddMuse,
- "mediawiki": MediaWiki,
- "moin1": MoinMoin1,
- "moin2": MoinMoin2,
- "dokuwiki": DokuWiki,
+ "agora": Agora,
"generic": Generic,
}
diff --git a/static/default.css b/static/default.css
index 518d270..26e52ee 100644
--- a/static/default.css
+++ b/static/default.css
@@ -865,4 +865,21 @@ dt {
}
dd + dt {
margin-top: .5rem;
+}
+
+/*
+ * Interwiki page
+ * A possible improvement: show those two fields when Generic is selected, hide otherwise
+ */
+body[data-rrh-addr^="/interwiki"] label,
+body[data-rrh-addr^="/interwiki"] input[type="text"],
+body[data-rrh-addr^="/interwiki"] input[type="url"] {
+ display: block;
+ width: 100%;
+ max-width: 20rem;
+}
+.required-field::after {
+ color: red;
+ content: "*";
+ margin-left: .25rem;
}
\ No newline at end of file