diff --git a/client/scss/_mixins.scss b/client/scss/_mixins.scss index 1e4196a..76d9279 100644 --- a/client/scss/_mixins.scss +++ b/client/scss/_mixins.scss @@ -1,4 +1,3 @@ - // Global padding across all first level elements @mixin boxPadding($paddingTop: 20px, $paddingBottom: 20px) { padding: $paddingTop $boxPadding $paddingBottom $boxPadding; diff --git a/client/scss/_reset.scss b/client/scss/_reset.scss index 47a6bf8..d66c284 100644 --- a/client/scss/_reset.scss +++ b/client/scss/_reset.scss @@ -1,10 +1,3 @@ -/* http://meyerweb.com/eric/tools/css/reset/ - v2.0 | 20110126 - License: none (public domain) -*/ - -// html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video - html, body, p { margin: 0; padding: 0; diff --git a/client/scss/components/_code.scss b/client/scss/components/_code.scss index ba3889a..5ccf55c 100644 --- a/client/scss/components/_code.scss +++ b/client/scss/components/_code.scss @@ -1,7 +1,3 @@ -.snippet-text { - background-color: $bgColor; -} - .snippet-diff { color: $codeTextColor; background-color: $codeBgColor; diff --git a/client/scss/components/_form.scss b/client/scss/components/_form.scss index 52c37f7..4eebbab 100644 --- a/client/scss/components/_form.scss +++ b/client/scss/components/_form.scss @@ -5,7 +5,6 @@ line-height: 17px; } - .snippet-form { background-color: $bgColor; @@ -82,4 +81,3 @@ } } } - diff --git a/client/scss/components/_header.scss b/client/scss/components/_header.scss index ccf6e69..a606f88 100644 --- a/client/scss/components/_header.scss +++ b/client/scss/components/_header.scss @@ -121,7 +121,6 @@ ul#snippetOptions { } } - .snippet-message { @include boxPadding(20px, 0); padding: 8px 20px; diff --git a/client/scss/components/_history.scss b/client/scss/components/_history.scss index 7c71ead..a5c0e3a 100644 --- a/client/scss/components/_history.scss +++ b/client/scss/components/_history.scss @@ -1,6 +1,3 @@ - - - .history-header { @include boxPadding(15px, 15px); margin: 0; @@ -32,5 +29,3 @@ @include boxPadding(40px, 40px); color: $textColor; } - - diff --git a/client/scss/components/_text.scss b/client/scss/components/_text.scss index f3b19c5..035bb0f 100644 --- a/client/scss/components/_text.scss +++ b/client/scss/components/_text.scss @@ -1,3 +1,6 @@ +.snippet-text { + background-color: $bgColor; +} // Generic content pages such as About/404/500 // and base styles for text based lexer. diff --git a/dpaste/apps.py b/dpaste/apps.py index fa4c0a3..f82222b 100644 --- a/dpaste/apps.py +++ b/dpaste/apps.py @@ -1,6 +1,7 @@ from django.apps import AppConfig, apps from django.utils.translation import ugettext_lazy as _ + class dpasteAppConfig(AppConfig): name = 'dpaste' verbose_name = 'dpaste' @@ -11,6 +12,8 @@ class dpasteAppConfig(AppConfig): SLUG_LENGTH = 4 # String. A string of characters which are used to create the random slug. + # This is intentionally missing l and I as they look too similar with + # sans-serif fonts. SLUG_CHOICES = 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ1234567890' # String. The lexer key that is pre-selected in the dropdown. Note that @@ -31,7 +34,6 @@ class dpasteAppConfig(AppConfig): # (3600 * 24 * 30 * 12 * 100, _('100 Years')), # ) # - # **Infinite snippets** are supported. You can keep snippets forever when # you set the choice key to ``never``. The management command will ignore # these snippets:: @@ -88,7 +90,6 @@ class dpasteAppConfig(AppConfig): return 'https://{0}'.format(site.domain) return 'https://dpaste.de' - # Key names of the default text and code lexer. PLAIN_TEXT_SYMBOL = '_text' PLAIN_CODE_SYMBOL = '_code' diff --git a/dpaste/highlight.py b/dpaste/highlight.py index 50661a7..3ad41ef 100644 --- a/dpaste/highlight.py +++ b/dpaste/highlight.py @@ -14,15 +14,6 @@ from pygments.util import ClassNotFound logger = getLogger(__file__) config = apps.get_app_config('dpaste') -class NakedHtmlFormatter(HtmlFormatter): - """Pygments HTML formatter with no further HTML tags.""" - def wrap(self, source, outfile): - return self._wrap_code(source) - - def _wrap_code(self, source): - for i, t in source: - yield i, t - # ----------------------------------------------------------------------------- # Highlight Code Snippets @@ -62,7 +53,6 @@ class PlainTextHighlighter(Highlighter): return linebreaksbr(code_string) - class MarkdownHighlighter(PlainTextHighlighter): """Markdown""" extensions = ('tables', 'fenced-code', 'footnotes', 'autolink,', @@ -101,12 +91,25 @@ class RestructuredTextHighlighter(PlainTextHighlighter): # ----------------------------------------------------------------------------- -class PlainCodeHighlighter(Highlighter): - """Plain Code. No highlighting but Pygments like span tags around each line.""" +class NakedHtmlFormatter(HtmlFormatter): + """Pygments HTML formatter with no further HTML tags.""" + def wrap(self, source, outfile): + return self._wrap_code(source) + def _wrap_code(self, source): + for i, t in source: + yield i, t + + +class PlainCodeHighlighter(Highlighter): + """ + Plain Code. No highlighting but Pygments like span tags around each line. + """ def highlight(self, code_string, **kwargs): - return '\n'.join(['{}'.format(escape(l) or '​') - for l in code_string.splitlines()]) + return '\n'.join([ + '{}'.format(escape(l) or '​') + for l in code_string.splitlines() + ]) class PygmentsHighlighter(Highlighter): diff --git a/dpaste/templates/dpaste/history.html b/dpaste/templates/dpaste/history.html index cd4845b..d6a2bd3 100644 --- a/dpaste/templates/dpaste/history.html +++ b/dpaste/templates/dpaste/history.html @@ -40,9 +40,7 @@ {% blocktrans with snippet.published|timesince as since %}Created {{ since }} ago{% endblocktrans %} - {{ snippet.highlight }} - {% empty %}

{% trans "No snippets saved. Either all your snippets are expired or your cookie has changed." %}

diff --git a/dpaste/tests/test_highlight.py b/dpaste/tests/test_highlight.py index bf0b514..50234ff 100644 --- a/dpaste/tests/test_highlight.py +++ b/dpaste/tests/test_highlight.py @@ -79,7 +79,6 @@ class HighlightAPITestCase(TestCase): value = PygmentsHighlighter().highlight(input, 'python') self.assertEqual(value, expected) - def test_broken_rst_syntax(self): """ rst Syntax thats not valid must not raise an exception (SystemMessage) diff --git a/dpaste/views.py b/dpaste/views.py index 9bc8518..b9b3953 100644 --- a/dpaste/views.py +++ b/dpaste/views.py @@ -78,8 +78,8 @@ class SnippetDetailView(SnippetView, DetailView): snippet = self.get_object() # One-Time snippet get deleted if the view count matches our limit - if snippet.expire_type == Snippet.EXPIRE_ONETIME \ - and snippet.view_count >= config.ONETIME_LIMIT: + if (snippet.expire_type == Snippet.EXPIRE_ONETIME and + snippet.view_count >= config.ONETIME_LIMIT): snippet.delete() raise Http404() @@ -274,5 +274,6 @@ class APIView(View): def page_not_found(request, exception=None, template_name='dpaste/404.html'): return django_page_not_found(request, exception, template_name=template_name) + def server_error(request, template_name='dpaste/500.html'): return django_server_error(request, template_name=template_name) # pragma: no cover