Peter's Blog 2004/4

2004-04-30

More VIM based editing.

I don't know how long I can go on posting the evolution of this but anyway.

  • PostBlog now marks buffers as unmodified as after posting they do not need to be written to disk.

  • ReadBlog will now default to reading the last posted entry as that is most likely to need modifying.

def PostBlog():
  
import xmlrpclib
  
import re

  
#
  
# If first line contains a blog entry ID then edit existing post,
  
# otherwise write a new one.
  
#
  
nFirstLine = 0
  
strID = vim.current.buffer[0]
  
if not re.match( '^P\d+$', strID):
    
strID = ''
  
else:
    
nFirstLine = 1

  
strTitle = im.current.buffer[nFirstLine]
  
strText = "\n".join( vim.current.buffer[2:])

  
oPyds = xmlrpclib.ServerProxy( 'http://localhost:4334/RPC2')

  
oPost = { 'title': strTitle,
            
'description': strText}

  
if strID == '':
    
strID = oPyds.metaWeblog.newPost( '', 'peter', 'wibble', oPost, 1)
  
else:
    
bSuccess = oPyds.metaWeblog.editPost( strID, 'peter', 'wibble', oPost, 1)

  
print "Posted entry %s" % strID

  
#
  
# Don't intend to write posts to disk so unmodify the buffer and
  
# allow easy quit from VIM.
  
#
  
vim.command( 'set nomodified')

def ReadBlog( strID = None):
  
import xmlrpclib

  
oPyds = xmlrpclib.ServerProxy( 'http://localhost:4334/RPC2')
  
if strID:
    
oBlog = oPyds.metaWeblog.getPost( strID, 'peter', 'wibble')
  
else:
    
oBlogs = oPyds.metaWeblog.getRecentPosts( '', 'peter', 'wibble', 1)
  
oBlog = oBlogs[0]
  
strID = oBlog['postid']

  
vim.current.buffer[:] = []
  
vim.current.buffer[0] = strID
  
vim.current.buffer.append( oBlog['title'])
  
vim.current.buffer.append( '')
  
for strLine in oBlog['description'].split('\n'):
    
vim.current.buffer.append( strLine)
posted at 12:50:24    #    comment []    trackback []
 

Smileys

What has happened to my text smileys Unsmiley

This is the magic of shortcuts. Here are some I prepared earlier. Python is the language of my dreams. Microsoft is the company of my nightmares.

posted at 12:26:56    #    comment []    trackback []
 

Scrolling preformatted text

Something I noticed on the PYDS site is how a code snippet was in a box that could scroll horizontally. This is useful as it stops preformatted text from making the page grow too wide to be displayed nicely. The secret seems to be this:

.literal-block {
    overflow
: auto;
}

Here is an example:

This is a very long line of stuff. It is too long to go on one line and as it is preformatted it will not word wrap. You can scroll it horizontally.

Magical. It works in Mozilla but not in IE 5.0: that just creates a very wide web page. I'm not sure I have access to a later I.E. here at work.

Update: This makes Mozilla 1.6 on my laptop at home hang, gobbling cpu time and it doesn't work on IE6, so I ripped it out and reformatted the long lines.

posted at 11:57:04    #    comment []    trackback []
 

More VIM Editing

I cannot leave these things alone.

#
# Post a new blog item or write the changes to an existing item.
#
def PostBlog():
  
import xmlrpclib
  
import re

  
#
  
# If first line contains a blog entry ID then edit existing post,
  
# otherwise write a new one.
  
#
  
nFirstLine = 0
  
strID = vim.current.buffer[0]
  
if not re.match( '^P\d+$', strID):
    
strID = ''
  
else:
    
nFirstLine = 1

  
strTitle = vim.current.buffer[nFirstLine]
  
strText = "\n".join( vim.current.buffer[2:])

  
oPyds = xmlrpclib.ServerProxy( 'http://localhost:4334/RPC2')

  
oPost = { 'title': strTitle,
        
'description': strText}

  
if strID == '':
    
strID = oPyds.metaWeblog.newPost( '', 'peter', 'wibble', oPost, 1)
  
else:
    
bSuccess = oPyds.metaWeblog.editPost( strID, 'peter', 'wibble', oPost, 1)

  
print "Posted entry %s" % strID

#
# Edit an existing post.
#
def ReadBlog( strID):
  
import xmlrpclib

  
oPyds = xmlrpclib.ServerProxy( 'http://localhost:4334/RPC2')
  
oBlog = oPyds.metaWeblog.getPost( strID, 'peter', 'wibble')
  
vim.current.buffer[:] = []
  
vim.current.buffer[0] = strID
  
vim.current.buffer.append( oBlog['title'])
  
vim.current.buffer.append( '')
  
for strLine in oBlog['description'].split('\n'):
    
vim.current.buffer.append( strLine)

It seems to work.

posted at 11:29:20    #    comment []    trackback []
 

Syntax Highlighted Entries

If this works it will be really cool.

def HelloWorld():
  
print 'Hello World'

Well blow me. NOTE: two colons, case sensitive language name.

void HelloWorld() {
  
printf( "Hello World\n");
}

I installed the SilverCity python package and rebooted PYDS.

Does it support shitty languages?

System Message: ERROR/3 (<string>, line 20)

No SilverCity lexer found for language 'VB'.

.. code-block:: VB

    Sub HelloWorld()
        MsgBox "Hello World"
    End Sub

That would be a No.

I edited this entry using this:

def ReadBlog( strID):
  
import xmlrpclib

  
oPyds = xmlrpclib.ServerProxy( 'http://localhost:4334/RPC2')
  
oBlog = oPyds.metaWeblog.getPost( strID, 'peter', 'wibble')
  
vim.current.buffer[:] = []
  
vim.current.buffer.append( oBlog['title'])
  
vim.current.buffer.append( '')
  
for strLine in oBlog['description'].split('\n'):
    
vim.current.buffer.append( strLine)

def WriteBlog( strID):
  
import xmlrpclib

  
strTitle = vim.current.buffer[0]
  
strText = "\n".join( vim.current.buffer[2:])

  
oPyds = xmlrpclib.ServerProxy( 'http://localhost:4334/RPC2')

  
oPost = { 'title': strTitle,
        
'description': strText}

  
strID = oPyds.metaWeblog.editPost( strID, 'peter', 'wibble', oPost, 1)

  
print "Posted entry %s" % strID

Good isn't it?

posted at 10:48:48    #    comment []    trackback []
 

Posting Blog Entries from VIM

This is as easy as:

def PostBlog():
  import xmlrpclib

  strTitle = vim.current.buffer[0]
  strText = "\n".join( vim.current.buffer[2:])

  oPyds = xmlrpclib.ServerProxy( 'http://localhost:4334/RPC2')

  oPost = { 'title': strTitle, 'description': strText}

  strID = oPyds.metaWeblog.newPost( '', 'peter', 'wibble', oPost, 1)

  print "Posted entry %s" % strID

Ok, this uses VIM with python support.

posted at 09:34:08    #    comment []    trackback []
 
2004-04-29

XMLRPC

This was submitted via the MetaWeblogApi

posted at 16:23:44    #    comment []    trackback []
 

Wiki Woes

The Blog button in the wiki stuff is supposed to create a blog entry that links to the Wiki. Nice idea, except that the link does not work, gives a 404.

posted at 15:26:08    #    comment []    trackback []
 

Change of Theme

I changed the colour scheme of the weblog:

  • made the font slightly smaller

  • put underlines on links

  • made it all blue

These were all changes to the pyds.css style sheet, made via the themes link on the pyds desktop. I found I had to clear Mozillas cache to force the style sheet to be reloaded. Whether this is due to Mozilla or pyds I know not. I could test it with IE but I don't care that much.

I'd like to make the aggregator use less padding.

posted at 13:26:40    #    comment []    trackback []
 
2004-04-28

Transpires that my old Wharfedale 750 DVD player..

Transpires that my old Wharfedale 750 DVD player can play video CD's. This is good because I can burn video's from the camcorder. Camera came with ImaqeMixer which has a horribly non-windows interface but blows VCD's complete with menu and chapters (which I would rather skip). I had to install the WinASPI drivers that came with the software before it would recognise the CD-R in my laptop.

posted at 22:56:16    #    comment []    trackback []
 
2004-04-27

First Post

Not quite the last post

  • These

  • Are

  • Bullet

  • Points

posted at 17:08:32    #    comment []    trackback []
 

XMLRPC posted two days ago

This was submitted via the MetaWeblogApi, with a new pubtime element added by peter

posted at 16:38:40    #    comment []    trackback []
 
2004-04-24

Bought a Sony DCR TRV 14E Camcorder for £280.

Bought a Sony DCR TRV 14E Camcorder for £280. I'm very pleased with it, a bargain, on sale elsewhere for £450. It's small but fat, won't fit in a pocket.

It has USB and firewire ports. I tried the USB but it is very poor so I have to buy a firewire card.

posted at 10:21:04    #    comment []    trackback []
 
2004-04-23

Been playing with **Radio Userland**.

Been playing with Radio Userland. It is a mixed bag of things:

  • a local web server, driving the main application through a web browser

  • a blogging tool. Type a post in a box and publish. It gets uploaded to Userland's servers and there it is.

  • a news aggregator, it aggregates RSS feeds for perusal through the browser

  • Content Management System: put files in directorys and they get rendered and uploaded automatically.

  • Scripting tool

  • Outliner

Good points:

  • Easy blogging for newbies

  • Can email it to post blogs

  • Easy to knock up a web site

  • The outliner has neat features like linking to web pages or other outlines which can be opened in place.

  • It is heavily scripte.

Bad points:

  • I had to reinstall it because the upload got broke

  • The scripting language is clean but it's no Python

  • The outliner is not nice to use. It is a fairly crude app by modern windows standards. Bonsai is far nicer to write in.

  • The outliner is used to edit the system scripts: no syntax highlighting and all nodes collapsed by default. I find this hard to read. I miss Vim.

  • Their web servers can be very slow: uploads can time out.

  • Uploading is all done automatically in the background so you have to keep looking at an events page to see if it has worked.

My head says dump it but something in my heart wants me to keep it. If it ran on linux I probably would.

posted at 21:24:32    #    comment []    trackback []
 
2004-04-20

Tried **zfeeder**..

Tried zfeeder (http://zvonnews.sourceforge.net/). It is an Apache PHP news aggregator. I got it working quite smoothly but I don't like it's presentation of articles so I have zapped it again.

posted at 14:22:08    #    comment []    trackback []
April 2004
MoTuWeThFrSaSu
    1 2 3 4
5 6 7 8 91011
12131415161718
19202122232425
2627282930  
Mar
2004
 May
2004

A blog documenting Peter's dabblings with Python, Gentoo Linux and any other cool toys he comes across.

XML-Image Letterimage

© 2004, Peter Wilkinson

Bisi and me