Skip to content

Commit

Permalink
Merge pull request #416 from Princeton-CDH/feature/code-blocks
Browse files Browse the repository at this point in the history
Add support for code blocks
  • Loading branch information
rlskoeser authored Aug 9, 2023
2 parents 2b7be76 + c6ea0f7 commit c2daf95
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

3.5
---

- Added `wagtailcodeblock` to support formatted code in content pages

3.4.5
-----
- updated to django 4.2 and wagtail 5.0
Expand Down
2 changes: 2 additions & 0 deletions cdhweb/pages/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from wagtail.search import index
from wagtail.snippets.blocks import SnippetChooserBlock
from wagtail.snippets.models import register_snippet
from wagtailcodeblock.blocks import CodeBlock
from wagtailmenus.models import AbstractLinkPage
from wagtailmenus.panels import linkpage_tab

Expand Down Expand Up @@ -114,6 +115,7 @@ class BodyContentBlock(StreamBlock):
migrated = RichTextBlock(
features=PARAGRAPH_FEATURES + ["image", "embed"], icon="warning"
)
code = CodeBlock(label="Code")


class AttachmentBlock(StreamBlock):
Expand Down
22 changes: 22 additions & 0 deletions cdhweb/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"compressor",
"fullurl",
"django_cas_ng",
"wagtailcodeblock",
"pucas",
# local apps
"cdhweb.projects",
Expand Down Expand Up @@ -395,6 +396,27 @@
}


WAGTAIL_CODE_BLOCK_THEME = "coy"

WAGTAIL_CODE_BLOCK_LANGUAGES = (
# default
("bash", "Bash/Shell"),
("css", "CSS"),
("diff", "diff"),
("html", "HTML"),
("javascript", "Javascript"),
("json", "JSON"),
("python", "Python"),
("scss", "SCSS"),
("yaml", "YAML"),
# extras
("django", "Django/Jinja2"),
("git", "Git"),
("go", "Go"),
("markup", "Markup + HTML + XML + SVG + MathML"),
("r", "R"),
)

CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.filebased.FileBasedCache",
Expand Down
3 changes: 2 additions & 1 deletion requirements/prod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ django-fullurl
django-apptemplates
wagtailmenus>=3.1
opencv-python
bleach
bleach
wagtailcodeblock

0 comments on commit c2daf95

Please sign in to comment.