需要将搜索添加到静态HTML网站 [英] Need to add a search to static HTML site

查看:140
本文介绍了需要将搜索添加到静态HTML网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我有一个旧的静态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>

我知道,这是非常糟糕的,不会有任何创意?多年来我一直没有创造这样的东西,而且几乎只需要一点点代码就可以把它粘在一起!

解决方案

有相当多的解决方案可用于此。没有特定的顺序:

免费或开源


  1. Google自定义搜索引擎

  2. Tapir - 托管服务,用于在RSS订阅源中对页面进行索引。 Tipue - 自主托管的javaScript插件,有详细记录,包含用于固定搜索结果的选项。

  3. < a href =http://lunrjs.com/ =noreferrer> lunr.js - javaScript库。
  4. phinde - 自主托管php和elasticsearch搜索引擎 >另见 http://indieweb.org/search#Software



    订阅(又称付费)服务: =https://开头WWW .google.com / work / search / products / gss.htmlrel =noreferrer> Google Site Search

  5. Swiftype - 为个人网站/博客提供免费计划。

  6. Algolia

  7. Amazon Cloud搜索


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

  1. Google Custom Search Engine
  2. Tapir - hosted service that indexes pages on your RSS feed.
  3. Tipue - self hosted javaScript plugin, well documented, includes options for pinned search results.
  4. lunr.js - javaScript library.
  5. phinde - self hosted php and elasticsearch based search engine

See also http://indieweb.org/search#Software

Subscription (aka paid) Services:

  1. Google Site Search
  2. Swiftype - offers a free plan for personal sites/blogs.
  3. Algolia
  4. Amazon Cloud Search

这篇关于需要将搜索添加到静态HTML网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆