crowdblog 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +5 -0
- data/.gitignore +1 -0
- data/app/assets/javascripts/crowdblog/models/post.js.coffee.erb +1 -1
- data/app/assets/stylesheets/application.css +3 -0
- data/app/controllers/crowdblog/admin/assets_controller.rb +20 -0
- data/app/controllers/crowdblog/admin/authors_controller.rb +11 -0
- data/app/controllers/crowdblog/admin/base_controller.rb +7 -0
- data/app/controllers/crowdblog/admin/posts_controller.rb +71 -0
- data/app/controllers/crowdblog/application_controller.rb +8 -7
- data/app/controllers/crowdblog/posts_controller.rb +2 -66
- data/app/models/crowdblog/post.rb +2 -2
- data/app/models/crowdblog/user.rb +18 -26
- data/app/views/crowdblog/{authors → admin/authors}/index.html.slim +0 -0
- data/app/views/crowdblog/{posts → admin/posts}/_form.html.slim +0 -0
- data/app/views/crowdblog/admin/posts/_post.html.slim +13 -0
- data/app/views/crowdblog/{posts → admin/posts}/edit.html.slim +2 -2
- data/app/views/crowdblog/admin/posts/index.html.slim +24 -0
- data/app/views/crowdblog/{posts → admin/posts}/new.html.slim +0 -0
- data/app/views/crowdblog/{posts → admin/posts}/update.json.jbuilder +0 -0
- data/app/views/crowdblog/application/_navbar.html.slim +4 -6
- data/app/views/crowdblog/posts/_post.html.slim +4 -13
- data/app/views/crowdblog/posts/index.html.slim +1 -24
- data/app/views/layouts/crowdblog/admin/base.html.slim +20 -0
- data/app/views/layouts/crowdblog/application.html.slim +2 -3
- data/config/routes.rb +9 -8
- data/crowdblog.gemspec +2 -1
- data/lib/crowdblog.rb +1 -4
- data/lib/crowdblog/rspec/crowdblog_shared_examples.rb +70 -73
- data/lib/crowdblog/version.rb +1 -1
- data/lib/generators/crowdblog/views_generator.rb +11 -0
- data/spec/dummy/app/controllers/application_controller.rb +0 -2
- data/spec/dummy/config/routes.rb +1 -3
- data/spec/dummy/db/schema.rb +1 -42
- data/spec/generators/crowdblog/views_generator_spec.rb +16 -0
- data/spec/models/post_spec.rb +4 -14
- metadata +46 -35
- data/app/assets/images/crowdblog/logo.png +0 -0
- data/app/controllers/crowdblog/assets_controller.rb +0 -18
- data/app/controllers/crowdblog/authors_controller.rb +0 -9
- data/app/controllers/crowdblog/devise/sessions_controller.rb +0 -3
- data/config/initializers/devise.rb +0 -16
- data/db/migrate/20120215232711_create_crowdblog_users.rb +0 -23
- data/db/migrate/20120220033923_create_vestal_versions.rb +0 -28
- data/spec/dummy/app/controllers/admin_controller.rb +0 -0
- data/spec/dummy/app/controllers/home_controller.rb +0 -4
- data/spec/dummy/app/controllers/sessions_controller.rb +0 -2
- data/spec/dummy/config/initializers/devise.rb +0 -222
- data/spec/models/user_spec.rb +0 -81
Binary file
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Crowdblog
|
2
|
-
class AssetsController < Crowdblog::ApplicationController
|
3
|
-
# TODO: Skipping filters is the worst solution ever to this problem
|
4
|
-
# Someone should fix the uploadify.js thing
|
5
|
-
skip_before_filter :verify_authenticity_token, :only => :create
|
6
|
-
skip_before_filter :authorize!
|
7
|
-
|
8
|
-
def create
|
9
|
-
@post = Post.find(params[:post_id])
|
10
|
-
asset = @post.assets.build
|
11
|
-
asset.attachment = params['attachment']
|
12
|
-
asset.save!
|
13
|
-
|
14
|
-
render json: asset
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
Devise.setup do |config|
|
2
|
-
require 'devise/orm/active_record'
|
3
|
-
|
4
|
-
config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
|
5
|
-
#config.apply_schema = false
|
6
|
-
config.case_insensitive_keys = [ :email ]
|
7
|
-
config.strip_whitespace_keys = [ :email ]
|
8
|
-
config.skip_session_storage = [:http_auth]
|
9
|
-
config.stretches = Rails.env.test? ? 1 : 10
|
10
|
-
config.reconfirmable = true
|
11
|
-
#config.use_salt_as_remember_token = true
|
12
|
-
config.reset_password_within = 6.hours
|
13
|
-
config.sign_out_via = :get
|
14
|
-
|
15
|
-
config.warden { |manager| manager.failure_app = Crowdblog::Devise::FailureApp }
|
16
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
class CreateCrowdblogUsers < ActiveRecord::Migration
|
2
|
-
def change
|
3
|
-
create_table :crowdblog_users do |t|
|
4
|
-
t.string :name
|
5
|
-
t.boolean :is_publisher
|
6
|
-
t.string :email, :null => false, :default => ""
|
7
|
-
t.string :encrypted_password, :null => false, :default => ""
|
8
|
-
t.datetime :remember_created_at
|
9
|
-
t.integer :sign_in_count, :default => 0
|
10
|
-
t.datetime :current_sign_in_at
|
11
|
-
t.datetime :last_sign_in_at
|
12
|
-
t.string :current_sign_in_ip
|
13
|
-
t.string :last_sign_in_ip
|
14
|
-
t.string :authentication_token
|
15
|
-
t.string :gravatar_alias
|
16
|
-
|
17
|
-
t.timestamps
|
18
|
-
end
|
19
|
-
|
20
|
-
add_index :crowdblog_users, :email, :unique => true
|
21
|
-
add_index :crowdblog_users, :authentication_token, :unique => true
|
22
|
-
end
|
23
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
class CreateVestalVersions < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :versions do |t|
|
4
|
-
t.belongs_to :versioned, :polymorphic => true
|
5
|
-
t.belongs_to :user, :polymorphic => true
|
6
|
-
t.string :user_name
|
7
|
-
t.text :modifications
|
8
|
-
t.integer :number
|
9
|
-
t.integer :reverted_from
|
10
|
-
t.string :tag
|
11
|
-
|
12
|
-
t.timestamps
|
13
|
-
end
|
14
|
-
|
15
|
-
change_table :versions do |t|
|
16
|
-
t.index [:versioned_id, :versioned_type]
|
17
|
-
t.index [:user_id, :user_type]
|
18
|
-
t.index :user_name
|
19
|
-
t.index :number
|
20
|
-
t.index :tag
|
21
|
-
t.index :created_at
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.down
|
26
|
-
drop_table :versions
|
27
|
-
end
|
28
|
-
end
|
File without changes
|
@@ -1,222 +0,0 @@
|
|
1
|
-
#require 'openid/store/filesystem'
|
2
|
-
#
|
3
|
-
# Use this hook to configure devise mailer, warden hooks and so forth.
|
4
|
-
# Many of these configuration options can be set straight in your model.
|
5
|
-
Devise.setup do |config|
|
6
|
-
# ==> Mailer Configuration
|
7
|
-
# Configure the e-mail address which will be shown in Devise::Mailer,
|
8
|
-
# note that it will be overwritten if you use your own mailer class with default "from" parameter.
|
9
|
-
config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
|
10
|
-
|
11
|
-
# Configure the class responsible to send e-mails.
|
12
|
-
# config.mailer = "Devise::Mailer"
|
13
|
-
|
14
|
-
# ==> ORM configuration
|
15
|
-
# Load and configure the ORM. Supports :active_record (default) and
|
16
|
-
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
17
|
-
# available as additional gems.
|
18
|
-
require 'devise/orm/active_record'
|
19
|
-
|
20
|
-
# ==> Configuration for any authentication mechanism
|
21
|
-
# Configure which keys are used when authenticating a user. The default is
|
22
|
-
# just :email. You can configure it to use [:username, :subdomain], so for
|
23
|
-
# authenticating a user, both parameters are required. Remember that those
|
24
|
-
# parameters are used only when authenticating and not when retrieving from
|
25
|
-
# session. If you need permissions, you should implement that in a before filter.
|
26
|
-
# You can also supply a hash where the value is a boolean determining whether
|
27
|
-
# or not authentication should be aborted when the value is not present.
|
28
|
-
# config.authentication_keys = [ :email ]
|
29
|
-
|
30
|
-
# Configure parameters from the request object used for authentication. Each entry
|
31
|
-
# given should be a request method and it will automatically be passed to the
|
32
|
-
# find_for_authentication method and considered in your model lookup. For instance,
|
33
|
-
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
|
34
|
-
# The same considerations mentioned for authentication_keys also apply to request_keys.
|
35
|
-
# config.request_keys = []
|
36
|
-
|
37
|
-
# Configure which authentication keys should be case-insensitive.
|
38
|
-
# These keys will be downcased upon creating or modifying a user and when used
|
39
|
-
# to authenticate or find a user. Default is :email.
|
40
|
-
config.case_insensitive_keys = [ :email ]
|
41
|
-
|
42
|
-
# Configure which authentication keys should have whitespace stripped.
|
43
|
-
# These keys will have whitespace before and after removed upon creating or
|
44
|
-
# modifying a user and when used to authenticate or find a user. Default is :email.
|
45
|
-
config.strip_whitespace_keys = [ :email ]
|
46
|
-
|
47
|
-
# Tell if authentication through request.params is enabled. True by default.
|
48
|
-
# It can be set to an array that will enable params authentication only for the
|
49
|
-
# given strategies, for example, `config.params_authenticatable = [:database]` will
|
50
|
-
# enable it only for database (email + password) authentication.
|
51
|
-
# config.params_authenticatable = true
|
52
|
-
|
53
|
-
# Tell if authentication through HTTP Basic Auth is enabled. False by default.
|
54
|
-
# It can be set to an array that will enable http authentication only for the
|
55
|
-
# given strategies, for example, `config.http_authenticatable = [:token]` will
|
56
|
-
# enable it only for token authentication.
|
57
|
-
# config.http_authenticatable = false
|
58
|
-
|
59
|
-
# If http headers should be returned for AJAX requests. True by default.
|
60
|
-
# config.http_authenticatable_on_xhr = true
|
61
|
-
|
62
|
-
# The realm used in Http Basic Authentication. "Application" by default.
|
63
|
-
# config.http_authentication_realm = "Application"
|
64
|
-
|
65
|
-
# It will change confirmation, password recovery and other workflows
|
66
|
-
# to behave the same regardless if the e-mail provided was right or wrong.
|
67
|
-
# Does not affect registerable.
|
68
|
-
# config.paranoid = true
|
69
|
-
|
70
|
-
# By default Devise will store the user in session. You can skip storage for
|
71
|
-
# :http_auth and :token_auth by adding those symbols to the array below.
|
72
|
-
# Notice that if you are skipping storage for all authentication paths, you
|
73
|
-
# may want to disable generating routes to Devise's sessions controller by
|
74
|
-
# passing :skip => :sessions to `devise_for` in your config/routes.rb
|
75
|
-
config.skip_session_storage = [:http_auth]
|
76
|
-
|
77
|
-
# ==> Configuration for :database_authenticatable
|
78
|
-
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
|
79
|
-
# using other encryptors, it sets how many times you want the password re-encrypted.
|
80
|
-
#
|
81
|
-
# Limiting the stretches to just one in testing will increase the performance of
|
82
|
-
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
|
83
|
-
# a value less than 10 in other environments.
|
84
|
-
config.stretches = Rails.env.test? ? 1 : 10
|
85
|
-
|
86
|
-
# Setup a pepper to generate the encrypted password.
|
87
|
-
# config.pepper = "6c7957fc3416ab1f88702c4ee999fe69bfc0ec4677e8e6429a6eba5c3c13225a072dc8fc63a7af8b82851f4aebd11612bffbcfd9247c9c3bd8d66cf6b3c8e4d6"
|
88
|
-
|
89
|
-
# ==> Configuration for :confirmable
|
90
|
-
# A period that the user is allowed to access the website even without
|
91
|
-
# confirming his account. For instance, if set to 2.days, the user will be
|
92
|
-
# able to access the website for two days without confirming his account,
|
93
|
-
# access will be blocked just in the third day. Default is 0.days, meaning
|
94
|
-
# the user cannot access the website without confirming his account.
|
95
|
-
# config.allow_unconfirmed_access_for = 2.days
|
96
|
-
|
97
|
-
# If true, requires any email changes to be confirmed (exctly the same way as
|
98
|
-
# initial account confirmation) to be applied. Requires additional unconfirmed_email
|
99
|
-
# db field (see migrations). Until confirmed new email is stored in
|
100
|
-
# unconfirmed email column, and copied to email column on successful confirmation.
|
101
|
-
config.reconfirmable = true
|
102
|
-
|
103
|
-
# Defines which key will be used when confirming an account
|
104
|
-
# config.confirmation_keys = [ :email ]
|
105
|
-
|
106
|
-
# ==> Configuration for :rememberable
|
107
|
-
# The time the user will be remembered without asking for credentials again.
|
108
|
-
# config.remember_for = 2.weeks
|
109
|
-
|
110
|
-
# If true, extends the user's remember period when remembered via cookie.
|
111
|
-
# config.extend_remember_period = false
|
112
|
-
|
113
|
-
# Options to be passed to the created cookie. For instance, you can set
|
114
|
-
# :secure => true in order to force SSL only cookies.
|
115
|
-
# config.cookie_options = {}
|
116
|
-
|
117
|
-
# ==> Configuration for :validatable
|
118
|
-
# Range for password length. Default is 6..128.
|
119
|
-
# config.password_length = 6..128
|
120
|
-
|
121
|
-
# Email regex used to validate email formats. It simply asserts that
|
122
|
-
# an one (and only one) @ exists in the given string. This is mainly
|
123
|
-
# to give user feedback and not to assert the e-mail validity.
|
124
|
-
# config.email_regexp = /\A[^@]+@[^@]+\z/
|
125
|
-
|
126
|
-
# ==> Configuration for :timeoutable
|
127
|
-
# The time you want to timeout the user session without activity. After this
|
128
|
-
# time the user will be asked for credentials again. Default is 30 minutes.
|
129
|
-
# config.timeout_in = 30.minutes
|
130
|
-
|
131
|
-
# ==> Configuration for :lockable
|
132
|
-
# Defines which strategy will be used to lock an account.
|
133
|
-
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
134
|
-
# :none = No lock strategy. You should handle locking by yourself.
|
135
|
-
# config.lock_strategy = :failed_attempts
|
136
|
-
|
137
|
-
# Defines which key will be used when locking and unlocking an account
|
138
|
-
# config.unlock_keys = [ :email ]
|
139
|
-
|
140
|
-
# Defines which strategy will be used to unlock an account.
|
141
|
-
# :email = Sends an unlock link to the user email
|
142
|
-
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
143
|
-
# :both = Enables both strategies
|
144
|
-
# :none = No unlock strategy. You should handle unlocking by yourself.
|
145
|
-
# config.unlock_strategy = :both
|
146
|
-
|
147
|
-
# Number of authentication tries before locking an account if lock_strategy
|
148
|
-
# is failed attempts.
|
149
|
-
# config.maximum_attempts = 20
|
150
|
-
|
151
|
-
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
152
|
-
# config.unlock_in = 1.hour
|
153
|
-
|
154
|
-
# ==> Configuration for :recoverable
|
155
|
-
#
|
156
|
-
# Defines which key will be used when recovering the password for an account
|
157
|
-
# config.reset_password_keys = [ :email ]
|
158
|
-
|
159
|
-
# Time interval you can reset your password with a reset password key.
|
160
|
-
# Don't put a too small interval or your users won't have the time to
|
161
|
-
# change their passwords.
|
162
|
-
config.reset_password_within = 6.hours
|
163
|
-
|
164
|
-
# ==> Configuration for :encryptable
|
165
|
-
# Allow you to use another encryption algorithm besides bcrypt (default). You can use
|
166
|
-
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
|
167
|
-
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
|
168
|
-
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
|
169
|
-
# REST_AUTH_SITE_KEY to pepper)
|
170
|
-
# config.encryptor = :sha512
|
171
|
-
|
172
|
-
# ==> Configuration for :token_authenticatable
|
173
|
-
# Defines name of the authentication token params key
|
174
|
-
config.token_authentication_key = :auth_token
|
175
|
-
|
176
|
-
# ==> Scopes configuration
|
177
|
-
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
178
|
-
# "users/sessions/new". It's turned off by default because it's slower if you
|
179
|
-
# are using only default views.
|
180
|
-
# config.scoped_views = false
|
181
|
-
|
182
|
-
# Configure the default scope given to Warden. By default it's the first
|
183
|
-
# devise role declared in your routes (usually :user).
|
184
|
-
# config.default_scope = :user
|
185
|
-
|
186
|
-
# Configure sign_out behavior.
|
187
|
-
# Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
|
188
|
-
# The default is true, which means any logout action will sign out all active scopes.
|
189
|
-
# config.sign_out_all_scopes = true
|
190
|
-
|
191
|
-
# ==> Navigation configuration
|
192
|
-
# Lists the formats that should be treated as navigational. Formats like
|
193
|
-
# :html, should redirect to the sign in page when the user does not have
|
194
|
-
# access, but formats like :xml or :json, should return 401.
|
195
|
-
#
|
196
|
-
# If you have any extra navigational formats, like :iphone or :mobile, you
|
197
|
-
# should add them to the navigational formats lists.
|
198
|
-
#
|
199
|
-
# The "*/*" below is required to match Internet Explorer requests.
|
200
|
-
# config.navigational_formats = ["*/*", :html]
|
201
|
-
|
202
|
-
# The default HTTP method used to sign out a resource. Default is :delete.
|
203
|
-
config.sign_out_via = :get
|
204
|
-
|
205
|
-
# ==> OmniAuth
|
206
|
-
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
207
|
-
# up on your models and hooks.
|
208
|
-
#config.omniauth :google_oauth2, '289799840893.apps.googleusercontent.com', '6DYqOtdhC8S5WARlkiOwS3zb'
|
209
|
-
#config.omniauth :google_oauth2, ENV['GOOGLE_APP_ID'], ENV['GOOGLE_SECRET_KEY'],
|
210
|
-
# {:client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}
|
211
|
-
#config.omniauth :google_apps, :domain => 'crowdint.com'
|
212
|
-
|
213
|
-
|
214
|
-
# ==> Warden configuration
|
215
|
-
# If you want to use other strategies, that are not supported by Devise, or
|
216
|
-
# change the failure app, you can configure them inside the config.warden block.
|
217
|
-
#
|
218
|
-
# config.warden do |manager|
|
219
|
-
# manager.intercept_401 = false
|
220
|
-
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
|
221
|
-
# end
|
222
|
-
end
|
data/spec/models/user_spec.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Crowdblog
|
4
|
-
describe User do
|
5
|
-
|
6
|
-
describe '#gravatar_email' do
|
7
|
-
context 'when using a Gravatar' do
|
8
|
-
before { subject.should_receive(:gravatar_alias).and_return 'GRAVATAR' }
|
9
|
-
|
10
|
-
it 'should use the alias' do
|
11
|
-
subject.gravatar_email.should == 'GRAVATAR'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context 'when not using a Gravatar' do
|
16
|
-
before do
|
17
|
-
subject.should_receive(:gravatar_alias)
|
18
|
-
subject.should_receive(:email).and_return 'EMAIL'
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should use the email' do
|
22
|
-
subject.gravatar_email.should == 'EMAIL'
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#last_post_at' do
|
28
|
-
context 'when has posts' do
|
29
|
-
let(:post) { mock_model Post }
|
30
|
-
|
31
|
-
before do
|
32
|
-
subject.should_receive(:last_post).and_return post
|
33
|
-
post.should_receive(:published_at).and_return '2012-06-31'
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should be the published post date' do
|
37
|
-
subject.last_post_at.should == '2012-06-31'
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'when no posts' do
|
42
|
-
it 'should be nil' do
|
43
|
-
subject.should_receive(:last_post)
|
44
|
-
subject.last_post_at.should be_nil
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "#last_published_at" do
|
50
|
-
context 'has published posts' do
|
51
|
-
let(:date) { Date.today }
|
52
|
-
|
53
|
-
before do
|
54
|
-
posts = [ mock_model(Post, :published_at => date), mock_model(Post, :published_at => 1.day.ago) ]
|
55
|
-
subject.stub(:published_posts).and_return posts
|
56
|
-
end
|
57
|
-
|
58
|
-
it "returns the published_at date of the first post" do
|
59
|
-
subject.last_published_at.should be(date)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'no published posts' do
|
64
|
-
before do
|
65
|
-
subject.stub(:published_posts).and_return []
|
66
|
-
end
|
67
|
-
|
68
|
-
it "returns nil" do
|
69
|
-
subject.last_published_at.should be_nil
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe '#publisher!' do
|
75
|
-
it 'should make User a Publisher' do
|
76
|
-
subject.should_receive(:update_attribute).with(:is_publisher, true)
|
77
|
-
subject.publisher!
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|