Nola hobetu zure COREBlog bloga III: Kolaboratzaileei gure blogean artikuluak idazteko aukera eman
COREBlog-ekin egindako blogek (eibar.org-en daudenak adibidez) ez daukate artikuluak gehitzeko pantailarik, ez bada kudeatzailearen pasahitzarekin kudeatze-pantailetan sartuta. Eta gure blogean hainbat kolaboratzaileri artikuluak idazteko aukera eman nahi badiegu, ez dugu kudeatzaile baimenak eman beste aukerarik. Baina hau kolaboratzaile batentzat konplikatuegia izan daiteke eta gure blogarentzat arriskutsua. Ikusi hemen nola egin dezakegun artikuluak idazteko pantaila bat, argazkiak gehitzeko aukera eta guzti, eta nola eman baimenak horretarako soilik.
Hasteko, blogaren erroan DTMLMethod bat sortu, "addEntryForm" izenarekin, eta eduki honekin:
<dtml-var blog_header>
<dtml-var blog_banner>
<div id="content">
<div class="blog">
<h3 class="title">Artikulua gehitu</h3>
<div class="comments-head">Bete artikuluaren eremuak. Batzuk aukerakoak dira.</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">Egilea</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">Izenburua</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">Azpititulua</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">Noiz</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">Atala</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">Azpiatalak</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">Sarrera</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">Gorputza</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">Laburpena</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">Erantzunak</div>
</td>
<td align="left" valign="top">
<select name="allow_comment:int">
<option value="0" >Ezer ez (ezin gehitu, ezkutatuta)</option>
<option value="1" selected>Irekita (gehitu daiteke, agerian)</option>
<option value="2" >Itxita (ezin gehitu, agerian)</option>
</select>
</td>
</tr>
<tr>
<td align="left" valign="top" class="list-header">
<div class="form-label">Trackback-ak</div>
</td>
<td align="left" valign="top">
<select name="receive_trackback:int">
<option value="0" >Ezer ez (ezin gehitu, ezkutatuta)</option>
<option value="1" selected>Irekita (gehitu daiteke, agerian)</option>
<option value="2" >Itxita (ezin gehitu, agerian)</option>
</select>
</td>
</tr>
<tr>
<td align="left" valign="top" class="list-header">
<div class="form-label">Egoera</div>
</td>
<td align="left" valign="top">
<select name="moderated:int">
<option value="0" >Itxita</option>
<option value="1" selected>Irekita</option>
</select>
</td>
</tr>
<tr>
<td align="left" valign="top" class="list-header">
<div class="form-optional">Argazkia</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 helbidea(k)</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 />Bidali trackback eskaera(k) orain
</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="Artikulua gehitu" />
</div>
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
<dtml-var blog_footer>
Metodo honek "manage_addEntry2" izeneko beste bati deitzen dio, honek hainbat gauza egin ditzan (irudia gehitu irudien karpetan, sarreraren hasieran lerro bat gehitu irudia sartzeko, aurrebista erakutsi) COREBlog-en jatorrizko "manage_addEntry" metodoari deitu aurretik. Hau da "manage_addEntry2" metodoaren edukia:
<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','<img src="./images/img_'+_.str(imgnumber)+'" border="0"><br>\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,'<','<'),'>','>'),'"',_.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,'<','<'),'>','>'),_.chr(34),'"')">">
<input type="hidden" name="extend" value="<dtml-var "_.string.replace(_.string.replace(_.string.replace(extend,'<','<'),'>','>'),_.chr(34),'"')">">
<input type="hidden" name="excerpt" value="<dtml-var "_.string.replace(_.string.replace(_.string.replace(excerpt,'<','<'),'>','>'),_.chr(34),'"')">">
<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>
Gero "objecttype" izeneko python script bat gehitu behar da, "object" izeneko parametroa hartzen duena eta eduki hau duena:
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'
Bukatzeko, baimen batzuk aldatu behar dira. "Manager" eta "owner" erabiltzaileei "View" baimena emango diegu hasieran aipatutako "addEntryForm" formularioan, eta "Add COREBlog entries" eta "Add documents, images and files" COREBlog objektuan.
Eta kitto! Orain kolaboratzaile berri bati artikuluak gehitzeko aukera eman nahi diogun bakoitzean, "acl_users" karpetan erabiltzaile berri bat gehituko dugu, "owner" motakoa. Hauek beren pasahitzarekin "addEntryForm" formularioa erabil dezakete artikuluak gehitzeko, hasieran irudi bat ere sartzeko aukerarekin, baina ezin dituzte kudeaketako beste pantailak ikusi.
Bi limitazio ditu oraingoz: gehitutako artikuluak testu egituratua formatuan egon behar dira eta ezin da EPOZ edizio zerbitzua erabili.
Aurreko artikuluak: