wheels 0.0.17 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. data/VERSION +1 -1
  2. data/app/controllers/blogs_controller.rb +7 -6
  3. data/app/controllers/galleries_controller.rb +3 -3
  4. data/app/controllers/pages_controller.rb +11 -0
  5. data/app/controllers/profiles_controller.rb +1 -1
  6. data/app/helpers/blogs_helper.rb +10 -0
  7. data/app/helpers/pages_helper.rb +11 -0
  8. data/app/models/ability.rb +20 -3
  9. data/app/models/blog.rb +2 -1
  10. data/app/models/image.rb +3 -1
  11. data/app/models/page.rb +5 -0
  12. data/app/models/page_revision.rb +2 -0
  13. data/app/models/profile.rb +1 -0
  14. data/app/models/tagging.rb +4 -0
  15. data/app/models/user.rb +17 -12
  16. data/app/views/blogs/_form.html.haml +4 -10
  17. data/app/views/blogs/index.html.haml +4 -0
  18. data/app/views/blogs/show.html.haml +3 -4
  19. data/app/views/galleries/_form.html.haml +3 -2
  20. data/app/views/galleries/_show.html.haml +2 -2
  21. data/app/views/galleries/show.html.haml +2 -2
  22. data/app/views/layouts/application.html.haml +48 -0
  23. data/app/views/pages/_form.html.haml +19 -0
  24. data/app/views/pages/edit.html.haml +7 -0
  25. data/app/views/pages/index.html.haml +21 -0
  26. data/app/views/pages/new.html.haml +5 -0
  27. data/app/views/pages/show.html.haml +6 -0
  28. data/db/migrate/create_blogs.rb +1 -1
  29. data/db/migrate/create_roles.rb +0 -3
  30. data/db/migrate/insert_admin_user_and_roles.rb +4 -4
  31. data/lib/generators/app_layout/LICENCE +20 -0
  32. data/lib/generators/app_layout/USAGE +8 -0
  33. data/lib/generators/app_layout/app_layout_generator.rb +18 -0
  34. data/lib/generators/app_layout/core_extensions.rb +51 -0
  35. data/lib/generators/update_wheels/LICENCE +20 -0
  36. data/lib/generators/update_wheels/USAGE +8 -0
  37. data/lib/generators/update_wheels/core_extensions.rb +51 -0
  38. data/lib/generators/update_wheels/recipes/wheels.rb +11 -0
  39. data/lib/generators/update_wheels/templates/cancan/ability.rb +13 -0
  40. data/lib/generators/update_wheels/templates/database/postgresql.yml +19 -0
  41. data/lib/generators/update_wheels/templates/git/gitignore +8 -0
  42. data/lib/generators/update_wheels/templates/haml/app/views/layouts/application.html.haml +9 -0
  43. data/lib/generators/update_wheels/templates/mongoid/features/step_definitions/mongoid_steps.rb +4 -0
  44. data/lib/generators/update_wheels/templates/mongoid/features/support/hooks.rb +3 -0
  45. data/lib/generators/update_wheels/update_wheels_generator.rb +43 -0
  46. data/lib/generators/wheels/recipes/cancan.rb +3 -3
  47. data/lib/generators/wheels/recipes/haml.rb +2 -2
  48. data/lib/generators/wheels/recipes/recipes.rb +164 -0
  49. data/lib/generators/wheels/recipes/wheels.rb +41 -35
  50. data/lib/generators/wheels/templates/haml/app/views/layouts/application.html.haml +0 -9
  51. data/lib/generators/wheels/views_generator.rb +15 -0
  52. data/lib/generators/wheels/wheels_generator.rb +1 -1
  53. data/lib/generators/wheels_views/LICENCE +20 -0
  54. data/lib/generators/wheels_views/USAGE +8 -0
  55. data/lib/generators/wheels_views/wheels_views_generator.rb +15 -0
  56. data/lib/wheels/action_view_helper_extensions.rb +9 -0
  57. data/lib/wheels/active_record_extensions.rb +44 -0
  58. data/lib/wheels/active_record_user_extensions.rb +34 -0
  59. data/lib/wheels/user.rb +32 -0
  60. data/lib/wheels/wheels_engine.rb +7 -0
  61. data/lib/wheels.rb +2 -0
  62. data/public/javascripts/galleries/configure_ckeditor.js +8 -0
  63. data/public/javascripts/jqUrl.js +28 -0
  64. data/public/stylesheets/dreamy.css +3 -1
  65. data/public/stylesheets/sass/dreamy.sass +3 -0
  66. data/public/stylesheets/sass/wheels.sass +25 -0
  67. data/wheels.gemspec +42 -2
  68. metadata +44 -4
@@ -0,0 +1,11 @@
1
+
2
+ stategies << lambda do
3
+ # migration_template 'db/migrate/add_fields_to_users.rb', 'db/migrate/add_fields_to_users'
4
+ # sleep 1
5
+
6
+ directory 'public', 'public'
7
+ unless no? "Update views as well?"
8
+ directory 'app/views', 'app/views'
9
+ end
10
+ end
11
+
@@ -0,0 +1,13 @@
1
+ class Ability
2
+ include CanCan::Ability
3
+
4
+ def initialize(user)
5
+ can :manage, :all
6
+ # if user.admin?
7
+ # can :manage, :all
8
+ # else
9
+ # can :read, :all
10
+ # end
11
+ end
12
+ end
13
+
@@ -0,0 +1,19 @@
1
+ development:
2
+ adapter: postgresql
3
+ encoding: unicode
4
+ database: %database_name%
5
+ pool: 5
6
+ username: %database_username%
7
+ password: %database_password%
8
+ host: localhost
9
+ port: 5432
10
+
11
+ # Warning: The database defined as "test" will be erased and
12
+ # re-generated from your development database when you run "rake".
13
+ # Do not set this db to the same as development or production.
14
+ test:
15
+ adapter: sqlite3
16
+ database: db/test.sqlite3
17
+ pool: 5
18
+ timeout: 5000
19
+
@@ -0,0 +1,8 @@
1
+ .ackrc
2
+ .rvmrc
3
+ config/database.yml
4
+ config/mongoid.yml
5
+ public/cache/
6
+ public/stylesheets/compiled/
7
+ public/system/*
8
+ tmp/restart.txt
@@ -0,0 +1,9 @@
1
+ !!! 5
2
+ %html
3
+ %head
4
+ = csrf_meta_tag
5
+ /[if lt IE 9]
6
+ = javascript_include_tag 'html5'
7
+ %body
8
+ = yield
9
+ = javascript_include_tag :defaults
@@ -0,0 +1,4 @@
1
+ Given /^an? (.+) exists with an? (.+) of "([^"]*)"$/ do |model, field, value|
2
+ factory_name = model.gsub(' ', '_')
3
+ Factory factory_name, field => value
4
+ end
@@ -0,0 +1,3 @@
1
+ Before do |scenario|
2
+ Mongoid.master.collections.select {|c| c.name !~ /system/ }.each(&:drop)
3
+ end
@@ -0,0 +1,43 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+ require 'rails/generators/generated_attribute'
4
+ require 'rails/generators/active_record'
5
+
6
+ class UpdateWheelsGenerator < Rails::Generators::Base
7
+ include Rails::Generators::Migration
8
+ require File.join(File.dirname(__FILE__), 'core_extensions.rb')
9
+ source_root File.expand_path('../../../../', __FILE__)
10
+ desc "Installs files needed for App Template gem."
11
+
12
+ def init
13
+ initialize_templater
14
+ end
15
+
16
+ def load_recipes
17
+ # required_recipes = %w(default jquery haml devise cancan postgresql)
18
+ # required_recipes.each {|required_recipe| apply recipe(required_recipe)}
19
+ apply recipe('wheels')
20
+ end
21
+
22
+ # def bundle_install
23
+ # run 'bundle install'
24
+ # end
25
+
26
+ def execute
27
+ execute_stategies
28
+ end
29
+
30
+ def init_git
31
+ git :add => "."
32
+ end
33
+
34
+ def self.next_migration_number(dirname)
35
+
36
+ if ActiveRecord::Base.timestamped_migrations
37
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
38
+ else
39
+ "%.3d" % (current_migration_number(dirname) + 1)
40
+ end
41
+ end
42
+ end
43
+
@@ -1,6 +1,6 @@
1
1
  gem 'cancan'
2
2
 
3
- stategies << lambda do
4
- create_file 'app/models/ability.rb', load_template('ability.rb', 'cancan')
5
- end
3
+ #stategies << lambda do
4
+ # create_file 'app/models/ability.rb', load_template('ability.rb', 'cancan')
5
+ #end
6
6
 
@@ -1,8 +1,8 @@
1
1
  gem 'haml'
2
2
 
3
3
  remove_file 'app/views/layouts/application.html.erb'
4
- create_file 'app/views/layouts/application.html.haml', load_template('app/views/layouts/application.html.haml','haml')
5
4
 
6
5
  initializer 'haml.rb',<<EOF
7
6
  Haml::Template.options[:format] = :html5
8
- EOF
7
+ EOF
8
+
@@ -0,0 +1,164 @@
1
+ gem 'cancan'
2
+ gsub_file 'Gemfile', /(gem "rspec-rails".*:group =>) \[:development, :test\]/, '\1 [:development, :test, :cucumber]'
3
+ gsub_file 'Gemfile', /(gem "factory_girl_rails".*:group =>) :test/, '\1 [:test, :cucumber]'
4
+
5
+ append_file 'Gemfile', <<-EOF
6
+ group :cucumber do
7
+ gem 'capybara'
8
+ gem 'cucumber-rails'
9
+ gem 'spork'
10
+ gem 'launchy'
11
+ end
12
+ EOF
13
+
14
+ # Delete all unnecessary files
15
+ remove_file "README"
16
+ remove_file "public/index.html"
17
+ remove_file "public/robots.txt"
18
+ remove_file "public/images/rails.png"
19
+
20
+ create_file 'README'
21
+ create_file 'log/.gitkeep'
22
+ create_file 'tmp/.gitkeep'
23
+
24
+ gsub_file 'config/application.rb', 'require "rails/test_unit/railtie"', '# require "rails/test_unit/railtie"'
25
+
26
+ get "http://html5shiv.googlecode.com/svn/trunk/html5.js", "public/javascripts/html5.js"
27
+
28
+ git :init
29
+
30
+ append_file '.gitignore', load_template('gitignore','git')
31
+
32
+ if template_options[:design] == "compass"
33
+ gem 'compass'
34
+
35
+ # TODO: support more than one framework from compass
36
+ compass_sass_dir = "app/stylesheets"
37
+ compass_css_dir = "public/stylesheets/compiled"
38
+
39
+ compass_command = "compass init rails . --using blueprint/semantic --css-dir=#{compass_css_dir} --sass-dir=#{compass_sass_dir} "
40
+
41
+ stategies << lambda do
42
+ puts "Beginning Compass setup"
43
+ run compass_command
44
+ puts "Compass has been setup"
45
+ end
46
+
47
+ end
48
+ gem 'devise', '1.1.rc2'
49
+ gem 'factory_girl_rails', :group => :test
50
+
51
+
52
+ create_file 'app/models/ability.rb', load_template('ability.rb', 'cancan')
53
+ generate 'cucumber:install --rspec --capybara --skip-database'
54
+ generate "devise:install"
55
+ generate "devise User"
56
+ route "devise_for :users"
57
+ inject_into_file 'spec/spec_helper.rb', "\nrequire 'factory_girl'", :after => "require 'rspec/rails'"
58
+ endgem 'haml'
59
+
60
+ remove_file 'app/views/layouts/application.html.erb'
61
+
62
+ initializer 'haml.rb',<<EOF
63
+ Haml::Template.options[:format] = :html5
64
+ EOF
65
+
66
+ # Initialize jQuery
67
+ get "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "public/javascripts/jquery.js"
68
+ get "http://github.com/rails/jquery-ujs/raw/master/src/rails.js", "public/javascripts/rails.js"
69
+
70
+ # Set default JavaScript files
71
+ environment "config.action_view.javascript_expansions = { :defaults => ['jquery', 'rails'] }"gem 'mongoid', '>= 2.0.0.beta.14'
72
+ gem 'bson_ext', '1.0.4'
73
+
74
+ stategies << lambda do
75
+ generate 'mongoid:config'
76
+ run 'cp config/mongoid.yml config/mongoid.yml.example'
77
+ end
78
+ gem 'pg'
79
+
80
+ stategies << lambda do
81
+ opts = {}
82
+ opts[:database_name] = ask("What's the name of the database?")
83
+ opts[:database_username] = ask("Database username?")
84
+ opts[:database_password] = ask("Password? *** Will show in plain text on your screen")
85
+ create_file 'config/database.yml',
86
+ load_template('postgresql.yml', 'database', opts)
87
+ end
88
+
89
+ gem 'remarkable_activemodel', '>=4.0.0.alpha4', :group => :test
90
+ if recipes.include? 'mongoid'
91
+ gem 'remarkable_mongoid', :group => :test
92
+
93
+ stategies << lambda do
94
+ inject_into_file 'spec/spec_helper.rb', "\nrequire 'remarkable/active_model'\nrequire 'remarkable/mongoid'", :after => "require 'rspec/rails'"
95
+ end
96
+ end
97
+
98
+ gem 'rspec-rails', '>= 2.0.0.beta.19', :group => [:development, :test]
99
+
100
+ stategies << lambda do
101
+ generate 'rspec:install'
102
+
103
+ spec_helper_path = 'spec/spec_helper.rb'
104
+
105
+ gsub_file spec_helper_path, 'config.fixture_path = "#{::Rails.root}/spec/fixtures"', ''
106
+ gsub_file spec_helper_path, /(config.use_transactional_fixtures = true)/, '# \1'
107
+
108
+ if recipes.include? 'mongoid'
109
+ mongoid_rspec_truncation = <<-MONGOID
110
+
111
+ config.before :each do
112
+ Mongoid.master.collections.select {|c| c.name !~ /system/ }.each(&:drop)
113
+ end
114
+
115
+ MONGOID
116
+
117
+ inject_into_file spec_helper_path, mongoid_rspec_truncation, :after => "# config.use_transactional_fixtures = true\n"
118
+ end
119
+ end
120
+
121
+ gem 'rails3-generators'
122
+ gem 'RedCloth'
123
+ gem 'acts-as-taggable-on'
124
+ gem 'da_huangs_ruby_extensions'
125
+ gem 'casey_jones'
126
+ gem 'inherited_resources', '1.1.2'
127
+ gem 'has_scope'
128
+ gem 'paperclip'
129
+ gem 'aws-s3'
130
+
131
+ route "root :to => \"blogs#index\""
132
+ route "wheels_resources"
133
+
134
+ migration_template 'db/migrate/add_fields_to_users.rb', 'db/migrate/add_fields_to_users'
135
+ generate "acts_as_taggable_on:migration"
136
+ migration_template 'db/migrate/create_blogs.rb', 'db/migrate/create_blogs'; sleep 1
137
+ migration_template 'db/migrate/create_galleries.rb', 'db/migrate/create_galleries'; sleep 1
138
+ migration_template 'db/migrate/create_images.rb', 'db/migrate/create_images'; sleep 1
139
+ migration_template 'db/migrate/create_profiles.rb', 'db/migrate/create_profiles'; sleep 1
140
+ migration_template 'db/migrate/create_roles.rb', 'db/migrate/create_roles'
141
+
142
+ user_attr = %w(user_email user_password user_first_name user_last_name user_blog_title user_alias)
143
+ for attrib in user_attr
144
+ class_eval "attr_accessor :#{attrib}"
145
+ send "#{attrib}=", ask("Please enter #{attrib}...")
146
+ end
147
+
148
+ migration_template 'db/migrate/insert_admin_user_and_roles.rb',
149
+ 'db/migrate/insert_admin_user_and_roles'
150
+ class_eval do
151
+ attr_accessor :bucket, :access_key_id, :secret_access_key
152
+ end
153
+ say ("If you have your S3 info handy, put it in now.")
154
+ for attribute in %w(bucket access_key_id secret_access_key)
155
+ self.send "#{attribute}=", ask("What's the #{attribute}?")
156
+ end
157
+
158
+
159
+ template 'config/amazon_s3.yml', 'config/amazon_s3.yml'
160
+ run "git submodule add git://github.com/tylergannon/ckeditor.git public/ckeditor"
161
+
162
+ directory 'public', 'public'
163
+ run "git submodule add -b rails3 http://github.com/mislav/will_paginate.git vendor/plugins/will_paginate"
164
+
@@ -1,47 +1,53 @@
1
- gem 'rails3-generators'
2
- gem 'RedCloth'
3
1
  gem 'acts-as-taggable-on'
4
- gem 'da_huangs_ruby_extensions'
2
+ gem 'aws-s3'
5
3
  gem 'casey_jones'
6
- gem 'inherited_resources', '1.1.2'
4
+ gem 'da_huangs_ruby_extensions'
5
+ gem 'devise', '1.1.rc2'
7
6
  gem 'has_scope'
7
+ gem 'inherited_resources', '1.1.2'
8
+ gem 'paperclip'
9
+ gem 'rails3-generators'
10
+ gem 'RedCloth'
11
+
12
+ route "root :to => \"blogs#index\""
13
+
14
+
15
+ user_attr = %w(user_email user_password user_first_name user_last_name user_blog_title user_alias)
16
+ for attrib in user_attr
17
+ class_eval "attr_accessor :#{attrib}"
18
+ send "#{attrib}=", ask("Please enter #{attrib}...")
19
+ end
20
+
21
+ class_eval do
22
+ attr_accessor :bucket, :access_key_id, :secret_access_key
23
+ end
24
+ say ("If you have your S3 info handy, put it in now.")
25
+ for attribute in %w(bucket access_key_id secret_access_key)
26
+ self.send "#{attribute}=", ask("What's the #{attribute}?")
27
+ end
28
+
29
+
30
+ template 'config/amazon_s3.yml', 'config/amazon_s3.yml'
31
+ run "git submodule add git://github.com/tylergannon/ckeditor.git public/ckeditor"
32
+
33
+ directory 'public', 'public'
34
+ run "git submodule add -b rails3 http://github.com/mislav/will_paginate.git vendor/plugins/will_paginate"
8
35
 
9
36
  stategies << lambda do
37
+ generate "devise:install"
38
+ generate "devise User"
10
39
  migration_template 'db/migrate/add_fields_to_users.rb', 'db/migrate/add_fields_to_users'
11
- sleep 1
12
- migration_template 'db/migrate/create_blogs.rb', 'db/migrate/create_blogs'
13
- sleep 1
14
- migration_template 'db/migrate/create_galleries.rb', 'db/migrate/create_galleries'
15
- sleep 1
16
- migration_template 'db/migrate/create_images.rb', 'db/migrate/create_images'
17
- sleep 1
18
- migration_template 'db/migrate/create_profiles.rb', 'db/migrate/create_profiles'
19
- sleep 1
40
+ generate "acts_as_taggable_on:migration"
41
+ migration_template 'db/migrate/create_blogs.rb', 'db/migrate/create_blogs'; sleep 1
42
+ migration_template 'db/migrate/create_galleries.rb', 'db/migrate/create_galleries'; sleep 1
43
+ migration_template 'db/migrate/create_images.rb', 'db/migrate/create_images'; sleep 1
44
+ migration_template 'db/migrate/create_profiles.rb', 'db/migrate/create_profiles'; sleep 1
20
45
  migration_template 'db/migrate/create_roles.rb', 'db/migrate/create_roles'
21
-
22
- user_attr = %w(user_email user_password user_first_name user_last_name user_blog_title user_alias)
23
- for attrib in user_attr
24
- class_eval "attr_accessor :#{attrib}"
25
- send "#{attrib}=", ask("Please enter #{attrib}...")
26
- end
27
-
28
46
  migration_template 'db/migrate/insert_admin_user_and_roles.rb',
29
- 'db/migrate/insert_admin_user_and_roles'
47
+ 'db/migrate/insert_admin_user_and_roles'
30
48
 
49
+ # create wheels_resources first so that devise_for :users will appear first in routes.rb
31
50
  route "wheels_resources"
32
- class_eval do
33
- attr_accessor :bucket, :access_key_id, :secret_access_key
34
- end
35
- say ("If you have your S3 info handy, put it in now.")
36
- for attribute in %w(bucket access_key_id secret_access_key)
37
- self.send "#{attribute}=", ask("What's the #{attribute}?")
38
- end
39
-
40
- template 'config/amazon_s3.yml', 'config/amazon_s3.yml'
41
- run "git submodule add git://github.com/tylergannon/ckeditor.git public/ckeditor"
42
-
43
- directory 'public', 'public'
44
- gem "will_paginate", :git=>"http://github.com/mislav/will_paginate.git",
45
- :branch=>"rails3"
51
+ route "devise_for :users"
46
52
  end
47
53
 
@@ -1,9 +0,0 @@
1
- !!! 5
2
- %html
3
- %head
4
- = csrf_meta_tag
5
- /[if lt IE 9]
6
- = javascript_include_tag 'html5'
7
- %body
8
- = yield
9
- = javascript_include_tag :defaults
@@ -0,0 +1,15 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+ require 'rails/generators/generated_attribute'
4
+ require 'rails/generators/active_record'
5
+
6
+ class ViewsGenerator < Rails::Generators::Base
7
+ include Rails::Generators::Migration
8
+ source_root File.expand_path('../../../../', __FILE__)
9
+ desc "Installs files needed for App Template gem."
10
+
11
+ def copy_files
12
+ directory 'app/views', 'app/views'
13
+ end
14
+ end
15
+
@@ -20,7 +20,7 @@ class WheelsGenerator < Rails::Generators::Base
20
20
  end
21
21
 
22
22
  def load_recipes
23
- required_recipes = %w(default jquery haml devise cancan postgresql)
23
+ required_recipes = %w(default jquery haml cancan postgresql)
24
24
  required_recipes.each {|required_recipe| apply recipe(required_recipe)}
25
25
 
26
26
  # apply recipe(ask("Which database? (m)ongoid or (p)ostgresql")=='m' ? 'mongoid' : 'postgresql')
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Kevin Faustino
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate app_template Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,15 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+ require 'rails/generators/generated_attribute'
4
+ require 'rails/generators/active_record'
5
+
6
+ class WheelsViewsGenerator < Rails::Generators::Base
7
+ include Rails::Generators::Migration
8
+ source_root File.expand_path('../../../../', __FILE__)
9
+ desc "Installs files needed for App Template gem."
10
+
11
+ def copy_files
12
+ directory 'app/views', 'app/views'
13
+ end
14
+ end
15
+
@@ -0,0 +1,9 @@
1
+ module ActionViewHelperExtensions
2
+ def super_user
3
+ @@super_user ||= User.where(:role_id=>Role.find_by_name("Super").id).first
4
+ end
5
+ end
6
+
7
+ ActionController::Base.send :include, ActionViewHelperExtensions
8
+ ActionController::Base.helper_method :super_user
9
+
@@ -0,0 +1,44 @@
1
+ module Wheels
2
+ module ActiveRecordExtensions
3
+ def commentable_tags
4
+ class_eval do
5
+ after_save.reject! {|callback| callback.method.to_s == 'save_tags' }
6
+
7
+ def save_commentable_tags
8
+ tagging_contexts.each do |context|
9
+ next unless tag_list_cache_set_on(context)
10
+
11
+ tag_list = tag_list_cache_on(context).uniq
12
+
13
+ # Do it normal like, but get the taggings, too.
14
+
15
+
16
+ # Find existing tags or create non-existing tags:
17
+ tag_list = ActsAsTaggableOn::Tag.find_or_create_all_with_like_by_name(tag_list)
18
+
19
+ current_tags = tags_on(context)
20
+ old_tags = current_tags - tag_list
21
+ new_tags = tag_list - current_tags
22
+
23
+ # Find taggings to remove:
24
+ old_taggings = taggings.where(:tagger_type => nil, :tagger_id => nil,
25
+ :context => context.to_s, :tag_id => old_tags).all
26
+
27
+ if old_taggings.present?
28
+ # Destroy old taggings:
29
+ ActsAsTaggableOn::Tagging.destroy_all :id => old_taggings.map(&:id)
30
+ end
31
+
32
+ # Create new taggings:
33
+ new_tags.each do |tag|
34
+ taggings.create!(:tag_id => tag.id, :context => context.to_s, :taggable => self)
35
+ end
36
+ end
37
+ end
38
+ after_save :save_commentable_tags
39
+
40
+ end
41
+ end
42
+ end
43
+ end
44
+
@@ -0,0 +1,34 @@
1
+ module Wheels
2
+ module ActiveRecordUserExtensions
3
+ def create_profile
4
+ self.profile ||= Profile.create(:user => self)
5
+ end
6
+
7
+ def role=(role)
8
+ if role.kind_of? Role
9
+ self.role_id = role.id
10
+ else
11
+ role = role.to_s.camelize
12
+ if role.is_numeric?
13
+ self.role_id= role
14
+ else
15
+ self.role_id= Role.find_by_name(role).id
16
+ end
17
+ end
18
+ end
19
+
20
+ def confirm!
21
+ self.confirmed_at = DateTime::now
22
+ save
23
+ end
24
+ end
25
+ end
26
+
27
+ User.send :include, Wheels::ActiveRecordExtensions
28
+
29
+ User.before_create :create_profile
30
+ User.belongs_to :role
31
+ User.has_many :blogs, :dependent => :destroy
32
+ User.has_one :profile, :dependent => :destroy
33
+ User.has_many :galleries, :dependent => :destroy
34
+
@@ -0,0 +1,32 @@
1
+ class User < ActiveRecord::Base
2
+ before_create :create_profile
3
+ belongs_to :role
4
+ has_many :blogs, :dependent => :destroy
5
+ has_one :profile, :dependent => :destroy
6
+ has_many :galleries, :dependent => :destroy
7
+
8
+
9
+ def create_profile
10
+ self.profile ||= Profile.create(:user => self)
11
+ end
12
+
13
+ def role=(role)
14
+ if role.kind_of? Role
15
+ self.role_id = role.id
16
+ else
17
+ role = role.to_s.camelize
18
+ if role.is_numeric?
19
+ self.role_id= role
20
+ else
21
+ self.role_id= Role.find_by_name(role).id
22
+ end
23
+ end
24
+ end
25
+
26
+ def confirm!
27
+ self.confirmed_at = DateTime::now
28
+ save
29
+ end
30
+
31
+ end
32
+
@@ -0,0 +1,7 @@
1
+ # lib/my_engine.rb
2
+ module WheelsEngine
3
+ class Engine < Rails::Engine
4
+ engine_name :wheels_engine
5
+ end
6
+ end
7
+
data/lib/wheels.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'wheels/wheels_engine.rb'
1
2
  require 'wheels/routes.rb'
2
3
  require 'wheels/action_controller_extensions.rb'
4
+ require 'wheels/action_view_helper_extensions.rb'
3
5
 
@@ -0,0 +1,8 @@
1
+
2
+ $(function(){
3
+ config = {
4
+ filebrowserBrowseUrl : '/galleries'
5
+ };
6
+ $('.ckeditor_textarea').ckeditor(config);
7
+ });
8
+
@@ -0,0 +1,28 @@
1
+ function QSObject(querystring){
2
+ //Create regular expression object to retrieve the qs part
3
+ var qsReg = new RegExp("[?][^#]*","i");
4
+ hRef = unescape(querystring);
5
+ var qsMatch = hRef.match(qsReg);
6
+
7
+ //removes the question mark from the url
8
+ qsMatch = new String(qsMatch);
9
+ qsMatch = qsMatch.substr(1, qsMatch.length -1);
10
+
11
+ //split it up
12
+ var rootArr = qsMatch.split("&");
13
+ for(i=0;i<rootArr.length;i++){
14
+ var tempArr = rootArr[i].split("=");
15
+ if(tempArr.length ==2){
16
+ tempArr[0] = unescape(tempArr[0]);
17
+ tempArr[1] = unescape(tempArr[1]);
18
+
19
+ this[tempArr[0]]= tempArr[1];
20
+ }
21
+ }
22
+ }
23
+
24
+ function queryParamFor(jsFile) {
25
+ url = $('script[src~='+jsFile+']').attr('src').toLowerCase();
26
+ return new QSObject(url);
27
+ }
28
+