Merge branch 'master' into dev

Conflicts:
	MANIFEST.in
	docs/docs/install.rst
	isso/tests/test_html.py
This commit is contained in:
Martin Zimmermann 2014-07-14 20:03:50 +02:00
commit 7886c20aef
16 changed files with 176 additions and 40 deletions

View File

@ -7,6 +7,38 @@ Changelog for Isso
- Nothing changed yet.
0.9.5 (unreleased)
------------------
- Nothing changed yet.
0.9.4 (2014-07-09)
------------------
- fixed a regression when using Isso and Gevent
0.9.3 (2014-07-09)
------------------
- remove scrollIntoView while expanding further comments if a fragment is used
(e.g. #isso-thread brought you back to the top, unexpectedly)
- implement a custom Markdown renderer to support multi-line code listings. The
extension "fenced_code" is now enabled by default and generates HTML
compatible with Highlight.js__.
- escape HTML entities when editing a comment with raw HTML
- fix CSS for input
- remove isso.css from binary distribution to avoid confusion (it's still there
from the very first release, but modifications do not work)
.. __: http://highlightjs.org/
0.9 (2014-05-29)
----------------

View File

@ -9,5 +9,4 @@ include isso/js/embed.dev.js
include isso/js/count.min.js
include isso/js/count.dev.js
include isso/css/isso.css
include isso/demo/index.html

View File

@ -209,6 +209,21 @@ main {
h4 {
margin-bottom: 0.5em;
}
blockquote {
margin-top: 10px;
margin-bottom: 10px;
padding-left: 15px;
border-left: 3px solid #ccc;
}
pre {
background: #eee;
border: 1px solid #ddd;
padding: 10px 15px;
color: #4d4d4c;
overflow: auto;
}
}
.sidebar {

View File

@ -12,14 +12,27 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import pkg_resources
dist = pkg_resources.get_distribution("isso")
import sys
import io
import re
import pkg_resources
from os.path import join, dirname
sys.path.insert(0, join(dirname(__file__), "_isso/"))
try:
dist = pkg_resources.get_distribution("isso")
except pkg_resources.DistributionNotFound:
dist = type("I'm a Version", (object, ), {})
with io.open(join(dirname(__file__), "../setup.py")) as fp:
for line in fp:
m = re.match("\s*version='([^']+)'\s*", line)
if m:
dist.version = m.group(1)
break
else:
dist.version = ""
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.

View File

@ -47,8 +47,8 @@ but not recommended):
.. code-block:: sh
~> virtualenv /home/user/python/isso
~> source /home/user/python/isso/activate
~> virtualenv /path/to/isso
~> source /path/to/isso/bin/activate
After calling `source`, you can now install packages from PyPi locally into this
virtual environment. If you don't like Isso anymore, you just `rm -rf` the
@ -69,12 +69,30 @@ machines or a shared host (e.g. Uberspace.de).
Install from PyPi
-----------------
Requirements:
Requirements
^^^^^^^^^^^^
- Python 2.7, 3.3 or 3.4 (+ devel headers)
- Python 2.7, 3.3 or 3.4+ (+ devel headers)
- SQLite 3.3.8 or later
- a working C compiler
For Debian/Ubuntu just `copy and paste
<http://thejh.net/misc/website-terminal-copy-paste>`_ to your terminal:
.. code-block:: sh
~> sudo apt-get install python-dev sqlite3 build-essential
Similar for Fedora (and derivates):
.. code-block:: sh
~> sudo yum install python-devel sqlite
~> sudo yum groupinstall “Development Tools”
Installation
^^^^^^^^^^^^
Install Isso with `pip <http://www.pip-installer.org/en/latest/>`_:
.. code-block:: sh
@ -88,16 +106,20 @@ Install Isso with `pip <http://www.pip-installer.org/en/latest/>`_:
~> easy_install isso # cross your fingers
For easier execution, you can symlink the executable to a location in your
PATH:
:envvar:`PATH`.
.. code-block:: sh
~> ln -s /path/to/isso-venv/bin/isso /usr/local/bin/isso
Upgrade
^^^^^^^
To upgrade Isso, activate your virtual environment again, and run
.. code-block:: sh
~> source /path/to/isso/bin/activate # optional
~> pip install --upgrade isso
.. _prebuilt-package:
@ -108,16 +130,14 @@ Prebuilt Packages
* Debian: https://packages.crapouillou.net/ built from PyPi. Includes
startup scripts and vhost configurations for Lighttpd, Apache and Nginx
[`source <https://github.com/jgraichen/debian-isso>`__].
`#729218 <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=729218>`_ is a
ITP for Debian. To be officially packages by Debian, `#51
<https://github.com/posativ/isso/issues/51>`_ needs to be done (contributions
are welcome).
`#729218 <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=729218>`_ is an
ITP for Debian.
* Gentoo: http://eroen.eu/cgit/cgit.cgi/eroen-overlay/tree/www-apps/isso?h=isso
not yet available in Portage, but you can use the ebuild to build Isso.
* Arch Linux: https://aur.archlinux.org/packages/isso/ built from PyPi.
* Arch Linux: https://aur.archlinux.org/packages/isso/
install with `yaourt isso`.
Install from Source
-------------------

View File

@ -178,19 +178,12 @@
.isso-postbox > .form-wrapper > .auth-section .input-wrapper input {
padding: .3em 10px;
max-width: 100%;
border-radius: 3px;
background-color: #fff;
line-height: 1.4em;
border: 1px solid rgba(0, 0, 0, 0.2);
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}
.isso-postbox > .form-wrapper > .auth-section .input-wrapper:first-child input {
border-radius: 3px 0 0 3px;
border-right: 0;
}
.isso-postbox > .form-wrapper > .auth-section .input-wrapper:nth-last-child(2) input {
border-radius: 0 3px 3px 0;
border-left: 0;
}
.isso-postbox > .form-wrapper > .auth-section .post-action {
display: inline-block;
float: right;
@ -220,7 +213,6 @@
}
.isso-postbox > .form-wrapper > .auth-section .input-wrapper input {
width: 100%;
border-radius: 3px;
}
.isso-postbox > .form-wrapper > .auth-section .post-action {
display: block;

View File

@ -1,5 +1,7 @@
# -*- encoding: utf-8 -*-
from __future__ import unicode_literals
import sys
import os
import logging

View File

@ -89,10 +89,6 @@ define(["app/dom", "app/utils", "app/config", "app/api", "app/jade", "app/i18n",
if(rv.hidden_replies > 0) {
insert_loader(rv, lastcreated);
}
if (window.location.hash.length > 0) {
$(window.location.hash).scrollIntoView();
}
},
function(err) {
console.log(err);

View File

@ -38,6 +38,21 @@ define(["app/i18n"], function(i18n) {
i18n.pluralize("date-year", Math.ceil(days / 365.25));
};
var HTMLEntity = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': '&quot;',
"'": '&#39;',
"/": '&#x2F;'
};
var escape = function(html) {
return String(html).replace(/[&<>"'\/]/g, function (s) {
return HTMLEntity[s];
});
};
var text = function(html) {
var _ = document.createElement("div");
_.innerHTML = html.replace(/<div><br><\/div>/gi, '<br>')
@ -47,8 +62,8 @@ define(["app/i18n"], function(i18n) {
};
var detext = function(text) {
return text.replace(/\n\n/gi, '<br><div><br></div>')
.replace(/\n/gi, '<br>');
return escape(text.replace(/\n\n/gi, '<br><div><br></div>')
.replace(/\n/gi, '<br>'));
};
return {

View File

@ -1,5 +1,7 @@
# -*- encoding: utf-8 -*-
from __future__ import unicode_literals
import os
from isso import make_app

View File

@ -1,5 +1,6 @@
# -*- encoding: utf-8 -*-
import textwrap
import unittest
from isso.utils import html
@ -26,6 +27,37 @@ class TestHTML(unittest.TestCase):
for (input, expected) in examples:
self.assertEqual(convert(input), expected)
def test_github_flavoured_markdown(self):
convert = html.Markdown(extensions=("fenced_code", ))
# without lang
_in = textwrap.dedent("""\
Hello, World
```
#!/usr/bin/env python
print("Hello, World")""")
_out = textwrap.dedent("""\
<p>Hello, World</p>
<pre><code>#!/usr/bin/env python
print("Hello, World")
</code></pre>""")
self.assertEqual(convert(_in), _out)
# w/ lang
_in = textwrap.dedent("""\
Hello, World
```python
#!/usr/bin/env python
print("Hello, World")""")
_out = textwrap.dedent("""\
<p>Hello, World</p>
<pre><code class="python">#!/usr/bin/env python
print("Hello, World")
</code></pre>""")
@unittest.skipIf(html.html5lib_version == "0.95", "backport")
def test_sanitizer(self):
sanitizer = html.Sanitizer(elements=[], attributes=[])

View File

@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
from __future__ import division
from __future__ import division, unicode_literals
import pkg_resources
werkzeug = pkg_resources.get_distribution("werkzeug")

View File

@ -1,5 +1,7 @@
# -*- encoding: utf-8 -*-
from __future__ import unicode_literals
import pkg_resources
import operator
@ -59,16 +61,30 @@ def Markdown(extensions=("strikethrough", "superscript", "autolink")):
flags = reduce(operator.xor, map(
lambda ext: getattr(misaka, 'EXT_' + ext.upper()), extensions), 0)
md = misaka.Markdown(Unofficial(), extensions=flags)
def inner(text):
rv = misaka.html(text, extensions=flags).rstrip("\n")
if not rv.endswith("<p>") and not rv.endswith("</p>"):
return "<p>" + rv + "</p>"
rv = md.render(text).rstrip("\n")
if rv.startswith("<p>") or rv.endswith("</p>"):
return rv
return "<p>" + rv + "</p>"
return inner
class Unofficial(misaka.HtmlRenderer):
"""A few modifications to process "common" Markdown.
For instance, fenced code blocks (~~~ or ```) are just wrapped in <code>
which does not preserve line breaks. If a language is given, it is added
to <code class="$lang">, compatible with Highlight.js.
"""
def block_code(self, text, lang):
lang = ' class="{0}"'.format(lang) if lang else ''
return "<pre><code{1}>{0}</code></pre>\n".format(text, lang)
class Markup(object):
"""Text to HTML conversion using Markdown (+ configurable extensions) and
an HTML sanitizer to remove malicious elements.

View File

@ -1,5 +1,5 @@
from __future__ import print_function
from __future__ import print_function, unicode_literals
from itertools import chain

View File

@ -1,5 +1,7 @@
# -*- encoding: utf-8 -*-
from __future__ import unicode_literals
import socket
try:
@ -140,7 +142,7 @@ class CORSMiddleware(object):
return start_response(status, headers.to_list(), exc_info)
if environ.get("REQUEST_METHOD") == "OPTIONS":
add_cors_headers("200 Ok", [("Content-Type", "text/plain")])
add_cors_headers(b"200 Ok", [("Content-Type", "text/plain")])
return [b'200 Ok']
return self.app(environ, add_cors_headers)

View File

@ -134,7 +134,7 @@ reply-to-self = false
# Misaka-specific Markdown extensions, all flags starting with EXT_ can be used
# there, separated by comma.
options = strikethrough, superscript, autolink
options = strikethrough, autolink, fenced_code, no_intra_emphasis
# Additional HTML tags to allow in the generated output, comma-separated. By
# default, only a, blockquote, br, code, del, em, h1, h2, h3, h4, h5, h6, hr,