wheels 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +22 -22
- data/VERSION +1 -0
- data/app/controllers/access_control_entries_controller.rb +38 -0
- data/app/controllers/app_configs_controller.rb +17 -0
- data/app/controllers/application_controller.rb +39 -0
- data/app/controllers/attachments_controller.rb +16 -0
- data/app/controllers/blogs_controller.rb +39 -0
- data/app/controllers/discussions_controller.rb +10 -0
- data/app/controllers/external_links_controller.rb +5 -0
- data/app/controllers/feedbacks_controller.rb +10 -0
- data/app/controllers/forum_messages_controller.rb +13 -0
- data/app/controllers/forums_controller.rb +2 -0
- data/app/controllers/galleries_controller.rb +60 -0
- data/app/controllers/images_controller.rb +30 -0
- data/app/controllers/menus_controller.rb +2 -0
- data/app/controllers/pages_controller.rb +80 -0
- data/app/controllers/profiles_controller.rb +16 -0
- data/app/controllers/sitemaps_controller.rb +135 -0
- data/app/controllers/users_controller.rb +28 -0
- data/app/helpers/access_control_entries_helper.rb +2 -0
- data/app/helpers/app_configs_helper.rb +2 -0
- data/app/helpers/application_helper.rb +43 -0
- data/app/helpers/blogs_helper.rb +10 -0
- data/app/helpers/discussions_helper.rb +2 -0
- data/app/helpers/external_links_helper.rb +2 -0
- data/app/helpers/feedbacks_helper.rb +2 -0
- data/app/helpers/forums_helper.rb +2 -0
- data/app/helpers/menus_helper.rb +2 -0
- data/app/helpers/pages_helper.rb +192 -0
- data/app/helpers/sitemaps_helper.rb +12 -0
- data/app/mailers/feedback_mailer.rb +10 -0
- data/app/models/ability.rb +43 -0
- data/app/models/access_control_entry.rb +109 -0
- data/app/models/app_config.rb +26 -0
- data/app/models/attachment.rb +10 -0
- data/app/models/blog.rb +10 -0
- data/app/models/discussion.rb +19 -0
- data/app/models/external_link.rb +10 -0
- data/app/models/feedback.rb +11 -0
- data/app/models/forum.rb +4 -0
- data/app/models/forum_message.rb +5 -0
- data/app/models/gallery.rb +5 -0
- data/app/models/image.rb +10 -0
- data/app/models/menu.rb +5 -0
- data/app/models/page.rb +8 -0
- data/app/models/page_revision.rb +2 -0
- data/app/models/profile.rb +12 -0
- data/app/models/role.rb +29 -0
- data/app/models/s3_provider.rb +84 -0
- data/app/models/sitemap.rb +175 -0
- data/app/models/tagging.rb +4 -0
- data/app/models/user.rb +69 -0
- data/app/validators/email_validator.rb +22 -0
- data/app/views/access_control_entries/_form.html.haml +33 -0
- data/app/views/access_control_entries/_index.html.haml +53 -0
- data/app/views/access_control_entries/_show.html.haml +12 -0
- data/app/views/access_control_entries/create.js.haml +3 -0
- data/app/views/access_control_entries/destroy.js.haml +3 -0
- data/app/views/access_control_entries/edit.html.haml +7 -0
- data/app/views/access_control_entries/edit.js.haml +3 -0
- data/app/views/access_control_entries/index.html.haml +2 -0
- data/app/views/access_control_entries/index.js.haml +3 -0
- data/app/views/access_control_entries/new.html.haml +5 -0
- data/app/views/access_control_entries/new.js.haml +3 -0
- data/app/views/access_control_entries/show.html.haml +2 -0
- data/app/views/access_control_entries/show.js.haml +4 -0
- data/app/views/access_control_entries/update.js.haml +3 -0
- data/app/views/app_configs/_form.html.haml +11 -0
- data/app/views/app_configs/_index.html.haml +6 -0
- data/app/views/app_configs/_show.html.haml +3 -0
- data/app/views/app_configs/create.js.haml +3 -0
- data/app/views/app_configs/css.css.haml +2 -0
- data/app/views/app_configs/destroy.js.haml +3 -0
- data/app/views/app_configs/edit.html.haml +2 -0
- data/app/views/app_configs/edit.js.haml +3 -0
- data/app/views/app_configs/index.html.haml +2 -0
- data/app/views/app_configs/index.js.haml +3 -0
- data/app/views/app_configs/new.html.haml +2 -0
- data/app/views/app_configs/new.js.haml +3 -0
- data/app/views/app_configs/show.html.haml +2 -0
- data/app/views/app_configs/show.js.haml +3 -0
- data/app/views/app_configs/update.js.haml +3 -0
- data/app/views/attachments/_form.html.haml +26 -0
- data/app/views/attachments/_index.html.haml +9 -0
- data/app/views/attachments/_show.html.haml +6 -0
- data/app/views/attachments/_uploadify.html.erb +12 -0
- data/app/views/attachments/create.js.haml +3 -0
- data/app/views/attachments/destroy.js.haml +3 -0
- data/app/views/attachments/edit.js.haml +3 -0
- data/app/views/attachments/index.html.haml +2 -0
- data/app/views/attachments/index.js.haml +3 -0
- data/app/views/attachments/new.html.haml +3 -0
- data/app/views/attachments/new.js.haml +3 -0
- data/app/views/attachments/show.html.haml +2 -0
- data/app/views/attachments/show.js.haml +3 -0
- data/app/views/attachments/update.js.haml +3 -0
- data/app/views/blogs/_form.html.haml +22 -0
- data/app/views/blogs/edit.html.haml +8 -0
- data/app/views/blogs/index.html.haml +21 -0
- data/app/views/blogs/index.xml.builder +27 -0
- data/app/views/blogs/new.html.haml +6 -0
- data/app/views/blogs/show.html.haml +25 -0
- data/app/views/discussions/_form.html.haml +16 -0
- data/app/views/discussions/edit.html.haml +7 -0
- data/app/views/discussions/index.html.haml +10 -0
- data/app/views/discussions/new.html.haml +25 -0
- data/app/views/discussions/show.html.haml +16 -0
- data/app/views/external_links/_fields_for.html.haml +2 -0
- data/app/views/external_links/_form.html.haml +18 -0
- data/app/views/external_links/_show.html.haml +7 -0
- data/app/views/external_links/create.js.haml +3 -0
- data/app/views/external_links/destroy.js.haml +3 -0
- data/app/views/external_links/edit.html.haml +7 -0
- data/app/views/external_links/edit.js.haml +3 -0
- data/app/views/external_links/index.html.haml +23 -0
- data/app/views/external_links/index.js.haml +3 -0
- data/app/views/external_links/new.html.haml +5 -0
- data/app/views/external_links/new.js.haml +3 -0
- data/app/views/external_links/show.html.haml +2 -0
- data/app/views/external_links/show.js.haml +3 -0
- data/app/views/external_links/update.js.haml +3 -0
- data/app/views/feedback_mailer/submit_feedback.html.haml +22 -0
- data/app/views/feedbacks/_form.html.haml +38 -0
- data/app/views/feedbacks/index.html.haml +27 -0
- data/app/views/feedbacks/new.html.haml +6 -0
- data/app/views/feedbacks/show.html.haml +19 -0
- data/app/views/forum_messages/_form.html.haml +6 -0
- data/app/views/forum_messages/index.html.haml +11 -0
- data/app/views/forum_messages/new.html.haml +5 -0
- data/app/views/forums/_form.html.haml +13 -0
- data/app/views/forums/edit.html.haml +7 -0
- data/app/views/forums/index.html.haml +23 -0
- data/app/views/forums/new.html.haml +5 -0
- data/app/views/forums/show.html.haml +20 -0
- data/app/views/galleries/_form.html.haml +30 -0
- data/app/views/galleries/_show.html.haml +21 -0
- data/app/views/galleries/edit.html.haml +7 -0
- data/app/views/galleries/index.html.haml +15 -0
- data/app/views/galleries/new.html.haml +5 -0
- data/app/views/galleries/show.html.haml +4 -0
- data/app/views/images/_form.html.haml +10 -0
- data/app/views/images/create.js.haml +3 -0
- data/app/views/images/destroy.js.haml +3 -0
- data/app/views/images/edit.html.haml +7 -0
- data/app/views/images/edit.js.haml +3 -0
- data/app/views/images/index.html.haml +17 -0
- data/app/views/images/index.js.haml +3 -0
- data/app/views/images/new.html.haml +5 -0
- data/app/views/images/new.js.haml +3 -0
- data/app/views/images/show.html.haml +5 -0
- data/app/views/images/show.js.haml +3 -0
- data/app/views/images/update.js.haml +3 -0
- data/app/views/layouts/application.html.haml +60 -0
- data/app/views/layouts/bare.html.haml +2 -0
- data/app/views/layouts/image_dialog.html.haml +18 -0
- data/app/views/loadbehind/_destroy.js.haml +3 -0
- data/app/views/loadbehind/_edit.js.haml +4 -0
- data/app/views/loadbehind/_errors.html.haml +5 -0
- data/app/views/loadbehind/_growl_template.html.haml +65 -0
- data/app/views/loadbehind/_show_box.html.haml +9 -0
- data/app/views/loadbehind/_view.js.haml +4 -0
- data/app/views/loadbehind/growl.js.haml +4 -0
- data/app/views/loadbehind/index.js.haml +4 -0
- data/app/views/menus/_form.html.haml +13 -0
- data/app/views/menus/edit.html.haml +7 -0
- data/app/views/menus/index.html.haml +19 -0
- data/app/views/menus/new.html.haml +5 -0
- data/app/views/menus/show.html.haml +7 -0
- data/app/views/pages/_child_pages_links.html.haml +5 -0
- data/app/views/pages/_control_panel.html.haml +15 -0
- data/app/views/pages/_form.html.haml +27 -0
- data/app/views/pages/_form_fields.html.haml +23 -0
- data/app/views/pages/_show.html.haml +4 -0
- data/app/views/pages/_show_attachment.html.haml +6 -0
- data/app/views/pages/_show_small.html.haml +2 -0
- data/app/views/pages/create.js.haml +3 -0
- data/app/views/pages/destroy.js.haml +3 -0
- data/app/views/pages/edit.html.haml +16 -0
- data/app/views/pages/edit.js.haml +4 -0
- data/app/views/pages/index.html.haml +19 -0
- data/app/views/pages/index.js.haml +3 -0
- data/app/views/pages/new.html.haml +5 -0
- data/app/views/pages/new.js.haml +3 -0
- data/app/views/pages/show.html.haml +18 -0
- data/app/views/pages/show.js.haml +3 -0
- data/app/views/pages/update.js.haml +3 -0
- data/app/views/profiles/_form.html.haml +26 -0
- data/app/views/profiles/edit.html.haml +7 -0
- data/app/views/profiles/index.html.haml +25 -0
- data/app/views/profiles/new.html.haml +5 -0
- data/app/views/profiles/show.html.haml +21 -0
- data/app/views/sitemaps/edit.html.haml +12 -0
- data/app/views/sitemaps/index.html.haml +83 -0
- data/app/views/sitemaps/index.json.erb +23 -0
- data/app/views/sitemaps/new.html.haml +8 -0
- data/app/views/sitemaps/new.js.erb +0 -0
- data/app/views/users/edit.html.haml +45 -0
- data/app/views/users/index.html.haml +19 -0
- data/config/amazon_s3.yml +15 -0
- data/db/migrate/0000_devise_create_users.rb +26 -0
- data/db/migrate/0010_add_fields_to_users.rb +28 -0
- data/db/migrate/0020_create_blogs.rb +16 -0
- data/db/migrate/0030_create_galleries.rb +15 -0
- data/db/migrate/0040_create_images.rb +17 -0
- data/db/migrate/0050_create_profiles.rb +24 -0
- data/db/migrate/0060_insert_admin_user_and_roles.rb +24 -0
- data/db/migrate/0070_create_pages.rb +16 -0
- data/db/migrate/0080_create_forums.rb +13 -0
- data/db/migrate/0090_create_discussions.rb +14 -0
- data/db/migrate/0100_create_forum_messages.rb +15 -0
- data/db/migrate/0110_create_access_control_entries.rb +23 -0
- data/db/migrate/0120_create_attachments.rb +17 -0
- data/db/migrate/0130_create_roles.rb +13 -0
- data/db/migrate/0140_create_feedbacks.rb +20 -0
- data/db/migrate/0150_create_external_links.rb +14 -0
- data/db/migrate/0160_create_sitemaps.rb +17 -0
- data/db/migrate/0170_create_menus.rb +14 -0
- data/db/migrate/0180_acts_as_taggable_on_migration.rb +28 -0
- data/db/migrate/20100912194121_add_stylesheet_to_pages.rb +9 -0
- data/db/migrate/20100913073354_add_position_to_access_control_entries.rb +9 -0
- data/init.rb +2 -0
- data/lib/{core_extensions.rb → generators/core_extensions.rb} +2 -2
- data/lib/generators/templates/haml/app/views/layouts/application.html.haml +0 -0
- data/lib/generators/wheels/wheels_generator.rb +2 -0
- data/lib/generators/wheels_update/wheels_update_generator.rb +1 -1
- data/lib/wheels/routes.rb +13 -2
- data/wheels.gemspec +254 -122
- metadata +268 -124
- data/README +0 -2
- data/lib/generators/wheels/recipes/public.rb +0 -9
- data/lib/generators/wheels_update/core_extensions.3.rb +0 -64
- data/lib/wheels/base.rb +0 -7
- data/test/functional/access_control_entries_controller_test.rb +0 -49
- data/test/functional/app_configs_controller_test.rb +0 -49
- data/test/functional/discussions_controller_test.rb +0 -49
- data/test/functional/external_links_controller_test.rb +0 -49
- data/test/functional/feedback_mailer_test.rb +0 -8
- data/test/functional/feedbacks_controller_test.rb +0 -49
- data/test/functional/forums_controller_test.rb +0 -49
- data/test/functional/layouts_controller_test.rb +0 -49
- data/test/functional/member_pages_controller_test.rb +0 -49
- data/test/functional/members_controller_test.rb +0 -8
- data/test/functional/menus_controller_test.rb +0 -49
- data/test/functional/pages_controller_test.rb +0 -49
- data/test/functional/product_revisions_controller_test.rb +0 -49
- data/test/performance/browsing_test.rb +0 -9
- data/test/test_helper.rb +0 -13
- data/test/unit/access_control_entry_test.rb +0 -8
- data/test/unit/app_config_test.rb +0 -8
- data/test/unit/attachment_test.rb +0 -8
- data/test/unit/discussion_test.rb +0 -8
- data/test/unit/external_link_test.rb +0 -8
- data/test/unit/feedback_test.rb +0 -8
- data/test/unit/forum_message_test.rb +0 -8
- data/test/unit/forum_test.rb +0 -8
- data/test/unit/helpers/access_control_entries_helper_test.rb +0 -4
- data/test/unit/helpers/app_configs_helper_test.rb +0 -4
- data/test/unit/helpers/discussions_helper_test.rb +0 -4
- data/test/unit/helpers/external_links_helper_test.rb +0 -4
- data/test/unit/helpers/feedbacks_helper_test.rb +0 -4
- data/test/unit/helpers/forums_helper_test.rb +0 -4
- data/test/unit/helpers/layouts_helper_test.rb +0 -4
- data/test/unit/helpers/member_pages_helper_test.rb +0 -4
- data/test/unit/helpers/members_helper_test.rb +0 -4
- data/test/unit/helpers/menus_helper_test.rb +0 -4
- data/test/unit/helpers/pages_helper_test.rb +0 -4
- data/test/unit/helpers/product_revisions_helper_test.rb +0 -4
- data/test/unit/layout_test.rb +0 -8
- data/test/unit/member_page_test.rb +0 -8
- data/test/unit/menu_test.rb +0 -8
- data/test/unit/page_revision_test.rb +0 -8
- data/test/unit/page_test.rb +0 -8
- data/test/unit/product_revision_test.rb +0 -8
- data/test/unit/settings_test.rb +0 -8
- data/test/unit/sitemap_test.rb +0 -8
- data/test/unit/user_test.rb +0 -8
- /data/{lib/generators/wheels/templates/haml/app/views/layouts/application.html.haml → app/views/sitemaps/edit.js.erb} +0 -0
- /data/lib/generators/{wheels/recipes → recipes}/cancan.rb +0 -0
- /data/lib/generators/{wheels/recipes → recipes}/cucumber.rb +0 -0
- /data/lib/generators/{wheels/recipes → recipes}/default.rb +0 -0
- /data/lib/generators/{wheels/recipes → recipes}/design.rb +0 -0
- /data/lib/generators/{wheels/recipes → recipes}/devise.rb +0 -0
- /data/lib/generators/{wheels/recipes → recipes}/factory_girl.rb +0 -0
- /data/lib/generators/{wheels/recipes → recipes}/haml.rb +0 -0
- /data/lib/generators/{wheels/recipes → recipes}/jquery.rb +0 -0
- /data/lib/generators/{wheels/recipes → recipes}/mongoid.rb +0 -0
- /data/lib/generators/{wheels/recipes → recipes}/postgresql.rb +0 -0
- /data/lib/generators/{wheels/recipes → recipes}/recipes.rb +0 -0
- /data/lib/generators/{wheels/recipes → recipes}/remarkable.rb +0 -0
- /data/lib/generators/{wheels/recipes → recipes}/rspec.rb +0 -0
- /data/lib/generators/{wheels/recipes → recipes}/wheels.rb +0 -0
- /data/lib/generators/{wheels_update/recipes/wheels.rb → recipes/wheels_update.rb} +0 -0
- /data/lib/generators/{wheels/snippets → snippets}/cucumber/database_config +0 -0
- /data/lib/generators/{wheels/templates → templates}/cancan/ability.rb +0 -0
- /data/lib/generators/{wheels/templates → templates}/database/postgresql.yml +0 -0
- /data/lib/generators/{wheels/templates → templates}/git/gitignore +0 -0
- /data/lib/generators/{wheels/templates → templates}/mongoid/features/step_definitions/mongoid_steps.rb +0 -0
- /data/lib/generators/{wheels/templates → templates}/mongoid/features/support/hooks.rb +0 -0
@@ -0,0 +1,43 @@
|
|
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 nav_content(&block)
|
20
|
+
@sidebar = true
|
21
|
+
content_for(:navigation) do
|
22
|
+
block.call
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def include_ckeditor
|
27
|
+
content_for :head do
|
28
|
+
javascript_include_tag('/ckeditor/ckeditor.js',
|
29
|
+
'/ckeditor/adapters/jquery.js',
|
30
|
+
"galleries/configure_ckeditor.js")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
def session_key_name
|
34
|
+
Rails.application.config.session_options[:key]
|
35
|
+
end
|
36
|
+
def make_session_string
|
37
|
+
arr = []
|
38
|
+
request.env['HTTP_COOKIE'].each_char{|c| arr.push(c[0].to_s)}
|
39
|
+
arr.join("x")
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,192 @@
|
|
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
|
+
|
@@ -0,0 +1,10 @@
|
|
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
|
+
|
@@ -0,0 +1,43 @@
|
|
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 :edit, User, :id => user.id
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,109 @@
|
|
1
|
+
class AccessControlEntry < ActiveRecord::Base
|
2
|
+
belongs_to :user
|
3
|
+
belongs_to :role
|
4
|
+
belongs_to :resource, :polymorphic=>true
|
5
|
+
validates :resource_type, :presence=>true
|
6
|
+
|
7
|
+
default_scope order(:position)
|
8
|
+
|
9
|
+
scope :by_resource, lambda {|resource_type, resource_id|
|
10
|
+
where(:resource_type=>resource_type).
|
11
|
+
where(:resource_id=>resource_id)
|
12
|
+
}
|
13
|
+
scope :by_role, lambda {|role_id|
|
14
|
+
where(:role_id=>role_id)
|
15
|
+
}
|
16
|
+
scope :by_class, lambda {|class_name|
|
17
|
+
where(:resource_type=>class_name)
|
18
|
+
}
|
19
|
+
|
20
|
+
def resource=(res)
|
21
|
+
@res = res
|
22
|
+
if res.is_a? Class then resource_type = res.name
|
23
|
+
else
|
24
|
+
resource_id = res.id
|
25
|
+
resource_type = res.class.name
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def resource
|
30
|
+
unless @res
|
31
|
+
if resource_id
|
32
|
+
@res = resource_type.constantize.find(resource_id) unless resource_type.empty?
|
33
|
+
else
|
34
|
+
@res = resource_type.constantize unless resource_type.empty?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
@res
|
38
|
+
end
|
39
|
+
|
40
|
+
def resource_class; resource_type.constantize unless resource_type.empty?; end;
|
41
|
+
|
42
|
+
def options
|
43
|
+
@options ||= (self.serialized_options ? eval(self.serialized_options) : {})
|
44
|
+
end
|
45
|
+
|
46
|
+
def options_str
|
47
|
+
options.map{|u,v| "#{u.inspect}=>#{v.is_numeric? ? v : v.inspect}"}.join(", ")
|
48
|
+
end
|
49
|
+
def options_str=(str)
|
50
|
+
opts = str.split(",").map(&:strip).map_hash{|keyval|
|
51
|
+
key, val = keyval.split("=>").map(&:strip)
|
52
|
+
val = val.to_i if val.is_numeric?
|
53
|
+
if key.index(":")
|
54
|
+
key = key.gsub(/\:/, "").to_sym
|
55
|
+
end
|
56
|
+
{key=>val}
|
57
|
+
}
|
58
|
+
|
59
|
+
@options = opts
|
60
|
+
self.serialized_options = opts.inspect
|
61
|
+
end
|
62
|
+
|
63
|
+
def configure(ability)
|
64
|
+
raise "I only like Ability" unless ability.class==Ability
|
65
|
+
able = self.can ? :can : :cannot
|
66
|
+
ability.send able, verb.to_sym, resource_type.try(:constantize), able_options
|
67
|
+
end
|
68
|
+
|
69
|
+
def able_options
|
70
|
+
resource.id ? options.merge({:id=>resource.id}) : options
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.can(verb, resource, options={})
|
74
|
+
AccessControlEntry.new(:can=>true, :verb=> verb, :resource=>resource, :options=>options )
|
75
|
+
end
|
76
|
+
def self.cannot(verb, resource, options)
|
77
|
+
AccessControlEntry.new(:can=>false, :verb=> verb, :resource=>resource, :options=>options )
|
78
|
+
end
|
79
|
+
|
80
|
+
def method_name
|
81
|
+
self.can ? :can : :cannot
|
82
|
+
end
|
83
|
+
|
84
|
+
def user_email
|
85
|
+
self.user.email if self.user
|
86
|
+
end
|
87
|
+
def user_email=(email)
|
88
|
+
self.user = User.find_by_email(email) unless email.blank?
|
89
|
+
end
|
90
|
+
|
91
|
+
def role=(role)
|
92
|
+
unless role.empty?
|
93
|
+
if role.kind_of? Role
|
94
|
+
self.role_id = role.id
|
95
|
+
else
|
96
|
+
role = role.to_s.camelize
|
97
|
+
if role.is_numeric?
|
98
|
+
self.role_id= role
|
99
|
+
else
|
100
|
+
self.role_id= Role.find_by_name(role).id
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
attr_protected :serialized_options
|
107
|
+
|
108
|
+
end
|
109
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class AppConfig < ActiveRecord::Base
|
2
|
+
has_many :sitemaps, :as=>:resource
|
3
|
+
after_save :reload
|
4
|
+
|
5
|
+
before_create :set_name
|
6
|
+
|
7
|
+
def self.[](name)
|
8
|
+
val = select{|t| t.name==name}[0].try(:value)
|
9
|
+
if val && (val==val.to_i.to_s)
|
10
|
+
val = val.to_i
|
11
|
+
end
|
12
|
+
val
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.current
|
16
|
+
@current ||= AppConfig.all
|
17
|
+
end
|
18
|
+
def reload
|
19
|
+
AppConfig.instance_variable_set '@current', nil
|
20
|
+
end
|
21
|
+
|
22
|
+
def set_name
|
23
|
+
self.name = sitemaps[0].try(:menu_text) unless self.name
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
data/app/models/blog.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
class Discussion < ActiveRecord::Base
|
2
|
+
belongs_to :forum
|
3
|
+
has_many :forum_messages
|
4
|
+
|
5
|
+
attr_accessor :new_message
|
6
|
+
after_save :save_new_message
|
7
|
+
|
8
|
+
def save_new_message
|
9
|
+
self.new_message.save if self.new_message
|
10
|
+
end
|
11
|
+
|
12
|
+
def new_message_attributes=(attributes)
|
13
|
+
unless attributes["body"].blank?
|
14
|
+
self.new_message ||= ForumMessage.new(:discussion=>self)
|
15
|
+
self.new_message.attributes = attributes
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class Feedback < ActiveRecord::Base
|
2
|
+
validates :email, :presence=>true, :email=>true
|
3
|
+
validates :name, :presence=>true, :length=>{:minimum=>6}
|
4
|
+
validates :phone
|
5
|
+
validates :subject, :presence=>true
|
6
|
+
|
7
|
+
def self.jq_validation
|
8
|
+
JQueryValidator.new
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
data/app/models/forum.rb
ADDED
data/app/models/image.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
class Image < ActiveRecord::Base
|
2
|
+
belongs_to :gallery
|
3
|
+
acts_as_taggable
|
4
|
+
has_attached_file :image,
|
5
|
+
:storage => :s3,
|
6
|
+
:s3_credentials => "#{Rails.root}/config/amazon_s3.yml",
|
7
|
+
:path => "/images/:user_email/:style/:filename",
|
8
|
+
:styles => {:large=>"700x700>", :medium => "300x300>", :thumb => "100x100>" }
|
9
|
+
end
|
10
|
+
|
data/app/models/menu.rb
ADDED
data/app/models/page.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
class Profile < ActiveRecord::Base
|
2
|
+
acts_as_tagger
|
3
|
+
belongs_to :user
|
4
|
+
validates_uniqueness_of :alias
|
5
|
+
has_attached_file :image,
|
6
|
+
:storage => :s3,
|
7
|
+
:s3_credentials => "#{Rails.root}/config/amazon_s3.yml",
|
8
|
+
:path => "/:style/:filename",
|
9
|
+
:styles => { :medium => "300x300>", :thumb => "100x100>" }
|
10
|
+
|
11
|
+
end
|
12
|
+
|
data/app/models/role.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
class Role < ActiveRecord::Base
|
2
|
+
has_many :users
|
3
|
+
has_many :access_control_entries
|
4
|
+
|
5
|
+
def self.root
|
6
|
+
@root ||= find_by_name("Super")
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.nobody
|
10
|
+
@nobody ||= find_by_name("Nobody")
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.user
|
14
|
+
@user ||= find_by_name("User")
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.admin
|
18
|
+
@admin ||= find_by_name("Admin")
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.collection_entries
|
22
|
+
roles = [["Not Set", nil]]
|
23
|
+
Role.all.map{|t| [t.name, t.id]}.each do |t|
|
24
|
+
roles << t
|
25
|
+
end
|
26
|
+
roles
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|