Skip to content

night-crawler/wagtail-asciinema

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

Wagtail Asciinema

Implements asciinema-player embedding block.

Requirements (tested)

  • Python 3.5+
  • Wagtail 1.9+
  • Django 1.10

Installation

Install the library with pip:

$ pip install wagtail-asciinema

Add wagtail_asciinema to your INSTALLED_APPS setting like this:

INSTALLED_APPS = [
    ...
    'wagtail_asciinema',
]

Download asciinema-player sources from it's release page and then place it in your STATIC directory.

Add AsciinemaBlock to your StreamField:

from wagtail_asciinema.blocks import AsciinemaBlock
asciinema = AsciinemaBlock(classname='full')

You can add a method to determine if you need to include asciinema code into your static/js blocks:

from wagtail.wagtailcore.models import Page
class ArticlePage(Page):
    @property
    def has_asciinema(self):
        for stream_child in self.content:
            if stream_child.block.name == 'asciinema':
                return True
        return False

And then add asciinema on your page on demand:

{% block extra_css %}
  {% if self.has_asciinema %}
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}frontend/asciinema/v2.4.1/asciinema-player.css">
  {% endif %}
{% endblock %}
{% block extra_js %}
  {% if self.has_asciinema %}
    <script src="{{ STATIC_URL }}frontend/asciinema/v2.4.1/asciinema-player.js"></script>
  {% endif %}
{% endblock %}

About

Implements Wagtail CMS asciinema integration

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published