Created
January 27, 2012 12:11
-
-
Save timmyomahony/1688510 to your computer and use it in GitHub Desktop.
django-semantic-editor layout to use the Zurb Foundation CSS
This file contains hidden or 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
import re | |
from semanticeditor.layout import LayoutDetailsBase | |
def num_to_word(num): | |
return ('', 'one', 'two', 'three', 'four',)[num] | |
class FoundationLayoutDetails(LayoutDetailsBase): | |
""" | |
A custom layout to use the Zurb Foundation grid. At the moment it only works for up | |
to 4 columns to avoid messy calculations. | |
""" | |
ROW_CLASS = "row" | |
COLUMN_CLASS = "columns" | |
max_columns = 4 | |
use_inner_column_div = False | |
def row_classes(self, logical_column_count, actual_column_count): | |
return [self.ROW_CLASS,] | |
def column_classes(self, logical_column_num, actual_column_num, logical_column_count, actual_column_count): | |
return [num_to_word(12/actual_column_count), self.COLUMN_CLASS,] | |
def is_row_class(self, class_): | |
return class_ == self.ROW_CLASS | |
def is_column_class(self, class_): | |
return class_ == self.COLUMN_CLASS or re.match(r'^(one|two|three|four) columns$', class_) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment