class Quote(blocks.StructBlock): body = blocks.TextBlock() citation = blocks.TextBlock() class Meta: icon = 'openquote' template = '_includes/molecules/quote.html'
class SidebarBlock(blocks.StructBlock): """ HalvesBlock is an example of a sub-block / component / pre-defined collection of HTML elements. Using StructBlock sets this overall block to have a specific predefined format. This block can only consist of photo - title - text, and these fields are required. """ main_content = blocks.StreamBlock([ ('heading', blocks.CharBlock()), ('image', ImageChooserBlock()), ('text', blocks.TextBlock()), ('person', PersonBlock()), ('drink', DrinksChoiceBlock())]) sidebar = blocks.StreamBlock([ ('heading', blocks.CharBlock()), ('image', ImageChooserBlock()), ('text', blocks.TextBlock()), ('person', PersonBlock()), ('drink', DrinksChoiceBlock())]) class Meta: template = 'home/blocks/sidebar.html' icon = 'placeholder' form_classname = 'side-bar'
class AgendaPage(Page): author= models.CharField(max_length=255) date = models.DateField('Post date') agenda = StreamField([ ('agenda_item', blocks.StreamBlock([ ('item_title', blocks.TextBlock()), ('item_content', blocks.ListBlock(blocks.StructBlock([ ('item_text', blocks.TextBlock()), ('mtg_doc', blocks.StructBlock([ ('doc_description', blocks.TextBlock()), ('doc_link', blocks.TextBlock()) ])) ]))) ] #, #template='blocks/agenda_temp.html', )) ]) content_panels = Page.content_panels + [ FieldPanel('author'), FieldPanel('date'), StreamFieldPanel('agenda'), ]
class Quote(blocks.StructBlock): body = blocks.TextBlock() citation = blocks.TextBlock(required=False) is_large = blocks.BooleanBlock(required=False) class Meta: icon = 'openquote' template = '_includes/molecules/quote.html'
class StoryPage(Page): date = models.DateField("Post date") intro = models.CharField(max_length=250) # intro = models.CharField(max_length=250, help_text="Listen up buddy This thing is non editable Yeah!") author = models.CharField(max_length=250,default="Anonymous") body = StreamField([ ('heading', blocks.CharBlock(classname="full title")), ('paragraph', blocks.RichTextBlock()), ('images', blocks.StructBlock( [ ('image', ImageChooserBlock()), ('caption', blocks.CharBlock(blank=True,required=False,null=True)), ], icon='image', )), ('gist', blocks.TextBlock(help_text="Go to gist.github.com to write code and copy the embed Link.")), ('Link', blocks.StructBlock( [ ('URL', blocks.URLBlock()), ('Text', blocks.CharBlock()), ], icon='site', )), ('Quote',blocks.StructBlock( [ ('quote',blocks.BlockQuoteBlock()), ('Author',blocks.TextBlock(max_length=50)), ], icon='quote' )), ('embed',EmbedBlock()), ]) tags = ClusterTaggableManager(through=StoryPageTag, blank=True) categories = ParentalManyToManyField('story.StoryCategory', blank=True) search_fields = Page.search_fields + [ index.SearchField('intro'), index.SearchField('body'), ] content_panels = Page.content_panels + [ MultiFieldPanel([ FieldPanel('date'), FieldPanel('author'), FieldPanel('tags'), FieldPanel('categories', widget=forms.CheckboxSelectMultiple), ], heading="Information About Story"), FieldPanel('intro'), StreamFieldPanel('body'), ]
class BustOutQuoteBlock(blocks.StructBlock): image = ImageChooserBlock() quote = blocks.TextBlock() source = blocks.TextBlock() inverted = blocks.BooleanBlock(required=False) class Meta: icon = 'openquote' template = 'home/bust_out_quote_block.html'
class SubHeaderBlock(blocks.StructBlock): text = blocks.TextBlock(label='Title') sub_title = blocks.TextBlock(label='Sub-title') meta = blocks.TextBlock() class Meta: template = 'resume/blocks/sub_header_block.html' icon = 'title' label = 'Sub-header'
class HeroCallToActionBlock(blocks.StructBlock): background_color = blocks.TextBlock(required=False) pull_up = blocks.TextBlock(required=False) cta_content = blocks.StreamBlock([ ('HTML', HtmlBlock()), ('WYSIWYG', WysiwygBlock()), ('Row', RowBlock()), ]) class Meta: template = 'blocks/hero_cta_block.html' icon = 'pick'
class ColumnBlock(blocks.StructBlock): background_image = ImageChooserBlock(required=False) background_color = blocks.TextBlock(required=False) padding = blocks.TextBlock(required=False) max_width = blocks.TextBlock(required=False) content = blocks.StreamBlock([ ('HTML', HtmlBlock()), ('WYSIWYG', WysiwygBlock()), ]) class Meta: template = 'blocks/column_block.html' icon = 'grip'
class HeroDonateBlock(blocks.StructBlock): hero_image = ImageChooserBlock(required=False) background_color = blocks.TextBlock(required=False) padding = blocks.TextBlock(required=False) amount_one = blocks.TextBlock(required=False) amount_two = blocks.TextBlock(required=False) amount_three = blocks.TextBlock(required=False) amount_four = blocks.TextBlock(required=False) amount_five = blocks.TextBlock(required=False) amount_six = blocks.TextBlock(required=False) logo = blocks.ChoiceBlock(choices=[ ('hide', 'Hide'), ('show', 'Show'), ('animate', 'Animate'), ]) hero_content = blocks.StreamBlock([ ('HTML', HtmlBlock()), ('WYSIWYG', WysiwygBlock()), ('Row', RowBlock()), ]) thankyou_content = blocks.StreamBlock([ ('HTML', HtmlBlock()), ('WYSIWYG', WysiwygBlock()), ('Row', RowBlock()), ]) class Meta: template = 'blocks/hero_donate_block.html' icon = 'pick'
class CodeBlock(blocks.StructBlock): """ Code Highlighting Block """ LANGUAGE_CHOICES = ( ('python', 'Python'), ('bash', 'Bash/Shell'), ('html', 'HTML'), ('css', 'CSS'), ('scss', 'SCSS'), ) language = LanguageChooserBlock() code = blocks.TextBlock() class Meta: icon = 'code' def render(self, value): from pygments import highlight from pygments.formatters import get_formatter_by_name from pygments.lexers import get_lexer_by_name src = value['code'].strip('\n') lang = value['language'].ref lexer = get_lexer_by_name(lang) formatter = get_formatter_by_name( 'html', linenos=None, cssclass='codehilite', style='default', noclasses=False, ) return mark_safe(highlight(src, lexer, formatter))
class Footer(models.Model): links_text = models.CharField(max_length=255) contact_text = models.CharField(max_length=255) button_text = models.CharField(max_length=255) popup_text = RichTextField() popup_heading = models.CharField(max_length=255) links = StreamField([ ('link', blocks.StructBlock([ ('text', blocks.TextBlock()), ('url', blocks.URLBlock()), ], template='streams/footer_link.html')) ]) panels = [ FieldPanel('links_text'), FieldPanel('contact_text'), FieldPanel('button_text'), FieldPanel('popup_text'), FieldPanel('popup_heading'), StreamFieldPanel('links'), ] def __str__(self): return self.links_text
class BlockQuote(blocks.StructBlock): quote = blocks.TextBlock() citation = blocks.CharBlock(required=False) class Meta: icon = "openquote" template = "blocks/blockquote_block.html"
class NotificationBlock(blocks.StructBlock): message = blocks.CharBlock(required=True, help_text='Main message of the notification') explanation = blocks.TextBlock( required=False, help_text='An explanation for the notification') notification_type = blocks.ChoiceBlock(required=True, choices=[ ('success', 'Success'), ('warning', 'Warning'), ('error', 'Error'), ], default='warning') def get_context(self, value, parent_context=None): context = super(NotificationBlock, self).get_context(value, parent_context=parent_context) if value.get('notification_type') == 'success': context['notification_icon'] = 'approved-round' else: context['notification_icon'] = (value.get('notification_type') + '-round') return context class Meta: icon = 'warning' template = 'regulations3k/notification.html'
class ImageWithTextBlock(blocks.StructBlock): image = ImageChooserBlock(required=True, label='Bild') heading = blocks.TextBlock(required=False, label="Titel") subline = blocks.TextBlock(required=False, label="Unterzeile") subline2 = blocks.TextBlock(required=False, label="Unterzeile 2") size = blocks.ChoiceBlock( choices=[('150', 'klein (Breite: 150px)'), ('200', 'mittel (Breite: 200px)'), ('300', 'groß (Breite: 300px)'), ('0', 'Bild nur verlinken, nicht anzeigen')], label='Größe', required=True, ) class Meta: template = 'scms2/blocks/image_with_text_block.html'
class PullQuote(blocks.StructBlock): quote = blocks.TextBlock() author = blocks.CharBlock(required=False) class Meta: icon = 'openquote' template = 'home/pullquote.html'
class StreamBlock(blocks.StreamBlock): paragraph = blocks.RichTextBlock(icon="pilcrow", template="blocks/paragraph.html") header = blocks.CharBlock(classname="title", icon="fa-header", template="blocks/h3.html") image = blocks.StructBlock( [('image', ImageChooserBlock()), ('caption', blocks.CharBlock(blank=True, required=False)), ('style', blocks.ChoiceBlock(choices=[('', 'Select an image size'), ('full', 'Full-width'), ('half', 'Half-width')], required=False))], icon="image", template="blocks/image.html") blockquote = blocks.StructBlock([ ('text', blocks.TextBlock()), ('attribute_name', blocks.CharBlock( blank=True, required=False, label='e.g. Guy Picciotto')), ('attribute_group', blocks.CharBlock(blank=True, required=False, label='e.g. Fugazi')), ], icon="openquote", template="blocks/blockquote.html")
class CaptionedImageBlock(blocks.StructBlock): image = ImageChooserBlock() caption = blocks.TextBlock() class Meta: icon = 'cogs'
class StringAnswerBlock(AnswerBlock): """ Represents a numeric answer. """ answer = blocks.TextBlock( required=True, help_text=_('String with the correct answer.'), ) case_sensitive = blocks.BooleanBlock( default=False, help_text=_('If enabled, the response will be sensitive to the case.'), ) use_regex = blocks.BooleanBlock( verbose_name=_('use regular expressions?'), default=False, help_text=_( 'If enabled, the answer string is interpreted as a regular ' 'expression. A response is considered to be correct if it matches ' 'the regular expression. Remember to use both ^ and $ to match the' 'begining and the end of the string, if that is desired.')) multiple_lines = blocks.BooleanBlock( verbose_name=_('allow multiple lines?'), default=False, help_text=_( 'If enabled, this will allow the user input multiple lines of ' 'text. It will also present <textarea> widget instead of a regular ' '<input> text box.'))
class CodeBlock(blocks.StructBlock): """ Code Highlighting Block """ LANGUAGE_CHOICES = ( ('python', 'Python'), ('javascript', 'Javascript'), ('json', 'JSON'), ('bash', 'Bash/Shell'), ('html', 'HTML'), ('css', 'CSS'), ('scss', 'SCSS'), ('yaml', 'YAML'), ) language = blocks.ChoiceBlock(choices=LANGUAGE_CHOICES) code = blocks.TextBlock() class Meta: icon = 'code' def render(self, value): src = value['code'].strip('\n') lang = value['language'] lexer = get_lexer_by_name(lang) formatter = get_formatter_by_name( 'html', linenos=None, cssclass='codehilite', style='default', noclasses=False, ) return mark_safe(highlight(src, lexer, formatter))
class ImageCarouselBlock(blocks.StructBlock): image = ImageChooserBlock() caption = blocks.TextBlock(required=False) class Meta: template = "testapp/t_page.html" icon = 'image'
class ExtraInformationBlock(blocks.StructBlock): title = blocks.CharBlock() text = blocks.TextBlock(help_text='This text will be formatted with markdown.') class Meta: icon = 'plus' template = 'blog/extra_information_block.html' label = 'Extra Information'
class QuoteBlock(blocks.StructBlock): quote = blocks.TextBlock() source = blocks.CharBlock() link = blocks.URLBlock(required=False) class Meta: icon = 'openquote' template = 'home/blocks/quote.html'
class IntroTextBlock(blocks.StructBlock): intro = blocks.TextBlock(label='Inleiding van het artikel', required=True) class Meta: template = 'home/blocks/intro.html' label = 'Blog intro' icon = 'success'
class YESChecklistItem(blocks.StructBlock): """Deliver a standard set of values for a checklist item.""" item = blocks.CharBlock(help_text='Short description for a checkbox item') details = blocks.TextBlock(help_text='Deeper explanation of the item') class Meta: template = 'youth_employment/yes-checklist-items.html'
class CoupleBlock(blocks.StructBlock): bg_gray = blocks.BooleanBlock(required=False, help_text="Select if background should by gray") maintitle = blocks.CharBlock() subtitle = blocks.CharBlock() headline = blocks.CharBlock() bridename = blocks.CharBlock() bridetext = blocks.TextBlock() bridephoto = ImageChooserBlock() groomame = blocks.CharBlock() groomtext = blocks.TextBlock() groomphoto = ImageChooserBlock() class Meta: template = 'homepage/couple_block.html' icon = 'placeholder' label = 'Couple Block'
class FullWidthImageBlock(blocks.StructBlock): image = ImageChooserBlock() title = blocks.CharBlock(required=False) description = blocks.TextBlock(required=False) page = blocks.PageChooserBlock(required=False) link = blocks.URLBlock(required=False) class Meta: template = 'blocks/full_width_image_block.html'
class ComplexListItem(blocks.StructBlock): content = blocks.TextBlock(label='Inhalt') level = blocks.ChoiceBlock(choices=( ('0', 'Ebene 1'), ('1', 'Ebene 2'), ('2', 'Ebene 3'), ('3', 'Ebene 4'), ), label='Ebene')
class CodeBlock(blocks.StructBlock): """ Code Highlighting Block """ LANGUAGE_CHOICES = ( ('python', 'Python'), ('bash', 'Bash/Shell'), ('html', 'HTML'), ('css', 'CSS'), ('scss', 'SCSS'), ('json', 'JSON'), ) STYLE_CHOICES = ( ('autumn', 'autumn'), ('borland', 'borland'), ('bw', 'bw'), ('colorful', 'colorful'), ('default', 'default'), ('emacs', 'emacs'), ('friendly', 'friendly'), ('fruity', 'fruity'), ('github', 'github'), ('manni', 'manni'), ('monokai', 'monokai'), ('murphy', 'murphy'), ('native', 'native'), ('pastie', 'pastie'), ('perldoc', 'perldoc'), ('tango', 'tango'), ('trac', 'trac'), ('vim', 'vim'), ('vs', 'vs'), ('zenburn', 'zenburn'), ) language = blocks.ChoiceBlock(choices=LANGUAGE_CHOICES) style = blocks.ChoiceBlock(choices=STYLE_CHOICES, default='syntax') code = blocks.TextBlock() class Meta: icon = 'code' def render(self, value, context): src = value['code'].strip('\n') lang = value['language'] lexer = get_lexer_by_name(lang) css_classes = ['code', value['style']] formatter = get_formatter_by_name( 'html', linenos=None, cssclass=' '.join(css_classes), noclasses=False, ) return mark_safe(highlight(src, lexer, formatter))
class DrawMapBlock(blocks.StructBlock): idNum = models.AutoField(primary_key=False) drawnNeighborhood = blocks.TextBlock() class Meta: form_classname = 'map-block struct-block' icon = 'site' label = 'Draw Tools' form_template = 'blocks/map.html' template = 'blocks/json.html'