Last active
November 30, 2016 09:24
-
-
Save VincentLoy/5d626afde79b52081d2cc4b019d36e82 to your computer and use it in GitHub Desktop.
Wagtail, tu aurais pu t'appeler Swagtail.
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
# blocks.py | |
from django.utils.translation import ugettext_lazy as _ | |
from wagtail.wagtailcore import blocks | |
class TweetBlock(blocks.StructBlock): | |
url = blocks.URLBlock(help_text=_('Tweet URL')) | |
class Meta: | |
icon = 'twitter' |
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
<style> | |
.twitter-tweet { | |
display: block; | |
margin: auto; | |
} | |
</style> | |
<blockquote class="twitter-tweet"> | |
<a href="{{ url }}"> Chargement du tweet</a> | |
</blockquote> | |
<!-- Don't forget to insert the twitter script ! --> | |
<!-- <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script> --> |
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
# models.py | |
class BlogPost(Page): | |
cover_picture = models.ForeignKey( | |
'wagtailimages.Image', | |
null=True, | |
blank=True, | |
on_delete=models.SET_NULL, | |
related_name='+', | |
help_text=_('Choose the cover picture') | |
) | |
body = StreamField([ | |
('paragraph', blocks.RichTextBlock( | |
label=_('paragraphe'), | |
icon='pilcrow', | |
help_text=_('Insert a paragraph'), | |
)), | |
('tweet', TweetBlock( | |
label=_('Tweet URL'), | |
help_text=_('Insert a Tweet') | |
)), | |
]) | |
content_panels = Page.content_panels + [ | |
ImageChooserPanel('cover_picture'), | |
StreamFieldPanel('body'), | |
] | |
search_fields = Page.search_fields + ( | |
index.SearchField('body'), | |
) |
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
# models.py | |
class BlogPost(Page): | |
cover_picture = models.ForeignKey( | |
'wagtailimages.Image', | |
null=True, | |
blank=True, | |
on_delete=models.SET_NULL, | |
related_name='+', | |
help_text=_('Choose the cover picture') | |
) | |
body = RichTextField() | |
content_panels = Page.content_panels + [ | |
ImageChooserPanel('cover_picture'), | |
FieldPanel('body'), | |
] | |
search_fields = Page.search_fields + ( | |
index.SearchField('body'), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment