| 資訊科技與中文教學應用 | 首頁 | 前頁 | 論壇 | 搜尋 |
|
Simple Search 是一個十分簡單、易用的免費搜尋引擎程式,它能快速搜尋網站內的內容,然後把有關連結羅列出來,示例見於搜尋頁。Simple
Search 版權為 London Perl Mongers 擁有。
Simple Search 載於 http://nms-cgi.sourceforge.net/scripts.shtml ,下載並解壓後,得到以下四個檔案:
首兩檔案須上載到伺服器,後兩檔案為說明文件。
編寫新網頁,或改寫舊有網頁。很多時候,cgi 程式的供應者同時提供所需網頁,與程式一併下載。當然,有關網頁一般須稍作修改、調校(見下步驟四)。
調校有關的參數。不同的程式,有不同的效果,同時,也有不同的要求。應用某一特定 cgi 程式 ,便須按照程式的規定(有關網頁多會說明清楚),設定網頁上的內容。有關 cgi 程式的調校項目包括:
一、程式。常包括:a) 如程式以 PERL 編寫,程式的第一句說明哪裡找到運行 PERL 程式的資源,須因應伺服器修改;b) 程式涉及的網址;c) 程式顯示的內容。
There are a number of variables that you can change in search.pl which
alter the way that the program works. $basedir and $baseurl are the two
most important variables, and must be altered to refer to your website.
尋找以下部份:
| $DEBUGGING = 1; $basedir = '/usr/local/apache/htdocs'; $baseurl = 'http://localhost/'; @files = ('*.html','*/*.html'); $title = "NMS Search Program"; $title_url = 'http://cgi-nms.sourceforge.net'; $search_url = 'http://localhost/search.html'; @blocked = (); $emulate_matts_code = 1; $style = ''; $charset = 'iso-8859-1'; |
修改以下套紅的部分:
| $DEBUGGING = 0; $basedir = '/user?/<login-name>/public_html'; $baseurl = 'http://web.hku.hk/~<login-name>'; @files = ('*.htm','*/*.htm','*.html','*/*.html'); $title = "回到主頁"; $title_url = 'http://web.hku.hk/~<login-name>'; $search_url = 'http://web.hku.hk/~<login-name>/cgi-bin/search/search.htm'; @blocked = (); $emulate_matts_code = 1; $style = ''; $charset = 'big5'; |
以下是一個實際的例子:
| $DEBUGGING = 0; $basedir = '/user3/jwilam/public_html'; $baseurl = 'http://web.hku.hk/~jwilam'; @files = ('*.htm','*/*.htm','*.html','*/*.html'); $title = "回到主頁"; $title_url = 'http://web.hku.hk/~jwilam'; $search_url = 'http://web.hku.hk/~jwilam/cgi-bin/search/search.htm'; @blocked = (); $emulate_matts_code = 1; $style = ''; $charset = 'big5'; |
$basedir
This is the base directory (where each search will start); hence it should encompass everything you want searched. Files and directories you want blocked from the search should be placed in the @blocked array (described below); everything else will be searched. The base directory and all directories below it (that you want searched) must be world readable and executable. For example, this variable might be set to /home/larry/public_html/articles
Simple Search will scan and search all directories and subdirectories
from a start point (defined by $basedir).
$baseurl
This is the base URL, which is the URL relative to $basedir (mentioned above). This variable will be used in generating links (URLs) relative to the files found containing the text search for. For example, this variable might be set to http://www.webhost.com/~larry/articles
@files
This array contains the files to be searched. There are a few special symbols you can use to describe those files.
$title
This is the title that will be displayed on the search results page, and it will also be used as the text of the link intended to point back to your main webpage.
$title_url
This variable is intended to be set to the URL of your main web- page. The associated hypertext will be the value of $title, and it will be displayed on the results page so that users can link back to the search page (to perform another search).
$search_url
The URL of search.html. This is included on the results page so that users can link back to the search page to perform a new search.
$charset
The name of the character set to use for the output document.
二、網頁。常包括:a) 網頁中 form tag 之中,所要啟動程式的網址;b) 網頁所顯示的內容。
|
<body> ...... <form method="post" action="http://web.hku.hk/cgi-bin/cgiwrap/jwilam/search/search.pl"> ...... </body> |
這部份的作用有點像 javascript 的程式部份,不同者在於,javascript 是把程式放置在網頁原始檔之內,而 cgi 則須上載到伺服器之上。但較複雜的地方是,上載到伺服器上的程式及其他相關檔案,必須經 chmod 指令修改屬性,方能運行。
Simple Search is installed simply by copying the file search.pl into your cgi-bin directory. If you don't know the location of your cgi-bin directory, then please ask your system administrator.
You will probably need to turn on execute permissions to the file search.pl. If you have shell access to the HTTP server, you can do this by running the command `chmod +x search.pl` from the command line. If you don't have command line access then there will probably be an equivalent function (to change file mode) in your file transfer program.
試用看看有沒有錯誤,如有出錯,則重新檢視以上各步驟以除錯,然後把網頁以及有關附帶檔案都上載到伺服器上。
搜尋內容 terms
This parameter contains the terms that will be searched.
搜尋方式 bool
If there is more then one term in the search query, this parameter
defines whether the terms AND'ed or OR'ed. The default is OR.
大寫小寫 case
This parameter defines whether a search will be case-sensitive or
case-insensitive. The default is case-insensitive.