refinerycms 0.9.5.5 → 0.9.5.6
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/refinery +3 -1
- data/config/environment.rb +1 -0
- data/db/migrate/20091109012126_add_missing_indexes.rb +25 -0
- data/db/schema.rb +13 -1
- data/vendor/plugins/images/app/controllers/admin/images_controller.rb +2 -4
- data/vendor/plugins/images/app/views/admin/images/_form.html.erb +1 -1
- data/vendor/plugins/images/app/views/admin/images/insert.html.erb +10 -12
- data/vendor/plugins/pages/app/views/admin/pages/_form.html.erb +12 -37
- data/vendor/plugins/refinery/app/views/shared/_message.html.erb +3 -2
- data/vendor/plugins/refinery/app/views/shared/admin/_image_picker.html.erb +42 -0
- data/vendor/plugins/refinery/app/views/shared/admin/_resource_picker.html.erb +52 -0
- data/vendor/plugins/refinery/lib/generators/refinery/templates/migration.rb +3 -2
- data/vendor/plugins/refinery/lib/generators/refinery/templates/views/admin/_form.html.erb +8 -8
- data/vendor/plugins/refinery/lib/generators/refinery/templates/views/admin/_singular_name.html.erb +2 -1
- data/vendor/plugins/refinery/lib/indexer.rb +280 -0
- data/vendor/plugins/refinery/lib/tasks/indexer.rake +18 -0
- data/vendor/plugins/resources/app/controllers/admin/resources_controller.rb +50 -8
- data/vendor/plugins/resources/app/views/admin/resources/_form.html.erb +11 -0
- data/vendor/plugins/resources/app/views/admin/resources/insert.html.erb +110 -0
- data/vendor/plugins/resources/config/routes.rb +1 -1
- metadata +8 -2
data/bin/refinery
CHANGED
@@ -17,10 +17,12 @@ unless (app_path = ARGV.shift).nil? or app_path.length == 0
|
|
17
17
|
FileUtils::makedirs RAILS_ROOT
|
18
18
|
|
19
19
|
# copy in all of the relevant directories and root files.
|
20
|
-
to_copy = %w(app config db public script CONTRIBUTORS LICENSE Rakefile README).map do |dir|
|
20
|
+
to_copy = %w(app config db lib public script CONTRIBUTORS LICENSE Rakefile README).map do |dir|
|
21
21
|
File.join REFINERY_ROOT, dir
|
22
22
|
end
|
23
23
|
FileUtils::cp_r to_copy, RAILS_ROOT, :verbose => false
|
24
|
+
# ensure lib/refinery_initializer.rb doesn't make it in.
|
25
|
+
FileUtils::rm File.join(RAILS_ROOT, %w(lib refinery_initializer.rb)) if File.exists?(File.join(RAILS_ROOT, %w(lib refinery_initializer.rb)))
|
24
26
|
|
25
27
|
# add in the database config file.
|
26
28
|
FileUtils::move File.join(RAILS_ROOT, %w(config database.yml.example)), File.join(RAILS_ROOT, %w(config database.yml))
|
data/config/environment.rb
CHANGED
@@ -66,4 +66,5 @@ eval("#{(defined? Refinery::Initializer) ? Refinery : Rails}::Initializer").run
|
|
66
66
|
config.gem "rails", :version => ">= 2.3.4", :lib => "rails"
|
67
67
|
config.gem "aasm", :version => ">= 2.1.3", :lib => "aasm", :source => "http://gemcutter.org"
|
68
68
|
config.gem "unicode", :version => ">= 0.1", :lib => "unicode"
|
69
|
+
config.gem "slim_scrooge", :source => "http://gemcutter.org"
|
69
70
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class AddMissingIndexes < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
add_index :pages, :parent_id
|
4
|
+
add_index :pages, :custom_title_image_id
|
5
|
+
add_index :pages, :image_id
|
6
|
+
add_index :images, :parent_id
|
7
|
+
add_index :page_parts, :page_id
|
8
|
+
|
9
|
+
add_index :pages, :id
|
10
|
+
add_index :page_parts, :id
|
11
|
+
add_index :users, :id
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.down
|
15
|
+
remove_index :pages, :parent_id
|
16
|
+
remove_index :pages, :custom_title_image_id
|
17
|
+
remove_index :pages, :image_id
|
18
|
+
remove_index :images, :parent_id
|
19
|
+
remove_index :page_parts, :page_id
|
20
|
+
|
21
|
+
remove_index :pages, :id
|
22
|
+
remove_index :page_parts, :id
|
23
|
+
remove_index :users, :id
|
24
|
+
end
|
25
|
+
end
|
data/db/schema.rb
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
#
|
10
10
|
# It's strongly recommended to check this file into your version control system.
|
11
11
|
|
12
|
-
ActiveRecord::Schema.define(:version =>
|
12
|
+
ActiveRecord::Schema.define(:version => 20091109012126) do
|
13
13
|
|
14
14
|
create_table "images", :force => true do |t|
|
15
15
|
t.integer "parent_id"
|
@@ -24,6 +24,8 @@ ActiveRecord::Schema.define(:version => 20091029034951) do
|
|
24
24
|
t.datetime "updated_at"
|
25
25
|
end
|
26
26
|
|
27
|
+
add_index "images", ["parent_id"], :name => "index_images_on_parent_id"
|
28
|
+
|
27
29
|
create_table "inquiries", :force => true do |t|
|
28
30
|
t.string "name"
|
29
31
|
t.string "email"
|
@@ -60,6 +62,9 @@ ActiveRecord::Schema.define(:version => 20091029034951) do
|
|
60
62
|
t.datetime "updated_at"
|
61
63
|
end
|
62
64
|
|
65
|
+
add_index "page_parts", ["id"], :name => "index_page_parts_on_id"
|
66
|
+
add_index "page_parts", ["page_id"], :name => "index_page_parts_on_page_id"
|
67
|
+
|
63
68
|
create_table "pages", :force => true do |t|
|
64
69
|
t.string "title"
|
65
70
|
t.integer "parent_id"
|
@@ -82,6 +87,11 @@ ActiveRecord::Schema.define(:version => 20091029034951) do
|
|
82
87
|
t.boolean "skip_to_first_child", :default => false
|
83
88
|
end
|
84
89
|
|
90
|
+
add_index "pages", ["custom_title_image_id"], :name => "index_pages_on_custom_title_image_id"
|
91
|
+
add_index "pages", ["id"], :name => "index_pages_on_id"
|
92
|
+
add_index "pages", ["image_id"], :name => "index_pages_on_image_id"
|
93
|
+
add_index "pages", ["parent_id"], :name => "index_pages_on_parent_id"
|
94
|
+
|
85
95
|
create_table "refinery_settings", :force => true do |t|
|
86
96
|
t.string "name"
|
87
97
|
t.text "value"
|
@@ -137,4 +147,6 @@ ActiveRecord::Schema.define(:version => 20091029034951) do
|
|
137
147
|
t.datetime "updated_at"
|
138
148
|
end
|
139
149
|
|
150
|
+
add_index "users", ["id"], :name => "index_users_on_id"
|
151
|
+
|
140
152
|
end
|
@@ -36,11 +36,9 @@ class Admin::ImagesController < Admin::BaseController
|
|
36
36
|
|
37
37
|
def create
|
38
38
|
@image = Image.create(params[:image])
|
39
|
-
saved = @image.valid?
|
40
|
-
flash.now[:notice] = "'#{@image.title}' was successfully created." if saved
|
41
|
-
|
42
39
|
unless params[:insert]
|
43
|
-
if
|
40
|
+
if @image.valid?
|
41
|
+
flash[:notice] = "'#{@image.title}' was successfully created."
|
44
42
|
unless from_dialog?
|
45
43
|
redirect_to :action => 'index'
|
46
44
|
else
|
@@ -22,7 +22,7 @@
|
|
22
22
|
<input type='hidden' name='update_image' value='<%= @update_image %>' />
|
23
23
|
<input type='hidden' name='thumbnail' value='<%= @thumbnail %>' />
|
24
24
|
<input type='hidden' name='callback' value='<%= @callback %>' />
|
25
|
-
<input type='hidden' name='conditions' value='<%= @conditions %>'
|
25
|
+
<input type='hidden' name='conditions' value='<%= @conditions %>' />
|
26
26
|
<% end %>
|
27
27
|
<% end %>
|
28
28
|
|
@@ -82,7 +82,7 @@
|
|
82
82
|
});
|
83
83
|
|
84
84
|
<% if @thickbox %>
|
85
|
-
$('submit_button').observe('click', function(e)
|
85
|
+
$('dialog-form-actions').down('#submit_button').observe('click', function(e)
|
86
86
|
{
|
87
87
|
selected = null;
|
88
88
|
$$('#existing_image_area_content ul li.selected img').each(function(selected_img)
|
@@ -91,19 +91,17 @@
|
|
91
91
|
});
|
92
92
|
if (selected != null)
|
93
93
|
{
|
94
|
-
|
94
|
+
<% unless @field.blank? %>
|
95
|
+
if ((field = parent.document.getElementById('<%= @field %>')) != null)
|
95
96
|
{
|
96
|
-
field =
|
97
|
-
if (field != null)
|
98
|
-
{
|
99
|
-
field.value = selected.id.replace("image_", "");
|
100
|
-
}
|
101
|
-
if ((image = parent.document.getElementById('<%= @update_image %>')) != null)
|
102
|
-
{
|
103
|
-
image.src = selected.src.replace("_dialog_thumb", '<%= "_#{@thumbnail}" unless @thumbnail.blank? %>');
|
104
|
-
$(image).writeAttribute("width", null).writeAttribute("height", null);
|
105
|
-
}
|
97
|
+
field.value = selected.id.replace("image_", "");
|
106
98
|
}
|
99
|
+
if ((image = parent.document.getElementById('<%= @update_image %>')) != null)
|
100
|
+
{
|
101
|
+
image.src = selected.src.replace("_dialog_thumb", '<%= "_#{@thumbnail}" unless @thumbnail.blank? %>');
|
102
|
+
$(image).writeAttribute("width", null).writeAttribute("height", null);
|
103
|
+
}
|
104
|
+
<% end %>
|
107
105
|
<%= "self.parent.#{@callback}();" unless @callback.blank? %>
|
108
106
|
self.parent.tb_remove();
|
109
107
|
}
|
@@ -56,21 +56,13 @@
|
|
56
56
|
</p>
|
57
57
|
</div>
|
58
58
|
<div id='custom_title_image' style='display: <%= @page.custom_title_type == 'image' ? 'block' : 'none' %>' class='clearfix'>
|
59
|
-
<%=
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
<% end %>
|
67
|
-
<span id='no_custom_title_image_selected' <%= "style='display: none;'" unless @page.custom_title_image.nil? %>>
|
68
|
-
There is currently no image selected. Click here to add one
|
69
|
-
</span>
|
70
|
-
</a>
|
71
|
-
<br/>
|
72
|
-
<%= link_to "Remove Current Image", "", :id => "remove_custom_title_image", :style => "margin-top:8px;display:inline-block;width:auto;#{"display:none;" if @page.custom_title_image.nil?}" %>
|
73
|
-
</div>
|
59
|
+
<%= render :partial => "/shared/admin/image_picker", :locals =>
|
60
|
+
{
|
61
|
+
:f => f,
|
62
|
+
:field => :custom_title_image_id,
|
63
|
+
:image => @page.custom_title_image
|
64
|
+
}
|
65
|
+
%>
|
74
66
|
</div>
|
75
67
|
</div>
|
76
68
|
<div class='field'>
|
@@ -136,7 +128,7 @@
|
|
136
128
|
<div id='dialog-form-actions' class='form-actions'>
|
137
129
|
<%= f.submit 'Save', :id => "new_page_part_save" %>
|
138
130
|
or
|
139
|
-
<%= link_to "Cancel", "
|
131
|
+
<%= link_to "Cancel", "", :id => "new_page_part_cancel", :class => "close_dialog" %>
|
140
132
|
</div>
|
141
133
|
</div>
|
142
134
|
<% end %>
|
@@ -154,7 +146,7 @@
|
|
154
146
|
$('toggle_advanced_options').observe('click', function(e)
|
155
147
|
{
|
156
148
|
$('more_options').toggle();
|
157
|
-
e.
|
149
|
+
e.preventDefault();
|
158
150
|
});
|
159
151
|
|
160
152
|
$$('input[type=radio]').each(function(radio)
|
@@ -167,22 +159,12 @@
|
|
167
159
|
});
|
168
160
|
}
|
169
161
|
});
|
170
|
-
|
171
|
-
$('remove_custom_title_image').observe('click', function(e)
|
172
|
-
{
|
173
|
-
$('current_custom_title_image').removeClassName('brown_border');
|
174
|
-
$('current_custom_title_image').src = '';
|
175
|
-
$('current_custom_title_image').alt = 'There is currently no image selected. Click here to add one.';
|
176
|
-
$('page_custom_title_image_id').value = '';
|
177
|
-
this.hide();
|
178
|
-
e.stop();
|
179
|
-
});
|
180
162
|
|
181
163
|
<% if RefinerySetting.find_or_set(:new_page_parts, false) %>
|
182
164
|
$('add_page_part').observe('click', function(e) {
|
183
165
|
tb_show('Create Content Section', '#?auto_size_content=true&draggable=true&titlebar=true&inlineId=new_page_part_dialog&TB_inline=true&modal=true');
|
184
166
|
|
185
|
-
e.
|
167
|
+
e.preventDefault();
|
186
168
|
});
|
187
169
|
|
188
170
|
$('new_page_part_save').observe('click', function(e) {
|
@@ -224,7 +206,7 @@
|
|
224
206
|
$('new_page_part_cancel').observe('click', function(e) {
|
225
207
|
$('new_page_part_title').value = "";
|
226
208
|
tb_remove();
|
227
|
-
e.
|
209
|
+
e.preventDefault();
|
228
210
|
});
|
229
211
|
|
230
212
|
$('delete_page_part').observe('click', function(e) {
|
@@ -250,17 +232,10 @@
|
|
250
232
|
WYMeditor.loaded();
|
251
233
|
}
|
252
234
|
|
253
|
-
e.
|
235
|
+
e.preventDefault();
|
254
236
|
});
|
255
237
|
<% end %>
|
256
238
|
});
|
257
|
-
|
258
|
-
custom_title_image_changed = function()
|
259
|
-
{
|
260
|
-
$('remove_custom_title_image').show();
|
261
|
-
$('current_custom_title_image').addClassName('brown_border');
|
262
|
-
$('no_custom_title_image_selected').hide();
|
263
|
-
}
|
264
239
|
|
265
240
|
// Hook into the loaded function. This will be called when WYMeditor has done its thing.
|
266
241
|
WYMeditor.loaded = function()
|
@@ -1,9 +1,10 @@
|
|
1
1
|
<% flash.each do |key, value| %>
|
2
2
|
<div id="flash" class="flash_<%= key %>" style='display: none;' >
|
3
|
-
<%= value %> (<%= link_to "close", "
|
3
|
+
<%= value %> (<%= link_to "close", "", {:id => "close"} %>)
|
4
4
|
<script type="text/javascript">
|
5
|
-
$('close').observe('click', function(){
|
5
|
+
$('close').observe('click', function(e){
|
6
6
|
$('flash').fade({ duration: 0.3 });
|
7
|
+
e.preventDefault();
|
7
8
|
});
|
8
9
|
</script>
|
9
10
|
</div>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<%= f.hidden_field field %>
|
2
|
+
<div>
|
3
|
+
<a id='current_image_link' href="<%= insert_admin_images_url %>?thickbox=true&modal=true&titlebar=true&field=<%= f.object.class.name.downcase %>_<%= field %>&update_image=current_picked_image&callback=picked_image_changed&thumbnail=&KeepThis=true&TB_iframe=true&width=<%= width ||= 950 %>&height=<%= height ||= 510 %>" style='border: 0px' title='Change Image' name='Change Image' class='thickbox'>
|
4
|
+
<% unless image.nil? %>
|
5
|
+
<%= image_fu image, nil, {:class => "brown_border", :id => "current_picked_image"} %>
|
6
|
+
<% else %>
|
7
|
+
<img id="current_picked_image" class="" src="" alt="" style='display: none' />
|
8
|
+
<% end %>
|
9
|
+
<p id='no_picked_image_selected' <%= "style='display: none;'" unless image.nil? %>>
|
10
|
+
There is currently no image selected, please click here to add one.
|
11
|
+
</p>
|
12
|
+
</a>
|
13
|
+
<br/>
|
14
|
+
<%= link_to "Remove Current Image", "", :id => "remove_picked_image", :style => "margin-top:8px;display:inline-block;width:auto;#{"display:none;" if image.nil?}" %>
|
15
|
+
</div>
|
16
|
+
<% content_for :head do %>
|
17
|
+
<script type='text/javascript'>
|
18
|
+
picked_image_changed = function()
|
19
|
+
{
|
20
|
+
$('remove_picked_image').show();
|
21
|
+
$('current_picked_image').show();
|
22
|
+
$('current_picked_image').addClassName('brown_border');
|
23
|
+
$('no_picked_image_selected').hide();
|
24
|
+
}
|
25
|
+
|
26
|
+
FastInit.addOnLoad(function() {
|
27
|
+
$('remove_picked_image').observe('click', function(e)
|
28
|
+
{
|
29
|
+
$('current_picked_image').removeClassName('brown_border');
|
30
|
+
$('current_picked_image').src = '';
|
31
|
+
$('current_picked_image').alt = 'There is currently no image selected. Click here to add one.';
|
32
|
+
$('<%= f.object.class.name.downcase %>_<%= field %>').value = '';
|
33
|
+
$('current_picked_image').style.width = "auto";
|
34
|
+
$('current_picked_image').style.height = "auto";
|
35
|
+
$('no_picked_image_selected').show();
|
36
|
+
$('current_picked_image').hide();
|
37
|
+
this.hide();
|
38
|
+
e.stop();
|
39
|
+
});
|
40
|
+
});
|
41
|
+
</script>
|
42
|
+
<% end %>
|
@@ -0,0 +1,52 @@
|
|
1
|
+
<%= f.hidden_field field %>
|
2
|
+
<div>
|
3
|
+
<a id='current_resource_link' href="<%= insert_admin_resources_url %>?thickbox=true&modal=true&titlebar=true&field=<%= "#{f.object.class.name.downcase}_#{field}" %><%= "&current_link=#{resource.public_filename unless resource.nil?}" %>&update_resource=current_resource&update_text=current_resource_text&callback=resource_changed&thumbnail=&KeepThis=true&TB_iframe=true&width=<%= width ||= 950 %>&height=<%= height ||= 510 %>" style='border: 0px' title='Change Resource' name='Change Resource' class='thickbox'>
|
4
|
+
<span id='no_resource_selected' <%= "style='display: none;'" unless resource.nil? %>>
|
5
|
+
There is currently no message file selected, click here to add one.
|
6
|
+
</span>
|
7
|
+
</a>
|
8
|
+
<div id='current_resource_container'>
|
9
|
+
<% unless resource.nil? %>
|
10
|
+
Current message file:
|
11
|
+
<span id='current_resource_text'>
|
12
|
+
<%= "#{resource.title} (#{resource.public_filename})" %>
|
13
|
+
</span>
|
14
|
+
<br/>
|
15
|
+
<%= link_to "#{refinery_icon_tag("page_white_put.png")} Download current message file (<em>Opens in a new window</em>)", resource.public_filename,
|
16
|
+
:id => "current_resource",
|
17
|
+
:target => "_blank" %>
|
18
|
+
<% else %>
|
19
|
+
<%= link_to "#{refinery_icon_tag("page_white_put.png")} Download current message file (<em>Opens in a new window</em>)", "",
|
20
|
+
:id => "current_resource",
|
21
|
+
:style => "display:none;",
|
22
|
+
:target => "_blank" %>
|
23
|
+
<% end %>
|
24
|
+
</div>
|
25
|
+
<br/>
|
26
|
+
<%= link_to "Remove Current Resource", "",
|
27
|
+
:id => "remove_resource",
|
28
|
+
:style => "margin-top:8px;display:inline-block;width:auto;#{"display:none;" if resource.nil?}" %>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<% content_for :head do %>
|
32
|
+
<script type='text/javascript'>
|
33
|
+
resource_changed = function() {
|
34
|
+
$('current_resource_link').href = $('current_resource_link').href.gsub(/current_link=([^&])*&/, "current_link=" + $('current_resource').href + "&");
|
35
|
+
$('remove_resource').show();
|
36
|
+
$('current_resource_container').show();
|
37
|
+
$('no_resource_selected').hide();
|
38
|
+
}
|
39
|
+
|
40
|
+
FastInit.addOnLoad(function() {
|
41
|
+
$('remove_resource').observe('click', function(e) {
|
42
|
+
$('<%= f.object.class.name.downcase %>_<%= field %>').value = "";
|
43
|
+
$('current_resource_container').hide();
|
44
|
+
$('current_resource_text').innerHTML = '';
|
45
|
+
$('no_resource_selected').show();
|
46
|
+
$('current_resource_link').href = $('current_resource_link').href.gsub(/current_link=([^&])*&/, "current_link=&");
|
47
|
+
this.hide();
|
48
|
+
e.preventDefault();
|
49
|
+
});
|
50
|
+
});
|
51
|
+
</script>
|
52
|
+
<% end %>
|
@@ -9,6 +9,8 @@ class <%= migration_name %> < ActiveRecord::Migration
|
|
9
9
|
|
10
10
|
t.timestamps
|
11
11
|
end
|
12
|
+
|
13
|
+
add_index :<%= table_name %>, :id
|
12
14
|
|
13
15
|
User.find(:all).each do |user|
|
14
16
|
user.plugins.create(:title => "<%= class_name.pluralize.underscore.titleize %>", :position => (user.plugins.maximum(:position) || -1) +1)
|
@@ -17,8 +19,7 @@ class <%= migration_name %> < ActiveRecord::Migration
|
|
17
19
|
page = Page.create(:title => "<%= class_name.pluralize.underscore.titleize %>", :link_url => "/<%= plural_name %>", :deletable => false, :position => ((Page.maximum(:position, :conditions => "parent_id IS NULL") || -1)+1))
|
18
20
|
RefinerySetting.find_or_set(:default_page_parts, ["body", "side_body"]).each do |default_page_part|
|
19
21
|
page.parts.create(:title => default_page_part, :body => nil)
|
20
|
-
end
|
21
|
-
|
22
|
+
end
|
22
23
|
end
|
23
24
|
|
24
25
|
def self.down
|
@@ -1,13 +1,13 @@
|
|
1
|
-
<%%= error_messages_for :<%= singular_name %>
|
2
|
-
<%% form_for [:admin, @<%= singular_name %>] do |f|
|
1
|
+
<%%= error_messages_for :<%= singular_name %> -%>
|
2
|
+
<%% form_for [:admin, @<%= singular_name %>] do |f| -%>
|
3
3
|
<% attributes.each do |attribute| -%>
|
4
4
|
<div class='field'>
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
<%%= f.label :<%= attribute.name %> -%>
|
6
|
+
<% if attribute.field_type.to_s == "text_area" -%>
|
7
|
+
<%%= f.text_area :<%= attribute.name %>, :rows => 20, :cols => 140, :class => 'wymeditor' -%>
|
8
|
+
<% else -%>
|
9
|
+
<%%= f.<%= attribute.field_type -%> :<%= attribute.name -%> -%>
|
10
|
+
<% end -%>
|
11
11
|
</div>
|
12
12
|
<% end -%>
|
13
13
|
<div class='form-actions'>
|
data/vendor/plugins/refinery/lib/generators/refinery/templates/views/admin/_singular_name.html.erb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
<span class='title'>
|
3
3
|
<span class='actions'>
|
4
4
|
<%%= link_to refinery_icon_tag("application_go.png"), <%= singular_name %>_url(<%= singular_name %>),
|
5
|
-
:title => 'View this <%= $title_name.downcase
|
5
|
+
:title => 'View this <%= $title_name.downcase %><br/><em>Opens in a new window</em>',
|
6
|
+
:target => "_blank" %>
|
6
7
|
<%%= link_to refinery_icon_tag("application_edit.png"), edit_admin_<%= singular_name %>_path(<%= singular_name %>),
|
7
8
|
:title => 'Edit this <%= $title_name.downcase %>' %>
|
8
9
|
<%%= link_to refinery_icon_tag("delete.png"), admin_<%= singular_name %>_path(<%= singular_name %>),
|
@@ -0,0 +1,280 @@
|
|
1
|
+
module Indexer
|
2
|
+
|
3
|
+
|
4
|
+
def self.sortalize(array)
|
5
|
+
Marshal.load(Marshal.dump(array)).each do |element|
|
6
|
+
element.sort! if element.is_a?(Array)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.check_for_indexes(migration_format = false)
|
11
|
+
model_names = []
|
12
|
+
Dir.chdir(Rails.root) do
|
13
|
+
model_names = Dir["**/app/models/*.rb"].collect {|filename| File.basename(filename) }.uniq
|
14
|
+
end
|
15
|
+
|
16
|
+
model_classes = []
|
17
|
+
model_names.each do |model_name|
|
18
|
+
class_name = model_name.sub(/\.rb$/,'').camelize
|
19
|
+
begin
|
20
|
+
klass = class_name.split('::').inject(Object){ |klass,part| klass.const_get(part) }
|
21
|
+
if klass < ActiveRecord::Base && !klass.abstract_class?
|
22
|
+
model_classes << klass
|
23
|
+
end
|
24
|
+
rescue
|
25
|
+
# No-op
|
26
|
+
end
|
27
|
+
end
|
28
|
+
puts "Found #{model_classes.size} Models"
|
29
|
+
|
30
|
+
@indexes_required = Hash.new([])
|
31
|
+
@index_migrations = Hash.new([])
|
32
|
+
|
33
|
+
model_classes.each do |class_name|
|
34
|
+
|
35
|
+
# check if this is an STI child instance
|
36
|
+
if class_name.base_class.name != class_name.name && (class_name.column_names.include?(class_name.base_class.inheritance_column) || class_name.column_names.include?(class_name.inheritance_column))
|
37
|
+
# add the inharitance column on the parent table
|
38
|
+
if !(migration_format)
|
39
|
+
@indexes_required[class_name.base_class.table_name] += [class_name.inheritance_column].sort unless @indexes_required[class_name.base_class.table_name].include?([class_name.inheritance_column].sort)
|
40
|
+
else
|
41
|
+
# index migration for STI should require both the primary key and the inheritance_column in a composite index.
|
42
|
+
@index_migrations[class_name.base_class.table_name] += [[class_name.inheritance_column, class_name.base_class.primary_key].sort] unless @index_migrations[class_name.base_class.table_name].include?([class_name.base_class.inheritance_column].sort)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class_name.reflections.each_pair do |reflection_name, reflection_options|
|
47
|
+
case reflection_options.macro
|
48
|
+
when :belongs_to
|
49
|
+
# polymorphic?
|
50
|
+
@table_name = class_name.table_name.to_s #(reflection_options.options.has_key?(:class_name) ? reflection_options.options[:class_name].constantize.table_name : )
|
51
|
+
if reflection_options.options.has_key?(:polymorphic) && (reflection_options.options[:polymorphic] == true)
|
52
|
+
poly_type = "#{reflection_options.name.to_s}_type"
|
53
|
+
poly_id = "#{reflection_options.name.to_s}_id"
|
54
|
+
if !(migration_format)
|
55
|
+
@indexes_required[@table_name.to_s] += [poly_type, poly_id].sort unless @indexes_required[@table_name.to_s].include?([poly_type, poly_id].sort)
|
56
|
+
else
|
57
|
+
|
58
|
+
@index_migrations[@table_name.to_s] += [[poly_type, poly_id].sort] unless @index_migrations[@table_name.to_s].include?([poly_type, poly_id].sort)
|
59
|
+
end
|
60
|
+
else
|
61
|
+
|
62
|
+
foreign_key = reflection_options.options[:foreign_key] ||= reflection_options.primary_key_name
|
63
|
+
|
64
|
+
if !(migration_format)
|
65
|
+
@indexes_required[@table_name.to_s] += [foreign_key] unless @indexes_required[@table_name.to_s].include?(foreign_key)
|
66
|
+
else
|
67
|
+
@index_migrations[@table_name.to_s] += [foreign_key] unless @index_migrations[@table_name.to_s].include?(foreign_key)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
when :has_and_belongs_to_many
|
71
|
+
table_name = reflection_options.options[:join_table] ||= [class_name.table_name, reflection_name.to_s].sort.join('_')
|
72
|
+
association_foreign_key = reflection_options.options[:association_foreign_key] ||= "#{reflection_name.to_s.singularize}_id"
|
73
|
+
foreign_key = reflection_options.options[:foreign_key] ||= "#{class_name.name.tableize.singularize}_id"
|
74
|
+
|
75
|
+
if !(migration_format)
|
76
|
+
@indexes_required[table_name.to_s] += [association_foreign_key, foreign_key].sort unless @indexes_required[table_name].include?([association_foreign_key, foreign_key].sort)
|
77
|
+
else
|
78
|
+
@index_migrations[table_name.to_s] += [[association_foreign_key, foreign_key].sort] unless @index_migrations[table_name].include?([association_foreign_key, foreign_key].sort)
|
79
|
+
end
|
80
|
+
else
|
81
|
+
#nothing
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
@missing_indexes = {}
|
87
|
+
@indexes_required.each do |table_name, foreign_keys|
|
88
|
+
|
89
|
+
unless foreign_keys.blank?
|
90
|
+
existing_indexes = ActiveRecord::Base.connection.indexes(table_name.to_sym).collect(&:columns)
|
91
|
+
keys_to_add = self.sortalize(foreign_keys.uniq) - self.sortalize(existing_indexes)
|
92
|
+
@missing_indexes[table_name] = keys_to_add unless keys_to_add.empty?
|
93
|
+
end
|
94
|
+
end
|
95
|
+
if !(migration_format)
|
96
|
+
@missing_indexes
|
97
|
+
else
|
98
|
+
@index_migrations
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.scan_finds
|
103
|
+
file_names = []
|
104
|
+
Dir.chdir(Rails.root) do
|
105
|
+
file_names = Dir["**/app/**/*.rb"].uniq.reject {|file_with_path| file_with_path.include?('test')}
|
106
|
+
end
|
107
|
+
|
108
|
+
puts "Found #{file_names.size} files."
|
109
|
+
|
110
|
+
@indexes_required = Hash.new([])
|
111
|
+
file_names.each do |file_name|
|
112
|
+
current_file = File.open(File.join(Rails.root, file_name), 'r')
|
113
|
+
|
114
|
+
current_file.each do |line|
|
115
|
+
find_regexp = Regexp.new(/([A-Z]{1}[A-Za-z]+).(find){1}((_all){0,1}(_by_){0,1}([A-Za-z_]+))?\(([0-9A-Za-z"\':=>. \[\]{},]*)\)/)
|
116
|
+
if matches = find_regexp.match(line)
|
117
|
+
|
118
|
+
model_name, column_names, options = matches[1], matches[6], matches[7]
|
119
|
+
# puts "Model: #{model_name}, columns: #{column_names}, options: #{options}"
|
120
|
+
|
121
|
+
if model_name.respond_to?(:constantize)
|
122
|
+
if model_name.constantize.respond_to?(:table_name)
|
123
|
+
table_name = model_name.constantize.table_name
|
124
|
+
else
|
125
|
+
puts "Unable to get the table_name for #{model_name.to_s}. it could be an ActiveResource"
|
126
|
+
next
|
127
|
+
end
|
128
|
+
else
|
129
|
+
puts "Unable to constantize #{model_name.to_s}, if you are sure that #{model_name.to_s} is a valid class name, please file an issue on\nhttp://github.com/eladmeidar/rails_indexes\nPlease supply the relevant code as well, thanks. =)"
|
130
|
+
next
|
131
|
+
end
|
132
|
+
|
133
|
+
if column_names.blank?
|
134
|
+
primary_key = model_name.constantize.primary_key
|
135
|
+
@indexes_required[table_name] += [primary_key] unless @indexes_required[table_name].include?(primary_key)
|
136
|
+
else
|
137
|
+
column_names = column_names.split('_and_')
|
138
|
+
|
139
|
+
# remove find_by_sql references.
|
140
|
+
# column_names.delete("sql")
|
141
|
+
|
142
|
+
column_names = model_name.constantize.column_names & column_names
|
143
|
+
|
144
|
+
# Check if there were more than 1 column
|
145
|
+
if column_names.size == 1
|
146
|
+
column_name = column_names.first
|
147
|
+
@indexes_required[table_name] += [column_name] unless @indexes_required[table_name].include?(column_name)
|
148
|
+
else
|
149
|
+
@indexes_required[table_name] += [column_names.sort] unless @indexes_required[table_name].include?(column_names.sort)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
@missing_indexes = {}
|
156
|
+
@indexes_required.each do |table_name, foreign_keys|
|
157
|
+
|
158
|
+
unless foreign_keys.blank?
|
159
|
+
existing_indexes = ActiveRecord::Base.connection.indexes(table_name.to_sym).collect(&:columns)
|
160
|
+
keys_to_add = self.sortalize(foreign_keys.uniq) - self.sortalize(existing_indexes)
|
161
|
+
@missing_indexes[table_name] = keys_to_add unless keys_to_add.empty?
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
@indexes_required
|
166
|
+
end
|
167
|
+
|
168
|
+
def self.key_exists?(table,key_columns)
|
169
|
+
result = (key_columns.to_a - ActiveRecord::Base.connection.indexes(table).map { |i| i.columns }.flatten)
|
170
|
+
result.empty?
|
171
|
+
end
|
172
|
+
|
173
|
+
def self.simple_migration
|
174
|
+
migration_format = true
|
175
|
+
missing_indexes = check_for_indexes(migration_format)
|
176
|
+
|
177
|
+
unless missing_indexes.keys.empty?
|
178
|
+
add = []
|
179
|
+
remove = []
|
180
|
+
missing_indexes.each do |table_name, keys_to_add|
|
181
|
+
keys_to_add.each do |key|
|
182
|
+
next if key_exists?(table_name,key)
|
183
|
+
next if key.blank?
|
184
|
+
if key.is_a?(Array)
|
185
|
+
keys = key.collect {|k| ":#{k}"}
|
186
|
+
add << "add_index :#{table_name}, [#{keys.join(', ')}]"
|
187
|
+
remove << "remove_index :#{table_name}, :column => [#{keys.join(', ')}]"
|
188
|
+
else
|
189
|
+
add << "add_index :#{table_name}, :#{key}"
|
190
|
+
remove << "remove_index :#{table_name}, :#{key}"
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
migration = <<EOM
|
197
|
+
class AddMissingIndexes < ActiveRecord::Migration
|
198
|
+
def self.up
|
199
|
+
|
200
|
+
# These indexes were found by searching for AR::Base finds on your application
|
201
|
+
# It is strongly recommanded that you will consult a professional DBA about your infrastucture and implemntation before
|
202
|
+
# changing your database in that matter.
|
203
|
+
# There is a possibility that some of the indexes offered below is not required and can be removed and not added, if you require
|
204
|
+
# further assistance with your rails application, database infrastructure or any other problem, visit:
|
205
|
+
#
|
206
|
+
# http://www.railsmentors.org
|
207
|
+
# http://www.railstutor.org
|
208
|
+
# http://guides.rubyonrails.org
|
209
|
+
|
210
|
+
|
211
|
+
#{add.uniq.join("\n ")}
|
212
|
+
end
|
213
|
+
|
214
|
+
def self.down
|
215
|
+
#{remove.uniq.join("\n ")}
|
216
|
+
end
|
217
|
+
end
|
218
|
+
EOM
|
219
|
+
|
220
|
+
puts "## Drop this into a file in db/migrate ##"
|
221
|
+
puts migration
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
def self.indexes_list
|
226
|
+
check_for_indexes.each do |table_name, keys_to_add|
|
227
|
+
puts "Table '#{table_name}' => #{keys_to_add.to_sentence}"
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
def self.ar_find_indexes
|
232
|
+
find_indexes = self.scan_finds
|
233
|
+
|
234
|
+
unless find_indexes.keys.empty?
|
235
|
+
add = []
|
236
|
+
remove = []
|
237
|
+
find_indexes.each do |table_name, keys_to_add|
|
238
|
+
keys_to_add.each do |key|
|
239
|
+
next if key_exists?(table_name,key)
|
240
|
+
next if key.blank?
|
241
|
+
if key.is_a?(Array)
|
242
|
+
keys = key.collect {|k| ":#{k}"}
|
243
|
+
add << "add_index :#{table_name}, [#{keys.join(', ')}]"
|
244
|
+
remove << "remove_index :#{table_name}, :column => [#{keys.join(', ')}]"
|
245
|
+
else
|
246
|
+
add << "add_index :#{table_name}, :#{key}"
|
247
|
+
remove << "remove_index :#{table_name}, :#{key}"
|
248
|
+
end
|
249
|
+
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
migration = <<EOM
|
254
|
+
class AddFindsMissingIndexes < ActiveRecord::Migration
|
255
|
+
def self.up
|
256
|
+
|
257
|
+
# These indexes were found by searching for AR::Base finds on your application
|
258
|
+
# It is strongly recommanded that you will consult a professional DBA about your infrastucture and implemntation before
|
259
|
+
# changing your database in that matter.
|
260
|
+
# There is a possibility that some of the indexes offered below is not required and can be removed and not added, if you require
|
261
|
+
# further assistance with your rails application, database infrastructure or any other problem, visit:
|
262
|
+
#
|
263
|
+
# http://www.railsmentors.org
|
264
|
+
# http://www.railstutor.org
|
265
|
+
# http://guides.rubyonrails.org
|
266
|
+
|
267
|
+
#{add.uniq.join("\n ")}
|
268
|
+
end
|
269
|
+
|
270
|
+
def self.down
|
271
|
+
#{remove.uniq.join("\n ")}
|
272
|
+
end
|
273
|
+
end
|
274
|
+
EOM
|
275
|
+
|
276
|
+
puts "## Drop this into a file in db/migrate ##"
|
277
|
+
puts migration
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.join(REFINERY_ROOT, %w(vendor plugins refinery lib indexer.rb))
|
2
|
+
|
3
|
+
namespace :db do
|
4
|
+
desc "collect indexes based on AR::Base.find calls."
|
5
|
+
task :show_me_ar_find_indexes => :environment do
|
6
|
+
Indexer.ar_find_indexes
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "scan for possible required indexes"
|
10
|
+
task :show_me_some_indexes => :environment do
|
11
|
+
# Indexer.indexes_list
|
12
|
+
puts "Sorry, simple report is deprecated.\nuse rake db:show_me_a_migration or db:show_me_ar_find_indexes instead"
|
13
|
+
end
|
14
|
+
|
15
|
+
task :show_me_a_migration => :environment do
|
16
|
+
Indexer.simple_migration
|
17
|
+
end
|
18
|
+
end
|
@@ -10,16 +10,58 @@ class Admin::ResourcesController < Admin::BaseController
|
|
10
10
|
|
11
11
|
def create
|
12
12
|
@resource = Resource.create params[:resource]
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
|
14
|
+
unless params[:insert]
|
15
|
+
if @resource.valid?
|
16
|
+
flash[:notice] = "'#{@resource.title}' was successfully created."
|
17
|
+
unless from_dialog?
|
18
|
+
redirect_to :action => 'index'
|
19
|
+
else
|
20
|
+
render :text => "<script type='text/javascript'>parent.window.location = '#{admin_resources_url}';</script>"
|
21
|
+
end
|
22
|
+
else
|
23
|
+
render :action => 'new'
|
24
|
+
end
|
20
25
|
else
|
21
|
-
|
26
|
+
@resource_id = @resource.id
|
27
|
+
@resource = nil
|
28
|
+
self.insert
|
22
29
|
end
|
23
30
|
end
|
31
|
+
|
32
|
+
def insert
|
33
|
+
self.new if @resource.nil?
|
34
|
+
@dialog = from_dialog?
|
35
|
+
@thickbox = !params[:thickbox].blank?
|
36
|
+
@field = params[:field]
|
37
|
+
@update_resource = params[:update_resource]
|
38
|
+
@update_text = params[:update_text]
|
39
|
+
@thumbnail = params[:thumbnail]
|
40
|
+
@callback = params[:callback]
|
41
|
+
@conditions = params[:conditions]
|
42
|
+
@current_link = params[:current_link]
|
43
|
+
@url_override = admin_resources_url(:dialog => @dialog, :insert => true)
|
44
|
+
|
45
|
+
unless params[:conditions].blank?
|
46
|
+
extra_condition = params[:conditions].split(',')
|
47
|
+
|
48
|
+
extra_condition[1] = true if extra_condition[1] == "true"
|
49
|
+
extra_condition[1] = false if extra_condition[1] == "false"
|
50
|
+
extra_condition[1] = nil if extra_condition[1] == "nil"
|
51
|
+
paginate_resources({extra_condition[0].to_sym => extra_condition[1]})
|
52
|
+
else
|
53
|
+
paginate_resources
|
54
|
+
end
|
55
|
+
render :action => "insert"
|
56
|
+
end
|
57
|
+
|
58
|
+
protected
|
59
|
+
|
60
|
+
def paginate_resources(conditions={})
|
61
|
+
@resources = Resource.paginate :page => (@paginate_page_number ||= params[:page]),
|
62
|
+
:conditions => conditions,
|
63
|
+
:order => 'created_at DESC',
|
64
|
+
:per_page => Resource.per_page(from_dialog?)
|
65
|
+
end
|
24
66
|
|
25
67
|
end
|
@@ -15,4 +15,15 @@
|
|
15
15
|
or
|
16
16
|
<%= link_to "Cancel", admin_resources_url, :title => "Cancelling will lose all changes you've made to this file", :class => "close_dialog" -%>
|
17
17
|
</div>
|
18
|
+
|
19
|
+
<% if @thickbox %>
|
20
|
+
<input type='hidden' name='thickbox' value='<%= @thickbox %>' />
|
21
|
+
<input type='hidden' name='field' value='<%= @field %>' />
|
22
|
+
<input type='hidden' name='update_resource' value='<%= @update_resource %>' />
|
23
|
+
<input type='hidden' name='update_text' value='<%= @update_text %>' />
|
24
|
+
<input type='hidden' name='thumbnail' value='<%= @thumbnail %>' />
|
25
|
+
<input type='hidden' name='callback' value='<%= @callback %>' />
|
26
|
+
<input type='hidden' name='conditions' value='<%= @conditions %>' />
|
27
|
+
<input type='hidden' name='current_link' value='<%= @current_link %>' />
|
28
|
+
<% end %>
|
18
29
|
<% end -%>
|
@@ -0,0 +1,110 @@
|
|
1
|
+
<div class='clearfix'>
|
2
|
+
<div id='dialog_menu_left'>
|
3
|
+
<% unless @resources.empty? %>
|
4
|
+
<span id='existing_resource_radio' class='radio'>
|
5
|
+
<input type='radio' name='resource_type' value='existing_resource' id='resource_type_existing' <%= "checked='true'" if @resource.errors.empty? %> />
|
6
|
+
<label for='resource_type_existing' class='stripped'>Existing File</label>
|
7
|
+
</span>
|
8
|
+
<% end %>
|
9
|
+
<span id='upload_resource_radio' class='radio<%= " selected_radio" if @resource.errors.size > 0 %>'>
|
10
|
+
<input type='radio' name='resource_type' value='upload_resource' id='resource_type_upload' <%= "checked='true'" if @resources.empty? or !@resource.errors.empty? %> />
|
11
|
+
<label for='resource_type_upload' class='stripped'>New File</label>
|
12
|
+
</span>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<div id='dialog_main'>
|
16
|
+
<% unless @resources.empty? %>
|
17
|
+
<div id='existing_resource_area' class='dialog_area' <%= "style='display:none;'" unless @resource.errors.empty? %>>
|
18
|
+
<input type='hidden' name='linked_resource' id='linked_resource' />
|
19
|
+
<div id='existing_resource_area_content' class='clearfix'>
|
20
|
+
<div id='pages_list'>
|
21
|
+
<ul class='link_list'>
|
22
|
+
<% @resources.each do |resource| -%>
|
23
|
+
<% resource_linked = (resource.public_filename == params[:current_link]) unless params[:current_link].blank? %>
|
24
|
+
<li<%= " class='linked'" if resource_linked %>>
|
25
|
+
<%= link_to "#{resource.title} (#{resource.public_filename})", resource.public_filename, :title => 'Link to this Resource',
|
26
|
+
:rel => resource.title, :class => 'page_link', :id => "resource_#{resource.id}" %>
|
27
|
+
</li>
|
28
|
+
<% end %>
|
29
|
+
</ul>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
<%= will_paginate @resources, :previous_label => '« Previous', :next_label => 'Next »', :renderer => Refinery::LinkRenderer, :url => {:controller => "admin/resources", :action => "insert", :dialog => @dialog} unless @thickbox %>
|
33
|
+
</div>
|
34
|
+
<% end %>
|
35
|
+
<div id='upload_resource_area' class='dialog_area' <%= "style='display:none;'" if @resources.empty? %>>
|
36
|
+
<%= render :partial => "form", :locals => {:insert => true} %>
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
<% if @thickbox %>
|
41
|
+
<div id='dialog-form-actions' class='form-actions'>
|
42
|
+
<%= submit_tag 'Insert', :id => "submit_button" %>
|
43
|
+
or
|
44
|
+
<%= link_to "Cancel", "", :id => "cancel_button", :class => "close_dialog" %>
|
45
|
+
|
46
|
+
<%= will_paginate @resources, :previous_label => '« Previous', :next_label => 'Next »', :renderer => Refinery::LinkRenderer, :url => {:controller => "admin/resources", :action => "insert", :dialog => @dialog } %>
|
47
|
+
</div>
|
48
|
+
<% end %>
|
49
|
+
<% content_for :head do %>
|
50
|
+
<%= javascript_include_tag 'refinery/parse_url' %>
|
51
|
+
<script type='text/javascript'>
|
52
|
+
set_resource = function(anchor)
|
53
|
+
{
|
54
|
+
if (anchor != null) {
|
55
|
+
$$('#existing_resource_area_content ul li.linked').each(function(linked)
|
56
|
+
{
|
57
|
+
$(linked).removeClassName('linked');
|
58
|
+
});
|
59
|
+
$(anchor.parentNode).addClassName('linked');
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
FastInit.addOnLoad(function()
|
64
|
+
{
|
65
|
+
<% unless @resource_id.nil? %>
|
66
|
+
set_resource($('resource_<%= @resource_id %>'));
|
67
|
+
<% end %>
|
68
|
+
$$('#existing_resource_area_content ul li a').each(function(anchor)
|
69
|
+
{
|
70
|
+
anchor.observe('click', function(e){set_resource(this);e.preventDefault()});
|
71
|
+
});
|
72
|
+
|
73
|
+
<% if @thickbox %>
|
74
|
+
$('dialog-form-actions').down('#submit_button').observe('click', function(e)
|
75
|
+
{
|
76
|
+
linked = null;
|
77
|
+
$$('#existing_resource_area_content ul li.linked a').each(function(linked_anchor)
|
78
|
+
{
|
79
|
+
linked = linked_anchor;
|
80
|
+
});
|
81
|
+
if (linked != null)
|
82
|
+
{
|
83
|
+
<% unless @field.blank? %>
|
84
|
+
if ((field = parent.document.getElementById('<%= @field %>')) != null)
|
85
|
+
{
|
86
|
+
field.value = linked.id.replace("resource_", "");
|
87
|
+
}
|
88
|
+
if ((resource = parent.document.getElementById('<%= @update_resource %>')) != null)
|
89
|
+
{
|
90
|
+
resourceUrl = parseURL(linked.href);
|
91
|
+
relevant_href = resourceUrl.pathname;
|
92
|
+
// Add any alternate resource stores that need a absolute URL in the regex below
|
93
|
+
if( resourceUrl.hostname.match(/s3.amazonaws.com/) ) {
|
94
|
+
relevant_href = resourceUrl.protocol + '//' + resourceUrl.host + relevant_href;
|
95
|
+
}
|
96
|
+
resource.href = relevant_href;
|
97
|
+
}
|
98
|
+
if ((text = parent.document.getElementById('<%= @update_text %>')) != null) {
|
99
|
+
text.innerHTML = linked.innerHTML;
|
100
|
+
}
|
101
|
+
<% end %>
|
102
|
+
<%= "self.parent.#{@callback}();" unless @callback.blank? %>
|
103
|
+
self.parent.tb_remove();
|
104
|
+
}
|
105
|
+
e.stop();
|
106
|
+
});
|
107
|
+
<% end %>
|
108
|
+
});
|
109
|
+
</script>
|
110
|
+
<% end %>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.5.
|
4
|
+
version: 0.9.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Resolve Digital
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2009-11-
|
14
|
+
date: 2009-11-10 00:00:00 +13:00
|
15
15
|
default_executable: refinery
|
16
16
|
dependencies: []
|
17
17
|
|
@@ -45,6 +45,7 @@ files:
|
|
45
45
|
- config/rackspace_cloudfiles.yml
|
46
46
|
- config/routes.rb
|
47
47
|
- db/migrate/20091029034951_remove_blurb_from_news_items.rb
|
48
|
+
- db/migrate/20091109012126_add_missing_indexes.rb
|
48
49
|
- db/schema.rb
|
49
50
|
- db/seeds.rb
|
50
51
|
- public/.htaccess
|
@@ -422,6 +423,8 @@ files:
|
|
422
423
|
- vendor/plugins/refinery/app/views/shared/_message.html.erb
|
423
424
|
- vendor/plugins/refinery/app/views/shared/_submenu.html.erb
|
424
425
|
- vendor/plugins/refinery/app/views/shared/_submenu_branch.html.erb
|
426
|
+
- vendor/plugins/refinery/app/views/shared/admin/_image_picker.html.erb
|
427
|
+
- vendor/plugins/refinery/app/views/shared/admin/_resource_picker.html.erb
|
425
428
|
- vendor/plugins/refinery/app/views/shared/admin/_make_sortable.html.erb
|
426
429
|
- vendor/plugins/refinery/app/views/shared/admin/_search.html.erb
|
427
430
|
- vendor/plugins/refinery/app/views/shared/admin/_sortable_list.html.erb
|
@@ -456,7 +459,9 @@ files:
|
|
456
459
|
- vendor/plugins/refinery/lib/refinery/link_renderer.rb
|
457
460
|
- vendor/plugins/refinery/lib/refinery/plugin.rb
|
458
461
|
- vendor/plugins/refinery/lib/refinery/plugins.rb
|
462
|
+
- vendor/plugins/refinery/lib/indexer.rb
|
459
463
|
- vendor/plugins/refinery/lib/refinery.rb
|
464
|
+
- vendor/plugins/refinery/lib/tasks/indexer.rake
|
460
465
|
- vendor/plugins/refinery/lib/tasks/refinery.rake
|
461
466
|
- vendor/plugins/refinery_dialogs/app/controllers/admin/dialogs_controller.rb
|
462
467
|
- vendor/plugins/refinery_dialogs/app/views/admin/dialogs/show.html.erb
|
@@ -479,6 +484,7 @@ files:
|
|
479
484
|
- vendor/plugins/resources/app/views/admin/resources/_resource.html.erb
|
480
485
|
- vendor/plugins/resources/app/views/admin/resources/edit.html.erb
|
481
486
|
- vendor/plugins/resources/app/views/admin/resources/index.html.erb
|
487
|
+
- vendor/plugins/resources/app/views/admin/resources/insert.html.erb
|
482
488
|
- vendor/plugins/resources/app/views/admin/resources/new.html.erb
|
483
489
|
- vendor/plugins/resources/config/routes.rb
|
484
490
|
- vendor/plugins/resources/init.rb
|