effective_posts 0.1.2 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 896d5d35da11a85728025e30637b1b98b0d8444c
4
- data.tar.gz: f1be7c5c2bdab2b86fdcbb80bb424fe3b0b404c4
3
+ metadata.gz: eca3438b280dc68df0a2068bc09754ebdf9d11f5
4
+ data.tar.gz: e84fcb3c11970fe9f60f3917c4bbcf97cd39ce5f
5
5
  SHA512:
6
- metadata.gz: d581efa632c5220c944c326493bc392ef9c0e91f259dfe8fbf6652f181642ce5fba3c1b7d513393b32b2a81beb6d1378384d3d7060549f20bd96046ba51a2b6b
7
- data.tar.gz: 6d24be4f730f39c57802747a85d5c79dc961dba908c37b050dd53d90742114dae54875c44ec52315f24fecfa86ab478079706443bd9ae1783b9fd0bdbdbb9fb1
6
+ metadata.gz: 8e8f78680d751d43fd2cc15b7daff3150075601522d6f330fc3b2ce18132a560c3704e915d5e176540aa38008f4eed95e9344298db47715255e62dbd66b1a21d
7
+ data.tar.gz: f572bc531f7f88a3a093b97d3f543db5bb8b00c7db8f35eeaa9ed0b0cbbcf700c9499cb87af8b96d69dd1a6e0f8bfc073a7e0c8a332b17edd4ac3578da14c4d3
data/README.md CHANGED
@@ -1,7 +1,175 @@
1
1
  # Effective Posts
2
2
 
3
- WIP Gem
3
+ A blog implementation with WYSIWYG content editing, post scheduling, pagination and optional top level routes for each post category.
4
4
 
5
- ## TODO
5
+ Built ontop of effective_regions for post content entry and Kaminari for pagination.
6
6
 
7
- Write a README
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
@@ -1,3 +1,3 @@
1
1
  module EffectivePosts
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  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
- # Only add to the end of this array. Never prepend categories.
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.1.2
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-01-28 00:00:00.000000000 Z
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: CRUD Posts with intention to work with EffectiveRegions. WIP.
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: CRUD Posts with intention to work with EffectiveRegions. WIP.
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