Skip to content

Commit

Permalink
Added link to rebuild_cache. Better relations listing.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed May 27, 2011
1 parent 6e1a820 commit b88f8fb
Show file tree
Hide file tree
Showing 32 changed files with 682 additions and 614 deletions.
2 changes: 2 additions & 0 deletions app/controllers/columns_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ def update
respond_to do |format|
if @column.update_attributes(params[:column])
flash.now[:notice] = _('Column was successfully updated.')
format.js
format.html { redirect_to(@column) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.js
format.xml { render :xml => @column.errors, :status => :unprocessable_entity }
end
end
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/relations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ class RelationsController < ApplicationController

def index
secure(Relation) do
@relations = Relation.paginate(:all, :order => 'source_role', :per_page => 20, :page => params[:page])
@relations = Relation.paginate(:all, :order => 'source_kpath', :per_page => 20, :page => params[:page])
end

@relation = Relation.new
respond_to do |format|
format.html # index.erb
Expand Down
11 changes: 7 additions & 4 deletions app/controllers/sites_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ def update
end
end

def clear_cache
@site.clear_cache

@clear_cache_message = _("Cache cleared.")
def action
if Site::ACTIONS.include?(params[:do])
@site.send(params[:do])
flash.now[:notice] = _("#{params[:do]} done.")
else
flash.now[:error] = _("Invalid action '%{action}'.") % {:action => params[:do]}
end
end

protected
Expand Down
5 changes: 5 additions & 0 deletions app/helpers/relations_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module RelationsHelper
def show_dir
@show_dir || params[:dir]
end
end
1 change: 1 addition & 0 deletions app/models/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
+default_lang+:: The default language of the site.
=end
class Site < ActiveRecord::Base
ACTIONS = %w{clear_cache rebuild_index}
include RubyLess
safe_method :host => String, :lang_list => [String]
safe_context :root => {:class => 'Node', :method => 'root_node'}
Expand Down
7 changes: 4 additions & 3 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def self.node_user_proc
:to_publish => ['Version'], :redactions => ['Version'], :proposed => ['Version'],
:comments_to_publish => ['Comment']

attr_accessible :login, :lang, :node, :time_zone, :status, :group_ids, :site_ids, :crypted_password, :password, :dev_skin_id
attr_accessible :login, :lang, :node, :time_zone, :status, :group_ids, :site_ids, :crypted_password, :password, :dev_skin_id, :node_attributes
attr_accessor :visited_node_ids
attr_accessor :ip

Expand Down Expand Up @@ -188,6 +188,8 @@ def prototype_attributes
def node_attributes=(node_attrs)
if self[:node_id]
@node = secure!(Node) { node_without_secure }
elsif !node_attrs[:id].blank?
@node = secure!(Node) { Node.find_node_by_pseudo(node_attrs.delete(:id)) }
else
@node = secure(Node) { Node.new_node(prototype_attributes) }
end
Expand Down Expand Up @@ -316,7 +318,6 @@ def user_site

def create_node
return unless visitor.site[:root_id] # do not try to create a node if the root node is not created yet

@node.version.status = Zena::Status[:pub]

unless @node.save
Expand All @@ -328,7 +329,7 @@ def create_node
raise Zena::InvalidRecord, "Could not publish contact node for user #{user_id} in site #{site_id} (#{@node.errors.map{|k,v| [k,v]}.join(', ')})"
end

self[:node_id] = @node[:id]
self.node_id = @node.id
end

# Set user defaults.
Expand Down
2 changes: 1 addition & 1 deletion app/models/virtual_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class << self
attr_accessor :export_attributes
end

self.export_attributes = %w{auto_create_discussion}
self.export_attributes = %w{auto_create_discussion icon}

attr_accessor :import_result
belongs_to :create_group, :class_name => 'Group', :foreign_key => 'create_group_id'
Expand Down
2 changes: 1 addition & 1 deletion app/views/relations/_form.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<td class="adm_icon">
<%= unless @relation.new_record?
link_to_remote _('btn_x'), :url => relation_path(@relation), :method => :get
link_to_remote _('btn_x'), :url => relation_path(@relation, :dir => params[:dir]), :method => :get
else
link_to_function _('btn_x'), "['add_relation', 'add_relation_form'].each(Element.toggle)"
end %>
Expand Down
14 changes: 9 additions & 5 deletions app/views/relations/_li.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<tr id='relation<%= li[:id] %>'>
<tr id='relation<%= li[:id] %><%= show_dir %>'>
<td class="dark"><%= link_to_remote(_('edit'),
:update =>"relation#{li[:id]}",
:url => edit_relation_path(li),
:update =>"relation#{li[:id]}#{show_dir}",
:url => edit_relation_path(li, :dir => show_dir),
:method => :get) %></td>
<td class="ruby relation" colspan='7'>
<span class='constant min_width'><%= VirtualClass.find_by_kpath(li.source_kpath) %></span> <span class='arity'><%= li.target_unique? ? _('has_one') : _('has_many') %></span> <span class='string'>'<%= li.target_role %>'</span>, <span class='symbol'>:class</span> => <span class='constant'><%= VirtualClass.find_by_kpath(li.target_kpath).to_s %></span><br/>
<span class='constant min_width'><%= VirtualClass.find_by_kpath(li.target_kpath) %></span> <span class='arity'><%= li.source_unique? ? _('has_one') : _('has_many') %></span> <span class='string'>'<%= li.source_role %>'</span>, <span class='symbol'>:class</span> => <span class='constant'><%= VirtualClass.find_by_kpath(li.source_kpath).to_s %></span><br/>
<% if show_dir == 'src' -%>
<span class='constant min_width'>
<%= VirtualClass.find_by_kpath(li.source_kpath) %></span> <span class='arity'><%= li.target_unique? ? _('has_one') : _('has_many') %></span> <span class='string'>'<%= li.target_role %>'</span>, <span class='symbol'>:class</span> => <span class='constant'><%= VirtualClass.find_by_kpath(li.target_kpath).to_s %></span>
<% else -%>
<span class='constant min_width'><%= VirtualClass.find_by_kpath(li.target_kpath) %></span> <span class='arity'><%= li.source_unique? ? _('has_one') : _('has_many') %></span> <span class='string'>'<%= li.source_role %>'</span>, <span class='symbol'>:class</span> => <span class='constant'><%= VirtualClass.find_by_kpath(li.source_kpath).to_s %></span><br/>
<% end -%>
</td>
</tr>
4 changes: 3 additions & 1 deletion app/views/relations/index.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<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 %>
<%= @show_dir = 'src';render :partial=>'relations/li', :collection=>@relations %>
<tr><th class='nav' colspan='9'><%= _('reverse relation') %></th></tr>
<%= @show_dir = 'trg';render :partial=>'relations/li', :collection=>@relations.sort{|a,b| a.target_kpath <=> b.target_kpath} %>
<%= render :partial=>'relations/add' %>
</table>
2 changes: 1 addition & 1 deletion app/views/relations/show.rjs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
page.replace "relation#{@relation[:id]}", :partial=>'relations/li', :collection=>[@relation]
page.replace "relation#{@relation[:id]}#{show_dir}", :partial=>'relations/li', :collection=>[@relation]
9 changes: 7 additions & 2 deletions app/views/relations/update.rjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
if @relation.errors.empty?
page.replace "relation#{@relation[:id]}", :partial=>"relations/li", :collection=>[@relation]
@show_dir = 'src'
page.replace "relation#{@relation[:id]}src", :partial=>"relations/li", :collection=>[@relation]
@show_dir = 'trg'
page.replace "relation#{@relation[:id]}trg", :partial=>"relations/li", :collection=>[@relation]
page.visual_effect :highlight, "relation#{@relation[:id]}src", :duration => 2.5
page.visual_effect :highlight, "relation#{@relation[:id]}trg", :duration => 2.5
else
page.replace "relation#{@relation[:id]}", :partial=>"relations/form"
page.replace "relation#{@relation[:id]}#{show_dir}", :partial=>"relations/form"
end
8 changes: 6 additions & 2 deletions app/views/sites/_form.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@
<% end -%>
</td></tr>
<% if !@site.new_record? %>
<tr><td class='label'><%= _('clear cache') %></td><td id='clear_site<%= @site[:id] %>'>
<%= link_to_remote _('clear cache'), :url => clear_cache_site_path(@site), :confirm => _('Are you sure you want destroy all cache (site may be slow during first reloads) ?') %>
<tr><td class='label'><%= _('action') %></td><td id='messages<%= @site[:id] %>'>
<ul>
<% Site::ACTIONS.each do |action| %>
<li><%= link_to_remote _(action), :url => action_site_path(@site, :do => action), :method => 'put' %></li>
<% end %>
</ul>
</td></tr>
<% end %>
<tr><td colspan='2'><p class='btn_validate'><input type='submit' value='<%= _('validate') %>'/></p></td></tr>
Expand Down
2 changes: 2 additions & 0 deletions app/views/sites/action.rjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
page.replace_html "messages#{@site[:id]}", :inline => flash_messages
page.visual_effect :highlight, "messages#{@site[:id]}", :duration => 1.5
2 changes: 0 additions & 2 deletions app/views/sites/clear_cache.rjs

This file was deleted.

9 changes: 4 additions & 5 deletions app/views/versions/custom_tab.rhtml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<% @node.schema.columns.each do |col_name, col| -%>
<% next if %w{title text summary}.include?(col_name) || !@node.safe_method_type([col_name]) -%>
<label for='<%= col_name %>'><%= _(col_name) %></label>
<% @node.vclass.safe_columns.each do |col| -%>
<label for='<%= col.name %>'><%= _(col.name) %></label>
<% case col.ptype
when :datetime %>
<%= date_box(@node, col_name, :size=>15) %>
<%= date_box(@node, col.name, :size=>15, :value => @node.prop[col.name]) %>
<% else %>
<%= text_area 'node', col_name, :cols => nil, :rows => 1, :value => @node.prop[col_name], :class => 'full_width' %>
<%= text_area 'node', col.name, :cols => nil, :rows => 1, :value => @node.prop[col.name], :class => 'full_width' %>
<% end %>
<% end -%>
14 changes: 7 additions & 7 deletions app/views/virtual_classes/_li.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
<td class='ruby'><span class='spacer'><%= li.kpath[1..-1].gsub(/./, '| ') + '+ ' %></span><span class='constant'><%= li.name %></span></td>
<td class='info'>&nbsp;</td>
</tr>
<% else -%>
<% else
link_def = {
:update => "virtual_class#{li[:id]}",
:url => edit_virtual_class_path(li),
:method => :get} -%>
<tr id='virtual_class<%= li[:id] %>'>
<td class="adm_icon"><%= (li.new_record? || !li.errors.empty?) ? _('virtual_class_error_img') : link_to_remote( !li.icon.blank? ? "<img src='#{li.icon}'/>" : _('virtual_class_img'),
{ :update => "virtual_class#{li[:id]}",
:url => edit_virtual_class_path(li),
:method => :get},
{ :title => li.kpath}) %></td>
<td class="adm_icon"><%= (li.new_record? || !li.errors.empty?) ? _('virtual_class_error_img') : link_to_remote( !li.icon.blank? ? "<img src='#{li.icon}'/>" : _('virtual_class_img'), link_def, { :title => li.kpath}) %></td>
<% if li.kind_of?(VirtualClass) -%>
<td class='ruby'>
<span class='spacer'><%= li.kpath[1..-1].gsub(/./, '| ') %>+ </span>
<span class='constant'><%= li.name %><%= li.import_result ? " (#{li.import_result})" : ''%></span>
<span class='constant'><%= link_to_remote(li.name, link_def) %><%= li.import_result ? " (#{li.import_result})" : ''%></span>
</td>
<td class='info'>
<%= (
Expand Down
6 changes: 4 additions & 2 deletions bricks/captcha/lib/bricks/captcha.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ def r_captcha
end

def r_mail_hide
text = get_text_for_erb
"<%= visitor.is_anon? ? mail_hide(#{text},:mh_pub => #{visitor.site.prop['mail_hide_pub'].inspect}, :mh_priv => #{visitor.site.prop['mail_hide_priv'].inspect}#{get_recaptcha_params}) : #{text} %>"
if code = get_attribute_or_eval
return parser_error("Argument to mail_hide should be a String (found #{code.klass}).") unless code.klass <= String
"<%= visitor.is_anon? ? mail_hide(#{code},:mh_pub => #{visitor.site.prop['mail_hide_pub'].inspect}, :mh_priv => #{visitor.site.prop['mail_hide_priv'].inspect}#{get_recaptcha_params}) : #{code} %>"
end
end

def get_recaptcha_params
Expand Down
14 changes: 10 additions & 4 deletions lib/gettext_strings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,22 @@ def CustomGettext
N_('rebuild') # zafu_templates.rb
N_('rebuild_btn') # zafu_templates.rb
N_('turn_dev_off_btn') # zafu_templates.rb
# contact
# contact: FIXME remove ?
N_('first_name')
N_('name')
N_('last_name')
N_('address')
N_('zip')
N_('city')
N_('postal_code')
N_('locality')
N_('country')
N_('telephone')
N_('mobile')
N_('email')
N_('birthday')

# Site actions
N_('clear_cache')
N_('clear_cache done.')
N_('rebuild_index')
N_('rebuild_index done.')
end
end
3 changes: 1 addition & 2 deletions lib/zena/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def zen_routes

resources :columns

resources :sites,
:member => { :clear_cache => :post }
resources :sites, :member => { :action => :put }

resources :comments,
:collection => { :empty_bin => :delete },
Expand Down
2 changes: 1 addition & 1 deletion lib/zena/use/display.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def generic_img_tag(obj, opts)
end

if obj.vclass.kind_of?(VirtualClass) && !obj.vclass.icon.blank?
# FIXME: we could use a 'zip' to an image as 'icon' (but we would need some caching to avoid multiple loading during doc listing)
# TODO: we could use a 'zip' to an image as 'icon' (but we would need some caching to avoid multiple loading during doc listing)
res[:src] = obj.vclass.icon
res[:alt] = opts[:alt] || (_('%{type} node') % {:type => obj.vclass.name})
res[:class] ||= obj.klass
Expand Down
Binary file modified locale/de/LC_MESSAGES/zena.mo
Binary file not shown.

0 comments on commit b88f8fb

Please sign in to comment.