Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 27e6d9c

Browse files
committed
further cleanup of create bundle doc
1 parent 45f1c05 commit 27e6d9c

File tree

1 file changed

+54
-40
lines changed

1 file changed

+54
-40
lines changed

bundles/create/introduction.rst

Lines changed: 54 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,56 @@ The javascript library `create.js`_ provides a comprehensive web editing
1313
interface for Content Management Systems. It is designed to provide a modern,
1414
fully browser-based HTML5 environment for managing content. Create.js can be
1515
adapted to work on almost any content management backend. Create.js makes your
16-
content editable based on RDFa annotations in the HTML content. Data is saved
17-
through backbone.js, CreateBundle providing the endpoint for the requests.
18-
The default editor used in the CreateBundle is CKEditor, but you can also use
19-
the lightweight `hallo.js`_ editor bundled with the create.js distribution.
16+
content editable based on `RDF`_ information. The CreateBundle provides the
17+
means to load create.js, provide the RDF information and handle the save
18+
requests send by create.js.
2019

21-
`CreatePHP`_ is a PHP library that helps you putting the RDFa attributes into
22-
your HTML for `create.js`_ and map back from the JSON-LD sent by backbone.js
23-
to your model classes.
20+
For WYSIWYG text, the default editor is `CKEditor`_, but you can also use
21+
the lightweight `hallo.js`_ editor bundled with the create.js distribution
22+
or integrate your own editor.
2423

2524
Concepts
2625
--------
2726

28-
CreatePHP uses `RDFa`_ metadata about your model classes. This metadata is
29-
used to map between your model and the RDFa information. If you know Doctrine,
30-
you have seen the idea of metadata to know how class fields map to database
31-
columns.
27+
To know the RDF model of your data, create.js parses the page DOM for `RDFa`_
28+
attributes. Whenever it encounters an `about` attribute, it knows that this
29+
section is an editable content. The `typeof` attribute tells what type the
30+
content has. The `property` attributes mean that the parts inside that tag are
31+
editable. An article might look like this:
3232

33-
The CreatePHP metadata is modelled by the ``Type`` class. CreatePHP provides
34-
metadata loaders that read XML, php arrays and one that just introspects
35-
objects and creates non-semantical metadata that will be enough for create.js
36-
to edit.
33+
.. code-block:: html
3734

38-
An ``RdfMapper`` is used to translate between your storage layer and CreatePHP.
39-
It is passed the model instance and the relevant metadata object.
35+
<div about="/cms/content/home" typeof="schema:WebPage" xmlns:schema="http://schema.org/">
36+
<h1 property="schema:headline">The Title</h1>
37+
<div property="schema:text">
38+
<h2>Welcome to the Symfony CMF Demo</h2>
39+
<p>If you see this page, it means that the...</p>
40+
</div>
41+
</div>
42+
43+
Each property has a type. You can configure what editor to use for which type.
44+
CreateBundle comes with two editors: `plaintext` with no formatting, and
45+
WYSIWYG editing. You can also define your own editors.
46+
47+
Create.js uses backbone.js to save edited data to the server in the JSON-LD
48+
format. You may have several objects editable on a single page. There will be
49+
one request per editable content that was actually modified.
4050

41-
With the metadata and the twig helper, the content is rendered with RDFa
42-
annotations. create.js is loaded and enables editing the content. Note that
43-
you may have several objects editable on a single page. Save operations happen
44-
through backbone.js with ajax calls containing JSON-LD data. There is one
45-
request per editable content that was actually modified. The CreateBundle REST
46-
controller handles those ajax calls and maps the JSON-LD data back onto your
47-
model classes and stores them in the database.
51+
The `CreatePHP`_ library provides the RDF information for `create.js`_ by
52+
creating `RDFa`_ attributes on your data in the templates. It also maps
53+
the JSON-LD sent by backbone.js back to your domain objects.
4854

49-
For image support, CKEditor can use elfinder to upload, browse and insert
50-
images into the content. See the
51-
:doc:`MediaBundle elfinder adapter documentation<../media/adapters/elfinder>`
52-
to enable this powerful image browser.
55+
The `CreatePHP`_ library contains a metadata tool to define the mapping between
56+
your domain objects and the RDF information. It provides a twig extension to
57+
enrich your HTML pages with the RDFa attributes, similar to how you output forms.
58+
CreatePHP also provides the means to store the JSON-LD data sent by backbone.js
59+
back into your domain objects and save them. If you know Doctrine, this is a
60+
similar job to how Doctrine reads data from database columns and loads them
61+
into your domain objects.
5362

63+
The CreateBundle finally registers the twig extension in Symfony and provides
64+
a REST controller for the backbone.js ajax calls. It also provides helpers to
65+
bootstrap create.js in your templates.
5466

5567
.. index:: CreateBundle
5668

@@ -68,7 +80,7 @@ which in turn needs the JmsSerializerBundle. Make sure you load all those
6880
bundles in your kernel and properly configure Assetic as described below.
6981

7082
To upload and display images the :doc:`MediaBundle <../media/introduction>` is
71-
used.
83+
used. CKEditor uses the :doc:`elfinder adapter <../media/adapters/elfinder>`.
7284

7385
.. _bundle-create-ckeditor:
7486

@@ -343,10 +355,10 @@ you need to adjust your templates to output that information.
343355

344356
.. note::
345357

346-
If you use custom models that did not come with RDFa mapping files, see
358+
If you use custom types that did not come with RDFa mapping files, see
347359
the remainder of this page to learn how to define the mappings.
348360

349-
To render your model named ``cmfMainContent`` with a handle you call ``rdf``, use the
361+
To render your data named ``cmfMainContent`` with a handle you call ``rdf``, use the
350362
``createphp`` twig tag as follows:
351363

352364
.. code-block:: html+jinja
@@ -360,9 +372,9 @@ To render your model named ``cmfMainContent`` with a handle you call ``rdf``, us
360372

361373
The ``noautotag`` tells CreatePHP to not automatically output a ``<div>`` with
362374
namespace declarations and the ``about`` property containing the id of your
363-
model. When using ``noautotag``, it is your responsibility to call
364-
``createphp_attributes()`` inside a container tag that contains all fields of
365-
one model instance.
375+
object. When using ``noautotag``, it is your responsibility to call
376+
``createphp_attributes()`` inside a container tag that contains the fields of
377+
the object.
366378

367379
You can also output a whole field complete with tag, attributes and content by
368380
just calling ``{{ rdf.body|raw }}``. (Without the ``raw`` filter, the HTML
@@ -384,15 +396,15 @@ your HTML structure if you want.
384396
Metadata
385397
--------
386398

387-
CreatePHP needs metadata information for each class of your domain model. By
399+
CreatePHP needs metadata information for each class of your domain objects. By
388400
default, the create bundle uses the XML metadata driver and looks for metadata
389401
in every bundles at ``<Bundle>/Resources/rdf-mappings``. If you use a third
390402
party bundle that does not come with RDFa mapping, you can simply include a
391403
mapping file for it in any of your bundles, or specify a directory containing
392404
mapping files with the ``rdf_config_dirs`` option.
393405

394-
The mapping file name needs to be the fully qualified class name of your model
395-
class, having the backslash (``\\``) replaced by a dot (``.``), i.e.
406+
The mapping file name needs to be the fully qualified class name, having the
407+
backslash (``\\``) replaced by a dot (``.``), i.e.
396408
``Symfony.Cmf.Bundle.ContentBundle.Doctrine.Phpcr.StaticContent.xml``.
397409

398410
A basic mapping look as follows:
@@ -457,11 +469,11 @@ reads like this:
457469
All of these issues will hopefully be fixed in later versions if people
458470
step up and contribute pull requests.
459471

460-
Mapping Requests to Domain Model
461-
--------------------------------
472+
Mapping Requests to Domain Objects
473+
----------------------------------
462474

463475
One last piece is the mapping between CreatePHP data and the application
464-
domain model. Data needs to be stored back into the database.
476+
domain objects. Data needs to be stored back into the database.
465477

466478
In version 1.0, the CreateBundle only provides a service to map to Doctrine
467479
PHPCR-ODM. If you do not enable the phpcr persistence layer, you need to
@@ -479,8 +491,10 @@ into the CreatePHP and CreateBundle and do a pull request to enable this feature
479491

480492
.. _`create.js`: http://createjs.org
481493
.. _`hallo.js`: http://hallojs.org
494+
.. _`CKEditor`: http://ckeditor.com/
482495
.. _`CreatePHP`: https://github.com/flack/createphp
483496
.. _`with composer`: http://getcomposer.org
484497
.. _`symfony-cmf/create-bundle`: https://packagist.org/packages/symfony-cmf/create-bundle
498+
.. _`RDF`: http://en.wikipedia.org/wiki/Resource_Description_Framework
485499
.. _`RDFa`: http://en.wikipedia.org/wiki/RDFa
486500
.. _`Symfony2 security chapter`: http://symfony.com/doc/current/book/security.html

0 commit comments

Comments
 (0)