effective_posts 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +171 -3
- data/config/routes.rb +2 -0
- data/lib/effective_posts/version.rb +1 -1
- data/lib/generators/templates/effective_posts.rb +2 -3
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eca3438b280dc68df0a2068bc09754ebdf9d11f5
|
4
|
+
data.tar.gz: e84fcb3c11970fe9f60f3917c4bbcf97cd39ce5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e8f78680d751d43fd2cc15b7daff3150075601522d6f330fc3b2ce18132a560c3704e915d5e176540aa38008f4eed95e9344298db47715255e62dbd66b1a21d
|
7
|
+
data.tar.gz: f572bc531f7f88a3a093b97d3f543db5bb8b00c7db8f35eeaa9ed0b0cbbcf700c9499cb87af8b96d69dd1a6e0f8bfc073a7e0c8a332b17edd4ac3578da14c4d3
|
data/README.md
CHANGED
@@ -1,7 +1,175 @@
|
|
1
1
|
# Effective Posts
|
2
2
|
|
3
|
-
|
3
|
+
A blog implementation with WYSIWYG content editing, post scheduling, pagination and optional top level routes for each post category.
|
4
4
|
|
5
|
-
|
5
|
+
Built ontop of effective_regions for post content entry and Kaminari for pagination.
|
6
6
|
|
7
|
-
|
7
|
+
Rails 3.2.x and 4.x
|
8
|
+
|
9
|
+
|
10
|
+
## Getting Started
|
11
|
+
|
12
|
+
Please first install the [effective_regions](https://github.com/code-and-effect/effective_regions) and [effective_datatables](https://github.com/code-and-effect/effective_datatables) gems.
|
13
|
+
|
14
|
+
Please download and install [Twitter Bootstrap3](http://getbootstrap.com)
|
15
|
+
|
16
|
+
Add to your Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'effective_posts'
|
20
|
+
```
|
21
|
+
|
22
|
+
Run the bundle command to install it:
|
23
|
+
|
24
|
+
```console
|
25
|
+
bundle install
|
26
|
+
```
|
27
|
+
|
28
|
+
Then run the generator:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
rails generate effective_posts:install
|
32
|
+
```
|
33
|
+
|
34
|
+
The generator will install an initializer which describes all configuration options and creates a database migration.
|
35
|
+
|
36
|
+
If you want to tweak the table name (to use something other than the default 'posts'), manually adjust both the configuration file and the migration now.
|
37
|
+
|
38
|
+
Then migrate the database:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
rake db:migrate
|
42
|
+
```
|
43
|
+
|
44
|
+
There are no required javascript or stylesheet includes.
|
45
|
+
|
46
|
+
|
47
|
+
## Posts
|
48
|
+
|
49
|
+
To create your first post, visit `/admin/posts` and click `New Post`.
|
50
|
+
|
51
|
+
If you've defined more than one category in the `/app/config/initializers/effective_posts.rb` initializer, you will be asked to assign this post a category. Otherwise the default category `posts` will be assigned.
|
52
|
+
|
53
|
+
You can schedule a post to appear at a later date by setting the published_at value to a future date.
|
54
|
+
|
55
|
+
If you're using the [effective_form_inputs](https://github.com/code-and-effect/effective_form_inputs) gem, the published_at input will be displayed with a nice bootstrap3 datetimepicker, otherwise it will use the default simple_form datetime input (which is pretty bad).
|
56
|
+
|
57
|
+
As well, if you're using the [effective_roles](https://github.com/code-and-effect/effective_roles) gem, you will be able to configure permissions so that only permitted users may view this post.
|
58
|
+
|
59
|
+
Once you click `Save and Edit Content` you will be brought into the effective_regions editor where you may enter the content for your post. Click `Insert Snippet` -> `Read more divider` from the toolbar to place a divider into your post. Only the content above the Read more divider, the excerpt content, will be displayed on any posts#index screens. The full content will be displayed on the posts#show screen.
|
60
|
+
|
61
|
+
|
62
|
+
## Category Routes
|
63
|
+
|
64
|
+
If `config.use_category_routes` is enabled in the `/app/config/initializers/effective_posts.rb` initializer, each category you specify will automatically have a top level route. So posts created in the `:blog` category will be available at `/blog` and any posts made in that category will be available at `/blog/1-my-post-title`.
|
65
|
+
|
66
|
+
If disabled, all posts will be available at `/posts`, with posts for a specific category available at `/posts?category=blog` and the show routes will be `/posts/1-my-post-title` regardless of category.
|
67
|
+
|
68
|
+
|
69
|
+
## Helpers
|
70
|
+
|
71
|
+
Use `link_to_post_category(:blog)` to display a link to the Blog page. The helper considers `config.use_category_routes` and puts in the correct url.
|
72
|
+
|
73
|
+
|
74
|
+
## Pagination
|
75
|
+
|
76
|
+
The [kaminari](https://github.com/amatsuda/kaminari) gem is used for pagination on all posts#index type screens.
|
77
|
+
|
78
|
+
The per_page for posts may be configured via the `/app/config/initializers/effective_posts.rb` initializer.
|
79
|
+
|
80
|
+
Included within this gem is the bootstrap3 theme for kaminari, but, as with any gem, your app-specific kaminari views will take priority over these included views.
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
## Authorization
|
85
|
+
|
86
|
+
All authorization checks are handled via the config.authorization_method found in the `app/config/initializers/effective_posts.rb` file.
|
87
|
+
|
88
|
+
It is intended for flow through to CanCan or Pundit, but neither of those gems are required.
|
89
|
+
|
90
|
+
This method is called by all controller actions with the appropriate action and resource
|
91
|
+
|
92
|
+
Action will be one of [:index, :show, :new, :create, :edit, :update, :destroy]
|
93
|
+
|
94
|
+
Resource will the appropriate Effective::Post object or class
|
95
|
+
|
96
|
+
The authorization method is defined in the initializer file:
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
# As a Proc (with CanCan)
|
100
|
+
config.authorization_method = Proc.new { |controller, action, resource| authorize!(action, resource) }
|
101
|
+
```
|
102
|
+
|
103
|
+
```ruby
|
104
|
+
# As a Custom Method
|
105
|
+
config.authorization_method = :my_authorization_method
|
106
|
+
```
|
107
|
+
|
108
|
+
and then in your application_controller.rb:
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
def my_authorization_method(action, resource)
|
112
|
+
current_user.is?(:admin) || EffectivePunditPolicy.new(current_user, resource).send('#{action}?')
|
113
|
+
end
|
114
|
+
```
|
115
|
+
|
116
|
+
or disabled entirely:
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
config.authorization_method = false
|
120
|
+
```
|
121
|
+
|
122
|
+
If the method or proc returns false (user is not authorized) an Effective::AccessDenied exception will be raised
|
123
|
+
|
124
|
+
You can rescue from this exception by adding the following to your application_controller.rb:
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
rescue_from Effective::AccessDenied do |exception|
|
128
|
+
respond_to do |format|
|
129
|
+
format.html { render 'static_pages/access_denied', :status => 403 }
|
130
|
+
format.any { render :text => 'Access Denied', :status => 403 }
|
131
|
+
end
|
132
|
+
end
|
133
|
+
```
|
134
|
+
|
135
|
+
### Permissions
|
136
|
+
|
137
|
+
The permissions you actually want to define are as follows (using CanCan):
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
can [:index, :show], Effective::Post
|
141
|
+
can [:manage], Effective::Post if user.is?(:admin)
|
142
|
+
```
|
143
|
+
|
144
|
+
## Future Plans
|
145
|
+
|
146
|
+
There are some obvious additional features that have yet to be implemented:
|
147
|
+
|
148
|
+
- Tagging
|
149
|
+
- Some kind of helper for displaying a sidebar for the categories
|
150
|
+
- Post archives and date filtering
|
151
|
+
|
152
|
+
|
153
|
+
## License
|
154
|
+
|
155
|
+
MIT License. Copyright [Code and Effect Inc.](http://www.codeandeffect.com/)
|
156
|
+
|
157
|
+
Code and Effect is the product arm of [AgileStyle](http://www.agilestyle.com/), an Edmonton-based shop that specializes in building custom web applications with Ruby on Rails.
|
158
|
+
|
159
|
+
|
160
|
+
## Testing
|
161
|
+
|
162
|
+
Run tests by:
|
163
|
+
|
164
|
+
```ruby
|
165
|
+
guard
|
166
|
+
```
|
167
|
+
|
168
|
+
## Contributing
|
169
|
+
|
170
|
+
1. Fork it
|
171
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
172
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
173
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
174
|
+
5. Bonus points for test coverage
|
175
|
+
6. Create new Pull Request
|
data/config/routes.rb
CHANGED
@@ -8,6 +8,8 @@ EffectivePosts::Engine.routes.draw do
|
|
8
8
|
|
9
9
|
if EffectivePosts.use_category_routes
|
10
10
|
EffectivePosts.categories.each do |category|
|
11
|
+
next if category.to_s == 'posts'
|
12
|
+
|
11
13
|
match "#{category}", :to => 'posts#index', :via => [:get], :defaults => {:category => category.to_s }
|
12
14
|
match "#{category}/:id", :to => 'posts#show', :via => [:get], :defaults => {:category => category.to_s }
|
13
15
|
end
|
@@ -3,9 +3,8 @@
|
|
3
3
|
EffectivePosts.setup do |config|
|
4
4
|
config.posts_table_name = :posts
|
5
5
|
|
6
|
-
# Every post must belong to one or more category
|
7
|
-
#
|
8
|
-
# Don't include :posts
|
6
|
+
# Every post must belong to one or more category.
|
7
|
+
# Don't use the category :posts
|
9
8
|
config.categories = [:blog, :news]
|
10
9
|
|
11
10
|
# Create top level routes for each category
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_posts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -122,7 +122,8 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 1.2.2
|
125
|
-
description:
|
125
|
+
description: A blog implementation with WYSIWYG content editing, post scheduling,
|
126
|
+
pagination and optional top level routes for each post category.
|
126
127
|
email:
|
127
128
|
- info@codeandeffect.com
|
128
129
|
executables: []
|
@@ -194,7 +195,8 @@ rubyforge_project:
|
|
194
195
|
rubygems_version: 2.4.3
|
195
196
|
signing_key:
|
196
197
|
specification_version: 4
|
197
|
-
summary:
|
198
|
+
summary: A blog implementation with WYSIWYG content editing, post scheduling, pagination
|
199
|
+
and optional top level routes for each post category.
|
198
200
|
test_files:
|
199
201
|
- spec/effective_pages_spec.rb
|
200
202
|
- spec/spec_helper.rb
|