| ||||
By: Jesse Shanks In what I have to think is a first, this weblog is updated using an AppleScript Studio project. I have used bookmarklets with Javascript and AppleScripts to handle this type of updating before and had good facility. But, with the release of AppleScript Studio, I decided that making an application that does the work of keeping the site up would be handy to have running in my dock, especially for the times when I am not posting from a web page. Plus, it is always so much easier to learn when actually doing something that is needed than doing endless tutorials. I have done some experimenting in the past with the "Dialog Director" scripting addition and "Dialog Studio" from macscripter.net. I have eagerly anticipated the release of AppleScript Studio to allow for more expanded scripting options. My first experiences with AppleScript Studio showed me something quickly that I later read on the Studio mailing list: Nicholas Riley said, "An issue with much of AppleScript Studio is that if you don't know what's going on with Cocoa, and want to do something complex, you can often get very confused, very quickly. I hope the documentation improves, so that AppleScript Studio can be accessible to a wider audience." on getExplorer() tell application "Internet Explorer" set theT to do script "TheT=document.title;" set theU to do script "TheU=document.URL;" set theQ to do script "Q=document.getSelection();" end tell set contents of text field "title" of window "main" to theT set contents of text field "myurl" of window "main" to theU set the contents of text view "content" of scroll view ¬Of course, AppleScript can get the page title and page url without resorting to Javascript, but since I wanted to to go there to get the selected text, it seemed just fine. So, it just a matter of calling this handler from the on clicked handler designating the name of the button, in this case "update." So, it was fairly easy to bring the same code that had worked before into AppleScript Studio behind the Cocoa interface. ![]() This window allows for creation of three types of entries on the site. The "Update" button captures the title, url and selected text of a web page. Although, it isn't necessary, a sheet then comes down and allows for input of a "source." I will probably delete the sheet, but it does prompt to make sure a source is included. A category is selected in the table. Then the "Post" button send the assembled URL to Explorer, which then connects to the PHP script. Update: Upgraded the application to use "curl" in "do shell script" for uploading the posted data. Infinitely better. If the "Diary Entry" button is checked, then the "source" and "url" are not necessary. This allows for a log entry that is, well, a "diary entry." To send a link to the "links" page of the site, the "Links" button can be clicked. This points to a different PHP script that sends the information into a different table, although it could be the same and use a parameter to choose the proper query to run. The "Clear" button responds to the escape key and clears all the fields. I am still not completely happy with the interface, because I sometimes make mistakes in what I hit. So, more usage experiments will need to be done to see what causes problems. The main mistake I make is it hit the "post" button when I mean to submit a link. Items to be upgraded: Store the categories in a preferences file. Add a window to allow uploading articles like this one to the web site. File upload capability. Storage of favorites in a drawer. Editing of information that is stored in the database. Currently, I have to go to the browser and connect to the database to fix mistakes. Another item to be upgraded is my own personal knowledge of Cocoa and Object-oriented programming. Hopefully, I have used my experience in AppleScript as a bridge into the Cocoa world and eventually my applications will become more Cocoa and less AppleScript. January 8, 2002
|
| |||