pelican-plugins / search

Pelican plugin that adds site search capability
47 stars 9 forks source link

Handle the URL setting RELATIVE_URLS #7

Closed micansid closed 1 year ago

micansid commented 2 years ago

Handle the URL setting RELATIVE_URLS, is need to include the search bar to a sidebar.

justinmayer commented 2 years ago

I believe that the problem this PR was intended to fix has already been addressed by https://github.com/pelican-plugins/search/commit/a608bdfcceea10cc1350026f4468d5ade17145a1 in the just-published Search 1.0.1 version of this plugin.

@micansid: Would you please test this latest version and let me know whether the problem you were trying to fix here has been resolved in Search 1.0.1?

micansid commented 2 years ago

The fix a608bdf works, when the URL starts at the root. I tested the Search 1.0.1 and found an case when it is not working. The Problem occurs, when you use github-pages. The URL is structured like this:

https://username.github.io/repo/index.html

Search 1.0.1 always removes the repo part at links of the index.

Example: https://micansid.github.io/demo-sfgmund-website/index.html Search: "bier" Result: https://micansid.github.io/2018/2018-06-01_volksfesteinzug-2018.html Expected: https://micansid.github.io/demo-sfgmund-website/2018/2018-06-01_volksfesteinzug-2018.html

publishconf.py SITEURL = 'https://micansid.github.io/demo-sfgmund-website/' RELATIVE_URLS = False

lioman commented 2 years ago

My PR #5 solves this too in another way as you are able to add the site_url input option

bigfootXadite commented 1 year ago

The fix a608bdf works, when the URL starts at the root. I tested the Search 1.0.1 and found an case when it is not working. The Problem occurs, when you use github-pages. The URL is structured like this:

https://username.github.io/repo/index.html

Search 1.0.1 always removes the repo part at links of the index.

Example: https://micansid.github.io/demo-sfgmund-website/index.html Search: "bier" Result: https://micansid.github.io/2018/2018-06-01_volksfesteinzug-2018.html Expected: https://micansid.github.io/demo-sfgmund-website/2018/2018-06-01_volksfesteinzug-2018.html

publishconf.py SITEURL = 'https://micansid.github.io/demo-sfgmund-website/' RELATIVE_URLS = False

@justinmayer I can confirm this is the case on gitlab pages as well for the latest version of stork search. If there's anything I can do to speed up the PR let me know. #5 also could be a potential fix as well.

justinmayer commented 1 year ago

Many thanks to @micansid for the submission and to @bigfootXadite for chiming in with good feedback.

As far as I can tell, this PR changes the default behavior, which I do not believe is warranted. To wit, url = page.url was previously used in all cases, but after the change proposed here, that would only be true if RELATIVE_URLS is enabled. I, for example, do not have RELATIVE_URLS enabled, and yet the changes here would appear to result in changed behavior for me (i.e., url = self.siteurl + '/' + page.url), which (if true) I believe to be unwarranted.

If the changes from PR no. 5, which as of a few hours ago I just merged and published as version 1.1.0 of this plugin, are insufficient to address the target use case (i.e., GitHub Pages, if I understand correctly), please submit a follow-up pull request to build upon @lioman's work in the latest release. Thanks again! 💫

justinmayer commented 1 year ago

@micansid: Side note… As a suggestion for the future, I highly recommend doing all work on a feature/topic branch instead of the default main branch, even in the context of your own fork. Doing so really does help make things easier for maintainers. Thanks in advance! 😁