remove django-cms support

This commit is contained in:
Benjamin Dauvergne 2016-05-04 18:38:27 +02:00
parent 4069fb6481
commit 8a655f5abb
10 changed files with 0 additions and 227 deletions

2
debian/control vendored
View File

@ -11,9 +11,7 @@ Package: python-django-cmsplugin-blurp
Architecture: all
Depends: ${misc:Depends},
python (>= 2.6),
python-django-cms (>= 3),
python-django (>= 1.5),
python-django-classy-tags,
python-feedparser
Description: Django CMS plugin framework

View File

@ -1,37 +0,0 @@
from django.utils.translation import ugettext_lazy as _
from cms.plugin_pool import plugin_pool
from cms.plugin_base import CMSPluginBase
from . import models
class BlurpPlugin(CMSPluginBase):
name = _('Blurp Plugin')
text_enabled = True
model = models.PluginRenderer
render_template = ''
def render(self, context, instance, placeholder):
renderer = instance.get_renderer()
request = context.get('request')
ajax = context.get('ajaxy', True) and renderer.config.get('ajax', False)
if not ajax:
self.render_template = renderer.render_template()
return renderer.render(context)
else:
request = context.get('request')
context['plugin_id'] = instance.id
context['ajax_refresh'] = renderer.config.get('ajax_refresh', 0)
if request.GET:
context['plugin_args'] = '?{0}'.format(request.GET.urlencode())
# hack alert !!
self.render_template = 'cmsplugin_blurp/ajax.html'
return context
plugin_pool.register_plugin(BlurpPlugin)

View File

@ -16,22 +16,6 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: cms_plugins.py:9
msgid "Blurp Plugin"
msgstr "Contenu externe"
#: models.py:11
msgid "name"
msgstr "nom"
#: utils.py:9
msgid "{name} using template {template}"
msgstr "{name} via le modèle {template}"
#: templates/cmsplugin_blurp/ajax.html:30
msgid "loading..."
msgstr "chargement..."
#: templates/cmsplugin_blurp/template_not_found.html:1
msgid "Template not found"
msgstr "Template introuvable"

View File

@ -1,25 +0,0 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from . import utils
if 'cms' in settings.INSTALLED_APPS:
from cms.models import CMSPlugin
class PluginRenderer(CMSPlugin):
__renderer = None
name = models.CharField(verbose_name=_('name'),
choices=utils.renderers_choices(),
max_length=256)
def get_renderer(self):
if self.__renderer is None:
self.__renderer = utils.resolve_renderer(self.name)
return self.__renderer
def __unicode__(self):
return utils.renderer_description(self.get_renderer()) or self.name

View File

@ -1,45 +0,0 @@
{% load i18n %}
{% load sekizai_tags %}
{% addtoblock "js" %}
<script type="text/javascript">
(function($) {
if ($ == undefined) {
alert('jQuery is missing');
} else {
var $container = $("#block-plugin-ajax-{{ plugin_id }}");
var ajax_refresh = {{ ajax_refresh }};
var exponential_refresh = ajax_refresh;
var reload = function () {
$container.removeClass('block-plugin-ajax-failed');
$container.addClass('block-plugin-ajax-loading');
$.getJSON('{% url 'ajax_render' plugin_id=plugin_id %}{{ plugin_args|safe }}', function (result) {
$container.html(result.content);
$container.removeClass('block-plugin-ajax-loading');
if (ajax_refresh > 0) {
setTimeout(reload, ajax_refresh*1000);
}
exponential_refresh = ajax_refresh;
})
.fail(function (jqXHR) {
$container.addClass('block-plugin-ajax-failed');
if (ajax_refresh > 0 && jqXHR.status != 404) {
/* continue polling but use exponential backoff */
exponential_refresh = exponential_refresh * 2;
setTimeout(reload, exponential_refresh*1000);
}
})
};
$(document).ready(function(){
reload();
});
}
})($)
</script>
{% endaddtoblock %}
<div id="block-plugin-ajax-{{ plugin_id }}" class='block-plugin-ajax block-plugin-ajax-loading'>
<div class="block-plugin-ajax-placeholder">{% trans "loading..." %}</div>
</div>

View File

@ -1,4 +0,0 @@
{% load sekizai_tags %}
{{ content|safe }}
{% render_block "js" %}
{% render_block "css" %}

View File

@ -1,68 +0,0 @@
import logging
import json
from django import template
from django.conf import settings
from django.utils.html import escape
from django.core.serializers import serialize
from django.core.serializers.json import DjangoJSONEncoder
from django.db.models.query import QuerySet
from django.utils.safestring import mark_safe
from classytags.arguments import Argument
from classytags.core import Options, Tag
from .. import utils
register = template.Library()
# originally copied from django-jsonify(https://bitbucket.org/marltu/django-jsonify/)
# released under a three-clause BSD License by Marius Grigaitis
@register.filter
def jsonify(obj):
if isinstance(obj, QuerySet):
return mark_safe(serialize('json', obj))
return mark_safe(json.dumps(obj, cls=DjangoJSONEncoder))
@register.tag
class RenderBlurp(Tag):
name = 'render_blurp'
options = Options(
Argument('name', resolve=False),
)
def render_tag(self, context, name):
renderer = utils.resolve_renderer(name)
if not renderer:
return ''
template = renderer.render_template()
context = renderer.render(context)
try:
if not hasattr(template, 'render'):
template = template.Template(template)
return template.render(context)
except Exception, e:
logging.getLogger(__name__).exception('error while rendering %s',
renderer)
msg = ''
if settings.TEMPLATE_DEBUG:
msg += 'error while rendering %s: %s' % (renderer, e)
msg = '<pre>%s</pre>' % escape(msg)
return msg
@register.tag
class BlurpNode(Tag):
'''Insert content generated from a blurp block and render inside template'''
name = 'blurp'
options = Options(
Argument('name'),
blocks=[('endblurp', 'nodelist')])
def render_tag(self, context, name, nodelist):
context.push()
utils.insert_blurp_in_context(name, context)
output = self.nodelist.render(context)
context.pop()
return output

View File

@ -1,9 +0,0 @@
from django.conf.urls import patterns, url
from . import views
urlpatterns = patterns('',
url(r'^block-plugin-async/(?P<plugin_id>\d+)/$',
views.ajax_render,
name='ajax_render')
)

View File

@ -1,21 +0,0 @@
import json
import logging
from django.http import HttpResponse
from django.template import RequestContext, loader
from django.shortcuts import get_object_or_404
from cms.models import CMSPlugin
logger = logging.getLogger(__name__)
def ajax_render(request, plugin_id):
context = RequestContext(request)
context['ajaxy'] = False
plugin = get_object_or_404(CMSPlugin, pk=plugin_id)
rendered = plugin.render_plugin(context)
# use another template to render accumulated js and css declarations from sekizai
content = loader.render_to_string('cmsplugin_blurp/sekizai_render.html',
{'content': rendered}, context)
return HttpResponse(json.dumps({'content': content}))