mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 12:07:19 +00:00
First pass at admin user interface
This commit is contained in:
parent
1fb8b2e279
commit
615dc0c4a3
16
plugins/tiddlywiki/multiwikiserver/admin-ui/AdminLayout.tid
Normal file
16
plugins/tiddlywiki/multiwikiserver/admin-ui/AdminLayout.tid
Normal file
@ -0,0 +1,16 @@
|
||||
title: $:/MultiWikiServer/AdminLayout
|
||||
tags: $:/tags/Layout
|
||||
name: MultiWikiServer
|
||||
description: Admin Layout
|
||||
icon: $:/favicon.ico
|
||||
|
||||
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
||||
<div class="mws-admin-layout">
|
||||
{{MultiWikiServer Administration}}
|
||||
<div class="mws-admin-layout-controls">
|
||||
<$button>
|
||||
<$action-setfield $tiddler="$:/layout" text="$:/core/ui/PageTemplate"/>
|
||||
Switch to TiddlyWiki default user interface
|
||||
</$button>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,2 @@
|
||||
title: $:/DefaultTiddlers
|
||||
text: [[MultiWikiServer Administration]]
|
@ -0,0 +1,22 @@
|
||||
title: MultiWikiServer Administration
|
||||
|
||||
<div class="mws-admin-container">
|
||||
<h1>Recipes</h1>
|
||||
<ul>
|
||||
<$list filter="[prefix[$:/state/multiwikiserver/recipes/]]">
|
||||
<li>
|
||||
<a href={{{ [{!!recipe-name}addprefix[/wiki/]] }}} rel="noopener noreferrer" target="_blank">
|
||||
<$text text={{!!recipe-name}}/>
|
||||
</a>
|
||||
</li>
|
||||
</$list>
|
||||
</ul>
|
||||
<h1>Bags</h1>
|
||||
<ul>
|
||||
<$list filter="[prefix[$:/state/multiwikiserver/bags/]]">
|
||||
<li>
|
||||
<$text text={{!!bag-name}}/>
|
||||
</li>
|
||||
</$list>
|
||||
</ul>
|
||||
</div>
|
@ -0,0 +1,10 @@
|
||||
title: $:/MultiWikiServer/SideBarSegment
|
||||
tags: $:/tags/SideBarSegment
|
||||
list-before: $:/core/ui/SideBarSegments/page-controls
|
||||
|
||||
<div class="mws-admin-sidebar">
|
||||
<$button>
|
||||
<$action-setfield $tiddler="$:/layout" text="$:/MultiWikiServer/AdminLayout"/>
|
||||
Switch back to ~MultiWikiServer administration user interface
|
||||
</$button>
|
||||
</div>
|
5
plugins/tiddlywiki/multiwikiserver/admin-ui/Styles.tid
Normal file
5
plugins/tiddlywiki/multiwikiserver/admin-ui/Styles.tid
Normal file
@ -0,0 +1,5 @@
|
||||
title: $:/MultiWikiServer/Styles
|
||||
tags: $:/tags/Stylesheet
|
||||
|
||||
\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline macrocallblock
|
||||
|
2
plugins/tiddlywiki/multiwikiserver/admin-ui/layout.tid
Normal file
2
plugins/tiddlywiki/multiwikiserver/admin-ui/layout.tid
Normal file
@ -0,0 +1,2 @@
|
||||
title: $:/layout
|
||||
text: $:/MultiWikiServer/AdminLayout
|
@ -13,11 +13,14 @@ Functions to perform basic tiddler operations with a sqlite3 database
|
||||
Create a tiddler store. Options include:
|
||||
|
||||
databasePath - path to the database file (can be ":memory:" to get a temporary database)
|
||||
adminWiki - reference to $tw.Wiki object into which entity state tiddlers should be saved
|
||||
*/
|
||||
function SqlTiddlerStore(options) {
|
||||
options = options || {};
|
||||
this.adminWiki = options.adminWiki || $tw.wiki;
|
||||
this.entityStateTiddlerPrefix = "$:/state/multiwikiserver/";
|
||||
// Create the database
|
||||
var databasePath = options.databasePath || ":memory:";
|
||||
// Create our database
|
||||
this.db = new $tw.sqlite3.Database(databasePath,{verbose: undefined && console.log});
|
||||
}
|
||||
|
||||
@ -50,6 +53,10 @@ SqlTiddlerStore.prototype.runStatements = function(sqlArray) {
|
||||
}
|
||||
};
|
||||
|
||||
SqlTiddlerStore.prototype.saveEntityStateTiddler = function(tiddler) {
|
||||
this.adminWiki.addTiddler(new $tw.Tiddler(tiddler,{title: this.entityStateTiddlerPrefix + tiddler.title}));
|
||||
};
|
||||
|
||||
SqlTiddlerStore.prototype.createTables = function() {
|
||||
this.runStatements([`
|
||||
-- Bags have names and access control settings
|
||||
@ -110,6 +117,15 @@ SqlTiddlerStore.prototype.logTables = function() {
|
||||
}
|
||||
};
|
||||
|
||||
SqlTiddlerStore.prototype.listBags = function() {
|
||||
const rows = this.runStatementGetAll(`
|
||||
SELECT bag_name, accesscontrol
|
||||
FROM bags
|
||||
ORDER BY bag_name
|
||||
`);
|
||||
return rows;
|
||||
};
|
||||
|
||||
SqlTiddlerStore.prototype.createBag = function(bagname) {
|
||||
// Run the queries
|
||||
this.runStatement(`
|
||||
@ -126,6 +142,20 @@ SqlTiddlerStore.prototype.createBag = function(bagname) {
|
||||
bag_name: bagname,
|
||||
accesscontrol: "[some access control stuff]"
|
||||
});
|
||||
this.saveEntityStateTiddler({
|
||||
title: "bags/" + bagname,
|
||||
"bag-name": bagname,
|
||||
text: ""
|
||||
});
|
||||
};
|
||||
|
||||
SqlTiddlerStore.prototype.listRecipes = function() {
|
||||
const rows = this.runStatementGetAll(`
|
||||
SELECT recipe_name
|
||||
FROM recipes
|
||||
ORDER BY recipe_name
|
||||
`);
|
||||
return rows;
|
||||
};
|
||||
|
||||
SqlTiddlerStore.prototype.createRecipe = function(recipename,bagnames) {
|
||||
@ -154,6 +184,12 @@ SqlTiddlerStore.prototype.createRecipe = function(recipename,bagnames) {
|
||||
recipe_name: recipename,
|
||||
bag_names: JSON.stringify(bagnames)
|
||||
});
|
||||
this.saveEntityStateTiddler({
|
||||
title: "recipes/" + recipename,
|
||||
"recipe-name": recipename,
|
||||
text: "",
|
||||
list: $tw.utils.stringifyList(bagnames)
|
||||
});
|
||||
};
|
||||
|
||||
SqlTiddlerStore.prototype.saveTiddler = function(tiddlerFields,bagname) {
|
||||
|
Loading…
Reference in New Issue
Block a user