]> git.0d.be Git - panikdb.git/commitdiff
remove wiki stuff, moved to its own module
authorFrédéric Péters <fpeters@0d.be>
Thu, 29 Oct 2020 07:22:38 +0000 (08:22 +0100)
committerFrédéric Péters <fpeters@0d.be>
Thu, 29 Oct 2020 07:22:38 +0000 (08:22 +0100)
panikdb/settings.py
panikdb/static/css/style.scss
panikdb/static/js/combo.wiki.js [deleted file]
panikdb/templates/combo/page_template_sidebar.html [deleted file]
panikdb/urls.py
panikdb/wiki/__init__.py [deleted file]
panikdb/wiki/forms.py [deleted file]
panikdb/wiki/templates/wiki/new_page.html [deleted file]
panikdb/wiki/urls.py [deleted file]
panikdb/wiki/views.py [deleted file]

index 19760226263a46453d369f823275ee6f1194c148..3bc5d531bb158b40968b725ccfd353141d2cb79d 100644 (file)
@@ -151,13 +151,13 @@ INSTALLED_APPS = (
     'emissions',
     'newsletter',
     'matos',
+    'wiki',
     'nonstop',
     'panikdb.aa',
     'panikdb.customtags',
     'panikdb.regie',
     'panikdb.stats',
     'panikdb.poll',
-    'panikdb.wiki',
     'gadjo',
     'combo.data',
     'combo.profile',
index 4fe61ef80344ea80ed637b0fed56aa923486f970..e9ce77b09e46a360a972adb01d975cceba0586da 100644 (file)
@@ -752,222 +752,6 @@ div#content div.section > h3 {
        margin-bottom: 0;
 }
 
-div#content div.wiki-section h3 {
-       margin-bottom: 0;
-}
-
-#quickedit {
-       position: absolute;
-       top: 0.15em;
-       right: 2px;
-       label {
-               display: inline-block;
-               margin-left: 6px;
-               cursor: pointer;
-       }
-       input {
-               display: none;
-       }
-
-       button,
-       span {
-               display: inline-block;
-               font-weight: normal;
-               background: white;
-               border: 1px solid #386ede;
-               padding: 1ex;
-               border-radius: 3px;
-               color: #386ede;
-       }
-       button:hover {
-               &:hover {
-                       color: white;
-                       background: #386ede;
-               }
-       }
-
-       input:checked + span {
-               background: #386ede;
-               color: white;
-       }
-}
-
-div[contenteditable=true] {
-       outline: 2px solid #386ede;
-       outline-offset: 12px;
-}
-
-.inline-style-popup,
-.block-style-popup {
-       background: white;
-       box-shadow: 0 0 5px #666;
-       input {
-               display: none;
-               margin: 0;
-               padding: 3px;
-               border: 1px inset #ccc;
-               background: white;
-               width: 0px;
-               transition: width ease 2s;
-               &.shown {
-                       display: inline-block;
-                       width: 400px;
-               }
-       }
-       button {
-               padding: 0 0.5em;
-               height: 2em;
-               text-align: center;
-               font-weight: normal;
-               color: #333;
-               background: #eee;
-               border: 0px;
-               &:hover {
-                       background: #ccc;
-               }
-               &[data-action=createLink] {
-                       color: blue;
-                       text-decoration: underline;
-               }
-               &.on {
-                       background: #444;
-                       color: white;
-               }
-       }
-       &.inline-style-popup button {
-               width: 2em;
-               padding: 0;
-       }
-       &.block-style-popup {
-               &.selected button {
-                       display: none;
-                       &.on {
-                               display: block;
-                       }
-               }
-       }
-}
-
-div.wiki-section {
-       position: relative;
-       margin: 0 auto;
-       max-width: 45em;
-       font-size: 16px;
-       border: none;
-       line-height: 150%;
-       pre.code {
-               background: #111;
-               color: white;
-               padding: 2px;
-               max-width: 100%;
-               overflow: auto;
-               font-size: 90%;
-       }
-       div.note {
-               margin: 1em auto;
-               width: 80%;
-               border: 1px solid #babdb6;
-               background: #F3F3F0 url(../images/yelp-note.png) no-repeat 1ex 1ex;
-               padding: 1ex 1ex 1ex 7ex;
-               p:first-child {
-                       margin-top: 0;
-               }
-       }
-       [contenteditable=true] div.figure {
-               cursor: pointer;
-       }
-       div.document,
-       div.figure {
-               text-align: center;
-               line-height: initial;
-               img {
-                       max-width: 90%;
-                       max-height: 70vh;
-               }
-               span.empty::before {
-                       min-height: 50px;
-                       margin: 0 auto;
-                       display: block;
-                       width: 90%;
-                       background: #eee;
-                       padding: 1rem;
-                       font-size: 200px;
-                       content: "\f03e";
-                       color: #aaa;
-                       font-family: FontAwesome;
-               }
-       }
-       div.document a {
-               &::before {
-                       content: "\f019";
-                       font-family: FontAwesome;
-                       padding-right: 0.7em;
-               }
-       }
-       div.document span.empty::before {
-               content: "\f0f6";  // fa-file-text-o
-       }
-       div[contenteditable] {
-               a[href^="/wiki/"] {
-                       box-shadow: inset 0 -8px 0 0 rgba(34, 27, 242,0.1);
-                       color: #073593;
-                       transition: box-shadow ease 0.2s;
-                       &:hover {
-                               box-shadow: inset 0 -21px 0 0 rgba(34, 27, 242,0.3);
-                       }
-               }
-               a[href^="http://"], a[href^="https://"] {
-                       &::after {
-                               content: "\f08e"; /* external link */
-                               font-family: FontAwesome;
-                               font-size: 80%;
-                               position: relative;
-                               padding-left: 5px;
-                               top: -4px;
-                       }
-               }
-       }
-       h4[id]::before {
-               content: "";
-               display: block;
-               position: relative;
-               width: 0px;
-               height: 10px;
-               margin-top: -60px;
-               height: 60px;
-       }
-}
-
-div#content div.wiki-section > h3 {
-       position: sticky;
-       top: 0;
-}
-
-div#content div.wiki-section h4.intertitle {
-       margin-bottom: 1em;
-}
-
-.wiki-breadcrumbs-separator {
-       padding-left: 1em;
-}
-
-.latest-page-updates-cell--item-date {
-       font-size: 80%;
-}
-
-.latest-page-updates-cell--item-isnew {
-       background: #f1f92f;
-       color: black;
-       font-size: 80%;
-       position: relative;
-       top: 0px;
-}
-
-#document-upload,
-#image-upload {
-       visibility: hidden;
-}
-
 body.loading {
        cursor: wait;
 }
@@ -992,19 +776,6 @@ body.loading::before {
        100% { right: 0%; }
 }
 
-#search-results {
-       background: white;
-       ul, li {
-               list-style: none;
-               margin: 0;
-               padding: 0;
-       }
-       a {
-               display: block;
-               padding: 0.6rem;
-       }
-}
-
 div.section > div > *:first-child {
        margin-top: 0;
 }
diff --git a/panikdb/static/js/combo.wiki.js b/panikdb/static/js/combo.wiki.js
deleted file mode 100644 (file)
index d1464e3..0000000
+++ /dev/null
@@ -1,580 +0,0 @@
-// from django/contrib/admin/static/admin/js/urlify.js
-var LATIN_MAP = {
-    'À': 'A', 'Á': 'A', 'Â': 'A', 'Ã': 'A', 'Ä': 'A', 'Å': 'A', 'Æ': 'AE',
-    'Ç': 'C', 'È': 'E', 'É': 'E', 'Ê': 'E', 'Ë': 'E', 'Ì': 'I', 'Í': 'I',
-    'Î': 'I', 'Ï': 'I', 'Ð': 'D', 'Ñ': 'N', 'Ò': 'O', 'Ó': 'O', 'Ô': 'O',
-    'Õ': 'O', 'Ö': 'O', 'Ő': 'O', 'Ø': 'O', 'Ù': 'U', 'Ú': 'U', 'Û': 'U',
-    'Ü': 'U', 'Ű': 'U', 'Ý': 'Y', 'Þ': 'TH', 'Ÿ': 'Y', 'ß': 'ss', 'à': 'a',
-    'á': 'a', 'â': 'a', 'ã': 'a', 'ä': 'a', 'å': 'a', 'æ': 'ae', 'ç': 'c',
-    'è': 'e', 'é': 'e', 'ê': 'e', 'ë': 'e', 'ì': 'i', 'í': 'i', 'î': 'i',
-    'ï': 'i', 'ð': 'd', 'ñ': 'n', 'ò': 'o', 'ó': 'o', 'ô': 'o', 'õ': 'o',
-    'ö': 'o', 'ő': 'o', 'ø': 'o', 'ù': 'u', 'ú': 'u', 'û': 'u', 'ü': 'u',
-    'ű': 'u', 'ý': 'y', 'þ': 'th', 'ÿ': 'y'
-};
-
-function downcode(string) {
-  return string.toLowerCase().replace(/[^A-Za-z0-9\[\] ]/g,function(a){ return LATIN_MAP[a]||a }).replace(/[^-\w\s]/g, '').replace(/^\s+|\s+$/g, '').replace(/[-\s]+/g, '-');
-};
-
-function remove_auto_anchors() {
-  $('div#main-content .wiki-anchor-auto').each(function(idx, anchor) {
-          $(anchor).parent().removeAttr('id');
-          $(anchor).remove();
-  });
-}
-
-function auto_anchors() {
-  $('div#main-content div.textcell h1, div#main-content div.textcell h2, div#main-content div.textcell h3').each(function(idx, elem) {
-    var $elem = $(elem);
-    if ($elem.attr('id')) return;
-    if ($elem.find('.wiki-anchor').length) return;
-    $elem.attr('id', downcode($elem.text()));
-    $('<a class="wiki-anchor wiki-anchor-auto" href="#' + $elem.attr('id') + '">¶</a>').appendTo($elem);
-  });
-}
-
-(function(window, document, undefined) {
-  var Phylly = {
-    BLOCKS: [
-          {name: 'intertitre', tag: 'H4', klass: 'intertitle'},
-          {name: 'liste', special: 'list', tag: 'UL', klass: 'list'},
-          {name: 'illustration', special: 'img', tag: 'DIV', subtag: true, klass: 'figure'},
-          {name: 'document', special: 'doc', tag: 'DIV', subtag: true, klass: 'document'},
-          {name: 'code', tag: 'PRE', klass: 'code'},
-          {name: 'note', tag: 'DIV', subtag: true, klass: 'note'},
-    ],
-    input_event: function(event) {
-      var sel = document.getSelection();
-      var anchorNode = sel.anchorNode;
-      if (sel.anchorNode.contentEditable === 'true' && (
-              sel.anchorNode.innerHTML == '<br>' || !sel.anchorNode.innerHTML)) {
-        // when everything has been removed, add back <p><br></p>
-        var empty_p = document.createElement('P');
-        empty_p.appendChild(document.createElement('BR'));
-        if (anchorNode.childNodes.length) { // lone <br>
-          anchorNode.removeChild(anchorNode.childNodes[0]);
-        }
-        anchorNode.appendChild(empty_p);
-        var range = document.createRange();
-        range.setStart(empty_p, 0);
-        sel.removeAllRanges();
-        sel.addRange(range);
-        return;
-      }
-      if (event.originalEvent.inputType == "insertText") {
-        var main_node = get_contenteditable_subnode(sel.anchorNode);
-        if (main_node.tagName != 'PRE') {
-          var anchorNode = sel.anchorNode;
-          var offset = sel.anchorOffset;
-          var orig_text = sel.anchorNode.data;
-          var text = orig_text;
-          // typography
-          if (event.originalEvent.data === "'") {
-            text = text.slice(0, offset-1) + '’' + text.slice(offset);
-          }
-          if (text != orig_text) {
-            var new_text = document.createTextNode(text);
-            anchorNode.replaceWith(new_text);
-            sel.collapse(new_text, offset);
-          }
-        }
-        return;
-      }
-      if (event.originalEvent.inputType != "insertParagraph") return true;
-      if (sel.anchorNode.tagName == "DIV" && sel.anchorNode.innerHTML == "<br>") {
-        // new empty div got inserted, replace it with a <p>
-        var empty_p = document.createElement('P');
-        empty_p.appendChild(document.createElement('BR'));
-        var empty_div = sel.anchorNode;
-        empty_div.replaceWith(empty_p);
-        var range = document.createRange();
-        range.setStart(empty_p, 0);
-        sel.removeAllRanges();
-        sel.addRange(range);
-      }
-      if (sel.anchorNode.tagName == "LI" && sel.anchorNode.innerHTML == "<br>") {
-        // new empty li got inserted, insert a <p> within
-        var empty_p = document.createElement('P');
-        empty_p.appendChild(document.createElement('BR'));
-        var empty_li = anchorNode;
-        if (empty_li.childNodes.length) { // lone <br>
-          empty_li.removeChild(empty_li.childNodes[0]);
-        }
-        empty_li.appendChild(empty_p);
-        var range = document.createRange();
-        range.setStart(empty_p, 0);
-        sel.removeAllRanges();
-        sel.addRange(range);
-      }
-      var prev_p = sel.anchorNode.previousSibling;
-      if (! prev_p) return;
-      if (prev_p.tagName != 'P') {
-        prev_p = $(prev_p).parents('p')[0];
-        if (! prev_p || prev_p.tagName != 'P') return;
-      }
-      var title_match = prev_p.innerText.match(/^(h[1-6]). /);
-      if (title_match) {
-        var title = document.createElement(title_match[1]);
-        title.innerHTML = prev_p.innerHTML;
-        title.textContent = title.textContent.slice(4);
-        prev_p.replaceWith(title);
-      }
-      return true;
-    },
-
-    init: function() {
-      $(document).on('selectionchange', function(event) {
-        if ($('input[name=link-target].shown').length) {
-          return;
-        }
-        var sel = window.getSelection();
-        if ($(sel.anchorNode).parents('div[contenteditable]').length && sel.toString()) {
-          show_inline_style_toolbar(sel);
-        } else if (inline_style_toolbar) {
-          $(inline_style_toolbar).hide();
-        }
-      });
-      var $image_upload = $('<input type="file" nam="image" id="image-upload" accept="image/*">');
-      $image_upload.on('change', upload_image);
-      $image_upload.appendTo(document.body);
-
-      var $document_upload = $('<input type="file" nam="document" id="document-upload">');
-      $document_upload.on('change', upload_document);
-      $document_upload.appendTo(document.body);
-
-      document.execCommand('defaultParagraphSeparator', false, 'p');
-      $(document).on('click', 'div.figure span.empty', function() {
-        window.active_figure = this.parentNode;
-        $('#image-upload').trigger('click');
-        return true;
-      });
-      $(document).on('click', 'div.document span.empty', function() {
-        window.active_document = this.parentNode;
-        $('#document-upload').trigger('click');
-        return true;
-      });
-    },
-
-    off: function() {
-      $('#image-upload').remove();
-      $('#document-upload').remove();
-      if (block_style_toolbar) { block_style_toolbar.hide(); }
-      if (inline_style_toolbar) { inline_style_toolbar.hide(); }
-      $(document).off('selectionchange');
-    },
-
-    window_keypress: function(ev) {
-      if (inline_style_toolbar && inline_style_toolbar.is(':visible')) {
-        if (event.ctrlKey || event.metaKey) {
-          var key = String.fromCharCode(event.which).toLowerCase();
-          var button = inline_style_toolbar.find('[data-accel="' + key + '"]').first();
-          if (button.length) {
-            button.trigger('click');
-            ev.preventDefault();
-          }
-        }
-      }
-    },
-
-    bind_events: function(elem) {
-      $(elem).on('input', Phylly.input_event);
-      $(elem).on('keyup click', update_block_style_toolbar);
-      $(window).on('keydown', this.window_keypress);
-    },
-
-    unbind_events: function(elem) {
-      $(elem).off('input');
-      $(elem).off('keyup click');
-      $(window).off('keydown', this.window_keypress);
-    },
-
-  }
-  window.Phylly = Phylly;
-
-  function upload_image() {
-    if ($(this).prop('files').length > 0) {
-      var file = $(this).prop('files')[0];
-      var params = new FormData();
-      params.append('upload', file);
-      $.post({url: '/wiki/ajax/upload/', processData: false, data: params, contentType: false}).success(function(data) {
-        var img = document.createElement('IMG');
-        img.src = data.url;
-        if (data.orig_url) {
-          img.setAttribute('data-orig-url', data.orig_url);
-        }
-        $(window.active_figure).empty().append(img);
-      });
-    }
-  }
-
-  function upload_document() {
-    if ($(this).prop('files').length > 0) {
-      var file = $(this).prop('files')[0];
-      var params = new FormData();
-      params.append('upload', file);
-      $.post({url: '/wiki/ajax/upload/', processData: false, data: params, contentType: false}).success(function(data) {
-        var doc_link = document.createElement('A');
-        doc_link.className = 'button';
-        doc_link.textContent = 'Télécharger ' + data.filename;
-        doc_link.href = data.url;
-        $(window.active_document).empty().append(doc_link);
-      });
-    }
-  }
-
-  function get_contenteditable_subnode(node) {
-    if (node === null) return null;
-    if (node.contentEditable === 'true') return node;  // but we shouldn't arrive at root
-    if (node.parentNode.contentEditable === 'true') return node;
-    return get_contenteditable_subnode(node.parentNode);
-  }
-  function get_parent(node, type) {
-   if (node === null) return null;
-   if (node.tagName == type) return node;
-   return get_parent(node.parentNode, type);
-  }
-  function get_active_block(node) {
-    var main_node = get_contenteditable_subnode(node);
-    if (main_node === null) return null;
-    for (const block of Phylly.BLOCKS) {
-      if (main_node.tagName === block.tag && main_node.classList.contains(block.klass))
-        return block;
-    }
-    return null;
-  }
-
-  var block_style_toolbar = null;
-  function block_style() {
-    var sel = window.getSelection();
-    var current_anchor = sel.anchorNode;
-    if (this.action_block.special == 'img') {
-      action = 'insertHTML';
-      param = '<div class="figure"><span class="empty"></span></div><p id="new-p"></p>';
-      document.execCommand(action, false, param);
-      current_anchor = $('#new-p')[0];
-      $(current_anchor).attr('id', null);
-      var range = document.createRange();
-      range.setStart(current_anchor, 0);
-      sel.removeAllRanges();
-      sel.addRange(range);
-      update_block_style_toolbar();
-      return;
-    }
-    if (this.action_block.special == 'doc') {
-      action = 'insertHTML';
-      param = '<div class="document"><span class="empty"></span></div><p id="new-p"></p>';
-      document.execCommand(action, false, param);
-      current_anchor = $('#new-p')[0];
-      $(current_anchor).attr('id', null);
-      var range = document.createRange();
-      range.setStart(current_anchor, 0);
-      sel.removeAllRanges();
-      sel.addRange(range);
-      update_block_style_toolbar();
-      return;
-    }
-    if (this.action_block.special == 'list') {
-      if (this.classList.contains('on')) { // toggle off
-        var main_node = get_contenteditable_subnode(sel.anchorNode);
-        var li = get_parent(sel.anchorNode, 'LI');
-        for (var i=li.childNodes.length; i>0; i--) {
-          var child = li.childNodes[i-1];
-          main_node.insertAdjacentElement('afterend', child);
-          var range = document.createRange();
-          range.setStart(child, 0);
-          sel.removeAllRanges();
-          sel.addRange(range);
-        }
-        li.remove();
-        update_block_style_toolbar();
-      } else {
-        var current_node = sel.anchorNode;
-        var ul = document.createElement('UL');
-        ul.className = 'list';
-        var li = document.createElement('LI');
-        ul.appendChild(li);
-        sel.anchorNode.parentNode.insertBefore(ul, current_node);
-        li.appendChild(current_node);
-        var range = document.createRange();
-        range.setStart(current_node, 0);
-        sel.removeAllRanges();
-        sel.addRange(range);
-      }
-      return;
-    }
-    if (this.classList.contains('on')) { // toggle off
-      if (this.action_block.subtag) {
-        // unwrap
-        var main_node = get_contenteditable_subnode(current_anchor);
-        $(current_anchor).detach().insertAfter(main_node);
-      } else {
-        document.execCommand('formatBlock', false, 'p');
-        current_anchor = sel.anchorNode;
-      }
-    } else {
-      action = this.action_block.subtag || this.action_block.tag;
-      if (this.action_block.subtag) {
-        // enclose current tag into a new parent;
-        var new_parent = document.createElement(this.action_block.tag);
-        new_parent.className = this.action_block.klass;
-        $(current_anchor).wrap(new_parent);
-      } else {
-        document.execCommand('formatBlock', false, this.action_block.tag);
-        sel.anchorNode.className = this.action_block.klass;
-        current_anchor = sel.anchorNode;
-      }
-    }
-    var range = document.createRange();
-    range.setStart(current_anchor, 0);
-    sel.removeAllRanges();
-    sel.addRange(range);
-    update_block_style_toolbar();
-  }
-  function update_block_style_toolbar() {
-    var sel = window.getSelection();
-    if (! ((sel.anchorNode instanceof Element && (sel.anchorOffset == 0 && sel.isCollapsed)) || get_active_block(sel.anchorNode))) {
-      if (block_style_toolbar) {
-        $(block_style_toolbar).hide();
-      }
-      return true;
-    }
-    if (block_style_toolbar === null) {
-      block_style_toolbar = $('<div class="block-style-popup"></div>');
-      for (const block of Phylly.BLOCKS) {
-        var button = document.createElement('button');
-        button.action_block = block;
-        button.dataset.action = block.name;
-        button.textContent = block.name;
-        block_style_toolbar.append(button);
-      }
-      block_style_toolbar.hide();
-      block_style_toolbar.insertAfter(document.body);
-      block_style_toolbar.find('button').on('click', block_style);
-    }
-    block_style_toolbar.css('position', 'absolute');
-    var block = get_active_block(sel.anchorNode);
-    block_style_toolbar.find('button').removeClass('on');
-    if (block) {
-      block_style_toolbar.find('[data-action=' + block.name + ']').addClass('on');
-      block_style_toolbar.addClass('selected');
-    } else {
-      block_style_toolbar.removeClass('selected');
-    }
-    var anchor = get_contenteditable_subnode(sel.anchorNode);
-    var pos = $(anchor).offset();
-    block_style_toolbar.css('top', pos.top - 33);
-    block_style_toolbar.css('left', pos.left);
-    block_style_toolbar.show();
-    return true;
-  }
-
-  var inline_style_toolbar = null;
-  function update_style() {
-    var action = $(this).data('action');
-    var param = null;
-    if (action == 'code') {
-      action = 'insertHTML';
-      param = $('<code></code>', {text: window.getSelection().toString()})[0].outerHTML;
-    }
-    if (action == 'wiki') {
-      action = 'insertHTML';
-      var text = window.getSelection().toString();
-      var $new_link = $('<a></a>', {text: text, href: '#tbd'});
-      var request_id = Math.floor(Math.random() * 10000);
-      $new_link.attr('data-request-id', request_id);
-      var params = {};
-      params.title = text;
-      params.request_id = request_id;
-      $.post('/wiki/ajax/newpage/', params).success(function(data) {
-        $('a[data-request-id=' + data.request_id + ']').attr('href', data.url).removeAttr('data-request-id');
-      });
-      param = $new_link[0].outerHTML;
-    }
-    if (action == 'createLink') {
-      var sel = window.getSelection();
-      var $input = $('input[name=link-target]');
-      $input[0]._range = sel.getRangeAt(0);
-      if (sel.anchorNode instanceof Element) {
-        var elem = sel.anchorNode.childNodes[sel.anchorOffset];
-        if (elem.tagName == 'A') {
-          $input.val(elem.href);
-        }
-      }
-      $input.addClass('shown');
-      $input.focus();
-      return;
-    }
-    document.execCommand(action, false, param);
-  }
-  function validate_link(ev) {
-    var charCode = typeof ev.which == "number" ? ev.which : ev.keyCode;
-    if (ev.key == "Enter") {
-      var $input = $(this);
-      var range = this._range;
-      var url = $input.val();
-      $input.removeClass('shown');
-      var sel = window.getSelection();
-      sel.addRange(this._range);
-      if (url) {
-        document.execCommand('createLink', false, url);
-      } else {
-        document.execCommand('unlink', false, null);
-      }
-      sel.empty();
-      $input.val('');
-    }
-  }
-  function focusout_link(ev) {
-    var $input = $(this);
-    $input.removeClass('shown');
-    var range = this._range;
-    var sel = window.getSelection();
-    sel.addRange(this._range);
-  }
-
-  function show_inline_style_toolbar(sel) {
-    if (inline_style_toolbar === null) {
-      inline_style_toolbar = $('<div class="inline-style-popup">' +
-                      '<button data-action="italic" data-accel="i"><i>i</i></button>' +
-                      '<button data-action="bold" data-accel="b"><b>b</b></button>' +
-                      '<button data-action="code" data-accel="<">&lt;&gt;</button>' +
-                      '<button data-action="removeFormat" data-accel="m">×</button>' +
-                      '<button data-action="wiki">W</button>' +
-                      '<button data-action="createLink">a</button>' +
-                      '<input name="link-target"/>' +
-                      '</div>');
-      inline_style_toolbar.hide();
-      inline_style_toolbar.insertAfter(document.body);
-      inline_style_toolbar.find('button').on('click', update_style);
-      inline_style_toolbar.find('[name=link-target]').on('keypress', validate_link).on('focusout', focusout_link);
-    }
-    inline_style_toolbar.css('position', 'absolute');
-    var pos = sel.getRangeAt(0).getClientRects()[0];
-    inline_style_toolbar.css('top', pos.top + window.scrollY - 33);
-    inline_style_toolbar.css('left', pos.left + window.scrollX);
-    inline_style_toolbar.show();
-  };
-}(window, document));
-
-function init_page() {
-  $('#search-results').html('');
-  if (window.localStorage) {
-    var breadcrumbs = window.localStorage.wiki_breadcrumbs;
-    if (breadcrumbs) {
-      try {
-        breadcrumbs = JSON.parse(breadcrumbs);
-      } catch(e) {
-        breadcrumbs = new Array();
-      }
-    } else {
-      breadcrumbs = new Array();
-    }
-    var page = {href: window.location.pathname, text: $('div.wiki-section > h3 span.title').text()};
-    for (var i=0; i<breadcrumbs.length; i++) {
-      if (breadcrumbs[i].href === page.href) {
-        breadcrumbs.splice(i, 1);
-        break;
-      }
-    }
-    breadcrumbs.reverse();
-    breadcrumbs.push(page);
-    breadcrumbs.reverse();
-    breadcrumbs.splice(10, 1);  // only keep 10 elements
-    window.localStorage.wiki_breadcrumbs = JSON.stringify(breadcrumbs);
-    var $links = $('#more-user-links');
-    $links.append('<span class="wiki-breadcrumbs-separator"></span>');
-    for (var i=1; i<breadcrumbs.length; i++) {
-      var $a = $('<a></a>', breadcrumbs[i]);
-      $links.append(' ');
-      $links.append($a);
-    }
-  }
-  $('#quickedit input').on('change', function() {
-    var enable = $(this).is(':checked');
-    if (enable) {
-      remove_auto_anchors();
-      $('div[data-edit-url] > div').each(function(i, elem) {
-        $(elem).attr('contenteditable', 'true');
-        var $button = $('<button class="save">Enregistrer</button>');
-        $button[0].div_zone = elem;
-        elem.edit_url = $(elem).parents('[data-edit-url]').data('edit-url');
-        $button.insertBefore($('#quickedit label'));
-      });
-      Phylly.init(),
-      $('div[data-edit-url] > div').each(function(i, elem) {
-        Phylly.bind_events(elem);
-      });
-      $('.save').on('click', function() {
-        var csrf = $('[name=csrfmiddlewaretoken]').val();
-        attr = this.div_zone.edit_url.replace(/^.*(data_textcell.*)\//, 'c$1-text');
-        var params = {};
-        params[attr] = this.div_zone.innerHTML;
-        params['csrfmiddlewaretoken'] = csrf;
-        $.post(this.div_zone.edit_url, params).fail(function() {
-          $(this).css('background', 'red');
-        });
-        return false;
-      });
-    } else {
-      auto_anchors();
-      Phylly.off(),
-      $('button.save').remove();
-      $('div[data-edit-url] > div').each(function(i, elem) {
-        $(elem).attr('contenteditable', 'false');
-        Phylly.unbind_events(elem);
-      });
-    }
-  });
-  $('#quickedit input').trigger('change');
-
-  function load_page(href, push_history) {
-    $('body').addClass('loading');
-    var content = $.ajax({
-      url: href,
-      dataType: 'html',
-      success: function(html, status, xhr) {
-        Phylly.off(),
-        $('div[data-edit-url] > div').each(function(i, elem) {
-          Phylly.unbind_events(elem);
-        });
-        if (push_history) history.pushState({}, '', href);
-        $('body').removeClass('loading');
-        $('#main-content').replaceWith($(html).find('#main-content'));
-        if (push_history) window.scroll(0, 0);
-        init_page();
-      },
-      error: function() {
-        $('body').removeClass('loading');
-      },
-    });
-  }
-
-  $(window).off('popstate').on('popstate', function(e) {
-    load_page(location.href, false);
-  });
-
-  $('#main-content, #search-results').on('click', 'a[href]:not([rel])', function(e) {
-    var href = this.attributes.href.nodeValue;
-    if (e.which === 2) return true;
-    if (href.slice(0, 6) == '/wiki/') {
-      load_page(this.href, true);
-      return false;
-    }
-  });
-  $('div.wiki-section').on('click', 'img[data-orig-url]', function() {
-    window.location = $(this).data('orig-url');
-  });
-}
-
-$(function() {
-  init_page();
-  $('#search input').attr('placeholder', 'Rechercher dans le wiki');
-  var wiki_search_base_url = $('#search form').data('wiki-search-base-url');
-  $('#search form').on('submit', function() {
-    var value = $('input[name=q]').val();
-    $.ajax({url: wiki_search_base_url, data: {q: value}}).success(function(data) {
-      $('#search-results').html(data);
-    });
-    return false;
-  });
-});
diff --git a/panikdb/templates/combo/page_template_sidebar.html b/panikdb/templates/combo/page_template_sidebar.html
deleted file mode 100644 (file)
index 43e978b..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-{% extends "base.html" %}
-{% load i18n %}
-
-{% block gadjo-js %}
-{{ block.super }}
-<script src="{{ STATIC_URL }}js/combo.wiki.js"></script>
-{% endblock %}
-
-{% block more-user-links %}
-<a href="{% url 'home' %}" class="icon-home-space"></a>
-<a href="/wiki/">Accueil Wiki</a>
-{% if request.user.is_authenticated %}<a href="/wiki/newpage" rel="popup">Nouvelle page wiki</a>{% endif %}
-{% endblock %}
-
-{% block content %}
-<div class="section wiki-section">
-<h3><span class="title">{{ page.title }}</span>
-{% if request.user.is_authenticated %}
-<div id="quickedit">
-  <label><input type="checkbox"><span>Mode édition</span></label>
-</div>
-{% endif %}
-</h3>
-{% csrf_token %}
-
-<div>
-{% placeholder "content" %}
-</div>
-
-</div>
-{% endblock %}
index 3af2b696bc78eda886aab8bad946c9711fc03ebe..810b99f6dce382b01f49767dc8354bd811ab644e 100644 (file)
@@ -22,7 +22,7 @@ from nonstop.urls import urlpatterns as nonstop_urlpatterns
 from nonstop.urls import public_urlpatterns as nonstop_public_urlpatterns
 from .regie.urls import urlpatterns as regie_urlpatterns
 from .aa.urls import urlpatterns as aa_urlpatterns
-from .wiki.urls import urlpatterns as wiki_urlpatterns
+from wiki.urls import urlpatterns as wiki_urlpatterns
 import panikombo.views
 
 from .poll import views as poll_views
diff --git a/panikdb/wiki/__init__.py b/panikdb/wiki/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/panikdb/wiki/forms.py b/panikdb/wiki/forms.py
deleted file mode 100644 (file)
index 786bd12..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-from django import forms
-from django.utils.translation import ugettext_lazy as _
-
-
-class NewPageForm(forms.Form):
-    title = forms.CharField(label=_('Title'), required=True)
diff --git a/panikdb/wiki/templates/wiki/new_page.html b/panikdb/wiki/templates/wiki/new_page.html
deleted file mode 100644 (file)
index a2c4390..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-{% extends "base.html" %}
-{% load i18n %}
-
-{% block appbar %}
-<h2>{% trans "New Page" %}</h2>
-{% endblock %}
-
-{% block content %}
-<form method="post" action="/wiki/newpage/">
-{% csrf_token %}
-{{ form.as_p }}
-  <div class="buttons">
-    <button class="submit-button">{% trans "Add" %}</button>
-    <a class="cancel" href="/wiki/">{% trans "Cancel" %}</a>
-  </div>
-
-</form>
-{% endblock %}
diff --git a/panikdb/wiki/urls.py b/panikdb/wiki/urls.py
deleted file mode 100644 (file)
index 7d6dc89..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-from django.conf.urls import url
-
-import combo.public.views
-from . import views
-
-
-urlpatterns = [
-    url(r'^newpage/$', views.new_page),
-    url(r'^ajax/newpage/$', views.ajax_new_page),
-    url(r'^ajax/upload/$', views.ajax_upload),
-    url(r'^', combo.public.views.page),
-]
diff --git a/panikdb/wiki/views.py b/panikdb/wiki/views.py
deleted file mode 100644 (file)
index 15df481..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-import os
-
-from django.contrib.auth.decorators import login_required
-from django.core.files.storage import default_storage
-from django.db.models import Q
-from django.http import JsonResponse
-from django.utils.text import slugify
-from django.views.decorators.csrf import csrf_exempt
-from django.views.generic.edit import FormView
-
-from sorl.thumbnail.shortcuts import get_thumbnail
-
-from combo.data.models import Page, TextCell
-
-from .forms import NewPageForm
-
-
-class NewPageView(FormView):
-    form_class = NewPageForm
-    template_name = 'wiki/new_page.html'
-
-    def form_valid(self, form):
-        parent_wiki_page = Page.objects.get(slug='wiki', parent=None)
-        self.new_page = Page(title=form.cleaned_data['title'], parent=parent_wiki_page, public=False)
-        self.new_page.save()
-        cell = TextCell(placeholder='content', page=self.new_page, order=0)
-        cell.text = '<p>Nouvelle page, contenu à ajouter</p>'
-        cell.save()
-        return super().form_valid(form)
-
-    def get_success_url(self):
-        return self.new_page.get_online_url()
-
-
-new_page = login_required(NewPageView.as_view())
-
-
-@csrf_exempt
-def ajax_new_page(request, *args, **kwargs):
-    parent_wiki_page = Page.objects.get(slug='wiki', parent=None)
-    title = request.POST['title']
-    slug = slugify(title)
-    page = Page.objects.filter(Q(slug=slug) | Q(title=title)).first()
-    if not page:
-        page = Page(
-            title=title,
-            parent=parent_wiki_page,
-            public=False)
-        page.save()
-        cell = TextCell(placeholder='content', page=page, order=0)
-        cell.text = '<p>Nouvelle page, contenu à ajouter</p>'
-        cell.save()
-    return JsonResponse({
-        'url': page.get_online_url(),
-        'request_id': request.POST['request_id'],
-    })
-
-
-@csrf_exempt
-def ajax_upload(request, *args, **kwargs):
-    upload = request.FILES['upload']
-    upload_path = 'uploads'
-    if os.path.splitext(upload.name.lower())[-1] in ('.jpg', '.jpeg', '.png', '.gif', '.svg'):
-        upload_path = 'images'
-    saved_path = default_storage.save('wiki/%s/%s' % (upload_path, upload.name), upload)
-    url = '/media/' + saved_path
-    response = {'url': url, 'filename': upload.name}
-    if upload_path == 'images':
-        if default_storage.size(saved_path) > 500_000 and not upload.name.endswith('.svg'):
-            response['orig_url'] = url
-            try:
-                response['url'] = get_thumbnail(saved_path, '1000', upscale=False).url
-            except OSError:
-                pass
-    return JsonResponse(response)