It wasn't me. You can't prove anything.


2008-01-05

Just want to edit some HTML


#!/bin/sh

# Open an HTML file using the Mozilla editor.
# The editor wants the full path to the file, not relative.

# 1) Only edits files that exist as HTML files all ready.
# 2) Requires full path to target file.

dataFile=$(cd `dirname $1` && pwd)/`basename $1`

if [ ! -z $1 ];then
    if [ ! -f $dataFile ]; then
        touch $dataFile
        echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">" >> $dataFile
        echo "<html>" >> $dataFile
        echo "<head>" >> $dataFile
        echo "  <meta content=\"text/html;charset=ISO-8859-1\" http-equiv=\"Content-Type\">" >> $dataFile
        echo "  <title>blog</title>" >> $dataFile
        echo "</head>" >> $dataFile
        echo "<body>" >> $dataFile
        echo "<br>" >> $dataFile
        echo "</body>" >> $dataFile
        echo "</html>" >> $dataFile
    fi
else
    echo "usage me <html file to edit>"
fi

`which seamonkey` -edit $dataFile &

I have to write a script to allow me to enter an HTML file name from the command line and edit it in the SeaMonkey editor. I like the SeaMonkey editor because it is very simple and makes simple code. This makes things easy to paste in to the fields for my blog and for forums.

It has some limitations. That is why it is so simple. SeaMonkey Editor does not support CSS really. It doesn't do flash embedding or any of the fancy stuff. I use a text editor for those posts. Sometimes I will write the page and lay things our in SeaMonkey editor, then simply paste the code into a preset spot before publishing.

SeaMonkey editor is part of SeaMonkey. That is a whole browser suite. It is huge considering I only use the editor. I bet  the editor is less than 0.1% of the over all bulk of the program.

In order to evoke the editor from the command line, there are some things you have to do. You must run SeaMonkey.

> seamonkey --edit

SeaMonkey editor (Composer) will not create a new file. It will simply ignore the file name you put on the command line and title your page "unknown". You have to do a save as and type the name in again. That script at the top of this posts handles this issue with some bash controlled mayhem. You can't just touch the file because SeaMonkey editor will blow a gasket if you hand it an empty file.

The file you want to edit from the command line has to both exist, and contain something resembling HTML code.

One other rule you must follow when evoking an editor from the command line is the path. You must specify the full path to your file. This means from the top of the OS or the '/' root folder all the way down to your file. Otherwise you get the 'unknown' file name again. This sort of thing happens in many programs. They just don't take the system current folder in to account when trying to work.

These two rules tell me a couple things about the SeaMonkey Project. Linux is not their primary concern. And - the command line operation is on the back burner.

The above script is far from fool proof. It is just something that gets the job done most of the time. This is one thing I really like about Linux. There is still a highly robust command line. You can easily script up some commands and feed the correct information to where it needs to go in order to get something to happen. This is difficult in MS and Mac because they design the OS from the ground up with the GUI as the only way users are supposed to enter the sandbox to get something done.

No comments: