Skip to main content

This program exports your local [Zotero] library to a usable HTML website with following features.

Project description

Zotsite: A Zotero Export Utility

PyPI Python 3.11 Python 3.12 Build Status

This project exports your local Zotero library to a usable HTML website with following features:

  • Easily access your papers, site snapshots, notes from a navigation tree.
  • Provides metadata from collections and attachments (i.e. referenes etc).
  • Display PDF papers and website snapshot (the latter as framed).
  • Search function dynamically narrows down the papers you're looking for.
  • Embed links to a specific collection, article, item, note etc.
  • Export only a portion of your collection with regular expressions using the collection name.
  • BetterBibtex integration.
  • Snazzy look and feel from the latest Bootstrap CSS/Javascript library.

Table of Contents

Documentation

See the full documentation. The API reference is also available.

Obtaining

The library can be installed with pip from the pypi repository:

pip3 install zensols.zotsite

Process

The tool does the following:

  1. Exports the meta data (directory structure, references, notes, etc) from your Zotero library. On MacOS, this is done by querying the file system SQLite DB files.
  2. Copies a static site that enables traversal of the exported data.
  3. Copies your Zotero stored papers, snapshot (sites) etc.
  4. Generates a navigation tree to easily find your papers/content.

Sample Site Demonstration

See the live demo, which provides a variety of resources found in my own library. Note: To my knowledge, all of these resources are free to distribute and violate no laws. If I've missed one, please create an issue.

Requirements

BetterBibtex plugin for Zotero.

Usage

The library is typically used from the command line to create websites, but it can also be used as an API from Python.

Command Line

The command line program has two modes: show configuration (a good first step) and to create the web site. You can see what the program is parsing from your Zotero library:

zotsite print

To create the stand-alone site, run the program (without the angle brackets):

zotsite export

If your library is not in the default ~/zotero directory you will need to change that path by making a zotsite.conf config file. This will create the html files in the directory ./zotsite:

zotsite export --collection zotsite.conf

A mapping of BetterBibtex citation keys to Zotero's database unique item keys can be useful to scripts:

zotsite citekey -k all

The tool also provides a means of finding where papers are by item key:

zotsite docpath -k all

See usage for more information. Command line usage as provided with the --help option.

API

The API provides access to a Python object that creates the website, can resolve BetterBibtex citation keys to Zotero unique identifier item keys and provide paths of item attachments (such as papers).

The following example come from this working script.

>>> from typing import Dict, Any
>>> from pathlib import Path
>>> from zensols.zotsite import Resource, ApplicationFactory
# get the resource facade objects, which provides access to create the site,
# citation and path lookup methods
>>> resource: Resource = ApplicationFactory.get_resource()
# get a mapping from <library ID>_<item key> to entry dictionaries
>>> entries: Dict[str, Dict[str, Any]] = resource.cite_db.entries
# get a mapping from item key (sans library ID) to the attachment path
>>> paths: Dict[str, Path] = resource.zotero_db.item_paths
# create BetterBibtex citation key to item key mapping
>>> bib2item: Dict[str, str] = dict(map(
...     lambda e: (e['citationKey'], e['itemKey']),
...     entries.values()))
# get the item key from the citation key
>>> itemKey: str = bib2item['landesCALAMRComponentALignment2024']
# get the path using the Zotero DB item key
>>> paper_path: Path = paths[itemKey]
>>> print(paper_path)
# display the paper (needs 'pip install zensols.rend')
>>> from zensols.rend import ApplicationFactory as RendAppFactory
>>> RendAppFactory.get_browser_manager()(paper_path)

Configuration File

Either an environment variable ZOTSITERC must be set or a -c configuration option must be given and point to a file to customize how the program works. See the test configuration file for an example and inline comments for more detail on how and what can be configured.

Screenshot

Also see the live demo.

Screenshot

Ubuntu and Linux Systems with Python 3.5 or Previous Version

Please read this issue if you are installing a Ubuntu or any Linux system with Python 3.5 or previous version.

Attribution

This software uses:

Todo

  • Make the site portion a proper Javascript site. Right now, all the mins are added in the distribution to same directory as the main navigation/content file.
  • Use something like zotxt to make this work with a plugin rather than directly against the SQLite DB.

Zotero Plugin Listing

This is listed as a plugin on the Zotero site.

Changelog

An extensive changelog is available here.

Community

Please star this repository and let me know how and where you use this API. Contributions as pull requests, feedback, and any input is welcome.

License

MIT License

Copyright (c) 2019 - 2026 Paul Landes

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zensols_zotsite-1.3.0-py3-none-any.whl (629.7 kB view details)

Uploaded Python 3

File details

Details for the file zensols_zotsite-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: zensols_zotsite-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 629.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for zensols_zotsite-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fbada668d45de9f50adba4c0dbfdc35f86b5476a64b9cfa1e28f14864ce67bca
MD5 e775278c3436c085dfb10d5234d294b2
BLAKE2b-256 ce8ac88e820083a639744d31c67d4088312ecdfc83c2fd1beb5335689f4f6071

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page