Wagtail ‘TumblrField’ spec Motivation A common requirement for Wagtail sites is the ability to create ‘freeform’ content consisting of  different content types arranged in any order: headings, paragraphs, images, video, and  potentially others, including custom types specific to that site. The current go­to solution for this  is the rich text area, but this is undesirable for several reasons:    ● It encourages people to disregard separation of content and design  ● Browser support for ‘contenteditable’ elements is often quirky, particularly when dealing  with floated elements or blocks of non­editable text, and fixing the resulting bugs is either  impossible or requires digging into hallo.js code  ● It is difficult to extend to support new content types (resulting in developers adopting  less­than­ideal solutions like permitting arbitrary blobs of HTML within the field)    This spec proposes a new mechanism provisionally named TumblrField, inspired by Wagtail’s  existing ‘InlinePanel’ model along with Sir Trevor and Tumblr, which allows editing freeform  content as a sequence of interchangeable content blocks. 

Scope ●

A component for the page editor that allows building a mixed sequence of content types,  that serialises to a single JSON field in the database  ● A straightforward way to output the entire chunk of content on a template, using HTML  representations defined by each content type  ● A clean API for building new content types for use within this component 

Out of scope ● ●

Nested TumblrFields (for multi­column arrangements of content)  Native database representation of the content (e.g. giving each content item its own  database record)  ● Interaction between different items in the sequence (e.g. cursor movement between  adjacent paragraphs; pressing enter at the end of a paragraph block to spawn another  paragraph block) 

Functionality A page type incorporating a TumblrField might be defined like this (NB names and syntax are  subject to change):    BlogPage.content_panels = [  FieldPanel('title'),  TumblrFieldPanel('content', block_types=[  ('heading', HeadingBlock()), 

('paragraph', ParagraphBlock()),  ('side­image', ImageBlock(formats=['left', 'right'])),  ('lead­image', ImageBlock(formats=['full­width'])),  ])  ]   

This will provide an interface functionally equivalent to  http://madebymany.github.io/sir­trevor­js/example.html, with four block types available:    ● a 'heading' block, consisting of a single (non­rich) text field;  ● a 'paragraph' block, consisting of a rich text area with limited formatting capabilities such  as bold / italic text and links, but not image embedding or heading types;  ● a 'side image' block, consisting of an image chooser, a text field to specify alt text, and a  select box (or pair of radio buttons) to specify whether it will be left or right justified;  ● a 'lead image' block, consisting of an image chooser and a text field to specify alt text  (there is no format select box, since there is only one option available).    On submitting the form, these fields will be validated according to each block type's validation  rules, if any. If validation succeeds, the data will be written to the 'content' field of the model as a  JSON string:    [  {'type': 'heading', 'value': 'Fish found on moon'},  {'type': 'lead­image', 'value': {'id': 123, 'alt': 'a fish', 'format':  'full­width'}},  {'type': 'paragraph', 'value': 'A fish of species verasper  variegetus was found on the moon yesterday.'},  {'type': 'paragraph', 'value': 'NASA were unavailable for comment.'}  ] 

  The 'type' field indicates which of the block types (as specified within the TumblrFieldPanel  definition) is responsible for this content block; 'value' is an arbitrary JSON value assigned and  understood by that specific block type.    It will be possible to render the content on a template simply by using the tag {{ self.content  }}. Each block type defines a way to render its data in HTML form (e.g. as a suitably­styled   element for ImageBlock), and the HTML rendering for the TumblrField as a whole simply  loops over these renderings. It will also be possible to loop over the blocks manually if more  control over the output is required:    {% for block in self.content %}    {{ block }} 
  {% endfor %} 

As well as providing their own HTML representation, blocks will also expose the raw data for  templates to display using their own rendering. This might look something like:    {% tumblrfield self.content %}  {% blocktype 'heading' %}  {{ heading.text }}  {% endblocktype %}  {% blocktype 'side­image' as image %}    {% endblocktype %}  {# all block types not mentioned here fall back on their default HTML  renderings #}  {% endtumblrfield %} 

  Here {% tumblrfield %} and {% blocktype %} are custom tags that act as a kind of switch/case  statement, invoking the appropriate section for each content block in the sequence depending on  its type.    Wagtail site implementers will be able to create custom block types. We will provide a number of  abstract 'block type' base classes on top of which developers will be able to implement  block­specific behaviours, such as: the rendering of the field(s) within the edit form; form  validation; the block's default HTML rendering; the way it is serialised and deserialised to and  from JSON; and the styling of the button within the TumblrField's toolbar. 

Development notes The API required for block types somewhat resembles Wagtail's existing EditHandler API, and  Django's form field API. It may be that one or the other of these is a close enough fit for us to use  it as­is, or can be extended to fit our needs; alternatively, we may create a new API inspired by  these.    (The EditHandler API is one area of Wagtail that probably needs some review ­ it was developed  in a rather ad­hoc way, with constraints dictated by Wagtail’s visual design and Django internals.  As part of this development, we will consider whether the new block types API can serve as a  starting point for a new EditHandler implementation. EditHandler will not be dropped entirely in  this phase of development ­ indeed, TumblrFieldPanel will be implemented as an EditHandler.) 

Wagtail 'TumblrField' spec -

lessthanideal solutions like permitting arbitrary blobs of HTML within the field) ... as bold / italic text and links, but not image embedding or heading types;.

106KB Sizes 5 Downloads 204 Views

Recommend Documents

Wagtail 'TumblrField' spec -
lessthanideal solutions like permitting arbitrary blobs of HTML within the field) ... On submitting the form, these fields will be validated according to each block ...

Group 284 Spec. 260 Spec. 288 Spec. 237 Spec. 265 ...
0-Chan Dimr. Use. Group. Position #. Special. Color. 1. 284. 1. Spec. 2Bm 19. 6x16 ... 36° Source Four R02. 34. 403. K. Front. 1Bm 12. 36° Source Four R08 ...

Undertale Spec Script.pdf
Whoops! There was a problem loading more pages. Retrying... Undertale Spec Script.pdf. Undertale Spec Script.pdf. Open. Extract. Open with. Sign In. Details.

CS4 Spec Sheet.pdf
Advanced design. software allows ... Designed and Optimized for Post 2009 Digital TV Frequencies. The ClearStreamTM 4 ... CS4 Spec Sheet.pdf. CS4 Spec ...

CIFF Spec ver1.0 Rev03 - GitHub
Regulations for the Manipulation of CIFF Image Objects 4. A. ... Among the regulations stipulated by the CIFF (Camera Image File Format), the present document.

GO7 Spec Sheet.pdf
Geotab GO7TM - The World's Only Expandable Plug-&-Play Platform. GO7TM Device. GO7TM is a small yet extremely powerful. telematics measurement tool.

d800-spec-sheet.pdf
Whoops! There was a problem loading more pages. Whoops! There was a problem previewing this document. Retrying... Download. Connect more apps.

BGP Type Flow Spec BGP Flow Provider Flow Spec BGP ... - Groups
BGP Type Flow Spec. BGP Flow Provider. Flow Spec. BGP Flow web resource. (New). BGP Flow. Decoder. (New). BGP. Driver. (New). ONOS. Flow Rule.

Donnington spec TT Jn15.pdf
Website www.sm-t.co.uk Emails [email protected]. The Donnington the ideal parking lift for parking space problems. All businesses need to ...

panasonic-ncr18650-ga-spec-sheet.pdf
the elections were by and large peaceful and declared free. and fair by both national and international observers. Financial Highlights. Profit before tax ... Chairman. Whoops! There was a problem loading this page. Retrying... panasonic-ncr18650-ga-

NSF-Tank-Spec-Material.pdf
Dow requests that customers considering use of Dow products in medical applications notify Dow so that. appropriate assessments may be conducted. Dow does not endorse or claim suitability of its products for. specific medical applications. It is the

EN-DDL10160-Spec Sheet.pdf
specifications without prior notice. ZA Sales & Distribution. Building 6 Pinewood Office Park 33. Riley Road, Woodmead Gauteng. South Africa. Tel : +27 (0) 11 ...

SPEC 400kVA T04002006 STD.PDF
STANDARD : The transformer , all ... standard specifications and codes in the following list : ANSI American ... VDE Regulation and DIN Standard (VDE 0532/11).

NSF-Tank-Spec-Material.pdf
processing latitude, good color retention and long life expectancy. • Rotational molding or injection molding. • For intermediate bulk containers, toys, general ...

SPEC 500kVA 22000 T05002009.pdf
Page 2 of 7. TRANSFORMER TECHNICAL SPECIFICATION. 1. SPEC No : T0500200909. 2. CUSTOMER : 3. REQUIREMENT : Quantity. Description.

Colorado 100cm Tallboy Spec Sheet.pdf
Colorado 100cm Tallboy Spec Sheet.pdf. Colorado 100cm Tallboy Spec Sheet.pdf. Open. Extract. Open with. Sign In. Main menu. Whoops! There was a ...

Venus G999 Dining Spec Sheet.pdf
Southbank: Eureka Tower, 7 Riverside Quay. Thomastown: Northpoint, 187 Settlement Road. Nunawading: 328 Whitehorse Road G Phone: 96826868 Web: www.gainsville.com.au Email: [email protected]. 5 Year Structural Warranty. Exclusive Design by Gainsv

Utah Bedroom Furniture Spec Sheet.pdf
Page 1 of 5. Showroom Information. Southbank: Eureka Tower, 7 Riverside Quay. Thomastown: Northpoint, 187 Settlement Road. Nunawading: 328 Whitehorse Road. Phone: 96826868 Web: www.gainsville.com.au Email: [email protected]. GAiNSViLLE. G. AMERI

Spec ONE PLUS .pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Spec ONE ...

AIR SEA CONTAINER SPEC SHEET.pdf
AIR SEA CONTAINERS. SPECIFICATION SHEET. H. H ex. Page 1 of 1. AIR SEA CONTAINER SPEC SHEET.pdf. AIR SEA CONTAINER SPEC SHEET.pdf.

Odyssey IV spec sheet - MIT AUV Lab
mass spectrometer, manipulator and buoyancy drive. About MIT Sea Grant AUV Lab. Dedicated to the development and application of autonomous underwa-.

Spec-Selector Fire-SP510.pdf
Automatic speed control. Set to any percent speed and Jog ... some small commercial and. industrial buildings. ... Spec-Selector Fire-SP510.pdf. Spec-Selector ...

EN-DLB072D-Spec Sheet.pdf
Dimensions mm (L) x mm (W) x 72mm (H) x 85mm (OD) x. 87mm (RD) x mm. SKU Table and Ordering. SKU Code Colour lm Wattage Lumens/Watt Product Type.

JCB 3CX Spec Sheet.pdf
Cooling system Hot climate specification, pressurised 14.5 psi (1.0 bar) suction fan. Pressurised recovery tank with. integral filler neck. A. B. C. BACKHOE LOADER | 3CX. Page 4 of 12. JCB 3CX Spec Sheet.pdf. JCB 3CX Spec Sheet.pdf. Open. Extract. Op