root/cpsskins/branches/paris-sprint-2006/doc/theme-structure.txt

Revision 3584, 4.0 kB (checked in by jmorliaguet, 3 years ago)

- saving work

  • added the layout editor, all elements now have a layout
  • bug fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1
2 =======================
3 THEME MANAGEMENT FOLDER
4 =======================
5
6 Themes are located inside a Theme Management Folder.
7
8 The folder structure is::
9
10  + themes ( .../++etc++site/defaut/themes )
11  |
12  +--- Theme A
13  |  |
14  |  + page a
15  |
16  |
17  +--+ Theme B
18  |  |
19  |  + page a
20  |  |
21  |  + page b
22  |
23  |
24  + Portlets (local)
25  |
26  + Formats (styles, layouts, ...)
27  |
28  + Images (backgrounds, icons, ...)
29  |
30  + Presets
31  |
32  + Snapshots
33  |
34  + Locations
35
36 Setup:
37
38     >>> root = getRootFolder()
39
40     >>> from cpsskins.tests.setup import addThemeManager
41     >>> from cpsskins.tests.setup import makeSite
42     >>> from cpsskins.utils import addThemeSkeleton
43
44     >>> tmutil = addThemeManager(root, makeSite(root))
45
46     >>> def inspect():
47     ...     for theme in tmutil.getThemes():
48     ...         print '- %s (default: %s)' % (theme.title,
49     ...                                       tmutil.isDefault(theme))
50     ...         for page in theme.getPages():
51     ...             print '  |_ %s (default: %s)' % \
52     ...                 (page.title, tmutil.isDefault(page))
53
54
55 We add a theme skeleton, this creates a default theme with a default page.
56
57     >>> theme1 = addThemeSkeleton(tmutil)
58
59     >>> inspect()
60     - Theme (default: True)
61       |_ ThemePage (default: True)
62
63     >>> tmutil.getDefaultTheme()
64     Theme('Theme')
65
66 we create and add a second theme:
67
68     >>> from cpsskins.elements.theme import Theme
69     >>> theme2 = Theme(u'Theme 2')
70
71     >>> tmutil.addTheme(theme2)
72     u'Theme-2'
73
74     >>> inspect()
75     - Theme (default: True)
76       |_ ThemePage (default: True)
77     - Theme 2 (default: False)
78
79 the default theme is still the first theme:
80
81     >>> tmutil.getDefaultTheme()
82     Theme('Theme')
83
84     >>> theme1.isDefault(), theme2.isDefault()
85     (True, False)
86
87 themes have siblings:
88
89     >>> theme2.getSiblings()
90     [Theme('Theme')]
91
92     >>> theme1.getSiblings()
93     [Theme('Theme 2')]
94
95 a theme has pages:
96
97     >>> theme1.getPages()
98     [ThemePage('ThemePage')]
99
100 we create and add a page to the second theme:
101
102     >>> from cpsskins.elements.themepage import ThemePage
103     >>> page1 = ThemePage('Page 1')
104     >>> tmutil.addPage(theme2, page1)
105     'ThemePage'
106
107     >>> inspect()
108     - Theme (default: True)
109       |_ ThemePage (default: True)
110     - Theme 2 (default: False)
111       |_ Page 1 (default: True)
112
113 we add a second page to the second theme:
114
115     >>> page2 = ThemePage('Page 2')
116     >>> tmutil.addPage(theme2, page2)
117     u'ThemePage-2'
118
119     >>> inspect()
120     - Theme (default: True)
121       |_ ThemePage (default: True)
122     - Theme 2 (default: False)
123       |_ Page 2 (default: False)
124       |_ Page 1 (default: True)
125
126 pages have siblings:
127
128     >>> page1.getSiblings()
129     [ThemePage('Page 2')]
130
131     >>> page2.getSiblings()
132     [ThemePage('Page 1')]
133
134 we can set the second theme as the default theme:
135
136     >>> tmutil.setAsDefault(theme2)
137     >>> inspect()
138     - Theme (default: False)
139       |_ ThemePage (default: True)
140     - Theme 2 (default: True)
141       |_ Page 2 (default: False)
142       |_ Page 1 (default: True)
143
144 we can set the second page as the default page:
145
146     >>> tmutil.setAsDefault(page2)
147     >>> inspect()
148     - Theme (default: False)
149       |_ ThemePage (default: True)
150     - Theme 2 (default: True)
151       |_ Page 2 (default: True)
152       |_ Page 1 (default: False)
153
154
155 if we remove a page that was used by default, the first page of the theme
156 will be use by default instead:
157
158     >>> del theme2[u'ThemePage-2']
159
160     >>> inspect()
161     - Theme (default: False)
162       |_ ThemePage (default: True)
163     - Theme 2 (default: True)
164       |_ Page 1 (default: True)
165
166 we can also remove the only page of a theme:
167
168     >>> del theme2[u'ThemePage']
169
170     >>> inspect()
171     - Theme (default: False)
172       |_ ThemePage (default: True)
173     - Theme 2 (default: True)
174
175 if we remove a theme that is a default theme, the first theme will become
176 the default theme:
177
178     >>> del tmutil[u'Theme-2']
179     >>> inspect()
180     - Theme (default: True)
181       |_ ThemePage (default: True)
182
183 we can delete the only theme left:
184
185
186     >>> del tmutil[u'Theme']
187     >>> inspect()
Note: See TracBrowser for help on using the browser.