jamwise / ghosthunter Goto Github PK
View Code? Open in Web Editor NEWA Ghost blog search engine
License: MIT License
A Ghost blog search engine
License: MIT License
"The result template has access to these variables: title, description, link, pubDate."
Is possibile somehow to acess "tags" too?
My main problem is another, i would like to show "all results" when search-field is empty.
I mean,
after I search for something I would like that by deleting progressively the value in the input, I show all the posts, is it possible?
Looking at many ghost installations, their search only runs through the blog titles. While based on the screenshot it would appear that this does indeed also search post content, I wanted to make sure before I dived in to installing this.
Sorry if this is written clearly somewhere, scanning through the content I saw no mention of what exactly is indexed
Please add this plugin (package) in the Bower. This will help save time during development.
Hello,
I updated ghostHunted on a theme that I own and I get strange results with a fresh install. When we install a fresh ghost it comes with some posts.
If I search for 'Administrators' I get the page 'http://localhost:2368/managing-users/' that has the word 'Administrators' in the content.
If I search 'Editors can do' I get the page 'http://localhost:2368/the-editor/' that doesn't have this sentence in it. It does have 'editor' in title. I should've got the same page as for 'Administrators': 'http://localhost:2368/managing-users/'
What exactly does the new version parse. Is it the titles or the content? And how does the parsing works?
Thanks.
Hi, I opened this topic for two reasons.
Ghosthunter seems to work properly.
But i would like to do something like this:
https://myblog.com/?search=value
Then display all the results linked to that value.
I tried to search on the web but it is not entirely clear how to do it.
It is possibile to do?
Regarding the "tag", I noticed that in js we have:
this.field ('title');
this.field ('description');
this.field ('plaintext');
this.field ('pubDate');
this.field ('tag');
........
{{title}}, {{description}} and others work properly.
I wish I could render the tags this way, {{tag}}, but it does not work.
How can I do?
Thanks in advance.
怎么获取更多数据?比如image、content等等
How to get more data? Such as image, content and more?
我想在搜索结果中展示文章焦点图
I want to show the focus image of the article in the search results
Hello, I own a site called IAskMuslim.com, and we have been having problems with your search system. The first problem is that when someone searches something on the site itself many of the public discussions never show up. Any idea how I can make so for example if someone types "Muslim" it would show all of the posts with the word Muslim in it? Another thing, I was going to ask you guys is do you have any plans on advancing the Search System itself.
To work something like this.
https://vanillaforums.org/search
Thanks for this solution. Was very straight forward to integrate.
We've implement it on our blog however it only seems to be searching recent posts (~15). Assuming this is because looking at the RSS feed it only loads so many posts.
Is there any way to have it search all our posts?
ghostHunter currently updates the list of search hits by clearing and restoring the list. Since many Ghost styles do quite a bit of display formatting, there is pretty severe jitter effect when onKeyUp
is enabled. It should be possible to update the list using a Levenstein-distance tool, applying just the changes necessary in the current (last-search-result) display to make it reflect the incoming data array. I'll see if I can get this working, and if it works out, post a pull request after #42 has cleared.
var searchField = $("#search-field").ghostHunter({
results : "#results",
onKeyUp : true,
onPageLoad : true,
result_template : "<a href='{{link}}'><h2>{{title}}</h2><h4>{{pubDate}}</h4> <p>{{description}}</p></a>"
});
I added that and all I get is the link title and date , no description?
and I had a look in the ghost api docs https://api.ghost.org/docs/post
but all I see for the post json object is
post: {
id: 1,
uuid: "ec630e45-3342-4d7f-a24c-e448263c975b",
title: "Welcome to Ghost",
slug: "welcome-to-ghost",
markdown: "You're live! Nice.",
html: "<p>You're live! Nice.</p>",
image: '/content/images/2014/12/my-image.png',
featured: false,
page: false,
status: 'published',
language: "en_US",
meta_title: null,
meta_description: null,
author_id: 1,
created_at: "2014-04-15T12:36:28.353Z",
created_by: 1,
updated_at: "2014-04-15T12:36:28.353Z",
updated_by: 1,
published_at: "2014-04-15T12:36:28.363Z",
published_by: 1
}
going to have a play around and change description to html but if it's something i'm doing wrong some help would be great
I receive a query parameter and want to get results from this value, how can I access the Plugin API?
Is it possible to include the matching part of the blog post in the result?
Hey, thanks for this really nice addon, it works really good for me.
One thing though that I would love to have is the ability to search by date, e.g. with a search query like 2018-05
which then finds all posts that were created in May 2018. Is something like this doable with your current application?
Does ghostHunter support other languages then english cause when I write post with an Hebrew title and search for the excat title - I get no results
Any Idea? is it something in the configurations ?
One question related to RSS: is it possible to use the full RSS feed instead of only the first page for the searchable content? /rss/ displays only a part of the published blog post, you can see the rest with /rss/2, /rss/3, ...
Hi, I have tried v0.3.5, 0.4.1, and 0.5.0 and noticed strange behaviors since version 0.4.1:
Syntax used:
$(function() {
/* search results */
var res = {}
res.body = '\n <a href="{{link}}">\n <span>{{title}}</span>\n <span">{{pubDate}}</span>\n </a>';
res.info = '<p>Found {{amount}} stories</p>';
$("#search-field").ghostHunter({
results: "#results",
onKeyUp: true,
result_template: res.body,
info_template: res.info,
displaySearchInfo: true,
zeroResultsInfo: false,
includepages: false,
onPageLoad: true
});
});
Jquery version: 3.3.1 latest
Is this a bug or am I doing anything wrong?
Hello and thank you for your work!
I've installed ghostHunter on my fresh ghost blog, but soon I noticed, that only english matches show up in onKeyUp frame.
Hi, I'm using ghost in a maybe-unusual way, with multiple substantially-distinct sets of stories in a single ghost instance.
Different sets of stories coexist and display in different areas of the site, with tags controlling what shows where.
In my case I happen to be implementing a multi-language site (under a single ghost instance), but I could imagine other use-cases for this type of tag-based partitioning.
So, what I'm wondering is what it would take to support "filtered indexing" in ghosthunter, whereby I would pass in, at initialization time, the tag filters that I want passed into the ghost API.
In my case I would only ever want one search on any one page of the site, so I don't need to worry about encapsulating configuration/initialization properties that are currently "global" in the ghosthunter plugin object.
As far as I could tell this should be very straightforward, with only two important changes to be made:
Add support for passing the filter in, and having it be passed through to the ghost API call in indexing
Ensure that the localstorage key (at index setting and retrieval time) is updated to include the filter key (or some other explicitly passed in identifier).
Is there anything else I'm clearly missing in this proposed scheme?
Date is presented in a raw format (pubDate
variable). I'd like a more pleasant one, ideally matching the way my theme outputs the date (and the installed locale).
I guess it is easy to accomplish for javascript programmers... but I'm not!
I recently installed a Ghost instance with a theme that supports ghostHunter search. Looking at transactions against the site, I found that it was reindexing all items for each page visited. To save network traffic and speed things up, I hacked the ghostHunter code in the theme to cache search results in localStorage
.
In the hacked code, caching works as follows:
updated_at
as returned by the Ghost APIisInit
is falsey, we hit localStorage
for the three values.
isInit
to true
isInit
is now true
, we hit the Ghost API for only the id
values of updates later than latestPost
isInit
is still falsey, we also hit the Ghost API for all post data and regenerate the indexIf no items have changed since the browser's last visit to the site, index data is reused. The only overhead is to reload the index out of localStorage
.
The code seems to be working well for us. It's been done against a dated release of ghostHunter, but if the approach sounds interesting, I could work up a pull request against current ghostHunter master.
Hi, locally it is working properly, I do not find any problem, I update the theme on the production site, and I get the following errors:
GET https://example.it/assets/js/jquery.ghosthunter.js/?v=f2e5f77e91 net::ERR_ABORTED
search.js?v=f2e5f77e91:1 Uncaught TypeError: $(...).ghostHunter is not a function
at search.js?v=f2e5f77e91:1
script loaded
1 - jquery
2 - ghosthunter
3 - search.js -->$("#search-field").ghostHunter({});
Do you know the reason?
Setting result_template doesn't seem to be working.
Using
$("#search-field").ghostHunter({
results : "#results",
onKeyUp : true,
zeroResultsInfo : false,
//result_template : "<a href='{{link}}'><p><h2>{{title}}</h2><h4>{{pubDate}}</h4></p></a>"
});
will correctly yield the results' info and the results themselves.
However, uncommenting the commented line, which should simply set the template to its default value, will only show the results' info. If we look at the HTML source code, it appears that the correct structure has been created, but it has not been filled with content.
My best guess is that Ghost is consuming the variables before GhostHunter can get to them and replacing them with nothing.
Could be nice offer a version without dependencies inside, like:
ghostHunter.standalone.min.js → wihtout lunr
ghostHunter.standalone.min.js → with lunr
Hi there,
I am getting the following error when trying to clear search results and search field value with searchField.clear(); :
Uncaught TypeError: Cannot read property 'val' of undefined
at Object.clear (jquery.ghosthunter.js?v=79caedeb82:3532)
at HTMLButtonElement. (custom.js?v=79caedeb82:87)
at HTMLButtonElement.dispatch (jquery-3.3.1.min.js:2)
at HTMLButtonElement.y.handle (jquery-3.3.1.min.js:2)
Could you please help? Thank you.
Hi! I use the Techno theme on my Ghost blog and the full-text search is blocking UI on page load (the initSearch() function in the default.js file). If I disable initSearch(), everything goes fine (except for the search function obviously ^^). I have a css animation on the homepage and it only runs after a delay, more than 10 seconds on my android phone.
On my blog I have only one article but he is very long (14200 words).
Here is my website : http://www.protection-cultures-histoire.fr/
Here is the repo of the website : https://github.com/Janaka-Steph/protection-cultures-histoire.fr
Thank you for your help.
Renaming prettyPubDate to pubDate should work.
Please :)
I am trying to host my ghost blog on both www.example.com and example.com. I set the site url of the blog to be example.com. If I try searching on example.com everything works as expected. If however, I try searching on www.example.com I get errors and search results are not returned. I'm guessing this has to do with CORS? Is there CORS somewhere in this code or is this a LocalStorage issue? Seems like you can't call the API methods from anything but the exact site url that you specify. Here is the error I get when trying to search:
https://example.com/blog/ghost/api/v0.1/posts/?limit=all&include=tags&formats=plaintext*client_id=ghost-frontend&client_secret=abcdef123
Failed to load resource: Origin https://www.example.com is not allowed by Access-Control-Allow-Origin.
I tried to customize the html template this way, because all I wanted to see in the results was the title.
<script>
$("#search-field").ghostHunter({
results : "#results",
onKeyUp : true,
result_template : "<a href='{{link}}'><p><h2>{{title}}</h2></p></a>"
});
</script>
When I do search for posts get back the message: "Number of posts found:" + the actual number of posts. With the inspector i could see that he is creating the hrefs with the p and the h2 but the {{link}} abd the {{title}} will not appear.
<section id="results" style="text-align:center">
<p>Number of posts found: 3</p>
<a href=""><p></p><h2></h2><p></p></a>
<a href=""><p></p><h2></h2><p></p></a>
<a href=""><p></p><h2></h2><p></p></a>
</section>
I tried around for a while but couldn't get it to work. Without my customization everything works fine.
Hi,
Thanks for this plugin. I have added to my theme but getting some issue. Every time I search it return Number of posts found: 0
here is a link to my blog
http://ghost.xvelopers.com/voltov/
right now, I have search page with default value in search box. I want to trigger the event using .keyup(), but it doesn't seem to work. Only show "Number of posts found: 0". Any idea?
In ghosthunter.js
,
clear : function(){
$(this.results).empty();
this.target.val("");
},
this.target
is undefined.
Tried to fix it by adding this.target = target
after line:176 of ghosthunter.js
but got a slightly different compiled version in dist
folder than the one cloned.
I've always used a very old version of ghosthunter, about 185 lines of code, I've never had any kind of problem. I tried to update, the latest version is about 3500 lines of code, unfortunately I must say that it works very badly. I do not understand why. It does not sort the articles according to the search key, often in the search result there are articles completely unrelated to the searched word, or simply not find them all. I'm forced to go back to the previous version, old for several months, or years, fortunately I had saved it :)
I wanted to warn you of this problem, I'm probably wrong?
I've been trying to change the result_template to remove the date from results each time I add the code to my site the search box is disabled.
<script> $("#search-field").ghostHunter({ results : "#results", onKeyUp : true, info_template : "
Number of posts found: {{amount}}
", result_template : "{{title}} {{description}}
"});</script></p>
"Number of posts:" is shown but no results appear.
Build the index in the server side is a handicap, but could be also great use web worker for this task in the frontend side.
Apparently it cannot search static page. Is this a known issue? Thanks!
I'm showing results in a custom result using {{title}} and {{description}}, is it possible to show tags in this way? {{tag}}, at the moment I think it is not possiible, could it be an upcoming implementation?
Hello all
I can not limit the number of search results and create a link that makes a redirect and show all the results.
For example, the search engine at: https://docs.ghost.org/docs
Is there any parameter to set?
Instead of build index all the time, we can use browser storage (localStorage, SessionStorage, webSQL or IndexDB) as temporal cache
Hi Jamal and everyone,
This search engine is marvelous! I'm wondering if it is possible to exclude certain tags from the search results? If yes, how to implement it?
Can it support the search for more languages? For example: Japanese, Korean Chinese.
Hello,
I've added it inside body in default.hbs:
<form>
<input id="search-field" />
<input type="submit" value="search">
<input type="button" value="clear" onclick="clearResults();" />
</form>
<hr />
<section id="results"></section>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="js/jquery.ghostHunter.js"></script>
<script>
var searchField = $("#search-field").ghostHunter({
results : "#results",
rss : "rss.xml",
//Enable the "search as you type" by uncommenting the following line
//onKeyUp : true
});
function clearResults() {
searchField.clear();
}
</script>
But i'm getting the following error:
Uncaught ReferenceError: ghost is not defined
at Object.loadAPI (jquery.ghostHunter.js:110)
at HTMLInputElement.<anonymous> (jquery.ghostHunter.js:76)
at HTMLInputElement.dispatch (jquery.min.js:5)
at HTMLInputElement.v.handle (jquery.min.js:5)
How to fix it?
Thank you
Hello, could someone update my Search function to support the latest ghosthunter? The goal of updating my search function is so users can be able to type anything in the Search bar and not be limited to only 15 responses. Plus, It would be great if when someone does update my Search function they edit any other files that could improve the search experience for users.
PS:
Sorry, If I made you mad @Windyo <3. I can be a little inpatient time to time but it would mean a lot if you took the time out of your day to help me with this problem. Lastly, I tried doing this myself but I could not get it to work and I contact the dev of the theme but he will not update he said. And is it necessary for me to turn on Public API?
#11
Hi, I'm having a similar issue to issue 11 - the search function worked previously when it was on v0.4.0 when I first added it but now it doesn't return any results. I'm getting ghostHunter: init - so it seems to be partially working, also there are no JS errors in the console.
Any help would be appreciated please!
Apologies if this isn't the appropriate spot to post this, but I'm having some trouble getting it working. After following all the usage instructions, I get the following javascript error when I focus on the search box:
Uncaught ReferenceError: ghost is not defined
at Object.loadAPI (jquery.ghostHunter.min.js?v=23405fddcb:1)
at HTMLInputElement.<anonymous> (jquery.ghostHunter.min.js?v=23405fddcb:1)
at HTMLInputElement.dispatch (jquery-latest.min.js:3)
at HTMLInputElement.r.handle (jquery-latest.min.js:3)
Any thoughts why this is? I'm using up-to-date chrome on Windows 10. Thanks in advance for your help.
Hello,
It looks like lunr v0.7.0 doesn't search correctly. For example I'm using Ghost v1.0.0 and I have multiple posts. 2 of them have the same name Welcome to Ghost. I implmented GhostHunter and it works like this:
I search for: w -> Both posts appear
I search for: we -> They don't appear
I search for: wel -> Both posts appear
...
I search for: welcome t -> Only one appears
The blogData seems to be ok but lunr does a bad parsing or something.
Hi there,
thanks you for this plugin.
I have updated it to version 0.5.0 in my theme but when trying to search I'm getting the following error:
Uncaught TypeError: results.size is not a function at Object. (jquery.ghosthunter.js?v=79caedeb82:3478)
HTML:
<form class="search-form">
<input type="text" id="search-field" class="search-field" placeholder="Type your keywords…" />
<input type="submit" class="search-submit" value="Search" />
</form>
<div id="search-results" class="search-results"></div>
jQuery code:
var searchField = $('#search-field').ghostHunter({
results : "#search-results",
onKeyUp : true
});
Can you help to fix it?
Thank you.
Hi, I've noticed if you have more than one tag per post the code merges them all into one string like so.
"My tag","test" = "My tagTest"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.