Merge branch 'legacy/0.9'
Conflicts: CHANGES.rst isso/core.py isso/dispatch.py setup.py
This commit is contained in:
commit
ce9781df51
20
CHANGES.rst
20
CHANGES.rst
@ -7,6 +7,26 @@ Changelog for Isso
|
||||
- Nothing changed yet.
|
||||
|
||||
|
||||
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)
|
||||
----------------
|
||||
|
||||
|
@ -7,5 +7,3 @@ include isso/js/embed.min.js
|
||||
include isso/js/embed.dev.js
|
||||
include isso/js/count.min.js
|
||||
include isso/js/count.dev.js
|
||||
|
||||
include isso/css/isso.css
|
||||
|
15
docs/_static/css/site.scss
vendored
15
docs/_static/css/site.scss
vendored
@ -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 {
|
||||
|
19
docs/conf.py
19
docs/conf.py
@ -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.
|
||||
|
@ -25,7 +25,7 @@
|
||||
#
|
||||
# Isso – a lightweight Disqus alternative
|
||||
|
||||
from __future__ import print_function
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import pkg_resources
|
||||
dist = pkg_resources.get_distribution("isso")
|
||||
|
@ -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;
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import sys
|
||||
import os
|
||||
import logging
|
||||
|
@ -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);
|
||||
|
@ -38,6 +38,21 @@ define(["app/i18n"], function(i18n) {
|
||||
i18n.pluralize("date-year", Math.ceil(days / 365.25));
|
||||
};
|
||||
|
||||
var HTMLEntity = {
|
||||
"&": "&",
|
||||
"<": "<",
|
||||
">": ">",
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
"/": '/'
|
||||
};
|
||||
|
||||
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 {
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
from isso import make_app
|
||||
|
@ -5,6 +5,7 @@ try:
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
import textwrap
|
||||
|
||||
from isso import config
|
||||
from isso.utils import html
|
||||
@ -31,6 +32,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=[])
|
||||
|
@ -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")
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import pkg_resources
|
||||
import operator
|
||||
|
||||
@ -54,16 +56,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>"
|
||||
return rv
|
||||
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):
|
||||
|
||||
def __init__(self, conf):
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
from __future__ import print_function
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
from itertools import chain
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import re
|
||||
import cgi
|
||||
import time
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import socket
|
||||
|
||||
try:
|
||||
|
@ -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, superscript, autolink, fenced_code
|
||||
|
||||
# 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,
|
||||
|
Loading…
Reference in New Issue
Block a user