Skip to content

Commit

Permalink
Added basic admin mode for site.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed May 16, 2011
1 parent ad92096 commit 4168178
Show file tree
Hide file tree
Showing 26 changed files with 404 additions and 87 deletions.
2 changes: 1 addition & 1 deletion app/views/columns/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h2 class='title'><%= _('manage properties') %></h2>
<h2 class='title'><%= _('properties') %></h2>

<table id='column_list' class='admin' cellspacing="0">
<tr><th class='nav' colspan='7'><%= will_paginate @columns %></th></tr>
Expand Down
2 changes: 1 addition & 1 deletion app/views/comments/index.rhtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h2 class='title'><%= _('manage comments') %></h2>
<h2 class='title'><%= _('comments') %></h2>
<div id='comment_errors'></div>

<%= will_paginate @comments %>
Expand Down
11 changes: 5 additions & 6 deletions app/views/documents/_crop.rhtml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<%= link_to_function(_('cancel'), "['crop', 'crop_form'].each(Element.toggle);$('crop_form').innerHTML = '';")%>
<ul class='infos' id='crop_options'>
<ul class='crop_options'>
<li>x: <input type='text' id='posx' name='node[crop][x]' size='4'/> y: <input type='text' id='posy' name='node[crop][y]' size='4'/> // w: <input type='text' id='width' name='node[crop][w]' size='4'/> h: <input type='text' id='height' name='node[crop][h]' size='4'/></li>
<li><b><%= _('convert') + '</b> ' + crop_formats(@node).join(' ') %></li>
<li><b><%= _('max size') %></b> <input type='text' name='node[crop][max_value]' size='4' value='<%= fs = fsize(@node.size); fs.to_f %>'/>
<li><b><%= _('convert') + '</b> ' + crop_formats(node).join(' ') %></li>
<li><b><%= _('max size') %></b> <input type='text' name='node[crop][max_value]' size='4' value='<%= fs = fsize(node.size); fs.to_f %>'/>
<%= ['Kb', 'Mb'].inject('') {|r,e| r + "<input type='radio' name='node[crop][max_unit]' value='#{e}'#{fs =~ /#{e}/ ? " checked='checked'" : ''}/> #{e} " }%>
</li>
</ul>
<p class='edit_info'><%= _('original') %> <%= @node.width %>x<%= @node.height %>, <%= _('original is #X this view').sub('#X', "<b>#{sprintf('%.1f', @node.width.to_f / @node.width(Iformat['edit']))}x</b>")%></p>
<%= img_tag(@node, :mode=>'edit', :id=>'edit_img') %>
<p class='edit_info'><%= _('original') %> <%= node.width %>x<%= node.height %>, <%= _('original is #X this view').sub('#X', "<b>#{sprintf('%.1f', node.width.to_f / node.width(Iformat['edit']))}x</b>")%></p>
<%= img_tag(node, :mode=>'edit', :id=>img_id) %>
5 changes: 3 additions & 2 deletions app/views/documents/crop_form.rjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
page.replace_html 'crop_form', :partial=>'documents/crop'
page.replace_html 'crop_form', :partial=>'documents/crop', :locals => {:node => @node, :img_id => 'edit_img'}
page.insert_html :top, 'crop_form', :inline => %Q{<%= link_to_function(_('cancel'), "['crop', 'crop_form'].each(Element.toggle);$('crop_form').innerHTML = '';")%>}
page.toggle 'crop_form', 'crop'
page << "new Zena.Div_editor('edit_img', 'posx', 'posy', 'width', 'height', #{@node.width / @node.width(Iformat['edit']).to_f}, 20, 220);"
page << "new Zena.Div_editor('edit_img', 'posx', 'posy', 'width', 'height', #{@node.width / @node.width(Iformat['edit']).to_f});"
page << "self.resizeTo(520,770);"
2 changes: 1 addition & 1 deletion app/views/groups/index.rhtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h2 class='title'><%= _('manage groups') %></h2>
<h2 class='title'><%= _('groups') %></h2>
<table class="admin" cellspacing="0">
<tr><th class='nav' colspan='3'><%= will_paginate @groups %></th></tr>
<%= render :partial=>'groups/li', :collection=>@groups %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/iformats/index.rhtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h2 class='title'><%= _('manage image formats') %></h2>
<h2 class='title'><%= _('image formats') %></h2>

<table id='iformat_list' class='admin' cellspacing="0">
<tr><th class='nav' colspan='7'>&nbsp;</th></tr>
Expand Down
2 changes: 1 addition & 1 deletion app/views/relations/index.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h2 class='title'><%= _('manage relations') %></h2>
<h2 class='title'><%= _('relations') %></h2>
<table id='relation_list' class='admin' cellspacing="0">
<tr><th class='nav' colspan='9'><%= will_paginate @relations %></th></tr>
<%= render :partial=>'relations/li', :collection=>@relations %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/sites/index.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h2 class='title'><%= _('manage sites') %></h2>
<h2 class='title'><%= _('sites') %></h2>

<table id='site_list' class='admin' cellspacing="0">
<tr><th class='nav' colspan='10'><%= will_paginate @sites %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/templates/edit_tabs/_image.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<label for="crop_x"><%= _("image") %></label>
<div id="crop" class='toggle_div'>
<div class='img_left'><%= link_to_remote(img_tag(@node,:mode=>'pv'), :url => crop_form_document_path(@node[:zip]), :method => :get) %></div>
<ul class='infos'>
<ul class='crop_options'>
<li><%= link_to_remote(_("crop/resize"), :url => crop_form_document_path(@node[:zip]), :method => :get) %></li>
<li><%= _('original') %> <%= @node.width %>px / <%= @node.height %>px</li>
<li><%= _('size') %> <%= fsize(@node.size) %></li>
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/index.rhtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h2 class='title'><%= _('manage users') %></h2>
<h2 class='title'><%= _('users') %></h2>

<table id='user_list' class='admin' cellspacing="0">
<tr><th class='nav' colspan='5'><%= will_paginate @users %></th></tr>
Expand Down
4 changes: 2 additions & 2 deletions app/views/users/preferences.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h3><%= @user.login %> : <%= _('preferences') %> </h3>
<h2 class='title'><%= @user.login %> : <%= _('preferences') %> </h2>

<ul class='actions' id='preferences'>
<ul class='actions admin_group' id='preferences'>

<li>
<div id='user_info'>
Expand Down
2 changes: 1 addition & 1 deletion app/views/virtual_classes/index.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h2 class='title'><%= _('manage classes') %></h2>
<h2 class='title'><%= _('classes') %></h2>

<%= flash_messages %>

Expand Down
13 changes: 1 addition & 12 deletions db/init/base/skins/default/Node-+adminLayout.zafu
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
<r:include template='Node'>
<r:with part='stylesheets'>
<r:stylesheets list='reset,zena,comment,admin,code,search,window'/>
<link href="style.css" rel="Stylesheet" type="text/css"/>
</r:with>

<r:with part='context'>
<ol class='admin_links' do='admin_links'>
<li do='each' do='show'><a href='#'>do this</a></li>
</ol>
</r:with>
<r:with part='title'/>
<r:include template='Node-admin'>
<r:with part='content' do='content_for_layout'>
<r:include template='Node' part='title'/>
<div id='related' do='visitor'>
Expand Down
186 changes: 186 additions & 0 deletions db/init/base/skins/default/Node-admin.zafu
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns='http://www.w3.org/1999/xhtml' lang='#{v.lang}' xml:lang='en' do='load' dictionary='translations'>
<head do='void' name='head'>
<title do='title_for_layout' do='show' attr='title' name='page_title'>page title</title>
<!-- link href='favicon.png' rel='shortcut icon' type='image/png' / -->
<meta http-equiv='Content-type' content='text/html; charset=utf-8' />
<r:void name='stylesheets'>
<r:stylesheets/>
<r:stylesheets list='admin'/>
<link href='img/admin.css' rel='Stylesheet' type='text/css'/>
</r:void>

<r:javascripts/>
<r:uses_datebox/>
</head>
<body>
<h1 id='logo' do='link' href='root' mode='admin' do='t'>admin_interface</h1>
<div id='container'>
<div id='navigation'>
<ul id='menu' do='admin_links'>
<li do='each' do='show'>x</li>
</ul>
</div>

<div id='content'>
<h1 id='title'><r:title/> <span class='klass'>(<r:klass/>)</span></h1>
<div id='preview'>
<h2 class='preview' do='link' do='t'>view_live</h2>
<r:Image?>
<table class='med_prev'><tr><td do='link' update='crop' crop='true'>
<r:img mode='med'/>
<span class='crop'>
<img src='/images/cut_red.png' title='#{t("crop")}'/>
</span>
</td></tr></table>
<r:else do='zazen' attr='text' live='true' code='#{content_lang}'/>
</r:Image?>
</div>

<div id='form' do='form'>
<r:if test='can_edit?'>
<label do='t("edit #{klass}")'/>
<r:Image?>
<div id='crop' do='block' do='if' test='params[:crop]'>
<p do='else'>
<r:void actions='edit'/>
<r:link update='crop' crop='true'>
<img src='/images/cut_red.png'/> <r:t>crop</r:t>
</r:link>
</p>
<p do='link' id='crop_x' update='crop'><r:t>btn_x</r:t> <r:t>cancel</r:t></p>
<!-- JS trigger must run effect before crop editor -->
<r:js>$$('#crop>div').each(function(o) { new Effect.Appear(o, {duration:0.5}) });</r:js>
<div class='mask' style='display:none;'>&nbsp;</div>
<!--div class='wrap' style='display:none;' onclick='$("crop_x").onclick();'>
<div class='win' onclick='Event.stop(event);return false;' -->

<div class='wrap' style='display:none;'>
<div class='win'>
<p class='btn'>
<p class='backup'><input name='node[v_backup]' type='checkbox' value='true' checked='checked'/><r:t>backup</r:t></p>
<input type='submit' value='#{t("crop")}'/>
<p do='link' update='crop' do='t'>btn_x</p>
</p>
<div class='crop_ed' do='crop'/>
</div>
</div>
</div>
<r:else>
<p do='void' actions='edit'/>
</r:else>
</r:Image?>
</r:if>
<r:if test='can_publish?'>
<label do='t("publish #{klass}")'/>
<p do='void' actions='publish'/>
</r:if>
<r:if test='can_drive?'>
<label do='t("move/manage versions")'/>
<p do='void' actions='drive'/>
</r:if>
<r:if test='can_edit?' do='default' label='t'>
<input type='hidden' name='redir' value='#{path(this, :mode =&gt; "admin")}'/>
<r:input name='title'/>
<r:input name='keywords'/>
<r:textarea name='summary'/>
<r:textarea name='text'/>

<r:vclass do='columns' do='each'>
<r:if test='name != "title" and name != "summary" and name != "keywords" and name != "text"'>
<r:textarea/>
</r:if>
</r:vclass>

<r:input type='submit'/>
</r:if>
</div> <!-- form -->

<div id='browser'>
<div class='wrap'>
<div id='parents'>
<div class='search' do='filter' live='true'>
<input type='text' name='f'/>
<r:select param='k' root_class='Node' attr='kpath'/>
</div>
<div id='par_list' do='block' do='children where kpath like "#{params[:k]}%" and title like "%#{params[:f]}%" from parent from parent limit 30 paginate p' set_ref='parent'>
<div class='pages'><r:t>page</r:t>: <r:link page='list' page_count='6' update='par_list' encode_params='f'/> (<r:count/> <r:t>records</r:t>)</div>
<ul>
<li do='each' alt_class='stripe' on_if='id == ref.id' name='elem'>
<r:Image?>
<r:img mode='tipop'/>
<r:else>
<img src='#{vclass.icon || "/images/brick.png"}'/>
</r:else>
</r:Image?>
<r:link mode='admin'>
<span class='id' do='id'/>
<r:Document?>
<r:show text='#{title.limit(14)}.#{ext}'/>
<r:else do='title.limit(23)'/>
</r:Document?>
</r:link>
</li>
</ul>
<r:else do='parent'>
<!-- no grand-parent -->
<div class='pages'><r:if test='!parent_id'><r:t>root_node</r:t><r:else do='t'>not_found</r:else></r:if></div>
<ul>
<r:include template='Node-admin' part='elem' method='void'/>
</ul>
<r:else><!-- no parent -->
<div class='pages' do='t'>no_parent</div>
<ul>
</ul>
</r:else>
</r:else>
</div>
</div> <!-- #parents -->
<div id='siblings'>
<div class='search' do='filter' live='true'>
<input type='text' name='f'/>
<r:select param='k' root_class='Node' attr='kpath'/>
</div>
<div id='sib_list' do='block' do='children where kpath like "#{params[:k]}%" and title like "%#{params[:f]}%" from parent limit 30 paginate p' set_ref='this'>
<div class='pages'><r:t>page</r:t>: <r:link page='list' page_count='6' update='sib_list' encode_params='f'/> (<r:count/> <r:t>records</r:t>)</div>
<ul>
<r:include template='Node-admin' part='elem' method='void'/>
</ul>
<r:else>
<!-- no parent, just show self -->
<div class='pages'><r:if test='!parent_id'><r:t>root_node</r:t><r:else do='t'>not_found</r:else></r:if></div>
<ul>
<r:include template='Node-admin' part='elem' method='void'/>
</ul>
</r:else>
</div>
</div> <!-- #siblings -->
<div id='children'>
<div class='search' do='filter' live='true'>
<input type='text' name='f'/>
<r:select param='k' root_class='Node' attr='kpath'/>
</div>
<div id='ch_list' do='block' do='children where kpath like "#{params[:k]}%" and title like "%#{params[:f]}%" limit 30 paginate p'>
<div class='pages'><r:t>page</r:t>: <r:link page='list' page_count='6' update='ch_list' encode_params='f'/> (<r:count/> <r:t>records</r:t>)</div>
<ul>
<r:each set_ref='main' do='include' template='Node-admin' part='elem' method='void'/>
<li class='add' do='add' do='t'>add_object</li>
<li class='add_doc' do='add_document' do='t'>upload_document</li>
<li do='form'><r:select name='klass' root_class='Node'/> <r:input name='title'/> <r:input type='submit'/></li>
</ul>
</div>
</div> <!-- #children -->

<r:js>
// TODO: scroll only in browser DIV
// $$('#browser .on').each(function(o) {
// o.scrollIntoView(true);
// });
</r:js>
</div> <!-- .wrap -->
</div> <!-- #browser -->
</div> <!-- content -->
</div>
</body>
</html>
4 changes: 2 additions & 2 deletions db/init/base/skins/default/Node.zafu
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<r:void name='stylesheets'>
<r:stylesheets media='all'/>
<link href="style.css" rel="Stylesheet" type="text/css"/>
<link href="img/style.css" rel="Stylesheet" type="text/css"/>
</r:void>

<r:javascripts/>
Expand All @@ -18,7 +18,7 @@
<div id='top' do='root' do='link'/>
<div id='header'>
<div id='login' do='login_link'/>
<div id='visitor' do='visitor_link'/>
<div id='visitor'><r:visitor_link/> <r:if test='can_edit?' do='link' mode='admin' do='t'>btn_edit</r:if></div>
<div id='search' do='search_box' type='search'/>
<ol id='menu' do='root' do='pages'>
<li do='each' on_if='is_ancestor?(main)' do='link'/>
Expand Down
57 changes: 57 additions & 0 deletions db/init/base/skins/default/img/admin.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
body {font-family:Verdana, sans-serif; font-size:12px; line-height:18px; background:#555}
a {text-decoration:none; color:inherit; }

#logo {font-size:21px; font-weight:bold; color:#333; text-shadow: 0 1px 0 #777;}
#container { border:1px solid black; background:#eee; margin:3em auto;}
#logo, #container {width:800px; display:table; margin:1em auto;}

#menu li {float:left;}
#menu li a { padding:4px; border:1px solid #333; border-width:0 1px 1px 0; display:block;}
#menu li a.on { background:#f7d493;}

#content {clear:both; padding-top:1px;}
#content h2.title {margin:20px; color:black; font-weight:bold; font-size:18px;}
#content table.admin {margin-bottom:2em;}

#browser {background:#333; padding:4em 0 2em;}
#browser .wrap {display:table; margin:0 auto;}
#browser .wrap>div {float:left; border:1px solid #444; width:200px; background:#444;}
#browser div ul {height:200px; overflow:auto;}
#browser li, #browser div .pages {border-bottom:1px solid #444; background:#eee}
#browser li img {float:left; margin:3px;}
#browser div .pages a { color:#7cf; padding:0 3px;}
#browser div .pages { background:#777; color:#bbb;}
#browser li.on { background:#aaa;}
#browser a:hover { background:#f4ecc1; color:black;}
#browser .pages, #browser li a {display:block; height:22px; padding:2px;}
#siblings li.on {background:#f7d493;}
#children .btn_add a { visibility:visible;}
#children .add { background:#82a0ae; color:#eee;}
#children .add_doc { background:#aea782; color:#eee;}
#browser .wrap>div {position:relative;}
#browser .search {position:absolute; top:-27px; background:#ddd; padding:2px;}
.search input, .search select {float:left; width:45%; margin-right:4px;}
#browser .id {float:right; color:#999; font-size:9px;}

#preview {border:4px dashed #ccc; width:450px; margin:1em; float:right; position:relative;}
#preview .zazen {height:220px; overflow:auto; padding:10px; }
h2.preview {position:absolute; top:7px; right:-4px;}
h2.preview a { background:#ccc; padding:0.5em; font-size:18px; font-weight:bold;}
h2.preview:hover a {background:#fbeab6;}
#preview .med_prev {background:#444; width:100%;}
#preview .crop { position:absolute; bottom:10px; right:10px; visibility:hidden; display:block;}
#preview:hover .crop { visibility:visible;}

.med_prev td {vertical-align:middle; text-align:center; height:240px;}
.med_prev .img {border:1px solid black;}
#title { font-size:21px; font-weight:bold; margin:18px; float:left;}
#title a, #form a {visibility:visible}
#title span {font-size:55%; color:#888;}

#form {clear:left; margin:18px; position:relative; width:300px;}
#form label { font-weight:bold; margin-top:1em; display:block; color:#999}
#crop .mask { position:fixed; top:0; left:0; width:100%; height:100%; background:black; opacity:0.8;}
#crop .wrap { position:absolute; top:-200px; left:180px; width:100%; height:100%;}
#crop .win { display:table; margin:80px auto; background:#999; padding:20px;}
#crop .crop_options {display:none;}
#crop .btn input {float:right}
Binary file added db/init/base/skins/default/img/favicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4168178

Please sign in to comment.