1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2025-02-03 04:39:19 +00:00

Interwiki: Translate to Russian and update docs

This commit is contained in:
Timur Ismagilov 2022-08-02 14:29:25 +05:00
parent 39ef4f9a2a
commit ba4d7b9d26
5 changed files with 101 additions and 38 deletions

View File

@ -9,14 +9,14 @@ In Mycomarkup, you can address a different wiki by prefixing the link target wit
The interwiki prefixes obey the same naming rules as hyphae. In particular, they are case-insensitive, among other things. Every interwiki entry has one main name and it might have any number of aliases, which can be used interchangeably.
See [[/interwiki]] for the list of configured interwiki entries. Unlike the WWW, there is no distributed list of wikis, so each wiki administrator has to maintain their own list.
See [[/interwiki]] for the list of configured interwiki entries. Unlike the WWW, there is no distributed list of wikis similar to DNS, so each wiki administrator has to maintain their own list.
== Mycorrhiza interwiki
Intermycorrhizal interwiki works the best, due to the nature of hyphae. Unlike with other systems, you can address images from the other wikis reliably.
Intermycorrhizal interwiki works the best, due to the nature of hyphae. Unlike with some other systems, you can address images from the other wikis reliably.
```myco
img {
melanocarpa
melanocarpa>quadrat 12
}
```
@ -24,9 +24,43 @@ img {
//This section is meant for wiki administrators.//
**Intermap**, or interwiki map, is the collection of all configured interwiki entries. To configure it, an administrator has to visit [[/interwiki]] and change the existing entries or add a new one.
You can also change `interwiki.json` directly.
Entries have the following fields:
*. {
**Name.** This is the canonical name of the wiki and one of the prefixes you can use for interlinks.
}
*. {
**Aliases.** They are separated with commas. You don't have to set them up.
There are three supported engine types:
* `mycorrhiza` is used for Mycorrhiza wikis.
* `agora` is used for intances of Agora, such as [[https://anagora.org]].
* `generic` is used for everything else.
A good idea is to have the full name in the //name// field (such as `wikipedia`), and shorter names in //aliases// (such as `pedia` and `wp`).
}
*. {
**URL.** The URL of the index/home/main page of the wiki. It should not end on trailing slash.
}
*. {
**Engine.** This is the software the target wiki runs.
There are two engines supported explicitly:
* Mycorrhiza
* [[https://anagora.org | Agora]]
Choose the //Generic// option for sites running different software.
}
*. {
**Formats.** Because interlinks are supported for two cases (hyperlinks and images), there has to be a way to convert a resource name to an URL of the resource. Format strings are a way to do that.
There are two format strings: one for hyperlinks, one for images. They directly correspond to HTML's `href` and `src` attributes of the `a` and `img` tags.
For Mycorrhiza wikis, you don't have to set them, they are set automatically to the following values (replace `https\:/\/example.org` with the URL of the target wiki):
* Link: `https\:/\/example.org/hypha/{NAME}`
* Image: `https\:/\/example.org/binary/{NAME}`
For Agora, they are set to:
* Link: `https\:/\/example.org/node/{NAME}`
* Image: `https\:/\/example.org/{NAME}`, which doesn't make a lot of sense
For generic sites, you will have to think of something by yourself. If you do not set it, it will default to `https\:/\/example.org/{NAME}`.
`{NAME}` is substituted. For example, from link `[[Melanocarpa>uxn]]`, `{NAME}` is replaced with `uxn`.
}
You can also change `interwiki.json` directly. Reload the wiki after editing it.

View File

@ -1,5 +1,16 @@
{{define "interwiki map"}}Interwiki map{{end}}
{{define "interwiki map"}}Intermap{{end}}
{{define "title"}}{{template "interwiki map"}}{{end}}
{{define "name"}}Name:{{end}}
{{define "aliases"}}Aliases:{{end}}
{{define "aliases (,)"}}Aliases (separated by commas):{{end}}
{{define "engine"}}Engine:{{end}}
{{define "engine/mycorrhiza"}}Mycorrhiza{{end}}
{{define "engine/generic"}}Generic (any website){{end}}
{{define "url"}}URL{{end}}
{{define "link href format"}}Link href attribute format string:{{end}}
{{define "img src format"}}Image src attribute format string:{{end}}
{{define "unset map"}}No interwiki map set.{{end}}
{{define "add interwiki entry"}}Add interwiki entry{{end}}
{{define "static map"}}
{{if len .Entries}}
@ -7,29 +18,29 @@
{{range $i, $wiki := .Entries}}
<li>
<dl>
<dt>Name</dt>
<dt>{{template "name"}}</dt>
<dd>{{.Name}}</dd>
<dt>Aliases</dt>
<dt>{{template "aliases"}}</dt>
{{range .Aliases}}<dd>{{.}}</dd>{{end}}
<dt>Engine</dt>
<dt>{{template "engine"}}</dt>
<dd>{{.Engine}}</dd>
<dt>URL</dt>
<dt>{{template "url"}}</dt>
<dd><a href="{{.URL}}">{{.URL}}</a></dd>
<dt>Link href format</dt>
<dt>{{template "link href format"}}</dt>
<dd>{{.LinkHrefFormat}}</dd>
<dt>Img src format</dt>
<dt>{{template "img src format"}}</dt>
<dd>{{.ImgSrcFormat}}</dd>
</dl>
</li>
{{end}}
</ul>
{{else}}
<p>No interwiki map set.</p>
<p>{{template "unset map"}}</p>
{{end}}
{{end}}
@ -41,74 +52,74 @@
{{range $i, $wiki := .Entries}}
<form method="post" action="/interwiki/modify-entry/{{.Name}}">
<p>
<label for="name{{$i}}" class="required-field">Name:</label>
<label for="name{{$i}}" class="required-field">{{template "name"}}</label>
<input type="text" id="name" name="name{{$i}}" required
value="{{.Name}}">
</p>
<p>
<label for="aliases{{$i}}">Aliases (separated by commas):</label>
<label for="aliases{{$i}}">{{template "aliases (,)"}}</label>
<input type="text" id="aliases{{$i}}" name="aliases"
value="{{range $j, $alias := .Aliases}}{{if gt $j 0}}, {{end}}{{.}}{{end}}">
</p>
<p>
<label for="url{{$i}}" class="required-field">URL:</label>
<label for="url{{$i}}" class="required-field">{{template "url"}}</label>
<input type="url" id="url{{$i}}" name="url" required
value="{{.URL}}">
</p>
<p>
<label for="engine{{$i}}" class="required-field">Engine:</label>
<label for="engine{{$i}}" class="required-field">{{template "engine"}}</label>
<select name="engine" id="engine{{$i}}" required>
<option value="mycorrhiza" {{if eq .Engine "mycorrhiza"}}selected{{end}}>Mycorrhiza 🍄</option>
<option value="mycorrhiza" {{if eq .Engine "mycorrhiza"}}selected{{end}}>{{template "engine/mycorrhiza"}} 🍄</option>
<option value="agora" {{if eq .Engine "agora"}}selected{{end}}>Agora ἀ</option>
<option value="generic" {{if eq .Engine "generic"}}selected{{end}}>Generic (any website)</option>
<option value="generic" {{if eq .Engine "generic"}}selected{{end}}>{{template "engine/generic"}}</option>
</select>
</p>
<p>
<label for="link-href-format{{$i}}">Link href attribute format string:</label>
<label for="link-href-format{{$i}}">{{template "link href format"}}</label>
<input type="url" id="link-href-format{{$i}}" name="link-href-format"
value="{{.LinkHrefFormat}}">
</p>
<p>
<label for="img-src-format{{$i}}">Image src attribute format string:</label>
<label for="img-src-format{{$i}}">{{template "img src format"}}</label>
<input type="url" id="img-src-format{{$i}}" name="img-src-format"
value="{{.ImgSrcFormat}}">
</p>
<input type="submit" class="btn" value="Save">
<input type="submit" class="btn" value="{{template `save`}}">
</form>
{{end}}
{{end}}
<form method="post" action="/interwiki/add-entry">
<h2>Add interwiki entry</h2>
<h2>{{template "add interwiki entry"}}</h2>
<p>
<label for="name" class="required-field">Name:</label>
<label for="name" class="required-field">{{template "name"}}</label>
<input type="text" id="name" name="name" required
placeholder="home_wiki">
</p>
<p>
<label for="aliases">Aliases (separated by commas):</label>
<label for="aliases">{{template "aliases (,)"}}</label>
<input type="text" id="aliases" name="aliases"
placeholder="homewiki, hw">
</p>
<p>
<label for="url" class="required-field">URL:</label>
<label for="url" class="required-field">{{template "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>
<label for="engine" class="required-field">{{template "engine"}}</label>
<select name="engine" id="engine" required>
<option value="mycorrhiza">Mycorrhiza 🍄</option>
<option value="mycorrhiza">{{template "engine/mycorrhiza"}} 🍄</option>
<option value="agora">Agora ἀ</option>
<option value="generic">Generic (any website)</option>
<option value="generic">{{template "engine/generic"}}</option>
</select>
</p>
<p>
<label for="link-href-format">Link href attribute format string:</label>
<label for="link-href-format">{{template "link href format"}}</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>
<label for="img-src-format">{{template "img src format"}}</label>
<input type="url" id="img-src-format" name="img-src-format"
placeholder="https://wiki.example.org/media/{NAME}">
</p>
@ -116,14 +127,16 @@
</form>
{{end}}
{{define "documentation."}}Documentation.{{end}}
{{define "edit separately."}}Edit and save every the entry separately.{{end}}
{{define "body"}}
<main class="main-width">
<h1>{{template "interwiki map"}}</h1>
{{if .CanEdit}}
<p><a href="/help/en/interwiki">Documentation.</a> Edit and save every entry separately.</p>
<p><a href="/help/en/interwiki">{{template "documentation."}}</a> {{template "edit separately."}}</p>
{{template "authorized map" .}}
{{else}}
<p><a href="/help/en/interwiki">Documentation.</a></p>
<p><a href="/help/en/interwiki">{{template "documentation."}}</a></p>
{{template "static map" .}}
{{end}}
</main>

View File

@ -10,8 +10,22 @@ import (
var (
//go:embed *html
fs embed.FS
ruTranslation = ``
fs embed.FS
ruTranslation = `
{{define "interwiki map"}}Интеркарта{{end}}
{{define "name"}}Название:{{end}}
{{define "aliases"}}Псевдонимы:{{end}}
{{define "aliases (,)"}}Псевдонимы (разделённые запятыми):{{end}}
{{define "engine"}}Движок:{{end}}
{{define "engine/mycorrhiza"}}Микориза{{end}}
{{define "engine/generic"}}Любой сайт{{end}}
{{define "link href format"}}Строка форматирования атрибута href ссылки:{{end}}
{{define "img src format"}}Строка форматирования атрибута src изображения:{{end}}
{{define "unset map"}}Интеркарта не задана.{{end}}
{{define "documentation."}}Документация.{{end}}
{{define "edit separately."}}Изменяйте записи по отдельности.{{end}}
{{define "add interwiki entry"}}Добавить запись в интеркарту{{end}}
`
chainInterwiki viewutil.Chain
chainNameTaken viewutil.Chain
)

View File

@ -1,5 +1,6 @@
{{define "confirm"}}Confirm{{end}}
{{define "cancel"}}Cancel{{end}}
{{define "save"}}Save{{end}}
{{define "page"}}
<!doctype html>
<html lang="{{.Meta.Locale}}">

View File

@ -27,6 +27,7 @@ const ruText = `
{{define "register"}}Регистрация{{end}}
{{define "confirm"}}Подтвердить{{end}}
{{define "cancel"}}Отмена{{end}}
{{define "save"}}Сохранить{{end}}
`
func Init() {