Skip to page content or skip to Accesskey List.
Search evolt.org
evolt.org login: or register

Work

Main Page Content

Using custom tags to ease content management

Rated 3.3 (Ratings: 10) (Add your rating)

Log in to add a comment
(19 comments so far)

Want more?

 
Picture of Junglee

Ashok Hariharan

Member info | Full bio

User since: January 27, 2002

Last login: January 27, 2002

Articles written: 5

Some typical questions from customers who want a website developed are...

  • I want to manage the content myself. Will you have a system for it?
  • I don't know HTML or programming. Can I still manage my content?
  • I can't understand these HTML tags? Is there an easier way out?

So to address these questions what I decided to do was to come up with a simpler tagging scheme than HTML which even a layman could understand, which could be easily parsed into a HTML tag, and which the browser could understand. I will try to illustrate this with a simple example.

The main advantages to this method would be:

  • A layuser can manage content/layout features very easily with very little knowledge of HTML.
  • Managing the content becomes much easier.
  • The same concept can be reused and replicated in other website projects.

Recreating the <img> Tag

Let's take up the simple example of the image tag:
&lt;img src=&quot;xyz001.jpg&quot; alt=&quot;xyz image&quot; align=&quot;right&quot;&gt;
This is a typical way the image tag would be found. In a page-length article on a website, typically images come within the text, so it makes sense to allow the user to place the image where they want and to place as many images as they want.

So what I did was reduce the image tag to:
&lt;g n=&quot;index&quot;&gt;l&lt;/g&gt;

The tag, &lt;g&gt;, is not an HTML tag, but is our very own tag that our server-side script recognises.

Let's examine the various parts of our tag for this example:

&lt;g&gt; &lt;/g&gt;
This just indicates to our parsing program the beginning and ending of our tag.
n=&quot;index&quot;
This attribute indicates to the parser which image the user has requested, but the index need not be the image name. We will come to that later.
&lt;g n=&quot;index&quot;&gt;<strong>l</strong>&lt;/g&gt;
The 'l' between the &lt;g&gt;&lt;/g&gt; is an alignment indicator which asks the image to align left ('l') or right ('r').

If you notice the "alt" attribute is not part of our tag, we shall come to that (again) later. Otherwise, this is definitely easier than entering a complete &lt;img&gt; tag.

Just a small clarification here, that i decided to add after reading some of the comments below :
I have used a tag called &lt;g&gt; in this example, some people might consider that too cryptic, I could have very well used something like &lt;image name=&quot;x&quot;&gt;left&lt;/image&gt;, The parser described below will handle something like that by just changing the input parameters

Applying our Custom Tag

So the content entry users have a form (I don't know what most people use… probably VB forms, Access forms or HTML forms like evolt.org) where they enter the content. In the case where I used this technique, the data store was a Domino database, so I used Domino forms (pretty rare…huh…!). The same technique can be easily duplicated on other systems. Some typical content entered by the user would be:

X company reached IPO on Feb 14th , but the CEO was disbarred from attending the conference by the police as he had 6 arms
&lt;g n=&quot;CEO&quot;&gt;l&lt;/g&gt;. But federal investigator Mr. Mulder came up with an alternate theory…. Blah… blah… Blah… blah… Blah… blah… Blah… blah… Blah… blah…which conclusively
&lt;g n=&quot;Mulder&quot;&gt;r&lt;/g&gt; proved that the CEO was an alien.

The parsing program goes through this and transforms the &lt;g&gt; tags to meaningful HTML &lt;img&gt; tags with the correct image name, which is then rendered in the browser, so the converted output would be:

X company reached IPO on Feb 14th, but the CEO was disbarred from attending the conference by the police as he had 6 arms &lt;img src=&quot;path/ceo.180x100.jpg&quot; align=&quot;left&quot; alt=&quot;CEOs at Lunch&quot;&gt;. But federal investigator Mr. Mulder came up with an alternate theory…. Blah… blah… Blah… blah… Blah… blah… Blah… blah… Blah… blah… which conclusively &lt;img src=&quot;path/mulder.jpg&quot; align=&quot;right&quot; alt=&quot;Agent Mulder&quot;&gt; proved that the CEO was an alien.

The two main components that accomplish this are:

  • A centralized image storage system.
  • An image parser.

A Centralized Image Store

I have a database table and form system (let's call it an image store…) which is managed by the content entry users where they upload the image in a user-friendly form and enter the image attributes there, which gets stored in the backend database. The parser uses the n="index" attribute to locate the requested image from this table.

The image entry form

A typical procedure for entering the image would be like this:

  1. Add the image…
    The image can be put in a database or in a file system, though in the case of a file system, we would also store the path information. (In my case, it was in a database for the sake of ease of management and the database had to be replicated as well - 2 birds with 1 stone). Typically the image has an unfriendly name, like img001_180x100.jpg. Users find these names very difficult to remember or to search for.
  2. Specify an index name for the image…
    This is a simple human understandable name which will be used by the content entry in our custom tag to identify the image: &lt;g n='indexname'&gt;.
  3. Specify an "alt" text for the image…
    This eases things for the user as they do not have to manually enter "alt=" text every time they put an image tag in the content. The parser automatically picks it up. There is an additional advantage, since alt texts are stored centrally. In the case of images which are used in many places on a website, changing alt texts globally for an image would just imply a change in one place.
  4. Enter a short description about the image…
    I found this, along with alt text, very useful, since it allows building of an intuitive image search on a website.

This is what my form would look like for entering images:
Picture of sample Form

The image store table

My table structure for the image manager would look like this:

Img_index Image Image_AltText Image_desc
Fishcatch8.jpgFish catch at hemingwayFishing for sailfish at hemingways in the bay of biscay
CeoCeo180x100.jpgMr. Ceo LaughingCEO of X corporation, Mr CEO

I used a global setting for things like "hspacing" and "vspacing" for images, even though this could have been incorporated into the form. I could have calculated things like height and width of the image when the user uploaded it… but let me leave it as another exercise.

The Image Parser

Regarding the Parser, I try to make it flexible for my needs. In reality, I use it not only to handle &lt;g&gt; tags, but also a variety of other custom tags. I have one for handling links and one for embedded tables. So it is a generic parser in Java which has generic routines from which other specialised parsers were extended.

How the parser works together with the Image store

  • Get the whole content to be displayed in a string.
  • The string has all the text content with the embedded custom tags.
  • The parser then scans through the string, and when it locates a &lt;g&gt; tag, it extracts the tag attributes.
  • The parser then uses the index specified in n=&quot;&quot; to locate the image name in the image store.
  • From the image store, it extracts all the associated info for the image, such as the "alt" attribute text.
  • The information between the &lt;g&gt; and &lt;/g&gt; (the "l" or "r") is used to set the align=&quot;right&quot; or align=&quot;left&quot; attributes for the &lt;img&gt; tag.
  • With all this information, the &lt;img&gt; tag is finally built.
  • Lastly, the parser replaces the &lt;g&gt;&lt;/g&gt; tags in the content string with the &lt;img&gt; tag.
  • The content string is then further scanned for &lt;g&gt;&lt;/g&gt; tags and the same process happens again.
  • Finally the transformed content string is outputted to the browser

Parser structure

  • There is a generic parser called the baseParser which has generic routines for scanning for a specified tag in a content string.
  • There is a task specific parser, in this case an image parser called imgParser, which uses the iterative routines of the baseParser to extract its tags from a string. The task specific parser also has a function to output a custom tag in a particular way (in this case it's as an &lt;img&gt; tag).

Image, below: structure of parsers
Picture of Parser Structure

Source Code Listings

Source Code for baseParser

This is a stripped out version of the baseParser. I removed a lot of application specific stuff to reduce the size of the parser as much as possible. There are descriptive comments along with source code.

public class baseParser
{
private int nPreParseLength =0 ;
private String strBeginp;
private String strEndp;
private String strRefp;
private String str;
private int lnkBeginLength;
private int lnkRefLength;
private int lnkEndLength;
//these 2 variables are used to keep track of tag position in the content string
//during an iterative scan through the content string
private int m_nLastIndex=0;
private int m_nPrevIndex=0;
public baseParser()
{
strBeginp="";
strEndp="";
strRefp="";
str="";
lnkBeginLength=0;
lnkRefLength=0;
lnkEndLength=0;
}
//String toBeParsed - string with content+custom tags which requires parsing
//beginP - beginning tag e.g. <g
//endP - ending tag e.g. </g>
//refP - ref.attribute tag n="
public baseParser(String toBeParsed, String beginP, String endP, String refP)
{
str = toBeParsed;
strBeginp = beginP;
strEndp = endP;
strRefp = refP;
lnkBeginLength = strBeginp.length();
lnkRefLength = strRefp.length();
lnkEndLength = strEndp.length();
}
 
//iterator function which scans for tags sequentially
public String parseUnit(int nBeginIndex)
{
//look for beginning
int nPrevIndex = str.indexOf(strBeginp,nBeginIndex);
//beginining tag not found..so end it
if (nPrevIndex == -1)
return "";
//look for ending
m_nPrevIndex = nPrevIndex;
int nLastIndex = str.indexOf(strEndp,nPrevIndex);
m_nLastIndex = nLastIndex+lnkEndLength;
return str.substring(nPrevIndex, nLastIndex+lnkEndLength);
}
  
//helper function for iterator 
public String parseUnit()
{
return parseUnit(lastUnit());
} //parses out the reference attribute of the tag
// in <tag ref="refattrib">prop</tag>
//this parses out refattrib...
public String parseRef(String strCur)
{
int nRefBegin=0;
int nRefEnd = 0;
nRefBegin=strCur.indexOf(strRefp);
nRefEnd = strCur.indexOf('"', nRefBegin+lnkRefLength);
return strCur.substring(nRefBegin+lnkRefLength,nRefEnd);
} 
  
//parses out the property of the tag 
// in <tag ref="refattrib">prop</tag>
//this parses out prop...
public String parseProp(String strCur)
{ 
int nLnkEnd = 0;
int n = 0;
nLnkEnd = strCur.lastIndexOf(strEndp);
for (n=nLnkEnd; strCur.charAt(n) != '>' && n >= 0; n--);
if (strCur.charAt(n) != '>')
return "";
String strLnk = strCur.substring(n, nLnkEnd);
nLnkEnd = strLnk.indexOf(">");
strLnk = strLnk.substring(nLnkEnd+1); 
return strLnk;
} 
  
//helper function for iterator 
public int prevUnit()
{
return m_nPrevIndex; 
}
//helper function for iterator
public int lastUnit()
{
if (str.indexOf(strBeginp, m_nLastIndex) == -1)
return -1;
else
return m_nLastIndex ;
}
};

The image parser

The base parser gets used by the imgParser, as shown below. Again, I removed lot of application specific error checking and caching code to reduce size.

import java.util.Vector;
public class imgParser
{
private baseParser m_spa; 
private String m_strMain="";
private String m_strKey="";
public imgParser()
{
m_strMain = "";
m_strKey = "";
}

//in reality i was also passing the db connection from the page 
//script to the parser...
//this allowed me to reuse the connection i made to the db for 
//displaying the page
//instead of creating new connections for each instance of the parser
public imgParser(String toBeParsed)
{
m_strMain = toBeParsed;
//seed the base parser with our required tags
m_spa = new baseParser(toBeParsed,"<g","</g>","n=\"");
}

  private Vector lookupImageDb(String sImageNo )
  {
  
  // this was a lotus domino routine which looked up the
  // index name in the database and returned a row of 
  //information as a java Vector
  //for illustrative purposes...i am just returning a dummy vector
  //but your routine to query the db would come over here...
  //this returned a vector with 2 columns
  // 1st col - image filename
  // 2nd col - image alt text
  Vector v = new Vector(2);
  v.addElement(new String("image.jpg"));
  v.addElement(new String("just a dummy image"));
  return v; 
  } private String getPath()
  {
  //i didnt hard code any paths...
  //this function simply calculated the path to the image inside the
  //database...since i was storing the image in the database
  //you could use it to calculate paths...
  //for illustrative purposes, i just return a dummy path...
  return new String("/images") ;
  }
  
  private int IMG_FILE_NAME_COL=0;
  private int IMG_ALT_NAME_COL=1;
  
  private String ParseImageTag(String sImageNo, String sAlign)
  {
  String sTemp = "";
  try{
    //lookup image info from image store	
  Vector v = lookupImageDb(sImageNo);
  //string used to store alt tag
  String strAltTag=new String("");
 	//string use to store image file name or handle in database
  String strFileName = new String("");
  //get the alt tage and file name
  strAltTag = (String)v.elementAt(IMG_ALT_NAME_COL);
  strFileName = (String)v.elementAt(IMG_FILE_NAME_COL);
  //build the image tag
  sTemp+="<img src=\""+getPath()+"/"+strFileName +"\"";
     //set alignment depending on l or r properties
  if (sAlign.equals("l"))
  sTemp+=" align=\"left\"";
  else
  sTemp+=" align=\"right\"";
  //other tags
  //apply alt tag only if it exists
  if (strAltTag.length() != 0)
  sTemp += " alt=\""+strAltTag+"\"";
  sTemp+=" hspace=\"8\" vspace=\"8\" ";
  sTemp+="border=0 />";
  }
  catch(Exception e)
  {
  e.printStackTrace();
  }
  finally{ 
  return sTemp; 
  }
  }
  
  //the only function called externally for this parser
  public String ParsedString() 
  {
  String strTemp="";
  
  int nBegin=0;
  int nPrev = 0;
  int nLast = 0;
  //call the base parser routine to iteratively scan for <g> tags
  String sRet = m_spa.parseUnit(nBegin);
  if (sRet.equals("")) //no image tags....so return string as is
  return m_strMain;
  //<g> tag found parse out attributes and properties 
  String sRef = m_spa.parseRef(sRet);
  String sTxt = m_spa.parseProp(sRet);
  nPrev = m_spa.prevUnit();
  if (nPrev != -1)
  {
  //skip string to position at the end of <g></g>
  strTemp = m_strMain.substring(0,nPrev);
  //now build the <img> tag from the <g> tag 
  strTemp+=ParseImageTag(sRef, sTxt);
  }
  nLast = m_spa.lastUnit(); //check if end
  while (nLast!=-1)
  {
  //parse the next <g> tag set
  sRet = m_spa.parseUnit();
  //<g> tag found parse out attributes and properties 
  sRef = m_spa.parseRef(sRet);
  sTxt = m_spa.parseProp(sRet);
  nPrev = m_spa.prevUnit();
  if (nPrev != -1)
  {
  //skip string to position at the end of current <g></g> 
  strTemp+= m_strMain.substring(nLast,nPrev);
  //parse out next image tag...
  strTemp+=ParseImageTag(sRef, sTxt);
  }
  nLast = m_spa.lastUnit();
  } 
  strTemp+=m_strMain.substring(nPrev+sRet.length());
  return strTemp; 
  }
  };

Using the parser in script

I use the imgParser in my code in this manner:

//..other code on page
String strContent;
String strParsedContent;
strContent = get_Content_As_String_From_Content_Table_Field();

//in reality i pass my database connection handle of the page script 
//to the parser, so i can reuse it
//create our image parser object and pass the content string to it
imgParser ipObj = new imgParser(strContent);

//strParsedContent contains the transformed string now...
strParsedContent = ipObj.ParsedString();

//...output parsed content to page
printwriterObj.print(strParsedContent);

Finally…

Just a few thoughts before I finish this…

I use quite a few parsers built around the base parser. I use a link parser, which basically uses a custom tag for links, that appends a particular class name and a target=_blank for links external to the site. I use another tag to embed a small table dynamically within the text with a specific alignment.

There might be performance implications in heavily trafficked sites, since the parser runs every time someone hits the page. What I do for such cases is pre-parse the content periodically on the server and cache it in the database, so when the user accesses the page, instead of parsing every time, they see the cached version.

The way the parser handles only single attributes (the "n=" in &lt;g n=&quot;&quot;&gt;) was by design. I wanted to make the tags as simple as possible for the user entering content. In almost all the cases where I used the parser, I never had to use more than a single attribute. Also I never check for incorrect tags. This was because I was checking it at the client side at the point of data entry of the content.

Using this technique certainly saved time and heartburn for me. Other than dealing with clients, I also had to deal with a copy writer who liked getting acquainted with Gilbey's dry gin more than with "complicated" HTML tags. But, he actually enjoyed entering these custom tags along with his copy, since for the first time he had complete control over where to position images in the copy.

Ashok is based in Nairobi, Kenya. When not busy dodging vagrant matatus in Nairobi traffic, he keeps himself upto date by evolt-ing.

Why?

Submitted by luminosity on March 3, 2002 - 04:00.

I'm sorry, but I just don't see the point of this. The system is much more confusing to me than html tags - they are designed to read like english. align="right" is a lot easier to remember than an r between the tags. Surely it wouldn't take much client education to teach them the basic html they'll need, especially since you're having to teach them how to use your custom tags anyway. I would also think it would take less time to teach someone how to use it, and produce a documentation book for helping teach new people, and refresh their memories.

What is the particular purpose of this system? It seems just as confusing, if not more (img sounds more like a picture than g which could be anything) and the basic html issn't that hard. A system which is trying to make it easier than html for the users would surely implement some other way of putting the tags in. Something such as and do the same substitution. Once again, though, I don't think the very basics of html they'd need to know would be very difficult at all to teach them. And if they have problems remembering image names, why can't those names be changed?

login or register to post comments

Why not ?

Submitted by Junglee on March 3, 2002 - 06:30.

At least from the experience that had, i found it easier explaining to the people entering content..what a simplified tag was than explaining what all the various parts of an img tag are, since the custom tag was restricted to a single attribute...

And then, I had quite a few cases where the same image was used in various parts of the website...it was much easier to maintain a simplified tag (no retyping of alt tags, no wrongly typed paths, no wrongly typed image names..etc..), and took less time to type in... Spelling mistakes were also much easier to handle...

Also now i have a system which calculates the dimensions of the image when its put in the image store ,so no typing of height, width etc...

Honestly , when there is 400 pages of content to be typed in..we had to draft in some secretarial to do a large part of this entry work...i was not about to start organising html training for them ..! I definitely found it easier explaining single alphabet tags...And i never gave them a documentation book... since i used 3 custom tags in all... all the documentation fits on a standard A4 sheet (or a whiteboard)
...and hey...i disagree that basic html is easy... i 've been tryin to explain it to my fairly intelligent uncle..he just doesnt get the point of it..
basically he stumps me at a very basic level with questions like : why do i always have click on the start button to shutdown windows...etc....some of the people entering content were like this....

login or register to post comments

why not a different way?

Submitted by nicole@parrot.ca on March 3, 2002 - 09:11.

The back end that is being described here makes sense, but the substitute tags are not user friendly at all. Instead of using which does not map to the word "image" at all (poor secretaries)... why couldn't you use < image> and instead of "n", why not name?

So your substitute tag would become < image name="Mulder"> < /image>

And even better ( I think)

< image name="Mulder" left> and no closing tags.

A parser should even be able to parse without the use of quote marks.

< image name=Mulder left>

Wouldnt that be easier to teach?

login or register to post comments

more tags?

Submitted by ironclad on March 3, 2002 - 09:38.

I've built a custom content system where there are image tags like this:

  [img left foo.gif a picture of foo]
  [img right foo.gif foo again]
  [img foo.gif]

Very simple to read, and very simple to write: I've found that requiring quotes around attributes leads to errors of missing quotes, and closure tags like are even worse.

It's also pretty easy to parse too...

s/\[img (([left|right|center]) )?([^ \]]+)( ([^\]])*)?\]/<img src="\3" alt="\5" align="\2">/

followed by s/ align="" // to clean out any non-aligned tags.

(code is from memory, not proofed)

login or register to post comments

different way

Submitted by Junglee on March 4, 2002 - 01:58.

does not map to the word "image" at all (poor secretaries)... why couldn't you use < image> and instead of "n", why not name?
actually the parser would work with a tag like <image name=....</image> , the only reason i didnt use one like that was <g n=...was much short to type ! (g stands for graphic...). The tag without the closing tag is a good idea (<image name=...left>) , honestly i never thought of that...

login or register to post comments

and such are the advantages of sharing... :)

Submitted by nicole@parrot.ca on March 4, 2002 - 07:42.

So Junglee shared his ideas with us, and in return he gets an even better product!

Now that's what I like in a community!

Way to go!

login or register to post comments

Sounds a lot like Cocoon

Submitted by teradome on March 4, 2002 - 13:11.

Cocoon pretty much does this too: Except you're entering in XML (so that would be <g n=""/> instead) and expanding custom tags usign XSL. And give them a decent editor and they can type in accented characters directly as Unicode values and have them automatically translated on paarsing to your output format: HTML, XML, PDF, SVG, or whatever you want to add on yourself. And since it's now at version 2.0, and not some bizarre 0.1.2 alpha, it's definitely worth a look see.

login or register to post comments

Nice...!

Submitted by chip on March 5, 2002 - 08:25.

I do something similar 1ce using asp. but for content entry i use visual basic. i had button whcich laucnh prompt for paramete :
<mypic pic="pic.gif"> , prompt pickup pic param and insert mypic tag into text field.

login or register to post comments

why not just use the image name in the database?

Submitted by chohawni on March 5, 2002 - 11:01.

Isn't it easier to build a page using Cold Fusion, Zope, ASP, or whatever you are using for contemnt management, and then have your users enter the name of the image in the database?

For example, I have built our staff listing pages using Cold Fusion, and entered the image name in the database where the content is stored. All the images are in a folder called /images/.

I built a similar system in Zope for advertising companies.

All the HTML (or CFML or Zope) for controlling the image's position, alt tag, border etc is in the page; all the user needs to do is correctly enter the image name (e.g. me.jpg) in the database.

login or register to post comments

tags for dummies?

Submitted by aggie on March 5, 2002 - 17:00.

In my experience, users (read: catatonic spineless imbeciles who whine like they get paid for it) aren't really capable of reading/learning/using tags. I agree with luminosity, they can't learn html tags, and probably won't have much fun using your tags either - although for a skilled content manager, the short hand is probably easier to type.

I use a system based on a php/postgresql combo, and since I developed for a company using Microsoft's Internet Explorer already (the neat thing about knowing your audience), I could use the MSHTML component, making pages directly editable. this enabled me to simply throw the text to be edited from the database into a page, as HTML, and provide a few buttons (bold,italic,underline) for working with selections, and two custom made buttons for inserting images and links.

The image button opens a new window where all images in the database are displayed, ordered by category, data, filename etc. A click will open an alert asking for alignment, and the image is inserted in the HTML editing page. Presto. This has (*finally* getting to the point) a bunch of distinct advantages:

  • Users aren't presented with filesystem intricacies (which they may mess up),
  • i got a unique id on all images, making misunderstandings near impossible, since the users don't see (or touch) *any* code, and
  • my html->db parser (making the edited text into something useful again) doesn't have to deal with user errors.

My system took a great deal of time making and is somewhat fragile when it comes to browser updates (im no dhtml shark) and only works using MSIE, but it has the one crucial feature; it keeps the blithering idiots at the trigger end of my system from messing up my pages.

login or register to post comments

Re: tags for dummies.

Submitted by luminosity on March 5, 2002 - 20:36.

This is exactly what I was talking about. I have no problem with a different method of inserting images into the pages, however I failed to see the usefulness of replacing a tag with a tag. The idea about storing all the image properties in a central database was a fine idea, except that some of these properties may need to differ from page to page. A system where the user is asked on a page by page basis, such as aggie's has it's own flaws too, namely lack of uniformity, but both systems in my opinion, could be combined together to make a really useful cms component.

PS: Sorry if I came across too harsh in my first comment - I tend to pick on bad things instead of praising good ones. This sytem does have some definite advantages, but I feel helping people iron out weaknesses (or at least pointing out what I consider to be weaknesses) in a system is many times more helpful than telling them what a good job they've done, and have them go out and continue to use flawed systems.

login or register to post comments

cold fusion, zope , asp...etc.

Submitted by Junglee on March 6, 2002 - 01:03.

thanks a lot for all the feedback and also the stick...! i am learning new stuff from you all as I write..!.
About the question if I could have used cf or zope or asp...etc.. please do remember I dont have much control over choice of programming platform..in the above case where i used this method, the client specifically required the site to be done on domino..(some kind of standard for that particular organization..)..quite a few of the other clients that i work with have such platform specific standards.
What i was trying was come up with a generic framework that i could use repeatedly in different projects, right now I am using a modified version (with some improvements suggested by u all !) of the above on a websphere/jasmine platform...

login or register to post comments

generate the tag for Jane Public

Submitted by cache on March 6, 2002 - 01:04.

I too store the image info in a database, associating a common name with the info. On the page where a user is editing the page's text in a textarea, there is therefore a select menu listing all of the images available to that user. The options display the common names and the values hold simple image tags, such as &lt;image foo align&gt;, where "foo" is the image's common name. The user selects an image and clicks a "Copy" button. That fires off a JS function that rapidly

  1. moves the menu's selected value to the "Copy" button, changing it's value to "&lt;image foo align&gt;",
  2. selects the button's value,
  3. copies the value to the Windows clipboard with execCommand("Copy"),
  4. writes the value "IMAGE COPIED" to the button.
The user then places their cursor in the textarea where they want the image, and right mouse/paste it in the text. They then change "align" to "left", "right', or "center". An onchange event in the textarea changes the button's value back to "Copy".

I also provide a "Preview" button that opens a slightly smaller, offset browser with the page in it, image tag translated. That's so Jane can say, "Oops, it's too high on the page", and cut and the simple tag to a different location in the text before saving the content.

It seems to work, we have volunteers in animal shelters posting pets for adoption without problems.

login or register to post comments

neato!

Submitted by nicole@parrot.ca on March 6, 2002 - 08:09.

I like your approach too, cache!
I might even implement something like that in one of my project. No tags at all for the end user!
it's so simplistic it might even be worthy of Frontpage! (just joking)...

login or register to post comments

But why not use a WYSIWYG content manager instead?

Submitted by daylami on March 6, 2002 - 18:05.

like the free one at Port41

It's incredibly simple to use, and is remotely hosted - so i can log in remotely & post...

saves a helluva lotta bother IMO.

login or register to post comments

deconfusization

Submitted by mwarden on March 6, 2002 - 22:34.

Let's consider the normal use of markup. Tags like &lt;strong&gt;, &lt;p&gt;, etc. all describe or alter the containted text or markup in a certain manner. So, why would the <image> tag surround the text "left". "left" is an attribute. What would make a little more sense would be to do: &lt;image align="left"&gt;CEO&lt;/image&gt;. This makes a little more sense because it's altering the "display" of the word "CEO". Rather than displaying the text, you're displaying an image that represents that text somehow. That's really only slightly better, though. Personally, I think it would be easier on the client if they were all attributes (it's hard to not know what type of value goes into the &quot;align&quot; attribute, once familiar with what the align attribute is -- with your approach, they would have to remember to what "attribute" the value inside the tags correspond).

The alt text in the database is a simple, yet clever, idea. One of those gee-i-should-have-figured-that-out type things.

It's been a while since I've done any real Java coding, but I'm having trouble justifying why you didn't make imgParser an extension of the baseParser class. Personally, unless I'm not seeing something, I would have constructed the baseParser with generic methods and then extended that class in the imgParser class and had it override a method or two to make it speficially for <g> tags (or whatever). When I say "extension", I mean literally an extension:

public class imgParser extends baseParser

It seems like that would make it a hundred times easier to add new tags. No?

login or register to post comments

deconfusioniszation.....

Submitted by Junglee on March 7, 2002 - 03:54.

Interesting that you mention this :
&lt;image align="left"&gt;CEO&lt;/image&gt;, so the semantically correct <g> tag could have been &lt;g align="l"&gt;CEO&lt;/g&gt; , looks like a pretty logical argument to me...might have actually saved some time in teaching the tag to the users, by just simply changing the attributes, cool.....!

I wrote the base parser code as part of a university project quite some time back...and the image parser was keyjocked out in 12-in-the-night-with-coffee-meet-deadline scenarios using whatever knowhow i had..., which meant i needed something quick & dirty but did the job.
The base parser as such is not very "extends" friendly . ideally i would have have liked to have the main while loop sequence that does the parsing (its currently in the image parser) into the base class . Then used some kind of late bound invocation of a generic function which parses out the <img> tag (which would have to be present in the image parser as it is now). This would have pretended duplication of the looping sequnce in every parser that uses the base parser.

Will probably have to do that when i get the time..! since I knew the base parser worked in its non-extended incarnation..., i decided to use it that way.

login or register to post comments

deconfusioniszation.....

Submitted by Junglee on March 7, 2002 - 03:59.

Interesting that you mention this :
&lt;image align="left"&gt;CEO&lt;/image&gt;, so the semantically correct <g> tag could have been &lt;g align="l"&gt;CEO&lt;/g&gt; , looks like a pretty logical argument to me...might have actually saved some time in teaching the tag to the users, by just simply changing the attributes, cool.....!

I wrote the base parser code as part of a university project quite some time back...and the image parser was keyjocked out in 12-in-the-night-with-coffee-meet-deadline scenarios using whatever knowhow i had..., which meant i needed something quick & dirty but did the job.
The base parser as such is not very "extends" friendly . ideally i would have have liked to have the main while loop sequence that does the parsing (its currently in the image parser) into the base class . Then used a late bound invocation of the method which parses out the <img> tag (which would have to be present in the image parser as it is now). This would have pretended duplication of the looping sequnce in every parser that uses the base parser.

Will probably have to do that when i get the time..! since I knew the base parser worked in its non-extended incarnation..., i decided to use it that way.

login or register to post comments

Re: deconfusioniszation....

Submitted by mwarden on March 8, 2002 - 15:59.

Sounds like a valid excuse. Fwiw, i wasn't attacking your methods, I was just wondering if there was a reason for that which I couldn't see.

Thanks for clearing up. And thanks for the article!

login or register to post comments

The access keys for this page are: ALT (Control on a Mac) plus:

evolt.orgEvolt.org is an all-volunteer resource for web developers made up of a discussion list, a browser archive, and member-submitted articles. This article is the property of its author, please do not redistribute or use elsewhere without checking with the author.