Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new feature: local search #694

Merged
merged 3 commits into from
Mar 2, 2016
Merged

new feature: local search #694

merged 3 commits into from
Mar 2, 2016

Conversation

flashlab
Copy link
Contributor

@flashlab flashlab commented Mar 1, 2016

localsearch

!dea and core codes are from Joseph Pan.

see Wiki.

@flashlab flashlab changed the title Mypr new feature: local search Mar 1, 2016
@flashlab
Copy link
Contributor Author

flashlab commented Mar 1, 2016

@iissnan wiki page done; compatibility pass 😄

iissnan added a commit that referenced this pull request Mar 2, 2016
new feature: local search
@iissnan iissnan merged commit 373b080 into iissnan:master Mar 2, 2016
@iissnan
Copy link
Owner

iissnan commented Mar 2, 2016

Cool. 👍

@iissnan iissnan added Docs and removed Docs labels May 6, 2016
@iissnan
Copy link
Owner

iissnan commented Jun 13, 2016

在站点配置文件里

@timeng
Copy link

timeng commented Jun 17, 2016

5.0.0 添加了配置,但是并没有百度和google搜索

@flashlab
Copy link
Contributor Author

@timeng 新版去掉了搜索框,只保留了搜索弹窗。

@flashlab
Copy link
Contributor Author

@dog-2 之前测试过是可以的,有没有demo呢?

@flashlab
Copy link
Contributor Author

@dog-2 我在本地试了下,是没有问题的。链接不存在问题,因为点击事件是js触发的。你试试www.xxx.yy/search.xml能不能访问。如果是本地测试,需要手动生成search.xml并且放到source的根目录下。

@haiwx
Copy link

haiwx commented Jun 25, 2016

@dog-2

我建议备份好文章等配置,重新部署,十分钟的事。

@effie999
Copy link

上面你们讨论的内容我都看不懂,我只知道我用了这个功能可以正常搜索……

@hustlibraco
Copy link

在Muse主题下面好像样式有问题,很多空白的地方。
ps.单个英文、汉字默认不能搜索

@flashlab
Copy link
Contributor Author

@hustlibraco 不太明白你的问题,单个字符搜索一般是没有意义的,所以忽略掉了。

@apsoftwaredev
Copy link

I'm having an issue with local search popup on mobile devices. It works fine on computer webpage, but when viewed on a mobile device the popup doesn't work. Thanks. I notice that it does work on mobile devices with the algolia example in the demo though.

@flashlab
Copy link
Contributor Author

flashlab commented Jul 4, 2016

Hi @danboice . did this problem happened on iphone? if so, maybe #969 had already mentioned it. Hope you can create a request to fix it, thanks ;)

@apsoftwaredev
Copy link

@flashlab Yes, it looks like the same issue. Sorry, I have to translate the text to understand it. It is an iPhone 6 with Safari that I am using. I did some searching and found that some other people are having trouble with similar popups on the current iOS. The local search works well otherwise.

@apsoftwaredev
Copy link

apsoftwaredev commented Jul 4, 2016

Also, I added $('#local-search-input').focus() after $('.popup').toggle(); in function proceedsearch in _scripts/third-party/localsearch.swig to get the cursor to focus on the search input field when it pops up. Something that might be good to add.

@flashlab
Copy link
Contributor Author

flashlab commented Jul 4, 2016

@danboice please check #973 , this should fix the issue. And it 'll be nice to see your pull request based on your idea, cause I can't spare much time to deal with it at present.

@apsoftwaredev
Copy link

okay. thanks. that fixed it.

@xuecat
Copy link

xuecat commented Aug 30, 2016

@flashlab 请问新版本只支持搜索弹窗,不支持搜索框可以修改吗?改成搜索框好看点!!

@FE-Mars
Copy link

FE-Mars commented Sep 2, 2016

@flashlab 点击搜索结果会出现重复域名

@flashlab
Copy link
Contributor Author

flashlab commented Sep 2, 2016

@xuecat #721 这个补丁完全移除了搜索框,你可以参考这patch改回去

@flashlab
Copy link
Contributor Author

@ilofter 我这里是可以访问的

@CalvinNeo
Copy link

@jiangxiaoqiang 你好,我遇到和你一样的问题,请问你是怎么找到这个特殊字符的错误的?我的文章比较多不太好找?

@tonyfloatersu
Copy link

目前我和@silverlining21 遇到相同的问题。。。在本地运行时,点击search时无法输入关键词,debug的时候也没有出现错误信息。并不明白发生了什么。

@flashlab
Copy link
Contributor Author

@CalvinNeo 我这里访问没有问题:smile: @tonyfloatersu 检查search.xml文件是不是生成

@tonyfloatersu
Copy link

@flashlab 需要从本地手动添加search.xml到repository里面去吗?(的确search.xml文件未生成)(再附上repository地址供参考)

@tonyfloatersu
Copy link

OK,问题解决了,感谢 👍

@CalvinNeo
Copy link

@flashlab @jiangxiaoqiang 刚测试了下search.xml是生成的,原因是我在_config.xml中有一个swifttype_key的字段没有注释掉,所以默认用swifttype引擎了。谢谢帮助

@marsggbo
Copy link

我用的是local Search,能正常搜索,但是跳转的时候出现问题,比如说文章标题是“flask入门笔记(四)--数据库”,但是它好像自动转义成了“%2Fblog%2F2017%2F01%2F19%2Fflask%E5%85%A5%E9%97%A8%E7%AC%94%E8%AE%B0-%E5%9B%9B-%E6%95%B0%E6%8D%AE%E5%BA%93%2F”,所以每次跳转就会失败,这个怎么解决?

@amoyiki
Copy link

amoyiki commented Jan 19, 2017

@marsggbo 转义是否是在--debug下看到?你可以先删除search.xml然后重新hexo g 生成search.xml试试

@jiangxiaoqiang
Copy link

jiangxiaoqiang commented Jan 23, 2017 via email

@marsggbo
Copy link

@amoyiki 我看了下那个文件,它的索引链接就是转义后的,重新hexo g后也是一样的,就像下面的图片一样(不知道可不可以上图片)
seach.xml文件

@marsggbo
Copy link

@amoyiki 我找到问题的解决办法了,需要修改localsearch.swig文件。修改前后:
修改前
修改后
但现在还有个问题就是我本地测试的时候可以正常跳转,但是hexo d后还是不行,这该怎么办?

@flashlab
Copy link
Contributor Author

@marsggbo 更新到最新版主题试试,不能跳转是因为没有解码

@alexpdh
Copy link

alexpdh commented Feb 19, 2017

@flashlab
image
我的配置是这样的,搜索跳转是,没有带上网址,直接从blog开始,将配置中的/blog/去掉改为默认的就可以,请问这个有解决办法吗

habren pushed a commit to habren/hexo-theme-next that referenced this pull request Apr 8, 2017
@sli1989
Copy link

sli1989 commented Jul 9, 2017

chrome和edge可以使用local search,IE11点击没有反应。

SCRIPT438: 对象不支持“endsWith”属性或方法

// Search DB path;
var search_path = "search.xml";
if (search_path.length === 0) {
  search_path = "search.xml";
} else if (search_path.endsWith("json")) {
  isXml = false;
}

endsWith 方法(字符串)(JavaScript)要求:
Microsoft Edge(Edge 浏览器)中受支持。应用商店应用(Windows 10 上的 Microsoft Edge)中也受支持。请参阅版本信息。
在以下文档模式中不受支持:Quirks、Internet Explorer 6 标准模式、Internet Explorer 7 标准模式、Internet Explorer 8 标准模式、Internet Explorer 9 标准模式、Internet Explorer 10 标准模式和 Internet Explorer 11 标准模式。在 Windows 8.1 中不受支持。

解决方案:

Just add the polyfill above your existing code.

//https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
if (!String.prototype.endsWith) {
  String.prototype.endsWith = function(searchString, position) {
      var subjectString = this.toString();
      if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
        position = subjectString.length;
      }
      position -= searchString.length;
      var lastIndex = subjectString.indexOf(searchString, position);
      return lastIndex !== -1 && lastIndex === position;
  };
}

@ivan-nginx
Copy link
Collaborator

@sli1989 try to install localsearch from @flashlab repository.

@sli1989
Copy link

sli1989 commented Jul 10, 2017

thank for your advise @ivan-nginx. i am depoy the hexo blog using gitlab pages with CI, so i can only using local search in command line. after all, i fixed the problem by add the polyfill above in localsearch.swig.

@XuCcc
Copy link

XuCcc commented Aug 6, 2017

我点搜索后一直是圆圈在转,根目录下也没有search.xml啊

@chaixuhong
Copy link

@XuCcc 我们的问题是一样的。点击搜索后一直转圈圈,搜索框出不来,虽然我执行,hexo g 时能生成.xml,但是没什么卵用

@lanbos
Copy link

lanbos commented Aug 25, 2017

本地搜索安装后点击搜索没有反应解决方式:

找到是因为生成的search.xml解析错误就很好排查了,进入xml格式检查网站,把search.xml粘进去一点一点找到报错的地方。最后发现是文章里有一处用了特殊字符,(前段时间vscode和搜狗配合使用会莫名其妙出一些特殊字符),删掉后hexo g重启,问题解决。

详细可以看我的blog解决过程,主要是更改localsearch.swigsearch.xml

@wcmiracle
Copy link

wcmiracle commented Sep 28, 2017

点击搜索后一直转圈的解决方案

1.更新next到最新版本

2.安装 hexo-generator-searchdb

3.在主题配置文件中,第二行改为true即可。

local_search:
  enable: true
  # if auto, trigger search by changing input
  # if manual, trigger search by pressing enter key or search button
  trigger: auto
  # show top n results per article, show all results by setting to -1
  top_n_per_article: 1

@mtrucc
Copy link

mtrucc commented Dec 2, 2017

发现了一些BUG,但不知道怎么修复。
如图所示,搜索的时候,代码部分前面会多一串数字“1234567...................”

这是我的博客页面

xml文件如下

这些数字好像是代码的行数,第一行第二行第三行。
不知道是主题的bug呢还是插件的bug。。

@flashlab
Copy link
Contributor Author

flashlab commented Dec 3, 2017

@mtrucc 不是bug 为了精简索引的体积同时也避免代码中某些字符会引起解析错误

@mtrucc
Copy link

mtrucc commented Dec 4, 2017

@flashlab 好的,谢谢你的回复,我也觉得不太像bug,但别扭肯定是有的。如果主题作者或者插件作者能稍微针对这个优化一下就好了。
这个可能需要主题作者和插件作者一起来弄了。因为插件是通用的,别的主题也能用这个插件。单方面修改可能会引起不必要的麻烦。

@sundongxu
Copy link

@flashlab 你好,我按照 NexT 官方文档 http://theme-next.iissnan.com/third-party-services.html#local-search,分别配置好了 站点配置文件和主题配置文件,之前还能够正常搜索,但是点击搜索按钮后会不停转菊花...就是在加载中的图案,然后一直无法正常弹窗,不知道之前有没有出现过类似的情况,这样应该怎么才能恢复正常呢?麻烦回答一下,谢谢~

@sundongxu
Copy link

@flashlab @iissnan 本地测试都不行...
2018-03-06 10 47 46

@ivan-nginx
Copy link
Collaborator

NexT is rebased into organization repo.
If you want new feature, fix, or support, create new in NexT v6.x repo (desirable in English).

There is instructions on English or Chinese how to update from v5.1.x to v 6.0.x

You also may read this for details.

@ivan-nginx ivan-nginx added the v6.x label Mar 6, 2018
Repository owner locked and limited conversation to collaborators Mar 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.