Code Monkey home page Code Monkey logo

djangocms-style's Introduction

django CMS Style

pypi build coverage

django CMS Style is a plugin for django CMS that allows you to create a HTML container containing classes, styles, ids and other attributes definable through the plugins settings.

Note

This project is considered 3rd party (no supervision by the django CMS Association). Join us on Slack for more information.

image

Contribute to this project and win rewards

Because this is a an open-source project, we welcome everyone to get involved in the project and receive a reward for their contribution. Become part of a fantastic community and help us make django CMS the best CMS in the world.

We'll be delighted to receive your feedback in the form of issues and pull requests. Before submitting your pull request, please review our contribution guidelines.

We're grateful to all contributors who have helped create and maintain this package. Contributors are listed at the contributors section.

Documentation

See REQUIREMENTS in the setup.py file for additional dependencies:

python django djangocms

Installation

For a manual install:

  • run pip install djangocms-style
  • add djangocms_style to your INSTALLED_APPS
  • run python manage.py migrate djangocms_style

Configuration

django CMS Style enables you to provide a list of predefined classes to be displayed as first options, the default choices are: :

DJANGOCMS_STYLE_CHOICES = ['container', 'content', 'teaser']

You are encouraged to modify that setting to your projects specifications.

This addon provides a default template for all instances. You can provide additional template choices by adding a DJANGOCMS_STYLE_TEMPLATES setting:

DJANGOCMS_STYLE_TEMPLATES = [
    ('feature', _('Feature')),
]

You'll need to create the feature folder inside templates/djangocms_style/ otherwise you will get a template does not exist error. You can do this by copying the default folder inside that directory and renaming it to feature.

The available tags can also be configured, the default choices are: :

DJANGOCMS_STYLE_TAGS = ['div', 'article', 'section', 'header', 'footer',
                        'h1', 'h2', 'h3', 'h4', 'h5', 'h6']

NOTICE:

All tags included in this list should be "paired tags" that require a
closing tag. It does not make sense to attempt to use 'img', 'input',
'meta', or other self-closing tags in this setting.

Also, the developer is advised to choose the tag-types wisely to avoid HTML
validation issues and/or unintentional security vulnerabilities. For
example, the 'script' tag should never be allowed in
``DJANGOCMS_STYLE_TAGS`` (though, we do not prevent this). If you have
an application where you find yourself wishing to do this, please see
djangocms-snippet as an alternative, but note these projects also come
with appropriate security warnings.

After that you can place any number of other plugins inside this style plugin. It will create a div (or other tag-type) with a class that was prior selected around the contained plugins.

Running Tests

You can run tests by executing:

virtualenv env
source env/bin/activate
pip install -r tests/requirements.txt
python setup.py test

djangocms-style's People

Contributors

armicron avatar asmaps avatar beniwohli avatar bhrutledge avatar bplociennik avatar crydotsnake avatar czpython avatar digi604 avatar filippoiovine avatar finalangel avatar fsbraun avatar jsma avatar leo-naeka avatar marksweb avatar mkoistinen avatar mogoh avatar nicolairidani avatar ojii avatar pierremanceaux avatar stefanfoulis avatar tidenhub avatar vthaian avatar vxsx avatar yakky avatar zerok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

djangocms-style's Issues

Alternative to djangocms-style

Started as a fork of this project, https://github.com/jrief/djangocms-cascade , now is a mature framework to manage a subtree of the DOM inside DjangoCMS placeholders.

Currently it works with Bootstrap-3.1, but in theory any other CSS framework can be added.

Thanks for seeding this project and please feel free to comment on djangocms-cascade. I would be pleased to put it under the hood of divio.

Jacob

additional_classes class order being destroyed by 'set(...)'.

Hi,
Working with Semantic-UI css framework I need to care about css class names order I set styling items.

For example:
additional classes = "sixteen, wide, column"

after passing thru line 221 / models.py (djangocms-style 2.0.1):
self.additional_classes = ', '.join(set(additional_classes))
(clearly to purge redundant class names)

become:
additional classes = 'column,wide,sixteen'
losing class order when rendered.

Useful idea

Hello, I'm creating my template and found, among several, a catch that I thought was necessary inclusion, it's about adding a text inside the element, example: <span class = "sr-only"> Toggle navigation </ span> . Using the plugin of the form that is, we can create the whole structure, execto put the text 'Toggle navigation'. On my own, I've added this functionality to my local environment, but I find it interesting to be implemented in the plugin.

Padding issue

There is an issue concerning the paddings:
in line 64 in model.py it should be "self.padding_bottom" instead of "self.padding_right"

At the moment, if you only set padding-top and padding-bottom and leave left and right empty, you dont't get any padding at all...

Issue with CMS_STYLE_NAMES

Once this is activated in settings.py

CMS_STYLE_NAMES = (
    ('style1', _("style1")),
    ('style2', _("style2")),
    ('style3', _("style3")),
)

The application errors on:

NameError: name '_' is not defined 

Happens on the first style. Thoughts?

Changing settings results in missing migrations

I just upgraded to 2.0.0, and discovered that setting DJANGOCMS_STYLE_CHOICES and DJANGOCMS_STYLE_TEMPLATES results in changing the choices for class_name and template, which necessitates new migrations.

I've pasted the relevant bits below. It looks any djangocms plugin that uses this pattern (-link, -picture, etc.) will display this behavior. I am not an expert on migrations, so it's not clear to me what problems it might cause, but it make me nervous about future conflicts, and having migrations outside of source control.

In my settings.py:

DJANGOCMS_STYLE_CHOICES = [
    'm-section',
    'm-highlight',
    'm-recommended',
    'm-content-icon',
    'm-content-title',
    'm-content-body',
    'm-column',
]

DJANGOCMS_STYLE_TEMPLATES = [
    ('recommended', 'Recommended For You'),
]

Output of python manage.py makemigrations:

Migrations for 'djangocms_style':
  0008_auto_20161116_1358.py:
    - Alter field class_name on style
    - Alter field template on style

Contents of venv/lib/python2.7/site-packages/djangocms_style/migrations/0008_auto_20161116_1358.py:

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('djangocms_style', '0007_style_template'),
    ]

    operations = [
        migrations.AlterField(
            model_name='style',
            name='class_name',
            field=models.CharField(default=b'm-section', max_length=255, verbose_name='Class name', blank=True, choices=[(b'm-section', b'm-section'), (b'm-highlight', b'm-highlight'), (b'm-recommended', b'm-recommended'), (b'm-content-icon', b'm-content-icon'), (b'm-content-title', b'm-content-title'), (b'm-content-body', b'm-content-body'), (b'm-column', b'm-column')]),
        ),
        migrations.AlterField(
            model_name='style',
            name='template',
            field=models.CharField(default='default', max_length=255, verbose_name='Template', choices=[('default', 'Default'), (b'recommended', b'Recommended For You')]),
        ),
    ]

Do not install tests

--- setup.py.orig	2018-11-08 08:19:23.000000000 +0000
+++ setup.py
@@ -40,7 +40,7 @@ setup(
     url='https://github.com/divio/djangocms-style',
     license='BSD',
     long_description=open('README.rst').read(),
-    packages=find_packages(),
+    packages=find_packages(exclude=['tests']),
     include_package_data=True,
     zip_safe=False,
     install_requires=REQUIREMENTS,

"Style" Plugin needs more HTML attribute options

I am looking to add a "Style" plugin so I can write the following code:

  <div class="container-fluid">

But when I look in the Advanced Settings I don't see any ways to add the particular HTML attribute.
screen shot 2015-11-26 at 10 32 58 am

I would like to open up a ticket to allowm more HTML attribute options to be available for the Style Plugin, more specifically:

  • id
  • class
  • style
  • onclick

[BUG] Missing migrations for cmsplugin_ptr

Description

djangocms 3.11.4 is missing migrations for plugins.

Steps to reproduce

  1. Install e.g. djangocms 3.11.0 with django 4.0
  2. Create a new project and add django cms to the INSTALLED_APPS as per the instructions
  3. Install a plugin, e.g. djangocms_column, djangocms_googlemap, djangocms_picture, djangocms_style, or djangocms_video
  4. Run ./manage.py migrate
  5. Run pip install -U django-cms
  6. Run ./manage.py makemigrations and notice that there are missing migrations for every plugin

Expected behaviour

Migrations are part of the packages.

Actual behaviour

Migrations are missing.

Screenshots

Example missing migration for cmsplugin_style:

Migrations for 'djangocms_style': 
  env/lib/python3.10/site-packages/djangocms_style/migrations/0008_alter_style_cmsplugin_ptr.py
    - Alter field cmsplugin_ptr on style                                        
Full migrations file '0008_alter_style_cmsplugin_ptr.py':                       
# Generated by Django 4.2.5 on 2023-09-26 12:31                                 
                                                                                
from django.db import migrations, models                                        
import django.db.models.deletion                                                
                                                                                
                                                                                
class Migration(migrations.Migration):                                          
                                                                                
    dependencies = [                                                            
        ('cms', '0022_auto_20180620_1551'),                                     
        ('djangocms_style', '0007_style_template'),                             
    ]                                                                           
                                                                                
    operations = [
        migrations.AlterField(
            model_name='style',
            name='cmsplugin_ptr',
            field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='%(app_label)s_%(class)s', serialize=False, to='cms.cmsplugin'),
        ),
    ]

Do you want to help fix this issue?

  • Yes, I want to help fix this issue and I will join #workgroup-pr-review on Slack to confirm with the community that a PR is welcome.
  • No, I only want to report the issue.

Add templates for styles?

I'm not sure this is the right place for this suggestion, or if it's already been done elsewhere, but here goes...

I think it would be handy to associate a Django template with entries in DJANGOCMS_STYLE_CHOICES, similar to how djangocms-link and -picture have optional templates.

My immediate use case is a "Recommended for You" section, with markup that looks something like this:

<section class="rec-section">
    <h2>Recommended For You</h2>
    <div class="rec-list">
        <a class="rec-item" href="...">
            <img class="rec-thumb" src="...">
            <div class="rec-title">First title</div>
        </a>
        <a class="rec-item" href="...">
            <img class="rec-thumb" src="...">
            <div class="rec-title">Second title</div>
        </a>
    </div>
</section>

Currently, to implement that, I think I my plugin structure would look something like this:

Style: .rec-section
  Text: <h2>Recommended For You</h2>
  Style: .rec-list
    Link: [href="..."]
      Text: .rec-thumb and .rec-title
    Link: [href="..."]
      Text: .rec-thumb and .rec-title

But, with a template that's mapped to .rec-section, and contains the h2 and div.rec-list wrapper, the structure could be:

Style: .rec-section
  Link: [href="..."]
    Text: .rec-thumb and .rec-title
  Link: [href="..."]
    Text: .rec-thumb and .rec-title

Overzealous whitespace removal

# The formatting of this file is very specific to remove unnecessary whitespaces

 id="{{ instance.id_name }}"{% endif %}{% spaceless %}
{% endspaceless %}{% if instance.class_name or instance.additional_classes %}class="{% spaceless %}

This creates a HTML tag ala id="foo"class="bar"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.