new feature: local search #694

Merged
merged 3 commits into from Mar 2, 2016

Conversation

Projects
None yet
@flashlab
Contributor

flashlab commented Mar 1, 2016

localsearch

!dea and core codes are from Joseph Pan.

see Wiki.

@flashlab flashlab changed the title from Mypr to new feature: local search Mar 1, 2016

@flashlab

This comment has been minimized.

Show comment
Hide comment
@flashlab

flashlab Mar 1, 2016

Contributor

@iissnan wiki page done; compatibility pass 😄

Contributor

flashlab commented Mar 1, 2016

@iissnan wiki page done; compatibility pass 😄

iissnan added a commit that referenced this pull request Mar 2, 2016

Merge pull request #694 from flashlab/mypr
new feature: local search

@iissnan iissnan merged commit 373b080 into iissnan:master Mar 2, 2016

1 check passed

hound No violations found. Woof!
@iissnan

This comment has been minimized.

Show comment
Hide comment
@iissnan

iissnan Mar 2, 2016

Owner

Cool. 👍

Owner

iissnan commented Mar 2, 2016

Cool. 👍

@iissnan iissnan added the Enhancement label Mar 2, 2016

@iissnan iissnan added Docs and removed Docs labels May 6, 2016

@iissnan

This comment has been minimized.

Show comment
Hide comment
@iissnan

iissnan Jun 13, 2016

Owner

在站点配置文件里

Owner

iissnan commented Jun 13, 2016

在站点配置文件里

@timeng

This comment has been minimized.

Show comment
Hide comment
@timeng

timeng Jun 17, 2016

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

timeng commented Jun 17, 2016

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

@flashlab

This comment has been minimized.

Show comment
Hide comment
@flashlab

flashlab Jun 18, 2016

Contributor

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

Contributor

flashlab commented Jun 18, 2016

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

@flashlab

This comment has been minimized.

Show comment
Hide comment
@flashlab

flashlab Jun 22, 2016

Contributor

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

Contributor

flashlab commented Jun 22, 2016

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

@flashlab

This comment has been minimized.

Show comment
Hide comment
@flashlab

flashlab Jun 24, 2016

Contributor

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

Contributor

flashlab commented Jun 24, 2016

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

@haiwx

This comment has been minimized.

Show comment
Hide comment
@haiwx

haiwx Jun 25, 2016

@dog-2

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

haiwx commented Jun 25, 2016

@dog-2

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

@effie999

This comment has been minimized.

Show comment
Hide comment
@effie999

effie999 Jun 26, 2016

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

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

@hustlibraco

This comment has been minimized.

Show comment
Hide comment
@hustlibraco

hustlibraco Jun 28, 2016

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

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

@flashlab

This comment has been minimized.

Show comment
Hide comment
@flashlab

flashlab Jun 29, 2016

Contributor

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

Contributor

flashlab commented Jun 29, 2016

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

@danboice

This comment has been minimized.

Show comment
Hide comment
@danboice

danboice Jul 4, 2016

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.

danboice commented Jul 4, 2016

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

This comment has been minimized.

Show comment
Hide comment
@flashlab

flashlab Jul 4, 2016

Contributor

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 ;)

Contributor

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 ;)

@danboice

This comment has been minimized.

Show comment
Hide comment
@danboice

danboice Jul 4, 2016

@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.

danboice commented Jul 4, 2016

@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.

@danboice

This comment has been minimized.

Show comment
Hide comment
@danboice

danboice 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.

danboice 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

This comment has been minimized.

Show comment
Hide comment
@flashlab

flashlab Jul 4, 2016

Contributor

@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.

Contributor

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.

@danboice

This comment has been minimized.

Show comment
Hide comment
@danboice

danboice Jul 4, 2016

okay. thanks. that fixed it.

danboice commented Jul 4, 2016

okay. thanks. that fixed it.

@xuecat

This comment has been minimized.

Show comment
Hide comment
@xuecat

xuecat Aug 30, 2016

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

xuecat commented Aug 30, 2016

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

@FE-Mars

This comment has been minimized.

Show comment
Hide comment
@FE-Mars

FE-Mars Sep 2, 2016

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

FE-Mars commented Sep 2, 2016

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

@flashlab

This comment has been minimized.

Show comment
Hide comment
@flashlab

flashlab Sep 2, 2016

Contributor

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

Contributor

flashlab commented Sep 2, 2016

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

@flashlab

This comment has been minimized.

Show comment
Hide comment
@flashlab

flashlab Sep 2, 2016

Contributor

@jwang141 能给个例子吗?

Contributor

flashlab commented Sep 2, 2016

@jwang141 能给个例子吗?

@wang9262

This comment has been minimized.

Show comment
Hide comment
@wang9262

wang9262 Sep 16, 2016

@flashlab 遇到了和 @jwang141 一样的问题,具体例子可以查看 我的博客
具体表现形式为:假设我的博客地址为 abc.com,然后搜索点击查询的结果,结果跳转至了 abc.com/abc.com/articletitle 本应该跳转到 abc.com/articletitle

不是很懂前端,但看了下代码,感觉像是 localsearch.swig 第74行的问题?

str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";

仅仅为个人的猜测,不知道是不是受到我站点的 root 的影响。我站点的配置如下:

url: vongloo.me
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:

search:
  path: search.xml
  field: post

如果有时间的话,帮忙看看具体是啥问题,感谢!❤️

@flashlab 遇到了和 @jwang141 一样的问题,具体例子可以查看 我的博客
具体表现形式为:假设我的博客地址为 abc.com,然后搜索点击查询的结果,结果跳转至了 abc.com/abc.com/articletitle 本应该跳转到 abc.com/articletitle

不是很懂前端,但看了下代码,感觉像是 localsearch.swig 第74行的问题?

str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";

仅仅为个人的猜测,不知道是不是受到我站点的 root 的影响。我站点的配置如下:

url: vongloo.me
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:

search:
  path: search.xml
  field: post

如果有时间的话,帮忙看看具体是啥问题,感谢!❤️

@flashlab

This comment has been minimized.

Show comment
Hide comment
@flashlab

flashlab Sep 19, 2016

Contributor

@wang9262 配置重的url最好加上http://。herf前缀什么也没有会被当成相对路径,具体为什么插件没有生成完整的地址我没有仔细看。

Contributor

flashlab commented Sep 19, 2016

@wang9262 配置重的url最好加上http://。herf前缀什么也没有会被当成相对路径,具体为什么插件没有生成完整的地址我没有仔细看。

@wang9262

This comment has been minimized.

Show comment
Hide comment
@wang9262

wang9262 Sep 19, 2016

所以还有救吗?

所以还有救吗?

@clatisus

This comment has been minimized.

Show comment
Hide comment
@clatisus

clatisus Sep 19, 2016

@wang9262 你把url: vongloo.me改成url: http://vongloo.me试试

@wang9262 你把url: vongloo.me改成url: http://vongloo.me试试

@wang9262

This comment has been minimized.

Show comment
Hide comment
@wang9262

wang9262 Sep 20, 2016

@flashlab @clatisus 加上 http:// 可以了,谢谢!

@flashlab @clatisus 加上 http:// 可以了,谢谢!

@silverlining21

This comment has been minimized.

Show comment
Hide comment
@silverlining21

silverlining21 Nov 25, 2016

你好 为什么用Next添加参照【Wiki】安装这个插件的时候,在生成的博客界面上搜索,无法输出搜索内容。
我的博客地址

1

你好 为什么用Next添加参照【Wiki】安装这个插件的时候,在生成的博客界面上搜索,无法输出搜索内容。
我的博客地址

1

@xuecat

This comment has been minimized.

Show comment
Hide comment
@xuecat

xuecat Nov 25, 2016

@silverlining21 我照作者教程来,是对的哟:http://theme-next.iissnan.com/third-party-services.html

第一次弹出窗口一般都比较慢,你等等?

xuecat commented Nov 25, 2016

@silverlining21 我照作者教程来,是对的哟:http://theme-next.iissnan.com/third-party-services.html

第一次弹出窗口一般都比较慢,你等等?

@silverlining21

This comment has been minimized.

Show comment
Hide comment
@silverlining21

silverlining21 Nov 25, 2016

@xcatliu 我开始也是参照了那个的 可是结果是一样的. 而且好像每次打开search框都要双击而不是单击就跳出...

除了下面这两项配置还有其他的地方需要修改吗?

1

@xcatliu 我开始也是参照了那个的 可是结果是一样的. 而且好像每次打开search框都要双击而不是单击就跳出...

除了下面这两项配置还有其他的地方需要修改吗?

1

@xcatliu

This comment has been minimized.

Show comment
Hide comment
@xcatliu

xcatliu Nov 25, 2016

Contributor

@silverlining21 我怕你没有 @ 到正确的人,导致他没有看到你的回复,所以第一时间提醒了你。
我简单看了下,并不知道是哪儿出问题了。。。抱歉

Contributor

xcatliu commented Nov 25, 2016

@silverlining21 我怕你没有 @ 到正确的人,导致他没有看到你的回复,所以第一时间提醒了你。
我简单看了下,并不知道是哪儿出问题了。。。抱歉

@xuecat

This comment has been minimized.

Show comment
Hide comment
@xuecat

xuecat Nov 25, 2016

@silverlining21 这是我的博客: https://xuecat.github.io/,我表示真的可以。我勉强给点建议,希望能帮助你。
1、hexo-generator-searchdb没安装成功,或许需要其他库(大部分需要的库名你在百度的教程和官方找的到);再不行你就重新安装下它看看。
2、本地尝试能搜索后再上传。(好像这会产生些文件似的)
3、主题文件配置。这个我晚点把我的配置发给你,你对比下搜索的位置

xuecat commented Nov 25, 2016

@silverlining21 这是我的博客: https://xuecat.github.io/,我表示真的可以。我勉强给点建议,希望能帮助你。
1、hexo-generator-searchdb没安装成功,或许需要其他库(大部分需要的库名你在百度的教程和官方找的到);再不行你就重新安装下它看看。
2、本地尝试能搜索后再上传。(好像这会产生些文件似的)
3、主题文件配置。这个我晚点把我的配置发给你,你对比下搜索的位置

@jiangxiaoqiang

This comment has been minimized.

Show comment
Hide comment
@jiangxiaoqiang

jiangxiaoqiang Dec 6, 2016

按照配置步骤配置后,我的博客搜索无法使用,显示链接是javascript:;,博客地址:http://jiangxiaoqiang.com.

按照配置步骤配置后,我的博客搜索无法使用,显示链接是javascript:;,博客地址:http://jiangxiaoqiang.com.

@flashlab

This comment has been minimized.

Show comment
Hide comment
@flashlab

flashlab Dec 7, 2016

Contributor

@jiangxiaoqiang 没有发现什么问题,你debug下popup-trigger的click事件有没有被触发。也有可能是配置里search.xml的路径不对

Contributor

flashlab commented Dec 7, 2016

@jiangxiaoqiang 没有发现什么问题,你debug下popup-trigger的click事件有没有被触发。也有可能是配置里search.xml的路径不对

@jiangxiaoqiang

This comment has been minimized.

Show comment
Hide comment
@jiangxiaoqiang

jiangxiaoqiang Dec 7, 2016

@flashlab 问题已经解决,是由于post文件夹下一个markdown文件里面有一个非UTF-8字符导致的,去掉那个特殊字符即可

@flashlab 问题已经解决,是由于post文件夹下一个markdown文件里面有一个非UTF-8字符导致的,去掉那个特殊字符即可

@ipreacher

This comment has been minimized.

Show comment
Hide comment
@ipreacher

ipreacher Dec 8, 2016

我出现了搜索出来的链接网址错误这个问题 #1298
望大神指点啊,,@flashlab

ipreacher commented Dec 8, 2016

我出现了搜索出来的链接网址错误这个问题 #1298
望大神指点啊,,@flashlab

@ipreacher

This comment has been minimized.

Show comment
Hide comment
@ipreacher

ipreacher Dec 8, 2016

@xuecat 求一份配置,我也不能搜索

@xuecat 求一份配置,我也不能搜索

@geekzw

This comment has been minimized.

Show comment
Hide comment
@geekzw

geekzw Dec 9, 2016

我就是按照配置来的,先npm install hexo-generator-searchdb,然后
search:
path: search.xml
field: post
format: html
limit: 10000
主页中有搜索项,但是点不动,谁遇到这种情况了,怎么解决的

geekzw commented Dec 9, 2016

我就是按照配置来的,先npm install hexo-generator-searchdb,然后
search:
path: search.xml
field: post
format: html
limit: 10000
主页中有搜索项,但是点不动,谁遇到这种情况了,怎么解决的

@flashlab

This comment has been minimized.

Show comment
Hide comment
@flashlab

flashlab Dec 9, 2016

Contributor

@geekzw 你需要 npm install hexo-generator-searchdb --save

Contributor

flashlab commented Dec 9, 2016

@geekzw 你需要 npm install hexo-generator-searchdb --save

@ilofter

This comment has been minimized.

Show comment
Hide comment
@ilofter

ilofter Dec 25, 2016

http://blog.iloft.xyz/ 下可以搜索,并访问http://blog.iloft.xyz/search.xml
https://blog.iloft.xyz/ 并不可以搜索,且不能访问https://blog.iloft.xyz/search.xml 显示404,请问是什么原因

ilofter commented Dec 25, 2016

http://blog.iloft.xyz/ 下可以搜索,并访问http://blog.iloft.xyz/search.xml
https://blog.iloft.xyz/ 并不可以搜索,且不能访问https://blog.iloft.xyz/search.xml 显示404,请问是什么原因

@flashlab

This comment has been minimized.

Show comment
Hide comment
@flashlab

flashlab Dec 25, 2016

Contributor

@ilofter 我这里是可以访问的

Contributor

flashlab commented Dec 25, 2016

@ilofter 我这里是可以访问的

@CalvinNeo

This comment has been minimized.

Show comment
Hide comment
@CalvinNeo

CalvinNeo Jan 17, 2017

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

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

@tonyfloatersu

This comment has been minimized.

Show comment
Hide comment
@tonyfloatersu

tonyfloatersu Jan 17, 2017

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

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

@flashlab

This comment has been minimized.

Show comment
Hide comment
@flashlab

flashlab Jan 18, 2017

Contributor

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

Contributor

flashlab commented Jan 18, 2017

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

@tonyfloatersu

This comment has been minimized.

Show comment
Hide comment
@tonyfloatersu

tonyfloatersu Jan 18, 2017

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

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

@tonyfloatersu

This comment has been minimized.

Show comment
Hide comment
@tonyfloatersu

tonyfloatersu Jan 18, 2017

OK,问题解决了,感谢 👍

OK,问题解决了,感谢 👍

@CalvinNeo

This comment has been minimized.

Show comment
Hide comment
@CalvinNeo

CalvinNeo Jan 18, 2017

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

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

@marsggbo

This comment has been minimized.

Show comment
Hide comment
@marsggbo

marsggbo Jan 19, 2017

我用的是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”,所以每次跳转就会失败,这个怎么解决?

我用的是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

This comment has been minimized.

Show comment
Hide comment
@amoyiki

amoyiki Jan 19, 2017

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

amoyiki commented Jan 19, 2017

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

@jiangxiaoqiang

This comment has been minimized.

Show comment
Hide comment
@jiangxiaoqiang

jiangxiaoqiang Jan 23, 2017

@marsggbo

This comment has been minimized.

Show comment
Hide comment
@marsggbo

marsggbo Jan 23, 2017

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

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

@marsggbo

This comment has been minimized.

Show comment
Hide comment
@marsggbo

marsggbo Jan 23, 2017

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

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

@flashlab

This comment has been minimized.

Show comment
Hide comment
@flashlab

flashlab Jan 24, 2017

Contributor

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

Contributor

flashlab commented Jan 24, 2017

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

@alexpdh

This comment has been minimized.

Show comment
Hide comment
@alexpdh

alexpdh Feb 19, 2017

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

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

Merge pull request #694 from flashlab/mypr
new feature: local search
@sli1989

This comment has been minimized.

Show comment
Hide comment
@sli1989

sli1989 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;
  };
}

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

This comment has been minimized.

Show comment
Hide comment
@ivan-nginx

ivan-nginx Jul 10, 2017

Collaborator

@sli1989 try to install localsearch from @flashlab repository.

Collaborator

ivan-nginx commented Jul 10, 2017

@sli1989 try to install localsearch from @flashlab repository.

@sli1989

This comment has been minimized.

Show comment
Hide comment
@sli1989

sli1989 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.

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

This comment has been minimized.

Show comment
Hide comment
@XuCcc

XuCcc Aug 6, 2017

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

XuCcc commented Aug 6, 2017

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

@chaixuhong

This comment has been minimized.

Show comment
Hide comment
@chaixuhong

chaixuhong Aug 11, 2017

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

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

@lanbos

This comment has been minimized.

Show comment
Hide comment
@lanbos

lanbos Aug 25, 2017

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

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

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

lanbos commented Aug 25, 2017

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

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

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

@wcmiracle

This comment has been minimized.

Show comment
Hide comment
@wcmiracle

wcmiracle 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

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

This comment has been minimized.

Show comment
Hide comment
@mtrucc

mtrucc Dec 2, 2017

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

这是我的博客页面

xml文件如下

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

mtrucc commented Dec 2, 2017

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

这是我的博客页面

xml文件如下

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

@flashlab

This comment has been minimized.

Show comment
Hide comment
@flashlab

flashlab Dec 3, 2017

Contributor

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

Contributor

flashlab commented Dec 3, 2017

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

@mtrucc

This comment has been minimized.

Show comment
Hide comment
@mtrucc

mtrucc Dec 4, 2017

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

mtrucc commented Dec 4, 2017

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

@sundongxu

This comment has been minimized.

Show comment
Hide comment
@sundongxu

sundongxu Mar 6, 2018

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

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

@sundongxu

This comment has been minimized.

Show comment
Hide comment
@sundongxu

sundongxu Mar 6, 2018

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

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

@ivan-nginx

This comment has been minimized.

Show comment
Hide comment
@ivan-nginx

ivan-nginx Mar 6, 2018

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.

Collaborator

ivan-nginx commented Mar 6, 2018

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.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.