<fieldset metal:define-macro="course_right_box" 
                tal:define="mpk python:context.gf.isFreshObject(request);
                                unread_notes python:context.get_n_unread_notes(str(user));
                                unseen_jams python:context.total_n_unseen_jams(request);
                                quote context/getQuote;
                                logo context/getLogoTag;
                                global hasEntries context/Blog/getNumberOfEntries|nothing;
                                global right_box python:logo or quote or mpk or unread_notes or unseen_jams or hasEntries;"
				tal:omit-tag="not:right_box"
			tal:condition="right_box" style="width:25%;border:0px solid red;position:relative;float:right">
	<span metal:use-macro="container/blog_macro/macros/course_right_box_content" tal:omit-tag="" />	
	<br tal:condition="hasEntries" />
	<span metal:use-macro="container/blog_macro/macros/blog_right_box_content" tal:omit-tag="" />
</fieldset>

<span metal:define-macro="course_right_box_content" tal:omit-tag="">
		<table width="100%" bgcolor="#EEEEEE" tal:condition="python: logo or quote">
			<thead>
				<tr>
					<th><a href="" tal:attributes="href string:${kursus/absolute_url}/gf/course_info" tal:content="kursus/get_name"></a></th>
				</tr>
			</thead>
			<tbody>
				<tr tal:condition="logo">
					<td class="t1" style="text-align:center"><a href="" tal:attributes="href string:${kursus/absolute_url}/gf/course_info" tal:content="structure logo"></a></td>
				</tr>
				<tr tal:condition="quote">
					<td class="t1" style="text-align:center" tal:content="quote"></td>
				</tr>
			</tbody>
		</table>
		<br />
		<table width="100%" border="0" bgcolor="#EEEEEE" tal:condition="python:mpk or unread_notes or unseen_jams">
			<thead>
				<tr>
					<th i18n:translate="">new things</th>
				</tr>
			</thead>
			<tbody>
				<tr tal:condition="mpk">
					<td class="t1"><a href="gf/" i18n:translate="">Bookshelf</a></td>
				</tr>
				<tr tal:condition="unread_notes">
					<td class="t1">
						<a href="" tal:attributes="href string:${kursus/absolute_url}/course_html">
								<label tal:omit-tag="" i18n:translate="">Knowledge building has <label i18n:name="number" tal:replace="python:context.get_n_unread_notes(str(user))" /> unread messages!</label>
						</a>
					</td>
				</tr>
				<tr tal:condition="unseen_jams">
					<td class="t1"><a href="" tal:attributes="href string:${kursus/absolute_url}/jamming/jamming_index_html" i18n:translate="">Jamming has <label i18n:name="number" tal:content="python:context.total_n_unseen_jams(request)" /> unseen artefacts!</a></td>
				</tr>
			</tbody>
		</table>
</span>

<fieldset 
	metal:define-macro="blog_right_box" 
	tal:define="global hasEntries python:here.Blog.getNumberOfEntries()>0" 
	tal:condition="hasEntries" 
	style="width:25%;border:0px solid red;position:relative;float:right">
	
	<span metal:use-macro="container/blog_macro/macros/blog_right_box_content" tal:omit-tag="" />
	
</fieldset>

<span metal:define-macro="blog_right_box_content" tal:omit-tag="">
	<span metal:use-macro="container/blog_macro/macros/last_entries" tal:omit-tag="" />
	<br />
	<span metal:use-macro="container/blog_macro/macros/entries_archive" tal:omit-tag="" />
</span>

<span metal:define-macro="blog_box" tal:omit-tag="">
	<span tal:define="global fstyle string:width:90%;;border:0px solid red" tal:omit-tag="" />
	<span tal:condition="hasEntries" tal:omit-tag="">
		<span tal:define="global fstyle string:width:65%;;border:0px solid red" tal:omit-tag="" />
	</span>
	<fieldset style="" tal:attributes="style fstyle">
		<h2>
			<span i18n:translate="" tal:omit-tag="">Blog</span>
			<span tal:replace="structure python:': '+here.firstAndLast(here.kasutajaNimi(request))" />
			<span tal:condition="python:kursus and userLocation!='Organizer'" i
			      tal:replace="python:' @ '+kursus.get_name()" />
		</h2>
		<span tal:omit-tag="" metal:define-slot="blog_page" />
	</fieldset>
</span>

<span metal:define-macro="course_box" tal:omit-tag="">
	<span tal:define="global fstyle string:width:90%;;border:0px solid red" />
	<span tal:condition="right_box">
		<span tal:define="global fstyle string:width:65%;;border:0px solid red" />
	</span>
	<fieldset style="" tal:attributes="style fstyle" tal:define="xyz python:request.set('wnested',1)">
		<span tal:omit-tag="" metal:define-slot="blog_page" />
	</fieldset>
</span>

<span metal:define-macro="last_entries" tal:omit-tag="" tal:condition="hasEntries">
		<table width="100%" bgcolor="#EEEEEE">
			<thead>
				<tr>
					<th i18n:translate="">Last entries</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td class="t1">
						<div style="margin-top:5px" tal:repeat="entry python:context.Blog.getEntries(5)">
						- <a href="" 
							title="" 
							tal:attributes="href python:entry.absolute_url()+'?userLocation='+userLocation;
									title python:entry.getFormattedTime(request)" tal:content="python:entry.getTitle()">
						</a>
						(<span tal:replace="entry/getNumberOfComments" />)
						</div>
					</td>
				</tr>
			</tbody>
		</table>
</span>

<span metal:define-macro="entries_archive" tal:omit-tag="" tal:condition="hasEntries">
		<table width="100%" bgcolor="#EEEEEE">
			<thead>
				<tr>
					<th i18n:translate="">Entries archive</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td class="t1">
						<span style="margin-top:5px" tal:repeat="arch python:here.Blog.getEntriesArchive(request)">
						- <a href="" title="" tal:attributes="href python:here.Blog.absolute_url()+'/blog_archive?month='+arch[0]+'&amp;userLocation='+userLocation"><span tal:content="python:arch[1]" i18n:translate="" tal:omit-tag="" /> <span tal:content="python:arch[2]" tal:omit-tag="" /></a><br />
						</span>
					</td>
				</tr>
			</tbody>
		</table><br />
		<a href="" target="_blank" tal:attributes="href string:${here/Blog/absolute_url}/rss"><img src="images/icon_rss" border="0" /></a>
</span>

<div metal:define-macro="add_entry_link" tal:condition="python:here.Blog.isOwner(request,user)">
	<table width="100%" border="0" cellpadding="2" cellspacing="0" bgcolor="#EEEEEE">
		<tr>
			<td width="30" align="center">
				<img src="images/kb_context" height="20" width="20" alt="Add new entry" i18n:attributes="alt" />
			</td>
			<td>
				<a href="" tal:attributes="href python:here.Blog.absolute_url()+'/blog_addEntryForm?userLocation='+userLocation" i18n:translate="">Add new entry</a>
			</td>
		</tr>
	</table>
</div>

<span metal:define-macro="add_entry_form" tal:condition="python:here.Blog.isOwner(request,user)" tal:omit-tag="">
	<h2 i18n:translate="">Add new entry</h2>
	<form method="post" action="addEntry"><!-- tal:attributes="action python:here.Blog.absolute_url()+'/addEntry'">-->
		<table>
			<tr>
				<td i18n:translate="">Title:</td>
				<td><input type="text" name="title" style="width:400px" /></td>
			</tr>
			<tr>
				<td i18n:translate="">Entry intro:</td>
				<td><textarea name="intro" rows="6" cols="45" style="width:400px;height:200px"></textarea></td>
			</tr>
			<tr>
				<td i18n:translate="">Entry content:</td>
				<td><textarea name="content" rows="12" cols="45" style="width:400px;height:200px"></textarea></td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td><input type="submit" value="Save entry" i18n:attributes="value" /></td>
			</tr>
		</table>
	<input tal:condition="userLocation" type="hidden" name="userLocation" value="" tal:attributes="value userLocation" /> 
	</form>
</span>

<span metal:define-macro="change_entry_form" tal:condition="python:here.isOwner(request,user)" tal:omit-tag="">
	<h2 i18n:translate="">Change entry</h2>
	<form method="post" action="changeEntry" tal:define="entry python:here">
		<table>
			<tr>
				<td i18n:translate="">Title:</td>
				<td><input type="text" name="title" style="width:400px" value="" tal:attributes="value python:entry.getTitle()" /></td>
			</tr>
			<tr>
				<td i18n:translate="">Entry intro:</td>
				<td><textarea name="intro" rows="6" cols="45" style="width:400px;height:200px" tal:content="python:entry.getIntro(False)"></textarea></td>
			</tr>
			<tr>
				<td i18n:translate="">Entry content:</td>
				<td><textarea name="content" rows="12" cols="45" style="width:400px;height:200px" tal:content="python:entry.getContent(False)"></textarea></td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td><input type="submit" value="Change entry" i18n:attributes="value" /></td>
			</tr>
		</table>
	<input tal:condition="userLocation" type="hidden" name="userLocation" value="" tal:attributes="value userLocation" /> 
	</form>
</span>
<span metal:define-macro="archive_entries_list" tal:omit-tag="">
	<h3 i18n:translate="">Entries archive</h3>
	<span tal:omit-tag="" tal:repeat="entry python:here.getArchiveEntries(request)">
		<span tal:omit-tag="" tal:content="python:entry.getFormattedTime(request)">23:00 01.02.2005</span> -
		<a href="" tal:attributes="href python:entry.absolute_url()+'?userLocation='+userLocation" tal:content="python:entry.getTitle()">Entry Title</a>
		(<span tal:omit-tag="" tal:content="entry/getNumberOfComments" />)<br />
	</span>
</span>

<span metal:define-macro="entries_list" tal:omit-tag="">
	<span tal:condition="not:hasEntries" i18n:translate="">No entries found!</span>
	<span tal:omit-tag="" tal:repeat="entry python:here.Blog.getEntries(20)">
		<a name="" tal:attributes="name entry/getID"></a>
		<div class="entry_title" style="border-bottom:1px dashed #000000;margin-top:30px;margin-bottom:10px">
			<table width="100%">
				<tr>
					<td><a href="" style="font-size:13pt;" tal:attributes="href python:entry.absolute_url()+'/blog_entry?userLocation='+userLocation" tal:content="entry/getTitle"></a></td>
					<td align="right" valign="bottom"><span tal:omit-tag="" i18n:translate="">Posted by</span> <b tal:content="structure python:entry.getAuthor(True)"></b><br /><span tal:content="python:entry.getFormattedTime(request)" tal:omit-tag="" /><br /><img src="images/transparent_gif" width="170" height="1" /></td>
				</tr>
			</table>
		</div>
		<div class="entry_intro" style="text-align:justify;" tal:content="structure python:entry.getIntro(True)"></div>
		<div class="entry_links" style="text-align:right;margin-top:5px;margin-bottom:25px;">
			<a href="" tal:attributes="href python:entry.absolute_url()+'/blog_entry?userLocation='+userLocation" i18n:translate="">Read more...</a> :
			<a href="" tal:attributes="href python:entry.absolute_url()+'/blog_entry?showComments=1&amp;userLocation='+userLocation+'#Comments'"><span tal:omit-tag="" i18n:translate="">Read comments</span> (<span tal:omit-tag="" tal:content="entry/getNumberOfComments">0</span>)</a>
		</div>
	</span>
</span>

<span metal:define-macro="entry" tal:define="entry python:here;comm exists:request/showComments" tal:omit-tag="">
	<a name="" tal:attributes="name entry/getID"></a>
	<div class="entry_title" style="border-bottom:1px dashed #000000;margin-top:20px;margin-bottom:10px">
		<table width="100%">
			<tr>
				<td><a href="" style="font-size:13pt;" tal:attributes="href python:entry.absolute_url()+'/blog_entry?userLocation='+userLocation" tal:content="entry/getTitle"></a></td>
				<td align="right" valign="bottom"><span tal:omit-tag="" i18n:translate="">Posted by</span> <b tal:content="structure python:entry.getAuthor(True)"></b><br /> <span tal:content="python:entry.getFormattedTime(request)" tal:omit-tag="" /><br /><img src="images/transparent_gif" width="170" height="1" /></td>
			</tr>
		</table>
	</div>

	<div class="entry_intro" style="text-align:justify;margin-bottom:20px;font-style:italic;" 
		tal:content="structure python:entry.getIntro(True)">
	</div>
	<div class="entry_content" style="text-align:justify" 
		tal:condition="not:comm" 
		tal:content="structure python:entry.getContent(True)">
	</div>
	<div class="entry_links" style="text-align:right;margin-top:5px;margin-bottom:25px;">
		<span tal:condition="python:entry.hasBeenChanged()" tal:omit-tag="">
			<span tal:omit-tag="" i18n:translate="">Last changed:</span>
			<span tal:replace="structure python:entry.getFormattedChangeTime(request)" /><br />
		</span>
		<a tal:condition="comm" 
			href="" 
			tal:attributes="href python:entry.absolute_url()+'/blog_entry?userLocation='+userLocation" 
			i18n:translate="">Read more...</a>
		<a tal:condition="not:comm" 
			href="" 
			tal:attributes="href python:entry.absolute_url()+'/blog_entry?showComments=1&amp;userLocation='+userLocation+'#Comments'">
			<span tal:omit-tag="" i18n:translate="">Read comments</span> 
			(<span tal:omit-tag="" tal:content="python:entry.getNumberOfComments()">0</span>)</a>
		<span tal:condition="python:here.isOwner(request,user)" tal:omit-tag="">:
			<a href="" 
				tal:attributes="href python:entry.absolute_url()+'/blog_changeEntryForm?userLocation='+userLocation" 
				i18n:translate="">Change entry</a>
		</span>
	</div>
	<a name="Comments"></a>
	<div tal:condition="comm" 
		tal:define="hasComments python:entry.getNumberOfComments()>0" 
		class="entry_comments" 
		style="">
		<span tal:condition="not:hasComments" 
			tal:omit-tag="" 
			i18n:translate="">No commets yet!</span>
		<a tal:repeat="a python:entry.getIntervals(request)" 
			href="" 
			tal:attributes="href python:entry.absolute_url()+'/blog_entry?showComments=1&amp;start='+str(a[1])+'&amp;count='+str(a[0])+'&amp;userLocation='+userLocation+'#Comments'" 
			tal:content="python:str(a[1])+'-'+str(a[2])">1-10</a>
		<div class="entry_comment" 
			style="margin-top:20px;margin-bottom:10px" 
			tal:repeat="comment python:entry.getComments(request)"
			>
			<a name="" tal:attributes="name comment/getID"></a>
			<b>
				<span tal:replace="structure python:comment.getAuthor(True)">John Smith</span>
			</b>, <span tal:replace="python:comment.getFormattedTime(request)">10:10 10.10.2010</span>
			<br />
			<i>
				<span tal:replace="python:comment.getTitle()">Comments title</span>
			</i>
			<br />
			<span tal:replace="structure python:comment.getContent(True)">Comments content</span>
		</div>
		<a tal:repeat="a python:entry.getIntervals(request)" 
			href="" 
			tal:attributes="href python:entry.absolute_url()+'/blog_entry?showComments=1&amp;start='+str(a[1])+'&amp;count='+str(a[0])+'&amp;userLocation='+userLocation+'#Comments'" 
			tal:content="python:str(a[1])+'-'+str(a[2])">1-10</a>
	</div>
	<a name="addCommentForm"></a>
	<div id="entry_comments" style="margin-top:20px">
		<form method="post" action="addComment">
			<table cellspacing="0" width="100%">
				<tr bgcolor="#EEEEEE">
					<td>&nbsp;</td>
					<td i18n:translate="">Add comment</td>
				</tr>
				<tr>
					<td i18n:translate="">Title:</td>
					<td><input type="text" name="title" style="width:400px" /></td>
				</tr>
				<tr>
					<td i18n:translate="">Comment:</td>
					<td><textarea name="content" rows="6" cols="45" class="width400"></textarea></td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td><input type="submit" value="Add comment" i18n:attributes="value" /></td>
				</tr>
			</table>
		<input tal:condition="userLocation" type="hidden" name="userLocation" value="" tal:attributes="value userLocation" />
		</form>
	</div>
</span>
