pelican-plugins / search Goto Github PK
View Code? Open in Web Editor NEWPelican plugin that adds site search capability
Pelican plugin that adds site search capability
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?
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?
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.
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.
STORK_URL_PREFIX
will be url_prefix
in inputSTORK_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
Hi,
When enable search, the stork url is not going to correct place when im inside article:
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.
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?
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
Steps up to this point:
stork --version
reports 1.3.0.SEARCH_MODE = "output"
and SEARCH_HTML_SELECTOR = "main"
to the pelicanconf.py
file.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).
I have installed the plugin, using Flex theme. I cannot see any search.toml, or instructions on how to generate it.
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 search? My site is in portuguese and the search in english:
Hi, from today Stork's development has been ceased. For more information please see jameslittle230/stork#360 (comment)
We should find alternative way to handle search.
Some of the alternatives that we can look into:
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"
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?
Please include a hint to include plugins=['search'] in the README.MD
Hello ! It could be cool to have a demo site for this plugin ! :D
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
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.
...something in that recipe[*] is seriously at odds with my system. Now every commit tries to reinstall poetry, invoke, etc., then encounters a compatbility error and aborts. I'll follow up with a seperate issue after I've had a chance to try and understand what's going on.
Originally posted by @maphew in #22 (comment)
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?
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?
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:
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])
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.