[Zope-CMF] Please, help to start using Epoz

Colin Leath cleath@j9k.org
Sun, 1 Jun 2003 08:50:41 -0400 (EDT)


Here's what I do to use Epoz in cmf
(at http://carfreeuniverse.org):

(1) copy document_edit_form (ZPT) and put it in your epoz
skin folder. Rename it to epoz_edit_form

since I'm running epoz on freezope, some modification of the
init script is necessary (just commenting out lines). Mine
is at the end of this email.

(2) edit the epoz_edit_form so that it calls Epoz!
my epoz_edit_form is below. Really, I only made one
essential change.

(3) follow the instructions at
http://cmf.zope.org/Members/tseaver/20020723_external_editor_available/view

but modify as appropriate (read the responses) to use epoz.
(the security part is not necessary, for one thing.).


Being lazy, I call my epoz_edit action "edit (wysiwyg)" and
leave it there along with the normal edit and edit
(external) actions.

Colin
http://j9k.org

On Sat, 31 May 2003, gxk@rambler.ru wrote:

> Hi!
>
> I am new guy in Zope, so excuse me for dumm questions.Have Zope-2.6.1,
> CMF-1.4, Epoz-0.2.2 under RedHat9 w/ Mozilla-1.4rc1 and IE6-sp1
>
> 1.
> I am trying to use Epoz under CMFPortal.
> Add epoz under <portal_skins> and add epoz to the skin path.
>
> Create edit dtml-method (id=edit) w/ code from your example under
> <portal>/skins/custom
> Also create dtml-doc at the same place, named test.
>
> Now when i did URL/<portal>/test getting test document, but when
> URL/<portal>/test/edit nothing changed.
> Can u have any advise for me?
>
>
>
> _______________________________________________
> Zope-CMF maillist  -  Zope-CMF@zope.org
> http://mail.zope.org/mailman/listinfo/zope-cmf
>
> See http://collector.zope.org/CMF for bug reports and feature requests
>

## Script (Python) "Epoz"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=name, data='', toolbox='', lang='en',
style='width: 600px; height: 250px;', path=''
##title=
##
#
#    This program is free software; you can redistribute it
and/or modify
#    it under the terms of the GNU General Public License as
published by
#    the Free Software Foundation; either version 2 of the
License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be
useful,
#    but WITHOUT ANY WARRANTY; without even the implied
warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General
Public License
##   along with this program; if not, write to the Free
Software
###  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
MA  02111-1307  USA
#####

""" Create an Epoz-Wysiwyg-Editor.

    name : the name of the form-element which submits the
data
    data : the data to edit
    toolbox : a link to a HTML-Page which delivers
additional tools
    lang: a code for the language-file (en,de,...)
    style : style-definition for the editor
    path : path to Epoz-Javascript. Needed mainly for Plone
(portal_url).

    If Epoz can't create a Rich-Text-Editor, a simple
textarea is created.
"""

if data is None:
    data=''

js_data = data

# Unqoute newlines and single quotes, so the Epoz-JavaScript
won't break.

for (key,val) in {'\n':'\\n', '\r':'', "'":"\\'"}.items():
    js_data = js_data.replace(key, val)

# Return the HTML-Code for the Epoz-Rich-Text-Editor

return """
<iframe id="EpozIFrame" style="position: absolute;
visibility: hidden; width: 0px; height: 0px;"></iframe>

<script language="JavaScript" type="text/javascript"
src="%sepoz_lang_%s.js"></script>
<script language="JavaScript" type="text/javascript"
src="%sepoz_script_widget.js"></script>
<script language="JavaScript" type="text/javascript"
src="%sepoz_script_detect.js"></script>
<script language="JavaScript" type="text/javascript"
src="%sepoz_script_main.js"></script>
<script language="JavaScript" type="text/javascript">
<!--
InitEpoz('%s','%s','%s','%s','%s');
//-->
</script>
<noscript><textarea name="%s"
style="%s">%s</textarea></noscript>
""" % ( path, lang,
        path,
	    path,
	    path,
        name, js_data, toolbox, style, path,
        name, style, data
      )


###########################=epoz_edit_form:=#################

<html xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      metal:use-macro="here/main_template/macros/master">
<body>
<div metal:fill-slot="main">
<div class="Desktop">
<h2>Edit <span tal:replace="here/getId">ID</span></h2>

<form action="document_edit" method="post"
enctype="multipart/form-data"
      tal:attributes="action
string:${here/absolute_url}/document_edit"
>

 <input type="hidden" name="SafetyBelt" value=""
        tal:attributes="value here/SafetyBelt">

<table class="FormLayout">
 <tr>
  <th>
    Title
  </th>
  <td>
   <span tal:replace="here/Title">Title</span>
  </td>
 </tr>

 <tr>
  <th>
    Description
  </th>
  <td>
   <span tal:replace="here/description">Description</span>
  </td>
 </tr>

 <tr>
  <th>
   Format
  </th>
  <td>
   <input type="radio" name="text_format"
                     value="structured-text"
                     tal:attributes="checked python:
path('here/text_format') == 'structured-text'" />
   <label for="cb_structuredtext">structured-text</label>
   <input type="radio" name="text_format" value="plain"
          tal:attributes="checked python:
path('here/text_format') == 'plain'" />
   <label for="cb_html">plain text</label>
   <input type="radio" name="text_format" value="html"
          tal:attributes="checked python:
path('here/text_format') == 'html'" />
   <label for="cb_html">html</label>
  </td>
 </tr>

 <tr>
  <th> Upload </th>
  <td>
   <input type="file" name="file" size="25">
  </td>
 </tr>

 <tr>
  <th class="TextField"> Edit </th>
  <td class="TextField">

   <span tal:replace="structure python:
here.Epoz('text:text', data=here.EditableBody(),
                           toolbox='',
                           lang='en',
                           style='width: 820px; height:
450px;')">Epoz editor here</span>


  </td>
 </tr>

 <tr>
  <td> <br> </td>
  <td>
    <input type="submit" name="choice" value=" Change ">
    <input type="submit" name="choice" value=" Change and
View ">
  </td>
 </tr>


<tr>
<th>
Note:
</th>
<td>
You will get a WYSIWYG (what you see is what you get) editor
only if you're using Mozilla version &gt;= 1.3.1 or I.E.
version &gt;= 5.5. If you would like to have the option of
setting the editing area height &amp; width, <a
href="email_admin">tell me so</a>. It is easy to do.
 </td>
 </tr>


</table>
</form>
</div>
</div>
</body>
</html>