Forum OpenACS Q&A: Re: More Google Optimization thoughts for an OpenACS app

Eric,

It's possible yes, and perhaps commonplace to put data through filters to optimize search engine indexing for db backed websites, though I'm not aware of any specific code in the OpenACS api. The following should get you most of the way to having it work for all pages in a standard OpenACS installation.

1. Consider placing it at the end of service0/www/site-master.tcl which has access to context_bar:

proc xyz_remove_html {description} {
# remvoves html from a string
    # reomve tags
    regsub -all -- "<\[^\>\]*>" $description " " description

    # convert fancy delimiter to one that complies with meta tag values
    regsub -all -- "&\#187;" $description ":" description

    # convert bracketed items as separate (delimited) items
    regsub -all -- {\]} $description "" description
    regsub -all -- {\[} $description ":" description

    # convert any dangling lt/gt signs to delimiters
    regsub -all -- ">" $description ":" description
    regsub -all -- "<" $description ":" description

    # remove characters that
    # can munge some meta tag values or how they are interpreted
    regsub -all -nocase -- {\'} $description {} description
    regsub -all -nocase -- {\"} $description {} description

    # remove html entities, such as &trade; &copy; etc.
    regsub -all -nocase -- {&[a-z]+;} $description {} description

    # filter extra spaces
    regsub -all -- {\s+} $description { } description
    set description "[string trim $description]"

return $description }

if {[info exists context_bar} { set context_text [xyz_remove_html $context_bar] set keywords_list [split $context_text :] set len_keywords [llength $keywords_list] set max_keywords $len_keywords set reverse_context_bar [lindex $keywords_list $len_keywords] incr len_keywords -1 for {set i $len_keywords} {$i >= 0 } {incr i -1} { append reverse_context_bar ", [lindex $keywords_list $i]" } # remove a leading blank, if it exists if {[string range $reverse_context_bar 0 1] == ", "} { set reverse_context_bar "[string range $reverse_context_bar 2 end]" } } # reverse_context_bar contains ad_context_bar items in reverse order

2. Then add the following into the service0/www/site-master.adp to push $reverse_context_bar into the blank-master file, where the head section with meta tags are defined:

&lt;if @reverse_context_bar@ not nil&gt;
    &lt;property name="reverse_context_bar"&gt;@reverse_context_bar;noquote@&lt;/property&gt;
  &lt;/if&gt;

3. Add the html head meta tags in service0/www/blank-master.adp

The above code is from some batch scripts. I have added comments to help identify what it does. You may want to add filters to handle different kinds of data. For example if some of the context bar items use abbreviations, you can create other regsub's to expand them.

cheers,