Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

GitHub release (latest SemVer) python versions on pypi version on pypi license Donate

Shinxsearch & Manticore Search for Pelican

The aim of this Pelican plugin is to provide a support for Sphinxsearch and Manticore Search tools, bringing fulltext searchs on a website generated with Pelican (a static site generator written in Python).

search box screenshot

The plugin itself is widely inspired from this nice work: pelican-search.

Here is a list of improvements:

  • Support of Python 3.x;
  • Better support for html text with BeautifulSoup;
  • HTML and PHP templates for the search box and the results page;
  • Support of boolean query operators (OR, AND, NOT);
  • A simple PHP server is the only requirement;
  • The code uses SphinxQL queries sent on a MySQL protocol (PDO + prepared queries). There is no need to compile the old and deprecated Sphinx library.

Installation of Python dependencies

Installation from pypi:

pip install pelican-sphinxsearch

Or locally:

git clone https://github.com/ysard/sphinxsearch-for-pelican
pip install -e ./sphinxsearch-for-pelican

Template integration

Examples are available in the folder site_files.

An example of a search area is in the file search_box.html; you can include this template where you want in your theme; preferably in the file base.html with this directive:

{% include 'search_box.html' %}

The related CSS rules are available in the file search_box.css.


The provided PHP page search.php handles form posts, sends queries to Sphinx or Manticore engine, and format the results for the users.

You can modify the location of your engine, by updating this line:

$dsn = 'mysql:host=127.0.0.1;port=9306;charset=utf8';

Here is an example of what you can expect:

search results screenshot

Template installation

search.php and search_box.html files have to be copied in the directory templates of your Pelican theme.

Example:

./pelican-themes/aboutwilson/templates/

Pelican configuration

In your pelicanconf.py, please add/update these lines:

# If installed via PyPI/pip
PLUGINS += ['pelican.plugins.sphinxsearch',]

# If installed locally
#PLUGIN_PATHS = ['pelican-plugins']
#PLUGINS += ['sphinxsearch',]

# Tell Pelican to render this page as a template
TEMPLATE_PAGES = {'search.php': 'search.php',}

# The Sphinx index name is by default set to 'my_blog', but can be
# modified thanks to the `SPHINX_INDEX` variable
#SPHINX_INDEX = "my_blog"

Sphinxsearch configuration

Configuration file

Please edit the following file in the server:

sudo nano /etc/sphinxsearch/sphinx.conf

The only file that will be indexed is named sphinxsearch.xml and it appears in the folder output of the Pelican project when you update it.

Exemple of section for a website (using the default index named myblog and hosted in /var/www/html/blog/):

source my_blog {
	type = xmlpipe2
	xmlpipe_command = cat /var/www/html/blog/sphinxsearch.xml
	xmlpipe_fixup_utf8 = 1
	xmlpipe_field = content
	xmlpipe_attr_string = title
	xmlpipe_attr_string = author
	xmlpipe_attr_json = authors
	xmlpipe_attr_string = url
	xmlpipe_attr_string = category
	xmlpipe_attr_string = category_url
	xmlpipe_attr_json = tags
	xmlpipe_attr_string = summary
	xmlpipe_attr_string = slug
	xmlpipe_attr_timestamp = published
}

index my_blog {
	type = plain
	source = my_blog
	path = /var/lib/sphinxsearch/data/
	charset_type = utf-8
	charset_table = U+FF10..U+FF19->0..9, U+FF21..U+FF3A->a..z\
		, U+FF41..U+FF5A->a..z, 0..9, A..Z->a..z, a..z ,U+00C0->a, U+00C1->a\
		, U+00C2->a, U+00C3->a, U+00C4->a, U+00C5->a, U+00E0->a, U+00E1->a\
		, U+00E2->a, U+00E3->a, U+00E4->a, U+00E5->a, U+0100->a, U+0101->a\
		, U+0102->a, U+0103->a, U+010300->a, U+0104->a, U+0105->a, U+01CD->a\
		, U+01CE->a, U+01DE->a, U+01DF->a, U+01E0->a, U+01E1->a, U+01FA->a\
		, U+01FB->a, U+0200->a, U+0201->a, U+0202->a, U+0203->a, U+0226->a\
		, U+0227->a, U+023A->a, U+0250->a, U+04D0->a, U+04D1->a, U+1D2C->a\
		, U+1D43->a, U+1D44->a, U+1D8F->a, U+1E00->a, U+1E01->a, U+1E9A->a\
		, U+1EA0->a, U+1EA1->a, U+1EA2->a, U+1EA3->a, U+1EA4->a, U+1EA5->a\
		, U+1EA6->a, U+1EA7->a, U+1EA8->a, U+1EA9->a, U+1EAA->a, U+1EAB->a\
		, U+1EAC->a, U+1EAD->a, U+1EAE->a, U+1EAF->a, U+1EB0->a, U+1EB1->a\
		, U+1EB2->a, U+1EB3->a, U+1EB4->a, U+1EB5->a, U+1EB6->a, U+1EB7->a\
		, U+2090->a, U+2C65->a ,U+00C8->e, U+00C9->e, U+00CA->e, U+00CB->e\
		, U+00E8->e, U+00E9->e, U+00EA->e, U+00EB->e, U+0112->e, U+0113->e\
		, U+0114->e, U+0115->e, U+0116->e, U+0117->e, U+0118->e, U+0119->e\
		, U+011A->e, U+011B->e, U+018E->e, U+0190->e, U+01DD->e, U+0204->e\
		, U+0205->e, U+0206->e, U+0207->e, U+0228->e, U+0229->e, U+0246->e\
		, U+0247->e, U+0258->e, U+025B->e, U+025C->e, U+025D->e, U+025E->e\
		, U+029A->e, U+1D07->e, U+1D08->e, U+1D31->e, U+1D32->e, U+1D49->e\
		, U+1D4B->e, U+1D4C->e, U+1D92->e, U+1D93->e, U+1D94->e, U+1D9F->e\
		, U+1E14->e, U+1E15->e, U+1E16->e, U+1E17->e, U+1E18->e, U+1E19->e\
		, U+1E1A->e, U+1E1B->e, U+1E1C->e, U+1E1D->e, U+1EB8->e, U+1EB9->e\
		, U+1EBA->e, U+1EBB->e, U+1EBC->e, U+1EBD->e, U+1EBE->e, U+1EBF->e\
		, U+1EC0->e, U+1EC1->e, U+1EC2->e, U+1EC3->e, U+1EC4->e, U+1EC5->e\
		, U+1EC6->e, U+1EC7->e, U+2091->e ,U+00CC->i, U+00CD->i, U+00CE->i\
		, U+00CF->i, U+00EC->i, U+00ED->i, U+00EE->i, U+00EF->i, U+010309->i\
		, U+0128->i, U+0129->i, U+012A->i, U+012B->i, U+012C->i, U+012D->i\
		, U+012E->i, U+012F->i, U+0130->i, U+0131->i, U+0197->i, U+01CF->i\
		, U+01D0->i, U+0208->i, U+0209->i, U+020A->i, U+020B->i, U+0268->i\
		, U+026A->i, U+040D->i, U+0418->i, U+0419->i, U+1E09->c, U+212D->c\
		, U+2184->c
	mlock = 1
	enable_star = 1
	expand_keywords = 1
	phrase_boundary = ., ?, !, U+2026 # horizontal ellipsis
	preopen = 1
	html_strip = 1
	html_index_attrs = img=alt,title; a=title;
	html_remove_elements    = style, script
	min_word_len = 2
	stopwords = /var/lib/sphinxsearch/data/stopwords_fr.txt
	morphology = libstemmer_french
}

Note: Don't forget to modify the stemmer in the morphology key, and the stopwords list according to the language you are processing.

Create/update the index

The index must be created once with:

sudo indexer --all

Next times, the command will be like:

sudo /usr/bin/indexer --rotate --config /etc/sphinxsearch/sphinx.conf --all

You can update the Makefile of the Pelican project by adding this directive:

update_sphinxsearch:
	@echo "Update Sphinxsearch index"
	sudo /usr/bin/indexer --rotate --config /etc/sphinxsearch/sphinx.conf --all

... and adding it to your favorite deployment directive with:

$(MAKE) update_sphinxsearch

License

This program is released under the GNU Affero General Public License.

Metadata

Release files for pelican-sphinxsearch 2.1.dev0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pelican-sphinxsearch 2.1.dev0
File Size Uploaded Provenance Actions
pelican_sphinxsearch-2.1.dev0.tar.gz 19.3 kB Without provenance Details for pelican_sphinxsearch-2.1.dev0.tar.gz

Release files / pelican_sphinxsearch-2.1.dev0.tar.gz

Download URL pelican_sphinxsearch-2.1.dev0.tar.gz
Size 19.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1d9279ceaaaf0e723d8729daeb6236a7ea5eb859a0d0ed6487f8abe4d06eaba2
BLAKE2b-256 checksum
How to use checksums
6f54cba09875fb0419b8e77e3ffa1a47a3c43ce0fcb8267a69f76512cfd85a99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Security for pelican-sphinxsearch 2.1.dev0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page