Skip to content

Commit

Permalink
Fixed main_class for [project] method.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed May 12, 2011
1 parent aced143 commit ad92096
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 19 deletions.
5 changes: 2 additions & 3 deletions app/models/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ def self.author_proc
:data_b => {:class => ['DataEntry'], :zafu => {:data_root => 'node_b'}},
:data_c => {:class => ['DataEntry'], :zafu => {:data_root => 'node_c'}},
:data_d => {:class => ['DataEntry'], :zafu => {:data_root => 'node_d'}},
:traductions => ['Version'], :discussion => 'Discussion',
:project => 'Node'
:traductions => ['Version'], :discussion => 'Discussion'

# we use safe_method because the columns can be null, but the values are never null
safe_method :kpath => String, :user_zip => Number,
Expand Down Expand Up @@ -1746,7 +1745,7 @@ def change_klass
return
end
end

if @new_klass && !new_record?
old_kpath = self.kpath
# Reset 'schema' and 'virtual_class'
Expand Down
1 change: 1 addition & 0 deletions app/models/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def attributes_for_form
property.string 'usr_prototype_attributes'

Site.attributes_for_form[:text] << 'usr_prototype_attributes'
attr_accessible :usr_prototype_attributes

# Return path for static/cached content served by proxy: RAILS_ROOT/sites/_host_/public
# If you need to serve from another directory, we do not store the path into the sites table
Expand Down
6 changes: 0 additions & 6 deletions app/views/templates/edit_tabs/_title.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
<label for='v_lang'><%= _("language") %></label>
<%= select 'node', 'v_lang', current_site.lang_list.map {|l| [_(l), l]} %>

<% if @node.kind_of?(Note) -%>
<label for='log_at'><%= _("log date") %></label>
<%= date_box(@node, 'log_at')%>
<label for='event_at'><%= _("event date") %></label>
<%= date_box(@node, 'event_at')%>
<% end -%>
<label><%= _('publication date') %></label>
<%= date_box(@node, 'v_publish_from') %>
<label for="summary"><%= _("summary") %></label>
Expand Down
1 change: 1 addition & 0 deletions app/views/zafu/default/Node-+login.zafu
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ td { padding:5px; }
<body do='void' name='body'>
<div id='login_form'>
<p class='welcome' do='link'><r:t>Login for</r:t> <b do='title'/></p>
<r:flash_messages/>
<form action="/session" method="post"> <table>
<tr>
<td><label for='user_login' do='trans'>User name:</label></td>
Expand Down
1 change: 1 addition & 0 deletions db/init/base/skins/default/Node-+login.zafu
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ td { padding:5px; }
<body do='void' name='body'>
<div id='login_form'>
<p class='welcome' do='link'><r:t>Login for</r:t> <b do='title'/></p>
<r:flash_messages/>
<form action="/session" method="post"> <table>
<tr>
<td><label for='user_login' do='trans'>User name:</label></td>
Expand Down
1 change: 1 addition & 0 deletions lib/zena/acts/enrollable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def safe_method_type(signature, receiver = nil)
return nil
end
elsif klass
deb "Enrollable", klass
unless klass = Enrollable::Common.get_class(klass.to_s)
return nil
end
Expand Down
8 changes: 4 additions & 4 deletions lib/zena/use/dates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ def r_uses_datebox
l = visitor.site[:default_lang]
end
<<-EOL
<script src="/calendar/calendar.js" type="text/javascript"></script>
<script src="/calendar/calendar-setup.js" type="text/javascript"></script>
<script src="/calendar/lang/calendar-#{l}-utf8.js" type="text/javascript"></script>
<link href="/calendar/calendar-brown.css" media="screen" rel="Stylesheet" type="text/css" />
<script src="#{helper.send(:compute_public_path, 'calendar', 'calendar', 'js')}" type="text/javascript"></script>
<script src="#{helper.send(:compute_public_path, 'calendar-setup', 'calendar', 'js')}" type="text/javascript"></script>
<script src="#{helper.send(:compute_public_path, "calendar-#{l}-utf8", 'calendar/lang', 'js')}" type="text/javascript"></script>
<link href="#{helper.send(:compute_public_path, "calendar-brown", 'calendar', 'css')}" media="screen" rel="Stylesheet" type="text/css" />
<% js_data << %Q{Calendar._TT["DEF_DATE_FORMAT"] = "#{_('datetime')}";} -%>
<% js_data << %Q{Calendar._TT["FIRST_DAY"] = #{_('week_start_day')};} -%>
EOL
Expand Down
39 changes: 38 additions & 1 deletion lib/zena/use/display.rb
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,44 @@ def r_javascripts
else
list = @params[:list].split(',').map{|e| e.strip}
end
helper.javascript_include_tag(*list)

out helper.javascript_include_tag(*list)
return
# Experimental: move all scripts at end of file
if list.include?('prototype')
list -= ['prototype']
out helper.javascript_include_tag('prototype')
end
return if list.empty?

list = list.map do |e|
"Script.load('#{helper.javascript_path(e)}');"
end
code = %Q{ var Script = {
_loadedScripts: [],
load: function(script){
if (this._loadedScripts.include(script)){
return false;
}
var code = new Ajax.Request(script, {
asynchronous: false, method: "GET",
evalJS: false, evalJSON: false
}).transport.responseText;
if (Prototype.Browser.IE) {
window.execScript(code);
} else if (Prototype.Browser.WebKit){
$$("head").first().insert(Object.extend(
new Element("script", {type: "text/javascript"}), {text: code}
));
} else {
window.eval(code);
}
this._loadedScripts.push(script);
}
};
#{list.join("\n ")}
}
out "<% js_data.unshift #{code.inspect} -%>"
end

# Insert stylesheet asset tags
Expand Down
4 changes: 2 additions & 2 deletions lib/zena/use/html_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def check_exists(opts)

def unique_id
@counter ||= 0
"#{Time.now.to_i}_#{@counter += 1}"
"h#{Time.now.to_i}_#{@counter += 1}"
end

# Display the list of readers (group names).
Expand Down Expand Up @@ -174,7 +174,7 @@ def flash_messages(opts={})
if (type == 'error' || type == 'both') && flash[:error ]
error = "<div class='error' onclick='new Effect.Fade(this)'>#{flash[:error]}</div>"
end

if page = opts[:page]
page << %q{$$('#flash_messages .auto_fade').each(function(o) {
o.opacity = 100.0;
Expand Down
5 changes: 5 additions & 0 deletions lib/zena/use/query_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,11 @@ def context_relation(relation)
end

if CORE_CONTEXTS.include?(relation)
if %w{project section}.include?(relation)
set_main_class(VirtualClass[relation.capitalize])
else
set_main_class(VirtualClass['Node'])
end

# PREVIOUS_GROUP.id = NEW_GROUP.project_id
add_table(main_table)
Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/prototype.js
Original file line number Diff line number Diff line change
Expand Up @@ -4871,4 +4871,4 @@ Element.ClassNames.prototype = {

Object.extend(Element.ClassNames.prototype, Enumerable);

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
2 changes: 1 addition & 1 deletion public/javascripts/zena.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Zena.open_window = function(url, id, event, pos_x, pos_y) {
top:pos_y,
width: 300,
height:400,
zIndex:100,
zIndex:100 + Zena.window_offset,
showEffect: Element.show, hideEffect: Element.hide,
destroyOnClose: true
});
Expand Down
7 changes: 6 additions & 1 deletion test/integration/zafu_compiler/query.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,9 @@ select_group_count:

select_group_count_having:
src: "<div do='images select id.count as img_count from projects select id as pid, title as pt in site group by pid having img_count >= 2' do='each' join=', '><r:pt/>: <r:img_count/></div>"
res: "<div>a wiki with Zena: 2</div>"
res: "<div>a wiki with Zena: 2</div>"

core_context:
# Ensure that :project rubyless method uses enrollable.
src: "<r:project do='origin || title'/>"
tem: "/ar1.prop\['origin'\] or var1.prop\['title'\]/"
11 changes: 11 additions & 0 deletions test/unit/zena/use/query_node_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ class QueryNodeTest < Zena::Unit::TestCase
should 'set main_class' do
assert_equal VirtualClass['Document'], subject.main_class
end

context 'with core context' do
subject do
Node.build_query(:all, 'project')
end

should 'set main_class' do
assert_equal VirtualClass['Project'], subject.main_class
end
end # with core context

end # with a real class filter

context 'with root' do
Expand Down

0 comments on commit ad92096

Please sign in to comment.