Skip to content

Commit

Permalink
Merge 0d2e88d into bfe6091
Browse files Browse the repository at this point in the history
  • Loading branch information
FinalAngel committed Jul 28, 2016
2 parents bfe6091 + 0d2e88d commit ad6fef5
Show file tree
Hide file tree
Showing 28 changed files with 966 additions and 1 deletion.
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# editorconfig.org

root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 80

[*.{html,js}]
max_line_length = 120

[*.yml]
indent_size = 2

[Makefile]
indent_style = tab
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.pyc
*.egg-info
.DS_Store
.idea/
.tox/
dist/
build/
30 changes: 30 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Config file for automatic testing at travis-ci.org

language: python

sudo: false

env:
- TOX_ENV=flake8
- TOX_ENV=py27-latest
- TOX_ENV=py34-latest
# Django 1.8
- TOX_ENV=py34-dj18-cms33
- TOX_ENV=py34-dj18-cms32
- TOX_ENV=py27-dj18-cms33
- TOX_ENV=py27-dj18-cms32
# Django 1.9
- TOX_ENV=py34-dj19-cms33
- TOX_ENV=py34-dj19-cms32
- TOX_ENV=py27-dj19-cms33
- TOX_ENV=py27-dj19-cms32

install:
- pip install tox
- pip install coveralls

script:
- tox -e $TOX_ENV

after_success:
- coveralls
8 changes: 8 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[main]
host = https://www.transifex.com

[djangocms-audio.djangocms_audio]
file_filter = djangocms_audio/locale/<lang>/LC_MESSAGES/django.po
source_file = djangocms_audio/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
=========
Changelog
=========


0.1.0 (to be released)
==================

* Initial release
24 changes: 24 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (c) 2016, Divio AG
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Divio AG nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL DIVIO AG BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
recursive-include djangocms_audio/templates *
recursive-include djangocms_audio/static *
recursive-include djangocms_audio/locale *
99 changes: 98 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1 +1,98 @@
# djangocms-audio
================
django CMS Audio
================


|pypi| |build| |coverage|

**django CMS Audio** is a set of plugins for `django CMS <http://django-cms.org>`_
that allow you to publish audio files on your site (using an HTML5 player by default,
but you can override this in your own templates if required).

It uses files managed by `Django Filer <https://github.com/divio/django-filer>`_.
The plugins allow you to select a single file or an entire folder of files.

This addon is compatible with `Aldryn <http://aldryn.com>`_ and is also available on the
`django CMS Marketplace <https://marketplace.django-cms.org/en/addons/browse/djangocms-googlemap/>`_
for easy installation.

.. image:: preview.gif


Contributing
============

This is a an open-source project. We'll be delighted to receive your
feedback in the form of issues and pull requests. Before submitting your
pull request, please review our `contribution guidelines
<http://docs.django-cms.org/en/latest/contributing/index.html>`_.

One of the easiest contributions you can make is helping to translate this addon on
`Transifex <https://www.transifex.com/projects/p/djangocms-audio/>`_.


Documentation
=============


See ``REQUIREMENTS`` in the `setup.py
<https://github.com/divio/djangocms-audio/blob/master/setup.py>`_ file
for additional dependencies:

* Python 2.7, 3.4 or higher
* Django 1.8 or higher


Installation
------------

For a manual install:

* run ``pip install djangocms-audio``
* add ``djangocms_audio`` to your ``INSTALLED_APPS``
* run ``python manage.py migrate djangocms_audio``


Configuration
-------------

Note that the provided templates are very minimal by design. You are encouraged
to adapt and override them to your project's requirements.

This addon provides a ``default`` template for all instances. You can provide
additional template choices by adding a ``DJANGOCMS_AUDIO_TEMPLATES``
setting::

DJANGOCMS_AUDIO_TEMPLATES = [
('feature', _('Featured Version')),
]

You'll need to create the `feature` folder inside ``templates/djangocms_audio/``
otherwise you will get a *template does not exist* error. You can do this by
copying the ``standard`` folder inside that directory and renaming it to
``feature``.

``MP3`` and ``OGG`` files are allowed by default. We recommend using ``MP3``
as it's supported across all major browsers. You can change the default
setting by overriding::

ALLOWED_EXTENSIONS = ['mp3', 'ogg', 'wav']


Running Tests
-------------

You can run tests by executing::

virtualenv env
source env/bin/activate
pip install -r tests/requirements.txt
python setup.py test


.. |pypi| image:: https://badge.fury.io/py/djangocms-audio.svg
:target: http://badge.fury.io/py/djangocms-audio
.. |build| image:: https://travis-ci.org/divio/djangocms-audio.svg?branch=master
:target: https://travis-ci.org/divio/djangocms-video
.. |coverage| image:: https://coveralls.io/repos/github/divio/djangocms-audio/badge.svg?branch=master
:target: https://coveralls.io/github/divio/djangocms-audio?branch=master
6 changes: 6 additions & 0 deletions addon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"package-name": "djangocms-audio",
"installed-apps": [
"djangocms_audio"
]
}
24 changes: 24 additions & 0 deletions aldryn_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
from aldryn_client import forms
from django.template.defaultfilters import slugify


class Form(forms.BaseForm):
templates = forms.CharField(
'List of additional templates (comma separated)',
required=False,
)
extensions = forms.CharField(
'List of allowed extensions, default "mp3, ogg" when empty (comma separated)',
required=False,
)

def clean(self, value):
for x in value.split(','):
yield (slugify(x.strip()), x)

def to_settings(self, data, settings):
settings['DJANGOCMS_AUDIO_TEMPLATES'] = self.clean(templates)
if data[extensions]:
settings['DJANGOCMS_AUDIO_ALLOWED_EXTENSIONS'] = self.clean(extensions)
return settings
2 changes: 2 additions & 0 deletions djangocms_audio/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
__version__ = '0.1.0'
125 changes: 125 additions & 0 deletions djangocms_audio/cms_plugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# -*- coding: utf-8 -*-
from django.utils.translation import ugettext_lazy as _

from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool

from . import models


class AudioPlayerPlugin(CMSPluginBase):
model = models.AudioPlayer
name = _('Audio Player')
allow_children = True
child_classes = ['AudioFilePlugin', 'AudioFolderPlugin']

fieldsets = [
(None, {
'fields': (
'template',
'label',
)
}),
(_('Advanced settings'), {
'classes': ('collapse',),
'fields': (
'attributes',
)
})
]

def render(self, context, instance, placeholder):
context = super(AudioPlayerPlugin, self).render(context, instance, placeholder)
context['audio_template'] = instance.template
return context

def get_render_template(self, context, instance, placeholder):
return 'djangocms_audio/{}/audio_player.html'.format(instance.template)


class AudioFilePlugin(CMSPluginBase):
model = models.AudioFile
name = _('File')
module = _('Audio player')
allow_children = True
require_parent = True
parent_classes = ['AudioPlayerPlugin']
child_classes = ['AudioTrackPlugin']

fieldsets = [
(None, {
'fields': (
'audio_file',
'text_title',
)
}),
(_('Advanced settings'), {
'classes': ('collapse',),
'fields': (
'text_description',
'attributes',
)
})
]

def get_render_template(self, context, instance, placeholder):
return 'djangocms_audio/{}/file.html'.format(context['audio_template'])


class AudioFolderPlugin(CMSPluginBase):
model = models.AudioFolder
name = _('Folder')
module = _('Audio player')
require_parent = True
parent_classes = ['AudioPlayerPlugin']

fieldsets = [
(None, {
'fields': (
'audio_folder',
)
}),
(_('Advanced settings'), {
'classes': ('collapse',),
'fields': (
'attributes',
)
})
]

def get_render_template(self, context, instance, placeholder):
return 'djangocms_audio/{}/folder.html'.format(context['audio_template'])


class AudioTrackPlugin(CMSPluginBase):
model = models.AudioTrack
name = _('Track')
module = _('Audio player')
require_parent = True
parent_classes = ['AudioFilePlugin']

fieldsets = [
(None, {
'fields': (
'kind',
'src',
'srclang',
)
}),
(_('Advanced settings'), {
'classes': ('collapse',),
'fields': (
'label',
'attributes',
)
})
]

def get_render_template(self, context, instance, placeholder):
return 'djangocms_audio/{}/track.html'.format(context['audio_template'])


plugin_pool.register_plugin(AudioPlayerPlugin)
plugin_pool.register_plugin(AudioFilePlugin)
plugin_pool.register_plugin(AudioFolderPlugin)
plugin_pool.register_plugin(AudioTrackPlugin)

0 comments on commit ad6fef5

Please sign in to comment.