mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-25 01:20:30 +00:00
Add support for switching page templates
This commit is contained in:
parent
7134490f97
commit
dbf7682d47
@ -22,6 +22,7 @@ exports.synchronous = true;
|
|||||||
var PAGE_TITLE_TITLE = "$:/core/wiki/title";
|
var PAGE_TITLE_TITLE = "$:/core/wiki/title";
|
||||||
var PAGE_STYLESHEET_TITLE = "$:/core/ui/PageStylesheet";
|
var PAGE_STYLESHEET_TITLE = "$:/core/ui/PageStylesheet";
|
||||||
var PAGE_TEMPLATE_TITLE = "$:/core/ui/PageTemplate";
|
var PAGE_TEMPLATE_TITLE = "$:/core/ui/PageTemplate";
|
||||||
|
var PAGE_TEMPLATE_CONFIG_TITLE = "$:/config/ui/PageTemplate";
|
||||||
|
|
||||||
// Time (in ms) that we defer refreshing changes to draft tiddlers
|
// Time (in ms) that we defer refreshing changes to draft tiddlers
|
||||||
var DRAFT_TIDDLER_TIMEOUT_TITLE = "$:/config/Drafts/TypingTimeout";
|
var DRAFT_TIDDLER_TIMEOUT_TITLE = "$:/config/Drafts/TypingTimeout";
|
||||||
@ -52,7 +53,7 @@ exports.startup = function() {
|
|||||||
}));
|
}));
|
||||||
// Display the $:/core/ui/PageTemplate tiddler to kick off the display
|
// Display the $:/core/ui/PageTemplate tiddler to kick off the display
|
||||||
$tw.perf.report("mainRender",function() {
|
$tw.perf.report("mainRender",function() {
|
||||||
$tw.pageWidgetNode = $tw.wiki.makeTranscludeWidget(PAGE_TEMPLATE_TITLE,{document: document, parentWidget: $tw.rootWidget});
|
$tw.pageWidgetNode = $tw.wiki.makeTranscludeWidget(PAGE_TEMPLATE_CONFIG_TITLE,{document: document, parentWidget: $tw.rootWidget, textReference: true});
|
||||||
$tw.pageContainer = document.createElement("div");
|
$tw.pageContainer = document.createElement("div");
|
||||||
$tw.utils.addClass($tw.pageContainer,"tc-page-container-wrapper");
|
$tw.utils.addClass($tw.pageContainer,"tc-page-container-wrapper");
|
||||||
document.body.insertBefore($tw.pageContainer,document.body.firstChild);
|
document.body.insertBefore($tw.pageContainer,document.body.firstChild);
|
||||||
|
@ -1002,6 +1002,7 @@ exports.makeWidget = function(parser,options) {
|
|||||||
Make a widget tree for transclusion
|
Make a widget tree for transclusion
|
||||||
title: target tiddler title
|
title: target tiddler title
|
||||||
options: as for wiki.makeWidget() plus:
|
options: as for wiki.makeWidget() plus:
|
||||||
|
options.textReference : flag to indicate whether title is a text reference
|
||||||
options.field: optional field to transclude (defaults to "text")
|
options.field: optional field to transclude (defaults to "text")
|
||||||
options.mode: transclusion mode "inline" or "block"
|
options.mode: transclusion mode "inline" or "block"
|
||||||
options.children: optional array of children for the transclude widget
|
options.children: optional array of children for the transclude widget
|
||||||
@ -1026,12 +1027,24 @@ exports.makeTranscludeWidget = function(title,options) {
|
|||||||
children: []},
|
children: []},
|
||||||
parseTreeTransclude = {
|
parseTreeTransclude = {
|
||||||
type: "transclude",
|
type: "transclude",
|
||||||
attributes: {
|
attributes: {},
|
||||||
tiddler: {
|
isBlock: !options.parseAsInline},
|
||||||
|
parseTreeTiddler;
|
||||||
|
|
||||||
|
if(options.textReference) {
|
||||||
|
parseTreeTiddler = {
|
||||||
|
name: "tiddler",
|
||||||
|
type: "indirect",
|
||||||
|
textReference: title
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
parseTreeTiddler = {
|
||||||
name: "tiddler",
|
name: "tiddler",
|
||||||
type: "string",
|
type: "string",
|
||||||
value: title}},
|
value: title
|
||||||
isBlock: !options.parseAsInline};
|
}
|
||||||
|
}
|
||||||
|
parseTreeTransclude.attributes.tiddler = parseTreeTiddler;
|
||||||
if(options.importVariables || options.importPageMacros) {
|
if(options.importVariables || options.importPageMacros) {
|
||||||
if(options.importVariables) {
|
if(options.importVariables) {
|
||||||
parseTreeImportVariables.attributes.filter.value = options.importVariables;
|
parseTreeImportVariables.attributes.filter.value = options.importVariables;
|
||||||
|
2
core/wiki/config/ui/PageTemplate.tid
Normal file
2
core/wiki/config/ui/PageTemplate.tid
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
title: $:/config/ui/PageTemplate
|
||||||
|
text: $:/core/ui/PageTemplate
|
Loading…
Reference in New Issue
Block a user