> often if i introduce friends to werc they ask for a search box.
> i usually said 'use grep', but they wanted something for users from
> the webinterface - fair enough i think.
> i like /sitemap so i copied sitemap.tpl to search.tpl and stuffed
> it with grep, my draft looks like that:
> %{
> fn listDir {
> d=$1
> pattern=$2
> if(test -f $d/_werc/config)
> . $d/_werc/config
> if(~ $#perm_redir_to 0) {
> echo '<ul class="sitemap-list">'
> for(i in `{ls -dF $d^*/ $d^*.md $d^*.html $d^*.txt >[2]/dev/null \\
> | sed $dirfilter}) {
> desc=`{get_file_title $i}
> u=`{echo $i|sed 's!'$sitedir'!!; '$dirclean's!/index$!/!; '}
> if(! ~ $#desc 0 && ! ~ $desc '')
> desc=' - '$"desc
> n=`{echo /$u|sed 's/[\-_]/ /g; s,.*/([^/]+)/?$,\1,'}
> if(test -d $i) f=$i^index.md
> if not f=$i
> r=`{grep $pattern $f | sed G | markdown.pl | sed
> 's/'$pattern'/<span class="hl">&<\/span>/'}
> echo '<li><a href="'$u'">'^$"n^'</a>' $"desc '<br>' $"r '</li>'
> if(test -d $i)
> @{ listDir $i $pattern}
> }
> echo '</ul>'
> }
> }
> if(! ~ '' $"post_arg_search_go $"post_arg_search_pattern)
> listDir $sitedir/ $"post_arg_search_pattern
> %}
> so now i can use something like:
> <form action="/search" method="POST">
> <input type="text" name="search_pattern"
> value="%($"post_arg_search_pattern%)">
> <input type="submit" name="search_go" value="Search">
> </form>
> what do you think, can you improve this, do you have something else?
> best regards, yoshi
> --
> You received this message because you are subscribed to the Google Groups
> "werc" group.
> To post to this group, send email to werc9@googlegroups.com.
> To unsubscribe from this group, send email to
> werc9+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/werc9?hl=en.