From a4e010e4da061f93c77b2ce3142819145e170912 Mon Sep 17 00:00:00 2001 From: Dominique PERETTI Date: Tue, 5 Sep 2017 20:22:27 +0200 Subject: [PATCH 1/2] - Python 3 compatible. - Updated Docker development environment. - Now builds an optimized, minified version of wagtailmedium.js --- Documentation.codestory/data.codestory | 24 +- README.rst | 6 + docker/Dockerfile | 10 +- docker/launch.sh | 2 +- project/wagtailmedium/rich_text.py | 3 +- .../static/wagtailmedium/wagtailmedium.js | 36916 +--------------- src/webpack.config.js | 11 +- 7 files changed, 74 insertions(+), 36898 deletions(-) diff --git a/Documentation.codestory/data.codestory b/Documentation.codestory/data.codestory index c566018..eaf0e14 100644 --- a/Documentation.codestory/data.codestory +++ b/Documentation.codestory/data.codestory @@ -934,6 +934,24 @@ "settings": {}, "title": "What is Wagtailmedium ?" }, + { + "items": [ + { + "content": [ + { + "text": "docker-compose run --rm webpack /node_modules/.bin/webpack --config /src/webpack.config.js --optimize-minimize", + "type": "command" + } + ], + "ref": "b4bca1b0-9266-11e7-867c-7f6e91203e0a", + "settings": {}, + "type": "shell" + } + ], + "ref": "a5818da0-9266-11e7-8b2d-23764f7fce9f", + "settings": {}, + "title": "Building for production" + }, { "items": [ { @@ -1415,6 +1433,10 @@ "ref": "c30ce700-bad2-11e6-b645-b93d7aab43b9", "type": "note" }, + { + "ref": "a5818da0-9266-11e7-8b2d-23764f7fce9f", + "type": "note" + }, { "ref": "2b79c340-c98d-11e5-82ac-c145e5c0a4b3", "type": "note" @@ -1425,7 +1447,7 @@ } ], "selectedNotes": [ - "2b79c340-c98d-11e5-82ac-c145e5c0a4b3" + "a5818da0-9266-11e7-8b2d-23764f7fce9f" ] } } \ No newline at end of file diff --git a/README.rst b/README.rst index 8be3e68..fe73334 100644 --- a/README.rst +++ b/README.rst @@ -9,6 +9,12 @@ Wagtailmedium is a Medium Editor integration for the Wagtail CMS. **Note**: A more detailed documentation is available in `.codestory `_ format, along with a sample project to fiddle with. +Features +-------- +- Compatible with Wagtail internal links, plus the ability to add url fragments. +- Configurable from the Django settings. +- Ability to create custom buttons (ex: text marker). + Install ------- diff --git a/docker/Dockerfile b/docker/Dockerfile index a6c2885..833dd4e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,14 +1,14 @@ #Clcnt# -FROM debian:8 -RUN apt-get update &&\ - apt-get install -y python python-pip libjpeg-dev zlib1g-dev libpython-dev &&\ - apt-get clean +FROM python:3.6 + +# Get and install pip latest +RUN curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | python3.6 # for debugging RUN pip install ipdb # this will also trigger the install of Django -RUN pip install wagtail==1.7 +RUN pip install wagtail==1.12.1 # create a wagtail starter site # RUN mkdir -p /data/wagtail && cd /data/wagtail && wagtail start mysite diff --git a/docker/launch.sh b/docker/launch.sh index bcd5bc6..ff88218 100644 --- a/docker/launch.sh +++ b/docker/launch.sh @@ -6,6 +6,6 @@ set -e # no database yet ? let's run the migrations and fixtures #vkJmM# if [ ! -f /db/db.sqlite3 ]; then python manage.py migrate - python manage.py shell -c "execfile('fixture.py')" + python manage.py shell -c "exec(open('fixture.py').read())" fi exec "$@" diff --git a/project/wagtailmedium/rich_text.py b/project/wagtailmedium/rich_text.py index 05c4f65..2de3e25 100755 --- a/project/wagtailmedium/rich_text.py +++ b/project/wagtailmedium/rich_text.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, unicode_literals import json +import six from django.forms import widgets from wagtail.utils.widgets import WidgetWithScript @@ -35,7 +36,7 @@ def build_medium_js_config(options): """ extensions = [] custom_buttons = options.get('custom_buttons') - for name, config in custom_buttons.iteritems(): + for name, config in six.iteritems(custom_buttons): config.update(dict(name=name)) extensions.append(""" %s: new (MediumEditor.MediumButtonFactory(%s))() diff --git a/project/wagtailmedium/static/wagtailmedium/wagtailmedium.js b/project/wagtailmedium/static/wagtailmedium/wagtailmedium.js index 4d6e0d1..cce3a14 100644 --- a/project/wagtailmedium/static/wagtailmedium/wagtailmedium.js +++ b/project/wagtailmedium/static/wagtailmedium/wagtailmedium.js @@ -1,36889 +1,27 @@ -/******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; - -/******/ // The require function -/******/ function __webpack_require__(moduleId) { - -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) -/******/ return installedModules[moduleId].exports; - -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ exports: {}, -/******/ id: moduleId, -/******/ loaded: false -/******/ }; - -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); - -/******/ // Flag the module as loaded -/******/ module.loaded = true; - -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } - - -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; - -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; - -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = "/static/wagtailmedium/"; - -/******/ // Load entry module and return exports -/******/ return __webpack_require__(0); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - __webpack_require__(14); - - var _mediumEditor = __webpack_require__(18); - - var _mediumEditor2 = _interopRequireDefault(_mediumEditor); - - var _LinkButton = __webpack_require__(20); - - var _LinkButton2 = _interopRequireDefault(_LinkButton); - - var _LinkDocButton = __webpack_require__(23); - - var _LinkDocButton2 = _interopRequireDefault(_LinkDocButton); - - var _LinkPreview = __webpack_require__(24); - - var _LinkPreview2 = _interopRequireDefault(_LinkPreview); - - var _MediumButtonFactory = __webpack_require__(213); - - var _MediumButtonFactory2 = _interopRequireDefault(_MediumButtonFactory); - - __webpack_require__(214); - - __webpack_require__(216); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - // Make MediumEditor and related globally available - // #8VVkT# - window.MediumEditor = { - MediumEditor: _mediumEditor2.default, - LinkButton: _LinkButton2.default, - LinkDocButton: _LinkDocButton2.default, - LinkPreview: _LinkPreview2.default, - MediumButtonFactory: _MediumButtonFactory2.default - }; - -/***/ }, -/* 1 */, -/* 2 */, -/* 3 */, -/* 4 */, -/* 5 */, -/* 6 */, -/* 7 */, -/* 8 */, -/* 9 */, -/* 10 */, -/* 11 */, -/* 12 */, -/* 13 */, -/* 14 */ -/***/ function(module, exports, __webpack_require__) { - - // style-loader: Adds some css to the DOM by adding a