-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into task/GH-93-GH-142-GH-133-article-list-plugin…
…s-and-styles--no-reverts
- Loading branch information
Showing
50 changed files
with
1,527 additions
and
29 deletions.
There are no files selected for viewing
Empty file.
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
Empty file.
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,66 @@ | ||
from cms.plugin_base import CMSPluginBase | ||
from cms.plugin_pool import plugin_pool | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from taccsite_cms.contrib.helpers import concat_classnames | ||
from taccsite_cms.contrib.taccsite_offset.cms_plugins import get_direction_classname | ||
|
||
from .models import TaccsiteBlockquote | ||
|
||
@plugin_pool.register_plugin | ||
class TaccsiteBlockquotePlugin(CMSPluginBase): | ||
""" | ||
Components > "Blockquote" Plugin | ||
https://confluence.tacc.utexas.edu/x/FIEjCQ | ||
""" | ||
module = 'TACC Site' | ||
model = TaccsiteBlockquote | ||
name = _('Blockquote') | ||
render_template = 'blockquote.html' | ||
|
||
cache = True | ||
text_enabled = True | ||
allow_children = False | ||
|
||
fieldsets = [ | ||
(None, { | ||
'fields': ( | ||
'text', | ||
'origin', | ||
'use_cite', | ||
) | ||
}), | ||
(_('Citation'), { | ||
'classes': ('collapse',), | ||
'fields': ( | ||
'cite_person', | ||
('cite_text', 'cite_url'), | ||
) | ||
}), | ||
(_('Layout'), { | ||
'fields': ( | ||
'offset', | ||
) | ||
}), | ||
(_('Advanced settings'), { | ||
'classes': ('collapse',), | ||
'fields': ( | ||
'attributes', | ||
) | ||
}), | ||
] | ||
|
||
# Render | ||
|
||
def render(self, context, instance, placeholder): | ||
context = super().render(context, instance, placeholder) | ||
request = context['request'] | ||
|
||
classes = concat_classnames([ | ||
's-blockquote', | ||
get_direction_classname(instance.offset), | ||
instance.attributes.get('class'), | ||
]) | ||
instance.attributes['class'] = classes | ||
|
||
return context |
35 changes: 35 additions & 0 deletions
35
taccsite_cms/contrib/taccsite_blockquote/migrations/0001_initial.py
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,35 @@ | ||
# Generated by Django 2.2.16 on 2021-06-22 14:09 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import djangocms_attributes_field.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('cms', '0022_auto_20180620_1551'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='TaccsiteBlockquote', | ||
fields=[ | ||
('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='taccsite_blockquote_taccsiteblockquote', serialize=False, to='cms.CMSPlugin')), | ||
('text', models.TextField(default='', null=True, verbose_name='Quote')), | ||
('origin', models.CharField(blank=True, help_text='The origin of the quote (i.e. citation, attribution) (e.g. author, source). This value is ignored if "Advanced origin" fields have data.', max_length=100)), | ||
('use_cite', models.BooleanField(default=False, verbose_name='Use the "Citation" fields')), | ||
('cite_person', models.CharField(blank=True, help_text='The author or speaker of the quote.', max_length=50, verbose_name='Author / Speaker')), | ||
('cite_text', models.CharField(blank=True, help_text='Text for the source of the quote.', max_length=50, verbose_name='Source Text')), | ||
('cite_url', models.CharField(blank=True, help_text='URL for the source of the quote.', max_length=255, verbose_name='Source URL')), | ||
('offset', models.CharField(blank=True, choices=[('left', 'Left'), ('right', 'Right')], max_length=255)), | ||
('attributes', djangocms_attributes_field.fields.AttributesField(default=dict)), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
bases=('cms.cmsplugin',), | ||
), | ||
] |
Empty file.
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,59 @@ | ||
from cms.models.pluginmodel import CMSPlugin | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from django.db import models | ||
|
||
from djangocms_attributes_field import fields | ||
|
||
from taccsite_cms.contrib.taccsite_offset.models import DIRECTION_CHOICES | ||
|
||
class TaccsiteBlockquote(CMSPlugin): | ||
""" | ||
Components > "Blockquote" Model | ||
https://confluence.tacc.utexas.edu/x/FIEjCQ | ||
""" | ||
text = models.TextField( | ||
verbose_name=_('Quote'), | ||
null=True, | ||
default='', | ||
) | ||
|
||
origin = models.CharField( | ||
help_text=_('The origin of the quote (i.e. citation, attribution) (e.g. author, source). This value is ignored if "Advanced origin" fields have data.'), | ||
blank=True, | ||
max_length=100, | ||
) | ||
|
||
use_cite = models.BooleanField( | ||
verbose_name=_('Use the "Citation" fields'), | ||
default=False, | ||
) | ||
cite_person = models.CharField( | ||
verbose_name=_('Author / Speaker'), | ||
help_text='The author or speaker of the quote.', | ||
blank=True, | ||
max_length=50, | ||
) | ||
cite_text = models.CharField( | ||
verbose_name=_('Source Text'), | ||
help_text=_('Text for the source of the quote.'), | ||
blank=True, | ||
max_length=50, | ||
) | ||
cite_url = models.CharField( | ||
verbose_name=_('Source URL'), | ||
help_text=_('URL for the source of the quote.'), | ||
blank=True, | ||
max_length=255, | ||
) | ||
|
||
offset = models.CharField( | ||
choices=DIRECTION_CHOICES, | ||
blank=True, | ||
max_length=255, | ||
) | ||
|
||
attributes = fields.AttributesField() | ||
|
||
def get_short_description(self): | ||
return self.text |
29 changes: 29 additions & 0 deletions
29
taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html
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,29 @@ | ||
<figure {# class="s-blockquote" #}{{ instance.attributes_str }}> | ||
<blockquote cite="{{ instance.cite_url }}"> | ||
<p>{{ instance.text }}</p> | ||
</blockquote> | ||
{% if instance.use_cite %} | ||
<figcaption> | ||
|
||
{% if instance.cite_person %} | ||
{{ instance.cite_person }}{% if instance.cite_text %},{% endif %} | ||
{% endif %} | ||
|
||
{% if instance.cite_text and instance.cite_url %} | ||
<cite><a href="{{ instance.cite_url }}" target="_blank"> | ||
{{ instance.cite_text }} | ||
</a></cite> | ||
{% endif %} | ||
{% if instance.cite_text and not instance.cite_url %} | ||
<cite> | ||
{{ instance.cite_text }} | ||
</cite> | ||
{% endif %} | ||
|
||
</figcaption> | ||
{% elif instance.origin %} | ||
|
||
<figcaption>{{ instance.origin }}</figcaption> | ||
|
||
{% endif %} | ||
</figure> |
Empty file.
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,108 @@ | ||
from cms.plugin_base import CMSPluginBase | ||
from cms.plugin_pool import plugin_pool | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from djangocms_link.cms_plugins import LinkPlugin | ||
|
||
from taccsite_cms.contrib.helpers import ( | ||
concat_classnames, | ||
get_model_field_name | ||
) | ||
from taccsite_cms.contrib.constants import TEXT_FOR_NESTED_PLUGIN_CONTENT_SWAP | ||
|
||
from .models import TaccsiteCallout | ||
|
||
|
||
|
||
|
||
# Constants | ||
|
||
RESIZE_FIGURE_FIELD_NAME = get_model_field_name(TaccsiteCallout, 'resize_figure_to_fit') | ||
|
||
|
||
|
||
# Plugin | ||
|
||
@plugin_pool.register_plugin | ||
class TaccsiteCalloutPlugin(LinkPlugin): | ||
""" | ||
Components > "Callout" Plugin | ||
https://confluence.tacc.utexas.edu/x/EiIFDg | ||
""" | ||
module = 'TACC Site' | ||
model = TaccsiteCallout | ||
name = _('Callout') | ||
render_template = 'callout.html' | ||
def get_render_template(self, context, instance, placeholder): | ||
return self.render_template | ||
|
||
cache = True | ||
text_enabled = False | ||
allow_children = True | ||
# GH-91: Enable this limitation | ||
# parent_classes = [ | ||
# 'SectionPlugin' | ||
# ] | ||
child_classes = [ | ||
'PicturePlugin' | ||
] | ||
max_children = 1 | ||
|
||
fieldsets = [ | ||
(None, { | ||
'fields': ( | ||
'title', 'description', | ||
), | ||
}), | ||
(_('Link'), { | ||
'fields': ( | ||
('external_link', 'internal_link'), | ||
('anchor', 'target'), | ||
) | ||
}), | ||
(_('Image'), { | ||
'classes': ('collapse',), | ||
'description': TEXT_FOR_NESTED_PLUGIN_CONTENT_SWAP.format( | ||
element='an image', | ||
plugin_name='Image' | ||
) + '\ | ||
<br />\ | ||
If image disappears while editing, then reload the page to reload the image.', | ||
'fields': (), | ||
}), | ||
(_('Advanced settings'), { | ||
'classes': ('collapse',), | ||
'description': 'Only use the "' + RESIZE_FIGURE_FIELD_NAME + '" in emergencies. It is preferable to resize the image. <small>When the "Advanced settings" field "' + RESIZE_FIGURE_FIELD_NAME + '" is checked, the image may disappear after saving this plugin (because of a JavaScript race condition). Using a server-side solution would eliminate this caveat.</small>', | ||
'fields': ( | ||
'resize_figure_to_fit', | ||
'attributes', | ||
) | ||
}), | ||
] | ||
|
||
# Render | ||
|
||
def render(self, context, instance, placeholder): | ||
context = super().render(context, instance, placeholder) | ||
request = context['request'] | ||
has_child_plugin = {} | ||
|
||
# To identify child plugins | ||
for plugin_instance in instance.child_plugin_instances: | ||
if (type(plugin_instance).__name__ == 'Picture'): | ||
has_child_plugin['image'] = True | ||
context.update({ 'image_plugin': plugin_instance }) | ||
|
||
classes = concat_classnames([ | ||
'c-callout', | ||
'c-callout--has-figure' if has_child_plugin.get('image') else '', | ||
'c-callout--is-link' if instance.get_link() else '', | ||
instance.attributes.get('class'), | ||
]) | ||
instance.attributes['class'] = classes | ||
|
||
context.update({ | ||
'link_url': instance.get_link(), | ||
'link_target': instance.target | ||
}) | ||
return context |
Oops, something went wrong.