-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1150 from ubyssey/last-working-authors-bio
Redid merges
- Loading branch information
Showing
26 changed files
with
390 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 3.2.11 on 2023-07-13 21:44 | ||
|
||
from django.db import migrations | ||
import images.models | ||
import wagtail.core.blocks | ||
import wagtail.core.fields | ||
import wagtail.embeds.blocks | ||
import wagtail.images.blocks | ||
import wagtail.snippets.blocks | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('article', '0018_articlepage_noindex'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='articlepage', | ||
name='content', | ||
field=wagtail.core.fields.StreamField([('richtext', wagtail.core.blocks.RichTextBlock(help_text='Write your article contents here. See documentation: https://docs.wagtail.io/en/latest/editor_manual/new_pages/creating_body_content.html#rich-text-fields', label='Rich Text Block')), ('plaintext', wagtail.core.blocks.TextBlock(help_text='Warning: Rich Text Blocks preferred! Plain text primarily exists for importing old Dispatch text.', label='Plain Text Block')), ('dropcap', wagtail.core.blocks.TextBlock(help_text='DO NOT USE - Legacy block. Create a block where special dropcap styling with be applied to the first letter and the first letter only.\n\nThe contents of this block will be enclosed in a <p class="drop-cap">...</p> element, allowing its targetting for styling.\n\nNo RichText allowed.', label='Dropcap Block', template='article/stream_blocks/dropcap.html')), ('video', wagtail.core.blocks.StructBlock([('video_embed', wagtail.embeds.blocks.EmbedBlock(blank=False, null=False)), ('title', wagtail.core.blocks.CharBlock(max_length=255, required=False)), ('caption', wagtail.core.blocks.CharBlock(max_length=255, required=False)), ('credit', wagtail.core.blocks.CharBlock(max_length=255, required=False))], help_text='Use this to credit or caption videos that will only be associated with this current article, rather than entered into our video library. You can also embed videos in a Rich Text Block.', label='Credited/Captioned One-Off Video')), ('image', wagtail.core.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock(required=True)), ('style', wagtail.core.blocks.ChoiceBlock(choices=[('default', 'Default'), ('left', 'Left'), ('right', 'Right')])), ('width', wagtail.core.blocks.ChoiceBlock(choices=[('full', 'Full'), ('small', 'Small'), ('medium', 'Medium'), ('large', 'Large')])), ('caption', wagtail.core.blocks.CharBlock(max_length=255, required=False)), ('credit', wagtail.core.blocks.CharBlock(max_length=255, required=False))])), ('raw_html', wagtail.core.blocks.RawHTMLBlock(help_text="WARNING: DO NOT use this unless you really know what you're doing!", label='Raw HTML Block')), ('quote', wagtail.core.blocks.StructBlock([('content', wagtail.core.blocks.CharBlock(required=False)), ('source', wagtail.core.blocks.CharBlock(required=False))], icon='openquote', label='Pull Quote', template='article/stream_blocks/quote.html')), ('gallery', wagtail.snippets.blocks.SnippetChooserBlock(target_model=images.models.GallerySnippet, template='article/stream_blocks/gallery.html'))], blank=True, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,141 @@ | ||
from django.utils.html import format_html | ||
from django.templatetags.static import static | ||
|
||
|
||
from wagtail.core import hooks | ||
|
||
import wagtail.admin.rich_text.editors.draftail.features as draftail_features | ||
from wagtail.admin.rich_text.converters.html_to_contentstate import InlineStyleElementHandler | ||
|
||
@hooks.register('insert_global_admin_css') | ||
def global_admin_css(): | ||
return format_html('<link rel="stylesheet" href="{}">', static('css/custom.css')) | ||
return format_html('<link rel="stylesheet" href="{}">', static('css/custom.css')) | ||
|
||
# 1. Use the register_rich_text_features hook. | ||
@hooks.register('register_rich_text_features') | ||
def register_strikethrough_feature(features): | ||
""" | ||
Registering the `mark` feature, which uses the `MARK` Draft.js inline style type, | ||
and is stored as HTML with a `<mark>` tag. | ||
""" | ||
feature_name = 'strikethrough' | ||
type_ = 'STRIKETHROUGH' | ||
tag = 'strikethrough' | ||
|
||
# 2. Configure how Draftail handles the feature in its toolbar. | ||
control = { | ||
'type': type_, | ||
'label': 's', | ||
'description': 'Strikethrough', | ||
# This isn’t even required – Draftail has predefined styles for MARK. | ||
# 'style': {'textDecoration': 'line-through'}, | ||
} | ||
|
||
# 3. Call register_editor_plugin to register the configuration for Draftail. | ||
features.register_editor_plugin( | ||
'draftail', feature_name, draftail_features.InlineStyleFeature(control) | ||
) | ||
|
||
# 4.configure the content transform from the DB to the editor and back. | ||
db_conversion = { | ||
'from_database_format': {tag: InlineStyleElementHandler(type_)}, | ||
'to_database_format': {'style_map': {type_: tag}}, | ||
} | ||
|
||
# 5. Call register_converter_rule to register the content transformation conversion. | ||
features.register_converter_rule('contentstate', feature_name, db_conversion) | ||
|
||
# 6. (optional) Add the feature to the default features list to make it available | ||
# on rich text fields that do not specify an explicit 'features' list | ||
features.default_features.append('strikethrough') | ||
|
||
@hooks.register("register_rich_text_features") | ||
def register_centertext_feature(features): | ||
"""Creates centered text in our richtext editor and page.""" | ||
|
||
# Step 1 | ||
feature_name = "center" | ||
type_ = "CENTERTEXT" | ||
tag = "div" | ||
|
||
# Step 2 | ||
control = { | ||
"type": type_, | ||
"label": "Center", | ||
"description": "Center Text", | ||
"style": { | ||
"display": "block", | ||
"text-align": "center", | ||
}, | ||
} | ||
|
||
# Step 3 | ||
features.register_editor_plugin( | ||
"draftail", feature_name, draftail_features.InlineStyleFeature(control) | ||
) | ||
|
||
# Step 4 | ||
db_conversion = { | ||
"from_database_format": {tag: InlineStyleElementHandler(type_)}, | ||
"to_database_format": { | ||
"style_map": { | ||
type_: { | ||
"element": tag, | ||
"props": { | ||
"class": "d-block text-center" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
# Step 5 | ||
features.register_converter_rule("contentstate", feature_name, db_conversion) | ||
|
||
# Step 6, This is optional. | ||
features.default_features.append(feature_name) | ||
|
||
@hooks.register("register_rich_text_features") | ||
def register_righttext_feature(features): | ||
"""Creates centered text in our richtext editor and page.""" | ||
|
||
# Step 1 | ||
feature_name = "right" | ||
type_ = "RIGHTTEXT" | ||
tag = "div" | ||
|
||
# Step 2 | ||
control = { | ||
"type": type_, | ||
"label": "Right", | ||
"description": "Right Text", | ||
"style": { | ||
"display": "block", | ||
"text-align": "right", | ||
}, | ||
} | ||
|
||
# Step 3 | ||
features.register_editor_plugin( | ||
"draftail", feature_name, draftail_features.InlineStyleFeature(control) | ||
) | ||
|
||
# Step 4 | ||
db_conversion = { | ||
"from_database_format": {tag: InlineStyleElementHandler(type_)}, | ||
"to_database_format": { | ||
"style_map": { | ||
type_: { | ||
"element": tag, | ||
"props": { | ||
"class": "d-block text-right" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
# Step 5 | ||
features.register_converter_rule("contentstate", feature_name, db_conversion) | ||
|
||
# Step 6, This is optional. | ||
features.default_features.append(feature_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.