Skip to content

Commit

Permalink
Fixes (#20)
Browse files Browse the repository at this point in the history
* disable for now

* remove span from the standard list

only allow block elements per default

* allow badges to be added in text-enabled plugins

* make sure link doesn’t leak classes

* simplified cards system

* added aspect ratio for carousel

* make collapsable simpler

* do not import all of bootstrap

* webpack and webpack:watch should be separate

* use proper close sign for preview

* Add compiled files to the repo
  • Loading branch information
vxsx authored and FinalAngel committed Dec 21, 2017
1 parent 08bb0af commit 67277e6
Show file tree
Hide file tree
Showing 27 changed files with 3,781 additions and 425 deletions.
3 changes: 2 additions & 1 deletion djangocms_bootstrap4/constants.py
Expand Up @@ -15,10 +15,11 @@
)
DEVICE_SIZES = tuple([size for size, name in DEVICE_CHOICES])

# Only adding block elements
TAG_CHOICES = getattr(
settings,
'DJANGOCMS_BOOTSTRAP4_TAG_CHOICES',
['div', 'section', 'article', 'header', 'footer', 'aside', 'span'],
['div', 'section', 'article', 'header', 'footer', 'aside'],
)
TAG_CHOICES = tuple((entry, entry) for entry in TAG_CHOICES)

Expand Down
Expand Up @@ -22,6 +22,7 @@ class Bootstrap4BadgePlugin(CMSPluginBase):
module = _('Bootstrap 4')
render_template = 'djangocms_bootstrap4/badge.html'
change_form_template = 'djangocms_bootstrap4/admin/badge.html'
text_enabled = True

fieldsets = [
(None, {
Expand Down
121 changes: 0 additions & 121 deletions djangocms_bootstrap4/contrib/bootstrap4_card/blueprints.py

This file was deleted.

121 changes: 3 additions & 118 deletions djangocms_bootstrap4/contrib/bootstrap4_card/cms_plugins.py
Expand Up @@ -9,18 +9,7 @@

from djangocms_bootstrap4.helpers import concat_classes

# from .blueprints import (
# create_card_blueprint,
# create_panel_blueprint,
# create_teaser_blueprint,
# )
from .models import (
Bootstrap4Card,
Bootstrap4CardInner,
Bootstrap4CardContent,
Bootstrap4CardImage,
)
from .forms import Bootstrap4CardForm
from .models import Bootstrap4Card, Bootstrap4CardInner


class Bootstrap4CardPlugin(CMSPluginBase):
Expand All @@ -31,25 +20,18 @@ class Bootstrap4CardPlugin(CMSPluginBase):
model = Bootstrap4Card
name = _('Card')
module = _('Bootstrap 4')
form = Bootstrap4CardForm
render_template = 'djangocms_bootstrap4/card.html'
change_form_template = 'djangocms_bootstrap4/admin/card.html'
allow_children = True
child_classes = [
'Bootstrap4CardPlugin',
'Bootstrap4CardInnerPlugin',
'Bootstrap4CardImagePlugin',
'Bootstrap4LinkPlugin',
'Bootstrap4ListGroupPlugin',
'Bootstrap4PicturePlugin',
]
# TODO also allow for Blockquote, Nav Tabs

fieldsets = [
# (_('Blueprints'), {
# 'classes': ('collapse',),
# 'fields': (
# 'blueprint',
# )
# }),
(None, {
'fields': (
'card_type',
Expand All @@ -66,18 +48,6 @@ class Bootstrap4CardPlugin(CMSPluginBase):
}),
]

# def save_model(self, request, obj, form, change):
# super(Bootstrap4CardPlugin, self).save_model(request, obj, form, change)
# data = form.cleaned_data
#
# if data['blueprint']:
# if data['blueprint'] == 'card':
# create_card_blueprint(obj)
# if data['blueprint'] == 'panel':
# create_panel_blueprint(obj)
# if data['blueprint'] == 'teaser':
# create_teaser_blueprint(obj)

def render(self, context, instance, placeholder):
link_classes = []
if instance.card_type:
Expand Down Expand Up @@ -141,90 +111,5 @@ def render(self, context, instance, placeholder):
)


class Bootstrap4CardContentPlugin(CMSPluginBase):
"""
Components > "Card - Content" Plugin (Title, Subtitle, Text, Link)
https://getbootstrap.com/docs/4.0/components/card/
"""
model = Bootstrap4CardContent
name = _('Card content')
module = _('Bootstrap 4')
render_template = 'djangocms_bootstrap4/card_content.html'
allow_children = True
parent_classes = [
'Bootstrap4CardInnerPlugin',
'Bootstrap4CardImagePlugin',
'Bootstrap4CollapseTriggerPlugin',
'Bootstrap4CollapseContainerPlugin',
]

fieldsets = [
(None, {
'fields': (
('content_type', 'tag_type'),
'card_content',
'attributes',
)
}),
]

def render(self, context, instance, placeholder):
link_classes = []
if instance.content_type:
link_classes.append(instance.content_type)

classes = concat_classes(link_classes + [
instance.attributes.get('class'),
])
instance.attributes['class'] = classes

return super(Bootstrap4CardContentPlugin, self).render(
context, instance, placeholder
)


class Bootstrap4CardImagePlugin(CMSPluginBase):
"""
Components > "Card - Image" Plugin (Top, Bottom, Overlay)
https://getbootstrap.com/docs/4.0/components/card/
"""
model = Bootstrap4CardImage
name = _('Card image')
module = _('Bootstrap 4')
render_template = 'djangocms_bootstrap4/card.html'
allow_children = True
parent_classes = [
'Bootstrap4CardPlugin',
'Bootstrap4CardInnerPlugin',
]

fieldsets = [
(None, {
'fields': (
('content_type', 'tag_type'),
'attributes',
)
}),
]

def render(self, context, instance, placeholder):
link_classes = []
if instance.content_type:
link_classes.append(instance.content_type)
else:
link_classes.append('card-img')

classes = concat_classes(link_classes + [
instance.attributes.get('class'),
])
instance.attributes['class'] = classes

return super(Bootstrap4CardImagePlugin, self).render(
context, instance, placeholder
)


plugin_pool.register_plugin(Bootstrap4CardPlugin)
plugin_pool.register_plugin(Bootstrap4CardInnerPlugin)
plugin_pool.register_plugin(Bootstrap4CardContentPlugin)
plugin_pool.register_plugin(Bootstrap4CardImagePlugin)
24 changes: 2 additions & 22 deletions djangocms_bootstrap4/contrib/bootstrap4_card/constants.py
Expand Up @@ -5,13 +5,6 @@
from django.utils.translation import ugettext_lazy as _


CARD_BLUEPRINTS = (
('', '-----'),
('card', _('Card')), # image, body (title, text, button)
('panel', _('Panel')), # header, body (title, text, button)
('teaser', _('Teaser')), # body (title, text, button)
)

CARD_TYPES = (
('card', _('Card')),
('card-group', _('Card group')),
Expand All @@ -25,19 +18,12 @@
('text-right', _('Right')),
)

CARD_INNER_TYPE = (
('card-header', _('Header')),
CARD_INNER_TYPES = (
('card-body', _('Body')),
('card-header', _('Header')),
('card-footer', _('Footer')),
)

CARD_CONTENT_TYPE = (
('card-text', _('Text')),
('card-title', _('Title')),
('card-subtitle', _('Subtitle')),
('card-link', _('Link')),
)

CARD_TAG_CHOICES = (
('div', 'DIV'),
('h1', 'H1'),
Expand All @@ -49,9 +35,3 @@
('p', 'P'),
('small', 'SMALL'),
)

CARD_IMAGE_TYPE = (
('card-img-top', _('Image top')),
('card-img-bottom', _('Image bottom')),
('card-img-overlay', _('Image overlay')),
)
30 changes: 0 additions & 30 deletions djangocms_bootstrap4/contrib/bootstrap4_card/forms.py

This file was deleted.

0 comments on commit 67277e6

Please sign in to comment.