/[swish]/trunk/make_config.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/make_config.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32 - (show annotations)
Wed Apr 30 12:40:09 2003 UTC (20 years, 11 months ago) by dpavlin
File MIME type: text/plain
File size: 2974 byte(s)
added make_config.pl which creates swish config file
added checkbox to hide document properties (like content, size etc)
remove comments between <html> and <head> which confuse swish

1 #!/usr/bin/perl -w
2 #
3 # create configuration for my version of swish crawler and web interface
4 #
5 # 2003-04-26 Dobrica Pavlinusic <dpavlin@rot13.org>
6 #
7
8 use strict;
9
10 my ($name,$url,$stripurl) = @ARGV;
11
12 if (!$name || !$url) {
13 print "Usage: $0 name URL\n";
14 exit;
15 }
16
17 my $dir=$0; $dir=~s/\/[^\/]+$//;
18
19 # try to deduce working directory if script is not called with absolute path
20 if ($dir !~ m#^/#) {
21 chomp($dir = `pwd`);
22 }
23
24 my ($host,$urlpath);
25
26 if ($url =~ m#(http://[^/]+)(/.+)$#) {
27 ($host,$urlpath) = ($1,$2);
28 if ($stripurl && $urlpath =~ m/^(.*$stripurl)/) {
29 $stripurl = $1;
30 } else {
31 $stripurl = "";
32 }
33 } else {
34 print "Can't parse URL $url into host and path!\n";
35 exit 1;
36 }
37
38 my $baseurl = $url;
39 $baseurl =~ s#/[^/]+$#/#g;
40
41 print "Config name: $name\nCrawling url: $url [strip $stripurl]\n";
42
43
44 my $config = <<"EOF";
45
46 ###################################################
47 IncludeConfigFile $dir/common.config
48
49 # this is a cludge to implement no parent URL feature in swish indexer
50 IndexDir "$url $baseurl"
51 ReplaceRules replace " $baseurl" ""
52 ReplaceRules replace "${host}${stripurl}" ""
53
54 IndexFile $dir/index/$name
55
56 StoreDescription HTML <body> 500
57
58 # not very usefull, but...
59 MetaNames keywords description
60
61 # store <title>
62 PropertyNameAlias swishtitle title
63
64 EOF
65
66 my $xml = << "EOF";
67 <config
68 max_hits="1000"
69 prog="/usr/bin/swish-e"
70 index="$dir/index/$name"
71 charset="iso-8859-2"
72 title="$name search"
73 affix="/usr/lib/ispell/american.aff"
74 url="$stripurl"
75 >
76 <labels>
77 <label value="10"> 10</label>
78 <label value="100"> 100</label>
79 <label value="0">unlimited</label>
80 </labels>
81 <text>
82 <search>Search for </search>
83 <documents> documents containing words: </documents>
84 <submit>Search</submit>
85 <no_spell>don't use alternative spellings </no_spell>
86 <no_properties>don't display results details</no_properties>
87 <hits>Showing %s documents (of maximum %d)... (%s)</hits>
88 <no_hits>Can't find any documents (%s, %s)</no_hits>
89 <footer>Searcher will try to create different variations of words using spelling dictionary. If you enter a word with minus (-) before it, it will exclude documents with this word and plus (+) will do the opposite (e.g. -work +play)</footer>
90 </text>
91 <!-- additional data to show summary -->
92 <properties>swishdescription swishdocsize</properties>
93 <hit><![CDATA[ <a href="%s">%s</a> [%s]<br>
94 <font color=gray size=-2>%s ... <i>%s bytes</i></font><br>
95 ]]></hit>
96
97 </config>
98 EOF
99
100 print "Creating $dir/$name.config\n";
101 open(C,"> $dir/$name.config") || die "can't open $dir/$name.config: $!";
102 print C $config;
103 close(C);
104
105 print "Creating $dir/html/$name.xml\n";
106 open(C, "> $dir/html/$name.xml") || die "can't open $dir/html/$name.xml: $!";
107 print C $xml;
108 close(C);
109
110 print "Creating symlink to $dir/html/$name.cgi\n";
111 symlink "$dir/html/swish.cgi","$dir/html/$name.cgi" || die "can't create symlink $dir/html/$name.cgi: $!";
112
113 #print "Index this with:\nswish-e -S http -c $dir/$name.config\n";
114 #print "Search using $name.cgi\n";

Properties

Name Value
cvs2svn:cvs-rev 1.1
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26