瀏覽代碼

Remove CodeBlock (Formatted Code Block)

Timothy Allen 6 年之前
父節點
當前提交
6c5eba5ca2

+ 0 - 1
coderedcms/blocks/__init__.py

@@ -26,7 +26,6 @@ HTML_STREAMBLOCKS = [
     ('quote', QuoteBlock()),
     ('table', TableBlock()),
     ('google_map', EmbedGoogleMapBlock()),
-    ('code', CodeBlock()),
 ]
 
 CONTENT_STREAMBLOCKS = HTML_STREAMBLOCKS + [

+ 0 - 53
coderedcms/blocks/html_blocks.py

@@ -3,12 +3,7 @@ HTML blocks are simple blocks used to represent common HTML elements,
 with additional styling and attributes.
 """
 
-from django.utils.html import format_html
-from django.utils.safestring import mark_safe
 from django.utils.translation import ugettext_lazy as _
-from pygments import highlight
-from pygments.lexers import get_all_lexers, get_lexer_by_name
-from pygments.formatters import HtmlFormatter
 from wagtail.contrib.table_block.blocks import TableBlock as WagtailTableBlock
 from wagtail.core import blocks
 from wagtail.documents.blocks import DocumentChooserBlock
@@ -29,54 +24,6 @@ class ButtonBlock(ButtonMixin, BaseLinkBlock):
         value_class = LinkStructValue
 
 
-class CodeBlock(BaseBlock):
-    """
-    Source code with syntax highlighting in a <pre> tag.
-    """
-    LANGUAGE_CHOICES = []
-
-    for lex in get_all_lexers():
-        LANGUAGE_CHOICES.append((lex[1][0], lex[0]))
-
-    language = blocks.ChoiceBlock(
-        required=False,
-        choices=LANGUAGE_CHOICES,
-        label=_('Syntax highlighting'),
-    )
-    title = blocks.CharBlock(
-        required=False,
-        max_length=255,
-        label=_('Title'),
-    )
-    code = blocks.TextBlock(
-        classname='monospace',
-        rows=8,
-        label=('Code'),
-        help_text=_('Code is rendered in a <pre> tag.'),
-    )
-
-    def get_context(self, value, parent_context=None):
-        ctx = super(CodeBlock, self).get_context(value, parent_context)
-
-        if value['language']:
-            src = value['code'].strip('\n')
-            lexer = get_lexer_by_name(value['language'])
-            code_html = mark_safe(highlight(src, lexer, HtmlFormatter()))
-        else:
-            code_html = format_html('<pre>{}</pre>', value['code'])
-
-        ctx.update({
-            'code_html': code_html,
-        })
-
-        return ctx
-
-    class Meta:
-        template = 'coderedcms/blocks/code_block.html'
-        icon = 'fa-file-code-o'
-        label = _('Formatted Code')
-
-
 class DownloadBlock(ButtonMixin, BaseBlock):
     """
     Link to a file that can be downloaded.

File diff suppressed because it is too large
+ 22 - 0
coderedcms/migrations/0005_alter_content_field.py


+ 0 - 12
coderedcms/templates/coderedcms/blocks/code_block.html

@@ -1,12 +0,0 @@
-{% extends "coderedcms/blocks/base_block.html" %}
-
-{% block block_render %}
-
-{% if self.title %}
-<div class="code-title bg-primary text-white">{{self.title}}</div>
-{% endif %}
-<div class="pygments bg-light">
-    {{code_html}}
-</div>
-
-{% endblock %}

+ 0 - 1
setup.py

@@ -45,7 +45,6 @@ setup(
         'django>=1.11,<2.2',
         'geocoder>=1.38.1,<2.0',
         'icalendar==4.0.*',
-        'pygments>=2.2.0,<3.0',
         'wagtail==2.3.*',
         'wagtailfontawesome>=1.1.3,<2.0',
         'wagtail-cache==0.2.*',

Some files were not shown because too many files changed in this diff