コード例 #1
0
class EventListBlock(StructBlock):
    title = TextBlock()
    short_desc = TextBlock()
    # html_text = RawHTMLBlock(required=False)
    # image = ImageChooserBlock(required=False)
    # event_date = DateBlock()
    child_slug = TextBlock()
コード例 #2
0
ファイル: blocks.py プロジェクト: madicorp/wafa
class OfficerBlock(MemberBlock):
    deputy_name = TextBlock(label='Representant')
    contact = TextBlock(label='Contact', required=False)
    image = ImageChooserBlock()
    position_fr = TextBlock(label='Poste FR', required=False)
    position_en = TextBlock(label='Poste EN', required=False)
    biography_fr = RichTextBlock(label='Biography FR', required=False)
    biography_en = RichTextBlock(label='Biography EN', required=False)
コード例 #3
0
class QuoteBlock(StructBlock):
    quote = TextBlock("quote title")
    attribution = CharBlock()

    class Meta:
        icon = 'openquote'
        template = 'blog/blocks/quote.html'
コード例 #4
0
ファイル: models.py プロジェクト: FlipperPA/wagtailpress
class WPPage(Page):
    """
    This class will hold pages, similar to WordPress' post_type of 'page'.
    Posts will inherit from this class, adding additional fields needed.
    """
    class Meta:
        verbose_name = "Page"

    content = StreamField([
        ('heading', CharBlock(classname="full title")),
        ('paragraph', TextBlock()),
        ('image', ImageChooserBlock()),
        ('url', URLBlock()),
        ('code', CodeBlock()),
    ])
    tags = ClusterTaggableManager(through=WPPageTag, blank=True)
    modified = models.DateTimeField("Page Modified", null=True)

    search_fields = Page.search_fields + (
        index.SearchField('title'),
        index.SearchField('content'),
    )

    content_panels = Page.content_panels + [
        FieldPanel('tags'),
        StreamFieldPanel('content'),
    ]

    def save(self, *args, **kwargs):
        self.modified = timezone.now()
        super(WPPage, self).save(*args, **kwargs)

    def __str__(self):
        return 'ID %s: %s' % (str(self.pk), self.title)
コード例 #5
0
class CodeBlock(StructBlock):
    """
    Code Highlighting Block
    """

    LANGUAGE_CHOICES = (
        ('python', 'Python'),
        ('cpp', 'C++'),
        ('html', 'HTML'),
        ('css', 'CSS'),
    )

    language = ChoiceBlock(choices=LANGUAGE_CHOICES)
    code_text = TextBlock()

    def render(self, value):
        src = value['code_text'].strip('\n')
        lang = value['language']

        lexer = get_lexer_by_name(lang)
        formatter = get_formatter_by_name(
            'html',
            linenos='table',
            noclasses=True,
            style='monokai',
        )
        return mark_safe(highlight(src, lexer, formatter))
コード例 #6
0
class GlobalStreamBlock(StreamBlock):
    paragraph = RichTextBlock(icon="pilcrow", template="blocks/paragraph.html")
    header = StructBlock([
        ('header_text', CharBlock(blank=True, required=False, label='Header')),
        ('size',
         ChoiceBlock(choices=[('', 'Select a header size'), ('h2', 'H2'),
                              ('h3', 'H3'), ('h4', 'H4')],
                     blank=True,
                     required=False))
    ],
                         classname="title",
                         icon="title",
                         template="blocks/header.html")
    image = StructBlock([('image', ImageChooserBlock()),
                         ('caption', CharBlock(blank=True, required=False)),
                         ('style',
                          ChoiceBlock(choices=[('', 'Select an image size'),
                                               ('full', 'Full-width'),
                                               ('contain', 'Contained-width'),
                                               ('half', 'Half-width')],
                                      required=False))],
                        icon="image",
                        template="blocks/image.html")
    blockquote = StructBlock([
        ('text', TextBlock()),
        ('attribute_name',
         CharBlock(blank=True, required=False, label='e.g. Guy Picciotto')),
        ('attribute_group',
         CharBlock(blank=True, required=False, label='e.g. Fugazi')),
    ],
                             icon="openquote",
                             template="blocks/blockquote.html")
    embed = EmbedBlock(
        help_text=
        'Insert an embed URL e.g https://www.youtube.com/embed/SGJFWirQ3ks')
コード例 #7
0
class TextFieldBlock(OptionalFormFieldBlock):
    default_value = TextBlock(required=False, label=_('Default value'))

    widget = forms.Textarea(attrs={'rows': 5})

    class Meta:
        label = _('Text field (multi line)')
コード例 #8
0
class FormFieldBlock(StructBlock):
    field_label = CharBlock(label=_('Label'))
    help_text = TextBlock(required=False, label=_('Help text'))

    field_class = forms.CharField
    widget = None

    def get_slug(self, struct_value):
        return force_text(slugify(unidecode(struct_value['field_label'])))

    def get_field_class(self, struct_value):
        return self.field_class

    def get_widget(self, struct_value):
        return self.widget

    def get_field_kwargs(self, struct_value):
        kwargs = {
            'label': struct_value['field_label'],
            'help_text': struct_value['help_text'],
            'required': struct_value.get('required', False)
        }
        if 'default_value' in struct_value:
            kwargs['initial'] = struct_value['default_value']
        form_widget = self.get_widget(struct_value)
        if form_widget is not None:
            kwargs['widget'] = form_widget
        return kwargs

    def get_field(self, struct_value):
        return self.get_field_class(struct_value)(
            **self.get_field_kwargs(struct_value))
コード例 #9
0
class CodeBlock(StructBlock):
    LANGUAGE_CHOICES = (
        ('python', 'Python'),
        ('html', 'HTML'),
        ('css', 'CSS'),
        ('scss', 'SCSS'),
        ('json', 'JSON'),
        ('sh', 'Shell'),
    )

    STYLE_CHOICES = (
        ('syntax', 'default'),
        ('monokai', 'monokai'),
        ('xcode', 'xcode'),
    )

    language = ChoiceBlock(choices=LANGUAGE_CHOICES)
    style = ChoiceBlock(choices=STYLE_CHOICES, default='syntax')
    code = TextBlock()

    def render(self, value, context=None):
        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',
                                          lineos=None,
                                          cssclass=' '.join(css_classes),
                                          noclasses=False)

        return mark_safe(highlight(src, lexer, formatter))

    class Meta:
        icon = 'code'
コード例 #10
0
class BlockQuoteBlock(StructBlock):
    text = TextBlock()
    attribute = CharBlock(blank=True, required=False)

    class Meta:
        icon = 'openquote'
        template = 'blog/blocks/blockquote_block.html'
コード例 #11
0
ファイル: models.py プロジェクト: my2020m/hra
class NavigationSettings(BaseSetting, ClusterableModel):
    header_links = StreamField([
        ('item', OverrideablePageChooserBlock()),
    ],
                               blank=True)
    footer_links = StreamField([
        ('column',
         StructBlock([
             ('column_heading', TextBlock()),
             ('subitems',
              ListBlock(OverrideablePageChooserBlock(label="Sub-item"))),
         ])),
    ],
                               blank=True)
    footer_secondary_links = StreamField([
        ('item', OverrideablePageChooserBlock()),
    ],
                                         blank=True)

    panels = [
        StreamFieldPanel('header_links'),
        StreamFieldPanel('footer_links'),
        StreamFieldPanel('footer_secondary_links'),
    ]

    def save(self, *args, **kwargs):
        super().save(*args, **kwargs)
        purge_esi()

    def delete(self, *args, **kwargs):
        super().delete(*args, **kwargs)
        purge_esi()
コード例 #12
0
class PullQuoteBlock(StructBlock):
    quote = TextBlock('quote title')
    attribution = CharBlock()
    affiliation = CharBlock(required=False)
    style = PullQuoteStyleChoiceBlock()

    class Meta:
        template = 'cms/blocks/pull_quote_block.html'
コード例 #13
0
class ProductStreamBlock(StreamBlock):
    h2 = CharBlock(icon="title", classname="title")
    h3 = CharBlock(icon="title", classname="title")
    h4 = CharBlock(icon="title", classname="title")
    intro = TextBlock(icon="pilcrow")
    paragraph = RichTextBlock(icon="pilcrow")
    aligned_image = ImageBlock(label="Aligned image", icon="image")
    embed = EmbedBlock()
    document = DocumentChooserBlock(icon="doc-full-inverse")
コード例 #14
0
class CaptionedImageBlock(StructBlock):
    image = ImageChooserBlock()
    caption = TextBlock(required=False)

    class Meta:
        icon = 'image'

    class Meta:
        template = 'core/blocks/captioned_image.html'
コード例 #15
0
ファイル: blocks.py プロジェクト: v-hunt/chiropractor-site
class WhyChooseUsSectionBlock(StructBlock):
    headline = CharBlock(label='Заголовок секции', )
    text = TextBlock(label='Текст')
    cards = ListBlock(_WhyChoseUsBlock, label='Список карточек', max_num=4)

    class Meta:
        min_num = 1
        max_num = 1
        template = 'home/blocks/why_choose_us_section_block.html'
コード例 #16
0
class OrderedListBlock(StructBlock):
    title = CharBlock(required=False)
    items = ListBlock(
        StructBlock([('title', CharBlock()), ('description', TextBlock())]))
    label = CharBlock(required=False)
    page = PageChooserBlock(required=False)

    class Meta:
        template = 'cms/blocks/ordered_list_block.html'
コード例 #17
0
ファイル: blocks.py プロジェクト: v-hunt/chiropractor-site
class DiseaseSectionBlock(StructBlock):
    headline = CharBlock(label='Заголовок секции', )
    text = TextBlock(label='Текст')
    diseases = ListBlock(_SingleDiseaseBlock, label='Список заболеваний')

    class Meta:
        min_num = 1
        max_num = 1
        template = 'home/blocks/disease_section_block.html'
コード例 #18
0
ファイル: blocks.py プロジェクト: eea/eea.docker.flis
class ResourcesNexusBlock(StructBlock):
    block_heading = CharBlock(required=True)
    food_description = TextBlock()
    food_to_water_description = TextBlock()
    food_to_energy_description = TextBlock()
    water_description = TextBlock()
    water_to_food_description = TextBlock()
    water_to_energy_description = TextBlock()
    energy_description = TextBlock()
    energy_to_water_description = TextBlock()
    energy_to_food_description = TextBlock()
    read_more_button = ReadMoreButtonBlock(required=False)

    class Meta:
        image = 'topics/images/streamfield_blocks/resources_nexus.png'
        template = 'topics/streamfield_blocks/resources_nexus.html'
コード例 #19
0
class HomePagesStreamBlock(StreamBlock):
    paragraph = RichTextBlock(icon="pilcrow", label=u'段落')
    image_list_4 = FourColImageListBlock(icon="image", label=u"四列图片")
    image_list_3 = ThreeColImageListBlock(icon="image", label=u"三列图片")
    image_list_2 = TwoColImageListBlock(icon="image", label=u"两列图片")
    link_list = LinkList(icon="link", label=u"链接列表")
    html = RawHTMLBlock(icon="code", label=u'HTML代码')
    overlap = OverlapDesign(icon="pilcrow", label=u"大小标题模块")
    quote = TextBlock(icon = "openquote", label=u'引用')
    image_list_5 = HPFiveColImageListBlock(icon="image", label=u"主页五列图片")
    carousel = Carousel(icon="image", label=u"幻灯片图片")
コード例 #20
0
ファイル: blocks.py プロジェクト: zr777/school-wiki
class BlockQuote(StructBlock):
    """
    Custom `StructBlock` that allows the user to attribute
    a quote to the author
    """
    text = TextBlock(label=u'文本')
    attribute_name = CharBlock(blank=True, required=False, label=u'署名')

    class Meta:
        icon = "openquote"
        template = "blocks/blockquote.html"
コード例 #21
0
ファイル: models.py プロジェクト: dchaplinsky/pep.org.ua
class BlockQuote(StructBlock):
    """
    Custom `StructBlock` that allows the user to attribute a quote to the author
    """
    text = TextBlock()
    attribute_name = CharBlock(
        blank=True, required=False, label='e.g. Mary Berry')

    class Meta:
        icon = "snippet"
        template = "blocks/blockquote.html"
コード例 #22
0
class BlockQuote(StructBlock):
    """
    Custom `StructBlock` that allows the user to attribute a quote to the author
    """
    texto = TextBlock()
    nombre_autor = CharBlock(blank=True,
                             required=False,
                             label='e.g. Guy Picciotto')

    class Meta:
        icon = "fa-quote-left"
コード例 #23
0
ファイル: blocks.py プロジェクト: dsummersl/bakerydemo
class BreadQuote(StructBlock):
    """ Quotes about ONLY breads """
    text = TextBlock()
    attribute_name = CharBlock(
        blank=True, required=False, label='e.g. Mary Berry')
    # TODO When this field is added, a migration is made:
    # url = URLBlock()

    class Meta:
        icon = "fa-quote-left"
        template = "blocks/blockquote.html"
コード例 #24
0
class PagesStreamBlock(StreamBlock):
    content_centered = RichTextBlock(icon="pilcrow", label=u"居中内容")
    page_title = PageTitle(icon="pilcrow", label=u"大小标题模块")
    underline_title = PageTitle(icon="pilcrow", label=u"下划线标题模块")
    html_paragraph = RawHTMLBlock(icon="code", label=u'HTML段落')
    html_quote = RawHTMLBlock(icon = "openquote", label=u'HTML引用')
    right_aligned_quote = TextBlock(icon = "openquote", label=u'右对齐引用')
    paragraph = RichTextBlock(icon="pilcrow", label=u'段落')
    image_with_caption = ImageBlock(icon="image", label=u'带标题图片')
    image_list = ImageListBlock(icon="image", label=u'图片列表')
    html = RawHTMLBlock(icon="code", label=u'HTML代码')
コード例 #25
0
ファイル: blocks.py プロジェクト: v-hunt/chiropractor-site
class QuestionAnswerBlock(StructBlock):
    question = CharBlock(
        help_text="Введите часто задаваемый вопрос"
    )
    answer = TextBlock(
        help_text="Введите ответ"
    )

    class Meta:
        icon = "title"
        template = "faq/blocks/question_answer_block.html"
コード例 #26
0
class AccordionBlock(StructBlock):
    class Meta:
        icon = "arrow-down-big"
        template = "blocks/accordion_block.html"

    accordion_group_title = TextBlock(required=False, blank=True, default="")
    accordion_items = ListBlock(
        StructBlock([
            ('accordion_title', CharBlock(required=True)),
            ('accordion_content', RichTextBlock(required=True)),
        ]))
コード例 #27
0
ファイル: blocks.py プロジェクト: v-hunt/chiropractor-site
class SelectedMethodsSection(StructBlock):
    headline = CharBlock(label='Заголовок секции', )
    text = TextBlock(label='Текст')
    selected_methods = ListBlock(
        _MethodBlock,
        label='Методики',
        min_num=3,
        max_num=3,
    )

    class Meta:
        template = 'home/blocks/selected_methods_section_block.html'
コード例 #28
0
class CodeBlock(StructBlock):
    """
    Code Highlighting Block
    """
    LANGUAGE_CHOICES = (
        ('bash', 'Bash/Shell'),
        ('c', 'C'),
        ('cmake', 'CMake'),
        ('cpp', 'C++'),
        ('csharp', 'C#'),
        ('css', 'CSS'),
        ('go', 'Go'),
        ('haskell', 'Haskell'),
        ('haxe', 'Haxe'),
        ('html', 'HTML'),
        ('java', 'Java'),
        ('js', 'JavaScript'),
        ('json', 'JSON'),
        ('kotlin', 'Kotlin'),
        ('lua', 'Lua'),
        ('make', 'Makefile'),
        ('perl', 'Perl'),
        ('perl6', 'Perl 6'),
        ('php', 'PHP'),
        ('python', 'Python'),
        ('python3', 'Python 3'),
        ('ruby', 'Ruby'),
        ('sql', 'SQL'),
        ('swift', 'Swift'),
        ('xml', 'XML'),
    )

    language = ChoiceBlock(choices=LANGUAGE_CHOICES)
    code = 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='table',
            cssclass='code-highlight',
            style='default',
            noclasses=False,
        )
        return mark_safe(highlight(src, lexer, formatter))
コード例 #29
0
ファイル: blocks.py プロジェクト: NDevox/wagtailcodeblock
class CodeBlock(StructBlock):
    """
    Code Highlighting Block
    """

    WCB_LANGUAGES = get_language_choices()

    language = ChoiceBlock(choices=WCB_LANGUAGES,
                           help_text=_('Coding language'),
                           label=_('Language'))
    code = TextBlock(label=_('Code'))

    @property
    def media(self):

        theme = get_theme()

        prism_version = get_prism_version()
        if theme:
            prism_theme = '-{}'.format(theme)
        else:
            prism_theme = ""

        js_list = [
            "https://cdnjs.cloudflare.com/ajax/libs/prism/{}/prism.min.js".
            format(prism_version, ),
        ]

        for lang_code, lang_name in self.WCB_LANGUAGES:
            js_list.append(
                "https://cdnjs.cloudflare.com/ajax/libs/prism/{}/components/prism-{}.min.js"
                .format(
                    prism_version,
                    lang_code,
                ))
        return Media(
            js=js_list,
            css={
                'all': [
                    "https://cdnjs.cloudflare.com/ajax/libs/prism/{}/themes/prism{}.min.css"
                    .format(prism_version, prism_theme),
                ]
            })

    class Meta:
        icon = 'code'
        template = 'wagtailcodeblock/code_block.html'
        form_classname = 'code-block struct-block'
        form_template = 'wagtailcodeblock/code_block_form.html'
コード例 #30
0
class CodeBlock(blocks.StructBlock):

    LANGUAGE_CHOICES = [
        ('arduino', 'Arduino'),
        ('bash', 'Shell'),
        ('c', 'C'),
        ('css', 'CSS'),
        ('django', 'Django'),
        ('docker', 'Docker'),
        ('javascript', 'JavaScript'),
        ('json', 'JSON'),
        ('md', 'Markdown'),
        ('nginx', 'Nginx'),
        ('plpgsql', 'Pl/pgSQL'),
        ('postgresql', 'PostgreSQL'),
        ('python', 'Python'),
        ('sql', 'SQL'),
        ('sqlite3', 'SQLite3'),
        ('yaml', 'YAML'),
    ]

    STYLE_CHOICES = [
        ('syntax', 'default'),
    ]

    language = ChoiceBlock(choices=LANGUAGE_CHOICES)
    style = ChoiceBlock(choices=STYLE_CHOICES, default='syntax')
    code = TextBlock()

    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),
            cssclass='syntax',
            #style = 'default',
            noclasses=False,
        )

        return mark_safe(highlight(src, lexer, formatter))

    class Meta:
        icon = 'code'