wheels 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README +2 -0
- data/Rakefile +22 -22
- data/lib/{generators/core_extensions.rb → core_extensions.rb} +2 -2
- data/lib/generators/{recipes → wheels/recipes}/cancan.rb +0 -0
- data/lib/generators/{recipes → wheels/recipes}/cucumber.rb +0 -0
- data/lib/generators/{recipes → wheels/recipes}/default.rb +0 -0
- data/lib/generators/{recipes → wheels/recipes}/design.rb +0 -0
- data/lib/generators/{recipes → wheels/recipes}/devise.rb +0 -0
- data/lib/generators/{recipes → wheels/recipes}/factory_girl.rb +0 -0
- data/lib/generators/{recipes → wheels/recipes}/haml.rb +0 -0
- data/lib/generators/{recipes → wheels/recipes}/jquery.rb +0 -0
- data/lib/generators/{recipes → wheels/recipes}/mongoid.rb +0 -0
- data/lib/generators/{recipes → wheels/recipes}/postgresql.rb +0 -0
- data/lib/generators/wheels/recipes/public.rb +9 -0
- data/lib/generators/{recipes → wheels/recipes}/recipes.rb +0 -0
- data/lib/generators/{recipes → wheels/recipes}/remarkable.rb +0 -0
- data/lib/generators/{recipes → wheels/recipes}/rspec.rb +0 -0
- data/lib/generators/{recipes → wheels/recipes}/wheels.rb +0 -0
- data/lib/generators/{snippets → wheels/snippets}/cucumber/database_config +0 -0
- data/lib/generators/{templates → wheels/templates}/cancan/ability.rb +0 -0
- data/lib/generators/{templates → wheels/templates}/database/postgresql.yml +0 -0
- data/lib/generators/{templates → wheels/templates}/git/gitignore +0 -0
- data/lib/generators/{templates → wheels/templates}/haml/app/views/layouts/application.html.haml +0 -0
- data/lib/generators/{templates → wheels/templates}/mongoid/features/step_definitions/mongoid_steps.rb +0 -0
- data/lib/generators/{templates → wheels/templates}/mongoid/features/support/hooks.rb +0 -0
- data/lib/generators/wheels/wheels_generator.rb +0 -2
- data/lib/generators/wheels_update/core_extensions.3.rb +64 -0
- data/lib/generators/{recipes/wheels_update.rb → wheels_update/recipes/wheels.rb} +0 -0
- data/lib/generators/wheels_update/wheels_update_generator.rb +1 -1
- data/lib/wheels/base.rb +7 -0
- data/lib/wheels/routes.rb +2 -13
- data/test/functional/access_control_entries_controller_test.rb +49 -0
- data/test/functional/app_configs_controller_test.rb +49 -0
- data/test/functional/discussions_controller_test.rb +49 -0
- data/test/functional/external_links_controller_test.rb +49 -0
- data/test/functional/feedback_mailer_test.rb +8 -0
- data/test/functional/feedbacks_controller_test.rb +49 -0
- data/test/functional/forums_controller_test.rb +49 -0
- data/test/functional/layouts_controller_test.rb +49 -0
- data/test/functional/member_pages_controller_test.rb +49 -0
- data/test/functional/members_controller_test.rb +8 -0
- data/test/functional/menus_controller_test.rb +49 -0
- data/test/functional/pages_controller_test.rb +49 -0
- data/test/functional/product_revisions_controller_test.rb +49 -0
- data/test/performance/browsing_test.rb +9 -0
- data/test/test_helper.rb +13 -0
- data/test/unit/access_control_entry_test.rb +8 -0
- data/test/unit/app_config_test.rb +8 -0
- data/test/unit/attachment_test.rb +8 -0
- data/test/unit/discussion_test.rb +8 -0
- data/test/unit/external_link_test.rb +8 -0
- data/test/unit/feedback_test.rb +8 -0
- data/test/unit/forum_message_test.rb +8 -0
- data/test/unit/forum_test.rb +8 -0
- data/test/unit/helpers/access_control_entries_helper_test.rb +4 -0
- data/test/unit/helpers/app_configs_helper_test.rb +4 -0
- data/test/unit/helpers/discussions_helper_test.rb +4 -0
- data/test/unit/helpers/external_links_helper_test.rb +4 -0
- data/test/unit/helpers/feedbacks_helper_test.rb +4 -0
- data/test/unit/helpers/forums_helper_test.rb +4 -0
- data/test/unit/helpers/layouts_helper_test.rb +4 -0
- data/test/unit/helpers/member_pages_helper_test.rb +4 -0
- data/test/unit/helpers/members_helper_test.rb +4 -0
- data/test/unit/helpers/menus_helper_test.rb +4 -0
- data/test/unit/helpers/pages_helper_test.rb +4 -0
- data/test/unit/helpers/product_revisions_helper_test.rb +4 -0
- data/test/unit/layout_test.rb +8 -0
- data/test/unit/member_page_test.rb +8 -0
- data/test/unit/menu_test.rb +8 -0
- data/test/unit/page_revision_test.rb +8 -0
- data/test/unit/page_test.rb +8 -0
- data/test/unit/product_revision_test.rb +8 -0
- data/test/unit/settings_test.rb +8 -0
- data/test/unit/sitemap_test.rb +8 -0
- data/test/unit/user_test.rb +8 -0
- data/wheels.gemspec +122 -252
- metadata +124 -266
- data/LICENSE +0 -20
- data/README.rdoc +0 -17
- data/VERSION +0 -1
- data/app/controllers/access_control_entries_controller.rb +0 -20
- data/app/controllers/app_configs_controller.rb +0 -17
- data/app/controllers/application_controller.rb +0 -39
- data/app/controllers/attachments_controller.rb +0 -16
- data/app/controllers/blogs_controller.rb +0 -39
- data/app/controllers/discussions_controller.rb +0 -10
- data/app/controllers/external_links_controller.rb +0 -5
- data/app/controllers/feedbacks_controller.rb +0 -10
- data/app/controllers/forum_messages_controller.rb +0 -13
- data/app/controllers/forums_controller.rb +0 -2
- data/app/controllers/galleries_controller.rb +0 -60
- data/app/controllers/images_controller.rb +0 -30
- data/app/controllers/menus_controller.rb +0 -2
- data/app/controllers/pages_controller.rb +0 -71
- data/app/controllers/profiles_controller.rb +0 -16
- data/app/controllers/sitemaps_controller.rb +0 -135
- data/app/controllers/users_controller.rb +0 -28
- data/app/helpers/access_control_entries_helper.rb +0 -2
- data/app/helpers/app_configs_helper.rb +0 -2
- data/app/helpers/application_helper.rb +0 -36
- data/app/helpers/blogs_helper.rb +0 -10
- data/app/helpers/discussions_helper.rb +0 -2
- data/app/helpers/external_links_helper.rb +0 -2
- data/app/helpers/feedbacks_helper.rb +0 -2
- data/app/helpers/forums_helper.rb +0 -2
- data/app/helpers/menus_helper.rb +0 -2
- data/app/helpers/pages_helper.rb +0 -192
- data/app/helpers/sitemaps_helper.rb +0 -12
- data/app/mailers/feedback_mailer.rb +0 -10
- data/app/models/ability.rb +0 -43
- data/app/models/access_control_entry.rb +0 -100
- data/app/models/app_config.rb +0 -26
- data/app/models/attachment.rb +0 -10
- data/app/models/blog.rb +0 -10
- data/app/models/discussion.rb +0 -19
- data/app/models/external_link.rb +0 -4
- data/app/models/feedback.rb +0 -11
- data/app/models/forum.rb +0 -4
- data/app/models/forum_message.rb +0 -5
- data/app/models/gallery.rb +0 -5
- data/app/models/image.rb +0 -10
- data/app/models/menu.rb +0 -4
- data/app/models/page.rb +0 -7
- data/app/models/page_revision.rb +0 -2
- data/app/models/profile.rb +0 -12
- data/app/models/role.rb +0 -29
- data/app/models/s3_provider.rb +0 -84
- data/app/models/sitemap.rb +0 -171
- data/app/models/tagging.rb +0 -4
- data/app/models/user.rb +0 -69
- data/app/validators/email_validator.rb +0 -22
- data/app/views/access_control_entries/_form.html.haml +0 -33
- data/app/views/access_control_entries/_index.html.haml +0 -46
- data/app/views/access_control_entries/_show.html.haml +0 -12
- data/app/views/access_control_entries/create.js.haml +0 -3
- data/app/views/access_control_entries/destroy.js.haml +0 -3
- data/app/views/access_control_entries/edit.html.haml +0 -7
- data/app/views/access_control_entries/edit.js.haml +0 -3
- data/app/views/access_control_entries/index.html.haml +0 -2
- data/app/views/access_control_entries/index.js.haml +0 -3
- data/app/views/access_control_entries/new.html.haml +0 -5
- data/app/views/access_control_entries/new.js.haml +0 -3
- data/app/views/access_control_entries/show.html.haml +0 -2
- data/app/views/access_control_entries/show.js.haml +0 -4
- data/app/views/access_control_entries/update.js.haml +0 -3
- data/app/views/app_configs/_form.html.haml +0 -11
- data/app/views/app_configs/_index.html.haml +0 -6
- data/app/views/app_configs/_show.html.haml +0 -4
- data/app/views/app_configs/create.js.haml +0 -3
- data/app/views/app_configs/css.css.haml +0 -2
- data/app/views/app_configs/destroy.js.haml +0 -3
- data/app/views/app_configs/edit.html.haml +0 -2
- data/app/views/app_configs/edit.js.haml +0 -3
- data/app/views/app_configs/index.html.haml +0 -2
- data/app/views/app_configs/index.js.haml +0 -3
- data/app/views/app_configs/new.html.haml +0 -2
- data/app/views/app_configs/new.js.haml +0 -3
- data/app/views/app_configs/show.html.haml +0 -2
- data/app/views/app_configs/show.js.haml +0 -3
- data/app/views/app_configs/update.js.haml +0 -3
- data/app/views/attachments/_form.html.haml +0 -26
- data/app/views/attachments/_index.html.haml +0 -9
- data/app/views/attachments/_show.html.haml +0 -6
- data/app/views/attachments/_uploadify.html.erb +0 -12
- data/app/views/attachments/create.js.haml +0 -3
- data/app/views/attachments/destroy.js.haml +0 -3
- data/app/views/attachments/edit.js.haml +0 -3
- data/app/views/attachments/index.html.haml +0 -2
- data/app/views/attachments/index.js.haml +0 -3
- data/app/views/attachments/new.html.haml +0 -3
- data/app/views/attachments/new.js.haml +0 -3
- data/app/views/attachments/show.html.haml +0 -2
- data/app/views/attachments/show.js.haml +0 -3
- data/app/views/attachments/update.js.haml +0 -3
- data/app/views/blogs/_form.html.haml +0 -22
- data/app/views/blogs/edit.html.haml +0 -8
- data/app/views/blogs/index.html.haml +0 -21
- data/app/views/blogs/index.xml.builder +0 -27
- data/app/views/blogs/new.html.haml +0 -6
- data/app/views/blogs/show.html.haml +0 -25
- data/app/views/discussions/_form.html.haml +0 -16
- data/app/views/discussions/edit.html.haml +0 -7
- data/app/views/discussions/index.html.haml +0 -10
- data/app/views/discussions/new.html.haml +0 -25
- data/app/views/discussions/show.html.haml +0 -16
- data/app/views/external_links/_fields_for.html.haml +0 -2
- data/app/views/external_links/_form.html.haml +0 -18
- data/app/views/external_links/_show.html.haml +0 -7
- data/app/views/external_links/create.js.haml +0 -3
- data/app/views/external_links/destroy.js.haml +0 -3
- data/app/views/external_links/edit.html.haml +0 -7
- data/app/views/external_links/edit.js.haml +0 -3
- data/app/views/external_links/index.html.haml +0 -23
- data/app/views/external_links/index.js.haml +0 -3
- data/app/views/external_links/new.html.haml +0 -5
- data/app/views/external_links/new.js.haml +0 -3
- data/app/views/external_links/show.html.haml +0 -2
- data/app/views/external_links/show.js.haml +0 -3
- data/app/views/external_links/update.js.haml +0 -3
- data/app/views/feedback_mailer/submit_feedback.html.haml +0 -22
- data/app/views/feedbacks/_form.html.haml +0 -37
- data/app/views/feedbacks/index.html.haml +0 -27
- data/app/views/feedbacks/new.html.haml +0 -6
- data/app/views/feedbacks/show.html.haml +0 -19
- data/app/views/forum_messages/_form.html.haml +0 -6
- data/app/views/forum_messages/index.html.haml +0 -11
- data/app/views/forum_messages/new.html.haml +0 -5
- data/app/views/forums/_form.html.haml +0 -13
- data/app/views/forums/edit.html.haml +0 -7
- data/app/views/forums/index.html.haml +0 -23
- data/app/views/forums/new.html.haml +0 -5
- data/app/views/forums/show.html.haml +0 -20
- data/app/views/galleries/_form.html.haml +0 -30
- data/app/views/galleries/_show.html.haml +0 -21
- data/app/views/galleries/edit.html.haml +0 -7
- data/app/views/galleries/index.html.haml +0 -15
- data/app/views/galleries/new.html.haml +0 -5
- data/app/views/galleries/show.html.haml +0 -4
- data/app/views/images/_form.html.haml +0 -10
- data/app/views/images/create.js.haml +0 -3
- data/app/views/images/destroy.js.haml +0 -3
- data/app/views/images/edit.html.haml +0 -7
- data/app/views/images/edit.js.haml +0 -3
- data/app/views/images/index.html.haml +0 -17
- data/app/views/images/index.js.haml +0 -3
- data/app/views/images/new.html.haml +0 -5
- data/app/views/images/new.js.haml +0 -3
- data/app/views/images/show.html.haml +0 -5
- data/app/views/images/show.js.haml +0 -3
- data/app/views/images/update.js.haml +0 -3
- data/app/views/layouts/application.html.haml +0 -59
- data/app/views/layouts/bare.html.haml +0 -2
- data/app/views/layouts/image_dialog.html.haml +0 -18
- data/app/views/loadbehind/_destroy.js.haml +0 -3
- data/app/views/loadbehind/_edit.js.haml +0 -4
- data/app/views/loadbehind/_errors.html.haml +0 -5
- data/app/views/loadbehind/_growl_template.html.haml +0 -65
- data/app/views/loadbehind/_show_box.html.haml +0 -9
- data/app/views/loadbehind/_view.js.haml +0 -4
- data/app/views/loadbehind/growl.js.haml +0 -4
- data/app/views/loadbehind/index.js.haml +0 -4
- data/app/views/menus/_form.html.haml +0 -13
- data/app/views/menus/edit.html.haml +0 -7
- data/app/views/menus/index.html.haml +0 -19
- data/app/views/menus/new.html.haml +0 -5
- data/app/views/menus/show.html.haml +0 -7
- data/app/views/pages/_child_pages_links.html.haml +0 -5
- data/app/views/pages/_control_panel.html.haml +0 -15
- data/app/views/pages/_form.html.haml +0 -27
- data/app/views/pages/_form_fields.html.haml +0 -23
- data/app/views/pages/_show.html.haml +0 -4
- data/app/views/pages/_show_attachment.html.haml +0 -6
- data/app/views/pages/_show_small.html.haml +0 -2
- data/app/views/pages/create.js.haml +0 -3
- data/app/views/pages/destroy.js.haml +0 -3
- data/app/views/pages/edit.html.haml +0 -16
- data/app/views/pages/edit.js.haml +0 -4
- data/app/views/pages/index.html.haml +0 -19
- data/app/views/pages/index.js.haml +0 -3
- data/app/views/pages/new.html.haml +0 -5
- data/app/views/pages/new.js.haml +0 -3
- data/app/views/pages/show.html.haml +0 -20
- data/app/views/pages/show.js.haml +0 -3
- data/app/views/pages/update.js.haml +0 -3
- data/app/views/profiles/_form.html.haml +0 -26
- data/app/views/profiles/edit.html.haml +0 -7
- data/app/views/profiles/index.html.haml +0 -25
- data/app/views/profiles/new.html.haml +0 -5
- data/app/views/profiles/show.html.haml +0 -21
- data/app/views/sitemaps/edit.html.haml +0 -12
- data/app/views/sitemaps/edit.js.erb +0 -0
- data/app/views/sitemaps/index.html.haml +0 -83
- data/app/views/sitemaps/index.json.erb +0 -23
- data/app/views/sitemaps/new.html.haml +0 -8
- data/app/views/sitemaps/new.js.erb +0 -0
- data/app/views/users/edit.html.haml +0 -45
- data/app/views/users/index.html.haml +0 -19
- data/config/amazon_s3.yml +0 -15
- data/db/migrate/0000_devise_create_users.rb +0 -26
- data/db/migrate/0010_add_fields_to_users.rb +0 -28
- data/db/migrate/0020_create_blogs.rb +0 -16
- data/db/migrate/0030_create_galleries.rb +0 -15
- data/db/migrate/0040_create_images.rb +0 -17
- data/db/migrate/0050_create_profiles.rb +0 -24
- data/db/migrate/0060_insert_admin_user_and_roles.rb +0 -24
- data/db/migrate/0070_create_pages.rb +0 -16
- data/db/migrate/0080_create_forums.rb +0 -13
- data/db/migrate/0090_create_discussions.rb +0 -14
- data/db/migrate/0100_create_forum_messages.rb +0 -15
- data/db/migrate/0110_create_access_control_entries.rb +0 -23
- data/db/migrate/0120_create_attachments.rb +0 -17
- data/db/migrate/0130_create_roles.rb +0 -13
- data/db/migrate/0140_create_feedbacks.rb +0 -20
- data/db/migrate/0150_create_external_links.rb +0 -14
- data/db/migrate/0160_create_sitemaps.rb +0 -17
- data/db/migrate/0170_create_menus.rb +0 -14
- data/db/migrate/0180_acts_as_taggable_on_migration.rb +0 -28
- data/init.rb +0 -2
@@ -1,60 +0,0 @@
|
|
1
|
-
class GalleriesController < InheritedResources::Base
|
2
|
-
belongs_to :user, :optional=>true
|
3
|
-
before_filter :load_user
|
4
|
-
|
5
|
-
def index
|
6
|
-
index! do |format|
|
7
|
-
if params[:CKEditorFuncNum]
|
8
|
-
format.html{
|
9
|
-
render :action=>:index, :layout=>"image_dialog"
|
10
|
-
}
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def edit
|
16
|
-
edit! do |format|
|
17
|
-
if params[:CKEditorFuncNum]
|
18
|
-
format.html{
|
19
|
-
render :action=>:edit, :layout=>"image_dialog"
|
20
|
-
}
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def show
|
26
|
-
show! do |format|
|
27
|
-
@images = paginated_images_for(@gallery)
|
28
|
-
if params[:CKEditorFuncNum]
|
29
|
-
format.html{
|
30
|
-
render :action=>:show, :layout=>"image_dialog"
|
31
|
-
}
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def new
|
37
|
-
@gallery = Gallery.create(:user=>@user)
|
38
|
-
new!
|
39
|
-
end
|
40
|
-
|
41
|
-
def create
|
42
|
-
create! {images_path(params.slice(:CKEditor, :CKEditorFuncNum, :langCode))}
|
43
|
-
end
|
44
|
-
|
45
|
-
def load_user
|
46
|
-
unless params[:user_id]
|
47
|
-
@user ||= (current_user ? User.find(current_user.id) : super_user)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
helper_method :ckeditor_params, :paginated_images_for
|
51
|
-
|
52
|
-
def paginated_images_for(gallery)
|
53
|
-
@images ||= Image.where(:gallery_id=>gallery.id).paginate(:page => params[:page], :order => 'created_at DESC' )
|
54
|
-
end
|
55
|
-
|
56
|
-
def ckeditor_params
|
57
|
-
params.slice(:CKEditor, :CKEditorFuncNum, :langCode)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
@@ -1,30 +0,0 @@
|
|
1
|
-
class ImagesController < InheritedResources::Base
|
2
|
-
respond_to :html, :js, :xml
|
3
|
-
belongs_to :gallery
|
4
|
-
|
5
|
-
def index
|
6
|
-
index! do |format|
|
7
|
-
if params[:CKEditorFuncNum]
|
8
|
-
format.html {render :action=>:index, :layout=>"image_dialog"}
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def create
|
14
|
-
create! {edit_gallery_path(@gallery, params.slice(:CKEditor, :CKEditorFuncNum, :langCode))}
|
15
|
-
end
|
16
|
-
|
17
|
-
def show
|
18
|
-
show! do |format|
|
19
|
-
if params[:CKEditorFuncNum]
|
20
|
-
format.html {render :layout=>"image_dialog"}
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def collection
|
26
|
-
@images ||= end_of_association_chain.
|
27
|
-
paginate(:page => params[:page], :order => 'created_at DESC' )
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
@@ -1,71 +0,0 @@
|
|
1
|
-
class PagesController < InheritedResources::Base
|
2
|
-
respond_to :js, :html
|
3
|
-
ajax_loading
|
4
|
-
before_filter :set_collection_name
|
5
|
-
before_filter :parse_request_url, :only=>:show
|
6
|
-
|
7
|
-
def set_collection_name
|
8
|
-
if params[:page_id]
|
9
|
-
self.resources_configuration[:self][:collection_name] = :children
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def parse_request_url
|
14
|
-
if params["level1"]
|
15
|
-
@sitemap = Sitemap.find_by_path(*[1,2,3,4].map{|i|params["level#{i}"]})
|
16
|
-
@page = @sitemap.resource
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
before_filter :authenticate_user!, :except=>[:show]
|
21
|
-
before_filter :maybe_authenticate, :only=>[:show]
|
22
|
-
before_filter :resource, :only=>[:update, :show, :destroy, :edit]
|
23
|
-
authorize_resource
|
24
|
-
|
25
|
-
has_scope :tagged_with, :as => :tag
|
26
|
-
has_scope :accessible_by, :type=>:boolean, :default=>true do |c,s|
|
27
|
-
s.accessible_by(c.current_ability)
|
28
|
-
end
|
29
|
-
|
30
|
-
def resource
|
31
|
-
unless @page
|
32
|
-
page_id = params[:id]
|
33
|
-
if page_id.is_numeric?
|
34
|
-
@page ||= Page.find(page_id)
|
35
|
-
else
|
36
|
-
@page ||= Page.where(["lower(pages.title) = ?", page_id.downcase.gsub(/[_]/, ' ')]).first
|
37
|
-
end
|
38
|
-
@attachments ||= @page.attachments
|
39
|
-
end
|
40
|
-
@page
|
41
|
-
end
|
42
|
-
|
43
|
-
def maybe_authenticate
|
44
|
-
unless user_signed_in?
|
45
|
-
authenticate_user! unless current_ability.can? :read, resource
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def edit
|
50
|
-
edit! do |format|
|
51
|
-
@attachment = Attachment.new(:page=>@page)
|
52
|
-
@s3provider = S3Provider.new(:key=>"attachments/#{current_user.id}")
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def create
|
57
|
-
create! { (@parent_page ? page_child_path(@parent_page, @page) : @page) }
|
58
|
-
end
|
59
|
-
|
60
|
-
def update
|
61
|
-
update! do |format|
|
62
|
-
if params[:child_id]
|
63
|
-
@parent_page = @page
|
64
|
-
@page = Page.find(params[:child_id])
|
65
|
-
@page.parent = @parent_page
|
66
|
-
@page.save
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class ProfilesController < InheritedResources::Base
|
2
|
-
respond_to :html
|
3
|
-
before_filter :load_current_user
|
4
|
-
belongs_to :user, :optional => true, :singleton=>true
|
5
|
-
|
6
|
-
def load_current_user
|
7
|
-
unless params[:user_id]
|
8
|
-
@user ||= (current_user ? User.find(current_user.id) : super_user)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def resource
|
13
|
-
@profile ||= Profile.find_by_user_id(@user.id)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
@@ -1,135 +0,0 @@
|
|
1
|
-
class SitemapsController < InheritedResources::Base
|
2
|
-
ajax_loading
|
3
|
-
respond_to :html, :js, :json
|
4
|
-
before_filter :parse_request_url, :only=>:show
|
5
|
-
before_filter :resource, :except=>[:new, :create, :index]
|
6
|
-
before_filter :collection, :only=>[:index]
|
7
|
-
before_filter :new_resource, :only=>[:new, :create]
|
8
|
-
before_filter :authenticate_user!, :authorize_action!
|
9
|
-
|
10
|
-
def index
|
11
|
-
collection.reject!{|t| t==Sitemap.lost_and_found} if Sitemap.lost_and_found.children.empty?
|
12
|
-
index! do |format|
|
13
|
-
format.json{render :json=>collection.as_json}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def parse_request_url
|
18
|
-
if params[:level1]
|
19
|
-
@sitemap = Sitemap.find_by_path(*[1,2,3,4].map{|t|params["level#{i}".to_sym]})
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def create
|
24
|
-
@sitemap = new_resource
|
25
|
-
@sitemap.resource = @sitemap.resource_type.constantize.new
|
26
|
-
@sitemap.save
|
27
|
-
respond_with @sitemap do |format|
|
28
|
-
format.json {render :json=> json_obj.as_json}
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def json_obj
|
33
|
-
{
|
34
|
-
:status => @sitemap.errors.empty? ? 1 : 0,
|
35
|
-
:errors => @sitemap.errors,
|
36
|
-
:id => @sitemap.id,
|
37
|
-
:resource_type => @sitemap.resource_type,
|
38
|
-
:resource_id => @sitemap.resource_id,
|
39
|
-
:menu_text => @sitemap.menu_text,
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
def show
|
44
|
-
show! do |format|
|
45
|
-
format.html{
|
46
|
-
if resource.resource.is_a? ExternalLink
|
47
|
-
redirect_to resource.resource.url
|
48
|
-
elsif resource.resource.is_a? Page
|
49
|
-
|
50
|
-
end
|
51
|
-
}
|
52
|
-
format.json{render :json=>resource.as_json}
|
53
|
-
format.js{redirect_to(url_for(resource.resource)+'.js')}
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def destroy
|
58
|
-
if (resource.parent == Sitemap.lost_and_found) || (resource.resource.is_a? AppConfig)
|
59
|
-
resource.destroy
|
60
|
-
else
|
61
|
-
resource.parent = Sitemap.lost_and_found
|
62
|
-
resource.save
|
63
|
-
end
|
64
|
-
respond_with resource
|
65
|
-
end
|
66
|
-
|
67
|
-
def update
|
68
|
-
resource.parent = parent
|
69
|
-
update! do |format|
|
70
|
-
if params.stringify_keys["sitemap"]["position"]
|
71
|
-
childrunz = Array.new(parent.children.sorted)
|
72
|
-
childrunz.delete(resource)
|
73
|
-
childrunz.insert(params.stringify_keys["sitemap"]["position"].to_i, resource)
|
74
|
-
childrunz.each_with_index do |child, idx|
|
75
|
-
child.position = idx
|
76
|
-
child.save
|
77
|
-
end
|
78
|
-
end
|
79
|
-
format.json {render :json=> json_obj.as_json}
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def sort
|
84
|
-
params[:formula_herb_children].each_with_index do |id, index|
|
85
|
-
FormulaHerb.update_all(['position=?', index+1], ['id=?', id])
|
86
|
-
end
|
87
|
-
render :nothing => true
|
88
|
-
end
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
#helper methods
|
93
|
-
|
94
|
-
def authorize_action!
|
95
|
-
authorize! :manage, Sitemap
|
96
|
-
end
|
97
|
-
|
98
|
-
def resource
|
99
|
-
@sitemap ||= Sitemap.find(params[:id]) if params[:id]
|
100
|
-
end
|
101
|
-
|
102
|
-
def collection
|
103
|
-
@sitemaps ||= SitemapArray.new(parent.children)
|
104
|
-
end
|
105
|
-
|
106
|
-
def new_resource
|
107
|
-
@sitemap ||= Sitemap.new(params[:sitemap])
|
108
|
-
end
|
109
|
-
|
110
|
-
def parent
|
111
|
-
unless @parent
|
112
|
-
if params[:parent_id]
|
113
|
-
@parent = Sitemap.find(params[:parent_id])
|
114
|
-
else
|
115
|
-
if params[:action] == "index"
|
116
|
-
@parent = Sitemap.root
|
117
|
-
else
|
118
|
-
@parent = resource.try(:parent)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
@parent
|
123
|
-
end
|
124
|
-
|
125
|
-
private
|
126
|
-
def resource_would_be_orphaned?
|
127
|
-
resource.resource.sitemaps.size==1 &&
|
128
|
-
resource.resource.sitemaps[0] == resource
|
129
|
-
end
|
130
|
-
|
131
|
-
def resource_is_in_lost_and_found?
|
132
|
-
resource.parent==Sitemap.lost_and_found
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
@@ -1,28 +0,0 @@
|
|
1
|
-
class UsersController < InheritedResources::Base
|
2
|
-
respond_to :html, :js, :only=>[:edit, :show, :update]
|
3
|
-
respond_to :json, :only=>[:verify_password]
|
4
|
-
|
5
|
-
before_filter :authenticate_user!, :resource
|
6
|
-
|
7
|
-
def edit
|
8
|
-
respond_with(resource)
|
9
|
-
end
|
10
|
-
|
11
|
-
def update
|
12
|
-
update! do |success, failure|
|
13
|
-
failure.html{redirect_to "/change_password"}
|
14
|
-
success.html{flash[:notice] = "Your password has been updated."; redirect_to root_url}
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def verify
|
19
|
-
respond_with resource do |format|
|
20
|
-
format.json {render :json=> resource.valid_password?(params[:password]).to_json}
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def resource
|
25
|
-
@user ||= FullyValidatedUser.find(current_user)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module ApplicationHelper
|
2
|
-
def menu_node(name, url)
|
3
|
-
content_tag(:li, content_tag(:a, content_tag(:span, name, :class=>name.underscore.gsub(/ /, '_')), :href=>url))
|
4
|
-
end
|
5
|
-
|
6
|
-
def sidebar_link(name, url, is_title = false)
|
7
|
-
_class = name.underscore.gsub(/ /, '_')
|
8
|
-
_class += "sidebar_title" if is_title
|
9
|
-
content_tag(:li, content_tag(:a, content_tag(:span, name, :class=>name.underscore), :href=>url), :class=>_class)
|
10
|
-
end
|
11
|
-
|
12
|
-
def sidebar_content(&block)
|
13
|
-
@sidebar = true
|
14
|
-
content_for(:sidebar) do
|
15
|
-
block.call
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def include_ckeditor
|
20
|
-
content_for :head do
|
21
|
-
javascript_include_tag('/ckeditor/ckeditor.js',
|
22
|
-
'/ckeditor/adapters/jquery.js',
|
23
|
-
"galleries/configure_ckeditor.js")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
def session_key_name
|
27
|
-
Rails.application.config.session_options[:key]
|
28
|
-
end
|
29
|
-
def make_session_string
|
30
|
-
arr = []
|
31
|
-
request.env['HTTP_COOKIE'].each_char{|c| arr.push(c[0].to_s)}
|
32
|
-
arr.join("x")
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
data/app/helpers/blogs_helper.rb
DELETED
data/app/helpers/menus_helper.rb
DELETED
data/app/helpers/pages_helper.rb
DELETED
@@ -1,192 +0,0 @@
|
|
1
|
-
module PagesHelper
|
2
|
-
def form_url
|
3
|
-
@parent_page ? page_children_path(@parent_page) : page_path(@page)
|
4
|
-
end
|
5
|
-
def form_object
|
6
|
-
@parent_page ? [@parent_page, @page] : @page
|
7
|
-
end
|
8
|
-
|
9
|
-
def to_html_options(pages)
|
10
|
-
pages.map{|p| [p.title, p.id]}
|
11
|
-
end
|
12
|
-
|
13
|
-
######################################################
|
14
|
-
##
|
15
|
-
##
|
16
|
-
## Begin of uploadify_s3
|
17
|
-
##
|
18
|
-
##
|
19
|
-
######################################################
|
20
|
-
|
21
|
-
def uploadify_s3(options = {})
|
22
|
-
# stylesheet_link_tag('uploadify/uploadify') <<
|
23
|
-
# javascript_include_tag('uploadify/jquery.uploadify.v2.1.0.min') <<
|
24
|
-
# javascript_include_tag('uploadify/swfobject') <<
|
25
|
-
javascript_uploadify_s3_tag(options)
|
26
|
-
end
|
27
|
-
|
28
|
-
protected
|
29
|
-
|
30
|
-
def javascript_uploadify_s3_tag(options = {})
|
31
|
-
options = default_options.merge(options)
|
32
|
-
javascript_tag( %(
|
33
|
-
$(document).ready(function() {
|
34
|
-
$("#{options[:file_input_selector]}").uploadify({
|
35
|
-
'fileDataName' : 'file',
|
36
|
-
'uploader' : '/uploadify.swf',
|
37
|
-
'script' : '#{bucket_url}',
|
38
|
-
'cancelImg' : '/images/uploadify/cancel.png',
|
39
|
-
'folder' : 'attachments',
|
40
|
-
'auto' : true,
|
41
|
-
'multi' : true,
|
42
|
-
'buttonText' : 'Add File',
|
43
|
-
'sizeLimit' : '#{max_filesize}',
|
44
|
-
'fileDesc' : '#{options[:file_desc]}',
|
45
|
-
'fileExt' : '#{options[:file_ext]}',
|
46
|
-
'onSelect' : function(event, queueID, fileObj) {
|
47
|
-
if (fileObj.size >= "#{max_filesize}") {
|
48
|
-
$("#{options[:file_input_selector]}").uploadifyCancel(queueID);
|
49
|
-
alert('Sorry the max file size is #{((max_filesize/1024)/1024)} MB');
|
50
|
-
return false;
|
51
|
-
}
|
52
|
-
|
53
|
-
$('div.button_group').hide();
|
54
|
-
return true;
|
55
|
-
},
|
56
|
-
'onComplete' : function(event, queueID, fileObj, response) {
|
57
|
-
$('div.button_group').show();
|
58
|
-
fileInfo = {
|
59
|
-
'name' : fileObj.name,
|
60
|
-
'size' : fileObj.size,
|
61
|
-
'type' : fileObj.type,
|
62
|
-
'url' : '#{bucket_url}#{upload_path}/' + fileObj.name + '#{rangen}'
|
63
|
-
};
|
64
|
-
var onsucc = (#{options[:on_success]});
|
65
|
-
onsucc(fileInfo);
|
66
|
-
$('#{options[:file_input_selector]}').hide();
|
67
|
-
return true;
|
68
|
-
},
|
69
|
-
'onError' : function (a, b, c, d) {
|
70
|
-
if (d.info == 201) {
|
71
|
-
fileInfo = {
|
72
|
-
'name' : c.name,
|
73
|
-
'size' : c.size,
|
74
|
-
'type' : c.type,
|
75
|
-
'url' : '#{bucket_url}#{upload_path}/' + c.name + '#{rangen}'
|
76
|
-
};
|
77
|
-
var onsucc = (#{options[:on_success]});
|
78
|
-
onsucc(fileInfo);
|
79
|
-
$('#{options[:file_input_selector]}').hide();
|
80
|
-
} else {
|
81
|
-
var onerror = (#{options[:on_error]});
|
82
|
-
if (onerror) {
|
83
|
-
onerror(d.type, d.text);
|
84
|
-
$('#file_uploaderQueue').hide();
|
85
|
-
return false;
|
86
|
-
}
|
87
|
-
}
|
88
|
-
|
89
|
-
return true;
|
90
|
-
},
|
91
|
-
'scriptData' : {
|
92
|
-
'AWSAccessKeyId': '#{aws_access_key}',
|
93
|
-
'key': '#{key}',
|
94
|
-
'acl': '#{acl}',
|
95
|
-
'policy': '#{s3_policy}',
|
96
|
-
'success_action_status': '201',
|
97
|
-
'signature': encodeURIComponent(encodeURIComponent('#{s3_signature}')),
|
98
|
-
'Content-Type': ''
|
99
|
-
}
|
100
|
-
});
|
101
|
-
});
|
102
|
-
))
|
103
|
-
end
|
104
|
-
|
105
|
-
def bucket_url
|
106
|
-
"http://#{bucket}.s3.amazonaws.com/"
|
107
|
-
end
|
108
|
-
|
109
|
-
def key
|
110
|
-
"#{upload_path}/${filename}#{rangen}"
|
111
|
-
end
|
112
|
-
|
113
|
-
def rangen
|
114
|
-
@rangen ||= '' # rand(36 ** 8).to_s(36)
|
115
|
-
end
|
116
|
-
|
117
|
-
def policy_doc
|
118
|
-
@policy ||= "{'expiration': '#{expiration_date}',
|
119
|
-
'conditions': [{'bucket': '#{bucket}'},
|
120
|
-
['starts-with', '$key', '#{upload_path}'],
|
121
|
-
{'acl': '#{acl.to_s}'},
|
122
|
-
['content-length-range', 0, #{max_filesize}],
|
123
|
-
{'success_action_status': '201'},
|
124
|
-
['starts-with','$folder',''],
|
125
|
-
['starts-with','$Filename',''],
|
126
|
-
['starts-with','$fileext',''],
|
127
|
-
]
|
128
|
-
}"
|
129
|
-
end
|
130
|
-
|
131
|
-
def s3_policy
|
132
|
-
Base64.encode64(policy_doc).gsub(/\n|\r/, '')
|
133
|
-
end
|
134
|
-
|
135
|
-
def s3_signature
|
136
|
-
raise "Secret key should not be nil." if self.aws_secret_key.nil?
|
137
|
-
b64_hmac_sha1(aws_secret_key, s3_policy)
|
138
|
-
end
|
139
|
-
|
140
|
-
def load_s3config
|
141
|
-
a = YAML.load_file("#{Rails.root}/config/amazon_s3.yml")
|
142
|
-
puts 'loading config from yaml file.'
|
143
|
-
@s3config = a['development']
|
144
|
-
puts @s3config.inspect
|
145
|
-
end
|
146
|
-
|
147
|
-
def s3config(name)
|
148
|
-
load_s3config unless @s3config
|
149
|
-
@s3config[name]
|
150
|
-
end
|
151
|
-
|
152
|
-
def aws_access_key
|
153
|
-
s3config 'access_key_id'
|
154
|
-
end
|
155
|
-
|
156
|
-
def aws_secret_key
|
157
|
-
s3config('secret_access_key')
|
158
|
-
end
|
159
|
-
|
160
|
-
def bucket
|
161
|
-
s3config('bucket')
|
162
|
-
end
|
163
|
-
|
164
|
-
def acl
|
165
|
-
s3config('default_acl') || "public-read"
|
166
|
-
end
|
167
|
-
|
168
|
-
def upload_path
|
169
|
-
s3config('upload_path') || 'attachments'
|
170
|
-
end
|
171
|
-
|
172
|
-
def max_filesize
|
173
|
-
s3config('max_file_size') || 1000.megabyte
|
174
|
-
end
|
175
|
-
|
176
|
-
def expiration_date
|
177
|
-
10.hours.from_now.utc.strftime('%Y-%m-%dT%H:%M:%S.000Z')
|
178
|
-
end
|
179
|
-
|
180
|
-
def default_options
|
181
|
-
{
|
182
|
-
:button_text => 'Add File',
|
183
|
-
:button_img => '/images/uploadify/upload.png',
|
184
|
-
:height => '20',
|
185
|
-
:width => '30',
|
186
|
-
:file_ext => '*.*',
|
187
|
-
:file_input_selector => '#file_upload',
|
188
|
-
:file_desc => 'Please choose your file'
|
189
|
-
}
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
@@ -1,10 +0,0 @@
|
|
1
|
-
class FeedbackMailer < ActionMailer::Base
|
2
|
-
default :from => "mailer-no-reply@cagym.com"
|
3
|
-
|
4
|
-
def submit_feedback(feedback)
|
5
|
-
@feedback = feedback
|
6
|
-
#attachments["rails.png"] = File.read("#{Rails.root}/public/images/rails.png")
|
7
|
-
mail(:to => "hipkin@pacbell.net", :subject => %(CAGYM.com user feedback: #{feedback.subject}))
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
data/app/models/ability.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
class Ability
|
2
|
-
include CanCan::Ability
|
3
|
-
def self.initializers
|
4
|
-
@initializers ||= []
|
5
|
-
end
|
6
|
-
|
7
|
-
def self.initializer(*method_names)
|
8
|
-
method_names.each{|t| initializers << t}
|
9
|
-
end
|
10
|
-
initializer :init_wheels
|
11
|
-
|
12
|
-
def initialize(user)
|
13
|
-
user ||= User.nobody
|
14
|
-
puts all_aces_for(user).map{|t| "#{t.resource_type} #{t.options.inspect}"}.join("\n")
|
15
|
-
self.class.initializers.each{|t| self.send(t, user)}
|
16
|
-
all_aces_for(user).each do |ace|
|
17
|
-
ace.configure(self)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def all_aces_for(user)
|
22
|
-
(user.access_control_entries + user.role.access_control_entries)
|
23
|
-
end
|
24
|
-
|
25
|
-
def init_wheels(user)
|
26
|
-
can :read, :all
|
27
|
-
roles = Role.all
|
28
|
-
def roles.find_by_name(name); self.select{|t| t.name==name}[0]; end;
|
29
|
-
case user.role.id
|
30
|
-
when roles.find_by_name("Super").id
|
31
|
-
can :manage, :all
|
32
|
-
when roles.find_by_name("Admin").id
|
33
|
-
can :manage, :all
|
34
|
-
when roles.find_by_name("User").id
|
35
|
-
can :manage, Gallery, :user_id => user.id
|
36
|
-
can :manage, Blog, :user_id => user.id
|
37
|
-
can :edit, Profile, :user_id => user.id
|
38
|
-
cannot :read, User
|
39
|
-
can :manage, User, :id => user.id
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|