source: trunk/skins/lemill/widget_chapter.pt @ 3124

Revision 3124, 18.3 KB checked in by jukka, 9 years ago (diff)

Enabled embedding for Google Docs, Spreadsheets, Drawings and Presentations.

Line 
1<html xmlns="http://www.w3.org/1999/xhtml"
2      xmlns:tal="http://xml.zope.org/namespaces/tal"
3      xmlns:metal="http://xml.zope.org/namespaces/metal"
4      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
5      i18n:domain="lemill">
6  <head><title></title></head>
7  <body>
8
9<!-- Main view macro -->
10
11<metal:view_macro define-macro="view" tal:define="value accessor"> 
12    <tal:chapters repeat="chapter value">           
13        <tal:defs tal:define="text chapter/text;
14            type chapter/type;
15            index repeat/chapter/index;">
16            <metal:view_block use-macro="python:path('here/widget_chapter/macros/view_'+type)" />
17        </tal:defs>
18    </tal:chapters>
19</metal:view_macro>
20
21<!-- view macros, called from Main view macro and these can be used by other widgets too -->
22
23<metal:view_text_block define-macro="view_text_block">
24<div tal:replace="structure text" />
25</metal:view_text_block>
26
27<metal:view_media_piece define-macro="view_media_piece">
28<tal:piece_defs define="piece python:field.getObjectByUID(context, chapter.get('uid',''));
29    piece_url piece/absolute_url | nothing;
30    piece_type piece/getPiece_type | nothing;
31    macro_mapping python:{'image':'here/piece_macros/macros/image',
32        'audio':'here/macros_audioplayer/macros/audioplayer',
33        'flash':'here/piece_macros/macros/swf_macro',
34        'flv-video':'here/macros_flowplayer/macros/flowplayer_chapter_view',
35        'kml':'here/piece_macros/macros/kml_macro',
36        'video':'here/macros_flowplayer/macros/flowplayer_chapter_view'}">   
37        <tal:we_got_piece condition="python:piece and not piece.isDeleted()">
38            <metal:view use-macro="python:path(macro_mapping.get(piece_type,'here/piece_macros/macros/download_only'))" />
39        </tal:we_got_piece>
40</tal:piece_defs>
41</metal:view_media_piece>
42
43<metal:view_embed_block define-macro="view_embed_block">
44<div class="embed_content" tal:define="oembed python:field.isOEmbedChapter(chapter)">
45<tal:oembed condition="oembed"><tal:googledocs tal:define="gcode python:field.isGoogleDocs(chapter)"><tal:do_google condition="gcode" replace="structure gcode" />
46<a href="" tal:condition="not:gcode" tal:attributes="href chapter/embed" class="oembed" content="chapter/embed">Embedded content</a>
47</tal:googledocs></tal:oembed>
48<tal:old_embed condition="not:oembed" replace="structure chapter/embed | python:''" /></div>
49</metal:view_embed_block>
50
51<!-- Main edit macro -->
52
53<metal:define define-macro="edit">
54 <metal:use use-macro="field_macro | here/field/macros/edit">
55  <metal:fill fill-slot="widget_body">
56   <metal:chapter_editor_block define-macro="chapter_editor">
57  <tal:define define="edit_chapter request/chapter_edited | python:0;
58              edit_chapter python: int(edit_chapter);
59              translation translation | python:0;
60              chapter_count python:len(value);
61              edit_chapter python: test(edit_chapter&lt;chapter_count, edit_chapter, chapter_count-1);           
62              cleaned_chapters here/getBodyText;
63              macro_mapping python:{'text_block':'here/widget_chapter/macros/%s_text_block',
64                'guidelines':'here/widget_exercise/macros/%s_guidelines',
65                'media_piece':'here/widget_chapter/macros/%s_media_piece',
66                'embed_block':'here/widget_chapter/macros/%s_embed_block',
67                'choice':'here/widget_exercise/macros/%s_choice',
68                'multiple_choices':'here/widget_exercise/macros/%s_multiple_choices',
69                'poll':'here/widget_exercise/macros/%s_poll',
70                'fill_in_the_blanks':'here/widget_exercise/macros/%s_fill_in_the_blanks',
71                'open_ended':'here/widget_exercise/macros/%s_open_ended',
72                'exercise':'here/widget_exercise/macros/%s_exercise'};
73              chapter_names field/getChapterNames;">
74    <input type="hidden" name="chapter_count" id="chapter_count" value="1" tal:attributes="value chapter_count"/>
75    <input type="hidden" name="chapter_edited" id="chapter_edited" value="0" tal:attributes="value edit_chapter"/>
76    <input type="hidden" name="chapter_last_edited" id="chapter_last_edited" value="0" tal:attributes="value edit_chapter"/>
77    <input type="hidden" name="chapter_type" id="chapter_type" tal:attributes="value python:value[edit_chapter]['type']"/>
78   <div class="sortable">
79   <tal:chapters repeat="chapter value">
80    <tal:definitions define="index repeat/chapter/index;
81      text chapter/text;
82      type chapter/type;
83      cleaned_chapter python:cleaned_chapters[index];
84       ">       
85     <a name="#" tal:attributes="name index"></a>
86     <div class="sortable_row">       
87     <fieldset class="edit_box">   
88       <metal:legend define-macro="legendbuttons">
89            <div class="handle">
90                <img src="images/pattern.png" tal:attributes="src string:${portal_url}/images/pattern.png" alt="" width="18" height="10" style="padding-top:4px;padding-left:4px" />
91                <input class="editChapter "
92                    type="submit"
93                    name="editChapter"
94                    value="Edit" i18n:domain="plone"
95                    tal:condition="python:index!=edit_chapter"
96                    i18n:attributes="value label_edit;"
97                    tal:attributes="tabindex tabindex/next;
98                    onClick python:'''javascript:document.getElementById('chapter_edited').value=%s''' %  index"/>                   
99                <input class="saveChapter"
100                    tabindex=""
101                    type="submit"
102                    name="saveChapter"
103                    value="Save" i18n:domain="plone"
104                    tal:condition="python:index==edit_chapter"
105                    i18n:attributes="value label_save;"
106                    tal:attributes="tabindex tabindex/next;"
107                    onClick="$('chapter_edited').val('-1')"/>
108                <span tal:content="python:chapter_names[type]" i18n:translate="" class="discreet">text chapter</span>
109
110                <input class="right deleteButton"
111                    type="button"
112                    name="deleteButton"
113                    value="Delete" i18n:domain="plone"
114                    i18n:attributes="value;"
115                    tal:attributes="tabindex tabindex/next;"
116                    onClick="deleteChapter(this);" />
117                <input type="button"
118                    name="undeleteButton"
119                    class="right undeleteButton"
120                    value="Undelete"
121                    i18n:attributes="value;"
122                    tal:attributes="tabindex tabindex/next;"
123                    style="display:none"
124                    onClick="undeleteChapter(this);"/>
125                <input type="hidden"
126                    tal:attributes="id string:chapter_deleted_$index; name string:chapter_deleted_$index"
127                    class="deletionkeeper"
128                    value="0" />
129                <input type="hidden"
130                    class="orderkeeper"
131                    tal:attributes="name string:chapter_order_$index; id string:chapter_order_$index; value index" />       
132            </div>
133        </metal:legend>
134        <tal:view_mode condition="python:index!=edit_chapter">
135           <div class="inner_box">
136            <metal:block use-macro="python:path(macro_mapping[type] % 'edit_view')" />
137           </div>             
138        </tal:view_mode>
139      <tal:edit_mode condition="python:index==edit_chapter">
140           <a name="edit"></a>
141           <metal:block use-macro="python:path(macro_mapping[type] % 'edit')" />               
142      </tal:edit_mode>
143     </fieldset>
144     </div>
145     </tal:definitions>
146   </tal:chapters>
147   </div>
148   </tal:define>
149   </metal:chapter_editor_block>
150   <tal:buttons>
151       <input class="context"
152           tabindex=""
153           type="submit"
154           name="add_media_piece"
155           value="Add media piece"
156           i18n:attributes="value label_add_media_piece;"
157           tal:attributes="tabindex tabindex/next"
158           />               
159       <input class="context"
160           tabindex=""
161           type="submit"
162           name="add_text_block"
163           value="Add text block"
164           i18n:attributes="value label_add_textarea;"
165           tal:attributes="tabindex tabindex/next"
166           />
167       <input class="context"
168           tabindex=""
169           type="submit"
170           name="add_embed_block"
171           value="Add an embedded section"
172           i18n:attributes="value label_add_embed_block;"
173           tal:attributes="tabindex tabindex/next"
174           />
175   </tal:buttons>
176 </metal:fill>
177</metal:use>
178</metal:define>
179
180
181<!-- edit/view macros,  called from Main edit macros if chapter is not the one that is edited -->
182
183<metal:edit_view_text_block define-macro="edit_view_text_block">
184<div tal:replace="structure cleaned_chapter/text" />
185</metal:edit_view_text_block>
186
187<tal:edit_view_media_piece metal:define-macro="edit_view_media_piece">    
188    <tal:defs define="piece python:field.getObjectByUID(context, chapter['uid']);
189        deleted piece/isDeleted | python:True;
190        piece_url piece/absolute_url | nothing;
191        piece_type piece/getPiece_type | nothing;
192        macro_mapping python:{'image':'here/piece_macros/macros/image',
193            'audio':'here/macros_audioplayer/macros/audioplayer',
194            'flash':'here/piece_macros/macros/swf_macro',
195            'flv-video':'here/macros_flowplayer/macros/flowplayer_chapter_area_edit',
196            'kml':'here/piece_macros/macros/kml_macro'}">   
197        <tal:we_got_piece condition="python:piece and not piece.isDeleted()">
198            <metal:view use-macro="python:path(macro_mapping.get(piece_type,'here/piece_macros/macros/download_only'))" />
199        </tal:we_got_piece>
200    </tal:defs>
201</tal:edit_view_media_piece>
202
203<metal:edit_view_embed_block define-macro="edit_view_embed_block">
204<div class="embed_content" tal:define="oembed python:field.isOEmbedChapter(chapter)">
205<tal:oembed condition="oembed"><tal:googledocs tal:define="gcode python:field.isGoogleDocs(chapter)"><tal:do_google condition="gcode" replace="structure gcode" />
206<a href="" tal:condition="not:gcode" tal:attributes="href chapter/embed" class="oembed" content="chapter/embed">Embedded content</a>
207</tal:googledocs></tal:oembed>
208<tal:old_embed condition="not:oembed" replace="structure chapter/embed | python:''" /></div>
209</metal:edit_view_embed_block>
210
211
212<!-- edit macros, called from Main edit macro for chapter that is open to editing -->
213
214<metal:original_text define-macro="original_text">
215<label i18n:translate="label_original_field">Original<span i18n:name="field" >:</span></label>
216<div class="text_to_translate">
217   <span tal:replace="structure chapter/translation_source"/>           
218</div>
219</metal:original_text>
220
221
222<tal:edit_text_block metal:define-macro="edit_text_block">    
223<div class="translatedText" tal:condition="translation"><metal:tra use-macro="here/widget_chapter/macros/original_text" /></div>
224<tal:def define="inputvalue text;
225    fieldName python:'chapter_textarea';
226    inputname fieldName;
227    height python:'260px';
228    rows python:18">     
229        <metal:block metal:use-macro="here/wysiwyg_support/macros/wysiwygEditorBox" />
230</tal:def>
231</tal:edit_text_block>
232
233<tal:edit_embed_block metal:define-macro="edit_embed_block">
234<div class="editorPaddings" tal:define="oembed python:field.isOEmbedChapter(chapter) or not chapter['embed']"> 
235<div class="formHelp" i18n:translate="embed_field_help">Enter address for embedded content here. (for example http://www.youtube.com/watch?v=... )</div>      
236<p>
237<input type="text" style="width:60%" id="embed_field" name="embed_field" tal:attributes="value python:test(oembed, chapter['embed'], '')" />
238<input type="button" value="Test embedding" i18n:attributes="value python:'Test embedding'" onclick="$('#embed_test').oembed($('#embed_field').val());$('#old_embed').html('');" /></p>
239<div class="formHelp" i18n:translate="embed_google_notice">The test button doesn't work with Google embeds. Save this section to view the embedding. Embedding is enabled for Google Documents, Spreadsheets, Presentations and Drawings. Please use the link to published page given in sharing options (the one that begins with 'http://' or 'https://') instead of suggested embed code (the one that begins with '&lt;iframe '). </div>      
240
241<div id="embed_test">
242<a href="" tal:attributes="href chapter/embed" class="oembed" tal:condition="oembed" tal:content="chapter/embed">Embedded content</a></div>    
243<tal:old_embed condition="not:oembed">
244<div id="old_embed" tal:content="structure chapter/embed" />
245<br/>
246<div class="formHelp" i18n:translate="embed_field_old_value_help">For safety reason we don't allow direct embed codes anymore. The embed code for this resource was:</div>      
247
248<textarea readonly="1" rows="6" style="width:95%" id="embed_field_old" name="embed_field_old" tal:content="chapter/embed | python:''"></textarea>    
249<div class="formHelp" i18n:translate="embed_field_old_value_help_2">If you want to update this embedded content, please use the webpage address (not the embed code) of the resource.</div>
250</tal:old_embed></div>
251</tal:edit_embed_block>
252
253<metal:edit_media_piece define-macro="edit_media_piece">
254    <tal:def_search_type tal:define="piece_type python:'All'; piece_edit python:True">
255        <metal:block metal:use-macro="here/widget_chapter/macros/piece_chooser" />   
256    </tal:def_search_type>
257</metal:edit_media_piece>
258
259<metal:define define-macro="piece_chooser">
260  <tal:defines define="piece_uid chapter/uid;
261                        piece python: field.getObjectByUID(context, piece_uid);
262                        piece_url piece/absolute_url | nothing;
263                        deleted piece/isDeleted | python:True;
264                        isImage piece/isImage | python:0;
265                        isAudio piece/isAudio | python:0;
266                        isFLVVideo piece/isFLVVideo | python:0;
267                        coverImage piece/getCoverImage | nothing;">
268    <div id="piece-edit-box" tal:attributes="style python:test(piece_url, 'background-image:url(%s/image_large)' % piece_url, 'background-image:none')">
269    <div style="display:inline-block">
270        <div style="height:20px" class="visualClear">&nbsp;</div>
271        <div id="piece-edit-controls" tal:attributes="class python:test(piece and isImage, 'contrast','')"><tal:block tal:condition="python: piece_type=='image'" i18n:translate="label_upload_image_file">Upload image file</tal:block>
272        <tal:block tal:condition="python: piece_type=='audio'" i18n:translate="label_upload_audio">Upload audio file</tal:block>
273        <tal:block tal:condition="python: piece_type not in ['audio','image']" i18n:translate="label_upload_a_file">Upload a file</tal:block>...
274        <input type="hidden" value="0" name="piece_uid" id="piece_uid" tal:attributes="value piece_uid | nothing;"  />
275        <input type="hidden" value="" name="piece_type" id="piece_type" tal:attributes="value piece_type | string:image;" />
276        <input id="file"  type="file" value="" name="file" />
277        <input id="uploadFile"  type="submit"  name="uploadFile" value="Upload file" i18n:attributes="value label_upload_file;" /></div>
278        <div style="height:20px" class="visualClear">&nbsp;</div>
279    </div>
280    <div id="piece-view-controls"  style="display:inline-block">
281        <div id="piece-media-box">
282         <div style="display:inline-block;vertical-align:middle;">
283          <tal:not_image condition="python:piece and not isImage">
284            <a href="" tal:attributes="href piece_url">                       
285            <tal:coverimage condition="coverImage" replace="structure coverImage" />
286            <img tal:condition="python: isAudio and not coverImage" src="images/default_soundclip.png" />
287            <img tal:condition="python: not (isAudio or coverImage)" src="images/default_movieclip.png" />
288            </a>
289          </tal:not_image>
290         </div>
291        <div style="display:inline-block;vertical-align:middle;" tal:condition="python: isAudio and not deleted">
292         <metal:block metal:use-macro="here/macros_audioplayer/macros/audioplayer" />
293        </div>
294        </div>
295    </div>
296    <div id="tab_spacer" style="height:300px" tal:attributes="class python:test(not piece, 'hidden', '')">&nbsp;</div>
297    <div>
298    <div class="tab" id="tab_search" tal:attributes="class python:test(not piece, 'tab selected_tab', 'tab')" i18n:translate="label_or_search_from_pieces" onclick="clickedTab(this,'tab_sheet_search')">... or search from media pieces</div>
299    <div class="tab" id="tab_pieces" i18n:translate="label_browse_your_media" onclick="clickedTab(this,'tab_sheet_pieces')">browse your media</div>
300    <div class="tab" id="tab_collections" i18n:translate="label_browse_from_your_collections" onclick="clickedTab(this,'tab_sheet_collections')">browse from your collections</div>
301
302    <div class="tab_sheet" id="tab_sheet_search" tal:attributes="class python:test(not piece, 'tab_sheet selected_tab_sheet', 'tab_sheet')">
303    <p>
304    <input id="piece-search"
305            type="text"
306            value=""
307            name="piece-search"
308            onkeypress="if(event.keyCode==13) { document.getElementById('piece-searchbutton').onclick(); return false; }" />
309    <input id="piece-searchbutton"
310            type="button"
311            value="Search"
312            name="piece-searchbutton"
313            i18n:attributes="value label_search;" i18n:domain="plone"
314            onclick="search_for_pieces(this, event);"/>
315    </p>
316     <div class="tab_sheet_results">
317        <b class="message" style="display:none;">Query result message</b>
318        <div style="height:20px" class="visualClear">&nbsp;</div>
319        <div class="piece_chooser" style="display:none">Results go here</div>                                       
320    </div>
321    </div>
322   
323    <div class="tab_sheet" id="tab_sheet_pieces">
324     <div class="tab_sheet_results">
325        <b class="message" style="display:none;">Query result message</b>
326        <div style="height:20px" class="visualClear">&nbsp;</div>
327        <div class="piece_chooser" style="display:none"></div>                                       
328    </div>
329   </div>
330   <div class="tab_sheet" id="tab_sheet_collections">
331     <div class="tab_sheet_results">
332        <b class="message" style="display:none;">Query result message</b>
333        <div style="height:20px" class="visualClear">&nbsp;</div>
334        <div class="piece_chooser" style="display:none"></div>                                       
335    </div>
336  </div>
337
338    </div>
339    </div>
340
341     </tal:defines>
342</metal:define>
343
344  </body>
345</html>
Note: See TracBrowser for help on using the repository browser.