Package: django-fluent-contents
This project has reached the end of its development as CMS framework.It only receives low maintenance to continue running existing websites.Feel free to browse the code, but please use other Django-based CMS frameworks such asWagtail CMSwhen you start a new project.django-fluent-contentsThefluent_contentsmodule offers a widget engine to display various content on a Django page.This engine operates similarly like Django CMS, FeinCMS, Wagtail’s streaming field or django-portlets,
however, it can be used for any project, or CMS system.Page contents can be constructed with multiple “content items”.
You can define your own content items, or use one the available content items out of the box.
Standard web sites could use the bundled default content items.
Other advanced designs (such as a web site with a magazine-like design, having many blocks at a page)
can be implemented quickly by defining content items for the various “style elements” at the page.Web editors are able to place the “content items” at the page,
hence they can fill the content of advanced layouts easily and directly in the Django admin.
This also applies to pages which have a “free form” or “presentation slide” design,
this module allows the end-user to manage and configure the designed elements at the page.By default, the following content items are available:Standard content:Text content - write rich text in a WYSIWYG editor (provided bydjango-wysiwyg).Markup - write content with reStructuredText, Markdown or Textile (provided bydocutils,Markdownortextile).Forms - display forms created withdjango-form-designer-ai.Online content:Google Docs viewer - display a PDF or DOCX file on a page, using the Google Docs Viewer service.OEmbed support - embed content from YouTube, Vimeo, SlideShare, Twitter, and more.Twitter feed - display a Twitter timeline, or realtime search timeline.For programmers:Code - display code snippets with highlighting (provided byPygments).Gist - display Gist snippets from Github.IFrame - display an<iframe>on the page.Raw HTML content - include jQuery snippets, or “embed codes” by other services.Shared content - display a set of items at multiple locations.Interactive:Commentsarea - display comments on a page (provided bydjango.contrib.comments).Disqusarea - display DISQUS comments on a page (provided bydjango-disqus).Form-designer link - display adjango-form-designer-aiform on a page.For more details, see thedocumentationat Read The Docs.ScreenshotThePlaceholderFieldis nicely integrated in the Django admin interface:Secondly, it’s possible to build a CMS Page interface with thePlaceholderEditorAdmin,
which displays each content placeholder in a tab:InstallationFirst install the module, preferably in a virtual environment. It can be installed from PyPI:pipinstalldjango-fluent-contentsOr the current folder can be installed:pipinstall.The dependencies of plugins are not included by default. To install those, include the plugin names as extra option:pipinstalldjango-fluent-contents[code,disquscommentsarea,formdesignerlink,markup,oembeditem,text,twitterfeed]ConfigurationNext, create a project which uses the module:cd..django-admin.pystartprojectfluentdemoIt should have the following settings:INSTALLED_APPS+=('fluent_contents',# And optionally all plugins desired:'fluent_contents.plugins.code','fluent_contents.plugins.commentsarea','fluent_contents.plugins.disquswidgets','fluent_contents.plugins.formdesignerlink','fluent_contents.plugins.gist','fluent_contents.plugins.googledocsviewer','fluent_contents.plugins.iframe','fluent_contents.plugins.markup','fluent_contents.plugins.rawhtml','fluent_contents.plugins.text',# Some plugins need extra Django applications'disqus','django.contrib.comments','django_wysiwyg','form_designer',)The database tables can be created afterwards:./manage.pymigrateFinally, it needs a model or application that displays the content.
There are two ways to include content. The most simply way, is
adding aPlaceholderFieldto a model:# models.py:fromfluent_contents.modelsimportPlaceholderFieldclassArticle(models.Model):title=models.CharField("Title",max_length=200)slug=models.SlugField("Slug",unique=True)content=PlaceholderField("article_content")classMeta:verbose_name="Article"verbose_name_plural="Articles"def__unicode__(self):returnself.title# admin.py:fromfluent_contents.adminimportPlaceholderFieldAdminclassArticleAdmin(PlaceholderFieldAdmin):passadmin.site.register(Article,ArticleAdmin)The most advanced combination, is using thePlaceholderEditorAdminorPlaceholderEditorAdminMixinclasses.
These classes are designed for CMS-style applications which multiple placeholders on a page.
See the providedexampleapplication for details.NOTE:Thedjango-fluent-pagesapplication is built on top of this API, and provides a ready-to-use CMS that can be implemented with minimal configuration effort.
To build a custom CMS, the API documentation of thefluent_contents.adminmodule provides more details of the classes.Details about the various settings are explained in thedocumentation.Creating custom content itemsTo implement custom elements of a design - while making them editable for admins -
this module allows you to create custom content items.
Take a look in the existing types atfluent_contents.pluginsto see how it’s being done.It boils down to creating a package with 2 files:Themodels.pyfile should define the fields of the content item:fromdjango.dbimportmodelsfromfluent_contents.modelsimportContentItemclassAnnouncementBlockItem(ContentItem):title=models.CharField("Title",max_length=200)body=models.TextField("Body")button_text=models.CharField("Text",max_length=200)button_link=models.URLField("URL")classMeta:verbose_name="Announcement block"verbose_name_plural="Announcement blocks"def__unicode__(self):returnself.titleThecontent_plugins.pyfile defines the metadata and rendering:fromfluent_contents.extensionsimportplugin_pool,ContentPluginfrom.modelsimportAnnouncementBlockItem@plugin_pool.registerclassAnnouncementBlockPlugin(ContentPlugin):model=AnnouncementBlockItemrender_template="plugins/announcementblock.html"category="Simple blocks"The plugin can also define the admin layout, by adding fields such as afieldset, but that is all optional.
The template could look like:<divclass="announcement"><h3>{{instance.title}}</h3><divclass="text">{{instance.body|linebreaks}}</div><pclass="button"><ahref="{{instance.button_url}}">{{instance.button_text}}</a></p></div>Et, voila: web editors are now able to place an announcement items at the page
in a very structured manner! Other content items can be created in the same way,
either in the same Django application, or in a separate application.ContributingThis module is designed to be generic. In case there is anything you didn’t like about it,
or think it’s not flexible enough, please let us know. We’d love to improve it!If you have any other valuable contribution, suggestion or idea,
please let us know as well because we will look into it.
Pull requests are welcome too. :-)