Git Product home page Git Product logo

search's People

Contributors

botpub avatar justinmayer avatar lioman avatar maphew avatar pre-commit-ci[bot] avatar s3lph avatar tseing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

search's Issues

Missing index.st (search plugin breaks parsing titles with `"` or `\`)

  • I have searched the issues (including closed ones) and believe that this is not a duplicate.

Issue

When and how does the index get built? On two systems, Windows and Ubuntu, I've followed the instructions and verfied that stork is installed and in PATH.

$ stork --version
Stork 1.6.0

...then launched pelican with pelican --autoreload --listen, and in the resultant preview browser window typed text in the search box.

The web page says "Error! Check the browser console.".
Browser console says "Uncaught (in promise) undefined ".
Shell console says:

Done: Processed 69 articles, 0 drafts, 0 hidden articles, 1 page, 0 hidden pages and 0 draft pages in 8.83 seconds.
Unable to find `/search-index.st` or variations:
/search-index.st.html
/search-index.st/index.html
/search-index.st 

I've searched the file system for those files and they don't exist, so it looks like the index is not being built. How do I test and/or ensure the index is being built?

unexpected keyword argument 'capture_output'

Installed the module according the installation documentation.

But get the following error msg: CRITICAL TypeError: init() got an unexpected keyword argument 'capture_output'

Stork --help, results in the expected output.

I've added the plugin to the configuration, as well as the settings:

PLUGINS = [ .....
  'post_stats', 'related_posts', 'search', 'seo', 'simple_footnotes', 'share_post', 'sitemap',
  ....
]

SEARCH_MODE = "output"
SEARCH_HTML_SELECTOR = "main"

Can this be investigated?

Support for Lyra JS

Hi,

I have a suggestion to a feature.

You can use Lyra JS (https://lyrajs.io/) that is a javascript engine for document index like elasticsearch and you don't need WebAssembly.

import { create, insert, search } from "@lyrasearch/lyra";
const db = await create({
  schema: {
    quote: "string",
    author: "string",
  }
});
await insert(db, {
  quote: "I feel as if I'm always on the verge of waking up",
  author: "Fernando Pessoa"
});
const results = await search(db, {
  term: "waking up"
});

Maybe the plugin can create the index and the JS search function can use it.

add other options to stork.toml

  • I have searched the issues (including closed ones) and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.
  • I am willing to lend a hand to help implement this feature.

Feature Request

Stork has some other options in stork.toml to control index like stemming or url_prefix. It is needed if your pelican content is not written in English or the site has a certain structure.

Implementation options

  1. pipe all current settings to stork in a one to one matter like STORK_URL_PREFIX will be url_prefix in input
  2. add one setting like STORK_INPUT_OPTIONS to have all settings in one place.

The benefit of the latter is that we do not need to change anything, if stork add new options. But it is perhaps a bit more complex from a user perspective and easier to mess up.

I'm willing to implement it, but just wanted to discuss options first

Wrong URL when inside an article

  • I have read the Filing Issues and subsequent “How to Get Help” sections of the documentation.
  • I have searched the issues (including closed ones) and believe that this is not a duplicate.

Issue

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.

UTF-8 error in generated search.toml

  • I have read the Filing Issues and subsequent “How to Get Help” sections of the documentation.
  • I have searched the issues (including closed ones) and believe that this is not a duplicate.
  • OS version and name: Windows 10
  • Python version: Python 3.9.10
  • Pelican version: Pelican 4.8.0
  • Version of this plugin: pelican-search 1.1.0

Issue

Hi,

I got an unicode error when I was trying pelican-search 1.1.0.

CRITICAL Exception: Search plugin reported Error: Couldn't read file                        __init__.py:552
                    `output\search.toml`. Got error `stream did not contain valid UTF-8`

I checked output\search.toml and it is GB18030 encoding. Obviouly, pelican-search plugin generated output\search.toml with default system encoding. I speculate this error will be raised in Windows and non-English environment. I checked the code, line 97:

with search_settings_path.open("w") as fd:
            rtoml.dump(obj=search_settings, file=fd)

The open method should be modified as

with search_settings_path.open("w", encoding="utf-8") as fd:
            rtoml.dump(obj=search_settings, file=fd)

And this error is solved. It is a simple fix. Should I create a PR?

Installation fails due to version of rtoml dependency

  • I have read the Filing Issues and subsequent “How to Get Help” sections of the documentation.
  • I have searched the issues (including closed ones) and believe that this is not a duplicate.
  • OS version and name:Ubuntu 24.04 LTS
  • Python version: 3.12.3
  • Pelican version:
  • Version of this plugin: 4.9.1
  • Link to theme: none
  • Links to plugins: none
  • Link to your site: none
  • Link to your source: none
  • Link to a Gist with the contents of your settings file:

Issue

Hi,

When trying to pipx install the search plugins, it fails due to the required version of rtoml.

> pipx inject pelican pelican-search 
Fatal error from pip prevented installation. Full pip output in file:
    /home/camille/.local/pipx/logs/cmd_2024-06-15_18.51.26_pip_errors.log

pip seemed to fail to build package:
    rtoml<0.10.0,>=0.9.0

Some possibly relevant errors from pip install:
    error: subprocess-exited-with-error
    error: metadata-generation-failed
Error installing pelican-search.```

Same error happens when directly trying with rtoml==0.9.0

pipx inject pelican rtoml==0.9.0
Fatal error from pip prevented installation. Full pip output in file:
/home/camille/.local/pipx/logs/cmd_2024-06-15_18.41.47_pip_errors.log

pip seemed to fail to build package:
rtoml==0.9.0

Some possibly relevant errors from pip install:
error: subprocess-exited-with-error
error: metadata-generation-failed
Error installing rtoml from spec 'rtoml==0.9.0'.```

But installation succeeds with version 0.10.0 :

> pipx inject pelican rtoml==0.10.0
  injected package rtoml into venv pelican
done! ✨ 🌟 ✨

(and actually if fails because cargo is not installed

So, except if there is a reason not to switch to version 0.10.0, this could solve the problem, without requiring the installation of cargo.
Thanks,
Camille

expected newline, found an identifier

  • I have read the Filing Issues and subsequent “How to Get Help” sections of the documentation.
  • I have searched the issues (including closed ones) and believe that this is not a duplicate.

  • OS version and name: FreeBSD 13.0-RELEASE-p4
  • Python version:3.8.12
  • Pelican version: 4.7.1
  • Version of this plugin: 1.0.0

Steps up to this point:

  • I installed Stork as needed for this plugin via Rustup. stork --version reports 1.3.0.
  • I set up a venv with Pelican and generated some posts using the default theme. It all generated okay.
  • I installed pelican-search via pip in the venv
  • I set edited the theme to add the CDN code and add the search box.
  • I added SEARCH_MODE = "output" and SEARCH_HTML_SELECTOR = "main" to the pelicanconf.py file.
  • I called pelican to regenerate the site.

After that I got this error.

CRITICAL Exception: Search plugin         __init__.py:550
                    reported Error: expected                        
                    newline, found an identifier at                 
                    line 438 column 11   

Help! I do not understand Python at all, so I don't have any insight into the issue beyond what I have here. :( I am happy to provide additional information if requested (and given a little instruction on how).

`search.toml` file is not being generated

I have installed the plugin, using Flex theme. I cannot see any search.toml, or instructions on how to generate it.

  • I have searched the issues (including closed ones) and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Issue

Trying to generate my theme, with the search enabled, and I get errors regarding no search.toml file - it is similar to #3 and it appears all I need is a search.toml file. However, I can't see any definitive / suggested configurations for pelican.

If you could point me in the correct direction that would be superb!

Thanks

How to translate stork?

  • I have searched the issues (including closed ones) and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Issue

How to translate search? My site is in portuguese and the search in english:

image

`search.toml` doesn't add `SITEURL` before `url`

  • I have read the Filing Issues and subsequent “How to Get Help” sections of the documentation.
  • I have searched the issues (including closed ones) and believe that this is not a duplicate.

Issue

So when indexing with stork i have this file as search.toml

[input]
base_directory = "output"
html_selector = "main"

[[input.files]]
path = "how-i-added-daphne-server-dectection-to-wappalyzer.html"
url = "/how-i-added-daphne-server-dectection-to-wappalyzer.html"
title = "How I added daphne server dectection to wappalyzer"

[[input.files]]
path = "how-i-lost-my-first-pc.html"
url = "/how-i-lost-my-first-pc.html"
title = "How I lost my first PC"

[[input.files]]
path = "how-i-fell-in-love-with-honeyworks.html"
url = "/how-i-fell-in-love-with-honeyworks.html"
title = "How I fell in love with Honeyworks"

[[input.files]]
path = "how-i-fixed-htmx-redeclaration-of-let-element-with-hx-boosttrue.html"
url = "/how-i-fixed-htmx-redeclaration-of-let-element-with-hx-boosttrue.html"
title = "How I fixed htmx redeclaration of let element with hx-boost=true"

But if you see my site it is hosted on https://baseplate-admin.github.io/blog/

So whenever i search within my site the links all point to https://baseplate-admin.github.io/ + filename

The solution i would like :

Add SITEURL before url so that the search.toml becomes like this :

[input]
base_directory = "output"
html_selector = "main"

[[input.files]]
path = "how-i-added-daphne-server-dectection-to-wappalyzer.html"
url = "https://baseplate-admin.github.io/blog//how-i-added-daphne-server-dectection-to-wappalyzer.html"
title = "How I added daphne server dectection to wappalyzer"

[[input.files]]
path = "how-i-lost-my-first-pc.html"
url = "https://baseplate-admin.github.io/blog//how-i-lost-my-first-pc.html"
title = "How I lost my first PC"

[[input.files]]
path = "how-i-fell-in-love-with-honeyworks.html"
url = "https://baseplate-admin.github.io/blog//how-i-fell-in-love-with-honeyworks.html"
title = "How I fell in love with Honeyworks"

[[input.files]]
path = "how-i-fixed-htmx-redeclaration-of-let-element-with-hx-boosttrue.html"
url = "https://baseplate-admin.github.io/blog//how-i-fixed-htmx-redeclaration-of-let-element-with-hx-boosttrue.html"
title = "How I fixed htmx redeclaration of let element with hx-boost=true"

Layout issues due to Stork progress bar

  • [X ] I have searched the issues (including closed ones) and believe that this is not a duplicate.
  • [ X] I have searched the documentation and believe that my question is not covered.

I have a couple layout issues with the Stork progress bar.

First it appears in the middle of the article (seemingly where the results box would end).

Second, more bothersome, blank space appears on the right side of my page, which impacts usability, especially on mobiles when swiping.

Narrowed down the issue (deleting elements in DevTools until I found the culprit) to this div:

<div class="stork-progress" style="width: 100%; opacity: 0;"></div>

which is not mine - it seemingly gets inserted by the plugin at build time, and I have not managed to override the inline style via external CSS.

When width: 0% my layout issue disappears (because the progress bar does not have any space, ie is hidden).

Where/how can I change width to 0%, or deactivate the progress bar entirely (ie not have this div inserted)?
Perhaps better for a future version to define those inline styles in the external CSS?

demo website ?

  • I have searched the issues (including closed ones) and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.
  • I am willing to lend a hand to help implement this feature. (well, ATM I don't have time, but in a few week why not)

Feature Request

Hello ! It could be cool to have a demo site for this plugin ! :D

Spurious characters in titles introduced in v1.0.2

When testing the code for an upcoming release of the Search plugin, I upgraded from 1.0.1 to 1.0.2 on my local workstation and immediately noticed some spurious characters between the last two words of all the titles in the search results. (See attached screenshot.) I assume those spurious characters are associated with the &nbsp; added by Typogrify’s widont feature.

So it seems that the json.dumps() method introduced via cc48d48 in #23 was sadly not without its side effects after all. That being the case, I intend to revert that change in the upcoming release and, for the moment, go back to the original fix provided in #15.

@maphew / @s3lph / @lioman: If any of you would like to look at how the json.dumps() method could be re-deployed in this plugin in a way that does not produce these spurious characters, that assistance would be most welcome and appreciated.

Spurious

Use wasm Stork to build the index?

Maybe this is a stupid question born of ignorance, but is there a way to use the wasm version of Stork to build the search index instead of having to compile an executable for the local platform?

  • I have searched the issues (including closed ones) and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Issue

Why: on Windows installing Stork requires downloading ~7 GB of Visual Studio build tools and installing 'Desktop development with C++' kit, on top of Rustup (recipe).

Running wasm locally is reportedly possible: https://blog.devgenius.io/running-wasm-binaries-in-on-your-local-system-69694e100083, though this example also requries a local compiler so, yeah, nothing gained. However that was over 2 years ago so maybe there are other ways?

Wrong URL for i18 multisite

When using i18_multisite plugin the generation of search.toml uses wrong URLs.

For example

[[input.files]]
path = "pages/about_fr.html"
url = "/pages/about_fr.html"

should be

[[input.files]]
path = "pages/about_fr.html"
url = "/fr/pages/about_fr.html"

To solve:

  • add SEARCH_I18_SUBSITE parameter to generator
  • in site configuration add as follows
I18N_SUBSITES = {
    "fr": {
        "SITENAME": "Mon beau site",
        "SEARCH_I18_SUBSITE": "fr"
    }
}

The patch for search.py:

--- ./search.py.bak	2023-02-20 17:00:10.379008769 +0100
+++ ./search.py	2023-02-20 17:19:26.119005800 +0100
@@ -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.i18_subsite = settings.get("SEARCH_I18_SUBSITE", None)
 
     def build_search_index(self, search_settings_path):
         if not which("stork"):
@@ -62,6 +63,7 @@
             pages += article.translations
 
         input_files = ""
+        url_i18_prefix = self.i18_subsite + "/" if self.i18_subsite is not None else ""
 
         # Generate list of articles and pages to index
         for page in pages:
@@ -72,7 +74,7 @@
             input_file = f"""
                 [[input.files]]
                 path = "{page_to_index}"
-                url = "/{page.url}"
+                url = "/{url_i18_prefix}{page.url}"
                 title = {dumps(striptags(page.title))}
             """
             input_files = "".join([input_files, input_file])
@@ -86,7 +88,7 @@
             input_file = f"""
                 [[input.files]]
                 path = "{tpage_to_index}"
-                url = "{self.tpages[tpage]}"
+                url = "{url_i18_prefix}{self.tpages[tpage]}"
                 title = ""
             """
             input_files = "".join([input_files, input_file])

Just A Question: About Deploying A Pelican site with Search Enabled.

Hello,

I have just discovered Pelican and have a question about this search plugin.

To install the plugin, I also need to install Stork software... and it seems I need to install the mac version of the tool using brew. My hosting is on Linux, so if I add the plugin via pip ... surely that can't go any get a linux version of the app can it?

(Or this is a .wasm thing, about which I know next to nothing, so it'll be compiled and served accordingly)

Sorry to be dense - but I won't have to go to my hosting and install a Linux version will I? I'm looking for a super-simple search (I liked the look of the previous version of the plugin) for a site of <100 pages.... and would prefer the most basic option given that I may be teaching this approach to site building to students ... so it needs to be generic.

Thanks, I hope this makes some sense.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.