mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-20 00:34:50 +00:00
abde67e5df
Fixes #8022
232 lines
7.1 KiB
Plaintext
232 lines
7.1 KiB
Plaintext
title: MultiWikiServer Administration
|
|
|
|
\procedure createBag(name,description,errorTiddler)
|
|
\procedure completion-createBag()
|
|
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
|
<$action-log
|
|
status=<<status>>
|
|
statusText=<<statusText>>
|
|
error=<<error>>
|
|
data=<<data>>
|
|
headers=<<headers>>
|
|
/>
|
|
<%if [<error>match[]] %>
|
|
<$action-setfield $tiddler=<<errorTiddler>> text=""/>
|
|
<$action-sendmessage $message="tm-server-refresh"/>
|
|
<%else%>
|
|
<$action-setfield $tiddler=<<errorTiddler>> text=<<data>>/>
|
|
<%endif%>
|
|
\end completion-createBag
|
|
<$action-sendmessage
|
|
$message="tm-http-request"
|
|
url=`/wiki/${ [<name>encodeuricomponent[]] }$/bags/${ [<name>encodeuricomponent[]] }$`
|
|
method="PUT"
|
|
body=`{"description":"${ [<description>] }$"}`
|
|
oncompletion=<<completion-createBag>>
|
|
var-errorTiddler=<<errorTiddler>>
|
|
/>
|
|
\end createBag
|
|
|
|
\procedure createBagButton(name)
|
|
\whitespace trim
|
|
<form class="mws-form">
|
|
<div class="mws-form-heading">
|
|
<$text text="Create a new bag"/>
|
|
</div>
|
|
<div class="mws-form-fields">
|
|
<div class="mws-form-field">
|
|
<label class="mws-form-field-description">
|
|
Bag name
|
|
</label>
|
|
<$edit-text tiddler="$:/temp/NewBagName" tag="input" placeholder="(bag name)" class="mws-form-field-input"/>
|
|
</div>
|
|
<div class="mws-form-field">
|
|
<label class="mws-form-field-description">
|
|
Bag description
|
|
</label>
|
|
<$edit-text tiddler="$:/temp/NewBagDescription" tag="input" placeholder="(description)" class="mws-form-field-input"/>
|
|
</div>
|
|
</div>
|
|
<div class="mws-form-status">
|
|
<%if [[$:/temp/NewBagError]get[text]else[]!match[]] %>
|
|
<div class="mws-form-error">
|
|
<$text text={{$:/temp/NewBagError}}/>
|
|
</div>
|
|
<%endif%>
|
|
</div>
|
|
<div class="mws-form-buttons">
|
|
<$button class="mws-form-button">
|
|
<$transclude
|
|
$variable="createBag"
|
|
name={{$:/temp/NewBagName}}
|
|
description={{$:/temp/NewBagDescription}}
|
|
errorTiddler="$:/temp/NewBagError"
|
|
/>
|
|
Create Bag
|
|
</$button>
|
|
</div>
|
|
</form>
|
|
\end createBagButton
|
|
|
|
\procedure createRecipe(name,bag_names,description,errorTiddler)
|
|
\procedure completion-createRecipe()
|
|
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
|
<%if [<error>match[]] %>
|
|
<$action-setfield $tiddler=<<errorTiddler>> text=""/>
|
|
<$action-sendmessage $message="tm-server-refresh"/>
|
|
<%else%>
|
|
<$action-setfield $tiddler=<<errorTiddler>> text=<<data>>/>
|
|
<%endif%>
|
|
\end completion-createRecipe
|
|
\procedure emptyArray() []
|
|
\function createRecipeJson()
|
|
[<bag_names>enlist-input[]] :reduce[<accumulator>!match[]else<emptyArray>jsonset<index>,<currentTiddler>]
|
|
\end createRecipeJson
|
|
<$action-sendmessage
|
|
$message="tm-http-request"
|
|
url=`/wiki/${ [<name>encodeuricomponent[]] }$/recipes/${ [<name>encodeuricomponent[]] }$`
|
|
method="PUT"
|
|
body=`{"bag_names":${ [<createRecipeJson>] }$,"description":"${ [<description>] }$"}`
|
|
oncompletion=<<completion-createRecipe>>
|
|
var-errorTiddler=<<errorTiddler>>
|
|
/>
|
|
\end createRecipe
|
|
|
|
\procedure createRecipeButton()
|
|
\whitespace trim
|
|
<form class="mws-form">
|
|
<div class="mws-form-heading">
|
|
<$text text="Create a new recipe"/>
|
|
</div>
|
|
<div class="mws-form-fields">
|
|
<div class="mws-form-field">
|
|
<label class="mws-form-field-description">
|
|
Recipe name
|
|
</label>
|
|
<$edit-text tiddler="$:/temp/NewRecipeName" tag="input" placeholder="(recipe name)" class="mws-form-field-input"/>
|
|
</div>
|
|
<div class="mws-form-field">
|
|
<label class="mws-form-field-description">
|
|
Bag names
|
|
</label>
|
|
<$edit-text tiddler="$:/temp/NewRecipeBagNames" tag="input" placeholder="(space separated list of bags)"/>
|
|
</div>
|
|
<div class="mws-form-field">
|
|
<label class="mws-form-field-description">
|
|
Recipe description
|
|
</label>
|
|
<$edit-text tiddler="$:/temp/NewRecipeDescription" tag="input" placeholder="(description)" class="mws-form-field-input"/>
|
|
</div>
|
|
</div>
|
|
<div class="mws-form-status">
|
|
<%if [[$:/temp/NewRecipeError]get[text]else[]!match[]] %>
|
|
<div class="mws-form-error">
|
|
<$text text={{$:/temp/NewRecipeError}}/>
|
|
</div>
|
|
<%endif%>
|
|
</div>
|
|
<div class="mws-form-buttons">
|
|
<$button class="mws-form-button">
|
|
<$transclude
|
|
$variable="createRecipe"
|
|
name={{$:/temp/NewRecipeName}}
|
|
bag_names={{$:/temp/NewRecipeBagNames}}
|
|
description={{$:/temp/NewRecipeDescription}}
|
|
errorTiddler="$:/temp/NewRecipeError"
|
|
/>
|
|
Create Recipe
|
|
</$button>
|
|
</div>
|
|
</form>
|
|
\end createRecipeButton
|
|
|
|
<!-- Expects currentTiddler to be the title of a bag entity state tiddler -->
|
|
\procedure bagPill(element-tag:"span",is-topmost:"no")
|
|
\whitespace trim
|
|
<$genesis $type=<<element-tag>> class={{{ mws-bag-pill [<is-topmost>match[yes]then[mws-bag-pill-topmost]] +[join[ ]] }}}>
|
|
<a class="mws-bag-pill-link" href=`/wiki/${ [{!!bag-name}encodeuricomponent[]] }$/bags/${ [{!!bag-name}encodeuricomponent[]] }$` rel="noopener noreferrer" target="_blank">
|
|
<$image
|
|
source=`/wiki/${ [{!!bag-name}encodeuricomponent[]] }$/bags/${ [{!!bag-name}encodeuricomponent[]] }$/tiddlers/%24%3A%2Ffavicon.ico`
|
|
class="mws-favicon-small"
|
|
>
|
|
<$image
|
|
source="$:/plugins/multiwikiserver/images/missing-favicon.png"
|
|
class="mws-favicon-small"
|
|
/>
|
|
</$image>
|
|
<span class="mws-bag-pill-label">
|
|
<$text text={{!!bag-name}}/>
|
|
</span>
|
|
</a>
|
|
</$genesis>
|
|
\end
|
|
|
|
<!-- Expects currentTiddler to be the title of a recipe entity state tiddler -->
|
|
\procedure wikiCard()
|
|
\whitespace trim
|
|
<a class="mws-wiki-card" href=`/wiki/${ [{!!recipe-name}encodeuricomponent[]] }$` rel="noopener noreferrer" target="_blank">
|
|
<div class="mws-wiki-card-image">
|
|
<$image
|
|
source=`/wiki/${ [{!!recipe-name}encodeuricomponent[]] }$/recipes/${ [{!!recipe-name}encodeuricomponent[]] }$/tiddlers/%24%3A%2Ffavicon.ico`
|
|
class="mws-favicon"
|
|
>
|
|
<$image
|
|
source="$:/plugins/multiwikiserver/images/missing-favicon.png"
|
|
class="mws-favicon"
|
|
/>
|
|
</$image>
|
|
</div>
|
|
<div class="mws-wiki-card-content">
|
|
<div class="mws-wiki-card-header">
|
|
<$text text={{!!recipe-name}}/>
|
|
</div>
|
|
<div class="mws-wiki-card-meta">
|
|
<%if [list<currentTiddler>] %>
|
|
<ol class="mws-horizontal-list">
|
|
<$list filter="[list<currentTiddler>]" counter="counter">
|
|
<$transclude $variable="bagPill" is-topmost={{{ [<counter-last>match[yes]] }}} element-tag="li"/>
|
|
</$list>
|
|
</ol>
|
|
<%else%>
|
|
(no bags defined)
|
|
<%endif%>
|
|
</div>
|
|
<div class="mws-wiki-card-description">
|
|
<$text text={{!!text}}/>
|
|
</div>
|
|
</div>
|
|
</a>
|
|
\end
|
|
|
|
<div class="mws-admin-container">
|
|
<h1>Wikis</h1>
|
|
<p>
|
|
These are the wikis available on this server. Click on a wiki to visit it in a new browser tab.
|
|
</p>
|
|
<ul class="mws-vertical-list">
|
|
<$list filter="[prefix[$:/state/MultiWikiServer/recipes/]]">
|
|
<li>
|
|
<<wikiCard>>
|
|
</li>
|
|
</$list>
|
|
</ul>
|
|
<div>
|
|
<<createRecipeButton>>
|
|
</div>
|
|
<div>
|
|
Higher numbered bags take priority if a tiddler with the same title is in more than one bag
|
|
</div>
|
|
<h1>Bags</h1>
|
|
<ul class="mws-vertical-list">
|
|
<$list filter="[prefix[$:/state/MultiWikiServer/bags/]]">
|
|
<li>
|
|
<<bagPill>>
|
|
<$text text={{!!text}}/>
|
|
</li>
|
|
</$list>
|
|
</ul>
|
|
<div>
|
|
<<createBagButton>>
|
|
</div>
|
|
</div>
|