Changes between Initial Version and Version 1 of SortedTodos

Show
Ignore:
Timestamp:
05/09/09 10:42:38 (8 years ago)
Author:
chriz (IP: 84.61.119.128)
Comment:

Migrated from old trac wiki

Legend:

Unmodified
Added
Removed
Modified
  • SortedTodos

    v1 v1  
     1The scripts shown here use the DynamicTodoList script as found in Erik Neumann 's GettingThingsDone script, but changed to add functionality which sorts the page according to TAG words or todo.TYPE.  
     2 
     3there's a few versions here, starting with... 
     4 
     5=== SortedTodos by Jaysen Naidoo === 
     6it works with all WikiWords starting with ToDo / TODO / Todo: 
     7 
     8 * Opening a page called ToDo -> generates a list of ALL Todos with 'todo' in it 
     9 * Opening any page starting with Todo - for example Opening a page called TodoNEXT -> will generate a list of all Todos with strings 'todo' AND 'NEXT' in the text (including "todo.NEXT:") 
     10 
     11The Todos are then sorted according to further categories that can be customised in the code (look for TAG LIST in the code below or in attachment todos.py) 
     12 
     13Todos that have more than one Tag Word in it are displayed in the category that comes first in the TAG LIST, and not duplicated (although this can be easily changed) 
     14... 
     15 
     16'''How To Use This Script :''' 
     17 
     18 * Create '''user_extensions''' directory under your WikidPad directory 
     19 * Copy there "WikidPadHooks.py" and "WikiSyntax.py" from '''extensions''' directory 
     20 * Never edit original files in '''extensions''', only copies in '''user_extensions''' directory 
     21 * Edit '''WikidPadHooks.py''' file: add following script into '''openedWikiWord''' function 
     22 * '''CLOSE AND RESTART''' WikidPad to activate the changes 
     23 
     24 
     25{{{ 
     26#!python 
     27def openedWikiWord(wikidPad, wikiWord): 
     28    if (wikiWord[:4].upper() == "TODO"): 
     29        # tags contains the (Tag, TagHeader) pairs - customize the list of sort categories here: 
     30        # TagHeaders are the descriptive headings that will be shown for each category. 
     31        tags = [('HIGH','Tagged HIGH !'), 
     32                ('_spec.SPACER',''), 
     33                ('NEXT','Next Actions'), 
     34                ('ThisWeek','Tagged for This Week'), 
     35                ('_spec.SPACER',''), 
     36                ('_spec.NOTAGS','Untagged Todos'), 
     37 
     38 
     39                ('_spec.SPACER',''), 
     40                ('SomeDay','SomeDay / Maybe'), 
     41                ('_spec.SPACER',''), 
     42                ('TimeToTime','Tagged for from time to time'), 
     43                ('_spec.SPACER',''), 
     44                ('LOW','Tagged as LOW'), 
     45                ('_spec.SPACER',''), 
     46                ('VeryLow','Tagged as Very LOW')] 
     47 
     48        srchstr = wikiWord[4:] 
     49     
     50        # get all todos with 'todo' in them to seperate list to be used here: 
     51        todosFull = wikidPad.wikiData.getTodos() 
     52        todos = [todo for todo in todosFull if ('todo' in todo[1] and srchstr in todo[1]) ] 
     53 
     54        #clean the page code - and insert the harvested todos after placemark = '++ auto-harvested todos:' 
     55        editor = wikidPad.editor 
     56        st = editor.FindText(0, editor.GetLength(), "++ auto-harvested todos:", 0) 
     57        st = editor.PositionFromLine(1+editor.LineFromPosition(st)) 
     58        editor.SetSelection(st, editor.GetLength()) 
     59        editor.ReplaceSelection("\n") 
     60     
     61        # handle the page by displaying all keywords with srchstr  -> list all todos : 
     62        tagAdded = True    #used to stop two spacers in a row 
     63         
     64        for tag in tags: 
     65            wroteHeader = False   #used to make sure that header is written only once - in a non-empty category 
     66             
     67            # handle special tag '_spec.SPACER' by writing SPACERs in the tag list: 
     68            if tag[0] == '_spec.SPACER' and tagAdded: 
     69                editor.AddText('\n' + ('-'*70) + '\n') 
     70                tagAdded = False 
     71     
     72            # handle special NOTAG in the tag list 
     73            # This displays all untagged todos   : 
     74            elif tag[0] == '_spec.NOTAGS': 
     75                for todo in todos: 
     76                    foundTag = False 
     77                    for t in tags: 
     78                        if t[0] in todo[1]: 
     79                            foundTag = True 
     80                            break 
     81                         
     82                    if not foundTag and todo[0] != 'DEL': 
     83                        if not wroteHeader: 
     84                            editor.AddText('\n++ ' + tag[1] + ' :\n') 
     85                            wroteHeader = True 
     86                            s = str(todo[1]) 
     87                            editor.AddText(' * '+ str(todo[0]) + ': '+  s[s.find(':')+1:] + '\n') 
     88 
     89                        todos[todos.index(todo)] = ('DEL','DEL') #marks that todo to be ignored 
     90                        tagAdded = True 
     91     
     92            # handle normal Tags - write the todos for that tag: 
     93            else: 
     94                for todo in todos: 
     95                    if (tag[0] in todo[1]): 
     96                        if not wroteHeader: 
     97                            editor.AddText('\n++ ' + tag[1] + ' :\n') 
     98                            wroteHeader = True 
     99                        s = str(todo[1]) 
     100                        editor.AddText(' * '+ str(todo[0]) + ': '+  s[s.find(':')+1:] + '\n') 
     101                        todos[todos.index(todo)] = ('DEL','DEL') #marks that todo to be ignored 
     102                        tagAdded = True 
     103    
     104}}} 
     105 
     106 
     107'''Alternative using todos.py :''' 
     108 
     109 * save Todos.py (attached to this wiki page) in \user_extensions folder 
     110 * change WikidPadHooks.py is as follows : 
     111    * add the following to use todo.py (i'm not sure if this is the best or only way to do this)..  
     112{{{ 
     113#!python 
     114from sys import path 
     115path.append("C:\Program Files\WikidPad\user_extensions")  # replace this with the location of your Todos.py file 
     116import Todos 
     117}}} 
     118 
     119    * added the following to openedWikiWord hook: 
     120{{{ 
     121#!python 
     122def openedWikiWord(wikidPad, wikiWord): 
     123        if (wikiWord[:4].upper() == "TODO"): 
     124            Todos.genTodos(wikidPad, wikiWord) 
     125 
     126}}} 
     127 
     128 
     129 
     130---- 
     131 
     132For the 1.6Beta4, I needed to change the line 
     133 
     134{{{ 
     135editor = wikidPad.editor 
     136}}} 
     137 
     138to 
     139  
     140{{{ 
     141editor = wikidPad.activeEditor 
     142}}} 
     143 
     144---- 
     145 
     146It would be cleaner to use  
     147 
     148{{{ 
     149editor = wikidPad.getActiveEditor() 
     150}}} 
     151 
     152instead. 
     153 
     154=== Mods from Mike Crowe === 
     155Email me at mike at mikeandkellycrowe dot com 
     156 
     157I wanted my list to have dynamic tags, rather than the pre-defined tags always being hard-coded.  Added code to scan todos for unknown tags, append them with description of "Tagged (tag)": 
     158''Notes'': 
     159  * For dumb people like me, make sure you put it in __openedWikiWord__ and not ''openWikiWord''.  Big Difference  ;) 
     160  * This is compatible with 1.7a.   
     161  * In your main page, enter a link of ![Todo] to activate 
     162Code: 
     163{{{ 
     164#!python 
     165def openedWikiWord(wikidPad, wikiWord): 
     166    """ 
     167    Called when a new or existing wiki word was opened successfully. 
     168 
     169    wikiWord -- name of the wiki word to create 
     170    """ 
     171    if (wikiWord[:4].upper() == "TODO"): 
     172        # tags contains the (Tag, TagHeader) pairs - customize the list of sort categories here: 
     173        # TagHeaders are the descriptive headings that will be shown for each category. 
     174        tags = [('High','Tagged HIGH !'), 
     175                ('_spec.SPACER',''), 
     176                ('Next','Next Actions'), 
     177                ('ThisWeek','Tagged for This Week'), 
     178                ('_spec.SPACER',''), 
     179                ('SomeDay','SomeDay / Maybe'), 
     180                ('_spec.SPACER',''), 
     181                ('TimeToTime','Tagged for from time to time'), 
     182                ('_spec.SPACER',''), 
     183                ('Low','Tagged as LOW'), 
     184                ('_spec.SPACER',''), 
     185                ('VeryLow','Tagged as Very LOW')] 
     186         
     187        # MikeCrowe -- Untagged always at end of list 
     188        tagEnd = [ 
     189                ('_spec.SPACER',''), 
     190                ('_spec.NOTAGS','Untagged Todos')] 
     191 
     192 
     193        srchstr = wikiWord[4:] 
     194     
     195        # get all todos with 'todo' in them to seperate list to be used here: 
     196        todosFull = wikidPad.wikiData.getTodos() 
     197        todos = [todo for todo in todosFull if ('todo' in todo[1]) ] # and srchstr in todo[1]) ] 
     198 
     199        #clean the page code - and insert the harvested todos after placemark = '++ auto-harvested todos:' 
     200        editor = wikidPad.getActiveEditor() 
     201        st = editor.FindText(0, editor.GetLength(), "++ auto-harvested todos:", 0) 
     202        st = editor.PositionFromLine(1+editor.LineFromPosition(st)) 
     203        editor.SetSelection(st, editor.GetLength()) 
     204        editor.ReplaceSelection("\n") 
     205 
     206        # handle the page by displaying all keywords with srchstr  -> list all todos : 
     207        tagAdded = True    #used to stop two spacers in a row 
     208        checkTags = [tag[0] for tag in tags] 
     209 
     210        # MikeCrowe -- code to search for tags not in above list and automatically add 
     211        for todo in todos: 
     212            allTodo = todo[1].split(":") 
     213            words = allTodo[0].split(".") 
     214            for word in words[1:]: 
     215                if not word in checkTags: 
     216                    tags.append( ("_spec.SPACER","") ) 
     217                    tags.append( (word,"Tagged "+word) ) 
     218                    checkTags.append(word) 
     219        tags = tags + tagEnd 
     220 
     221        for tag in tags: 
     222            wroteHeader = False   #used to make sure that header is written only once - in a non-empty category 
     223             
     224            # handle special tag '_spec.SPACER' by writing SPACERs in the tag list: 
     225            if tag[0] == '_spec.SPACER' and tagAdded: 
     226                editor.AddText('\n' + ('-'*70) + '\n') 
     227                tagAdded = False 
     228     
     229            # handle special NOTAG in the tag list 
     230            # This displays all untagged todos   : 
     231            elif tag[0] != '_spec.NOTAGS': 
     232                for todo in todos: 
     233                    if (tag[0] in todo[1]): 
     234                        if not wroteHeader: 
     235                            editor.AddText('\n++ ' + tag[1] + ' :\n') 
     236                            wroteHeader = True 
     237                        s = str(todo[1]) 
     238                        editor.AddText(' * '+ str(todo[0]) + ': '+  s[s.find(':')+1:] + '\n') 
     239                        todos[todos.index(todo)] = ('DEL','DEL') #marks that todo to be ignored 
     240                        tagAdded = True 
     241            # handle normal Tags - write the todos for that tag: 
     242            else: 
     243                for todo in todos: 
     244                    foundTag = False 
     245                    for t in tags: 
     246                        if t[0] in todo[1]: 
     247                            foundTag = True 
     248                            break 
     249                         
     250                    if not foundTag and todo[0] != 'DEL': 
     251                        if not wroteHeader: 
     252                            editor.AddText('\n++ ' + tag[1] + ' :\n') 
     253                            wroteHeader = True 
     254                            s = str(todo[1]) 
     255                            editor.AddText(' * '+ str(todo[0]) + ': '+  s[s.find(':')+1:] + '\n') 
     256 
     257                        todos[todos.index(todo)] = ('DEL','DEL') #marks that todo to be ignored 
     258                        tagAdded = True 
     259}}} 
     260 
     261 
     262=== Another version by Christian Ziemski === 
     263 
     264Loosely based on the above and GettingThingsDone I wrote my own version. 
     265 
     266Due to handling issues I stored it on my site and not here in the wiki.  
     267Probably I'll change that later. 
     268 
     269Here is the address: http://www.ziemski.net/wikidpad/ 
     270 
     271Christian 
     272