Highlight search terms

Request new functionality here
feader
Bear Rating Master
Bear Rating Master
Posts: 160
Joined: 26 Dec 2012, 20:03

Highlight search terms

Postby feader » 25 Jul 2013, 22:27

Recently, I used the search function of Tiny Tiny RSS. Worked fine, only I thought it would be nice if the search terms were highlighted in the feed content, like they are when one queries the Google Cache.

imsinfo
Bear Rating Trainee
Bear Rating Trainee
Posts: 17
Joined: 07 May 2013, 20:00

Re: Highlight search terms

Postby imsinfo » 26 Jul 2013, 01:47

I wrote a similar post View Topic. I did not get any responses. Since then my company paid a freelancer to achieve this and the results of the plugin were not consistent. It was implemented poorly using a bad hook and is only compatible with MySQL. The other issue is it times out a lot making it unreliable and will prevent feeds from displaying when this happens.

My company is willing to share this coding with the community for improvement and personal use but the coding needs to be fixed or completely re-developed. I am sure this code could be used for the search and filters. Since I am not a programmer I don't want to put it on the forums for everyone else until it is a fully functional plugin, especially since I cannot provide support for it. If this is something you would be interested in PM me and I can get the code your way. If anyone would be interested in coding / fixing this plugin my company would be willing to pay (if reasonable) for your time.

Filtering is an extremely powerful tool for our company and having the highlighting would make it a lot easier for us to refine our filters while determining the focal point of the articles being flagged.Tiny RSS has been an extreme help in our project research we do surpassing all of the other readers we have tried in the past (Thanks Fox!).

gbcox
Bear Rating Master
Bear Rating Master
Posts: 149
Joined: 25 Apr 2013, 04:52

Re: Highlight search terms

Postby gbcox » 26 Jul 2013, 04:46

Not sure what your freelancer did but I did a quick google search and found where this could be accomplished via the sphinx buildexcerpts function. I'll dig in a little deeper...
http://sphinxsearch.com/docs/2.0.8/api- ... erpts.html

imsinfo
Bear Rating Trainee
Bear Rating Trainee
Posts: 17
Joined: 07 May 2013, 20:00

Re: Highlight search terms

Postby imsinfo » 26 Jul 2013, 23:21

The issue with the freelancer was he "made it work", not "made it work right"so to say. Poor implementation overall. Looking at the link seems to show a viable method, but I am unsure how this gets implemented correctly. Thanks for looking into this, any other help / point in the right direction is greatly appreciated.

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: Highlight search terms

Postby fox » 31 Jul 2013, 14:56

https://github.com/gothfox/Tiny-Tiny-RS ... 568db5ea4e

Only works for article content (search also matches title, author, etc) and combined mode.

Image

feader
Bear Rating Master
Bear Rating Master
Posts: 160
Joined: 26 Dec 2012, 20:03

Re: Highlight search terms

Postby feader » 31 Jul 2013, 22:52

Looks good, but it seems that this guy is right; because the XPath function contains in the query

Code: Select all

$elements = $xpath->query('//*[contains(.,"'.$word.'")]');

is case sensitive, the highlighting in the article content is so (Yes, I actually tested this before posting here). A complete solution probably would have to test every possible capitalization of $word, but IMO the three additional tests

Code: Select all

strtolower($word), strtoupper($word), ucfirst(strtolower($word))

would suffice.

Thank you! :)

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: Highlight search terms

Postby fox » 01 Aug 2013, 08:57

Yes, xpath contains() is case sensitive, I figured it was still worth using this approach for performance reasons (going through every domtext is quite slow).

I'll try to add this hack you proposed later (it would be great if you sent a pull request tho). :)


Return to “Feature requests”

Who is online

Users browsing this forum: Bing [Bot] and 6 guests