From b7a6330507a453772bf93170fd5d84ca16d3307d Mon Sep 17 00:00:00 2001 From: Erik Stein Date: Fri, 24 Aug 2018 17:17:47 +0200 Subject: [PATCH] Initial import. --- CHANGES | 2 + LICENSE | 8 ++ MANIFEST.in | 4 + README.md | 7 ++ ckeditor_extensions/__init__.py | 0 ckeditor_extensions/_version.py | 1 + .../soft-hyphen-shortcut/images/button.svg | 4 + .../plugins/soft-hyphen-shortcut/plugin.js | 27 +++++++ setup.py | 75 +++++++++++++++++++ 9 files changed, 128 insertions(+) create mode 100644 CHANGES create mode 100644 LICENSE create mode 100644 MANIFEST.in create mode 100644 README.md create mode 100644 ckeditor_extensions/__init__.py create mode 100644 ckeditor_extensions/_version.py create mode 100644 ckeditor_extensions/static/ckeditor/ckeditor/plugins/soft-hyphen-shortcut/images/button.svg create mode 100644 ckeditor_extensions/static/ckeditor/ckeditor/plugins/soft-hyphen-shortcut/plugin.js create mode 100644 setup.py diff --git a/CHANGES b/CHANGES new file mode 100644 index 0000000..18e73f6 --- /dev/null +++ b/CHANGES @@ -0,0 +1,2 @@ +0.1 2018-08-25 +- Initial release diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..472ac23 --- /dev/null +++ b/LICENSE @@ -0,0 +1,8 @@ +MIT License +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..3cba138 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,4 @@ +include AUTHORS +include LICENSE +include README.md +recursive-include ckeditor_extensions/static * diff --git a/README.md b/README.md new file mode 100644 index 0000000..42d1558 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# django-ckeditor-extensions + +## Usage + +CKEDITOR.replace('editor', { + extraPlugins: 'soft-hyphen-shortcut-key' +}); diff --git a/ckeditor_extensions/__init__.py b/ckeditor_extensions/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ckeditor_extensions/_version.py b/ckeditor_extensions/_version.py new file mode 100644 index 0000000..5e3048b --- /dev/null +++ b/ckeditor_extensions/_version.py @@ -0,0 +1 @@ +__version__ = '0.1' \ No newline at end of file diff --git a/ckeditor_extensions/static/ckeditor/ckeditor/plugins/soft-hyphen-shortcut/images/button.svg b/ckeditor_extensions/static/ckeditor/ckeditor/plugins/soft-hyphen-shortcut/images/button.svg new file mode 100644 index 0000000..db20484 --- /dev/null +++ b/ckeditor_extensions/static/ckeditor/ckeditor/plugins/soft-hyphen-shortcut/images/button.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ckeditor_extensions/static/ckeditor/ckeditor/plugins/soft-hyphen-shortcut/plugin.js b/ckeditor_extensions/static/ckeditor/ckeditor/plugins/soft-hyphen-shortcut/plugin.js new file mode 100644 index 0000000..f3711ef --- /dev/null +++ b/ckeditor_extensions/static/ckeditor/ckeditor/plugins/soft-hyphen-shortcut/plugin.js @@ -0,0 +1,27 @@ +// https://stackoverflow.com/questions/34491100/keyboard-shortcut-to-insert-text-soft-hyphen-with-ckeditor + +// Add soft-hyphen shortcut + +CKEDITOR.plugins.add('soft-hyphen-shortcut', { + init: function (editor) { + var softHyphenUnicodeChar = '\u00AD'; + var softHyphenEntity = '­'; + + editor.addCommand('insertSoftHyphen', { + exec: function (editor, data) { + editor.insertHtml(softHyphenEntity); + } + }); + + editor.ui.addButton('InsertSoftHyphen', { + label: "Shy", + command: 'insertSoftHyphen', + icon: this.path + 'images/button.svg' + }); + + // FIXME keystroke value 189, 173? + editor.setKeystroke( + CKEDITOR.CTRL + CKEDITOR.SHIFT + 173, 'insertSoftHyphen' + ); + } +}); diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..d34fe91 --- /dev/null +++ b/setup.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python + +from io import open +from setuptools import setup, find_packages +import os +import re +import subprocess + + +""" +Use `git tag -a -m "Release 1.0.0" 1.0.0` to tag a release; `python setup.py --version` +to update the _version.py file. +""" + + +def get_version(prefix): + if os.path.exists('.git'): + parts = subprocess.check_output(['git', 'describe', '--tags']).decode().strip().split('-') + if len(parts) == 3: + version = '{}.{}+{}'.format(*parts) + else: + version = parts[0] + version_py = "__version__ = '{}'".format(version) + _version = os.path.join(prefix, '_version.py') + if not os.path.exists(_version) or open(_version).read().strip() != version_py: + with open(_version, 'w') as fd: + fd.write(version_py) + return version + else: + for f in ('_version.py', '__init__.py'): + f = os.path.join(prefix, f) + if os.path.exists(f): + with open(f) as fd: + metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", fd.read())) + if 'version' in metadata: + break + return metadata['version'] + + +def read(filename): + path = os.path.join(os.path.dirname(__file__), filename) + with open(path, encoding='utf-8') as handle: + return handle.read() + + +setup( + name='django-ckeditor-extensions', + version=get_version('ckeditor_extensions'), + description='', + long_description=read('README.md'), + author='Erik Stein', + author_email='erik@classlibrary.net', + url='https://projects.c--y.net/erik/django-ckeditor-extensions/', + license='MIT License', + platforms=['OS Independent'], + packages=find_packages( + exclude=['tests', 'testapp'], + ), + include_package_data=True, + install_requires=[ + # 'django<2', commented out to make `pip install -U` easier + 'django-ckeditor', + ], + classifiers=[ + # "Development Status :: 3 - Alpha", + 'Environment :: Web Environment', + 'Framework :: Django', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: BSD License', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + 'Topic :: Utilities', + ], + zip_safe=False, +)