outpost-cms 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bfef55a2fe56f15367da92452ef73abbf321a011
4
- data.tar.gz: a6d770b0dede836f75a1f71ed8b8df6a5fbc750c
3
+ metadata.gz: 5c9cd74072ad0fa1a8984e87e473b45a7279eb8d
4
+ data.tar.gz: e5f9937a7b34e095fc055ea4a49225e0ada5a7f3
5
5
  SHA512:
6
- metadata.gz: c529623b4c5e19170c93276a6e81a80c972f5f227ee3a445db9f3fba0af29b252d4fd2bab301ccff0cefb43c15364d5fe7b4666ed9ac0ff21f012f92ac9fe627
7
- data.tar.gz: 808a4605e0a650b8dba66cb6bd9e13fa0661aa1a869fe32295642eb70606017cd198885706535bfeac266610e84e1a7626eeab4f912fc5bf8d49fad36b99bb11
6
+ metadata.gz: 477424d6cc1b69199e68b204e7834823a8ca8723be2d258b3b0b5c989416a550bb8771d1a6d044a068c0a02e2d09bd43e5b67fe5923df512856dad672947e4a8
7
+ data.tar.gz: 2d1a39fd30466b412fd26843e5e27e30d74afc43d78bb6cd0466d5628b30a6445f784357dda649e462638dc7583eb0252b4e59c2c9a9b0d3d0ae17046b153c61
data/README.md CHANGED
@@ -25,12 +25,12 @@ so we can both exist on RubyGems.
25
25
 
26
26
 
27
27
  This gem also has some hard dependencies that aren't in the gemspec.
28
- My goal is to reduce these dependencies as much as possible, but as this was
28
+ My goal is to reduce these dependencies as much as possible, but as this was
29
29
  extracted from the KPCC application, these are fairly strict at this point.
30
30
 
31
31
  * `simple_form` - for Rails 3.2, use `~> 2.1.0`.
32
32
  For Rails 4.0, you'll need to use `~> 3.0.0.beta1`
33
- * `kaminari` - You need to use the
33
+ * `kaminari` - You need to use the
34
34
  [kaminari master branch](https://github.com/amatsuda/kaminari).
35
35
  * `eco`
36
36
  * `sass-rails`
@@ -38,8 +38,33 @@ For Rails 4.0, you'll need to use `~> 3.0.0.beta1`
38
38
  * `coffee-rails`
39
39
 
40
40
  ## Usage
41
+ ### Configuration
42
+ Outpost has some required configuration. In an initializer, perhaps `outpost.rb`,
43
+ register your "outpost models" (first-class models which are managed directly through
44
+ Outpost), as strings. Other available configuration will be discussed throughout
45
+ this documentation.
46
+
47
+ ```ruby
48
+ Outpost::Config.configure do |config|
49
+ config.registered_models = [
50
+ "Article",
51
+ "Blog",
52
+ "User"
53
+ ]
54
+
55
+ # Attributes which should be looked for as "title attributes", used for representing
56
+ # the object throughout Outpost.
57
+ config.title_attributes = [:name, :headline, :short_headline, :title]
58
+
59
+ # For controllers without a list defined, Outpost will render a list
60
+ # with all of the attributes. Add attributes here which should always be
61
+ # excluded from these automatic lists.
62
+ config.excluded_list_columns = ["body"]
63
+ end
64
+
65
+
41
66
  ### Authentication
42
- Much like Devise, Outpost provides a basic `SessionsController` and
67
+ Much like Devise, Outpost provides a basic `SessionsController` and
43
68
  corresponding views. To use these, just add them to your routes:
44
69
 
45
70
  ```ruby
@@ -70,7 +95,7 @@ Your User class should have at least the following methods:
70
95
 
71
96
  #### Configuration
72
97
 
73
- You can set a different User class, or the attribute which the user
98
+ You can set a different User class, or the attribute which the user
74
99
  should use to login:
75
100
 
76
101
  ```
@@ -122,7 +147,7 @@ add_index :user_permissions, :permission_id
122
147
  ```
123
148
 
124
149
  You can include `Outpost::Model::Authorization` into your User model
125
- to provide the Permission association, and also add the `can_manage?`
150
+ to provide the Permission association, and also add the `can_manage?`
126
151
  method:
127
152
 
128
153
  ```ruby
@@ -131,7 +156,7 @@ if !current_user.can_manage?(Post)
131
156
  end
132
157
  ```
133
158
 
134
- Authorization is "All-or-None"... in other words, a user can either
159
+ Authorization is "All-or-None"... in other words, a user can either
135
160
  manage a resource or not - A user with permission for a particular model
136
161
  is able to Create, Read, Update, and Delete any of those objects.
137
162
 
@@ -150,8 +175,8 @@ or a link:
150
175
 
151
176
  ### User Preferences
152
177
  Preferences are stored in the session, and on a per-resource basis.
153
- Outpost provides built-in hooks in the controller and views for
154
- Order (attribute) and Sort Mode ("asc", "desc"). In order to manage other
178
+ Outpost provides built-in hooks in the controller and views for
179
+ Order (attribute) and Sort Mode ("asc", "desc"). In order to manage other
155
180
  preferences, you'll want to make use of a handful of methods that get
156
181
  mixed-in to your Outpost controllers:
157
182
 
@@ -171,7 +196,7 @@ For example:
171
196
  set_preference("blog_entries_color", "ff0000")
172
197
  ```
173
198
 
174
- You also need to add the parameter that the preference is using to
199
+ You also need to add the parameter that the preference is using to
175
200
  `config.preferences`:
176
201
 
177
202
  ```ruby
@@ -226,7 +251,7 @@ f.input :title, wrapper_html; { class: "field-counter", data: { target: 50, fuzz
226
251
 
227
252
  ![Preview](http://i.imgur.com/OZhlIOd.png)
228
253
 
229
- The Javascript for Preview is what handles sending the form data to the server, but you'll need to handle the server-side stuff yourself. The "Preview" button will show up once you've added a `preview` action to that controller.
254
+ The Javascript for Preview is what handles sending the form data to the server, but you'll need to handle the server-side stuff yourself. The "Preview" button will show up once you've added a `preview` action to that controller.
230
255
 
231
256
  #### Use
232
257
 
@@ -242,7 +267,7 @@ Here is a full example of what your `preview` action could look like:
242
267
  ```ruby
243
268
  def preview
244
269
  @post = ContentBase.obj_by_key(params[:obj_key]) || Post.new
245
-
270
+
246
271
  with_rollback @post do
247
272
  @post.assign_attributes(form_params)
248
273
 
@@ -293,16 +318,10 @@ The form ID argument is optional. By default it will target all forms on the pag
293
318
 
294
319
  #### More documentation to come.
295
320
 
296
- ## Todo
297
- A ton of stuff. Here is a sampler:
298
-
299
- * Generators for resources (models, controllers).
300
- * Add record versioning (needs to be extracted from the SCPRv4 app).
301
- * Documentation... oh man, the documentation...
302
321
 
303
322
  ## Contributing
304
- Pull Requests are encouraged! This engine was built specifically for KPCC,
305
- so its flexibility is limited... if you have improvements to make, please
323
+ Pull Requests are encouraged! This engine was built specifically for KPCC,
324
+ so its flexibility is limited... if you have improvements to make, please
306
325
  make them.
307
326
 
308
327
  Fork it, make your changes, and send me a pull request.
Binary file
@@ -17,6 +17,7 @@
17
17
  //= require bootstrap-alert
18
18
  //= require bootstrap-affix
19
19
  //= require bootstrap-datepicker
20
+ //= require bootstrap-typeahead
20
21
 
21
22
  //= require outpost/base
22
23
  //= require outpost/templates
@@ -0,0 +1,37 @@
1
+ // Set column widths
2
+ $datetimeWidth: 140px;
3
+ $booleanWidth: 60px;
4
+ $integerWidth: 50px;
5
+ $statusWidth: 105px;
6
+
7
+ @mixin url-cell {
8
+ width: 250px;
9
+ word-break: break-all;
10
+ }
11
+
12
+ table {
13
+
14
+ ///////////////////
15
+ // Global
16
+ .column-manage {
17
+ width: 60px;
18
+ white-space: nowrap;
19
+ }
20
+
21
+ .column-status {
22
+ width: $statusWidth;
23
+ }
24
+
25
+ .column-datetime, .column-date {
26
+ width: $datetimeWidth;
27
+ }
28
+
29
+ .column-boolean {
30
+ width: $booleanWidth;
31
+ }
32
+
33
+ .column-id {
34
+ width: $integerWidth;
35
+ }
36
+
37
+ }
@@ -11,4 +11,5 @@ $iconRedSpritePath: 'glyphicons-halflings-red.png';
11
11
  @import "outpost/edit";
12
12
  @import "outpost/forms";
13
13
  @import "outpost/index";
14
+ @import "outpost/columns";
14
15
  @import "outpost/utility";
@@ -14,7 +14,7 @@
14
14
  <div class="navbar navbar-fixed-top navbar-inverse">
15
15
  <div class="navbar-inner">
16
16
  <div class="container">
17
- <a href="<%=outpost_root_path%>" class="brand">Outpost</a>
17
+ <a href="<%=outpost_root_path%>" class="brand"><%= image_tag "outpost/logo.png" %></a>
18
18
 
19
19
  <% if current_user %>
20
20
  <ul class="nav">
@@ -22,7 +22,7 @@
22
22
  <!-- Full Navigation -->
23
23
  <li class="dropdown">
24
24
  <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-align-justify icon-white"></i> Navigation <b class="caret"></b></a>
25
- <% models = current_user.allowed_resources.sort_by(&:name) %>
25
+ <% models = current_user.respond_to?(:allowed_resources) ? current_user.allowed_resources.sort_by(&:name) : Outpost.config.registered_models.map(&:safe_constantize) %>
26
26
  <% per_col = 20 %>
27
27
  <% cols = (models.size.to_f / per_col.to_f).ceil %>
28
28
 
@@ -1,6 +1,6 @@
1
1
  <li class="dropdown">
2
2
  <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-align-justify icon-white"></i> Navigation <b class="caret"></b></a>
3
- <% models = current_user.allowed_resources.sort_by(&:name) %>
3
+ <% models = current_user.respond_to?(:allowed_resources) ? current_user.allowed_resources.sort_by(&:name) : Outpost.config.registered_models.map(&:safe_constantize) %>
4
4
  <% per_col = 20 %>
5
5
  <% cols = (models.size.to_f / per_col.to_f).ceil %>
6
6
 
@@ -16,8 +16,14 @@ module Outpost
16
16
  collection = options[:collection]
17
17
  @collection = begin
18
18
  case collection
19
- when NilClass
20
- # TODO Automatically detect column type
19
+ when NilClass # No collection given. Find it ourselves.
20
+ if list.model.column_names.include?(@attribute)
21
+ -> {
22
+ list.model.order(@attribute).pluck("distinct #{@attribute}")
23
+ }
24
+ else
25
+ # TODO Handle association filtering
26
+ end
21
27
  when Proc
22
28
  collection
23
29
  when Symbol
@@ -22,6 +22,20 @@ module Outpost
22
22
  extend ActiveSupport::Concern
23
23
 
24
24
  module ClassMethods
25
+ attr_accessor :public_route_key
26
+
27
+ def public_route_key
28
+ if !@public_route_key && defined?(self::ROUTE_KEY)
29
+ @public_route_key = self::ROUTE_KEY
30
+
31
+ ActiveSupport::Deprecation.warn(
32
+ "ROUTE_KEY is deprecated. Please move it to `public_route_key`.")
33
+ end
34
+
35
+ @public_route_key
36
+ end
37
+
38
+
25
39
  # /outpost/blog_entries/new
26
40
  def admin_new_path
27
41
  collection_route("new_outpost_#{self.singular_route_key}_path")
@@ -84,17 +98,17 @@ module Outpost
84
98
  alias_method :admin_destroy_url, :admin_show_url
85
99
 
86
100
 
87
- # Uses self.class::ROUTE_KEY to generate
101
+ # Uses self.class.public_route_key to generate
88
102
  # the front-end path to this object
89
103
  # If an object doesn't have a front-end path,
90
- # do not define a ROUTE_KEY on the class.
104
+ # do not define a public_route_key on the class.
91
105
  #
92
106
  # If the object isn't public, then leave route_hash
93
107
  # empty as well.
94
108
  def public_path(options={})
95
- if self.route_hash.present? && defined?(self.class::ROUTE_KEY)
109
+ if self.route_hash.present? && self.class.public_route_key
96
110
  Rails.application.routes.url_helpers.send(
97
- "#{self.class::ROUTE_KEY}_path", options.merge!(self.route_hash))
111
+ "#{self.class.public_route_key}_path", options.merge!(self.route_hash))
98
112
  end
99
113
  end
100
114
 
data/lib/outpost/model.rb CHANGED
@@ -14,8 +14,13 @@ module Outpost
14
14
  autoload :Serializer
15
15
 
16
16
  module ClassMethods
17
- def outpost_model
17
+ def outpost_model(options={})
18
18
  include Methods, Identifier, Routing, Naming, Serializer
19
+
20
+ # Convenience for setting options on the class.
21
+ options.each do |option, value|
22
+ send("#{option}=", value)
23
+ end
19
24
  end
20
25
  end # ClassMethods
21
26
  end # Model
@@ -1,3 +1,3 @@
1
1
  module Outpost
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -1,6 +1,5 @@
1
1
  class Person < ActiveRecord::Base
2
- outpost_model
3
- ROUTE_KEY = "person"
2
+ outpost_model public_route_key: "person"
4
3
 
5
4
  validates :name, presence: true
6
5
  validates :email, presence: true
@@ -130,7 +130,7 @@ describe Outpost::Model::Routing do
130
130
  person.public_path.should eq nil
131
131
  end
132
132
 
133
- it "returns nil if if ROUTE_KEY isn't defined" do
133
+ it "returns nil if if public_route_key isn't defined" do
134
134
  pidgeon = Pidgeon.new
135
135
  pidgeon.stub(:route_hash) { { id: 1, slug: "cool-dude" } }
136
136
  pidgeon.public_path.should eq nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: outpost-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Ricker
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-13 00:00:00.000000000 Z
12
+ date: 2014-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 3.0.0
55
55
  - - "<"
56
56
  - !ruby/object:Gem::Version
57
- version: '5'
57
+ version: '4'
58
58
  type: :runtime
59
59
  prerelease: false
60
60
  version_requirements: !ruby/object:Gem::Requirement
@@ -64,7 +64,7 @@ dependencies:
64
64
  version: 3.0.0
65
65
  - - "<"
66
66
  - !ruby/object:Gem::Version
67
- version: '5'
67
+ version: '4'
68
68
  - !ruby/object:Gem::Dependency
69
69
  name: select2-rails
70
70
  requirement: !ruby/object:Gem::Requirement
@@ -79,6 +79,20 @@ dependencies:
79
79
  - - '='
80
80
  - !ruby/object:Gem::Version
81
81
  version: 3.4.1
82
+ - !ruby/object:Gem::Dependency
83
+ name: kaminari
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 0.15.1
89
+ type: :runtime
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: 0.15.1
82
96
  description: This engine plugs into your Rails application and provides a plethora
83
97
  of useful methods, concerns, helpers, and conventions to help you quickly build
84
98
  a CMS for your Newsroom.
@@ -92,6 +106,7 @@ files:
92
106
  - README.md
93
107
  - Rakefile
94
108
  - app/assets/images/glyphicons-halflings-red.png
109
+ - app/assets/images/outpost/logo.png
95
110
  - app/assets/javascripts/outpost.js
96
111
  - app/assets/javascripts/outpost/application.js
97
112
  - app/assets/javascripts/outpost/auto_slug_field.js.coffee
@@ -111,6 +126,7 @@ files:
111
126
  - app/assets/javascripts/outpost/utilities.js.coffee
112
127
  - app/assets/stylesheets/outpost.css.scss
113
128
  - app/assets/stylesheets/outpost/_base.css.scss
129
+ - app/assets/stylesheets/outpost/_columns.css.scss
114
130
  - app/assets/stylesheets/outpost/_edit.css.scss
115
131
  - app/assets/stylesheets/outpost/_forms.css.scss
116
132
  - app/assets/stylesheets/outpost/_index.css.scss