Hi Måns,

The following code should work -- use with discretion.

Because you want to write over the same tiddler that you are using as
source, I added a bit of code to check if the tiddler has been
formatted. This should prevent you from running the script twice and
mangling the list. Got backups?

You can see that the very first variable holds the name of the source
listing to be formatted. A few other changes were necessary as well.

Mark

<script>
var src = "URL_LIST" ;
var txt = store.getTiddlerText(src) ;
if(txt.indexOf("[[") != -1) return "Tiddler " + src + " is already
wikified." ;
var tid = store.getTiddler(src) ;
var ara = txt.split("\n") ;
var out = "" ;

for(var i=0;i<ara.length;i+=3)
out += "[[" + ara[i]+"|"+ara[i+1]+"]]\n" ;
store.saveTiddler
(src,src,out,tid.modifier,tid.modified,tid.tags,tid.fields);
return "Tiddler " + src + " now wikified." ;
</script>

On Nov 23, 12:51 pm, Måns <humam...@gmail.com> wrote:
> Thanks a lot  Mark -
>
> I've tested it here:http://tinyurl.com/yafgwpp
> Works very well...
>
> One last question from me:
>
> I would like to make a version of your script which will overwrite the
> URL_LIST with the result..
> Will it work if I replace
> "return out;</script>" with "store.saveTiddler
> (tid.title,tid.title,txt,tid.modifier,tid.modified,tid.tags,tid.fields);
> </script> " ?
>
> Måns
>
> On 23 Nov., 21:21, "Mark S." <throa...@yahoo.com> wrote:
>
> > This is an extremely literal solution (not necessarily the best):
>
> > <script>
> > var txt = store.getTiddlerText("URL_LIST") ;
> > var ara = txt.split("\n") ;
> > var out = "" ;
> > for(var i=0;i<ara.length;i+=3)
> > out += "[[" + ara[i]+"|"+ara[i+1]+"]]\n" ;
> > return out ;
> > </script>
>
> > This works as long as every 3rd line is a HR. Note also that the HR
> > separated list format reverses the order of the URL and the Title from
> > that generated by the FF plugin.
>
> > Mark
>
> > On Nov 23, 11:44 am, Måns <humam...@gmail.com> wrote:
>
> > > Hi Mark
>
> > > Great script you've made - it solved many problems I encountered -
> > > trying to make my own.
> > > Thanks..
> > > How do I make your script use a hr-separated list but skip the
> > > '----' ?
>
> > > I've put my question to you in a MTC showing what options I have been
> > > playing with...
>
> > > There are two variations made to your UrlList-script and 2 scripts
> > > with very different purposes (one overwrites a tiddlerList and the
> > > other  filters a list and wikifies the result), which I've produced
> > > from different snippets, some of them I had from you and some from
> > > Eric.
>
> > >http://tinyurl.com/ToMark
>
> > > Regards Måns Mårtensson
>
> > > On 23 Nov., 18:07, "Mark S." <throa...@yahoo.com> wrote:
>
> > > > If you have Eric's Inline Javascript plugin, then this code will do a
> > > > quick and dirty job:
>
> > > > <script>
> > > > var txt = store.getTiddlerText("URL_LIST") ;
> > > > var ara = txt.split("\n") ;
> > > > var out = "" ;
> > > > for(var i=0;i<ara.length;i+=2)
> > > > out += "[[" + ara[i+1]+"|"+ara[i]+"]]\n" ;
> > > > return out ;
> > > > </script>
>
> > > > Where "URL_LIST" is the name of your tiddler with the alternating urls
> > > > and descriptions. Obviously this could be parameterized to use the
> > > > <<tiddler>> inclusion macro.
>
> > > > I haven't tried the FF plugin, but it sort looks like you should be
> > > > able to make it produce a wikified output.
>
> > > > Mark
> > > > On Nov 23, 6:31 am, Amzg <matiasg...@gmail.com> wrote:
>
> > > > > On Nov 22, 4:00 pm, BC <bruce.armstr...@gmail.com> wrote:
>
> > > > > > Incidentally, if like me, you tend to have too many tabs open all at
> > > > > > once and don't want to bookmark them, the Copy All Urls Firefox 
> > > > > > add-on
> > > > > > works great for tiddly bookmarking 
> > > > > > also:https://addons.mozilla.org/en-US/firefox/addon/934
>
> > > > > HA! That is GREAT!! Bookmark-LISTS are much more suitable in TW than
> > > > > FF because it is a lot easier to edit such a list in TW and, via
> > > > > framedLinksPlugin, take a peek at a bookmark.
>
> > > > > ...and how about this little addition;
>
> > > > > Create a tiddler titled URLlist, and put the following [1] in it:
> > > > > <<newJournal title:'URLs - YY0MM0DD' tag:'URLs' label:'Ctrl+Alt+C then
> > > > > paste'  >>
>
> > > > > Pressing the resulting button gives a new tiddler where to paste the
> > > > > URL list, and it is automatically named with todays date and tagged
> > > > > with URLlist.
>
> > > > > You can then use a <<tiddler [[URLlist]]>> macro to put the resulting
> > > > > button e.g in the sidebar, perhaps accompanied by a slider to show the
> > > > > URLlist (via e.g TagglyTagging [2] or a forEachTiddler).
>
> > > > > Now, the resulting list from that firefox addon is pretty messy. It
> > > > > would be great if it somehow could be turned into pretty wikilinks,
> > > > > i.e from the current format;
>
> > > > > URL1
> > > > > Name1
> > > > > URL2
> > > > > Name2
>
> > > > > into
>
> > > > > [[Name1|URL1]]
> > > > > [[Name2|URL2]]
>
> > > > > Any thoughts?
>
> > > > > :-)
>
> > > > > [1] from 
> > > > > here:http://groups.google.com/group/tiddlywiki/browse_thread/thread/1a6372...
> > > > > [2]http://mptw.tiddlyspot.com/#TagglyTagging
>
>

--

You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To post to this group, send email to tiddlyw...@googlegroups.com.
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=.


Reply via email to