johan wrote:

I have a question about moblog. I would like to have it possible, that
when I send a mail to the moblog-emailaddress, where the email is
divided in a part meant to appear in body and the second part in extend,
by using certain rules in the mail. Is this possible ?
Concerning coreblog, I would like to know how I could use topic images,
like in squishdot, because this doesnt work with me, problem with
manage_categoryForm : Cannot locate object at:
http://xxxxxx/blog/manage_categoryForm
I also try to get the following thing workin : authentication and
possiblility to add articles from the website and not from the zmi ?


I cannot help you with the moblog and topic images questions. To achieve authentication from the website, take a look at the CookieCrumbler product for Zope.

Concerning your question about adding articles from the website, some time ago I worked on it and got it working, including the addition of images to the post, but with some limitations I could not solve. Anyway, I'll explain it to you, maybe you can use it or even solve the problems!

I have added a DTMLMethod called 'addEntryForm' with the following code:

<dtml-var blog_header>
<dtml-var blog_banner>
<div id="content">
<div class="blog">
<h3 class="title">Add Entry</h3>
<div class="comments-head">Edit Entry informations to add. Some fields are optional.</div>
<div class="comments-body">
<form ACTION="manage_addEntry2" METHOD="POST" enctype="multipart/form-data">
<table cellspacing="1" cellpadding="0" border="0">
<tr>
<td align="left" valign="top" class="list-header">
<div class="form-label">Author</div>
</td>
<td align="left" valign="top">
<input type="text" name="author" size="40" value="<dtml-var "AUTHENTICATED_USER.getUserName()">" />
</td>
</tr>
<tr>
<td align="left" valign="top" class="list-header">
<div class="form-label">Title</div>
</td>
<td align="left" valign="top">
<input type="text" name="thetitle" size="80" value=""/>
</td>
</tr>
<tr>
<td align="left" valign="top" class="list-header">
<div class="form-optional">Subtitle</div>
</td>
<td align="left" valign="top">
<input type="text" name="subtitle" size="80" value=""/>
</td>
</tr>
<tr>
<td align="left" valign="top" class="list-header">
<div class="form-optional">Entry date&time</div>
</td>
<td align="left" valign="top">
<input type="text" name="entry_date" size="40" value=""/>
</td>
</tr>
<tr>
<td align="left" valign="top" class="list-header">
<div class="form-label">Category</div>
</td>
<td align="left" valign="top">
<select name="main_category:int">
<dtml-in category_list>
<option value="<dtml-var id>"><dtml-var name missing="category name is missing"></option>
</dtml-in>
</select>
</td>
</tr>
<tr>
<td align="left" valign="top" class="list-header">
<div class="form-optional">Sub Categories</div>
</td>
<td align="left" valign="top">
<dtml-in category_list>
<input type="checkbox" name="sub_category:list" value="<dtml-var id>" /><dtml-var name missing="category name is missing">
</dtml-in>
</td>
</tr>
<input type="hidden" name="format:int" value="1">
<tr>
<td align="left" valign="top" class="list-header">
<div class="form-label">Body</div>
</td>
<td align="left" valign="top">
<textarea name="thebody:text" style="width: 500px; height: 250px; border: 1px solid #000000;"></textarea>
</td>
</tr>
<tr>
<td align="left" valign="top" class="list-header">
<div class="form-optional">Extend</div>
</td>
<td align="left" valign="top">
<textarea name="extend:text" cols="60" rows="6"></textarea>
</td>
</tr>
<tr>
<td align="left" valign="top" class="list-header">
<div class="form-optional">Excerpt</div>
</td>
<td align="left" valign="top">
<textarea name="excerpt:text" cols="60" rows="6"></textarea>
</td>
</tr>
<tr>
<td align="left" valign="top" class="list-header">
<div class="form-label">Comment</div>
</td>
<td align="left" valign="top">
<select name="allow_comment:int">
<option value="0" >None(cannot add,hidden)</option>
<option value="1" selected>Open(can add,shown)</option>
<option value="2" >Closed(cannot add,shown)</option>
</select>
</td>
</tr>
<tr>
<td align="left" valign="top" class="list-header">
<div class="form-label">Trackback</div>
</td>
<td align="left" valign="top">
<select name="receive_trackback:int">
<option value="0" >None(cannot add,hidden)</option>
<option value="1" selected>Open(can add,shown)</option>
<option value="2" >Closed(cannot add,shown)</option>
</select>
</td>
</tr>
<tr>
<td align="left" valign="top" class="list-header">
<div class="form-label">Status</div>
</td>
<td align="left" valign="top">
<select name="moderated:int">
<option value="0" >Closed</option>
<option value="1" selected>Open</option>
</select>
</td>
</tr>
<tr>
<td align="left" valign="top" class="list-header">
<div class="form-optional">Picture</div>
</td>
<td align="left" valign="top">
<input type="file" name="photo">
</td>
</tr>
<tr>
<td align="left" valign="top" class="list-header" rowspan="2">
<div class="form-optional">Trackback URL(s)</div>
</td>
<td align="left" valign="top">
<textarea name="trackback_url:text" cols="60" rows="4"></textarea>
</td>
</tr>
<tr>
<td align="left" valign="top">
<input type="checkbox" name="sendnow" checked />Send Trackback(s) immediate.
</td>
</tr>
<tr>
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<div class="form-element">
<input class="form-element" type="submit" name="submit" value="Add Entry" />
</div>
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
<dtml-var blog_footer>


As you can see, this calls an intermediate 'manage_addEntry2' method which does some preprocessing (adding the image to the images folder, adding a line in the body to include that image, etc.) and a preview before calling COREBlog's own 'manage_addEntry' method. This is this DTMLMethod's content:

<dtml-var blog_header>
<dtml-var blog_banner>
<dtml-if photo>
<dtml-call "REQUEST.set('numblist',[])">
<dtml-in "images.objectIds()">
<dtml-if "_.getitem('sequence-item')[:4]=='img_'">
<dtml-call "numblist.append(_.int(_.getitem('sequence-item')[4:]))">
</dtml-if>
</dtml-in>
<dtml-if "_.len(numblist)==0">
<dtml-call "REQUEST.set('imgnumber',0)">
<dtml-else>
<dtml-call "REQUEST.set('imgnumber',_.max(numblist)+1)">
</dtml-if>
<dtml-call "images.manage_addImage('img_'+_.str(imgnumber),photo)">
<dtml-call "REQUEST.set('thebody2','&lt;img src=&quot;./images/img_'+_.str(imgnumber)+'&quot; border=&quot;0&quot;&gt;&lt;br&gt;\n')">
<dtml-else>
<dtml-call "REQUEST.set('thebody2','')">
</dtml-if>
<dtml-call "REQUEST.set('thebody2',thebody2+thebody)">
<h3 class="title">Confirm</h3>
<div id="content">
<div class="blog">
<div class="entry">
<div class="blogbody">
<h3 class="title"><dtml-var thetitle></h3>
<dtml-if "_.len(subtitle)>0"><div class="subtitle"><dtml-var subtitle></div></dtml-if>
<dtml-in category_list>
<dtml-if "_.int(id)==main_category">
<dtml-call "REQUEST.set('catname',name)">
</dtml-if>
</dtml-in>
<div class="category">
<a href="<dtml-var blogurl missing="">/categorylist_html?cat_id=<dtml-var main_category>">[<dtml-var catname missing="category name is missing">]</a>
</div>
<p>
<dtml-call "REQUEST.set('thebody3',_.string.replace(_.string.replace(_.string.replace(thebody2,'&lt;','<'),'&gt;','>'),'&quot;',_.chr(34)))">
<dtml-in "_.string.split(thebody3,'\n')">
<dtml-let bodyline="_.getitem('sequence-item')">
<dtml-if "_.getitem('sequence-index')==0">
<dtml-call "REQUEST.set('bodylist',[])">
<dtml-if "bodyline[0:4]=='<img'">
<dtml-let entry_image="bodyline[_.string.find(bodyline,'src=')+5:_.string.find(bodyline,_.chr(34),_.string.find(bodyline,'src=')+5)]">
<dtml-let theheight="images[entry_image[_.string.rfind(entry_image,'/')+1:_.len(entry_image)]].height">
<dtml-let thewidth="images[entry_image[_.string.rfind(entry_image,'/')+1:_.len(entry_image)]].width">
<dtml-if "thewidth>theheight">
<dtml-if "thewidth<300">
<dtml-call "REQUEST.set('imagewidth',thewidth)">
<dtml-else>
<dtml-call "REQUEST.set('imagewidth',300)">
</dtml-if>
<dtml-else>
<dtml-if "theheight<300">
<dtml-call "REQUEST.set('imagewidth',thewidth)">
<dtml-else>
<dtml-call "REQUEST.set('imagewidth',300*thewidth/theheight)">
</dtml-if>
</dtml-if>
</dtml-let>
</dtml-let>
<a href="<dtml-var entry_image>"><dtml-var "bodyline[:_.string.index(bodyline,'>')]"> width="<dtml-var imagewidth>"></a><br>
</dtml-let>
<dtml-else>
<dtml-call "bodylist.append(bodyline)">
</dtml-if>
<dtml-else>
<dtml-call "bodylist.append(bodyline)">
</dtml-if>
</dtml-let>
</dtml-in>
<dtml-call "REQUEST.set('changedbody',_.string.join(bodylist,'\n'))">
<dtml-if "format == 0">
<dtml-var changedbody newline_to_br>
<dtml-elif "format == 1">
<dtml-var changedbody fmt=structured-text>
<dtml-elif "format == 2">
<dtml-var changedbody>
</dtml-if>
</p>
<br clear="all" />
<p>
<a name="more"></a>
<dtml-if "format == 0">
<dtml-var extend newline_to_br>
<dtml-elif "format == 1">
<dtml-var extend fmt=structured-text>
<dtml-elif "format == 2">
<dtml-var extend>
</dtml-if>
</p>
<dtml-if entry_date>
<dtml-call "REQUEST.set('thedate',entry_date)">
<dtml-else>
<dtml-call "REQUEST.set('thedate',_.DateTime())">
</dtml-if>
<div class="posted">Posted by: <b><dtml-var author></b> Time: <dtml-var thedate></div>
<div class="comments-body">
<form ACTION="manage_addEntry" METHOD="POST">
<input type="hidden" name="author" value="<dtml-var author>" />
<input type="hidden" name="title" value="<dtml-var thetitle>" />
<input type="hidden" name="subtitle" value="<dtml-var subtitle>" />
<input type="hidden" name="entry_date" value="<dtml-var thedate>" />
<input type="hidden" name="main_category:int" value="<dtml-var main_category>" />
<dtml-if sub_category>
<dtml-if "objecttype(sub_category)=='list'">
<dtml-in sub_category>
<input type="hidden" name="sub_category:list" value="<dtml-var sequence-item>" />
</dtml-in>
<dtml-elif "objecttype(sub_category)=='string'">
<input type="hidden" name="sub_category:list" value="<dtml-var sub_category>" />
</dtml-if>
</dtml-if>
<input type="hidden" name="format:int" value="<dtml-var format>">
<input type="hidden" name="body" value="<dtml-var "_.string.replace(_.string.replace(_.string.replace(thebody2,'<','&lt;'),'>','&gt;'),_.chr(34),'&quot;')">">
<input type="hidden" name="extend" value="<dtml-var "_.string.replace(_.string.replace(_.string.replace(extend,'<','&lt;'),'>','&gt;'),_.chr(34),'&quot;')">">
<input type="hidden" name="excerpt" value="<dtml-var "_.string.replace(_.string.replace(_.string.replace(excerpt,'<','&lt;'),'>','&gt;'),_.chr(34),'&quot;')">">
<input type="hidden" name="allow_comment:int" value="<dtml-var allow_comment>">
<input type="hidden" name="receive_trackback:int" value="<dtml-var receive_trackback>">
<input type="hidden" name="moderated:int" value="<dtml-var moderated>">
<input type="hidden" name="trackback_url:text" value="<dtml-var trackback_url>">
<input type="hidden" name="sendnow" value="<dtml-var sendnow>">
<input type="submit" name="submit" value="Add Entry" />
</form>
</div>
</div>
</div>
</div>
</div>
<dtml-var blog_footer>


Then you need to add a python script called 'objecttype' which takes a parameter called 'object' and has the following content:

if object is None:
   return 'None'
s = str(object)
if object==s:
   return 'string'
try:
   t = object.meta_type
   return t
except:
   pass
try:
   l = len(object)
   if s[0]=='[':
       return 'list'
   if s[0]=='(':
       return 'tuple'
   if s[0]=='{':
       return 'dict'
   return 'sequence'
except:
   pass
try:
   t = object.timeTime()
   return 'DateTime'
except:
   pass
try:
   val = int(object)
   if val is object:
       return 'integer'
   return 'number'
except:
   return 'unknown'

Now you have to change some permisions. The first method we talked about, 'addEntryForm', has to be viewable by managers and owners. In your CoreBlog, managers and owners must be able to add coreblog entries and add documents, images and files.

So now every user you add with the 'owner' role will be able to add an article through the 'addEntryForm' form without going into the ZMI, and will even be able to add an image at the beginning of it.

The limitations I talked about are that you can only edit it in structured text and that you can not use the EPOZ service to edit the article (they both gave me some complications I haven't had time or been able to solve). But if it is of use to you as it is...

------------------------------------------------------
*Igor Leturia Azkarate*
Elhuyar I+G+B
Zelai Haundi kalea, 3
Osinalde industrialdea
20170 Usurbil
(+34) 943 36 30 40
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> / www.elhuyar.org <http://www.elhuyar.org>


_______________________________________________
COREblog-en mailing list
[email protected]
http://postaria.com/cgi-bin/mailman/listinfo/coreblog-en
Unsubscription writing to [EMAIL PROTECTED]

Reply via email to