Interwiki: Add the add entry form
This commit is contained in:
parent
5e2c20c559
commit
ee9602c745
@ -1,9 +1,7 @@
|
|||||||
{{define "interwiki map"}}Interwiki map{{end}}
|
{{define "interwiki map"}}Interwiki map{{end}}
|
||||||
{{define "title"}}{{template "interwiki map"}}{{end}}
|
{{define "title"}}{{template "interwiki map"}}{{end}}
|
||||||
|
|
||||||
{{define "body"}}
|
{{define "static map"}}{{$emojies := .Emojies}}
|
||||||
<main class="main-width">
|
|
||||||
<h1>{{template "interwiki map"}}</h1>{{$emojies := .Emojies}}
|
|
||||||
{{if len .Entries}}
|
{{if len .Entries}}
|
||||||
<ul>
|
<ul>
|
||||||
{{range $i, $wiki := .Entries}}
|
{{range $i, $wiki := .Entries}}
|
||||||
@ -21,8 +19,11 @@
|
|||||||
<dt>URL</dt>
|
<dt>URL</dt>
|
||||||
<dd><a href="{{.URL}}">{{.URL}}</a></dd>
|
<dd><a href="{{.URL}}">{{.URL}}</a></dd>
|
||||||
|
|
||||||
<dt>Link format</dt>
|
<dt>Link href format</dt>
|
||||||
<dd>{{.LinkFormat}}</dd>
|
<dd>{{.LinkHrefFormat}}</dd>
|
||||||
|
|
||||||
|
<dt>Img src format</dt>
|
||||||
|
<dd>{{.ImgSrcFormat}}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</li>
|
</li>
|
||||||
{{end}}
|
{{end}}
|
||||||
@ -30,5 +31,56 @@
|
|||||||
{{else}}
|
{{else}}
|
||||||
<p>No interwiki map set.</p>
|
<p>No interwiki map set.</p>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{define "authorized map"}}
|
||||||
|
{{if .Error}}
|
||||||
|
<p class="error">{{.Error}}</p>
|
||||||
|
{{end}}
|
||||||
|
{{template "static map" .}}
|
||||||
|
<form method="post" action="/interwiki/add-entry">
|
||||||
|
<h2>Add interwiki entry</h2>
|
||||||
|
<p><a href="/help/en/interwiki">Documentation.</a></p>
|
||||||
|
<p>
|
||||||
|
<label for="names" class="required-field">Names (separated by commas):</label>
|
||||||
|
<input type="text" id="names" name="names" required
|
||||||
|
placeholder="home_wiki, hw">
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="url" class="required-field">URL:</label>
|
||||||
|
<input type="url" id="url" name="url" required
|
||||||
|
placeholder="https://wiki.example.org">
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="engine" class="required-field">Engine:</label>
|
||||||
|
<select name="engine" id="engine" required>
|
||||||
|
<option value="mycorrhiza">Mycorrhiza 🍄</option>
|
||||||
|
<option value="agora">Agora ἀ</option>
|
||||||
|
<option value="generic">Generic (any website)</option>
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
<p>Fill the next two fields if you have chosen <kbd>Generic</kbd> in the previous field.</p>
|
||||||
|
<p>
|
||||||
|
<label for="link-href-format">Link href attribute format string:</label>
|
||||||
|
<input type="url" id="link-href-format" name="link-href-format"
|
||||||
|
placeholder="https://wiki.example.org/view/{NAME}">
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="img-src-format">Image src attribute format string:</label>
|
||||||
|
<input type="url" id="img-src-format" name="img-src-format"
|
||||||
|
placeholder="https://wiki.example.org/media/{NAME}">
|
||||||
|
</p>
|
||||||
|
<input type="submit">
|
||||||
|
</form>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{define "body"}}
|
||||||
|
<main class="main-width">
|
||||||
|
<h1>{{template "interwiki map"}}</h1>
|
||||||
|
{{if .CanEdit}}
|
||||||
|
{{template "authorized map" .}}
|
||||||
|
{{else}}
|
||||||
|
{{template "static map" .}}
|
||||||
|
{{end}}
|
||||||
</main>
|
</main>
|
||||||
{{end}}
|
{{end}}
|
||||||
@ -29,6 +29,7 @@ type interwikiData struct {
|
|||||||
// Emojies contains emojies that represent wiki engines. Emojies[i] is an emoji for Entries[i].Engine
|
// Emojies contains emojies that represent wiki engines. Emojies[i] is an emoji for Entries[i].Engine
|
||||||
Emojies []string
|
Emojies []string
|
||||||
CanEdit bool
|
CanEdit bool
|
||||||
|
Error string
|
||||||
}
|
}
|
||||||
|
|
||||||
func viewInterwiki(meta viewutil.Meta) {
|
func viewInterwiki(meta viewutil.Meta) {
|
||||||
@ -37,6 +38,7 @@ func viewInterwiki(meta viewutil.Meta) {
|
|||||||
Entries: theMap.list,
|
Entries: theMap.list,
|
||||||
Emojies: emojiesForEngines(theMap.list),
|
Emojies: emojiesForEngines(theMap.list),
|
||||||
CanEdit: meta.U.Group == "admin",
|
CanEdit: meta.U.Group == "admin",
|
||||||
|
Error: "",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,21 +11,20 @@ type WikiEngine int
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
Mycorrhiza WikiEngine = iota
|
Mycorrhiza WikiEngine = iota
|
||||||
OddMuse
|
Agora
|
||||||
MediaWiki
|
|
||||||
MoinMoin1
|
|
||||||
MoinMoin2
|
|
||||||
DokuWiki
|
|
||||||
// Generic is any website.
|
// Generic is any website.
|
||||||
Generic
|
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.
|
// 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 {
|
func (we WikiEngine) EmojiWithName() string {
|
||||||
switch we {
|
switch we {
|
||||||
case Mycorrhiza:
|
case Mycorrhiza:
|
||||||
return "🍄 Mycorrhiza"
|
return "🍄 Mycorrhiza"
|
||||||
case OddMuse:
|
case Agora:
|
||||||
|
return "ἀ Agora"
|
||||||
|
/*case OddMuse: Might return them in the future
|
||||||
return "🐫 OddMuse"
|
return "🐫 OddMuse"
|
||||||
case MediaWiki:
|
case MediaWiki:
|
||||||
return "🌻 MediaWiki"
|
return "🌻 MediaWiki"
|
||||||
@ -34,7 +33,7 @@ func (we WikiEngine) EmojiWithName() string {
|
|||||||
case MoinMoin2:
|
case MoinMoin2:
|
||||||
return "Ⓜ️ MoinMoin 2.*"
|
return "Ⓜ️ MoinMoin 2.*"
|
||||||
case DokuWiki:
|
case DokuWiki:
|
||||||
return "📝 DokuWiki"
|
return "📝 DokuWiki"*/
|
||||||
default:
|
default:
|
||||||
return "🌐 Generic"
|
return "🌐 Generic"
|
||||||
}
|
}
|
||||||
@ -67,11 +66,7 @@ type Wiki struct {
|
|||||||
|
|
||||||
var wikiEnginesLookup = map[string]WikiEngine{
|
var wikiEnginesLookup = map[string]WikiEngine{
|
||||||
"mycorrhiza": Mycorrhiza,
|
"mycorrhiza": Mycorrhiza,
|
||||||
"oddmuse": OddMuse,
|
"agora": Agora,
|
||||||
"mediawiki": MediaWiki,
|
|
||||||
"moin1": MoinMoin1,
|
|
||||||
"moin2": MoinMoin2,
|
|
||||||
"dokuwiki": DokuWiki,
|
|
||||||
"generic": Generic,
|
"generic": Generic,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -866,3 +866,20 @@ dt {
|
|||||||
dd + dt {
|
dd + dt {
|
||||||
margin-top: .5rem;
|
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;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user