[tw] Re: Retitle a tiddler - conceptually easy - HA!

2017-09-19 Thread RichardWilliamSmith
If you're using chrome, it's probably easier to paste the code as a 
'snippet' into the sources panel of the dev tools and run it from there.

On Wednesday, September 20, 2017 at 6:30:19 AM UTC+10, Joshua Fontany wrote:
>
> The Developer Console in Chrome is usually accessed by pressing F12 while 
> on the tab/page you want to inspect. "Console" will be one of the tabs (w/ 
> debug output from TW). Paste PMario's code into the input bos at the bottom 
> with the "> " symbol. Other browsers may have other methods to access their 
> dev console.
>
> BTW, that a neat trick. :)
>
> Best,
> Joshua Fontany
>
> On Tuesday, September 19, 2017 at 1:06:53 PM UTC-7, JWHoneycutt wrote:
>>
>> by copy paste into my developer console - you mean just add a new tiddler 
>> called "PMario step 1"  with the body containing your code (stripped of 
>> comments) and save it - and it is going to reveal me a list of tiddlers to 
>> check??? 
>>
>> Developer console must be something else...
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/757aa5ea-17fc-4028-ac13-cdb65a5913f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Retitle a tiddler - conceptually easy - HA!

2017-09-19 Thread Joshua Fontany
The Developer Console in a Chrome is usually accessed by pressing F12 while 
on the tab/page you want to inspect. "Console" will be one of the tabs (w/ 
debug output from TW). Paste PMario's code into the input bos at the bottom 
with the "> " symbol. Other browsers may have other methods to access their 
dev console.

BTW, that a neat trick. :)

Best,
Joshua Fontany

On Tuesday, September 19, 2017 at 1:06:53 PM UTC-7, JWHoneycutt wrote:
>
> by copy paste into my developer console - you mean just add a new tiddler 
> called "PMario step 1"  with the body containing your code (stripped of 
> comments) and save it - and it is going to reveal me a list of tiddlers to 
> check??? 
>
> Developer console must be something else...
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/10508451-d542-4057-a641-7ebb00c75fbb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Retitle a tiddler - conceptually easy - HA!

2017-09-19 Thread JWHoneycutt
@PMario

I will just remove the "//" and everything that follows to the end of the 
line (remove all comments and keep the programming)

I did create 2 short scripts, that you can copy paste into your developer 
> console and execute there. 
> ...
> The following script doesn't modify anything. 
> It just outputs a list of new tiddler names. ... 
>

by copy paste into my developer console - you mean just add a new tiddler 
called "PMario step 1"  with the body containing your code (stripped of 
comments) and save it - and it is going to reveal me a list of tiddlers to 
check??? 

Developer console must be something else...

 

>
> "use strict";
> // read existing tiddlers
> var titles = $tw.wiki.getTiddlers();
>
> var newTitle = function (elem) {
> var xx,
>   match = elem.match(/(.+)(\d{4}-\d?\d-\d?\d)(.*)/);
> if (match != null) {
> // matched text: match[0]
> // match start: match.index
> // capturing group n: match[n]
>
> // swap matches
> if (match[1] && match[2]) {
> xx = match[2] + " " + match[1]
> }
>
> // If there is some text after the date append it
> // format:  --
> // just change the "--"   to your likings
> if (match[3]) xx = xx + "--" + match[3];
>
> return xx.trim(); // trim() removes trailing spaces
> } else {
> return elem;
> }
> }
>
> // create new titles
> var newTitles = titles.map(newTitle)
>
> newTitles.map(function(elem) {console.log(elem)})
>
>
>
> *Second step *- *Danger Zone*
> If the frist step went OK, you can use the second function to rewrite your 
> titles. 
>
> WARNING - Use a BACKUP !!
>
> "use strict";
> // read existing tiddlers
> var titles = $tw.wiki.getTiddlers();
>
> var rewriteTitles = function (elem) {
> var xx,
> match = elem.match(/(.+)(\d{4}-\d?\d-\d?\d)(.*)/);
> if (match != null) {
> // matched text: match[0]
> // match start: match.index
> // capturing group n: match[n]
>
> // swap matches
> if (match[1] && match[2]) {
> xx = match[2] + " " + match[1]
> }
>
> // If there is some text after the date append it
> // format:  --
> // just change the "--"   to your likings
> if (match[3]) xx = xx + "--" + match[3];
>
> var tid = $tw.wiki.getTiddler(elem)
> 
> xx.trim(); // trim() removes trailing spaces
>
> // danger zone ...
> if (tid) {
>   $tw.wiki.addTiddler(new $tw.Tiddler(tid, {title: xx}));
>   $tw.wiki.deleteTiddler(elem);
>
>   // create some feedback
>   console.log(elem, "-->", xx);
> }
>
> return xx; 
> } else {
> return elem;
> }
> }
>
> // Enter the Danger Zone!
> // BACKUP - BACKUP - BACKUP before you execute this!
>
> // You need to uncomment the next line to excute the function!!
> // titles.map(rewriteTitles);
>
>
>
> Depending on the number of tiddlers, this may take some time. 
>
> have fun!
> mario
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/e8d7c6b7-216b-41a2-89ed-f4a6db2ff57b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Retitle a tiddler - conceptually easy - HA!

2017-09-19 Thread JWHoneycutt
@PMario

How exciting...

Thank you for the code - I take your warning to heart and created a backup 
TW5.html, renamed it, and am working on it in a separate "sandbox".

For some reason, all your comments start with "//" - but for my 
implementation of TW5, this just italicizes the text that follows, and 
therefore doesn't run.

It must be one of my loaded plugins?
 
 
*adds the ability to encrypt single tiddlers*
$:/plugins/danielo/encryptTiddler
*2.1*
<#%24%3A%2Fplugins%2Fdanielo%2FencryptTiddler>
 
 
*Context search - provides visual highlight of search results*
$:/plugins/danielo515/ContextPlugin
*2.1.0*
<#%24%3A%2Fplugins%2Fdanielo515%2FContextPlugin>
 
 
*rQuickTid - attention-free note taking*$:/plugins/TWaddle/rQuickTid
*1.0.9*
<#%24%3A%2Fplugins%2FTWaddle%2FrQuickTid>
 
 
*TiddlyWiki5 core*$:/core
*5.1.14*
<#%24%3A%2Fcore>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/b22ea88c-71e2-4ddd-84ec-8bf16556d53c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Retitle a tiddler - conceptually easy - HA!

2017-09-19 Thread JWHoneycutt
@Mark S

Thank you. You wrote:

In database theory, one of the central tenets is to use each field to do 
> only one thing. TW already breaks this by using the Title field for a title 
> and an ID. Now you want to also use it for a date field.
>

Agreed, except that BECAUSE the title is the ID, and each is unique, if I 
remove the date from the title I have 100 tiddlers all trying to share the 
title "Staff meeting"
 

> Why not extract the dates and put them in their own date field (e.g. 
> actiondate). Then you can sort on that field. This has the additional 
> benefit of not breaking any existing links.
>

Also a good idea, except that my sorts look like this, and I am still 
working on figuring out "second order sorts"
 <> 
 
JWHoneycutt

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/6af98b44-eeeb-4822-9888-3a284bbaca7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Retitle a tiddler - conceptually easy - HA!

2017-09-19 Thread TonyM
Mario,

You seem to be a wizard. Can you confirm your approach for me so I may learn 
from your example?

Loading tiddlywiki in your browser it is stored in active memory. I the 
developer console you are running a script to search then modify the tiddlywiki 
in memory. Then the user will save it (from memory) to disk and WALA it is now 
modified?

Is this another strong point for tiddlywikis single file quine nature or are 
there other cases that work the same?

Thanks
Tony

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/c7a4e855-6861-43d9-bf21-24a1c2142834%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Retitle a tiddler - conceptually easy - HA!

2017-09-18 Thread TonyM


Just a high level idea,

I agree with Mark

List all tiddlers with dates, which a check box to flag them suffix or 
Prefix or Other
Write a process to move the suffix or prefix into a field titledate
Manually fix the balance which is tagged other

You could stop there and sort the list based on the value of the field 
titledate.

However you could list all tiddlers with a title-date next to there tiddler 
title and scan the list to ensure all are of the correct form
If should be fairly easy to then process all tagged suffix to remove the 
suffix and add the titledate back as the prefix title

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/1ac61ce2-458f-4373-a199-0ac93d0457bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Retitle a tiddler - conceptually easy - HA!

2017-09-18 Thread 'Mark S.' via TiddlyWiki
In database theory, one of the central tenets is to use each field to do 
only one thing. TW already breaks this by using the Title field for a title 
and an ID. Now you want to also use it for a date field.

Why not extract the dates and put them in their own date field (e.g. 
actiondate). Then you can sort on that field. This has the additional 
benefit of not breaking any existing links.

Mark

On Monday, September 18, 2017 at 9:41:41 PM UTC-7, JWHoneycutt wrote:
>
> I realistically have a thousand tiddlers with titles like:
>
>- Foo Bar meeting 2016-9-12
>- Quarterly staff meeting 2017-04-22
>- 2017-07-21 Department Huddle
>
> Of note: all dates start with the character string "201"
>
> I am interested in renaming them with the date in the front of the title, 
> so that I can "!sort[]" them in filters, easily giving me the most recent 
> ones at the top of the list.
> *How do I accomplish this?* My guess is:
>
>1. Filter for all tiddlers whose title ends in a date (must allow for 
>optional 1 character months and days) (changing dates to add zeros was 
> done 
>by Stephan Hradek in this thread: 
>https://groups.google.com/forum/#!topic/tiddlywiki/eTbODCaTuYk)
>2. Use the fieldmangler widget to modify the field named "title"
>3. First I need to capture the date as a variable
>4. Change the value of the field(title) by removing the date from the 
>end (somehow using "suffix")
>5. Change the value of the field(title) by adding the same date to its 
>beginning followed by a single space (somehow using "prefix" - maybe both 
>functions can be done in one step?)
>6. Move onto the next tiddler in the filtered output of step #1
>
> Is this line of thinking the easiest way to accomplish this (based on my 
> early understanding of TW5)?
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/637e943e-2285-4fee-a39b-4af33f37f6de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.