mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-31 15:42:59 +00:00 
			
		
		
		
	Add docs bags
This commit is contained in:
		| @@ -41,6 +41,13 @@ exports.startup = function() { | |||||||
| 	$tw.sqlTiddlerStore = new SqlTiddlerStore({ | 	$tw.sqlTiddlerStore = new SqlTiddlerStore({ | ||||||
| 		databasePath: databasePath | 		databasePath: databasePath | ||||||
| 	}); | 	}); | ||||||
|  | 	// Create docs bag and recipe | ||||||
|  | 	$tw.sqlTiddlerStore.createBag("docs"); | ||||||
|  | 	$tw.sqlTiddlerStore.createRecipe("docs",["docs"],"TiddlyWiki Documentation from https://tiddlywiki.com/"); | ||||||
|  | 	$tw.sqlTiddlerStore.saveTiddlersFromPath(path.resolve($tw.boot.corePath,$tw.config.editionsPath,"tw5.com/tiddlers"),"docs"); | ||||||
|  | 	$tw.sqlTiddlerStore.createBag("dev-docs"); | ||||||
|  | 	$tw.sqlTiddlerStore.createRecipe("dev-docs",["dev-docs"],"TiddlyWiki Developer Documentation from https://tiddlywiki.com/dev/"); | ||||||
|  | 	$tw.sqlTiddlerStore.saveTiddlersFromPath(path.resolve($tw.boot.corePath,$tw.config.editionsPath,"dev/tiddlers"),"dev-docs"); | ||||||
| 	// Create bags and recipes | 	// Create bags and recipes | ||||||
| 	$tw.sqlTiddlerStore.createBag("bag-alpha"); | 	$tw.sqlTiddlerStore.createBag("bag-alpha"); | ||||||
| 	$tw.sqlTiddlerStore.createBag("bag-beta"); | 	$tw.sqlTiddlerStore.createBag("bag-beta"); | ||||||
|   | |||||||
| @@ -395,6 +395,19 @@ SqlTiddlerDatabase.prototype.getRecipeTiddlers = function(recipename) { | |||||||
| 	return rows; | 	return rows; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | SqlTiddlerDatabase.prototype.deleteAllTiddlersInBag = function(bagname) { | ||||||
|  | 	this.runStatement(` | ||||||
|  | 		DELETE FROM tiddlers | ||||||
|  | 		WHERE bag_id IN ( | ||||||
|  | 			SELECT bag_id | ||||||
|  | 			FROM bags | ||||||
|  | 			WHERE bag_name = $bag_name | ||||||
|  | 		) | ||||||
|  | 	`,{ | ||||||
|  | 		bag_name: bagname | ||||||
|  | 	}); | ||||||
|  | }; | ||||||
|  |  | ||||||
| /* | /* | ||||||
| Get the names of the bags in a recipe. Returns an empty array for recipes that do not exist | Get the names of the bags in a recipe. Returns an empty array for recipes that do not exist | ||||||
| */ | */ | ||||||
|   | |||||||
| @@ -89,6 +89,21 @@ SqlTiddlerStore.prototype.processOutgoingTiddler = function(tiddlerFields,tiddle | |||||||
| 	} | 	} | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | SqlTiddlerStore.prototype.saveTiddlersFromPath = function(tiddler_files_path,bag_name) { | ||||||
|  | 	// Clear out the bag | ||||||
|  | 	this.deleteAllTiddlersInBag(bag_name); | ||||||
|  | 	// Get the tiddlers | ||||||
|  | 	var path = require("path"); | ||||||
|  | 	var tiddlersFromPath = $tw.loadTiddlersFromPath(path.resolve($tw.boot.corePath,$tw.config.editionsPath,tiddler_files_path)); | ||||||
|  | 	// Save the tiddlers | ||||||
|  | 	for(const tiddlersFromFile of tiddlersFromPath) { | ||||||
|  | 		for(const tiddler of tiddlersFromFile.tiddlers) { | ||||||
|  | 			this.saveBagTiddler(tiddler,bag_name); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | }; | ||||||
|  |  | ||||||
| SqlTiddlerStore.prototype.logTables = function() { | SqlTiddlerStore.prototype.logTables = function() { | ||||||
| 	this.sqlTiddlerDatabase.logTables(); | 	this.sqlTiddlerDatabase.logTables(); | ||||||
| }; | }; | ||||||
| @@ -190,6 +205,10 @@ SqlTiddlerStore.prototype.getRecipeTiddlers = function(recipename) { | |||||||
| 	return this.sqlTiddlerDatabase.getRecipeTiddlers(recipename); | 	return this.sqlTiddlerDatabase.getRecipeTiddlers(recipename); | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | SqlTiddlerStore.prototype.deleteAllTiddlersInBag = function(bagname) { | ||||||
|  | 	return this.sqlTiddlerDatabase.deleteAllTiddlersInBag(bagname); | ||||||
|  | }; | ||||||
|  |  | ||||||
| /* | /* | ||||||
| Get the names of the bags in a recipe. Returns an empty array for recipes that do not exist | Get the names of the bags in a recipe. Returns an empty array for recipes that do not exist | ||||||
| */ | */ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jeremy Ruston
					Jeremy Ruston