2014-07-20 17:07:30 +00:00
/ * \
title : $ : / c o r e / m o d u l e s / s t a r t u p / i n f o . j s
type : application / javascript
module - type : startup
Initialise $ : / i n f o t i d d l e r s v i a $ : / t e m p / i n f o - p l u g i n p s e u d o - p l u g i n
\ * /
( function ( ) {
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict" ;
// Export name and synchronous status
exports . name = "info" ;
exports . before = [ "startup" ] ;
exports . after = [ "load-modules" ] ;
exports . synchronous = true ;
2019-09-16 11:15:39 +00:00
var TITLE _INFO _PLUGIN = "$:/temp/info-plugin" ;
2014-07-20 17:07:30 +00:00
exports . startup = function ( ) {
// Collect up the info tiddlers
var infoTiddlerFields = { } ;
// Give each info module a chance to fill in as many info tiddlers as they want
$tw . modules . forEachModuleOfType ( "info" , function ( title , moduleExports ) {
if ( moduleExports && moduleExports . getInfoTiddlerFields ) {
var tiddlerFieldsArray = moduleExports . getInfoTiddlerFields ( infoTiddlerFields ) ;
$tw . utils . each ( tiddlerFieldsArray , function ( fields ) {
if ( fields ) {
infoTiddlerFields [ fields . title ] = fields ;
}
} ) ;
}
} ) ;
2019-09-16 11:15:39 +00:00
// Bake the info tiddlers into a plugin. We use the non-standard plugin-type "info" because ordinary plugins are only registered asynchronously after being loaded dynamically
2014-07-20 17:07:30 +00:00
var fields = {
2019-09-16 11:15:39 +00:00
title : TITLE _INFO _PLUGIN ,
2014-07-20 17:07:30 +00:00
type : "application/json" ,
"plugin-type" : "info" ,
text : JSON . stringify ( { tiddlers : infoTiddlerFields } , null , $tw . config . preferences . jsonSpaces )
} ;
$tw . wiki . addTiddler ( new $tw . Tiddler ( fields ) ) ;
2019-09-16 11:15:39 +00:00
$tw . wiki . readPluginInfo ( [ TITLE _INFO _PLUGIN ] ) ;
2014-07-20 17:07:30 +00:00
$tw . wiki . registerPluginTiddlers ( "info" ) ;
$tw . wiki . unpackPluginTiddlers ( ) ;
} ;
} ) ( ) ;