alexandrevicenzi / Flex

The minimalist Pelican theme.
https://flex.alxd.me
MIT License
608 stars 331 forks source link

Stork search URL is not going to correct place #307

Open paulocoutinhox opened 2 years ago

paulocoutinhox commented 2 years ago

Hi,

When enable search, the stork url is not going to correct place when im inside article:

image

Example on screenshot above: http://localhost:8000/2022/06/28/2022/06/28/apocalipse-de-jesus-cristo-fase-3-o-trono-e-os-seres-viventes.html

duplicated: 2022/06/28/2022/06/28

If im on home, it is working.

Thanks.

alexandrevicenzi commented 2 years ago

I'm not able to reproduce this issue, the search takes me to the correct place every time.

lioman commented 2 years ago

I had some similar issue, basically it should work on / but on no other page. If this is your issue:

  1. install pelican search from my branch: https://github.com/lioman/search (A PR is open long ago but not reviewed yet)
  2. Set the input options like this:
    SEARCH_INPUT_OPTIONS = f"""url_prefix = "{SITEURL}"
    """

I will adapt the documentation, once PR is merged

alexandrevicenzi commented 2 years ago

@lioman I accepted your PRs.

radoeka commented 1 year ago

As this issue is still open, and I've a question related to stork search, I'll ask it here. Let me know if my question should be administrated in separate issue, please.

Why is this issue still open, the code has been integrated? Is it open to include the documentation? But before you close the issue (if it is to be closed), have a look at my question below, please.

First an observation: The search field is rather big, compared to the other text in the navigation bar one could say, it is huge. Of course it is now the same width as the search results window, but when there are no search results the field attracts the user's attention. It is possible to make the width 80% ( I did so in my own version, and I like the result ).

++ stork.css   2023-03-26 19:37:22.747923623 +0200
@@ -13,7 +13,7 @@
 }

 .stork .stork-input {
-  width: 100%;
+  width: 80%;
   padding: 0.4em 0.8em;
   border: none;
   font-family: inherit;

However, my main issue at the moment is that the search results do not point to the correct page. I have a SITEURL including a directory, like so: https://<fqdn>/blog. The search results however, are pointing to https://<fqdn> the folder /blog is left out :(

I set the SEARCH_INPUT_OPTIONS variable to SITEURL: SEARCH_INPUT_OPTIONS = SITEURL

And according to the print out, it is set to the SITEURL:

pelican
...
SEARCH_INPUT_OPTIONS = https://<fqdn>/blog

But is has no effect (at all). Is there anyway to get this working correctly on my site?

Is this a bug, or I'm doing something wrong?

I'm using Flex from git main.

radoeka commented 1 year ago

Small update: I changed the SEARCH_INPUT_OPTIONS defination to:

SEARCH_INPUT_OPTIONS = f"""url_prefix = "{SITEURL}"
"""

De output is now:

pelican
...
SEARCH_INPUT_OPTIONS = url_prefix = "https://<fqdn>/blog"

However, the search results still point to https://<fqdn>.

radoeka commented 1 year ago

Got it working with the patch from lioman applied.

--- plugins/search/search.py-backup     2023-03-26 20:30:19.354948046 +0200
+++ plugins/search/search.py    2023-03-26 20:30:54.546095996 +0200
@@ -30,6 +30,7 @@
         self.tpages = settings.get("TEMPLATE_PAGES")
         self.search_mode = settings.get("SEARCH_MODE", "output")
         self.html_selector = settings.get("SEARCH_HTML_SELECTOR", "main")
+        self.input_options = settings.get("SEARCH_INPUT_OPTIONS", "")

     def build_search_index(self, search_settings_path):
         if not which("stork"):
@@ -101,6 +102,7 @@
                 [input]
                 base_directory = "{base_dir}"
                 html_selector = "{self.html_selector}"
+                {self.input_options}
                 {input_files}
             """
         )
lioman commented 1 year ago

This is still open, because my PR is still not merged. It seems that the maintainer just can't find time to review it. Will update this issue, once it is done

alexandrevicenzi commented 1 year ago

@lioman I did merge your last PR.

I'm working on Flex v3, which refactors this theme and fixes a few open issues, it will be available later this year.

alexandrevicenzi commented 1 year ago

@radoeka the style of the input and result query is provided by stork, you can customize it with custom CSS from pelican settings.

I created a better styling for v3, once v3 is out, stork should have a look similar to everything else in Flex.

lioman commented 1 year ago

@lioman I did merge your last PR.

I'm working on Flex v3, which refactors this theme and fixes a few open issues, it will be available later this year.

I didn't mean you, but the maintainer of the search plugin. Sorry if this was not clear enough.

lioman commented 1 year ago

@alexandrevicenzi @paulocoutinhox pelican-search is released with version 1.1.0 with all my changes. I had to rework large bits of my branch, and the settings mentioned above are not valid anymore.

You need to configure it like this:

STORK_INPUT_OPTIONS = {"url_prefix": SITEURL}

I adapted the wiki and added a site on how to configure it.

radoeka commented 1 year ago

@lioman: I tried to upgrade from 1.0.2 to 1.1.0, but pelican exits with a CRITICAL. The critical error is:

CRITICAL UnicodeEncodeError: 'latin-1' codec can't encode character '\u2018' in position 1240: ordinal not in __init__.py:566

The error is rather cryptic.

Do you perhaps know what causes this? I've to admit, that I've the deprecation warnings for SEARCH_HTML_SELECTOR and OUTPUT_MODE. Are they maybe the reason for the error?