<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="wiki_master.html"/>
<?python
from pyforge.lib.security import has_artifact_access
?>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
<title>$page.title</title>
</head>
<body>
<h1 class="title">$page.title</h1>
<form method="POST" class="can-retry" action="update" id="page_edit_form">
<div class="span-3 clear"><label>Content:</label></div>
<div class="span-15 last" style="min-height:2em;">${c.markdown_editor.display(name='text',value=page.text)}</div>
<div class="span-3 clear"><label>Tags:</label></div>
<div class="editable viewing span-15 last" style="min-height:2em;">
<div class="viewer">
<span py:for="label in page.labels"><a href="../browse_tags">$label (${page.artifacts_labeled_with(label).count()})</a></span>
</div>
<div class="editor">${c.label_edit.display(name='labels', className="title", value=page.labels)}</div>
</div>
<py:if test="has_artifact_access('edit_page_permissions', page)()">
<div class="span-3 clear"><label>Viewable by:</label></div>
<div class="span-15 last">
<span py:for="j, u in enumerate(page.viewable_by)" class="removable">
${u}
<input type="hidden" name="viewable_by-${j}.id" value="$u"/>
</span>
</div>
</py:if>
<py:if test="has_artifact_access('edit_page_permissions', page)()">
<div class="span-3 clear"><label>Add Viewer:</label></div>
<div class="span-15 last">
${c.user_select.display(name='new_viewable_by', value='')}
</div>
</py:if>
<div class="push-3 span-15 last">
<input type="submit" value="Save Changes" class="ui-button ui-widget ui-state-default ui-button-text-only"/>
</div>
</form>
<hr class="clear clearfix" />
${c.attachment_list.display(attachments=list(page.attachments), edit_mode=has_artifact_access('edit', page)())}
<div py:if="has_artifact_access('edit', page)()" class="reply title-pane closed">
<button class="title">Add Attachment</button>
<div class="content">
<form id="attachment_form" method="post" action="${page.url() + 'attach'}" enctype="multipart/form-data">
${file_field('file_info', 'File to upload')}
${submit_button('Attach file')}
</form>
</div>
</div>
</body>
<script type="text/javascript">
/*<![CDATA[*/
$('span.removable').click(function(e){
var vals = $('#page_edit_form').serialize();
console.debug(vals)
var del_name = $('input', this)[0].name.replace('.id','.delete');
console.debug(del_name)
$.post($('#page_edit_form')[0].action, vals+'&'+del_name+'=Del', function(){
e.target.parentNode.removeChild(e.target);
});
});
/*]]>*/
</script>
</html>