Changeset 1889
- Timestamp:
- 02/06/07 14:53:36 (1 year ago)
- Files:
-
- swish_website/README (modified) (2 diffs)
- swish_website/bin/build (modified) (1 diff)
- swish_website/bin/index_hypermail.pl (modified) (1 diff)
- swish_website/etc/archive.conf (modified) (1 diff)
- swish_website/etc/httpd.conf.tt (modified) (3 diffs)
- swish_website/lib/config/macros (modified) (1 diff)
- swish_website/lib/config/map (modified) (1 diff)
- swish_website/lib/page/footer.html (modified) (1 diff)
- swish_website/lib/page/html.html (modified) (1 diff)
- swish_website/lib/page/search.html (modified) (9 diffs)
- swish_website/lib/page/searchform.html (modified) (1 diff)
- swish_website/src/.htaccess (deleted)
- swish_website/src/discuss.html (modified) (1 diff)
- swish_website/src/search.js (added)
- swish_website/src/search/.htaccess (deleted)
- swish_website/src/search/index.html (modified) (8 diffs)
- swish_website/src/swish.css (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
swish_website/README
r1887 r1889 276 276 277 277 278 It might be necessary to specify the full path to the modules unless 279 the modules are located "modules" in ServerRoot. 280 281 278 282 For debugging locally, say just the web site 279 283 … … 285 289 --ipaddr `hostname` \ 286 290 --domain `hostname` \ 291 --user `whoami` \ 292 --group `whoami` \ 287 293 --nodev_site \ 288 294 --nolists_site \ 289 295 --nosvn_site \ 296 --module_dir /usr/lib/apache2/modules \ 290 297 > httpd.test 291 298 swish_website/bin/build
r1887 r1889 364 364 # Thise have defaults so this should not fail 365 365 die "Must specify top-level web source directory with -src\n" unless $config->src; 366 die "Must specify either -dest \n" unless $config->dest; # not really true366 die "Must specify either -dest or -root\n" unless $config->dest; # not really true 367 367 368 368 swish_website/bin/index_hypermail.pl
r1886 r1889 65 65 <title>$title</title> 66 66 $metas 67 <meta name="section" content="archive"> 67 68 </head> 68 69 <body> swish_website/etc/archive.conf
r1886 r1889 1 MetaNames swishtitle name email 2 PropertyNames name email 1 ReplaceRules regex !^.*archive/!/archive/! 2 MetaNames swishtitle name email section 3 PropertyNames name email section 3 4 IndexContents HTML* .html 4 5 StoreDescription HTML* <body> 100000 swish_website/etc/httpd.conf.tt
r1887 r1889 68 68 END; 69 69 70 70 71 MACRO load_modules( modules ) BLOCK; 71 72 FOR module = modules; … … 73 74 mod_path = "$module_dir/mod_${module}.so"; 74 75 76 77 # This requires that the module directory is absolute 78 # but also makes the code Apache 2.2-aware. 75 79 TRY; 76 80 USE File( mod_path ); … … 202 206 </Directory> 203 207 [% END %] 208 209 210 ErrorDocument 404 /404.html 211 <Files 404.html> 212 Options +ExecCGI 213 SetHandler cgi-script 214 </Files> 215 216 <Directory [% dest %]/search> 217 <Files index.html> 218 Options +ExecCGI 219 SetHandler cgi-script 220 </Files> 221 </Directory> 204 222 205 223 </VirtualHost> swish_website/lib/config/macros
r1587 r1889 1 1 [%- 2 page.javascript = []; 3 4 MACRO include_javascript( name ) BLOCK; 5 js_found = 0; 6 FOR js = page.javascript; 7 IF js == name; 8 js_found = 1; 9 LAST; 10 END; 11 END; 12 page.javascript.push( name ) UNLESS js_found; 13 END; 2 14 3 15 swish_website/lib/config/map
r1871 r1889 251 251 search = { 252 252 name = 'Search' 253 hidden = 1 # don't show on main menu253 # hidden = 1 # don't show on main menu 254 254 menu = [] # make it /search/ instead of search.html 255 255 } swish_website/lib/page/footer.html
r1871 r1889 7 7 </span> 8 8 9 [%# This is slow as can be 9 10 <p> 10 11 <script type='text/javascript' src='http://www.ohloh.net/projects/3196;badge_js'></script> 11 12 </p> 13 %] 12 14 13 15 <p> swish_website/lib/page/html.html
r1869 r1889 20 20 21 21 <title>Swish-e :: [% page.title | html %]</title> 22 23 [%- FOREACH js = page.javascript %] 24 [%- IF js.match('^http:') %] 25 <script type="text/javascript" src="[% "js" %]"></script> 26 [%- ELSE %] 27 <script type="text/javascript" src="[% "/${js}.js" %]"></script> 28 [%- END %] 29 [%- END %] 30 22 31 </head> 23 32 swish_website/lib/page/search.html
r1629 r1889 1 1 [%- # $id$ 2 # Page for sh woing search results2 # Page for showing search results 3 3 -%] 4 4 [%- META … … 11 11 12 12 page.title = 'Search'; 13 page.no_search = 1; 14 15 include_javascript( 'search' ); 13 16 14 17 … … 20 23 END; 21 24 25 page_ids = {}; 26 MACRO radio( name, value, label, checked ) BLOCK; 27 page_ids.$name = page_ids.$name + 1; 28 id = page_ids.$name; 29 ck = checked ? ' checked="checked"' : ''; 30 %] 31 <input id="[% name; id %]" type="radio" name="[% name %]" value="[% value | html %]"[% ck %]/> 32 <label for="[% name; id %]">[% label | html %]</label> 33 [% 34 END; 35 36 37 MACRO select( name, value, label, checked ) BLOCK; 38 ck = checked ? ' selected="selected"' : ''; 39 %] 40 <option id="[% name; value %]" value="[% value | html %]"[% ck %]>[% label | html %]</option> 41 [% 42 END; 43 22 44 USE myurl = url( request.myself, query=request.query, 23 45 metaname=request.metaname, size=request.pagesize ); … … 26 48 27 49 28 UNLESS result; 29 message( "Must enter a query" ); 30 ELSE; 31 50 51 PROCESS search_form; 52 53 54 IF result; 32 55 # Show results 33 56 34 57 message( result.message ) IF result.message; 58 35 59 36 60 IF result.results.size; … … 49 73 </div> 50 74 75 <div id="hidingplace" style="display:none"></div> 76 77 78 79 [% BLOCK search_form %] 80 <form id="searchform" method="get" action="index.html"> 81 <h2>Enter your query</h2> 82 <div id="simpleform"> 83 <input type="text" size="30" name="query" /> 84 <input type="submit" name="submit" value="Search!" /> 85 </div> 86 <div id="advancedform" style="display: none"> 87 <input id="advflag" name="adv" type="hidden" value="0" /> 88 Limit to: 89 [% 90 radio( 'meta', '', 'Subject/Title & Body', 1 ); 91 radio( 'meta', 'title', 'Subject/Title' ); 92 radio( 'meta', 'name', "Poster's Name" ); 93 radio( 'meta', 'email', "Poster's Email" ); 94 %] 95 96 <br /> 97 98 Search: 99 <select name="section"> 100 [% 101 select( 'section', '', 'Everywhere',1 ); 102 select( 'section', 'docs', 'Documentation' ); 103 select( 'section', 'devel', 'Development Docs' ); 104 select( 'section', 'archive', 'List Archives' ); 105 select( 'section', 'website', 'Site web pages' ); 106 %] 107 </select> 108 109 Sort by: 110 <select name="sort"> 111 <option value="rank">Rank</option> 112 <option value="title">Subject/Title</option> 113 <option value="email">Email</option> 114 <option value="date">Date</option> 115 </select> 116 <input id="rsort" type="checkbox" name="reverse" /><label for="rsort">Reverse Sort</label> 117 118 <br /> 119 Limit to date: 120 [% 121 radio( 'date', '', 'All', 1); 122 radio( 'date', 'day', 'Today' ); 123 radio( 'date', 'week', 'This Week' ); 124 radio( 'date', 'month', 'This Month' ); 125 radio( 'date', '90', 'Last 90 Days' ); 126 '<br />'; 127 radio( 'date', 'select', 'Select date range' ); 128 129 130 PROCESS select_date name = 's'; 131 ' through '; 132 PROCESS select_date name = 'e'; 133 %] 134 </div><!-- /#advancedform --> 135 </form> 136 [% END %] 137 138 [% BLOCK select_date %] 139 <select name="[% name %]month"> 140 <option value="1">Jan</option> 141 <option value="2">Feb</option> 142 <option value="3">Mar</option> 143 <option value="4">Apr</option> 144 <option value="5">May</option> 145 <option value="6">Jun</option> 146 <option value="7">Jul</option> 147 <option value="8">Aug</option> 148 <option value="9">Sep</option> 149 <option value="10">Oct</option> 150 <option value="11">Nov</option> 151 <option value="12">Dec</option> 152 </select> 153 154 <select name="[% name %]day"> 155 [% i = 1; WHILE i < 32 %] 156 <option value="[% i %]">[% i %]</option> 157 [% i = i + 1; END %] 158 </select> 159 160 <select name="[% name %]year"> 161 [% i = cur_year; WHILE i > 1995 %] 162 <option value="[% i %]">[% i %]</option> 163 [% i = i - 1; END %] 164 </select> 165 [% END %] 166 167 168 51 169 52 170 … … 67 185 <div class="search-header"> 68 186 Results for <b>[% request.query | html %]</b><br /> 187 </div> 188 [% END %] 189 190 191 192 193 [% BLOCK next_links %] 69 194 Showing page [% result.page %] 70 195 ([% result.start +1 %] - [% (result.start + result.shown) %] of [% result.hits %] hits) 71 196 72 </div>73 [% END %]74 75 76 77 78 [% BLOCK next_links %]79 197 [% IF result.prev %] 80 198 <a class="next" href="[% myurl( page=result.prev ) %]">Previous</a> … … 94 212 %] 95 213 96 <div class="search-title"> 97 214 <h2 id="result-heading"> 215 <a href="[% item.Property('swishdocpath') %]"> 216 [% item.Property('swishtitle') || 'missing title' | highlight('swishtitle', item ) %] 217 </a> 218 </h2> 219 220 <div class="search-subtitle"> 98 221 [% IF is_list %] 99 222 <span class='indxtype'>[List Archive]</span> … … 104 227 [% END %] 105 228 106 <a href="[% item.Property('swishdocpath') %]"> 107 [% item.Property('swishtitle') || 'missing title' | highlight('swishtitle', item ) %]</a> 108 109 <span class="search-rank"> -- rank: <b>[% item.Property('swishrank') %]</b></span> 229 <span class="search-rank">Rank: <b>[% item.Property('swishrank') %]</b></span> 110 230 </div> 111 231 … … 134 254 SET name = item.Property('name'); 135 255 SET email = item.Property('email'); 136 SET name_href = myurl( query=" name=\"$name\"" );137 SET email_href = myurl( query=" email=\"$email\"" );256 SET name_href = myurl( query="\"$name\"", meta="name" ); 257 SET email_href = myurl( query="\"$email\"", meta="email" ); 138 258 %] 139 259 swish_website/lib/page/searchform.html
r1699 r1889 1 <!-- noindex --> 2 <div class="subHeader"> 3 4 <form method="get" 5 action="[% link_to_page('search','', 1 ) %]" 6 enctype="application/x-www-form-urlencoded" 7 class="srchform"> 8 9 <table width='100%'> 10 <tr> 11 <td align='left'> 12 [% link_to_page( 'index' ) %] | 13 [% link_to_page( 'support' ) %] | 14 [% link_to_page( 'download' ) %] 15 </td> 16 17 <td align='right'> 1 <!-- noindex --> 2 <div class="subHeader"> 3 <table width='100%'> 4 <tr> 5 <td align='left'> 6 [% link_to_page( 'index' ) %] | 7 [% link_to_page( 'support' ) %] | 8 [% link_to_page( 'download' ) %] 9 </td> 18 10 19 11 20 <label for="searchfield">Search for</label> 21 <input maxlength="200" value="" id="searchfield" size="30" name="query" type="text" alt="Search input field"/> 22 <input value="[% this.abslinks ? "search swish-e.org" : "search" %]" name="submit" type="submit" class='button' /> 12 [% UNLESS page.no_search %] 13 <td align='right'> 23 14 24 </td> 25 </tr> 26 </table> 15 <form method="get" 16 action="[% link_to_page('search','', 1 ) %]" 17 enctype="application/x-www-form-urlencoded" 18 class="srchform"> 27 19 28 </form> 20 <label for="searchfield">Search for</label> 21 <input maxlength="200" value="" id="searchfield" size="30" name="query" type="text" alt="Search input field" /> 22 <input value="[% this.abslinks ? "search swish-e.org" : "search" %]" name="submit" type="submit" class='button' /> 23 </form> 29 24 30 </div> 31 <!-- index --> 25 </td> 26 [% END %] 27 </tr> 28 </table> 29 </div> 30 <!-- index --> swish_website/src/discuss.html
r1885 r1889 44 44 45 45 <blockquote> 46 <form method="get" action="/search _archive/swish.cgi" enctype=46 <form method="get" action="/search/index.html" enctype= 47 47 "application/x-www-form-urlencoded" class="form"> 48 48 49 49 <p> 50 <input maxlength="200" value="" size="32" type="text" 51 name="query" /> <input value="Search!" type="submit" 52 name="submit" /><br /> 53 Limit search to: <input value="swishdefault" type= 54 "radio" checked="checked" name="metaname" />Message 55 text <input value="subject" type="radio" name= 56 "metaname" />Message Subject <input value="name" type= 57 "radio" name="metaname" />Poster's Name <input value= 58 "email" type="radio" name="metaname" />Poster's 59 Email<br /> 60 Sort by: <select name="sort"> 61 <option value="swishrank"> 62 Rank 63 </option> 64 65 <option value="subject"> 66 Message Subject 67 </option> 68 69 <option value="name"> 70 Poster's Name 71 </option> 72 73 <option value="email"> 74 Poster's Email 75 </option> 76 77 <option value="sent"> 78 Message Date 79 </option> 80 </select> <input value="1" type="checkbox" name= 81 "reverse" />Reverse Sort 50 <input maxlength="200" value="" size="32" type="text" name="query" /> 51 <input value="Search!" type="submit" name="submit" /><br /> 52 <input type="hidden" name="section" value="archive" /> 82 53 </p> 83 54 </form> swish_website/src/search/index.html
r1611 r1889 1 #![%- META type = 'text' -%] 2 [% locate.in_path( 'speedy') || locate.in_path( 'perl' ) %] 1 #![% locate.in_path( 'speedy') || locate.in_path( 'perl' ) %] 2 3 [% META type = 'text' %] 3 4 4 5 package SwishAPISearch; 5 6 use strict; 6 7 use warnings; 8 use DateTime; 9 10 7 11 8 12 ###################################################################### 9 13 # Skeleton CGI script for searching a Swsih-e index with SWISH::API. 10 # see below for documen ation or run "perldoc search.cgi"14 # see below for documentation or run "perldoc search.cgi" 11 15 # 12 16 # Copyright 2003, 2004 Bill Moseley - All rights reserved. … … 15 19 # 16 20 ####################################################################### 21 22 23 # Lookup hash for which metanames are defined 24 our %METANAMES = ( 25 title => 'swishtitle', 26 name => 'name', 27 email => 'email', 28 ); 29 30 our %PROPERTIES = ( 31 name => 'name', 32 email => 'email', 33 title => 'swishtitle', 34 rank => 'swishrank', 35 date => 'swishlastmodified', 36 ); 37 38 our %REVERSE_SORT = ( 39 swishrank => 1, 40 swishlastmodified => 1, 41 ); 42 43 # Valid section metaname values -- to limit to sections of the site. 44 our %SECTIONS = ( 45 website => 1, 46 devel => 1, 47 docs => 1, 48 archive => 1, 49 ); 50 51 17 52 18 53 use vars '$VERSION'; … … 163 198 $instance->{request} = $request; 164 199 200 $instance->{cur_year} = (gmtime(time))[5] + 1900; 201 165 202 $instance->{rooturl} = '[% site.url.root %]'; 166 203 … … 169 206 if ( $request->{query} ) { 170 207 171 # Limit by metaname 172 $request->{swish_query} = $request->{metaname} 173 ? "$request->{metaname}=( $request->{query} )" 174 : $request->{query}; 175 176 $instance->{result} = run_query( $instance ); 208 # Update to handle a bit more complex queries 209 generate_query( $request ); 210 211 212 $instance->{result} = $request->{message} 213 ? { message => $request->{message } } 214 : run_query( $instance ); 177 215 } 178 216 … … 188 226 print $fill_in_object->fill( scalarref => $output, fobject => $cgi ); 189 227 228 warn sprintf("Query=[%s] Hits=[%d]\n", 229 $instance->{request}->{swish_query} || '', 230 $instance->{result}->{hits} || 0 ); 231 190 232 delete $instance->{request}; # clean up the request 191 233 delete $instance->{result}; … … 195 237 196 238 239 240 241 242 243 244 245 =item generate_query 246 247 Looks at request and build up query, sorts, and limits 248 249 =cut 250 251 sub generate_query { 252 my $request = shift; 253 254 my $query = $request->{query}; 255 my $cgi = $request->{cgi}; 256 257 258 # Limit query to a specific metaname? 259 if ( my $meta = $cgi->param('meta') ) { 260 261 $query = "$METANAMES{$meta}=($query)" if $METANAMES{$meta}; 262 } 263 264 265 # Limit the query to sections of the site 266 267 my $sections = join " or ", grep { $SECTIONS{$_} } $cgi->param('section'); 268 $query .= " section=$sections" if $sections; 269 270 271 $request->{swish_query} = $query; 272 273 274 275 276 # Set sort 277 if ( $cgi->param('sort') && (my $sort = $PROPERTIES{ $cgi->param('sort')}) ) { 278 279 my $reverse = $cgi->param('reverse') ? 1 : 0; 280 $reverse = ! $reverse if $REVERSE_SORT{ $sort }; 281 282 $sort .= ' desc' if $reverse; 283 284 $request->{sort} = $sort; 285 } 286 287 288 # Limit by dates 289 my $limit = $cgi->param('date') || return; 290 291 292 my $low = DateTime->now; 293 my $high = DateTime->now; 294 295 my @limit_range; 296 297 if ( $limit =~ /^(day|month|year|week)$/ ) { 298 @limit_range = ( 299 DateTime->now->truncate( to => $1 )->epoch, 300 time, 301 ); 302 } 303 304 305 if ( $limit =~ /^\d+$/ && $limit < 5000 ) { 306 @limit_range = ( 307 DateTime->now->truncate( to => $1 )->subtract( days => $limit ), 308 time, 309 ); 310 } 311 312 if ( $limit eq 'select' ) { 313 314 my %params; 315 for my $t ( 's', 'e' ) { 316 for my $x ( qw/ year month day / ) { 317 my $value = $cgi->param( $t . $x ); 318 next unless $value; 319 $params{$t}{$x} = $value; 320 } 321 } 322 unless ( $params{s}{year} && $params{e}{year} ) { 323 $request->{message} = 'Incomplete date submitted'; 324 return; 325 } 326 327 328 eval { 329 @limit_range = ( 330 DateTime->new( %{$params{s}} )->epoch, 331 DateTime->new( %{$params{e}} 332 )->add( days => 1 )->subtract( seconds => 1 )->epoch, 333 ); 334 }; 335 336 if ( $@ ) { 337 warn "Bad date submitted $@\n"; 338 $request->{message} = "Invalid date submitted"; 339 @limit_range = (); 340 } else { 341 if ( $limit_range[0] > $limit_range[1] ) { 342 $request->{message} = "Start date must be before end date"; 343 @limit_range = (); 344 } 345 } 346 } 347 348 349 $request->{limit_search} = [ 'swishlastmodified' , @limit_range ] if @limit_range; 350 } 351 352 353 354 355 356 197 357 # Subroutine to run the Swish query. Returns a hash reference. 198 358 # A better design might be to return an object with methods for accessing the data. … … 218 378 219 379 # $$$ TODO need to test for index file being modified 220 # one trick is to touch public_html/seach/index.htmland then speedy will reload.380 # one trick is to touch this script and then speedy will reload. 221 381 222 382 if ( ! $swish ) { … … 240 400 241 401 242 # Run the search. See SWISH::API for more options (like sorting) 243 244 my $results = $swish->Query( $request->{swish_query} ); 402 # Run the search 403 my $search = $swish->New_Search_Object; 404 405 406 $search->SetSort( $request->{sort} ) if $request->{sort}; 407 $search->SetSearchLimit( @{ $request->{limit_search} } ) if $request->{limit_search}; 408 409 my $results = $search->Execute( $request->{swish_query} ); 245 410 246 411 return { message => check_swish_error( $swish ) } if $swish->Error; swish_website/src/swish.css
r1871 r1889 527 527 /* ## Search Results ## */ 528 528 529 form#searchform { 530 margin-bottom: 2em; 531 } 532 529 533 div.search-page { /* enclosing div */ 530 534 margin: 2em 2em 0 0em; … … 563 567 } 564 568 565 .search-title { 566 font-size: 1.2em; 569 h2#result-heading { 570 font-size: 100%; 571 border-bottom: 1px solid gray; 572 } 573 h2#result-heading a:hover { 574 text-decoration: none; 575 } 576 577 #showform, #hideform { 578 text-decoration: underline; 579 font-size: 80%; 580 color: rgb(61,92,122); 567 581 } 568 582
