Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
search box
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Yoshi Rokuko  
View profile  
 More options Nov 12 2011, 11:31 am
From: Yoshi Rokuko <yo...@rokuko.net>
Date: Sat, 12 Nov 2011 17:31:11 +0100
Local: Sat, Nov 12 2011 11:31 am
Subject: search box
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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Floren  
View profile  
 More options Nov 12 2011, 11:41 am
From: John Floren <j...@jfloren.net>
Date: Sat, 12 Nov 2011 08:41:12 -0800
Local: Sat, Nov 12 2011 11:41 am
Subject: Re: search box

What would happen if I searched for "foo *; rm -r *;"?

I'm always leery of taking input from users and executing it, but of course
I don't do much rc programming so it may be a non issue.
On Nov 12, 2011 8:32 AM, "Yoshi Rokuko" <yo...@rokuko.net> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yoshi Rokuko  
View profile  
 More options Nov 12 2011, 12:00 pm
From: Yoshi Rokuko <yo...@rokuko.net>
Date: Sat, 12 Nov 2011 18:00:36 +0100
Local: Sat, Nov 12 2011 12:00 pm
Subject: Re: search box
+------------------------------ John Floren -----------+

> What would happen if I searched for "foo *; rm -r *;"?

if this would be an issue it would be a bug in grep or
sed i think (see below)

yoshi

<...>

> > r=`{grep $pattern $f | sed G | markdown.pl | sed \\
> >    's/'$pattern'/<span class="hl">&<\/span>/'}

<...>

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ethan Grammatikidis  
View profile  
 More options Nov 18 2011, 7:41 pm
From: Ethan Grammatikidis <eeke...@fastmail.fm>
Date: Sat, 19 Nov 2011 00:41:33 +0000
Local: Fri, Nov 18 2011 7:41 pm
Subject: Re: search box
On Sat, 12 Nov 2011 18:00:36 +0100

Yoshi Rokuko <yo...@rokuko.net> wrote:
> +------------------------------ John Floren -----------+
> > What would happen if I searched for "foo *; rm -r *;"?

> if this would be an issue it would be a bug in grep or
> sed i think (see below)

> yoshi

> <...>
> > > r=`{grep $pattern $f | sed G | markdown.pl | sed \\
> > >    's/'$pattern'/<span class="hl">&<\/span>/'}
> <...>

I've been trying to make this break but the worst I made happen was a
syntax error from rc, so it looks ok. I would look at how pattern is
set rather than this end, just to be sure, but I expect werc's form
stuff is pretty well worked out.

I would think Bourne shell would be more likely to make this a problem.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »