需要将搜索添加到静态HTML网站 [英] Need to add a search to static HTML site
问题描述
基本上我有一个旧的静态HTML网站( http://www.brownwatson .co.uk / brochure / page1.html )我需要添加一个搜索框来搜索一个名为/ brochure的文件夹,该文件夹是html文档和图片等我需要搜索以查找ISBN编号,Book参考数字,标题等..没有数据库的托管服务提供商已经得到了PHP我试图创建这样的事情:
< ; div id =contentsearch>
< form id =searchFormname =searchFormmethod =postaction =search.php>
< input name =searchtype =textvalue =searchmaxlength =200/>
< input name =submittype =submitvalue =Search/>
< / form>
<?php
$ dir =/ brochure /;
//打开一个已知的目录,然后阅读它的内容
if(is_dir($ dir)){
if($ dh = opendir($ dir)){
while(($ file = readdir($ dh))!== false){
if($ file == $ _POST ['search']){
echo('< a。href ='。$ dir。$ file。'>'。$ file。'< / a>'。\\\
);
}
}
closedir($ dh);
}
}
?>
< / div>
我知道,这是非常糟糕的,不会有任何创意?多年来我一直没有创造这样的东西,而且几乎只需要一点点代码就可以把它粘在一起!
有相当多的解决方案可用于此。没有特定的顺序:
免费或开源
- Google自定义搜索引擎
- Tapir - 托管服务,用于在RSS订阅源中对页面进行索引。 Tipue - 自主托管的javaScript插件,有详细记录,包含用于固定搜索结果的选项。
- < a href =http://lunrjs.com/ =noreferrer> lunr.js - javaScript库。 phinde - 自主托管php和elasticsearch搜索引擎 >另见 http://indieweb.org/search#Software
- Swiftype - 为个人网站/博客提供免费计划。
- Algolia
- Amazon Cloud搜索
订阅(又称付费)服务: =https://开头WWW .google.com / work / search / products / gss.htmlrel =noreferrer> Google Site Search
Basically I've got an old static html site ( http://www.brownwatson.co.uk/brochure/page1.html ) I need to add a search box to it to search a folder called /brochure within that folder is html documents and images etc I need the search to find ISBN numbers, Book Reference Numbers, Titles etc.. There's no database the hosting provider has got php I was trying to create something like this:
<div id="contentsearch">
<form id="searchForm" name="searchForm" method="post" action="search.php">
<input name="search" type="text" value="search" maxlength="200" />
<input name="submit" type="submit" value="Search" />
</form>
<?php
$dir = "/brochure/";
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if($file == $_POST['search']){
echo('<a href="'.$dir . $file.'">'. $file .'</a>'."\n");
}
}
closedir($dh);
}
}
?>
</div>
I know, I know this is pretty bad and doesn't work any ideas? I haven't created anything like this in years, and have pretty much just taken bits of code and stuck it together!
There are quite a few solutions available for this. In no particular order:
Free or Open Source
- Google Custom Search Engine
- Tapir - hosted service that indexes pages on your RSS feed.
- Tipue - self hosted javaScript plugin, well documented, includes options for pinned search results.
- lunr.js - javaScript library.
- phinde - self hosted php and elasticsearch based search engine
See also http://indieweb.org/search#Software
Subscription (aka paid) Services:
- Google Site Search
- Swiftype - offers a free plan for personal sites/blogs.
- Algolia
- Amazon Cloud Search
这篇关于需要将搜索添加到静态HTML网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!