4
0
Bifurcation 1
This project has been migrated to https://framagit.org/cliss21/wagtail-webradio
Ce dépôt a été archivé le 2023-06-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
 
 
 
 
 
 
Aller au fichier
Antoine 2da89b5da2 fix(models): enlarge magic buffer 2022-05-09 18:41:00 +02:00
examples/player doc: provide an example of CSS for the player 2022-02-28 19:22:13 +01:00
tests feat(models): add url property to Podcast 2022-05-09 17:15:46 +02:00
wagtail_webradio fix(models): enlarge magic buffer 2022-05-09 18:41:00 +02:00
.babelrc.json build: configure eslint and rollup.js to bundle scripts 2022-02-26 21:30:41 +01:00
.browserslistrc build: configure eslint and rollup.js to bundle scripts 2022-02-26 21:30:41 +01:00
.editorconfig build: configure eslint and rollup.js to bundle scripts 2022-02-26 21:30:41 +01:00
.eslintignore style: fix the ignore rules for eslint 2022-02-28 18:21:23 +01:00
.eslintrc.json build: configure eslint and rollup.js to bundle scripts 2022-02-26 21:30:41 +01:00
.gitattributes feat(components): add a player component with django-unicorn 2022-02-28 14:10:39 +01:00
.gitignore build: configure eslint and rollup.js to bundle scripts 2022-02-26 21:30:41 +01:00
.prettierrc build: configure eslint and rollup.js to bundle scripts 2022-02-26 21:30:41 +01:00
CHANGELOG.md release 0.4.0 2022-05-09 17:52:03 +02:00
LICENSE feat(build): create a void pip package 2021-08-05 10:23:39 +02:00
MANIFEST.in ref: rename wagtailwebradio to wagtail_webradio 2021-11-25 11:14:16 +01:00
Makefile build: update Makefile rules for build and upload 2022-02-22 17:02:42 +01:00
README.md doc(readme): notes about settings 2022-05-09 16:58:38 +02:00
package-lock.json feat(components): add a player component with django-unicorn 2022-02-28 14:10:39 +01:00
package.json build(js): add a watch rule for rollup 2022-02-28 18:19:05 +01:00
pyproject.toml build: remove setup.py and deprecated setuptools-scm usage 2022-02-14 15:19:33 +01:00
rollup.config.js feat: replace server side validation of sound_url by client side 2022-02-28 18:16:51 +01:00
setup.cfg feat(models): add a sound_file field to upload an audio file 2022-05-09 16:58:38 +02:00
setup.py fix(build): restore setup.py, needed for developpement mode 2022-03-17 11:36:37 +01:00

README.md

wagtail-webradio

Manage your web radio - e.g. podcats, programs - in Wagtail.

Warning! This project is still early on in its development lifecycle. It is possible for breaking changes to occur between versions until reaching a stable 1.0. Feedback and pull requests are welcome.

Requirements

This package requires the following:

  • Wagtail (2.15 LTS)
  • Django (3.1, 3.2)
  • Python 3 (3.7, 3.8, 3.9)

Installation

  1. Install using pip:
    pip install wagtail-webradio
    
  2. Add wagtail_webradio to your INSTALLED_APPS setting:
    INSTALLED_APPS = [
        # ...
        'wagtail_webradio',
        # ...
    ]
    
  3. Run python manage.py migrate to create the models

Configuration

If you want, you can disable the possibility to upload a sound file or restrict to a custom authorized MIME types in your setting file:

# settings.py

WEBRADIO_SOUND_FILE = False  # default to True
WEBRADIO_AUTHORIZED_MIME_TYPES = ['audio/mpeg', 'audio/flac']

default authorized MIME types are audio/ogg, audio/mpeg, audio/flac, and audio/opus.

Usage

Frontend components

A player with a playlist management is provided to be easily included into your frontend. Under the hood, it uses django-unicorn with a bit of JavaScript to manipulate the audio from the Web browser. It is currently unstyled but you can find an example when using Bootstrap. You should also have a look to the template of this component to know how to extend it.

To make use of it:

  1. Install the player extra of this package:
    pip install wagtail-webradio[player]
    
  2. Integrate Unicorn in your project by following the documentation
  3. Configure Unicorn settings to look for this package's components:
    UNICORN = {
        'APPS': ['wagtail_webradio'],
    }
    

Then, e.g. in base.html, load the player scripts in the <head> of your document and the component in the <body>:

<html>
  <head>
    <!-- […] -->

    <script src="{% static "wagtail_webradio/player/js/main.js" %}" defer></script>
  </head>
  <body>
    <! -- […] -->

    {% unicorn "player" %}

    <! -- […] -->
  </body>
</html>

In the case of multi-process production environment, you must switch to redis, memcache or database caching to make Unicorn working correctly. For example with memcache listening through unix socket, you can add in settings.py :

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache',
        'LOCATION': 'unix:/var/run/memcached/memcached.sock',
    }
}

When the player scripts are loaded, you can simply add a song to the playlist by defining a data-player-add-podcast or data-player-add attribute on an element, and optionally data-player-autoplay to play the song once added:

<button data-player-add-podcast="10" data-player-autoplay>Add a podcast by id</button>

<button data-player-add="{'title': 'Title', 'subtitle': 'Subtitle', 'url': 'http://example.org/song.ogg', 'thumbnail_url': 'http://example.org/thumb.png'}">
  Add a song
</button>

Development

Quick start

To set up a development environment, ensure that Python 3 is installed on your system. Then:

  1. Clone this repository
  2. Create a virtual environment and activate it:
    python3 -m venv venv
    source venv/bin/activate
    
  3. Install this package in develop mode with extra requirements:
    pip install -e .[test]
    

If you plan to upload the package on PyPi, you will also need to run:

pip install --upgrade build twine

Contributing

The Python code is formatted and linted thanks to flake8, isort and black. To ease the use of this tools, the following commands are available:

  • make lint: check the Python code syntax and imports order
  • make format: fix the Python code syntax and imports order

The tests are written with pytest and code coverage is measured with coverage. You can use the following commands for that:

  • make test: run the tests and output a quick report of code coverage
  • make coverage: run the tests and produce an HTML report of code coverage

When submitting a pull-request, please ensure that the code is well formatted and covered, and that all the other tests pass.

License

This extension is mainly developed by Cliss XXI and licensed under the AGPLv3+. Any contribution is welcome!