meringue 0.3.1__py2.7.egg

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. EGG-INFO/PKG-INFO +169 -0
  2. EGG-INFO/SOURCES.txt +43 -0
  3. EGG-INFO/dependency_links.txt +1 -0
  4. EGG-INFO/requires.txt +2 -0
  5. EGG-INFO/top_level.txt +1 -0
  6. EGG-INFO/zip-safe +1 -0
  7. meringue/__init__.py +13 -0
  8. meringue/__init__.pyc +0 -0
  9. meringue/context_processors.py +11 -0
  10. meringue/context_processors.pyc +0 -0
  11. meringue/decorators.py +36 -0
  12. meringue/decorators.pyc +0 -0
  13. meringue/errors.py +8 -0
  14. meringue/errors.pyc +0 -0
  15. meringue/fields.py +64 -0
  16. meringue/fields.pyc +0 -0
  17. meringue/forms.py +57 -0
  18. meringue/forms.pyc +0 -0
  19. meringue/middleware.py +32 -0
  20. meringue/middleware.pyc +0 -0
  21. meringue/models.py +138 -0
  22. meringue/models.pyc +0 -0
  23. meringue/settings.py +83 -0
  24. meringue/settings.pyc +0 -0
  25. meringue/static/css/inline-gallery.css +93 -0
  26. meringue/static/css/reset.css +77 -0
  27. meringue/static/css/reset.min.css +1 -0
  28. meringue/static/images/noise.png +0 -0
  29. meringue/static/images/none.gif +0 -0
  30. meringue/static/js/jquery-2.1.0.min.js +4 -0
  31. meringue/templates/404.html +15 -0
  32. meringue/templates/500.html +16 -0
  33. meringue/templates/admin/filter.html +17 -0
  34. meringue/templates/meringue/edit_inline/gallery.html +81 -0
  35. meringue/templates/robots.txt +0 -0
  36. meringue/templatetags/__init__.py +0 -0
  37. meringue/templatetags/__init__.pyc +0 -0
  38. meringue/templatetags/forms_utils_new.py +91 -0
  39. meringue/templatetags/forms_utils_new.pyc +0 -0
  40. meringue/templatetags/meringue_base.py +172 -0
  41. meringue/templatetags/meringue_base.pyc +0 -0
  42. meringue/templatetags/thumbnails.py +44 -0
  43. meringue/templatetags/thumbnails.pyc +0 -0
  44. meringue/templatetags/weboven_base.py +35 -0
  45. meringue/templatetags/weboven_base.pyc +0 -0
  46. meringue/upload_handlers.py +22 -0
  47. meringue/upload_handlers.pyc +0 -0
  48. meringue/utils/__init__.py +6 -0
  49. meringue/utils/__init__.pyc +0 -0
  50. meringue/utils/admin.py +8 -0
  51. meringue/utils/admin.pyc +0 -0
  52. meringue/utils/thumbnails.py +201 -0
  53. meringue/utils/thumbnails.pyc +0 -0
  54. meringue/utils/unifying.py +32 -0
  55. meringue/utils/unifying.pyc +0 -0
  56. meringue/utils/urls.py +25 -0
  57. meringue/utils/urls.pyc +0 -0
  58. meringue/utils/version.py +15 -0
  59. meringue/utils/version.pyc +0 -0
  60. meringue/widgets.py +100 -0
  61. meringue/widgets.pyc +0 -0
meringue/widgets.py ADDED
@@ -0,0 +1,100 @@
1
+ # -*- coding:utf-8 -*-
2
+
3
+ from django import forms
4
+ from django.db import models
5
+ from django.utils.encoding import force_text
6
+ from django.utils.html import conditional_escape, format_html
7
+ from django.utils.safestring import mark_safe
8
+ from django.utils.translation import ugettext_lazy as _
9
+
10
+ from meringue.utils.thumbnails import get_thumbnail
11
+
12
+
13
+ class PreviewImageFileInput(forms.widgets.FileInput):
14
+ '''
15
+ TO-DO:
16
+ информация о изображении
17
+ изображение при инициализации
18
+ при загрузке изображения сразу же его выводить в превью (js)
19
+ '''
20
+
21
+ initial_text = _(u'Currently')
22
+ input_text = _(u'Change')
23
+ clear_checkbox_label = _(u'Clear')
24
+
25
+ preview = '<img src=\"%(src)s\" data-src=\"%(data_src)s\" >'
26
+ template_with_initial = u'<p class="file-upload">%(preview)s<br />\
27
+ %(initial_text)s: %(initial)s %(clear_template)s<br />\
28
+ %(input_text)s: %(input)s</p>'
29
+ template_with_clear = u'<span class="clearable-file-input">\
30
+ %(clear)s <label for="%(clear_checkbox_id)s">\
31
+ %(clear_checkbox_label)s</label></span>'
32
+ url_markup_template = u'<a href="{0}">{1}</a>'
33
+
34
+ def clear_checkbox_name(self, name):
35
+ """
36
+ Given the name of the file input, return the name of the clear
37
+ checkbox input.
38
+ """
39
+ return name + u'-clear'
40
+
41
+ def clear_checkbox_id(self, name):
42
+ """
43
+ Given the name of the clear checkbox input, return the HTML id
44
+ for it.
45
+ """
46
+ return name + u'_id'
47
+
48
+ def get_preview(self, value, size):
49
+ if value:
50
+ data = {
51
+ 'src': get_thumbnail(value.path, [
52
+ 's:%dx%d' % size,
53
+ 'resize',
54
+ 'crop'
55
+ ]),
56
+ 'data_src': value.url,
57
+ # 'alt': value.title,
58
+ }
59
+ else:
60
+ data = {
61
+ 'src': '',
62
+ 'data_src': '',
63
+ }
64
+ return self.preview % data
65
+
66
+ def render(self, name, value, size=(100, 100), attrs=None):
67
+ substitutions = {
68
+ 'initial_text': self.initial_text,
69
+ 'preview': self.get_preview(value, size),
70
+ 'input_text': self.input_text,
71
+ 'clear_template': u'',
72
+ 'clear_checkbox_label': self.clear_checkbox_label,
73
+ }
74
+ template = '%(input)s'
75
+ substitutions['input'] = super(PreviewImageFileInput, self).\
76
+ render(name, value, attrs)
77
+
78
+ if value and hasattr(value, "url"):
79
+ template = self.template_with_initial
80
+ substitutions['initial'] = format_html(
81
+ self.url_markup_template,
82
+ value.url,
83
+ force_text(value)
84
+ )
85
+ if not self.is_required:
86
+ checkbox_name = self.clear_checkbox_name(name)
87
+ checkbox_id = self.clear_checkbox_id(checkbox_name)
88
+ substitutions['clear_checkbox_name'] =\
89
+ conditional_escape(checkbox_name)
90
+ substitutions['clear_checkbox_id'] =\
91
+ conditional_escape(checkbox_id)
92
+ substitutions['clear'] = forms.CheckboxInput().render(
93
+ checkbox_name,
94
+ False,
95
+ attrs={'id': checkbox_id}
96
+ )
97
+ substitutions['clear_template'] =\
98
+ self.template_with_clear % substitutions
99
+
100
+ return mark_safe(template % substitutions)
meringue/widgets.pyc ADDED
Binary file