refinerycms 0.9.5.31 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/VERSION +1 -1
- data/bin/refinery +2 -1
- data/config/environment.rb +1 -1
- data/config/environments/development.rb +3 -0
- data/contributors.md +2 -0
- data/db/migrate/20100202034802_remove_custom_title_image_id_and_image_id_from_pages.rb +13 -0
- data/db/migrate/20100204011654_change_part_titles_to_titleized_version_for_new_format.rb +13 -0
- data/db/schema.rb +6 -10
- data/public/javascripts/admin.js +1 -1
- data/public/javascripts/jquery-ui-1.8rc1.min.js +375 -0
- data/public/javascripts/jquery.js +4231 -2529
- data/public/javascripts/refinery/admin.js +609 -38
- data/public/javascripts/refinery/boot_wym.js +3 -3
- data/public/javascripts/thickbox.js +116 -129
- data/public/javascripts/wymeditor/jquery.refinery.wymeditor.js +3674 -3732
- data/public/javascripts/wymeditor/skins/refinery/skin.js +8 -8
- data/public/stylesheets/refinery/refinery.css +142 -32
- data/public/stylesheets/wymeditor/skins/refinery/skin.css +8 -1
- data/readme.md +35 -21
- data/test/fixtures/page_parts.yml +9 -0
- data/test/fixtures/pages.yml +88 -0
- data/test/performance/browsing_test.rb +9 -0
- data/test/test_helper.rb +38 -0
- data/test/unit/image_test.rb +14 -0
- data/test/unit/page_part_test.rb +19 -0
- data/test/unit/page_test.rb +130 -0
- data/vendor/plugins/authentication/app/controllers/sessions_controller.rb +1 -1
- data/vendor/plugins/authentication/app/views/admin/users/index.html.erb +1 -2
- data/vendor/plugins/authentication/authentication.md +9 -1
- data/vendor/plugins/dashboard/dashboard.md +3 -3
- data/vendor/plugins/images/app/controllers/admin/images_controller.rb +17 -13
- data/vendor/plugins/images/app/helpers/admin/images_helper.rb +6 -0
- data/vendor/plugins/images/app/models/image.rb +24 -39
- data/vendor/plugins/images/app/views/admin/images/_form.html.erb +11 -4
- data/vendor/plugins/images/app/views/admin/images/_grid_view.html.erb +1 -2
- data/vendor/plugins/images/app/views/admin/images/_list_view_image.html.erb +1 -2
- data/vendor/plugins/images/app/views/admin/images/index.html.erb +1 -1
- data/vendor/plugins/images/app/views/admin/images/insert.html.erb +8 -71
- data/vendor/plugins/images/images.md +12 -7
- data/vendor/plugins/inquiries/app/views/admin/inquiries/_inquiry.html.erb +6 -13
- data/vendor/plugins/inquiries/app/views/admin/inquiry_settings/index.html.erb +1 -2
- data/vendor/plugins/inquiries/inquiries.md +8 -8
- data/vendor/plugins/news/app/views/admin/news_items/_news_item.html.erb +1 -2
- data/vendor/plugins/news/news.md +4 -4
- data/vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb +11 -10
- data/vendor/plugins/pages/app/controllers/admin/page_parts_controller.rb +5 -1
- data/vendor/plugins/pages/app/controllers/admin/pages_controller.rb +2 -2
- data/vendor/plugins/pages/app/models/page.rb +75 -29
- data/vendor/plugins/pages/app/models/page_part.rb +1 -1
- data/vendor/plugins/pages/app/views/admin/page_dialogs/_page_link.html.erb +2 -2
- data/vendor/plugins/pages/app/views/admin/page_dialogs/link_to.html.erb +8 -112
- data/vendor/plugins/pages/app/views/admin/pages/_form.html.erb +50 -154
- data/vendor/plugins/pages/app/views/admin/pages/_list.html.erb +10 -10
- data/vendor/plugins/pages/app/views/admin/pages/_page_part_field.html.erb +4 -4
- data/vendor/plugins/pages/app/views/admin/pages/_sortable_list.html.erb +1 -1
- data/vendor/plugins/pages/pages.md +30 -25
- data/vendor/plugins/refinery/app/views/admin/_head.html.erb +5 -14
- data/vendor/plugins/refinery/app/views/admin/_menu.html.erb +2 -64
- data/vendor/plugins/refinery/app/views/shared/_message.html.erb +0 -6
- data/vendor/plugins/refinery/app/views/shared/admin/_error_messages_for.html.erb +1 -6
- data/vendor/plugins/refinery/app/views/shared/admin/_form_actions.html.erb +8 -10
- data/vendor/plugins/refinery/app/views/shared/admin/_image_picker.html.erb +22 -38
- data/vendor/plugins/refinery/app/views/shared/admin/_make_sortable.html.erb +6 -65
- data/vendor/plugins/refinery/app/views/shared/admin/_resource_picker.html.erb +16 -16
- data/vendor/plugins/refinery/app/views/shared/admin/_sortable_list.html.erb +3 -4
- data/vendor/plugins/refinery/lib/crud.rb +1 -1
- data/vendor/plugins/refinery/lib/generators/refinery/templates/views/admin/_singular_name.html.erb +1 -1
- data/vendor/plugins/refinery/lib/generators/refinery/templates/views/admin/_sortable_list.html.erb +1 -1
- data/vendor/plugins/refinery/plugins.md +19 -12
- data/vendor/plugins/refinery_dialogs/app/controllers/admin/dialogs_controller.rb +6 -4
- data/vendor/plugins/refinery_dialogs/app/views/admin/dialogs/show.html.erb +3 -3
- data/vendor/plugins/refinery_dialogs/app/views/layouts/admin_dialog.html.erb +7 -14
- data/vendor/plugins/refinery_settings/app/views/admin/refinery_settings/_refinery_setting.html.erb +1 -1
- data/vendor/plugins/refinery_settings/settings.md +51 -1
- data/vendor/plugins/resources/app/controllers/admin/resources_controller.rb +16 -11
- data/vendor/plugins/resources/app/views/admin/resources/_form.html.erb +9 -2
- data/vendor/plugins/resources/app/views/admin/resources/_resource.html.erb +1 -3
- data/vendor/plugins/resources/app/views/admin/resources/index.html.erb +2 -2
- data/vendor/plugins/resources/app/views/admin/resources/insert.html.erb +14 -60
- data/vendor/plugins/resources/resources.md +1 -1
- data/vendor/plugins/themes/app/controllers/admin/themes_controller.rb +6 -6
- data/vendor/plugins/themes/app/models/theme.rb +3 -3
- data/vendor/plugins/themes/app/views/admin/themes/_theme.html.erb +14 -20
- data/vendor/plugins/themes/themes.md +21 -19
- metadata +18 -19
- data/public/javascripts/builder.js +0 -136
- data/public/javascripts/controls.js +0 -963
- data/public/javascripts/dragdrop.js +0 -973
- data/public/javascripts/effects.js +0 -1128
- data/public/javascripts/fastinit.js +0 -84
- data/public/javascripts/livepipe.js +0 -180
- data/public/javascripts/prototype.js +0 -4874
- data/public/javascripts/refinery/dialog.js +0 -52
- data/public/javascripts/refinery/parse_url.js +0 -38
- data/public/javascripts/refinery/prototype.enhancements.js +0 -24
- data/public/javascripts/refinery/tooltips.js +0 -173
- data/public/javascripts/scriptaculous.js +0 -47
- data/public/javascripts/slider.js +0 -275
- data/public/javascripts/tabs.js +0 -149
- data/vendor/plugins/refinery_settings/app/views/admin/refinery_settings/_make_sortable.html.erb +0 -7
@@ -0,0 +1,88 @@
|
|
1
|
+
# this page links to the inquiries plugin through a custom link_url
|
2
|
+
contact_us:
|
3
|
+
title: Contact Us
|
4
|
+
position: 4
|
5
|
+
show_in_menu: true
|
6
|
+
link_url: /inquiries/new
|
7
|
+
menu_match: ^/inquiries.*$
|
8
|
+
deletable: true
|
9
|
+
|
10
|
+
# A child page that is hidden
|
11
|
+
thank_you:
|
12
|
+
title: Thank You
|
13
|
+
position: 5
|
14
|
+
show_in_menu: false
|
15
|
+
menu_match: ^/inquiries/thank_you$
|
16
|
+
deletable: true
|
17
|
+
parent: contact_us
|
18
|
+
|
19
|
+
# this page is a draft
|
20
|
+
draft_page:
|
21
|
+
title: Secret Product
|
22
|
+
position: 3
|
23
|
+
show_in_menu: true
|
24
|
+
deletable: true
|
25
|
+
draft: true
|
26
|
+
|
27
|
+
# page inside draft_page
|
28
|
+
draft_page_child:
|
29
|
+
title: Secret information about secret product
|
30
|
+
position: 0
|
31
|
+
show_in_menu: true
|
32
|
+
deletable: true
|
33
|
+
draft: false # hopefully will actually be hidden from the menu becaues of it's parent
|
34
|
+
parent: draft_page # this is a child page.
|
35
|
+
|
36
|
+
# this page has a few "SEO" bits that change the page around
|
37
|
+
services:
|
38
|
+
title: Services
|
39
|
+
position: 2
|
40
|
+
show_in_menu: true
|
41
|
+
deletable: true
|
42
|
+
draft: false
|
43
|
+
browser_title: "Programming, Ruby, Rails"
|
44
|
+
custom_title_type: text
|
45
|
+
custom_title: Programming Services
|
46
|
+
|
47
|
+
# this page is the home page
|
48
|
+
home_page:
|
49
|
+
title: Home Page
|
50
|
+
position: 0
|
51
|
+
show_in_menu: true
|
52
|
+
deletable: false
|
53
|
+
link_url: /
|
54
|
+
|
55
|
+
# this is a products page that has 3 children, 1 that is hidden from the menu
|
56
|
+
products:
|
57
|
+
title: Products
|
58
|
+
position: 1
|
59
|
+
show_in_menu: true
|
60
|
+
deletable: true
|
61
|
+
|
62
|
+
blue_jelly:
|
63
|
+
title: Blue Jelly
|
64
|
+
position: 0
|
65
|
+
show_in_menu: true
|
66
|
+
deletable: true
|
67
|
+
parent: products
|
68
|
+
|
69
|
+
green_jelly:
|
70
|
+
title: Green Jelly
|
71
|
+
position: 1
|
72
|
+
show_in_menu: true
|
73
|
+
deletable: true
|
74
|
+
parent: products
|
75
|
+
|
76
|
+
rainbow_jelly:
|
77
|
+
title: Rainbow Jelly
|
78
|
+
position: 2
|
79
|
+
show_in_menu: true
|
80
|
+
deletable: true
|
81
|
+
parent: products
|
82
|
+
|
83
|
+
# this page is the generic 404 page
|
84
|
+
page_not_found:
|
85
|
+
title: Page Not Found
|
86
|
+
position: 0
|
87
|
+
show_in_menu: false
|
88
|
+
deletable: false
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
3
|
+
require 'test_help'
|
4
|
+
|
5
|
+
class ActiveSupport::TestCase
|
6
|
+
# Transactional fixtures accelerate your tests by wrapping each test method
|
7
|
+
# in a transaction that's rolled back on completion. This ensures that the
|
8
|
+
# test database remains unchanged so your fixtures don't have to be reloaded
|
9
|
+
# between every test method. Fewer database queries means faster tests.
|
10
|
+
#
|
11
|
+
# Read Mike Clark's excellent walkthrough at
|
12
|
+
# http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
|
13
|
+
#
|
14
|
+
# Every Active Record database supports transactions except MyISAM tables
|
15
|
+
# in MySQL. Turn off transactional fixtures in this case; however, if you
|
16
|
+
# don't care one way or the other, switching from MyISAM to InnoDB tables
|
17
|
+
# is recommended.
|
18
|
+
#
|
19
|
+
# The only drawback to using transactional fixtures is when you actually
|
20
|
+
# need to test transactions. Since your test is bracketed by a transaction,
|
21
|
+
# any transactions started in your code will be automatically rolled back.
|
22
|
+
self.use_transactional_fixtures = true
|
23
|
+
|
24
|
+
# Instantiated fixtures are slow, but give you @david where otherwise you
|
25
|
+
# would need people(:david). If you don't want to migrate your existing
|
26
|
+
# test cases which use the @david style and don't mind the speed hit (each
|
27
|
+
# instantiated fixtures translates to a database query per test method),
|
28
|
+
# then set this back to true.
|
29
|
+
self.use_instantiated_fixtures = false
|
30
|
+
|
31
|
+
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
32
|
+
#
|
33
|
+
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
34
|
+
# -- they do not yet inherit this setting
|
35
|
+
fixtures :all
|
36
|
+
|
37
|
+
# Add more helper methods to be used by all tests here...
|
38
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class PagePartTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
fixtures :page_parts
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@new_page_part = PagePart.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_should_not_save_page_part_without_title
|
12
|
+
assert !@new_page_part.save, "Saved the page part without a title"
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_alias_content_body_works
|
16
|
+
assert_equal page_parts(:home_page_body).body, page_parts(:home_page_body).content
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class PageTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
fixtures :pages, :page_parts
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@new_page = Page.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_should_not_save_page_without_title
|
12
|
+
assert !@new_page.save, "Saved the page without a title"
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_should_stop_system_pages_from_being_deleted
|
16
|
+
assert_equal false, pages(:home_page).deletable?
|
17
|
+
assert_equal false, pages(:page_not_found).destroy
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_should_allow_normal_pages_to_be_deleted
|
21
|
+
assert_equal true, pages(:services).deletable?
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_should_stop_custom_link_pages_from_being_deleted
|
25
|
+
assert_equal false, pages(:contact_us).deletable?
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_page_tree_structure
|
29
|
+
assert_equal 1, pages(:draft_page_child).ancestors.size
|
30
|
+
assert_equal pages(:draft_page), pages(:draft_page_child).ancestors.first
|
31
|
+
assert_equal 0, pages(:home_page).ancestors.size
|
32
|
+
|
33
|
+
assert_equal 3, pages(:products).children.size
|
34
|
+
assert_equal pages(:products), pages(:blue_jelly).ancestors.first
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_should_have_custom_seo_settings
|
38
|
+
assert_equal "Services", pages(:services).path
|
39
|
+
assert_equal "Secret Product - Secret information about secret product", pages(:draft_page_child).path
|
40
|
+
assert_equal "Secret information about secret product - Secret Product", pages(:draft_page_child).path(reverse = false)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_should_force_a_non_deletable_page_to_be_deleted
|
44
|
+
assert_equal Page, pages(:page_not_found).destroy!.class # not .destroy. Returns the page you just destroyed
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_should_have_custom_url_override
|
48
|
+
assert_equal "/inquiries/new", pages(:contact_us).url # the contact us page links to the inquiries plugin form
|
49
|
+
assert_equal "/", pages(:home_page).url # the home page has a special "/" url
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_should_have_regular_url
|
53
|
+
assert pages(:services).url.include? "/pages/"
|
54
|
+
# not sure how I get it to render the friendly_id url /pages/services
|
55
|
+
# test seems to reduce the id instead e.g. /pages/234423
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_drafts
|
59
|
+
assert_equal false, pages(:draft_page).live? # the draft page is indeed a draft
|
60
|
+
assert_equal true, pages(:home_page).live? # the home page is not a draft
|
61
|
+
assert_equal true, pages(:draft_page_child).live? # child pages with draft parents should be drafts too
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_home_page
|
65
|
+
assert pages(:home_page).home?
|
66
|
+
assert !pages(:services).home?
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_in_menu_logic
|
70
|
+
assert_equal true, pages(:home_page).in_menu? # home page should be in menu
|
71
|
+
assert_equal false, pages(:draft_page_child).in_menu? # child pages with draft parents should be hidden
|
72
|
+
assert_equal false, pages(:draft_page).in_menu? # draft pages should be hidden
|
73
|
+
|
74
|
+
pages(:home_page).toggle!(:draft) # make the page a draft
|
75
|
+
assert_equal false, pages(:home_page).live? # home page is no longer live
|
76
|
+
assert_equal false, pages(:home_page).in_menu? # it should also not appear in the menu now
|
77
|
+
|
78
|
+
pages(:home_page).toggle!(:draft) # make the page live again
|
79
|
+
assert_equal true, pages(:home_page).in_menu? # home page should reappear in the menu
|
80
|
+
|
81
|
+
pages(:home_page).toggle!(:show_in_menu) # now let's hide the home page from the menu
|
82
|
+
assert_equal false, pages(:home_page).in_menu? # yep, it's hidden.
|
83
|
+
|
84
|
+
assert_equal false, pages(:thank_you).in_menu? # a live page that's hidden should not show in menu
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_shown_siblings
|
88
|
+
assert_equal 3, pages(:products).children.size
|
89
|
+
assert_equal 3, pages(:products).shown_siblings.size
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_top_level_page_output
|
93
|
+
assert_equal 4, Page.top_level.size
|
94
|
+
|
95
|
+
# testing the order of pages.
|
96
|
+
assert_equal pages(:home_page), Page.top_level.first
|
97
|
+
assert_equal pages(:contact_us), Page.top_level.last
|
98
|
+
assert_equal pages(:products), Page.top_level[1]
|
99
|
+
assert_equal pages(:services), Page.top_level[2]
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_order_of_children
|
103
|
+
assert_equal pages(:blue_jelly), pages(:products).children.first
|
104
|
+
assert_equal pages(:green_jelly), pages(:products).children[1]
|
105
|
+
assert_equal pages(:rainbow_jelly), pages(:products).children.last
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_title_with_meta
|
109
|
+
assert_equal "Home Page", pages(:home_page).title_with_meta
|
110
|
+
assert_equal "Secret Product <em>(draft)</em>", pages(:draft_page).title_with_meta
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_per_page
|
114
|
+
assert_equal 20, Page.per_page
|
115
|
+
assert_equal 14, Page.per_page(dialog = true)
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_all_page_part_content
|
119
|
+
assert_equal "This is the body This is the side body", pages(:home_page).all_page_part_content
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_page_parts
|
123
|
+
assert_equal page_parts(:home_page_body).body, pages(:home_page)[:body]
|
124
|
+
assert_equal page_parts(:home_page_side_body).body, pages(:home_page)[:side_body]
|
125
|
+
|
126
|
+
# but make sure we can still access other fields through []
|
127
|
+
assert_equal "Home Page", pages(:home_page)[:title]
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
@@ -16,7 +16,7 @@ class SessionsController < ApplicationController
|
|
16
16
|
redirect_back_or_default(admin_root_url)
|
17
17
|
flash[:notice] = "Logged in successfully"
|
18
18
|
else
|
19
|
-
flash[:error] = "Sorry, your password or username was incorrect."
|
19
|
+
flash.now[:error] = "Sorry, your password or username was incorrect."
|
20
20
|
render :action => 'new'
|
21
21
|
end
|
22
22
|
end
|
@@ -14,8 +14,7 @@
|
|
14
14
|
<span class='title'>
|
15
15
|
<span class='actions'>
|
16
16
|
<%= link_to refinery_icon_tag('delete.png'), admin_user_path(user),
|
17
|
-
|
18
|
-
:class => "cancel", :method => :delete,
|
17
|
+
:class => "cancel confirm-delete",
|
19
18
|
:title => "Remove this user forever" if user.ui_deletable?(current_user) %>
|
20
19
|
<%= link_to refinery_icon_tag('application_edit.png'), edit_admin_user_path(user),
|
21
20
|
:title => 'Edit this user' %>
|
@@ -4,4 +4,12 @@
|
|
4
4
|
|
5
5
|
At the heart of Refinery's user management is the authentication plugin located in ``vendor/plugins/authentication``
|
6
6
|
|
7
|
-
What this really is is just a standard [RESTFul authentication](http://github.com/technoweenie/restful-authentication) install extended with a few extra features like "I forgot my password" and hooked directly into the heart of Refinery's plugin system.
|
7
|
+
What this really is is just a standard [RESTFul authentication](http://github.com/technoweenie/restful-authentication) install extended with a few extra features like "I forgot my password" and hooked directly into the heart of Refinery's plugin system.
|
8
|
+
|
9
|
+
## Adding New Users
|
10
|
+
|
11
|
+
New users can be easily added by going to the 'Users' area admin and clicking on "Add new user".
|
12
|
+
|
13
|
+
## Limiting and Granting Access
|
14
|
+
|
15
|
+
Each user has a set of plugins they're allowed to see. You can control which plugins each user can see by checking and unchecking the checkboxes next to the plugin name when editing or adding a new user.
|
@@ -6,12 +6,12 @@
|
|
6
6
|
|
7
7
|
Refinery's dashboard is a plugin that does two simple things
|
8
8
|
|
9
|
-
* Reports recent activity on all the core plugins
|
9
|
+
* Reports recent activity on all the core and custom plugins
|
10
10
|
* Provides convenient links to common tasks.
|
11
11
|
|
12
|
-
## How do I
|
12
|
+
## How do I Hook my Custom Plugin into the Recent Activity log?
|
13
13
|
|
14
|
-
Read
|
14
|
+
Read ["Getting your Plugin to Report Activity in the Dashboard"](http://github.com/resolve/refinerycms/blob/master/vendor/plugins/refinery/plugins.md) in the Plugin documentation.
|
15
15
|
|
16
16
|
## Related Settings
|
17
17
|
|
@@ -3,7 +3,7 @@ class Admin::ImagesController < Admin::BaseController
|
|
3
3
|
include Admin::ImagesHelper
|
4
4
|
|
5
5
|
crudify :image, :order => "created_at DESC", :conditions => "parent_id is NULL", :sortable => false
|
6
|
-
before_filter :change_list_mode_if_specified
|
6
|
+
before_filter :change_list_mode_if_specified, :init_dialog
|
7
7
|
|
8
8
|
def index
|
9
9
|
if searching?
|
@@ -28,20 +28,15 @@ class Admin::ImagesController < Admin::BaseController
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def new
|
31
|
-
@image = Image.new
|
31
|
+
@image = Image.new unless @image.present?
|
32
|
+
|
32
33
|
@url_override = admin_images_url(:dialog => from_dialog?)
|
33
34
|
end
|
34
35
|
|
35
36
|
def insert
|
36
37
|
self.new if @image.nil?
|
37
|
-
|
38
|
-
@
|
39
|
-
@field = params[:field]
|
40
|
-
@update_image = params[:update_image]
|
41
|
-
@thumbnail = params[:thumbnail]
|
42
|
-
@callback = params[:callback]
|
43
|
-
@conditions = params[:conditions]
|
44
|
-
@url_override = admin_images_url(:dialog => @dialog, :insert => true)
|
38
|
+
|
39
|
+
@url_override = admin_images_url(:dialog => from_dialog?, :insert => true)
|
45
40
|
|
46
41
|
unless params[:conditions].blank?
|
47
42
|
extra_condition = params[:conditions].split(',')
|
@@ -53,11 +48,13 @@ class Admin::ImagesController < Admin::BaseController
|
|
53
48
|
else
|
54
49
|
paginate_images
|
55
50
|
end
|
51
|
+
|
56
52
|
render :action => "insert"
|
57
53
|
end
|
58
54
|
|
59
55
|
def create
|
60
56
|
@image = Image.create(params[:image])
|
57
|
+
|
61
58
|
unless params[:insert]
|
62
59
|
if @image.valid?
|
63
60
|
flash[:notice] = "'#{@image.title}' was successfully created."
|
@@ -67,12 +64,10 @@ class Admin::ImagesController < Admin::BaseController
|
|
67
64
|
render :text => "<script type='text/javascript'>parent.window.location = '#{admin_images_url}';</script>"
|
68
65
|
end
|
69
66
|
else
|
67
|
+
self.new # important for dialogs
|
70
68
|
render :action => 'new'
|
71
69
|
end
|
72
70
|
else
|
73
|
-
# set the last page as the current page for image grid.
|
74
|
-
#@paginate_page_number = Image.last_page(Image.find_all_by_parent_id(nil, :order => "created_at DESC"), params[:dialog])
|
75
|
-
# currently images are sorting by date desc so the first page is always the selected page now.
|
76
71
|
@image_id = @image.id
|
77
72
|
@image = nil
|
78
73
|
self.insert
|
@@ -81,6 +76,15 @@ class Admin::ImagesController < Admin::BaseController
|
|
81
76
|
|
82
77
|
protected
|
83
78
|
|
79
|
+
def init_dialog
|
80
|
+
@thickbox = params[:thickbox].present?
|
81
|
+
@field = params[:field]
|
82
|
+
@update_image = params[:update_image]
|
83
|
+
@thumbnail = params[:thumbnail]
|
84
|
+
@callback = params[:callback]
|
85
|
+
@conditions = params[:conditions]
|
86
|
+
end
|
87
|
+
|
84
88
|
def paginate_images(conditions={})
|
85
89
|
@images = Image.paginate :page => (@paginate_page_number ||= params[:page]),
|
86
90
|
:conditions => {:parent_id => nil}.merge!(conditions),
|