|
1 .. -*- coding: utf-8 -*- |
|
2 |
|
3 Have a blog ready in less than ten minutes! |
|
4 ------------------------------------------- |
|
5 |
|
6 Installation |
|
7 ~~~~~~~~~~~~ |
|
8 |
|
9 You need to install the following packages:: |
|
10 |
|
11 cubicweb, cubicweb-blog |
|
12 |
|
13 The package `cubicweb` is installing the command `cubicweb-ctl` that |
|
14 will allow you to create new application. |
|
15 |
|
16 The package `cubicweb-blog` is installing the blogging support for the |
|
17 `CubicWeb` framework. |
|
18 |
|
19 Application creation |
|
20 ~~~~~~~~~~~~~~~~~~~~ |
|
21 |
|
22 Creation and initialization of your application by running:: |
|
23 |
|
24 cubicweb-ctl create blog myblog |
|
25 |
|
26 *myblog* is the name of the application you are creating. |
|
27 |
|
28 *blog* is the name of the component on which your application |
|
29 is based. |
|
30 |
|
31 Application launch |
|
32 ~~~~~~~~~~~~~~~~~~ |
|
33 |
|
34 Your application is now ready to go:: |
|
35 |
|
36 cubicweb-ctl start -D myblog |
|
37 |
|
38 This is it. Your blog is ready to you. Go to http://localhost:8080 and enjoy!! |
|
39 |
|
40 |
|
41 A little code snapshot from behind the scene |
|
42 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
43 |
|
44 The component `blog`, referred as a `cube` in the book |
|
45 (see :ref:`TermsVocabulary` for a complete definition), defines |
|
46 a data model in ``/usr/share/cubicweb/cubes/blog/schema.py``. |
|
47 Here is the corresponding Python code:: |
|
48 |
|
49 from cubicweb.schema import format_constraint |
|
50 |
|
51 class Blog(EntityType): |
|
52 title = String(maxsize=50, required=True) |
|
53 description_format = String(meta=True, internationalizable=True, maxsize=50, |
|
54 default='text/rest', constraints=[format_constraint]) |
|
55 description = String() |
|
56 rss_url = String(maxsize=128, description=_('blog\'s rss url (useful for when using external site such as feedburner)')) |
|
57 |
|
58 |
|
59 class BlogEntry(EntityType): |
|
60 title = String(required=True, fulltextindexed=True, maxsize=256) |
|
61 content_format = String(meta=True, internationalizable=True, maxsize=50, |
|
62 default='text/rest', constraints=[format_constraint]) |
|
63 content = String(required=True, fulltextindexed=True) |
|
64 entry_of = SubjectRelation('Blog', cardinality='?*') |
|
65 |
|
66 Two types of entities are defined here: Blog and BlogEntry. |
|
67 |
|
68 A Blog is defined by a title, a description and its format and a |
|
69 RSS URL to provide RSS feed. |
|
70 |
|
71 A BlogEntry is defined by a title, a content and its format and |
|
72 a relation to a Blog, meaning a BlogEntry belongs to a Blog. |
|
73 |
|
74 |
|
75 Next step |
|
76 ~~~~~~~~~ |
|
77 |
|
78 This was a brief demonstration of the re-usability of cubes and a way |
|
79 to show how you can use `CubicWeb` straigth out of the box. |
|
80 |
|
81 As a developper, you'll want to know more about how to develop new |
|
82 cubes and cutomize the views and this is what we talk about now. |
|
83 |
|
84 |