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

Tipue search return undefined url #147

Closed
lele1122 opened this Issue Sep 18, 2015 · 26 comments

Comments

Projects
None yet
@lele1122
Copy link

lele1122 commented Sep 18, 2015

when I use search, I can get the results, but all the urls of articles are "undefined", if click the articles, they all go to /undefined
How to solve it?

@lindsayrgwatt

This comment has been minimized.

Copy link

lindsayrgwatt commented Oct 5, 2015

I had this too. Here's how I fixed it (and introduced a new bug).

Issue is that line 217 of tipuesearch.js is the following:
found[c++] = score + '^' + tipuesearch_in.pages[i].title + '^' + s_t + '^' + tipuesearch_in.pages[i].loc;

but the attribute .loc does not exist, hence undefined.

If you change the code to be:
found[c++] = score + '^' + tipuesearch_in.pages[i].title + '^' + s_t + '^' + tipuesearch_in.pages[i].url;

It will work. Note that you also have to update /search.html to point to tipuesearch.js as the default is to load the minified js (or update the minified .js)

When I did this it worked - but it also introduced the error that my search result counts are wrong (I don't care about the count so stopped debugging).

@lele1122 lele1122 closed this Oct 6, 2015

@lele1122 lele1122 reopened this Oct 6, 2015

@tns-yuq

This comment has been minimized.

Copy link

tns-yuq commented Oct 8, 2015

same issue happened to me. I can get the search results successfully, but the link will lead to 'undefined'. Any solutions? @lele1122 I tried your way with version5 tipuesearch.js, but it doesn't work.

@lindsayrgwatt I also tried your way but still not working. I put <script src="{ SITEURL }}/theme/tipuesearch/tipuesearch.js"></script> in /search.html.

@lele1122

This comment has been minimized.

Copy link
Author

lele1122 commented Oct 8, 2015

@lindsayrgwatt I tried your method but failed to get the link.
@tns-yuq The solution I used was that I replaced tipuesearch version 5.0 and it works. To maintain the Elegant search box, you need to replace the tipuesearch.css file with 3.1 version. But it has a problem. When you search result showed nothing found, it does not have the elegant them text

@lindsayrgwatt

This comment has been minimized.

Copy link

lindsayrgwatt commented Oct 8, 2015

@tns-yuq and @lele1122 I've had intermittent issues with it and they all seemed to be related to browser caches having old versions of a javascript file. Once I cleared them all out, it worked fine.

If you still have issues, try adding console.log at the following points in tipuesearch.js and you can watch where it fails:

                         for (var i = 0; i < tipuesearch_in.pages.length; i++)
                         {
                              console.log("Working on article: " + i);

and

                              console.log("score is: " + score);
                              if (score < 1000000000)
                              {
                                   found[c++] = score + '^' + tipuesearch_in.pages[i].title + '^' + s_t + '^' + tipuesearch_in.pages[i].url; //.loc in original;
                                   console.log(tipuesearch_in.pages[i]);
                                   console.log(c);
                                   console.log(found[c-1]); // Was incremented, so decrement to see last item

Basically, tipue search works as follows:

  1. It creates an array called found around line 180
  2. It iterates over all the articles it has indexed starting around line 181
  3. It scores each and you can print the score around line 215 or so
  4. If the score is less than 1,000,000,000 it adds them to found around 217 or so
  5. When it adds them, it actually creates a string that is a concatenation of the data required to render a search result. found[c++] = score + '^' + ... This is the line that had the .loc that needed to be .url

If you add console.log at those points you can see if you get any undefined items. You should not and it should all work.

@silverhook

This comment has been minimized.

Copy link
Member

silverhook commented Oct 31, 2015

Sooooo the current Elegant theme is compatible with which Tipue search now?

@lindsayrgwatt

This comment has been minimized.

Copy link

lindsayrgwatt commented Nov 1, 2015

Honestly, I have no idea. You can hack it together to make it work but I
don't know if it will work out of the box.

On Saturday, 31 October 2015, Matija Šuklje notifications@github.com
wrote:

Sooooo the current Elegant theme is compatible with which Tipue search now?


Reply to this email directly or view it on GitHub
#147 (comment)
.

lindsay watt :: lindsay@lindsayrgwatt.com :: 206.599.9533 :: @lindsayrgwatt

@Moini

This comment has been minimized.

Copy link

Moini commented Nov 5, 2015

Thanks, @lindsayrgwatt - for me your solution did the trick. I don't have a lot of contents yet, so maybe that's the reason why my counts are still accurate.

@jeffmax

This comment has been minimized.

Copy link

jeffmax commented Dec 9, 2015

I used this fork to fix the "undefined" issue:

https://github.com/0x8BADFOOD/pelican-elegant

But the style for the search box changed (as mentioned above with the other solutions) is different. I think this is due to the fact that the latest tipuesearch.css has a css rule for the #tipue_search_input which overrides the navbar-search class from bootstrap-combined.css which previously too precedence.

There is probably a better way to fix this, but if you remove the #tipue_search_input rule from tipuesearch.css it should work. I don't think you can remove the id from the actual html or change it because there seems to be javascript that looks for it.

@endafarrell

This comment has been minimized.

Copy link

endafarrell commented May 11, 2016

Another idea/hack/work-around is to edit the pelican-plugins/tipue_search/tipue_search.py to add (twice) 'loc': page_url to the node = dicts in both def create_tpage_node and def create_json_node.

The resulting URLs are fully-qualified and seem to ignore the pelicanconf.py RELATIVE_URLS setting, but that too can be recognised in the init settings parameter. That's probably not a new thing though.

@chrisalbon

This comment has been minimized.

Copy link

chrisalbon commented May 20, 2016

I used @endafarrell's solution and it works well (except the relative urls, but that is okay in my case)

@scumer

This comment has been minimized.

Copy link

scumer commented Aug 2, 2016

resolve this issue with @endafarrell 's advice
node = {'title': page_title, 'text': page_text, 'tags': page_category, 'url': page_url, 'loc': page_url}

@yoander

This comment has been minimized.

Copy link

yoander commented Oct 14, 2016

I think if you change the 'loc' by 'url' key is enough i did it and works well. Als if you can use it the plugin in static mode (recommend by TIpue Search site) you can add at the end of generate_output function:

io = StringIO()
json.dump(root_node, io, separators=(',', ':'), ensure_ascii=False)
with open(path, 'w', encoding='utf-8') as fd:
fd.write('var tipuesearch = ' + io.getvalue())

Later in you theme load tipuesearch_content.json (or tipuesearch_content.js if you renamed it) before loading tipuesearch.min.js

@souaaz

This comment has been minimized.

Copy link

souaaz commented Feb 24, 2017

The fix from @endafarrell and @scumer was good for me. Thanks!

@silverhook

This comment has been minimized.

Copy link
Member

silverhook commented Dec 3, 2018

Now that we’ve grown to be a community-led project (see #173 for more info), we’re picking up the pace.

What seems to be the best way to fix this issue now?

Is #149 still considered the best solution? And if so, is anything else missing/regressing that we need to fix to merge it?

@talha131 talha131 added this to the Elegant 2.0 milestone Dec 10, 2018

@talha131

This comment has been minimized.

Copy link
Member

talha131 commented Dec 10, 2018

We are hitting this issue in the hosted docs site at https://pelican-elegant.github.io/

@talha131 talha131 added the bug label Dec 11, 2018

@iranzo

This comment has been minimized.

Copy link
Member

iranzo commented Dec 12, 2018

Adding the patch mentioned to tipue_search plugin:

        node = {'title': page_title,
                'text': page_text,
                'tags': page_category,
                'url': page_url,
                'loc': page_url}

Does fix the issue on my website with current plugin

@iranzo

This comment has been minimized.

Copy link
Member

iranzo commented Dec 12, 2018

PR with this fix was sent to getpelican/pelican-plugins#873 some time ago

@talha131

This comment has been minimized.

Copy link
Member

talha131 commented Dec 13, 2018

Great find @iranzo. So it's not a bug in the theme, but the search plugin broke down.

I hope your comment would raise the issue in the maintainers radar and they merge it soon.

@iranzo

This comment has been minimized.

Copy link
Member

iranzo commented Dec 13, 2018

Submitted PR #210 until we get getpelican/pelican-plugins#873 fixed.

Please do validate it and set reminder to 'revert' once patch upstream has landed

@talha131

This comment has been minimized.

Copy link
Member

talha131 commented Dec 13, 2018

Thanks @iranzo. I would rather wait for 2, 3 days before merging this request. Meanwhile, we should contact the pelican-plugins maintainers via twitter or IRC to merge the PR.

@talha131

This comment has been minimized.

Copy link
Member

talha131 commented Dec 13, 2018

@iranzo

This comment has been minimized.

Copy link
Member

iranzo commented Dec 13, 2018

I did via github issue 😂

@justinmayer

This comment has been minimized.

Copy link

justinmayer commented Dec 13, 2018

Hey @talha131. Long time no see. Related plugin PR has been merged. Hope all is well with you! 👋🏻

@iranzo

This comment has been minimized.

Copy link
Member

iranzo commented Dec 13, 2018

As the fix in upstream was commited AFTER our last master merge, I did manually triggered a build of documentation repo and now you can check how it does behave at https://pelican-elegant.github.io/search.html?q=linux

Regards,
Pablo

@talha131

This comment has been minimized.

Copy link
Member

talha131 commented Dec 13, 2018

@justinmayer It has been long indeed. 😃 Thanks a lot for prompt action.

On a side note, I was pleasantly surprised to see you still active in Pelican. Your commitment to Pelican is unparalleled. Seriously! I am yet to see any other OSS, where the maintainer has stayed on board and active for so long. More power to you!

@talha131 talha131 closed this Dec 13, 2018

@justinmayer

This comment has been minimized.

Copy link

justinmayer commented Dec 19, 2018

Many thanks for the kind words, Talha — they mean a great deal to me. The very nature of FLOSS (and human beings) inevitably results in a dearth of positive feedback for developers and maintainers. Your recognition and encouragement are deeply appreciated. Thank you! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment