From 44172ec98a8033803f578288ddd03702504980a0 Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Sun, 4 Oct 2015 14:13:29 -0700 Subject: [PATCH] clean up HTML, CSS, and JavaScript for CSP In order to implement Content-Security-Policy, the inlined style, event handlers, and scripts all have to go. This commit completes this work. --- static/css/linx.css | 73 +++++++++++++++++++++++++++++++++++- static/js/bin.js | 14 +++---- templates/404.html | 2 +- templates/display/audio.html | 6 +-- templates/display/bin.html | 32 ++++++++-------- templates/display/file.html | 4 +- templates/display/image.html | 2 +- templates/display/pdf.html | 5 +-- templates/display/video.html | 10 ++--- templates/index.html | 2 +- templates/oops.html | 2 +- templates/paste.html | 6 +-- 12 files changed, 110 insertions(+), 48 deletions(-) diff --git a/static/css/linx.css b/static/css/linx.css index cf83032..e365826 100644 --- a/static/css/linx.css +++ b/static/css/linx.css @@ -80,6 +80,16 @@ body { padding: 5px 5px 5px 5px; } +#info #filename, +#editform #filename { + width: 232px; +} + +#info #extension, +#editform #extension { + width: 40px; +} + #info .float-left { margin-top: 2px; margin-right: 20px; @@ -181,7 +191,7 @@ body { } .clear { - clear:both; + clear: both; } #upload_header { @@ -248,6 +258,65 @@ body { padding-top: 1px; } +.oopscontent { + width: 400px; +} + +.oopscontent img { + width: 400px; + border: 0; +} + +.editor { + width: 705px; + height: 450px; + border-color: #cccccc; +} + +/* Content display {{{ */ +.display-audio, +.display-file { + width: 500px; +} + +.display-image { + margin-bottom: -6px; + max-width: 800px; +} + +.display-pdf { + width: 910px; + height: 800px; +} + +.display-video { + width: 800px; +} + +.scrollable { + overflow: auto; +} + +.storycontent { + background-color: #f0e0d6; +} + +#editform, +#editform .editor { + display: none; +} + +#codeb { + white-space: pre-wrap; +} + +#editor { + display: none; + height: 800px; + font-size: 11px; +} +/* }}} */ + /* cat.js */ .qq-uploader { position:relative; width: 100%;} @@ -694,4 +763,4 @@ THE SOFTWARE. .hint--bounce:before, .hint--bounce:after { -webkit-transition: opacity 0.3s ease, visibility 0.3s ease, -webkit-transform 0.3s cubic-bezier(0.71, 1.7, 0.77, 1.24); -moz-transition: opacity 0.3s ease, visibility 0.3s ease, -moz-transform 0.3s cubic-bezier(0.71, 1.7, 0.77, 1.24); - transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s cubic-bezier(0.71, 1.7, 0.77, 1.24); } \ No newline at end of file + transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s cubic-bezier(0.71, 1.7, 0.77, 1.24); } diff --git a/static/js/bin.js b/static/js/bin.js index 4e86edf..0fd6990 100644 --- a/static/js/bin.js +++ b/static/js/bin.js @@ -8,7 +8,7 @@ function init() { editA.setAttribute("href", "#"); editA.addEventListener('click', function(ev) { - edit(); + edit(ev); return false; }); editA.innerHTML = "edit"; @@ -22,14 +22,16 @@ function init() { editor.getSession().setMode("ace/mode/" + lang); editor.setTheme("ace/theme/tomorrow"); + document.getElementById('save').addEventListener('click', paste); + document.getElementById('wordwrap').addEventListener('click', wrap); } -function edit() { +function edit(ev) { navlist.remove(); document.getElementById("filename").remove(); - document.getElementById("foarm").style.display = "block"; + document.getElementById("editform").style.display = "block"; var normalcontent = document.getElementById("normal-content"); normalcontent.removeChild(document.getElementById("normal-code")); @@ -44,14 +46,12 @@ function edit() { } -function paste() { - +function paste(ev) { document.getElementById("newcontent").value = editor.getSession().getValue(); document.forms["reply"].submit(); - } -function wrap() { +function wrap(ev) { if (document.getElementById("wordwrap").checked) { document.getElementById("codeb").style.wordWrap = "break-word"; document.getElementById("codeb").style.whiteSpace = "pre-wrap"; diff --git a/templates/404.html b/templates/404.html index 0999393..e792bf3 100644 --- a/templates/404.html +++ b/templates/404.html @@ -1,5 +1,5 @@ {% extends "base.html" %} {% block content %} - + {% endblock %} diff --git a/templates/display/audio.html b/templates/display/audio.html index 66b36fa..a88319f 100644 --- a/templates/display/audio.html +++ b/templates/display/audio.html @@ -1,9 +1,9 @@ {% extends "base.html" %} {% block main %} -