From af71957641e778bcf058e691151620f0ebb1a612 Mon Sep 17 00:00:00 2001 From: Zowie Date: Fri, 14 Jul 2017 00:38:55 +0200 Subject: [PATCH] Update readme, templates and fix manifest.in for building the pkg --- MANIFEST.in | 6 +-- README.md | 35 +++++++------- djangocms_slider_uploadcare/__init__.py | 2 +- djangocms_slider_uploadcare/cms_plugins.py | 4 +- djangocms_slider_uploadcare/models.py | 13 ++---- .../templates/djangocms_slider/slide.html | 8 ---- .../templates/djangocms_slider/slider.html | 46 ------------------- .../djangocms_slider_uploadcare/slide.html | 15 ++++++ .../djangocms_slider_uploadcare/slider.html | 29 ++++++++++++ setup.py | 8 ++-- 10 files changed, 72 insertions(+), 94 deletions(-) delete mode 100644 djangocms_slider_uploadcare/templates/djangocms_slider/slide.html delete mode 100644 djangocms_slider_uploadcare/templates/djangocms_slider/slider.html create mode 100644 djangocms_slider_uploadcare/templates/djangocms_slider_uploadcare/slide.html create mode 100644 djangocms_slider_uploadcare/templates/djangocms_slider_uploadcare/slider.html diff --git a/MANIFEST.in b/MANIFEST.in index db02935..19e2c42 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1 @@ -include LICENSE.txt -include README.md -recursive-include djangocms_slider/locale * -recursive-include djangocms_slider/templates * -recursive-exclude * *.py[co] +recursive-include djangocms_slider_uploadcare *.html *.png *.gif *js *jpg *jpeg *svg *py *css *po *mo \ No newline at end of file diff --git a/README.md b/README.md index 755937f..3d5f8c3 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,14 @@ -djangocms-slider +djangocms-slider-easy-uploadcare ================ -#WARNING: NOT SUITABLE FOR REUSE -Haven't had time to add a couple things that make it reusable.. :) - -A simple django cms slideshow plugin. For of https://github.com/urga/djangocms-slider, but using easy-thumbnails by default. +A simple django cms slideshow plugin. Fork of https://github.com/urga/djangocms-slider, but using uploadcare. Features: * There are 2 plugins: SlideShow and Slide. A SlideShow can only contains Slides. Those can be arranged in the order you want just like any other plugin. * Each image can have a url specified (creating an anchor around the image) * By default, creates a [flexslider](http://www.woothemes.com/flexslider/) slideshow. -* By default, uses [easy-thumbnails](https://github.com/SmileyChris/easy-thumbnails) as a thumbnail plugin. -* Allows use of a custom thumbnail configuration in Django settings, using an `slider_thumb_id` field that should correspond to your id in THUMBNAIL_ALIASES. - -So a settings of `'home_slider': {'size': (400, 200), 'crop': False},` in your `THUMBNAIL_ALIASES`, and a `slider_thumb_id` of `home_slider` in your Slider plugin/model (with `use_simple_settings` set to False) will result in the images being 400x200 instead of the settings in the `slide.html` template. - -Of course, you can still override templates. +* Uses the uploadcare 3.0.1 widget to enable free cropping (currently no setting to enable self-defined cropping dimensions) Installation ------------ @@ -25,12 +17,19 @@ This plugin requires `django CMS 3.0` or higher to be properly installed and con To install: -* run `pip install djangocms-slider-easy` on your virtualenv -* add `easy_thumbnails` to your `INSTALLED_APPS` setting if you want to use default template. -* add `djangocms_slider` to your `INSTALLED_APPS` setting (mind the underscore) -* Run `./manage.py migrate djangocms_slider` +* run `pip install djangocms-slider-easy-uploadcare` on your virtualenv +* Make sure `pyuploadcare` is configured with the `UPLOADCARE` setting +* add `djangocms_slider_uploadcare` to your `INSTALLED_APPS` setting (mind the underscore) +* Run `./manage.py migrate djangocms_slider_uploadcare` + + +### Why use this plugin? + +- Uploadcare is pretty great with an awesome widget, and very good at serving images *fast* +- If you've stumbled upon the well-known performance issues regarding cloud storage in combination with `easy-thumbnails` and `sorl-thumbnail` -Usage ------ +### Own Flexslider config? +This can be done by overriding the `slider.html` template. -To override the template, just add `slider.html` and or 'slide.html' in a django template directory under `templates/djangocms_slider`. +- Place a `djangocms_slider_uploadcare` directory with a `slider.html` in your `templates` directory +- In this `slider.html`, copy the original contents of `slider.html` and edit the Flexslider config included in it diff --git a/djangocms_slider_uploadcare/__init__.py b/djangocms_slider_uploadcare/__init__.py index 0404d81..40ed83d 100644 --- a/djangocms_slider_uploadcare/__init__.py +++ b/djangocms_slider_uploadcare/__init__.py @@ -1 +1 @@ -__version__ = '0.3.0' +__version__ = '0.3.5' diff --git a/djangocms_slider_uploadcare/cms_plugins.py b/djangocms_slider_uploadcare/cms_plugins.py index 6287eeb..f11ab8d 100644 --- a/djangocms_slider_uploadcare/cms_plugins.py +++ b/djangocms_slider_uploadcare/cms_plugins.py @@ -10,7 +10,7 @@ class UploadcareSlidePlugin(CMSPluginBase): model = UploadcareSlide module = _("Slider") name = _("Slide") - render_template = 'djangocms_slider/slide.html' + render_template = 'djangocms_slider_uploadcare/slide.html' plugin_pool.register_plugin(UploadcareSlidePlugin) @@ -19,7 +19,7 @@ class UploadcareSliderPlugin(CMSPluginBase): model = UploadcareSlider name = _('Slider') module = _("Slideshow") - render_template = 'djangocms_slider/slider.html' + render_template = 'djangocms_slider_uploadcare/slider.html' allow_children = True child_classes = ["UploadcareSlidePlugin"] diff --git a/djangocms_slider_uploadcare/models.py b/djangocms_slider_uploadcare/models.py index 13e5647..57fba6a 100644 --- a/djangocms_slider_uploadcare/models.py +++ b/djangocms_slider_uploadcare/models.py @@ -1,4 +1,3 @@ -import os from cms.models import CMSPlugin, Page from cms.utils.compat.dj import python_2_unicode_compatible from django.core.exceptions import ValidationError @@ -23,7 +22,7 @@ class UploadcareSlide(CMSPlugin): A Slide plugin that contains an image and some text. """ - image = ImageField(manual_crop="") + image = ImageField(manual_crop="", ) url = models.CharField( _("link"), max_length=255, blank=True, null=True, help_text=_("If present, clicking on image will take user to link.")) @@ -41,14 +40,8 @@ class UploadcareSlide(CMSPlugin): def __str__(self): if self.caption: return self.caption[:40] - elif self.image: - # added if, because it raised attribute error when file wasn't - # defined. - try: - return u"%s" % os.path.basename(self.image.name) - except AttributeError: - pass - return u"" + else: + return "Uploadcare Image" def clean(self): if self.url and self.page_link: diff --git a/djangocms_slider_uploadcare/templates/djangocms_slider/slide.html b/djangocms_slider_uploadcare/templates/djangocms_slider/slide.html deleted file mode 100644 index 5faf5a7..0000000 --- a/djangocms_slider_uploadcare/templates/djangocms_slider/slide.html +++ /dev/null @@ -1,8 +0,0 @@ -{% load thumbnail %} - -
  • - {{ instance.alt }} -
  • diff --git a/djangocms_slider_uploadcare/templates/djangocms_slider/slider.html b/djangocms_slider_uploadcare/templates/djangocms_slider/slider.html deleted file mode 100644 index 54f2c57..0000000 --- a/djangocms_slider_uploadcare/templates/djangocms_slider/slider.html +++ /dev/null @@ -1,46 +0,0 @@ -{% load sekizai_tags cms_tags %} -
    -
      - {% autoescape off %} - {% with slider_thumb_id=instance.slider_thumb_id simple_settings=instance.use_simple_settings %} - {% for plugin in instance.child_plugin_instances %} - {% render_plugin plugin %} - {% comment %} -
    • -
      - {% if instance.url or instance.page_link %} - {{ image }} - - {{ image.name }} - - {{ image.name }} - {% endif %} -
      -
    • - {% endcomment %} - {% endfor %} - {% endwith %} - {% endautoescape %} -
    -
    - -{% addtoblock "css" %} - -{% endaddtoblock %} - -{% addtoblock "js" %} - - -{% endaddtoblock %} diff --git a/djangocms_slider_uploadcare/templates/djangocms_slider_uploadcare/slide.html b/djangocms_slider_uploadcare/templates/djangocms_slider_uploadcare/slide.html new file mode 100644 index 0000000..43d863e --- /dev/null +++ b/djangocms_slider_uploadcare/templates/djangocms_slider_uploadcare/slide.html @@ -0,0 +1,15 @@ +
  • + {% if instance.url or instance.page_link %} + + {{ instance.alt }} + + {% else %} + {{ instance.alt }} + {% endif %} +
  • diff --git a/djangocms_slider_uploadcare/templates/djangocms_slider_uploadcare/slider.html b/djangocms_slider_uploadcare/templates/djangocms_slider_uploadcare/slider.html new file mode 100644 index 0000000..31f9f57 --- /dev/null +++ b/djangocms_slider_uploadcare/templates/djangocms_slider_uploadcare/slider.html @@ -0,0 +1,29 @@ +{% load sekizai_tags cms_tags %} +
    +
      + {% autoescape off %} + {% for plugin in instance.child_plugin_instances %} + {% render_plugin plugin %} + {% endfor %} + {% endautoescape %} +
    +
    + +{% addtoblock "css" %} + +{% endaddtoblock %} + +{% addtoblock "js" %} + + +{% endaddtoblock %} diff --git a/setup.py b/setup.py index 5794d2f..10f0f3d 100755 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ def read(fname): INSTALL_REQUIRES = [ "django>=1.8.0, <1.11", "django-cms>=3.0", - "easy-thumbnails==2.3", + "pyuploadcare==2.2.1", ] CLASSIFIERS = [ @@ -45,9 +45,9 @@ def read(fname): author_email="zowie@akoten.com", description="A slider plugin for djangocms that lets you arrange slides like any other djangocms plugin. Fork of urga/djangocms-slider, but using uploadcare.", license="BSD", - keywords=["slideshow", "django", "cms", "plugin"], - url="https://github.com/Akoten/djangocms-slider-easy-uploadcare", - packages=['djangocms_slider_uploadcare', 'djangocms_slider_uploadcare.migrations'], + keywords=["slideshow", "django", "cms", "plugin", "uploadcare", "flexslider", "jquery"], + url="https://github.com/Zowie/djangocms-slider-easy-uploadcare", + packages=['djangocms_slider_uploadcare'], install_requires=INSTALL_REQUIRES, classifiers=CLASSIFIERS, long_description=read('README.md'),