Blog with ecto

I thought about another improvement for BwE today. It really only occurred to me when I created a new blog for nanowriwo 2004. When a new folder is created, I wonder if it is possible to add a folder action (of the same folder action script) to the created folder. This way I could just attach the script to the .Blogs folder, and then when I create special purpose blogs, I only have to create a folder on the Palm with the right name. I also wondered if I should use the “Journal Entry” feature of Agendus for blogging. Must look into this. I placed a Blogger bug report about post times not being respected by the server, but haven’t heard back. At least they fixed up the timezone error. Update: I’ve updated the script so that when a new folder is created, a “Blog with ecto” Folder Action Script is automatically added to the sub-folder. The latest version, as always, can be found at Blog with ecto.scpt. Thought: I should also tell ecto to update the account cache, but I need to know the server details, I think.

Updated Blog with ecto.scpt

I went through a couple of revisions of Blog with ecto the other night. I’ve now added the following feature:

  • Allows posting to multiple blogs, where the closest match to the folder name is used as the blog name.

There is a small issue - the date I set (using set entry_date to date date_stamp) doesn’t seem to be respected by ecto when it posts. I’ll do a bit more testing, and possibly issue a bug report. Anyway, the link for it is Blog with ecto.scpt.

Blog with ecto.scpt

Yesterday I talked about blogging from my Palm Zire 21.

Here is the complete AppleScript for Blog with ecto.scpt. Copy this, paste it into Script Editor, and save it to ~/Library/Scripts/Folder Action Scripts/Blog with ecto.scpt

Then right-click on the folder you want monitored - I use ~/Documents/Palm/Matthew Schinckel/NoteTaker/Blog and away you go. For best results, use with MacNoteTaker. Obviously, ecto is required.

All code is ©2004 Matthew Schinckel, but may be freely used with attribution.

Note: the formatting is removed, because ecto wasn’t quite doing it right, but Script Editor will figure it out.

 1on adding folder items to this_folder after receiving added_items
 2 Set this to true to automatically post the item(s)
 3 Leave as false so you can check the data.
 4set autopost to false
 5repeat with each_file in added_items
 6tell application Finder
 7set filename to (name of each_file) as text
 8open for access each_file
 9set entry_body to (read each_file)
10close access each_file
11end tell
12try
13set entry_title to filename
14set date_stamp to word 3 of filename & / & word 2 of filename ¬
15& / & word 1 of filename &   & word 4 of filename
16set entry_date to false
17set entry_date to date date_stamp
18set entry_title to first paragraph of entry_body
19set entry_body to text ((count characters of entry_title) + 2) ¬
20thru end of entry_body
21end try
22–—— You WILL need to change the next line!
23set my_blog to Life According to Matt
24tell application ecto
25set my_doc to make new document at front with properties ¬
26{entry title:entry_title, current blog:my_blog, ¬
27body text:entry_body}
28if false is not entry_date then
29set entry date of my_doc to entry_date
30end if
31if true is autopost then
32do post my_doc
33end if
34end tell
35end repeat
36end adding folder items to

acronymmer.py final (?)

Taking into account the comments on PhotoMatt’s acronymit page (where I shamelessly stole some ideas, including the list of words!), I’ve modified acronymmer.py so that it:

  1. Does not apply <acronym> tags to instances that have been acronymmed already.
  2. Does not apply tags to instances that are inside href or title strings.
  3. Does not save the file if no changes have been made.

Here it is, including my current acronym list. (I know some of these are Abbreviations, but ecto, and some browsers do not handle this tag). Also, this code needs to be re-pasted - I was trying to make it (XHTML) valid, and it’s broken now.

 1    #! /usr/bin/env python
 2        
 3    'A script for ecto that adds abbr and acronym tags to the text'
 4        
 5    acronyms = {
 6    'WYSIWYG' : 'what you see is what you get',
 7    'XHTML' : 'eXtensible HyperText Markup Language',
 8    'IIRC' : 'if I remember correctly',
 9    'HDTV' : 'High Definition TeleVision',
10    'LGPL' : 'GNU Lesser General Public License',
11    'MSDN' : 'Microsoft Developer Network',
12    'WCAG' : 'Web Content Accessibility Guidelines',
13    'SOAP' : 'Simple Object Access Protocol',
14    'OPML' : 'Outline Processor Markup Language',
15    'MSIE' : 'Microsoft Internet Explorer',
16    'FOAF' : 'Friend of a Friend vocabulary',
17    'GFDL' : 'GNU Free Documentation License',
18    'XSLT' : 'eXtensible Stylesheet Language Transformation',
19    'HTML' : 'HyperText Markup Language',
20    'IMAP' : 'Internet Message Access Protocol',
21    'RAID' : 'Redundant Array of Independent Disks',
22    'MPEG' : 'Motion Picture Experts Group',
23    'JPEG' : 'Joint Photographic Experts Group',
24    'CSTA' : 'Central Scorpions Touch Association',
25    'CDDB' : 'Compact Disc DataBase (Gracenote)',
26    'XBMC' : 'Xbox Media Centre',
27    'VNC' : 'Virtual Network Computing',
28    'URL' : 'Uniform Resource Locator',
29    'W3C' : 'World Wide Web Consortium',
30    'MSN' : 'Microsoft Network',
31    'USB' : 'Universal Serial Bus',
32    'P2P' : 'Peer To Peer',
33    'PBS' : 'Public Broadcasting System',
34    'RSS' : 'Really Simple Syndication',
35    'SIG' : 'Special Interest Group',
36    'RDF' : 'Resource Description Framework',
37    'AOL' : 'American Online',
38    'PHP' : 'PHP Hypertext Processor',
39    'SSN' : 'Social Security Number',
40    'JSP' : 'Java Server Pages',
41    'DOM' : 'Document Object Model',
42    'DTD' : 'Document Type Definition',
43    'DVD' : 'Digital Versatile Disc',
44    'DNS' : 'Domain Name System',
45    'CSS' : 'Cascading Style Sheets',
46    'CGI' : 'Common Gateway Interface',
47    'CMS' : 'Content Management System',
48    'FAQ' : 'Frequently Asked Questions',
49    'FSF' : 'Free Software Foundation',
50    'API' : 'Application Interface',
51    'PDF' : 'Portable Document Format',
52    'IIS' : 'Internet Infomation Server',
53    'XML' : 'eXtensible Markup Language',
54    'XSL' : 'eXtensible Stylesheet Language',
55    'GPL' : 'GNU General Public License',
56    'KDE' : 'K Desktop Environment',
57    'STB' : 'Set Top Box',
58    'MP3' : 'Mpeg Layer 3',
59    'PVR' : 'Personal (Digital) Video Recorder',
60    'GUI' : 'Graphical User Interface',
61    'CLI' : 'Command Line Interface',
62    'AAC' : 'Advanced Audio Coding',
63    'IE' : 'Internet Explorer',
64    'CD' : 'Compact Disk',
65    'GB' : 'Gigabyte',
66    'MB' : 'Megabyte',
67    'KB' : 'Kilobyte',
68    'TV' : 'TeleVision',
69    'PC' : 'Personal Computer',
70    'NSLU2':'[Linksys] Network Storage Link (USB) 2.0'
71    }
72    
73    
74    import sys, re
75    data = open(sys.argv[1]).read()
76    olddata = data
77    
78    # replace only the first instance of each acronym/abbreviation
79    for each in acronyms:
80        d = re.search(r'(?!<.*(title|href)='*>)?\b%s\b(?!(.*'>|</acronym>))' % each, data)
81        if d:
82            data = data[:d.start()] + '<acronym title='' + \
83                   acronyms[each] + '>' + \
84                   each + '</acronym>' + data[d.end():]
85        
86    if data <> olddata:
87        open(sys.argv[1],'w').write(data)

Transferring posts with ecto.

I moved blogs from one server to another some time ago, and luckily I was using ecto to post, so had an archive of the posts on my computer. I wrote an AppleScript to move a post from one server/account (ecto calls them personalities) to another, and popped it into the ~/Library/Application Support/ecto/scripts directory, set up a shortcut key, and then it was just a matter of opening a post, pressing the key, and it posted the old post to the new server. Some posts caused ecto to crash, but I could live with that. Anyway, here is the script: tell application “ecto”     set _draft to document 1     tell _draft         set _date to entry date         set current personality to “Blogsome”         set entry date to _date         do post     end tell end **tell **

Blogsome XMLRPC issues

I cannot post via ecto, or any other offline client at the moment: Blogsome has disabled XMLRPC support, due to a security issue. Since they use Multi-User WordPress, there is not fix for this build as yet.

Sub-Pages don't work in Blogsome

There you go. Visit http://schinckel.net/software/, and then visit http://schinckel.net/software/acronymmerpy/ No difference, even though there is a page in acronymmerpy/ I’ll put this in the blogsome forums when I get a chance.

Bug in XMLRPC.php

Yay! The days of having every post I posted with ecto automatically having the default category as well as those that I choose are numbered! An official bug report of the error (including the line of code where the bug occurs) has been put into the Word Press bug system (mosquito).

Updated: acronymmer.py for ecto

I’ve improved acronymmer.py, my script for adding acronym tags to posts in ecto. It will work with any file, however, that is passed as an argument to the script. There is one issue with ecto, and that is that abbr tags are not recognised by the Rich Text parser, so I’ve just set it to convert tags to acronym only for the time being. (Note to Adriaan: You should fix this!) Don’t run this script over the same text twice: it will re-tag them, resulting in messy (but still legal) code. Also, this needs a little fixing: the dictionary of items needs to return keys in size order, rather than just randomly.

 1    #! /usr/bin/env python
 2        
 3    'A script for ecto that adds abbr and acronym tags to the text'
 4    
 5    import sys, re
 6        
 7    acronyms={'WYSIWYG':'What You See Is What You Get', 
 8              'DOM':'Document Object Model',
 9              'XHTML':'eXtensible HyperText Markup Language',
10              'NSLU2':'[Linksys] Network Storage Link (USB) 2.0'
11             }
12        
13    # get input data - depends on implementation.  For ecto:
14    data = open(sys.argv[1]).read()
15        
16    # replace only the first instance of each acronym/abbreviation
17    for each in acronyms:
18        d = re.search(r'\b%s\b' % each, data)
19        if d:
20            data = data[:d.start()] + '&lt;acronym title="' + \
21                   acronyms[each] + '"&gt;' + \
22                   each + '&lt;/acronym&gt;' + data[d.end():]
23        
24    #return data to ecto
25    open(sys.argv[1],'w').write(data)

ecto: Auto abbr/acronym

There are a couple of instances of scripts out there that automatically apply abbr and acronym tags to pages, but I wanted to be able to do the same in ecto. This is also the first time I wrote a plugin script for ecto, and I wanted to do it in python. Please note that this here script is untested until I get onto my Mac and test the hell out of it. The script works, with the caveat listed in TODO.

 1    #! /usr/bin/env python
 2    
 3    'A script for ecto that adds abbr and acronym tags to the text'
 4        
 5    TODO = '''
 6    Fix it so that acronyms without a space either side (for example,
 7    that finish a sentence) work.
 8        
 9    Lookup on the internet for a list of acronyms/abbreviations?
10    '''
11        
12    acronyms={'WYSIWYG':'What You See Is What You Get',
13              'DOM':'Document Object Model'}
14    abbrs={'XHTML':'eXtensible HyperText Markup Language',
15           'NSLU2':'[Linksys] Network Storage Link (USB) 2.0'}
16        
17    # Add more values to your hearts content…
18    
19    # get input data - depends on implementation.  For ecto:
20    import sys
21    data = open(sys.argv[1]).read()
22        
23    # replace only the first instance of each acronym/abbreviation
24    for each in acronyms:
25        data.replace(' '+each+' ', '&lt;acronym title=&quot;'+acronyms[each]+'&quot;&gt;'+each+'&lt;/acronym&gt;',1)
26    for each in abbrs:
27        data.replace(' '+each+' ', '&lt;abbr title=&quot;'+abbrs[each]+'&quot;&gt;'+each+'&lt;/abbr&gt;',1)
28        
29    #return data to ecto
30    open(sys.argv[1],'w').write(data)

Note: Comments turned off: too much Spam on this entry.