diff --git a/dpaste/highlight.py b/dpaste/highlight.py index 3ab69bd..79981b9 100644 --- a/dpaste/highlight.py +++ b/dpaste/highlight.py @@ -29,10 +29,10 @@ PLAIN_CODE = '_code' # lexer name of code with no hihglighting LEXER_LIST = getattr(settings, 'DPASTE_LEXER_LIST', ( (_('Text'), ( - ('_text_plain', 'Plain Text'), - ('_text_markdown', 'Markdown'), - ('_text_rst', 'reStructuredText'), - ('_text_textile', 'Textile'), + ('text', 'Plain Text'), + # ('_text_markdown', 'Markdown'), + # ('_text_rst', 'reStructuredText'), + # ('_text_textile', 'Textile'), )), (_('Code'), ( (PLAIN_CODE, 'Plain Code'), diff --git a/dpaste/migrations/0003_snippet_highlighted.py b/dpaste/migrations/0003_snippet_highlighted.py new file mode 100644 index 0000000..79597ce --- /dev/null +++ b/dpaste/migrations/0003_snippet_highlighted.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11a1 on 2017-01-21 16:04 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dpaste', '0002_auto_20170119_1038'), + ] + + operations = [ + migrations.AddField( + model_name='snippet', + name='highlighted', + field=models.TextField(default='', verbose_name='Highlighted Content'), + preserve_default=False, + ), + ] diff --git a/dpaste/models.py b/dpaste/models.py index cb98bc2..87d04b2 100644 --- a/dpaste/models.py +++ b/dpaste/models.py @@ -10,6 +10,7 @@ from .highlight import LEXER_DEFAULT R = SystemRandom() ONETIME_LIMIT = getattr(settings, 'DPASTE_ONETIME_LIMIT', 2) + def generate_secret_id(length=None, alphabet=None, tries=0): length = length or getattr(settings, 'DPASTE_SLUG_LENGTH', 4) alphabet = alphabet or getattr(settings, 'DPASTE_SLUG_CHOICES', @@ -26,6 +27,7 @@ def generate_secret_id(length=None, alphabet=None, tries=0): # regular one. return generate_secret_id(length=length+1, tries=tries) + class Snippet(models.Model): EXPIRE_TIME = 1 EXPIRE_KEEP = 2 @@ -39,6 +41,7 @@ class Snippet(models.Model): secret_id = models.CharField(_(u'Secret ID'), max_length=255, blank=True, null=True, unique=True) content = models.TextField(_(u'Content')) + highlighted = models.TextField(_(u'Highlighted Content')) lexer = models.CharField(_(u'Lexer'), max_length=30, default=LEXER_DEFAULT) published = models.DateTimeField(_(u'Published'), auto_now_add=True) expire_type = models.PositiveSmallIntegerField(_(u'Expire Type'), diff --git a/dpaste/templates/dpaste/highlight/code.html b/dpaste/templates/dpaste/highlight/code.html new file mode 100644 index 0000000..4c9ef72 --- /dev/null +++ b/dpaste/templates/dpaste/highlight/code.html @@ -0,0 +1 @@ +