Ignore:
Timestamp:
15 Dec 2014, 10:48:40 (10 years ago)
Author:
Henrik Bettermann
Message:

Add HTMLDocumentDisplayContentPage which renders only the content part of HTMLDocuments.

Include <a> element on display pages for copy and paste.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/documents
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/browser.py

    r12239 r12242  
    3636from waeup.ikoba.interfaces import MessageFactory as _
    3737from waeup.ikoba.interfaces import (
    38     IContactForm, IObjectHistory, IIkobaObject, IIkobaUtils)
     38    IContactForm, IObjectHistory, IIkobaObject, IIkobaUtils, PUBLISHED)
    3939from waeup.ikoba.browser.layout import (
    4040    IkobaPage, IkobaEditFormPage, IkobaAddFormPage, IkobaDisplayFormPage,
     
    187187
    188188
     189class HTMLDocumentDisplayContentPage(IkobaPage):
     190    """ Page to display the html content of document
     191    """
     192    grok.context(IHTMLDocument)
     193    grok.name('display')
     194    grok.template('htmldisplaypage')
     195
     196    @property
     197    def label(self):
     198        return self.context.title
     199
     200    def update(self):
     201        if self.context.state != PUBLISHED:
     202            self.flash(_('The document requested has not yet been published.'),
     203                type="warning")
     204            self.redirect(self.url(self.context))
     205        super(HTMLDocumentDisplayContentPage, self).update()
     206        return
     207
     208    @property
     209    def content(self):
     210        lang = self.request.cookies.get('ikoba.language')
     211        html = self.context.html_dict.get(lang,'')
     212        if html =='':
     213            portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE
     214            html = self.context.html_dict.get(portal_language,'')
     215        return html
     216
     217
    189218class DocumentManageFormPage(IkobaEditFormPage,
    190219                            LocalRoleAssignmentUtilityView):
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/browser_templates/htmldocumentpage.pt

    r12227 r12242  
    2424    <tr>
    2525      <td i18n:translate="" class="fieldname">
    26         Rendered Content:
     26        Content:
    2727      </td>
    2828      <td>
     
    3030      </td>
    3131    </tr>
     32    <tr tal:condition="python: getattr(context, 'state', None) == 'published'">
     33      <td i18n:translate="" class="fieldname">
     34        HTML Element:
     35      </td>
     36      <td>
     37        &lt;a href=&quot;
     38        <span tal:replace="python: view.url(context, 'display')"></span>
     39        &quot;&gt;<span tal:replace="context/title">FILENAME</span>&lt;/a&gt;
     40      </td>
     41    </tr>
    3242  </tbody>
    3343</table>
Note: See TracChangeset for help on using the changeset viewer.