Saq,
I don't really understand the need for this. The name "DefaultTiddlers" is not obviously visible to the user, so why is there a need to customise it? I can see at least three problems in allowing the customisation:
1) a user who learns how to change the default tiddlers on one TiddlyWiki may find that it doesn't work on another TiddlyWiki
2) Extra questions from users along the lines of "I changed my DefaultTiddlers and nothing happened..."
3) One extra thing to check when debugging a TiddlyWiki.
MartinOn 7/12/07, Saq Imtiaz <lew...@gmail.com > wrote:Currently the name of the tiddler used to get the list of start up tiddlers is hardcoded into the restart() function. It is suggested to use a variable for this instead to allow plugins to easily change this for different configurations.
Ticket: http://trac.tiddlywiki.org/ticket/362
Patch: http://trac.tiddlywiki.org/attachment/ticket/362/Patch362.patch
Just one extra line of code. This would be very useful for my PresentationPlugin, amongst other things. Any chance we can get this into 2.2.5?
Many thanks,
Saq
--
TiddlyThemes.com ( http://tiddlythemes.com ) : a gallery of TiddlyWiki themes.
TiddlySnip ( http://tiddlysnip.com ) : a firefox extension that turns TiddlyWiki into a scrapbook!
LewcidTW ( http://tw.lewcid.org ) : a repository of extensions for TiddlyWiki
Not that I should have a vote in this, but I'm with Saq on this one.
(I'm generally against hardcoding these kinda things anyway... )
-- F.
config.notifyTiddlers = [Uninformed changes to the above could lead to a TiddlyWiki not even starting up as opposed to just starting up with the wrong set of tiddlers but it has never been a problem. :)
{name: "StyleSheetLayout", notify: refreshStyles},
{name: "StyleSheetColors", notify: refreshStyles},
{name: "StyleSheet", notify: refreshStyles},
{name: "StyleSheetPrint", notify: refreshStyles},
{name: "PageTemplate", notify: refreshPageTemplate},
{name: "SiteTitle", notify: refreshPageTitle},
{name: "SiteSubtitle", notify: refreshPageTitle},
{name: "ColorPalette", notify: refreshColorPalette},
{name: null, notify: refreshDisplay}
];
// Default tiddler templates
var DEFAULT_VIEW_TEMPLATE = 1;
var DEFAULT_EDIT_TEMPLATE = 2;
config.tiddlerTemplates = {
1: "ViewTemplate",
2: "EditTemplate"
};
Ah, I understand what you are trying to do now. I was worried by the confusion that could be caused, as you said, by users changing to, say, "MyStartupTiddlers". But what you want is, for example, the ability to have:
DefaultTiddlers1
DefaultTiddlers2
DefaultTiddlers3
DefaultTiddlers4
and having the ability to change which is called at startup. This makes sense.
Rather the idea is to allow plugins to customize which tiddler is used to get the list of start up tiddlers.
So for example, you can have a plugin with different start modes based on paramifiers. Each mode has a different set of "start up tiddlers". Different starting states for instance. This change would allow such a feature to be offered in a clean and efficient manner.
Rather the idea is to allow plugins to customize which tiddler is used to get the list of start up tiddlers.
So for example, you can have a plugin with different start modes based on paramifiers. Each mode has a different set of "start up tiddlers". Different starting states for instance. This change would allow such a feature to be offered in a clean and efficient manner.
Just two ideas:
Instead of extending the core, what about using the shadow tiddlers mechanism? I.e. don't define an "DefaultTiddlers" tiddler in your TiddlyWiki but a shadowTiddler like this:config.shadowTiddlers["DefaultTiddlers"] = "MyFavoriteTiddler1 MyFavoriteTiddler2 MyFavoriteTiddler3".
Plugins could then easily modify the list of default tiddlers, like appending things to the list, replacing it etc.
Of cause this only works when there is no "real" DefaultTiddlers tiddler.
Alternatively a plugin that wants to change the set of tiddlers to be opened initially may hijack TiddlyWiki.prototype.getTiddlerText and return the modified list for the DefaultTiddlers tiddler:
(function(){
var old_func = TiddlyWiki.prototype.getTiddlerText;
TiddlyWiki.prototype.getTiddlerText = function(title,defaultText) {
if (title == "DefaultTiddlers")
return "PluginStartupTiddler1 PluginStartupTiddler2";
return old_func.apply(this,arguments);
})();
// not tested
These are two possible approaches if one does not want to change the core.
If we want to change the core I rather prefer to introduce a new function "getDefaultTiddlers()" but not make the tiddler name changable. I.e.function getDefaultTiddlers()
{
return store ? store.getTiddlerText("DefaultTiddlers") : "";
}
// Restarting
function restart()
{
invokeParamifier(params,"onstart");
if(story.isEmpty()) {
var defaultParams = getDefaultTiddlers().parseParams("open",null,false);
invokeParamifier(defaultParams,"onstart");
}
window.scrollTo(0,0);
}
This gives us more options to defined the initial set of tiddlers to display. E.g. a plugin does not need to introduce a special tiddler for each "configuration" but could make "getDefaultTiddlers" just return the approriate list of tiddler titles.
Every other 'special tiddler' in TiddlyWiki is so easily customizable so it makes sense that this should be too.
I don't want to argue on whether we should extend the core or not but leave this decision to Jeremy.
I just got one question:Every other 'special tiddler' in TiddlyWiki is so easily customizable so it makes sense that this should be too.
Can you explain a little bit what you mean by this? I think the other "special tiddlers" (like "PageTemplate", "StyleSheetLayout" etc.) are hardcoded the same way as "DefaultTiddlers" and not really much easier to customize than the DefaultTiddlers. Actually I think it is even harder to customize these other "special tiddlers". E.g. if you look at Eric's SelectStylesheetPlugin that is intended to "customize" some special tiddlers: it takes quite some code to achieve this.
config.tiddlerTemplates = {
1: "ViewTemplate",
2: "EditTemplate"
};Yes you are correct that it takes some code to change say PageTemplate to AdminPageTemplate. But it can be done without hijacking or replacing any core functions. All you need to do is remove the old notification and a new one.
I guess we are getting a little bit OT, but ... ;-)Yes you are correct that it takes some code to change say PageTemplate to AdminPageTemplate. But it can be done without hijacking or replacing any core functions. All you need to do is remove the old notification and a new one.
Is it really sufficient to remove the old notification and add a new one? What about the hard coded reference to "PartTemplate" in refreshPageTemplate(title)?
if(!title)
title = "PageTemplate";
Udo
----------
Udo Borkowski
http://www.abego-software.deOn 7/14/07, Saq Imtiaz < lew...@gmail.com> wrote:On 7/14/07, Udo Borkowski < udo.bo...@googlemail.com> wrote:Changing ViewTemplate to AdminViewTemplate is as easy as:I don't want to argue on whether we should extend the core or not but leave this decision to Jeremy.
Agreed, that was always the intent :)I just got one question:Every other 'special tiddler' in TiddlyWiki is so easily customizable so it makes sense that this should be too.
Can you explain a little bit what you mean by this? I think the other "special tiddlers" (like "PageTemplate", "StyleSheetLayout" etc.) are hardcoded the same way as "DefaultTiddlers" and not really much easier to customize than the DefaultTiddlers. Actually I think it is even harder to customize these other "special tiddlers". E.g. if you look at Eric's SelectStylesheetPlugin that is intended to "customize" some special tiddlers: it takes quite some code to achieve this.
Yes you are correct that it takes some code to change say PageTemplate to AdminPageTemplate. But it can be done without hijacking or replacing any core functions. All you need to do is remove the old notification and a new one.
The removeNotificaton function in SelectThemePlugin shows how easy this can be.
Even easier and what I was really thinking of is the tiddlerTemplates:config.tiddlerTemplates = {
1: "ViewTemplate",
2: "EditTemplate"
};
config.tiddlerTemplates["1"] = "AdminViewTemplate";
What I am really driving at is that all such settings and special tiddlers should at least provide 'hooks' for plugins to allow easy customization. It does not necessarily have to be as easy as the above example. TiddlyWiki is so extremely versatile and easy to modify.... I guess I am just a at a loss as to why this is the one exception to the rule. Is it just plai n and simple inertia? Anyway...... I'm sure Jeremy will have a good reason if he decides not to make this change.
Cheers,
Saq
That is a fallback.....
<div id='displayArea'>
<div id='messageArea'></div>
<div id='tiddlerDisplay' macro='story defaultTiddlers'></div>
</div>
As it happens, it would make it possible to embed multiple <<story>>
macros in the page template.
So, under that approach, Saq's presentation macro would be a
replacement for the <<story>> macro - either overriding and extending
the built-in macro, or he could provide a differently named macro and
have people modify their PageTemplate (conceivably applying the new
macro automatically if it detects that the shadow PageTemplate hasn't
been overridden).
What do you think?
Cheers
Jeremy
--
Jeremy Ruston
mailto:jer...@osmosoft.com
http://www.tiddlywiki.com
On deciding whatever solution, pls. remember 'there is also life out
of your only lingo'
On Jul 14, 11:46 am, "Saq Imtiaz" <lew...@gmail.com> wrote:
I've been bothered right from the beginning that the "defaultTiddlers"
title is hardcoded in the way that it is. But the way that I had
wanted to fix it was to change the PageTemplate so that it referenced
the defaultTiddlers tiddler directly like this:
<div id='displayArea'>
<div id='messageArea'></div>
<div id='tiddlerDisplay' macro='story defaultTiddlers'></div>
</div>
However, I disagree with the idea of having a new "getDefaultTiddlers" function. Instead, "defaultTiddlers" should be a property (member variable) of story. Then restart becomes: