blog_basic 0.1.6

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 (109) hide show
  1. data/Gemfile +24 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Manifest +0 -0
  4. data/README.md +186 -0
  5. data/Rakefile +47 -0
  6. data/app/admin/blog_basic_blog_posts.rb +9 -0
  7. data/app/admin/dashboards.rb +38 -0
  8. data/app/assets/images/rails.png +0 -0
  9. data/app/assets/javascripts/active_admin.js +1 -0
  10. data/app/assets/javascripts/application.js +9 -0
  11. data/app/assets/stylesheets/active_admin.css.scss +6 -0
  12. data/app/assets/stylesheets/application.css +7 -0
  13. data/app/controllers/application_controller.rb +3 -0
  14. data/app/controllers/blog_basic/app_controller.rb +27 -0
  15. data/app/controllers/blog_basic/application_controller.rb +4 -0
  16. data/app/controllers/blog_basic/blog_comments_controller.rb +69 -0
  17. data/app/controllers/blog_basic/blog_posts_controller.rb +149 -0
  18. data/app/controllers/blog_basic/sessions_controller.rb +32 -0
  19. data/app/controllers/blog_basic/tags_controller.rb +11 -0
  20. data/app/helpers/application_helper.rb +2 -0
  21. data/app/helpers/blog_basic/application_helper.rb +21 -0
  22. data/app/helpers/blog_basic/blog_posts_helper.rb +17 -0
  23. data/app/helpers/blog_basic/shared_helper.rb +36 -0
  24. data/app/helpers/blog_basic/tags_helper.rb +5 -0
  25. data/app/models/admin_user.rb +9 -0
  26. data/app/models/blog_basic/blog_comment.rb +78 -0
  27. data/app/models/blog_basic/blog_content.rb +4 -0
  28. data/app/models/blog_basic/blog_image.rb +23 -0
  29. data/app/models/blog_basic/blog_post.rb +104 -0
  30. data/app/models/blog_basic/session.rb +5 -0
  31. data/app/models/blog_basic/user.rb +22 -0
  32. data/app/views/blog_basic/blog_comments/_new_blog_comment.html.erb +43 -0
  33. data/app/views/blog_basic/blog_posts/_admin_links.html.erb +9 -0
  34. data/app/views/blog_basic/blog_posts/_blog_post.html.erb +62 -0
  35. data/app/views/blog_basic/blog_posts/_comment.html.erb +18 -0
  36. data/app/views/blog_basic/blog_posts/_comments.html.erb +6 -0
  37. data/app/views/blog_basic/blog_posts/_form.html.erb +133 -0
  38. data/app/views/blog_basic/blog_posts/_image.html.erb +20 -0
  39. data/app/views/blog_basic/blog_posts/drafts.html.erb +21 -0
  40. data/app/views/blog_basic/blog_posts/edit.html.erb +6 -0
  41. data/app/views/blog_basic/blog_posts/index.atom.builder +12 -0
  42. data/app/views/blog_basic/blog_posts/index.html.erb +31 -0
  43. data/app/views/blog_basic/blog_posts/new.html.erb +6 -0
  44. data/app/views/blog_basic/blog_posts/show.html.erb +8 -0
  45. data/app/views/blog_basic/shared/_footer.html.erb +15 -0
  46. data/app/views/blog_basic/shared/_index_top.html.erb +12 -0
  47. data/app/views/blog_basic/shared/_topbar.html.erb +24 -0
  48. data/app/views/layouts/application.html.erb +14 -0
  49. data/blog_basic.gemspec +57 -0
  50. data/config/routes.rb +21 -0
  51. data/db/migrate/1_blog_tables.rb +86 -0
  52. data/init.rb +9 -0
  53. data/lib/akismetor.rb +77 -0
  54. data/lib/blog_basic/active_admin.rb +103 -0
  55. data/lib/blog_basic/blog_basic_model_helper.rb +85 -0
  56. data/lib/blog_basic/blog_conf.rb +36 -0
  57. data/lib/blog_basic/engine.rb +13 -0
  58. data/lib/blog_basic/engine.rb.backup +80 -0
  59. data/lib/blog_basic.rb +16 -0
  60. data/lib/generators/blog_basic/create_assets/blog_assets_generator.rb +49 -0
  61. data/lib/generators/blog_basic/create_assets/templates/blog_comments_migration.rb +23 -0
  62. data/lib/generators/blog_basic/create_assets/templates/blog_images_migration.rb +19 -0
  63. data/lib/generators/blog_basic/create_assets/templates/blog_posts_migration.rb +17 -0
  64. data/lib/generators/blog_basic/create_assets/templates/config/blog_basic.yml +52 -0
  65. data/lib/generators/blog_basic/create_assets/templates/syntax/active4d.css +114 -0
  66. data/lib/generators/blog_basic/create_assets/templates/syntax/all_hallows_eve.css +72 -0
  67. data/lib/generators/blog_basic/create_assets/templates/syntax/amy.css +147 -0
  68. data/lib/generators/blog_basic/create_assets/templates/syntax/blackboard.css +88 -0
  69. data/lib/generators/blog_basic/create_assets/templates/syntax/brilliance_black.css +605 -0
  70. data/lib/generators/blog_basic/create_assets/templates/syntax/brilliance_dull.css +599 -0
  71. data/lib/generators/blog_basic/create_assets/templates/syntax/cobalt.css +149 -0
  72. data/lib/generators/blog_basic/create_assets/templates/syntax/dawn.css +121 -0
  73. data/lib/generators/blog_basic/create_assets/templates/syntax/eiffel.css +121 -0
  74. data/lib/generators/blog_basic/create_assets/templates/syntax/espresso_libre.css +109 -0
  75. data/lib/generators/blog_basic/create_assets/templates/syntax/idle.css +62 -0
  76. data/lib/generators/blog_basic/create_assets/templates/syntax/iplastic.css +80 -0
  77. data/lib/generators/blog_basic/create_assets/templates/syntax/lazy.css +73 -0
  78. data/lib/generators/blog_basic/create_assets/templates/syntax/mac_classic.css +123 -0
  79. data/lib/generators/blog_basic/create_assets/templates/syntax/magicwb_amiga.css +104 -0
  80. data/lib/generators/blog_basic/create_assets/templates/syntax/pastels_on_dark.css +188 -0
  81. data/lib/generators/blog_basic/create_assets/templates/syntax/slush_poppies.css +85 -0
  82. data/lib/generators/blog_basic/create_assets/templates/syntax/spacecadet.css +51 -0
  83. data/lib/generators/blog_basic/create_assets/templates/syntax/sunburst.css +180 -0
  84. data/lib/generators/blog_basic/create_assets/templates/syntax/twilight.css +137 -0
  85. data/lib/generators/blog_basic/create_assets/templates/syntax/zenburnesque.css +91 -0
  86. data/lib/generators/blog_basic/install/install_generator.rb +53 -0
  87. data/lib/generators/blog_basic/install/templates/active_admin.rb +103 -0
  88. data/lib/generators/blog_basic/install/templates/blog_basic.yml +52 -0
  89. data/lib/generators/blog_basic/install/templates/blog_kit.css +75 -0
  90. data/lib/generators/blog_basic/install/templates/devise.en.yml +58 -0
  91. data/lib/generators/blog_basic/install/templates/devise.rb +209 -0
  92. data/lib/generators/blog_basic/install/templates/migrations/1_blog_tables.rb +86 -0
  93. data/lib/generators/blog_basic/install/templates/migrations/20111213104240_devise_create_admin_users.rb +28 -0
  94. data/lib/generators/blog_basic/install/templates/migrations/20111213114257_create_admin_notes.rb +16 -0
  95. data/lib/generators/blog_basic/install/templates/migrations/20111213114258_move_admin_notes_to_comments.rb +25 -0
  96. data/lib/generators/blog_basic/install/templates/omniauth.rb.erb +10 -0
  97. data/lib/tasks/blog_basic_tasks.rake +0 -0
  98. data/lib/url_validator.rb +24 -0
  99. data/test/database.yml +4 -0
  100. data/test/fixtures/admin_users.yml +11 -0
  101. data/test/functional/blog_assets_generator_test.rb +35 -0
  102. data/test/functional/blog_comments_controller_test.rb +0 -0
  103. data/test/functional/blog_posts_controller_test.rb +84 -0
  104. data/test/performance/browsing_test.rb +12 -0
  105. data/test/schema.rb +61 -0
  106. data/test/test_helper.rb +13 -0
  107. data/test/unit/admin_user_test.rb +7 -0
  108. data/uninstall.rb +1 -0
  109. metadata +310 -0
@@ -0,0 +1,209 @@
1
+ # Use this hook to configure devise mailer, warden hooks and so forth.
2
+ # Many of these configuration options can be set straight in your model.
3
+ Devise.setup do |config|
4
+ # ==> Mailer Configuration
5
+ # Configure the e-mail address which will be shown in Devise::Mailer,
6
+ # note that it will be overwritten if you use your own mailer class with default "from" parameter.
7
+ config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
8
+
9
+ # Configure the class responsible to send e-mails.
10
+ # config.mailer = "Devise::Mailer"
11
+
12
+ # ==> ORM configuration
13
+ # Load and configure the ORM. Supports :active_record (default) and
14
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
15
+ # available as additional gems.
16
+ require 'devise/orm/active_record'
17
+
18
+ # ==> Configuration for any authentication mechanism
19
+ # Configure which keys are used when authenticating a user. The default is
20
+ # just :email. You can configure it to use [:username, :subdomain], so for
21
+ # authenticating a user, both parameters are required. Remember that those
22
+ # parameters are used only when authenticating and not when retrieving from
23
+ # session. If you need permissions, you should implement that in a before filter.
24
+ # You can also supply a hash where the value is a boolean determining whether
25
+ # or not authentication should be aborted when the value is not present.
26
+ # config.authentication_keys = [ :email ]
27
+
28
+ # Configure parameters from the request object used for authentication. Each entry
29
+ # given should be a request method and it will automatically be passed to the
30
+ # find_for_authentication method and considered in your model lookup. For instance,
31
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
32
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
33
+ # config.request_keys = []
34
+
35
+ # Configure which authentication keys should be case-insensitive.
36
+ # These keys will be downcased upon creating or modifying a user and when used
37
+ # to authenticate or find a user. Default is :email.
38
+ config.case_insensitive_keys = [ :email ]
39
+
40
+ # Configure which authentication keys should have whitespace stripped.
41
+ # These keys will have whitespace before and after removed upon creating or
42
+ # modifying a user and when used to authenticate or find a user. Default is :email.
43
+ config.strip_whitespace_keys = [ :email ]
44
+
45
+ # Tell if authentication through request.params is enabled. True by default.
46
+ # config.params_authenticatable = true
47
+
48
+ # Tell if authentication through HTTP Basic Auth is enabled. False by default.
49
+ # config.http_authenticatable = false
50
+
51
+ # If http headers should be returned for AJAX requests. True by default.
52
+ # config.http_authenticatable_on_xhr = true
53
+
54
+ # The realm used in Http Basic Authentication. "Application" by default.
55
+ # config.http_authentication_realm = "Application"
56
+
57
+ # It will change confirmation, password recovery and other workflows
58
+ # to behave the same regardless if the e-mail provided was right or wrong.
59
+ # Does not affect registerable.
60
+ # config.paranoid = true
61
+
62
+ # ==> Configuration for :database_authenticatable
63
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
64
+ # using other encryptors, it sets how many times you want the password re-encrypted.
65
+ #
66
+ # Limiting the stretches to just one in testing will increase the performance of
67
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
68
+ # a value less than 10 in other environments.
69
+ config.stretches = Rails.env.test? ? 1 : 10
70
+
71
+ # Setup a pepper to generate the encrypted password.
72
+ # config.pepper = "0fb64602cf316363ccdbce6b620c234777821e5bf9c214590401d4b8f90648b2f5376c7c244852654f5ffb5151d87fbeacbd5801d438cf37a9e968ab7aa71e0f"
73
+
74
+ # ==> Configuration for :confirmable
75
+ # A period that the user is allowed to access the website even without
76
+ # confirming his account. For instance, if set to 2.days, the user will be
77
+ # able to access the website for two days without confirming his account,
78
+ # access will be blocked just in the third day. Default is 0.days, meaning
79
+ # the user cannot access the website without confirming his account.
80
+ # config.confirm_within = 2.days
81
+
82
+ # Defines which key will be used when confirming an account
83
+ # config.confirmation_keys = [ :email ]
84
+
85
+ # ==> Configuration for :rememberable
86
+ # The time the user will be remembered without asking for credentials again.
87
+ # config.remember_for = 2.weeks
88
+
89
+ # If true, a valid remember token can be re-used between multiple browsers.
90
+ # config.remember_across_browsers = true
91
+
92
+ # If true, extends the user's remember period when remembered via cookie.
93
+ # config.extend_remember_period = false
94
+
95
+ # If true, uses the password salt as remember token. This should be turned
96
+ # to false if you are not using database authenticatable.
97
+ config.use_salt_as_remember_token = true
98
+
99
+ # Options to be passed to the created cookie. For instance, you can set
100
+ # :secure => true in order to force SSL only cookies.
101
+ # config.cookie_options = {}
102
+
103
+ # ==> Configuration for :validatable
104
+ # Range for password length. Default is 6..128.
105
+ # config.password_length = 6..128
106
+
107
+ # Email regex used to validate email formats. It simply asserts that
108
+ # an one (and only one) @ exists in the given string. This is mainly
109
+ # to give user feedback and not to assert the e-mail validity.
110
+ # config.email_regexp = /\A[^@]+@[^@]+\z/
111
+
112
+ # ==> Configuration for :timeoutable
113
+ # The time you want to timeout the user session without activity. After this
114
+ # time the user will be asked for credentials again. Default is 30 minutes.
115
+ # config.timeout_in = 30.minutes
116
+
117
+ # ==> Configuration for :lockable
118
+ # Defines which strategy will be used to lock an account.
119
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
120
+ # :none = No lock strategy. You should handle locking by yourself.
121
+ # config.lock_strategy = :failed_attempts
122
+
123
+ # Defines which key will be used when locking and unlocking an account
124
+ # config.unlock_keys = [ :email ]
125
+
126
+ # Defines which strategy will be used to unlock an account.
127
+ # :email = Sends an unlock link to the user email
128
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
129
+ # :both = Enables both strategies
130
+ # :none = No unlock strategy. You should handle unlocking by yourself.
131
+ # config.unlock_strategy = :both
132
+
133
+ # Number of authentication tries before locking an account if lock_strategy
134
+ # is failed attempts.
135
+ # config.maximum_attempts = 20
136
+
137
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
138
+ # config.unlock_in = 1.hour
139
+
140
+ # ==> Configuration for :recoverable
141
+ #
142
+ # Defines which key will be used when recovering the password for an account
143
+ # config.reset_password_keys = [ :email ]
144
+
145
+ # Time interval you can reset your password with a reset password key.
146
+ # Don't put a too small interval or your users won't have the time to
147
+ # change their passwords.
148
+ config.reset_password_within = 2.hours
149
+
150
+ # ==> Configuration for :encryptable
151
+ # Allow you to use another encryption algorithm besides bcrypt (default). You can use
152
+ # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
153
+ # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
154
+ # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
155
+ # REST_AUTH_SITE_KEY to pepper)
156
+ # config.encryptor = :sha512
157
+
158
+ # ==> Configuration for :token_authenticatable
159
+ # Defines name of the authentication token params key
160
+ # config.token_authentication_key = :auth_token
161
+
162
+ # If true, authentication through token does not store user in session and needs
163
+ # to be supplied on each request. Useful if you are using the token as API token.
164
+ # config.stateless_token = false
165
+
166
+ # ==> Scopes configuration
167
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
168
+ # "users/sessions/new". It's turned off by default because it's slower if you
169
+ # are using only default views.
170
+ # config.scoped_views = false
171
+
172
+ # Configure the default scope given to Warden. By default it's the first
173
+ # devise role declared in your routes (usually :user).
174
+ # config.default_scope = :user
175
+
176
+ # Configure sign_out behavior.
177
+ # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
178
+ # The default is true, which means any logout action will sign out all active scopes.
179
+ # config.sign_out_all_scopes = true
180
+
181
+ # ==> Navigation configuration
182
+ # Lists the formats that should be treated as navigational. Formats like
183
+ # :html, should redirect to the sign in page when the user does not have
184
+ # access, but formats like :xml or :json, should return 401.
185
+ #
186
+ # If you have any extra navigational formats, like :iphone or :mobile, you
187
+ # should add them to the navigational formats lists.
188
+ #
189
+ # The :"*/*" and "*/*" formats below is required to match Internet
190
+ # Explorer requests.
191
+ # config.navigational_formats = [:"*/*", "*/*", :html]
192
+
193
+ # The default HTTP method used to sign out a resource. Default is :delete.
194
+ config.sign_out_via = :delete
195
+
196
+ # ==> OmniAuth
197
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
198
+ # up on your models and hooks.
199
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
200
+
201
+ # ==> Warden configuration
202
+ # If you want to use other strategies, that are not supported by Devise, or
203
+ # change the failure app, you can configure them inside the config.warden block.
204
+ #
205
+ # config.warden do |manager|
206
+ # manager.intercept_401 = false
207
+ # manager.default_strategies(:scope => :user).unshift :some_external_strategy
208
+ # end
209
+ end
@@ -0,0 +1,86 @@
1
+ class BlogTables < ActiveRecord::Migration
2
+
3
+ def up
4
+ create_table "blog_basic_blog_comments", :force => true do |t|
5
+ t.integer "blog_post_id"
6
+ t.integer "user_id"
7
+ t.string "user_ip"
8
+ t.string "user_agent"
9
+ t.string "referrer"
10
+ t.string "name"
11
+ t.string "site_url"
12
+ t.string "email"
13
+ t.text "body"
14
+ t.datetime "created_at"
15
+ end
16
+
17
+ add_index "blog_basic_blog_comments", ["blog_post_id"], :name => "index_blog_comments_on_blog_post_id"
18
+
19
+ create_table "blog_basic_blog_contents", :force => true do |t|
20
+ t.string "title"
21
+ t.text "content"
22
+ t.integer "blog_post_id"
23
+ t.datetime "created_at"
24
+ t.datetime "updated_at"
25
+ end
26
+
27
+ create_table "blog_basic_blog_images", :force => true do |t|
28
+ t.string "image_file_name"
29
+ t.string "image_content_type"
30
+ t.integer "image_file_size"
31
+ t.datetime "image_updated_at"
32
+ t.integer "blog_post_id"
33
+ t.datetime "created_at"
34
+ t.datetime "updated_at"
35
+ end
36
+
37
+ add_index "blog_basic_blog_images", ["blog_post_id"], :name => "index_blog_images_on_blog_post_id"
38
+
39
+ create_table "blog_basic_blog_posts", :force => true do |t|
40
+ t.string "title", :null => false
41
+ t.text "body"
42
+ t.datetime "created_at"
43
+ t.datetime "updated_at"
44
+ t.integer "user_id"
45
+ t.datetime "published_at"
46
+ t.integer "published", :default => 0, :null => false
47
+ t.integer "parent_id"
48
+ end
49
+
50
+ create_table "blog_basic_sessions", :force => true do |t|
51
+ t.datetime "created_at"
52
+ t.datetime "updated_at"
53
+ end
54
+
55
+ create_table "taggings", :force => true do |t|
56
+ t.integer "tag_id"
57
+ t.integer "taggable_id"
58
+ t.string "taggable_type"
59
+ t.integer "tagger_id"
60
+ t.string "tagger_type"
61
+ t.string "context"
62
+ t.datetime "created_at"
63
+ end
64
+
65
+ add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
66
+ add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context"
67
+
68
+ create_table "tags", :force => true do |t|
69
+ t.string "name"
70
+ end
71
+
72
+ create_table "blog_basic_users", :force => true do |t|
73
+ t.string "email"
74
+ t.string "first_name"
75
+ t.string "last_name"
76
+ t.string "identifier_url"
77
+ t.datetime "created_at"
78
+ t.datetime "updated_at"
79
+ end
80
+
81
+ add_index "blog_basic_users", ["identifier_url"], :name => "index_users_on_identifier_url", :unique => true
82
+ end
83
+
84
+ def down
85
+ end
86
+ end
@@ -0,0 +1,28 @@
1
+ class DeviseCreateAdminUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table(:admin_users) do |t|
4
+ t.database_authenticatable :null => false
5
+ t.recoverable
6
+ t.rememberable
7
+ t.trackable
8
+
9
+ # t.encryptable
10
+ # t.confirmable
11
+ # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
12
+ # t.token_authenticatable
13
+
14
+
15
+ t.timestamps
16
+ end
17
+
18
+ # Create a default user
19
+ AdminUser.create!(:email => 'admin@example.com', :password => 'password', :password_confirmation => 'password')
20
+
21
+ add_index :admin_users, :email, :unique => true
22
+ add_index :admin_users, :reset_password_token, :unique => true
23
+ # add_index :admin_users, :confirmation_token, :unique => true
24
+ # add_index :admin_users, :unlock_token, :unique => true
25
+ # add_index :admin_users, :authentication_token, :unique => true
26
+ end
27
+
28
+ end
@@ -0,0 +1,16 @@
1
+ class CreateAdminNotes < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :admin_notes do |t|
4
+ t.references :resource, :polymorphic => true, :null => false
5
+ t.references :admin_user, :polymorphic => true
6
+ t.text :body
7
+ t.timestamps
8
+ end
9
+ add_index :admin_notes, [:resource_type, :resource_id]
10
+ add_index :admin_notes, [:admin_user_type, :admin_user_id]
11
+ end
12
+
13
+ def self.down
14
+ drop_table :admin_notes
15
+ end
16
+ end
@@ -0,0 +1,25 @@
1
+ class MoveAdminNotesToComments < ActiveRecord::Migration
2
+ def self.up
3
+ remove_index :admin_notes, [:admin_user_type, :admin_user_id]
4
+ rename_table :admin_notes, :active_admin_comments
5
+ rename_column :active_admin_comments, :admin_user_type, :author_type
6
+ rename_column :active_admin_comments, :admin_user_id, :author_id
7
+ add_column :active_admin_comments, :namespace, :string
8
+ add_index :active_admin_comments, [:namespace]
9
+ add_index :active_admin_comments, [:author_type, :author_id]
10
+
11
+ # Update all the existing comments to the default namespace
12
+ say "Updating any existing comments to the #{ActiveAdmin.application.default_namespace} namespace."
13
+ execute "UPDATE active_admin_comments SET namespace='#{ActiveAdmin.application.default_namespace}'"
14
+ end
15
+
16
+ def self.down
17
+ remove_index :active_admin_comments, :column => [:author_type, :author_id]
18
+ remove_index :active_admin_comments, :column => [:namespace]
19
+ remove_column :active_admin_comments, :namespace
20
+ rename_column :active_admin_comments, :author_id, :admin_user_id
21
+ rename_column :active_admin_comments, :author_type, :admin_user_type
22
+ rename_table :active_admin_comments, :admin_notes
23
+ add_index :admin_notes, [:admin_user_type, :admin_user_id]
24
+ end
25
+ end
@@ -0,0 +1,10 @@
1
+ require 'omniauth'
2
+ require 'omniauth-github'
3
+ require 'omniauth-openid'
4
+ require 'openid/store/filesystem'
5
+
6
+ Rails.application.config.middleware.use OmniAuth::Builder do
7
+ #provider :openid, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
8
+ provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'] # see https://github.com/account/applications
9
+ provider :open_id, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
10
+ end
File without changes
@@ -0,0 +1,24 @@
1
+ class UrlValidator < ActiveModel::EachValidator
2
+ def initialize(options)
3
+ super
4
+
5
+ @domain = options[:domain]
6
+ @permissible_schemes = options[:schemes] || %w(http https)
7
+ @error_message = options[:message] || 'is not a valid url'
8
+ end
9
+
10
+ def validate_each(record, attribute, value)
11
+ if URI::regexp(@permissible_schemes).match(value)
12
+ begin
13
+ uri = URI.parse(value)
14
+ if @domain
15
+ record.errors.add(attribute, 'does not belong to domain', :value => value) unless uri.host == @domain || uri.host.ends_with?(".#{@domain}")
16
+ end
17
+ rescue URI::InvalidURIError
18
+ record.errors.add(attribute, @error_message, :value => value)
19
+ end
20
+ else
21
+ record.errors.add(attribute, @error_message, :value => value)
22
+ end
23
+ end
24
+ end
data/test/database.yml ADDED
@@ -0,0 +1,4 @@
1
+ sqlite3:
2
+ :adapter: sqlite3
3
+ :database: vendor/plugins/blog_kit/test/blog_kit.sqlite3.db
4
+
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ # This model initially had no columns defined. If you add columns to the
4
+ # model remove the '{}' from the fixture names and add the columns immediately
5
+ # below each fixture, per the syntax in the comments below
6
+ #
7
+ one: {}
8
+ # column: value
9
+ #
10
+ two: {}
11
+ # column: value
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+ require 'rails/generators'
3
+
4
+ class BlogAssetsGeneratorTest < Test::Unit::TestCase
5
+ def setup
6
+ FileUtils.mkdir_p(fake_rails_root)
7
+ FileUtils.mkdir_p(fake_rails_root + '/config')
8
+ FileUtils.mkdir_p(fake_rails_root + '/public/stylesheets')
9
+ @original_files = file_list
10
+ end
11
+
12
+ def teardown
13
+ ActiveRecord::Base.pluralize_table_names = true
14
+ FileUtils.rm_r(fake_rails_root)
15
+ end
16
+
17
+ def test_generates_correct_file_name
18
+ Rails::Generators.invoke("blog_assets", [], :destination_root => fake_rails_root)
19
+ new_files = (file_list - @original_files)
20
+ assert_includes_with_regex /create_blog_comments/, new_files
21
+ assert_includes_with_regex /create_blog_posts/, new_files
22
+ assert_includes_with_regex /blog_kit.yml/, new_files
23
+ end
24
+
25
+ private
26
+ def fake_rails_root
27
+ File.join(File.dirname(__FILE__), 'rails_root')
28
+ end
29
+
30
+ def file_list
31
+ Dir.glob(File.join(fake_rails_root, "db", "migrate", "*")) +
32
+ Dir.glob(File.join(fake_rails_root, "config", "*"))
33
+ end
34
+
35
+ end
File without changes
@@ -0,0 +1,84 @@
1
+ # require File.dirname(__FILE__) + '/../test_helper.rb'
2
+ #
3
+ # class BlogPostsControllerTest < ActionController::TestCase
4
+ # def setup
5
+ # load_schema
6
+ #
7
+ # setup_user
8
+ # end
9
+ #
10
+ # def post_attrs
11
+ # {
12
+ # :title => 'Blog Title',
13
+ # :body => 'Test Body',
14
+ # :user_id => 1
15
+ # }
16
+ # end
17
+ #
18
+ # test "should get index" do
19
+ # get :index
20
+ # assert_response :success
21
+ # assert_not_nil assigns(:blog_posts)
22
+ # end
23
+ #
24
+ # test "should get new" do
25
+ # get :new
26
+ # assert_response :success
27
+ # end
28
+ #
29
+ # test "should create post" do
30
+ # assert_difference('BlogPost.count') do
31
+ # post :create, :blog_post => post_attrs
32
+ # end
33
+ #
34
+ # assert_redirected_to blog_post_path(assigns(:blog_post))
35
+ # end
36
+ #
37
+ # test "should only let admins create posts" do
38
+ # @user.admin = false
39
+ # @user.save
40
+ #
41
+ # assert_no_difference('BlogPost.count') do
42
+ # post :create, :blog_post => post_attrs
43
+ # end
44
+ #
45
+ # assert_redirected_to blog_posts_path
46
+ # end
47
+ #
48
+ # test "should show post" do
49
+ # blog_post = BlogPost.create(post_attrs.merge(:user_id => @user.id))
50
+ # get :show, :id => blog_post.to_param
51
+ # assert_response :success
52
+ # end
53
+ #
54
+ # test "should get edit" do
55
+ # blog_post = BlogPost.create(post_attrs.merge(:user_id => @user.id))
56
+ # get :edit, :id => blog_post.to_param
57
+ # assert_response :success
58
+ # end
59
+ #
60
+ # test "should update post" do
61
+ # blog_post = BlogPost.create(post_attrs.merge(:user_id => @user.id))
62
+ # put :update, :id => blog_post.to_param, :post => post_attrs
63
+ # assert_redirected_to blog_post_path(assigns(:blog_post))
64
+ # end
65
+ #
66
+ #
67
+ # test "should only let admins update posts" do
68
+ # @user.admin = false
69
+ # @user.save
70
+ #
71
+ # blog_post = BlogPost.create(post_attrs.merge(:user_id => @user.id))
72
+ # put :update, :id => blog_post.to_param, :post => post_attrs
73
+ # assert_redirected_to blog_posts_path
74
+ # end
75
+ #
76
+ # test "should destroy post" do
77
+ # blog_post = BlogPost.create(post_attrs.merge(:user_id => @user.id))
78
+ # assert_difference('BlogPost.count', -1) do
79
+ # delete :destroy, :id => blog_post.to_param
80
+ # end
81
+ #
82
+ # assert_redirected_to blog_posts_path
83
+ # end
84
+ # end
@@ -0,0 +1,12 @@
1
+ require 'test_helper'
2
+ require 'rails/performance_test_help'
3
+
4
+ class BrowsingTest < ActionDispatch::PerformanceTest
5
+ # Refer to the documentation for all available options
6
+ # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
7
+ # :output => 'tmp/performance', :formats => [:flat] }
8
+
9
+ def test_homepage
10
+ get '/'
11
+ end
12
+ end
data/test/schema.rb ADDED
@@ -0,0 +1,61 @@
1
+ # Test Schema
2
+
3
+ ActiveRecord::Schema.define(:version => 0) do
4
+ create_table "blog_comments", :force => true do |t|
5
+ t.integer "blog_post_id"
6
+ t.integer "user_id"
7
+ t.string "user_ip"
8
+ t.string "user_agent"
9
+ t.string "referrer"
10
+ t.string "name"
11
+ t.string "site_url"
12
+ t.string "email"
13
+ t.text "body"
14
+ t.datetime "created_at"
15
+ end
16
+
17
+ add_index "blog_comments", ["blog_post_id"], :name => "index_blog_comments_on_blog_post_id"
18
+
19
+ create_table "blog_posts", :force => true do |t|
20
+ t.string "title", :null => false
21
+ t.text "body"
22
+ t.datetime "created_at"
23
+ t.datetime "updated_at"
24
+ t.boolean "published", :default => false, :null => false
25
+ t.integer "user_id"
26
+ t.datetime "published_at"
27
+ end
28
+
29
+ create_table "users", :force => true do |t|
30
+ t.string "name", :null => false
31
+ t.string "email", :null => false
32
+ t.datetime "created_at"
33
+ t.datetime "updated_at"
34
+ t.string "crypted_password"
35
+ t.string "password_salt"
36
+ t.string "persistence_token"
37
+ t.boolean "admin", :default => false, :null => false
38
+ t.string "perishable_token", :default => "", :null => false
39
+ end
40
+
41
+ create_table "blog_images", :force => true do |t|
42
+ t.string "image_file_name"
43
+ t.string "image_content_type"
44
+ t.integer "image_file_size"
45
+ t.datetime "image_updated_at"
46
+ t.integer "blog_post_id"
47
+ t.datetime "created_at"
48
+ t.datetime "updated_at"
49
+ end
50
+
51
+ add_index "blog_images", ["blog_post_id"], :name => "index_blog_images_on_blog_post_id"
52
+
53
+ create_table "blog_tags", :force => true do |t|
54
+ t.integer "blog_post_id"
55
+ t.string "tag", :null => false
56
+ end
57
+
58
+ add_index "blog_tags", ["blog_post_id"], :name => "index_blog_tags_on_blog_post_id"
59
+ add_index "blog_tags", ["tag"], :name => "index_blog_tags_on_tag"
60
+
61
+ end
@@ -0,0 +1,13 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ require 'rails/test_help'
4
+
5
+ class ActiveSupport::TestCase
6
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
7
+ #
8
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
9
+ # -- they do not yet inherit this setting
10
+ fixtures :all
11
+
12
+ # Add more helper methods to be used by all tests here...
13
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class AdminUserTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here