-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
132 additions
and
84 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
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,3 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
__version__ = '5.0.3' | ||
__version__ = '5.1.0' |
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.forms.widgets import flatatt | ||
|
||
from .text import text_value | ||
|
||
|
||
# Handle HTML and CSS manipulation | ||
|
||
|
||
def split_css_classes(css_classes): | ||
""" | ||
Turn string into a list of CSS classes | ||
""" | ||
classes_list = text_value(css_classes).split(' ') | ||
return [c for c in classes_list if c] | ||
|
||
|
||
def add_css_class(css_classes, css_class, prepend=False): | ||
""" | ||
Add a CSS class to a string of CSS classes | ||
""" | ||
classes_list = split_css_classes(css_classes) | ||
classes_to_add = [c for c in split_css_classes(css_class) | ||
if c not in classes_list] | ||
if prepend: | ||
classes_list = classes_to_add + classes_list | ||
else: | ||
classes_list += classes_to_add | ||
return ' '.join(classes_list) | ||
|
||
|
||
def remove_css_class(css_classes, css_class): | ||
""" | ||
Remove a CSS class from a string of CSS classes | ||
""" | ||
remove = set(split_css_classes(css_class)) | ||
classes_list = [c for c in split_css_classes(css_classes) | ||
if c not in remove] | ||
return ' '.join(classes_list) | ||
|
||
|
||
def render_link_tag(url, rel='stylesheet', media='all'): | ||
""" | ||
Build a link tag | ||
""" | ||
return render_tag( | ||
'link', | ||
attrs={'href': url, 'rel': rel, 'media': media}, | ||
close=False) | ||
|
||
|
||
def render_tag(tag, attrs=None, content=None, close=True): | ||
""" | ||
Render a HTML tag | ||
""" | ||
builder = '<{tag}{attrs}>{content}' | ||
if content or close: | ||
builder += '</{tag}>' | ||
return builder.format( | ||
tag=tag, | ||
attrs=flatatt(attrs) if attrs else '', | ||
content=text_value(content), | ||
) |
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 @@ | ||
# Tox (http://codespeak.net/~hpk/tox/) is a tool for running tests | ||
# in multiple virtualenvs. This configuration file will run the | ||
# test suite on all supported python versions. To use it, "pip install tox" | ||
# and then run "tox" from this directory. | ||
|
||
[tox] | ||
minversion=1.8.0 | ||
envlist = | ||
py26-django14, | ||
py26-django15, | ||
|
||
py27-django14, | ||
py27-django15, | ||
py27-django16, | ||
py27-django17, | ||
|
||
py32-django15, | ||
py32-django16, | ||
py32-django17, | ||
|
||
py33-django15, | ||
py33-django16, | ||
py33-django17, | ||
|
||
py34-django15, | ||
py34-django16, | ||
py34-django17, | ||
|
||
[testenv] | ||
commands = python manage.py test | ||
deps = | ||
django14: django >=1.4.2,<1.5 | ||
django15: django >=1.5,<1.6 | ||
django16: django >=1.6,<1.7 | ||
django17: django >=1.7,<1.8 |