Skip to main content

Meze adds Sphinx flavor to Mezzanine. You can write your blog posts and pages in reStructuredText and get them converted into HTML via Sphinx.

Usage Examples

See a number of usage examples at: http://ahmetbakan.com/blog/category/meze/

Requirements

Sphinx is required to convert reStructuredText source.

Installation

You can use easy_install or pip:

easy_install -U mezzanine-meze
pip install mezzanine-meze

or download package from https://pypi.python.org/pypi/mezzanine-meze and install using setup.py.

Quick start

Make the following changes in your project settings.py file:

  1. Add “meze” to INSTALLED_APPS:

    INSTALLED_APPS = (
        ...
        'meze',
    )
  2. Inject source and convert fields to mezzanine.blog.models.BlogPost and mezzanine.pages.models.RichTextPage.source models:

    help_text = ("Source in reStructuredText format will be converted to "
                 "HTML and result will replace content field.")
    EXTRA_MODEL_FIELDS = (
        # Enable Meze for blog posts
        ("mezzanine.blog.models.BlogPost.source",
         "TextField", (), {"blank": True, "help_text": help_text}),
        ("mezzanine.blog.models.BlogPost.convert",
         "BooleanField", ("Convert source",), {"default": True}),
        # Enable Meze for rich text pages
        ("mezzanine.pages.models.RichTextPage.source",
         "TextField", (), {"blank": True, "help_text": help_text}),
        ("mezzanine.pages.models.RichTextPage.convert",
         "BooleanField", ("Convert source",), {"default": True}),
    )
    del help_text

    If you have started using Meze after creating database, you may need to make a migration. See field injection caveats in Mezzanine documentation.

  3. Update settings.py file.

    Add MEZE_SETTINGS:

    MEZE_SETTINGS = {
        'workdir': os.path.join(PROJECT_ROOT, 'meze_workdir'),
    }

    Default values are shown. You will need write access to workdir.

    Add configuration options for Sphinx:

    SPHINX_CONF = """
    project = u''
    copyright = u''
    version = '0'
    release = '0'
    master_doc = 'index'
    pygments_style = 'sphinx'
    html_theme = 'default'
    html_sidebars = {'**': []}
    html_domain_indices = False
    html_use_index = False
    html_show_sourcelink = False
    html_add_permalinks = None
    source_suffix = '.rst'
    intersphinx_mapping = {'python': ('http://docs.python.org/', None)}
    extlinks = {'wiki': ('http://en.wikipedia.org/wiki/%s', ''),}
    extensions = ['sphinx.ext.intersphinx', 'sphinx.ext.extlinks']
    """

    This file is written to Meze workdir.

  4. Sphinx is using Pygments for syntax highlighting, so you will need to add pygments.css file to your template:

    {% compress css %}
    ...
    <link rel="stylesheet" href="{% static "meze/css/meze.css" %}">
    <link rel="stylesheet" href="{% static "meze/css/pygments.css" %}">
    ...

    If you are writing Python snippets, you can also add copybutton.js file, to enable a copy friendly display option for code:

    {% compress js %}
    ...
    <script src="{% static "meze/js/copybutton.js" %}"></script>
    ...

How does it work?

Meze starts a Sphinx project in workdir by creating a simple configuration file (conf.py).

reStructuredText files are written into workdir, HTML files are built using Sphinx, and content of HTML files are stored in the database.

Source code

https://github.com/abakan/mezzanine-meze

Changes

v0.3 (Jan 10, 2014)

  • Moved static files to meze folder.

  • Added static files to setup.py.

v0.2.2 (Oct 11, 2013)

  • Searching images in both STATIC_ROOT and MEDIA_ROOT folders.

  • Improved revising image sources in HTML to avoid exceptions when an image file is not found.

v0.2.1 (July 17, 2013)

  • Fixed a bug in Meze class that prevented changes in Sphinx configuration to take place.

v0.2 (July 12, 2013)

  • Improved handling of image files.

v0.1 (July 11, 2013)

  • First release.

Metadata

Release files for mezzanine-meze 0.3

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

Source distributions (sdists)

Source distribution for mezzanine-meze 0.3
File Size Uploaded
mezzanine-meze-0.3.zip 13.7 kB Details
mezzanine-meze-0.3.tar.gz 10.0 kB Details

Release files / mezzanine-meze-0.3.zip

Download URL mezzanine-meze-0.3.zip
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ae9f706c063f9a5d336b16ff790884cb161ab948dbe99c73b958dd6012010c88
BLAKE2b-256 checksum
How to use checksums
a8ee455524fc1c64adfc0c5148f3d3a0f99c25dd67cd39ede8835120efdc89a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / mezzanine-meze-0.3.tar.gz

Download URL mezzanine-meze-0.3.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
004709a8eac001975d13e31b7d769b07c08fc73b6eaa68a6f82b6728d42beb60
BLAKE2b-256 checksum
How to use checksums
4e886de0486c88f8e82ae8cefa846a60fdf04810b6dc72fcb5b1ca8bc83dcaa8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.3 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2

2 release files

0.1

2 release files

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