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

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

Images other than inline.

000 0020 Is it possible to have images not inline in ecto - that is, spanning more than one line? In short, no. To do it like this page is, you’ll need to hand edit the HTML code (which almost removes the beauty of ecto), and put in a table. Just placing the photo and text inside a <table>, and <tr>, but with the image in one <td>, and the text in another <td> will do it. Update: A better method can be found at Using CSS to replace Tables.

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).

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 **

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.

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