[Zope-CMF] Page view without CMF framing
J C Lawrence
claw@kanga.nu
Sat, 24 Aug 2002 01:42:40 -0700
On Sat, 24 Aug 2002 03:13:10 -0500
Ausum Studio <ausum_studio@hotmail.com> wrote:
> Just write a skin (use the name you want, 'pdf_friendly' for example)
> to render the content of your current document as clean as you desire
> it, by carefully including just your relevant content, getting rid of
> navigational aids like 'action_box', for example.
> Then within portal_types add it as an action to every wiki or wiki
> page object.
That sounds neater than what I ended up doing. However I've yet to
figure out how to do what I want with a portal_types action. Care to
give a hint how to clean up the below with portal_types?
Using:
http://cmf.zope.org/Members/jshell/News/PrintablePage
http://www.easysw.com/htmldoc/
http://www.zope.org/Members/mjablonski/howtoPDF/
Getting it all to work took four steps:
1) Installed htmldoc. (There's a Debian package)
2) Getting html2pdf.py happy with Plone. The essential changes were
to change the condition to:
if self.meta_type=='Folder':
html = self.index_html(self,self.REQUEST,self.REQUEST.R$
else:
html = self()
3) Creating a new, "printable" skin:
a) Created a "printable" folder under portal_skins.
b) Copied main_template from portal_skins/plone_templates to the new
printable folder.
c) Edited main_template in the printable folder such that the guts
looks like:
--<cut>--
<table class="columns">
<tbody>
<tr>
<td class="main"
tal:define="global show_border python:here.showEditableBorder(template_id=template.getId(), actions=actions);">
<metal:block metal:define-slot="super"
tal:condition="show_border" >
<div class="contentBar">
</div>
</metal:block>
<div class="document"
tal:attributes="class python:test(show_border, 'editableDocument', 'document')">
<metal:block metal:define-slot="main" tal:content="nothing">
Page body text
</metal:block>
<metal:block metal:define-slot="sub">
<tal metal:use-macro="here/viewThreadsAtBottom/macros/discussionView" />
</metal:block>
</div>
</td>
</tr>
</tbody>
</table>
--<cut>--
d) In portal_skins Properties added a new skin, "printable", and
copied the value of the Plone Skin, "Plone Default" to it.
e) Prepended "printable" to the new printable skin value.
4) Getting a PDF link on all pages:
a) Copy, "navigation_slot" from
portal_skins/plone_templates/ui_slots to the custom folder.
b) Edit, "navigation_slot" to add the following section at the end
of the tbody tag:
--<cut>--
<tr class="odd">
<td colspan="2">
<a href="../folder_contents"
tal:attributes="href string:${here/absolute_url}/html2pdf?plone_skin=printable">
<img src="dummy.gif"
alt=">"
border="0"
tal:attributes="src string:$portal_url/linkTransparent.gif" />
PDF
</a>
</td>
</tr>
--<cut>--
Done.
Caveats: On very brief checking it seems to work everywhere EXCEPT for
the root of a Plone site where it gives an AttributeError on:
Traceback (innermost last):
File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 150, in publish_module
File /var/lib/zope/Products/Localizer/__init__.py, line 57, in new_publish
File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 114, in publish
File /usr/lib/zope/lib/python/Zope/__init__.py, line 159, in zpublisher_exception_hook
(Object: site)
File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 98, in publish
File /usr/lib/zope/lib/python/ZPublisher/mapply.py, line 88, in mapply
(Object: html2pdf)
File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 39, in call_object
(Object: html2pdf)
File /usr/lib/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, line 198, in __call__
(Object: html2pdf)
(Info: ((<CMFSite instance at 8eaf7c8>,), {}, None))
File /var/lib/zope/Extensions/html2pdf.py, line 20, in html2pdf
(Object: site)
AttributeError: (see above)
Where line 20 is a call to self() in my edited html2pdf.py.
I haven't attempted to debug this. Its late, I'm tired. Directions on
how to make this cleaner via portal_types would be most appreciated.
Heck, I'll promise to doc this all on the dogbowl for some cleanup
assistance...
--
J C Lawrence
---------(*) Satan, oscillate my metallic sonatas.
claw@kanga.nu He lived as a devil, eh?
http://www.kanga.nu/~claw/ Evil is a name of a foeman, as I live.