Updated: 1/21/02; 4:10:29 PM.
Cicada Photography Resource Weblog
An archive of thoughts and images,
sometimes about black-and-white
photography.
January 2002
Sun Mon Tue Wed Thu Fri Sat
    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  
Dec   Feb




Darkroom: building and using a darkroom.

Photo News Items: news items about photography.

Politics: personal politics and opinions. these posts are typically not about photography.

Zone System: a photographic technique

Learning Radio by writing a util

I wanted to created a simple macro called describeCategories() that would regurgitate the description of each of my weblog categories. I had to learn my way around radio a bit before doing creating it. The resulting macro is described in this story. I am an old hand at programming with UserTalk. If this all seems strange, unknowable and awkward, no need to worry. UserTalk is all pretty easy to get along with in the end. In any case, perhaps this article or the macro will be useful to somebody, and I had a good time learning a little about Radio while writing it.

This script is called on the left hand edge of my homepage. It is used to describe categories associated with this weblog. It reads the categories from the guest database where they are stored.

I am running Mac OS X, I do not know if this will execute properly on other platforms.

The output of the macro takes the form

Category name: category description
However, I wrote in four parameters that can be changed to vary the disply of the output: namePrefix, nameSuffix, descriptionPrefix, descriptionSuffix. By varying the appropriate parameters and combining with careful html formatting, it should be possible to format the output to make the category names bold, create a html list, or to create many other display options.

The util is stored in suites.lhd.utils.describeCategories of the main root. (my initials are "lhd" hence suites.lhd...) I am not sure if that is a great place for it in the current Userland root paradigm; anyway, here it is:


on describeCategories(namePrefix="", nameSuffix=": ", descriptionPrefix="", descriptionSuffix="<br><br>")
	on add(s) 
		htmltext = htmltext + s + cr
	local (adrdata = radio.weblog.init ())
	local (adrCategory = @adrdata^.categories)
	local(htmltext = "")
	for i = 1 to (sizeof(adrcategory^))
		add(namePrefix + nameof(adrcategory^[i]) + nameSuffix)
		add(descriptionPrefix + string(adrcategory^[i].description) + descriptionSuffix)
	return(htmltext)

The following html+macro call is in my homePageTemplate; this code aids and abets the display of my categories. One of the design principles of the utility above is to force minimal formatting through the output of the macro. By and large, it should just return simple data. The issue of flexible formatting became immediately apparent. In the end I opted to use html, coupled with the parameters used by the macro, to format the display of the data.

<table width="120" border="0">
 <tr>
  <td>
   <div align="left" class="small">
    <%lhd.utils.describeCategories()%> <-- no parameters passed in, use the defaults above -->
   </div>
  </td>
 </tr>
</table>

Because I wanted to use the default formatting, the actual macro call was simply:

  <%lhd.utils.describeCategories()%>
Combined with the html table it looks like this:
Darkroom: building and using a darkroom.

Photo News Items: news items about photography.

Politics: personal politics and opinions. these posts are typically not about photography.

Zone System: a photographic technique


Had I wanted additional formatting, say to make the name bold and the description italic with each catgegory separated by a little vertical whitespace, I would have used this call

<%lhd.utils.describeCategories("<b>", "</b>", "<i>", "</i><br><br>")%>

It would have looked like this:

Darkroom building and using a darkroom.

Photo News Items news items about photography.

Politics personal politics and opinions. these posts are typically not about photography.

Zone System a photographic technique


By putting that call inside of a simple table with a gray backgound in my homePageTemplate, I could have used this code:

<table width="120" cellpadding="8" border="1" bgcolor="gray">
 <tr>
  <td>
   <div align="left" class="small">
    <%lhd.utils.describeCategories("<b>", "</b>", "<i>", "</i><br><br>")%> 
   </div>
  </td>
 </tr>
</table>

The display would look like this:

It would have looked like this:

Darkroom building and using a darkroom.

Photo News Items news items about photography.

Politics personal politics and opinions. these posts are typically not about photography.

Zone System a photographic technique


Had I wanted to display the data as an html definition list, I would have done this:

<dl>
<%lhd.utils.describeCategories("<dt>", "", "<dd>", "")%>
</dl>

and it would have looked like this:

Darkroom
building and using a darkroom.
Photo News Items
news items about photography.
Politics
personal politics and opinions. these posts are typically not about photography.
Zone System
a photographic technique


Final example, use the definition list but make the defintion terms (the categgory names) bold:

<dl>
<%lhd.utils.describeCategories("<dt><b>", "</b>", "<dd>", "")%>
</dl>

and it would look like this:

Darkroom
building and using a darkroom.
Photo News Items
news items about photography.
Politics
personal politics and opinions. these posts are typically not about photography.
Zone System
a photographic technique

© Copyright 2002 Lewis Downey .