cmsable 0.4.1 → 0.6.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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YmQxZWViNjU4MjJiMzBiMGE1NzU1YzYwOTQxMWY3YWY0YmIyYTk1OQ==
4
+ YTdkODZlM2IyMDM2MjYyODk4YzExYmM3MWU1MDVjNTdlMTEwZTg1Yg==
5
5
  data.tar.gz: !binary |-
6
- ZWMwY2RhM2U5MzdjNTQ3NGY4NjEwYjNhNTM0MGI3YWYzN2Y0YzQ1YQ==
6
+ M2IwYjI0MDA3YWEzN2MwNWZiN2UzZTFiZTI3ZjNkYWYyYjdiMDUxMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDk1MjM2MDFkZDI5MjhhYmU4OGZlYjZkNWJjNDQwZTNhZWIzMTUzYzFiMmY1
10
- MjdiYzE4OTQ5ZmI2MDhmNmI3OGQwMTBhZjZkOWNmMmRiZDQ5OTU4ZGM1OGVh
11
- YjUyNmIwZjZmNmQyMzhkNjQxZmZjYTJlMDQ0ZTBjZjNlNWMxODQ=
9
+ ZDdjYWIwYWZmZTNkZjJkOWQ5NmNjM2Y1NmY0MjVkZTIyZDcxZWNmNWJhNWFl
10
+ OWUwNTcyMDI3NjM5MzgxNjY5YjJlZDg1ODE2MDZhNjk2ZjdiM2JkNWY4ODZm
11
+ YzM0ZjgyYTlmMDczZmU5MDM4NDNlNmZhNDI1YWMzMjgyZGFmM2I=
12
12
  data.tar.gz: !binary |-
13
- YTE1YzE4Mzc1MmZiYzk0MTBhODgyOGNiNTVkZTVmOTkxODFlMzU2NTc4ZmU1
14
- ZTFlNzcxNDBiZjk0YTJmMWQwMDIxOThlNDkwMzUzM2FhMTY0ZWVjNWQ5YWFk
15
- MTBjOTk3ZTg5ZWUwMjJlNTg4YzM0N2NlYTgxNjQyYjdlNjVkMjA=
13
+ Y2ZhMTM3OTZiZjUzYWIwM2ZlMzdhNzMyZmY0MTVmNTkxMjQ3Y2RmNTY0ZTI1
14
+ NjEzZmNkZDY1MTcwMjAzODk2OWJhN2JmYTg1N2RjYmFjN2MyZTczMzQyM2Jk
15
+ ODkxZGIzZTU2OTU4OGI0Y2VjOWRjYTY0ZmJlNzBkYjdmYmE4MTY=
data/README.md CHANGED
@@ -42,27 +42,21 @@ end
42
42
 
43
43
  ## Usage
44
44
 
45
- Add to your layout:
46
-
47
- ```ruby
48
- <%= cmsable_assets %>
49
- ```
50
-
51
45
  ### To use the built in model
52
46
  In your view files
53
47
 
54
48
  ```ruby
55
- <%= cmsable 'identifier' %>
49
+ <%= cms 'identifier' %>
56
50
  ```
57
51
 
58
52
  Identifier can be any string or symbol, for example `'Homepage Intro'` or `:something`
59
53
 
60
- For plain text areas pass `plain: true` as an option.
54
+ For plain text areas pass `type: :plain` as an option.
61
55
  This way you can put content in any tag you want without worrying about users
62
56
  messing up the markup.
63
57
 
64
58
  ```ruby
65
- <span><%= cmsable :identifier, plain: true %></span>
59
+ <span><%= cms :identifier, type: :plain %></span>
66
60
  ```
67
61
 
68
62
  The problem with the above is that in edit mode you'll end up with invalid HTML:
@@ -74,7 +68,7 @@ The problem with the above is that in edit mode you'll end up with invalid HTML:
74
68
  To avoid this you can override the tag used in edit mode:
75
69
 
76
70
  ```ruby
77
- <%= cmsable :identifier, plain: true, tag: 'span' %>
71
+ <%= cms :identifier, type: :plain, tag: 'span' %>
78
72
  ```
79
73
  Resulting in:
80
74
  ```html
@@ -85,22 +79,23 @@ Resulting in:
85
79
  Add to your model:
86
80
 
87
81
  ```ruby
88
- cmsable :body => :column_to_use_for_content
82
+ cms :body => :column_to_use_for_content
89
83
  ```
90
84
 
91
85
  Then in your views:
92
86
  ```ruby
93
- <%= cmsable @model_instance %>
87
+ <%= cms @model_instance %>
94
88
  ```
95
89
 
96
90
  ## TODO
91
+ - Allow classes on custom tags
92
+ - Fix highlight so empty areas are still visible
93
+ - Add image mode
94
+ - Add file mode
95
+ - Add video mode (youtube/vimeo/etc)
96
+ - Add support for langs/i18n
97
97
  - Handle saving errors
98
- - Remove CanCan dependancy
99
98
  - Decouple ckeditor
100
99
  - Support different editors
100
+ - Remove CanCan dependancy
101
101
  - Setup config initializer for added customizability
102
- - Add file mode
103
- - Add image mode
104
- - Add video mode (youtube/vimeo/etc)
105
- - Add support for langs/i18n
106
- - Fix highlight so empty areas are still visible
@@ -3,10 +3,13 @@ module Cmsable
3
3
  def update
4
4
  model = params[:model].constantize
5
5
 
6
- render :text => false and return if cannot? :update, model
6
+ render text: false and return if cannot? :update, model
7
7
 
8
+ record = model.find(params[:id])
9
+ body = params.require(:content).permit(:body)[:body]
8
10
  attribute = model.cmsable_body
9
- render :text => model.find(params[:id]).update_attribute(attribute, params[:content][:body])
11
+
12
+ render text: record.update(attribute => body)
10
13
  end
11
14
  end
12
15
  end
@@ -19,7 +19,7 @@ module Cmsable
19
19
  tag: nil # What tag to use for contenteditable
20
20
  }
21
21
 
22
- def cmsable(name_or_model, options = {})
22
+ def cms(name_or_model, options = {})
23
23
  model = get_model name_or_model
24
24
 
25
25
  options = DEFAULTS.merge options
@@ -3,9 +3,6 @@ module Cmsable
3
3
  # Extensions
4
4
  cmsable
5
5
 
6
- # Attribute accessibility
7
- attr_accessible :body, :name
8
-
9
6
  # Validations
10
7
  validates :name, :presence => true
11
8
 
@@ -21,7 +18,10 @@ module Cmsable
21
18
  end
22
19
 
23
20
  def self.get name
24
- find_or_create_by_name name, :body => I18n.t("cmsable.#{name}", default: "<p>Awaiting Content</p>")
21
+ find_or_create_by name: name do |record|
22
+ body = I18n.t("cmsable.#{name}", default: "<p>Awaiting Content</p><script>alert('Cmsable entry \"#{name}\" is awaiting content');</script>")
23
+ record.update body: body
24
+ end
25
25
  end
26
26
 
27
27
  # Scopes
@@ -1,3 +1,4 @@
1
+ <%= cmsable_assets %>
1
2
  <div id="cmsable_control">
2
3
  <a class="cmsable_edit">Edit Mode</a>
3
4
  <a class="cmsable_save" data-token="<%= form_authenticity_token %>">Save Changes</a>
@@ -1,4 +1,3 @@
1
1
  Cmsable::Engine.routes.draw do
2
- get '/:action', :to => 'cmsable'
3
2
  put '/:id', :to => 'cmsable#update'
4
3
  end
@@ -4,8 +4,8 @@ module Cmsable
4
4
  class Engine < ::Rails::Engine
5
5
  isolate_namespace Cmsable
6
6
  initializer 'cmsable.action_controller' do |app|
7
- ActiveSupport.on_load :action_controller do
8
- helper Cmsable::CmsableHelper
7
+ ActiveSupport.on_load :action_view do
8
+ include Cmsable::CmsableHelper
9
9
  end
10
10
  end
11
11
  end
@@ -1,3 +1,3 @@
1
1
  module Cmsable
2
- VERSION = '0.4.1'
2
+ VERSION = '0.6.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmsable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Butler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-26 00:00:00.000000000 Z
11
+ date: 2014-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '3.2'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ckeditor
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -84,7 +84,6 @@ files:
84
84
  - app/assets/stylesheets/cmsable/application.css
85
85
  - app/assets/stylesheets/cmsable/cmsable.css
86
86
  - app/controllers/cmsable/cmsable_controller.rb
87
- - app/helpers/cmsable/application_helper.rb
88
87
  - app/helpers/cmsable/cmsable_helper.rb
89
88
  - app/models/cmsable/content.rb
90
89
  - app/views/cmsable/cmsable/control.html.erb
@@ -1,4 +0,0 @@
1
- module Cmsable
2
- module ApplicationHelper
3
- end
4
- end