listtiddler.fields.list = $tw.utils.stringifyList(list);
--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/d/optout.
Hi TheDiveO> So what I am doing wrong here?The problem is that the $tw.Tiddler object is immutable; you can't reach into it and change the value of fields. If you want to change the value of a tiddler the correct way is to add a new tiddler that overwrites it. (I have been meaning to explore using getters for tiddler fields so that attempting to write to one will raise an error).
There's a second problem though: macros mustn't have side effects beyond returning their resulting text. If you want to modify stuff you would normally write a widget, or conceivably a startup module.
Anyhow, I think a neater way to do this might be to add support for a new field "list-before" (and possibly "list-after"). When we compute the list order for the tiddlers with a particular tag we'd start by positioning the tiddlers specified in the list field of the tag (as we do now). At the moment, any remaining tiddlers are just appended to the end of the list. But we could use the "list-before"/"list-after" fields to position them relative to other tiddlers already in the list.
After posting it occured to me that I'm trying to modify a shadow object. I understand that I can check for a shadow tiddler using $tw.wiki.isShadowTiddler(title). If I tripped on one, how do I clone it then?
Actually, I'm not really defining a macro with side effect; you're perfectly right on spot that doing so is a really bad practise. What I meant is doing a startup module. At the moment I've packed this into a tiddler of type "application/javascript" with module-type "macro". I suspect the latter setting isn't the correct way to do this? What module-type should I use instead?
Anyhow, I think a neater way to do this might be to add support for a new field "list-before" (and possibly "list-after"). When we compute the list order for the tiddlers with a particular tag we'd start by positioning the tiddlers specified in the list field of the tag (as we do now). At the moment, any remaining tiddlers are just appended to the end of the list. But we could use the "list-before"/"list-after" fields to position them relative to other tiddlers already in the list.
Doesn't this still lack the indication of which list to modify?
Hi TheDiveOAfter posting it occured to me that I'm trying to modify a shadow object. I understand that I can check for a shadow tiddler using $tw.wiki.isShadowTiddler(title). If I tripped on one, how do I clone it then?
It makes no difference; you can call wiki.addTiddler() to replace a shadow tiddler with an ordinary tiddler.
You can put it in a "browser-startup" module but that would mean that it would only execute in the browser.
Under the approach I'm suggesting we wouldn't need to actually modify the list field. We'd be dynamically placing the leftover tiddlers when wiki.sortByList() is called.
Would be $tw.wiki.addTiddler(new $tw.Tiddler(listtiddler)) a correct way to clone a tiddler? I'm still not accustomed to TW hacking, so please bear with me asking seemingly simple and stupid questions.
You can put it in a "browser-startup" module but that would mean that it would only execute in the browser.
Hmmm ... that wouldn't be exactly what we need, would it? When I'm making the tiddler of module-type: library, then my script crashes because there is (yet?) no getTiddlersWithTag() defined by the time my library gets called. In contrast, macros get instantiated only later when all things are in place. Is there something missing in between "library" and "macros" or is it just me not understanding the idea behind this sequence and modularization (which I suspect)?
Under the approach I'm suggesting we wouldn't need to actually modify the list field. We'd be dynamically placing the leftover tiddlers when wiki.sortByList() is called.
Ahh ... I'm beginning to see where this should lead to. I have to admit that before this explanation I didn't understood why you are mentioning wiki.sortByList(). But now, it really makes sense. Improving sortByList would avoid having to run my "fixing" module and would never need to modify the lists permanently, thus avoiding any cloning of shadow tiddlers and thus changing the overall persistent state. That surely is the right way to do...
Pull requests welcome :)
(function(){ /*jslint node: true, browser: true */ /*global $tw: false */ "use strict"; /* Sorts an array of tiddler titles according to an ordered list */ exports.sortByList = function(array,listTitle) {
...
It gets loaded and I see the module getting executed. However, it doesn't seem to replace the (existing) sortByList() function. Is this possible at all or am I doing something wrong here?
Hi TheDiveO
If you're working in the browser things aren't so simple. You'd probably be best off cloning $:/core/modules/wiki.js and modifying your copy. To make a pull request you'd clone the repo and then paste your modified wiki.js directly on github.com.
If all of this is sounding horrendously complex, don't panic! Pull requests can wait.
No need to apologise for ensuring correct administration. You've a pull request for the CLA. Never thought I would ever be able to contribute anything to TW... :)
--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/d/optout.