/django_summernote/settings.py

https://github.com/nidico/django-summernote · Python · 81 lines · 73 code · 8 blank · 0 comment · 0 complexity · 0c65b92a38eed096e9cf93a36a918d84 MD5 · raw file

  1. import os
  2. import uuid
  3. from datetime import datetime
  4. from django.conf import settings
  5. def uploaded_filepath(instance, filename):
  6. ext = filename.split('.')[-1]
  7. filename = "%s.%s" % (uuid.uuid4(), ext)
  8. today = datetime.now().strftime('%Y-%m-%d')
  9. return os.path.join('django-summernote', today, filename)
  10. SETTINGS_USER = getattr(settings, 'SUMMERNOTE_CONFIG', {})
  11. SETTINGS_DEFAULT = {
  12. 'iframe': True,
  13. 'airMode': False,
  14. 'empty': ('<p><br/></p>', '<p><br></p>'),
  15. 'width': 720,
  16. 'height': 480,
  17. 'toolbar': [
  18. ['style', ['style']],
  19. ['font', ['bold', 'italic', 'underline', 'superscript', 'subscript',
  20. 'strikethrough', 'clear']],
  21. ['fontname', ['fontname']],
  22. ['fontsize', ['fontsize']],
  23. ['color', ['color']],
  24. ['para', ['ul', 'ol', 'paragraph']],
  25. ['height', ['height']],
  26. ['table', ['table']],
  27. ['insert', ['link', 'picture', 'video', 'hr']],
  28. ['view', ['fullscreen', 'codeview']],
  29. ['help', ['help']],
  30. ],
  31. 'lang': None,
  32. 'lang_matches': {
  33. 'ar': 'ar-AR',
  34. 'ca': 'ca-ES',
  35. 'cs': 'cs-CZ',
  36. 'da': 'da-DK',
  37. 'de': 'de-DE',
  38. 'es': 'es-ES',
  39. 'fa': 'fa-IR',
  40. 'fr': 'fr-FR',
  41. 'hu': 'hu-HU',
  42. 'id': 'id-ID',
  43. 'it': 'it-IT',
  44. 'ja': 'ja-JP',
  45. 'ko': 'ko-KR',
  46. 'nb': 'nb-NO',
  47. 'nl': 'nl-NL',
  48. 'pl': 'pl-PL',
  49. 'pt': 'pt-BR',
  50. 'ro': 'ro-RO',
  51. 'ru': 'ru-RU',
  52. 'sr': 'sr-RS',
  53. 'sv': 'sv-SE',
  54. 'tr': 'tr-TR',
  55. 'uk': 'uk-UA',
  56. 'vi': 'vi-VN',
  57. 'zh': 'zh-CN',
  58. 'zh': 'zh-TW',
  59. },
  60. 'attachment_upload_to': uploaded_filepath,
  61. 'attachment_storage_class': None,
  62. 'attachment_filesize_limit': 1024 * 1024,
  63. 'inplacewidget_external_css': (
  64. '//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css',
  65. '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css',
  66. ),
  67. 'inplacewidget_external_js': (
  68. '//code.jquery.com/jquery-1.9.1.min.js',
  69. '//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js',
  70. ),
  71. }
  72. summernote_config = SETTINGS_DEFAULT.copy()
  73. summernote_config.update(SETTINGS_USER)