Skip to main content

A Mezzanine app to convert reStructuredText into HTML using Sphinx

Project description

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-hypernode.com/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 "css/meze.css" %}">
    <link rel="stylesheet" href="{% static "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 "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.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.

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

mezzanine-meze-0.2.2.zip (13.4 kB view details)

Uploaded Source

mezzanine-meze-0.2.2.tar.gz (9.8 kB view details)

Uploaded Source

File details

Details for the file mezzanine-meze-0.2.2.zip.

File metadata

  • Download URL: mezzanine-meze-0.2.2.zip
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mezzanine-meze-0.2.2.zip
Algorithm Hash digest
SHA256 c53e26041d8bf5daa12a6ece04efb2fd894558bbc68589531a0625c5e1671b61
MD5 2bd36b7f4d315067c7cc9ca539511419
BLAKE2b-256 bf8e50505ca18d76a225ae81a6f594ed291ae338d84d6584575b6a47d36d4dc4

See more details on using hashes here.

Provenance

File details

Details for the file mezzanine-meze-0.2.2.tar.gz.

File metadata

File hashes

Hashes for mezzanine-meze-0.2.2.tar.gz
Algorithm Hash digest
SHA256 6c3882ca64e889500f4fb30cb067a67cc60a80ac3c81ddaacd142b25269a9a86
MD5 34b15a56d880df2045c9ca289d62d071
BLAKE2b-256 f92ce6b1b8ba6d2956d2f3d1f7a7082a58a1487346fcea70a1d26c1557474ea2

See more details on using hashes here.

Provenance

Supported by

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