08.01.07
Update on the Bookmarking thing
There was a bug in this script. It took the wrong URL when multiple pages were opened. Never trust code from some stranger, I tell you. There is still a flaw, sometimes it changes the active Safari window for some or no reason. Buuut: Now there is a list of the acronyms and what’s their meaning. And the input works a bit different: type the acronym followed by a space and then the description. Page creation or direct addressing by pagename does not work anymore.
Here is the code. I edited it also in the previous post.
Edit: Ok, I hope I killed the flaw now. Script is updated again.
on run
tell application "Safari" to set new_bm_url to URL of document 1 of window 1
activate
set acronyms to {"s", "a", "g", "o", "d", "l"}
set pagenames to {"bm Science", "bm Apple", "bm Games", "bm Other", "bm Software Dev", "bm Read Later"}
set d_l to ""
repeat with x from 1 to number of items of acronyms
set d_l to d_l & item x of acronyms & " - " & item x of pagenames & return
end repeat
display dialog d_l as text default answer ""
set text_result to text returned of result
set acronym to first character of text_result
set bookmark_note to characters 3 thru (number of characters of text_result) of text_result as text
tell application "VoodooPad"
repeat with x from 1 to number of items of acronyms
if item x of acronyms is acronym then
set itemnumber to x
end if
end repeat
set pagename to item itemnumber of pagenames
append text bookmark_note & return & new_bm_url & return to page pagename of document 1
end tell
end run
07.30.07
Bookmarking with VoodooPad
Bookmarks in the browser (doesn’t matter which one) does not work for me. I figured this out yesterday after years of webbrowsing. Somehow I can never remember what categories I had or why I bookmarked this particular page. With some browsers you can add a comment to a bookmark, but you have to open the bookmark manager every time. There may be some plugins, but I want to stay flexible in the choice of my browser. Yes, it’s kind of weird. Anyway, I deliberated if I should just copy the links to my favourite app, VoodooPad. That’s soo last century. But wait, there’s this cool method of automation, AppleScript. So I wrote a little script which asks me for a page to append the bookmark. I defined some acronyms, “s” for science for example. And then it asks me for a note, so I can type in a few related words to remenber the content of the website. Still last century? Maybe. I don’t care, it’s much more pleasing to me this way. You could fill in your acronyms and pagenames in the lists at the beginning of the script. It behaves like this: If you use the acronym, it appends the Bookmark to its page. If you type in something else, it appends the bookmark to the page with this name and creates a new one if this page does not exist. Here is it, in case someone is interested. Which is quite unlikely.
on run
tell application "Safari" to set new_bm_url to URL of document 1 of window 1
activate
set acronyms to {"s", "a", "g", "o", "d", "l"}
set pagenames to {"bm Science", "bm Apple", "bm Games", "bm Other", "bm Software Dev", "bm Read Later"}
set d_l to ""
repeat with x from 1 to number of items of acronyms
set d_l to d_l & item x of acronyms & " - " & item x of pagenames & return
end repeat
display dialog d_l as text default answer ""
set text_result to text returned of result
set acronym to first character of text_result
set bookmark_note to characters 3 thru (number of characters of text_result) of text_result as text
tell application "VoodooPad"
repeat with x from 1 to number of items of acronyms
if item x of acronyms is acronym then
set itemnumber to x
end if
end repeat
set pagename to item itemnumber of pagenames
append text bookmark_note & return & new_bm_url & return to page pagename of document 1
end tell
end run
07.26.07
A crappy map for VoodooPad
There’s this Application called VoodooPad. It’s a personal Wiki where I write down just everything.
I am a visual learner and would love to have a map view of the pages. I guess there are too many feature requests and not enought time. So I looked around for an external solution and found Graphviz. This is an open source tool for representing structural information. I tried to write a little AppleScript which exports the information into a .dot file which will be opened by Graphviz.
It works, but not very well. It just takes a list of all pages and searches in the contents for these strings for pagenames. Then writes it to the .dot file which is located at home:scriptfiles:dot: and tells the Finder to open the file using Graphviz which must be locted in the applications folder.
Some bugs are:
- it shows just small letters
- if there is a for example a page called “funny”, the string “fun” refers to it
- no links to files are recognized
- to be continued…
Other problems are:
- it’s quite mazily if there are too many pages
- it takes some time to process if the document is more than just a few pages
- it’s not interactive, you can’t move the page representations nor navigate
- you would have to run the script every time you change something
- not linked pages are not displayed
- to be continued… this list is probably endless
There are some settings in Graphviz which could make it a bit more acceptable. I use the “Energy Minimized” Layout and tell it to not overlap. These settings can be saved as default.
Even with these deficiencies I use it and hope that the idea has some potential. I really need the map view… it helps me to get an idea of that information I have.
Here is the script for the case, someone is interested. Please forgive me for this crap. I’m obviously not a developer.
Code:
on run
set ignorelist to {"index", "post im forum", "vp to graph", "vp to graph mit ignorelist"}
set AppleScript's text item delimiters to ""
set homepath to path to home folder as text
set dotfile to homepath & "scriptfiles:voodoodot2.dot"
tell application "Finder"
try
make new folder at ((home as text) & "scriptfiles:") with properties {name:"dot"}
end try
end tell
tell application "VoodooPad"
set number_of_pages to the number of pages of document 1
set pagelist to {}
set dotfile_refn to open for access file ¬
dotfile with write permission
write "digraph untitled {" & return to dotfile_refn
repeat with i from number_of_pages to 1 by -1
set the beginning of pagelist to name of page i of document 1 as text
end repeat
repeat with x from number_of_pages to 1 by -1
set pagecontent to (text of page (item x of pagelist as text) of document 1) as string
repeat with y from number_of_pages to 1 by -1
if pagecontent contains item y of pagelist and x is not y and ignorelist does not contain item x of pagelist and ignorelist does not contain item y of pagelist then
write "\"" & item x of pagelist & "\"->\"" & item y of pagelist & "\";" & return to dotfile_refn
end if
end repeat
end repeat
write "}" & return to dotfile_refn
close access dotfile_refn
tell application "Finder"
open document file dotfile using application file "Graphviz.app" of folder "Applications" of startup disk
end tell
set AppleScript's text item delimiters to return
end tell
end run
Here is a picture.
It’s just a simple example. Most likely it does’t look so nice in a real world scenario. Oh, there’s also an ignore-list. Pages in this list will not be displayed.
Thanks a lot!
Lazra