mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-15 08:02:54 +11:00
Code cleanup
This commit is contained in:
parent
eb6dcb2b08
commit
aef701ec89
12 changed files with 26 additions and 41 deletions
|
@ -1,4 +1,3 @@
|
|||
|
||||
// Global padding across all first level elements
|
||||
@mixin boxPadding($paddingTop: 20px, $paddingBottom: 20px) {
|
||||
padding: $paddingTop $boxPadding $paddingBottom $boxPadding;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
.snippet-text {
|
||||
background-color: $bgColor;
|
||||
}
|
||||
|
||||
.snippet-diff {
|
||||
color: $codeTextColor;
|
||||
background-color: $codeBgColor;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
line-height: 17px;
|
||||
}
|
||||
|
||||
|
||||
.snippet-form {
|
||||
background-color: $bgColor;
|
||||
|
||||
|
@ -82,4 +81,3 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,6 @@ ul#snippetOptions {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
.snippet-message {
|
||||
@include boxPadding(20px, 0);
|
||||
padding: 8px 20px;
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
|
||||
|
||||
|
||||
.history-header {
|
||||
@include boxPadding(15px, 15px);
|
||||
margin: 0;
|
||||
|
@ -32,5 +29,3 @@
|
|||
@include boxPadding(40px, 40px);
|
||||
color: $textColor;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
.snippet-text {
|
||||
background-color: $bgColor;
|
||||
}
|
||||
|
||||
// Generic content pages such as About/404/500
|
||||
// and base styles for text based lexer.
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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(['<span class="plain">{}</span>'.format(escape(l) or '​')
|
||||
for l in code_string.splitlines()])
|
||||
return '\n'.join([
|
||||
'<span class="plain">{}</span>'.format(escape(l) or '​')
|
||||
for l in code_string.splitlines()
|
||||
])
|
||||
|
||||
|
||||
class PygmentsHighlighter(Highlighter):
|
||||
|
|
|
@ -40,9 +40,7 @@
|
|||
<span class="sep"></span>
|
||||
{% blocktrans with snippet.published|timesince as since %}Created {{ since }} ago{% endblocktrans %}
|
||||
</h3>
|
||||
|
||||
{{ snippet.highlight }}
|
||||
|
||||
{% empty %}
|
||||
<p class="history-empty">
|
||||
{% trans "No snippets saved. Either all your snippets are expired or your cookie has changed." %}</p>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue