dogMelon Note Studio Forum Index dogMelon Note Studio
For discussion of all aspects of Note Studio
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Plugin question
Goto page 1, 2, 3, 4  Next
 
Post new topic   Reply to topic    dogMelon Note Studio Forum Index -> Note Studio
View previous topic :: View next topic  
Author Message
njovin
Guest





PostPosted: Tue Sep 27, 2005 5:08 pm    Post subject: Plugin question Reply with quote

I, too, am developing some plugins. I am working on one that will accept some input from the user to generate new pages based on existing templates.

I read allan's earlier post, which helped me with step two of the process, but step 1 was never mentioned!

I know the tutorial is in the works, but I was wondering if someone can post sample code for displaying an input box to collect user input.

Thanks.
Back to top
ant
Dogmelon


Joined: 13 Jan 2004
Posts: 559
Location: Perth, Australia

PostPosted: Thu Sep 29, 2005 2:50 am    Post subject: Reply with quote

I don't have one handy to post. If you're just collecting one text parameter, you can use the wx built-in text collection dialog, sort of like:

Code:
      dlg = wxTextEntryDialog( self, "prompt","dialog name", "default")
      if dlg.ShowModal() == wxID_OK:
         text = dlg.GetValue()


I'll have to get back to those tutorials!
Back to top
View user's profile Send private message Visit poster's website
allan
Guest





PostPosted: Thu Sep 29, 2005 12:29 pm    Post subject: my plug in script Reply with quote

Here is the plug in I developed for capturing all my todo actions across all books in one summary page, this is followed by the control file the script requires. The control file can be tailored to your own use (you will need to ensure that the target book in the control file exists in your collection) as this is where the summary page is published. It seems to work fine with NS3.0 and NS3.1. Always interested in any ideas for improvement. Please note its my first attempt at a Python program so the real Python programmers will probably have a fit Smile

You will need to

1. Copy the plugin script to windows notepad and save the file as 'create_actions_list.py' in the Notestudio plugin folder (in my case its c:\program files\Notestudio\plugin)

2. Copy the control file data to windows notepad and save the file as 'create_actions_list.ini' in folder 'c:\'. (I know I should be more sophisticated as to where this temp file resides ... sorry)

Being able to use python scripts to enhance NS is really great and as this script is building a Notestudio page it opens up endless possibilities, this has stimulated lots of ideas for some further scripts I want to develop.

Maybe we could start a plugin sub forum and submit scripts and python code snippets for others to use.

Let me know how it goes.

Cheers
Allan Davies

===============================================

THE PYTHON SCRIPT

#-----------------------------------------------------------------------------------------
# Create Action Lists python script for Notestudio 3.x - Version 1
#-----------------------------------------------------------------------------------------
# This plugin finds the lines in every Notestudio book which contain specific tags
# such as GTD style links [@Calls], [@Errands] etc. and creates a notestudio page
# in a book which shows all the results and allows you to see ALL of your actions
# for your whole collection one place.
#
# Each tag and the target book for the results page are specified in the file
#
# c:\create_action_lists.ini
#
# you can change the tags in this file to suit your own needs
#
# Note. A temporary text file called "C:/ActionsList.txt" is created by the script
# (I don't delete it after use as it can be copied easily into notepad or a palm memo)
#
#-----------------------------------------------------------------------------------------
# VERSION HISTORY
#
# 1.0 Basic version that has the search tags and target book defined in a separate 'ini' text file
#
#-----------------------------------------------------------------------------------------
# PLANNED ENHANCEMENTS
#
# Now Ant has explained how to pass parameters from the pre-execute to the execute functions I will
# be setting up a GUI form which draws it information from the ini file and displays a selection
# form where further selection rules can be added such as setting a report format (which is
# current hard coded in the script)
#
# Hope this helps other plug in developers .. Allan Davies, Melbourne, Australia Sep 2005
#
#-----------------------------------------------------------------------------------------

from WikiPlugin import *
from AppData import *
import string
import StringIO
import time

##*********************************************************'
def getName():
##*********************************************************'
#
# This is the name that appears on the 'plugin' menu.
# It should be unique
#
return "Create Actions List - V1.0"


##*********************************************************'
def getVendorName():
##*********************************************************'
#
# The name of the person who developed the plugin
#
return "Allan Davies. A devoted Notestudio user"


##*********************************************************'
def getVendorVersionString():
##*********************************************************'
# A version string for this plugin
#
return "1.0"


##*********************************************************'
def getDescription():
##*********************************************************'
#
# A brief, helpful description of the plugin
#
return \
"-----------------------------------------------------------------------------------------"+\
" Create Action Lists python script for Notestudio 3.x - Version 1 "+\
"-----------------------------------------------------------------------------------------"+\
" This plugin finds the lines in every Notestudio book which contain specific tags "+\
" such as GTD style links [@Calls], [@Errands] etc. and creates a notestudio page "+\
" in a book which shows all the results and allows you to see ALL of your actions "+\
" for your whole collection one place. "+\
" "+\
" Each tag and the target book for the results page are specified in the file "+\
" "+\
" c:\create_action_lists.ini "+\
" "+\
" you can change the tags in this file to suit your own needs "+\
" "+\
"-----------------------------------------------------------------------------------------"



##*********************************************************'
def preExecute():
##*********************************************************'
#
# Do anything you need to do before running the plugin.
# This could include popping up a dialog to collect parameters.
# returns a list of parameters, which will be passed to the execute() method
#
STAGE_NAME = "preExecute"
return []


##*********************************************************'
def execute( parameterList ):
##*********************************************************'
#
# Here is where you actually do the plugin tasks.
#
# If anything goes wrong, you can throw a WikiPluginException
# as follows:
#
STAGE_NAME = "execute"

bThrowException = False

dlg = wxMessageDialog( None, "About to create Action Lists", "Create Action List", wxOK )
dlg.ShowModal()
#========== default search parameters ===============
#read text file and create an actions page with todays timestamp


configList = []
ActionTagList = []

#-------------------------------------------------------------------------------------------
# Get run time parameters (Action tags such as [@Calls]. These are contained in an 'ini' file
#
# The ini file contains search tags eg. tag=@Calls and thye target book to create the action lists
# page
#-------------------------------------------------------------------------------------------


#Open the ini file, abandon script if file not found. Note.
configFile = open("C:/create_actions_list.ini", "r" ) #Had to use capital C for the drive reference to work..python quirk??
if configFile == None:
dlg = wxMessageDialog( None, "create_actions_list.ini file missing....plugin cannot run", "Create Action List", wxOK )
dlg.ShowModal()
return []
configList=configFile.readlines()
configFile.close()


#Find the target book parameter (book=bookname)
for s in configList:
if s.startswith("book="):
targetbookname=s[s.index("=")+1:].strip()


#Find the search tags (tag=searchargument)
for s in configList:
if s.startswith("tag="):
ActionTagList.append(s[s.index("=")+1:].strip())

#-------------------------------------------------------------------------------------------
# Scan all books for the search tags and write the selected lines to a temporary file.
# This processing currently has two algorithms to support two report formats
#-------------------------------------------------------------------------------------------

#Set the title for the search results page that will be added or updated in the target book
pageTitle="Actions List"
book = theAppData.library.findBook(targetbookname)

actionPage = book.findPage(pageTitle)
if actionPage == None: #if no page found add it
book.addPageWithNameAndContents(pageTitle, "Empty Action List")
actionPage = book.findPage(pageTitle)

#Set the default text for the page
actionPage.setText("Empty Action List")

# Create Actions in a temporary text file first
outputFile = open( "C:/ActionsList.txt", "w" )
outputFile.write( "+++Actions List - "+time.strftime("%d %b %Y %H:%M:%S", time.localtime())+"\n" )

#============================================
#Set desired report type
reporttype="Group by Book, Action Tag"
#============================================

numBooks = theAppData.library.getNumBooks()

#Report format 1 - Produce page in Action Tag order eg. All @Calls grouped together
if reporttype=="Group by Action Tag":
#Search all books for each ActionTag
for tag in ActionTagList:
outputFile.write( "___\n+++%s\n"%(tag))

for i in range( numBooks ):

#Write Book Header
book = theAppData.library.getBook( i )
bookName = book.getDisplayName()

#Co through pages of current book
numPages = book.getNumPages()
for i in range( numPages ):
pageName = book.getPageName( i )
page = book.getPage( i )
rawText = page.getText()

if string.find( rawText, tag ) != -1:
stringStream = StringIO.StringIO( rawText )
pageLines = stringStream.readlines()
for line in pageLines:
if string.find( line, tag ) != -1:
outputFile.write("[%s|%s]\t%s"%(bookName,pageName,line))

# Report format 2 - Produce page in book, search tag sort order
if reporttype=="Group by Book, Action Tag":
#Search all books for each ActionTag
for i in range( numBooks ):

#Write Book Header
book = theAppData.library.getBook( i )
bookName = book.getDisplayName()
outputFile.write( "___\n+++%s\n"%(bookName))

for tag in ActionTagList:
#Go through pages of current book
numPages = book.getNumPages()
for i in range( numPages ):
pageName = book.getPageName( i )
page = book.getPage( i )
rawText = page.getText()

if string.find( rawText, tag ) != -1:
stringStream = StringIO.StringIO( rawText )
pageLines = stringStream.readlines()
for line in pageLines:
if string.find( line, tag ) != -1:
outputFile.write("[%s|%s]\t%s"%(bookName,pageName,line))

outputFile.close()


#-------------------------------------------------------------------------------------------
# Read the temporary text file back and create an actions page with todays timestamp
# in the target Notestudio book.
#-------------------------------------------------------------------------------------------

# Read selected lines from temporary file
inputFile = open( "C:/ActionsList.txt", "r" )
rawText=""
for line in inputFile.readlines():
rawText=rawText+line
inputFile.close()

#-------------------------------------------------------------------------------------------
#Now create the Action List Page
#-------------------------------------------------------------------------------------------

#Clear the Actions Page in target Book
actionPage.setText(rawText)

#Refresh Notestudio screen
theAppData.appFrame.onRefresh()

#inform user action list created
dlg = wxMessageDialog( None, "Action List Created in Book "+targetbookname, "Finished!", wxOK )
dlg.ShowModal()

#Refresh Notestudio screen
theAppData.appFrame.onRefresh()

if bThrowException:
raise WikiPluginException( STAGE_NAME, "Some error string describing the problem" )

##*********************************************************'
def postExecute():
##*********************************************************'
#
# Do anything you need to clean up after running the plugin.
#
STAGE_NAME = "postExecute"
pass






===============================================

THE CONTROL FILE

*Configuration File for Python Script create_actions_list V1.0
*
* This file is an 'ini' file which has all the

* configuration data for searching out specific strings in
* any Notestudio books in the current collection and creating
* a summary page in a target book.

*============
* Search Tags
*============
tag=[@Calls]
tag=[@Errands]
tag=[@WaitingFor]
tag=[@OfficePC]
tag=[@HomePC]
tag=[.Allan Davies]

*=================================================
* Target Book to create output page 'Actions List'
*=================================================
book=ADGTD

*END OF INI FILE
Back to top
ant
Dogmelon


Joined: 13 Jan 2004
Posts: 559
Location: Perth, Australia

PostPosted: Fri Sep 30, 2005 12:03 am    Post subject: Reply with quote

Hi Alan,

Thanks for this. I've made a new page on our site at http://www.dogmelon.com.au/ns/Plugins%20-%20Downloads.shtml

If possible, would you be able to send support@dogmelon.com.au the plugin files, as well as the info required by that page, so we can put up your plugin?[/url]
Back to top
View user's profile Send private message Visit poster's website
lemayp



Joined: 24 Sep 2005
Posts: 246
Location: Laval, Canada

PostPosted: Fri Oct 07, 2005 1:28 am    Post subject: Reply with quote

Allan,

I was waiting to have a more stable version of NS (which 3.1.1 seem to have provide me!!!) before trying your little plugin that appeared, when I read your code, as promising.

The only thing I would like to say is:

WOW!

That's a very interesting and practical plugin and I have just started to use it and I think that it will be very usefull for me. Thanks.

I like the fact that it allow the possibility to leave the action items inside of the original project page and then ask your plugin to scan all pages, I.E. All projects, and then generate a report group by action tag (that the report I prefer, I know your plugin can generate report by books instead.) That mean that as I write stuff in my project description or journal, I can immediatly put there any actions that come to my mind:
[@PC]Put a note in Newsgroup about the create_action_list plugin
[@Calls]Call dogmelon to inform them to update the GTD page
[@PC]Update my plugin list of tag

and then simply ask your plugin to generate me a report, i.e. a NS page, that will contains the list of action from ALL projects, located inside of all books.

I think this is a feature that should be more documented and put inside of the GTD page of NoteStudio (Don't you think Ant?). Ideally, a dedicated page that would show some basic examples and screen shot would probably be good to convert some GTD doer to take a deeper look at NoteStudio.

The installation of the plugin was not that evident since I failed to read your post completely here and refer to the readme that was failing to contains the steps you have mentionned here.

I have put a link in my home page to the [Action list] page, so I can refer to it anytime. Since the plugin only work on PC, not on Palm, I create a report just before I synch with my Palm and then I have the report in my Palm ready to be used whenever I need it.

Thanks a lot for that very good plugin. I think it will be very usefull.

- Pierre

PS: Ant, would it be possible to consider adding a "search in the current page" feature that will search and position oneself to where the string has been found? For instance, if I have in a hundreds line projects page one line containing the tag named "[@Calls]" I would like to locate it quickly once the plugin told me there is such entry that page. That would be good for both the Windows and Palm implementation.
Back to top
View user's profile Send private message Visit poster's website
lemayp



Joined: 24 Sep 2005
Posts: 246
Location: Laval, Canada

PostPosted: Fri Oct 07, 2005 2:59 am    Post subject: Reply with quote

Allan,

I went to the python language web page in order to learn some basic things about the language and I have been able to change your plugin in order to make the tag search case unsensitive, qualify "@Calls" with "@calls" and "@CAlls"...

I am wandering if people would prefer it this way or not...

what do you think?

Pierre
Back to top
View user's profile Send private message Visit poster's website
sokrne1



Joined: 17 Jun 2004
Posts: 50
Location: Northern Virginia

PostPosted: Fri Oct 07, 2005 3:42 am    Post subject: Reply with quote

Hi,
I've just downloaded the update to 3.1.1. I then followed the instructions for the plugin described in this thread; however, when I open NoteStudio, I am presented with an error message, through the Plugin Manager, indicating that create_action_lists.py could not be imported. I click on "ok", and NoteStudio opens, but, of course, the plugin is not available.

I know nothing about Python, so maybe I shouldn't have tried this. But I was just wondering if there is something I should have changed in the script. I did change the tags in the control file to conform with my NoteStudio contexts.

Thanks.

Any assistance would be greatly appreciated.

Take care,
Kathy
Back to top
View user's profile Send private message
lemayp



Joined: 24 Sep 2005
Posts: 246
Location: Laval, Canada

PostPosted: Fri Oct 07, 2005 11:24 pm    Post subject: Reply with quote

Hello Kathy,

I have just done another change to the plugin to fit my needs where I want the plugin to skip 1 page when generating the report, the one that contains GTD reference only, from the GTD template that is available from the NS website. This was causing entries in the report generated that were not usefull.

Meanwhile, while attempting to do my changes, I faced the same problem as you at one point. The problem was caused by a typo in my create_action_list.py file. I fixed it and then everything was OK.

I am wandering if during the download or the copy of your file, similarity occured for you. The error you are getting is, from my very limited experience about this, caused by a line that NS is not able to read from the create_action_list.py file.

I would recommand that you try to download again the plugin and copy again the create_action_list.py file into the plugin directory.

If that doesn't work, I could send you my version of the create_action_list.py. Simply send me a private message with your email adress.

Otherwise, let's hope that some expert will be able to help you. This little plugin is very good and it worth trying to fix it.

PS: make sure to remove completely your create_action_list.py from the plugin directory before trying with a new one. Simply renaming the old file will not be enough as NS will read any *.py file present in the plugin directory.

Good luck

Pierre
Back to top
View user's profile Send private message Visit poster's website
PDAguy



Joined: 17 Oct 2004
Posts: 86
Location: Oakville, Canada

PostPosted: Sat Oct 08, 2005 2:03 pm    Post subject: Create Actions List Plugin Reply with quote

I just want to say that the Actions List Plugin is fantastic!

Now I can do exactly what I have always wanted to do with GTD (and easily). I do manually reformat the summary page to my liking. Maybe I will figure out in Python how to get it done automatically to my format...

Thanks Allan Very Happy
Back to top
View user's profile Send private message Send e-mail
Guest






PostPosted: Sun Oct 09, 2005 12:38 pm    Post subject: Reply with quote

Absolutely brilliant.

May I make a couple of suggestions for someone who is good at coding to improve this script?

1. Output the Pipe character instead of tab to create new table cells, this makes it more understandable in Palm display - and 3.1.1 now recognises pipes.

2. Instead of outputting the link [Book name|Page name], output [[Book name|Page name][Page name]]. As the links are all sorted by book and under a heading with the book name, this allows you to jup to any page in any book, but keeps the space taken up by the link name smaller - again this helps on the Palm display.
Back to top
lemayp



Joined: 24 Sep 2005
Posts: 246
Location: Laval, Canada

PostPosted: Sun Oct 09, 2005 3:34 pm    Post subject: Reply with quote

"Guest",

Very good suggestion. I made some fix to my personnal version of the plugin. Please send me a personnal messsage with your email adress if you want it. I will try to contact Allan to see if he would like to have the changes to incorporate them in the official version. Anyone who would like to have my version is welcome to write to me.

Here are the changes I have done so far:

1) Make the search case-unsensible. That means that searching for the tag "@Calls" will also qualify "@calls" and "@CAlls", "@CALLS"....

2) Add the possibility to configure the plugin to skip 1 page while generating the report. As I use the GTD template available from the NS site, I had in my reports reference to this page, which doesn't contains any valid info, just entries that I use on the palm to generate backlinks report. This can be accomplished by adding a new entry in the c:\create_actions_list.ini file. Here is the entry used to skip the page named GTD:
skip_page=GTD

3) Replace the TAB by a PIPE character.

4) Change the [<bookname>|<PageName>] appearance in the report to only [<PageName>] but we proper reference to <bookName>|<PageName> as suggested.

I have tested principally the default report only (group by bookname and tag) as I don't use the otherone.

Please contact me and I will be pleased to provide this version to anyone interested.

thanks,

Pierre
Back to top
View user's profile Send private message Visit poster's website
lufad



Joined: 20 Jun 2005
Posts: 102
Location: Montréal

PostPosted: Sun Oct 09, 2005 4:51 pm    Post subject: Reply with quote

Hi,

Is anybody able to run the plugin successfully on a Mac?

Thanks for any info,

Luc
Back to top
View user's profile Send private message
sokrne1



Joined: 17 Jun 2004
Posts: 50
Location: Northern Virginia

PostPosted: Sun Oct 09, 2005 6:06 pm    Post subject: Reply with quote

Hi,

I have reinstalled the plugin (from the zip) file on Dog Melon's website. Everything is working beautifully!!! I am also going to take Pierre up on his revised plugin, as I am also using the GTD template.

Thanks for the suggestion to reinstall. I may have messed up when first trying to install the plugin, because I copy and pasted the post above (not realizing there was a zip file yet).

Again, thanks!!

Take care,
Kathy
Back to top
View user's profile Send private message
stuckagain



Joined: 04 Oct 2004
Posts: 107

PostPosted: Sun Oct 09, 2005 6:17 pm    Post subject: Reply with quote

"Guest" was me - sometimes I am not logged in properly, I don't know why.

I will PM Pierre to get his revision. The ability to specify the name of the page with all contexts on to exclude from the report, is great. I don't see why Pierre can't post his 'improved' code here?

It would also be nice to exclude names of books you don't want in the report, e.g. I have a book called "Templates" which has links, but as these are dummy pages for copying and pasting into new 'real' project pages they are unhelpful in the report, as I do not have any actions to do for them.

Another suggestion is to allow users to mod the ini file to swap between a link page per book, or all links in all books on one page (as it is now).

p.s. I couldn't work out how to use the second report style that is hardcoded in the py file. Can someone explain?

You are all just great!
Back to top
View user's profile Send private message
lemayp



Joined: 24 Sep 2005
Posts: 246
Location: Laval, Canada

PostPosted: Sun Oct 09, 2005 6:43 pm    Post subject: Reply with quote

I have sent an email to Allan to see what would be the best way to have the plugin updated with new features. This plugin belong to him and I want to respect that. Since Ant/NS provide a download page to download specific version of any plugin that would be made available, I think the best would be if only one person, (I presume Allan), would submit "official" versions of the plugin.

In the meantime, I can continue to provide my "parallel" version to anyone requesting it, until we could have an official version with those features.

As for your requestions on how to use the alternate report, I haven't tried it, but I think you simply need to change the line:
reporttype="Group by Book, Action Tag"
to:
reporttype="Group by Action Tag"

Have fun,

-Pierre
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    dogMelon Note Studio Forum Index -> Note Studio All times are GMT
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group