changeful 0.1.0 → 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 +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile +2 -0
- data/README.md +66 -51
- data/changeful.gemspec +14 -13
- data/lib/changeful.rb +5 -6
- data/lib/changeful/version.rb +1 -1
- data/lib/generators/changeful/model_generator.rb +13 -0
- data/lib/generators/changeful/models/active_admin_generator.rb +15 -0
- data/lib/generators/changeful/models/rails_admin_generator.rb +15 -0
- data/lib/generators/changeful/templates/active_admin.rb +35 -0
- data/lib/generators/changeful/templates/migration.rb +1 -1
- data/lib/generators/changeful/templates/model.rb +3 -0
- data/lib/generators/changeful/templates/rails_admin.rb +41 -0
- metadata +11 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82dad8cdeb433e1a3211c81eea7ff0a61bb82fa6
|
4
|
+
data.tar.gz: 489504cc58fbf58bbcf9dde4fd0bb7aa3efdf45e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2c2f7810a5c4e0591efee8d30e36b830b2f736c84d264214b0ec7aed89a15a00b6e2992e9a16c121c8281e5cacc7e602b8636e3cef883865602e0782963fb8c
|
7
|
+
data.tar.gz: c76ceec2047a4f2e3aecae0bc673b2fce543bd3ade3faff7d170ab150d28dc03e17a1e303c8ffe5aa4fcdbc269d97d18b8255117e33e8a42ea5953fffe76cf3b
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Changeful
|
2
|
-
|
2
|
+
[](http://badge.fury.io/rb/changeful)
|
3
3
|
[](https://travis-ci.org/futureworkz/changeful)
|
4
4
|
[](https://gemnasium.com/futureworkz/changeful)
|
5
5
|
[](https://codeclimate.com/github/futureworkz/changeful)
|
@@ -21,36 +21,35 @@ gem 'changeful'
|
|
21
21
|
|
22
22
|
And then execute:
|
23
23
|
|
24
|
-
```
|
24
|
+
```
|
25
25
|
$ bundle install
|
26
26
|
```
|
27
27
|
|
28
28
|
Or install it yourself as:
|
29
29
|
|
30
|
-
```
|
30
|
+
```
|
31
31
|
$ gem install changeful
|
32
32
|
```
|
33
33
|
|
34
34
|
After you install Changeful to your Gemfile, you need to run the generator:
|
35
35
|
|
36
|
-
```
|
37
|
-
rails generate changeful:install
|
36
|
+
```
|
37
|
+
$ rails generate changeful:install
|
38
38
|
```
|
39
39
|
|
40
40
|
This will generate the migration needed for Changeful
|
41
41
|
|
42
42
|
Run the migration to update the schema
|
43
43
|
|
44
|
-
```
|
45
|
-
rake db:migrate
|
44
|
+
```
|
45
|
+
$ rake db:migrate
|
46
46
|
```
|
47
47
|
|
48
48
|
## Usage
|
49
49
|
|
50
50
|
### ERB
|
51
|
-
```
|
51
|
+
```erb
|
52
52
|
<h1><%= changeful_content(:about_us_title) %></h1>
|
53
|
-
|
54
53
|
<div class='about-us-content'>
|
55
54
|
<%= changeful_content :about_us_content do %>
|
56
55
|
<p>You can also include HTML content as the default content in a block.</p>
|
@@ -60,7 +59,7 @@ rake db:migrate
|
|
60
59
|
```
|
61
60
|
|
62
61
|
### HAML
|
63
|
-
```
|
62
|
+
```haml
|
64
63
|
%h1= changeful_content(:about_us_title)
|
65
64
|
.about-us-content
|
66
65
|
= changeful_content :about_us_content do
|
@@ -69,9 +68,8 @@ rake db:migrate
|
|
69
68
|
```
|
70
69
|
|
71
70
|
### Slim
|
72
|
-
```
|
71
|
+
```slim
|
73
72
|
h1 = changeful_content(:about_us_title)
|
74
|
-
|
75
73
|
.about-us-content
|
76
74
|
= changeful_content :about_us_content do
|
77
75
|
p You can also include HTML content as the default content in a block.
|
@@ -104,59 +102,71 @@ cc :about_us_title, default: 'About Us', type: :plain
|
|
104
102
|
## Integration with back-end
|
105
103
|
|
106
104
|
### ActiveAdmin
|
107
|
-
|
105
|
+
Run the following CLI to generate the model
|
106
|
+
|
107
|
+
```
|
108
|
+
$ rails generate changeful:models:active_admin
|
109
|
+
```
|
110
|
+
|
111
|
+
By default it will create `changeful_content.rb` in `app/admin` folder with the default configuration.
|
112
|
+
|
113
|
+
Note: The default configuration for text editor assumes you are using the `ckeditor` gem, replace the editor accordingly.
|
108
114
|
|
109
|
-
|
115
|
+
|
116
|
+
### Rails Admin
|
117
|
+
There are two approaches to set up rails admin.
|
118
|
+
|
119
|
+
To include the ALL models manually.
|
110
120
|
|
111
121
|
```ruby
|
112
|
-
|
113
|
-
|
122
|
+
# config/initializers/rails_admin.rb
|
123
|
+
|
124
|
+
config.included_models = ["Changeful::Content", "YourOwnModel", "YourAnotherModel" ]
|
125
|
+
```
|
114
126
|
|
115
|
-
|
127
|
+
OR you can run the following CLI to generate the model.
|
116
128
|
|
117
|
-
|
129
|
+
```
|
130
|
+
$ rails generate changeful:models:rails_admin
|
131
|
+
```
|
132
|
+
|
133
|
+
This will generate `changeful_content.rb` in `app/model` with the default configuration for rails admin.
|
118
134
|
|
119
|
-
|
135
|
+
Note: The default configuration for text editor assumes you are using the `ckeditor` gem, replace the editor accordingly.
|
120
136
|
|
121
|
-
|
137
|
+
In the case where default configuration is not needed, run the following CLI.
|
138
|
+
|
139
|
+
```
|
140
|
+
$ rails generate changeful:model
|
141
|
+
```
|
142
|
+
|
143
|
+
This will generate a fresh `changeful_content.rb` in `app/model`
|
144
|
+
|
145
|
+
#### Additional Configuration for Rails Admin
|
146
|
+
You may wish to deactivate `create` to prevent users from creating records in changeful content.
|
147
|
+
|
148
|
+
`destroy` is optional, if the admin delete the record, the `default` option will be trigger and re-create the content accordingly.
|
122
149
|
|
123
150
|
```ruby
|
124
|
-
|
125
|
-
permit_params :content
|
126
|
-
actions :all, except: [:new]
|
127
|
-
|
128
|
-
index do
|
129
|
-
selectable_column
|
130
|
-
id_column
|
131
|
-
column :key, ->(row) { row.key.titleize }
|
132
|
-
column :content
|
133
|
-
column :updated_at
|
134
|
-
actions
|
135
|
-
end
|
151
|
+
# config/initializers/rails_admin.rb
|
136
152
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
row :content
|
143
|
-
row :updated_at
|
144
|
-
end
|
153
|
+
config.actions do
|
154
|
+
dashboard # mandatory
|
155
|
+
index # mandatory
|
156
|
+
new do
|
157
|
+
except ['ChangefulContent']
|
145
158
|
end
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
else
|
153
|
-
input :content
|
154
|
-
end
|
155
|
-
end
|
156
|
-
actions
|
159
|
+
export
|
160
|
+
bulk_delete
|
161
|
+
show
|
162
|
+
edit
|
163
|
+
delete do
|
164
|
+
except ['ChangefulContent']
|
157
165
|
end
|
166
|
+
show_in_app
|
158
167
|
end
|
159
168
|
```
|
169
|
+
|
160
170
|
## Contributing
|
161
171
|
|
162
172
|
1. Fork it ( https://github.com/futureworkz/changeful/fork )
|
@@ -167,3 +177,8 @@ end
|
|
167
177
|
|
168
178
|
## License
|
169
179
|
Changeful is Copyright © 2015 Futureworkz Pte Ltd. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
|
180
|
+
|
181
|
+
## About Futureworkz
|
182
|
+
<a href='http://www.futureworkz.com' title='Futureworkz - Ruby on Rails development' target='_blank'><img src='https://s3-ap-southeast-1.amazonaws.com/futureworkz/3rd-party/logo.png' alt='Futureworkz - Ruby on Rails development'/></a>
|
183
|
+
|
184
|
+
Changeful is maintained by <a href='http://www.futureworkz.com' title='Futureworkz - Ruby on Rails development' target='_blank'> Futureworkz </a>.
|
data/changeful.gemspec
CHANGED
@@ -4,26 +4,27 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'changeful/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'changeful'
|
8
8
|
spec.version = Changeful::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Wayne Tng', 'Steven Yap']
|
10
|
+
spec.email = ['wayne@futureworkz.com']
|
11
11
|
|
12
12
|
spec.summary = %q{Make your static contents editable in database}
|
13
13
|
spec.description = %q{Changeful is a gem that converts your static content in your views to be stored into database. Thereafter, administrator can use RailsAdmin or Active Admin to edit the static content.}
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
14
|
+
spec.homepage = 'https://github.com/futureworkz/changeful'
|
15
|
+
spec.license = 'MIT'
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.bindir =
|
18
|
+
spec.bindir = 'exe'
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = [
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
spec.required_ruby_version = '>= 2.0.0'
|
21
22
|
|
22
|
-
spec.add_dependency
|
23
|
+
spec.add_dependency 'rails', '> 4.2.0'
|
23
24
|
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'sqlite3'
|
27
|
+
spec.add_development_dependency 'rspec-rails'
|
28
|
+
spec.add_development_dependency 'generator_spec'
|
29
|
+
spec.add_development_dependency 'shoulda-matchers'
|
29
30
|
end
|
data/lib/changeful.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require 'changeful/version'
|
2
|
+
require 'changeful/models/changeful_content'
|
3
|
+
require 'changeful/helpers/view_helpers'
|
4
|
+
require 'active_support/lazy_load_hooks'
|
5
5
|
|
6
6
|
ActiveSupport.on_load(:action_view) do
|
7
|
-
|
7
|
+
include Changeful::ViewHelpers
|
8
8
|
end
|
9
9
|
|
10
10
|
module Changeful # :nodoc:
|
11
|
-
# Your code goes here...
|
12
11
|
end
|
data/lib/changeful/version.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
module Changeful
|
4
|
+
module Generators
|
5
|
+
class ModelGenerator < Rails::Generators::Base # :nodoc:
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
|
8
|
+
def copy_changeful_model_file
|
9
|
+
copy_file 'model.rb', 'app/models/changeful_content.rb'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
module Changeful
|
4
|
+
module Generators
|
5
|
+
module Models
|
6
|
+
class ActiveAdminGenerator < Rails::Generators::Base # :nodoc:
|
7
|
+
source_root File.expand_path('../../templates', __FILE__)
|
8
|
+
|
9
|
+
def copy_changeful_active_admin_model_file
|
10
|
+
copy_file 'active_admin.rb', 'app/admin/changeful_content.rb'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
module Changeful
|
4
|
+
module Generators
|
5
|
+
module Models
|
6
|
+
class RailsAdminGenerator < Rails::Generators::Base # :nodoc:
|
7
|
+
source_root File.expand_path('../../templates', __FILE__)
|
8
|
+
|
9
|
+
def copy_changeful_rails_admin_model_file
|
10
|
+
copy_file 'rails_admin.rb', 'app/models/changeful_content.rb'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
ActiveAdmin.register Changeful::Content, as: 'Contents' do
|
2
|
+
permit_params :content
|
3
|
+
actions :all, except: [:new, :destroy]
|
4
|
+
|
5
|
+
index do
|
6
|
+
selectable_column
|
7
|
+
id_column
|
8
|
+
column :key, ->(row) { row.key.titleize }
|
9
|
+
column :content
|
10
|
+
column :updated_at
|
11
|
+
actions
|
12
|
+
end
|
13
|
+
|
14
|
+
show do
|
15
|
+
attributes_table do
|
16
|
+
row :id
|
17
|
+
row :file_path
|
18
|
+
row :key
|
19
|
+
row :content
|
20
|
+
row :updated_at
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
form do |f|
|
25
|
+
f.inputs 'Details' do
|
26
|
+
input :key, input_html: { disabled: true }
|
27
|
+
if f.object.view_type == 'html'
|
28
|
+
input :content, as: :ckeditor
|
29
|
+
else
|
30
|
+
input :content
|
31
|
+
end
|
32
|
+
end
|
33
|
+
actions
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class ChangefulContent < ActiveRecord::Base
|
2
|
+
rails_admin do
|
3
|
+
label 'Content'
|
4
|
+
label_plural 'Contents'
|
5
|
+
list do
|
6
|
+
field :id
|
7
|
+
field :key
|
8
|
+
field :content
|
9
|
+
field :file_path
|
10
|
+
field :updated_at do
|
11
|
+
strftime_format "%d-%m-%y"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
show do
|
16
|
+
field :id
|
17
|
+
field :key
|
18
|
+
field :content
|
19
|
+
field :file_path
|
20
|
+
field :updated_at do
|
21
|
+
strftime_format "%d-%m-%y"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
edit do
|
26
|
+
field :id do
|
27
|
+
read_only true
|
28
|
+
help false
|
29
|
+
end
|
30
|
+
field :key do
|
31
|
+
read_only true
|
32
|
+
help false
|
33
|
+
end
|
34
|
+
field :content, :ck_editor
|
35
|
+
field :file_path do
|
36
|
+
read_only true
|
37
|
+
help false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: changeful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wayne Tng
|
8
|
+
- Steven Yap
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
12
|
+
date: 2015-09-16 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rails
|
@@ -108,6 +109,7 @@ files:
|
|
108
109
|
- ".ruby-gemset"
|
109
110
|
- ".ruby-version"
|
110
111
|
- ".travis.yml"
|
112
|
+
- CHANGELOG.md
|
111
113
|
- CODE_OF_CONDUCT.md
|
112
114
|
- Gemfile
|
113
115
|
- LICENSE.txt
|
@@ -121,7 +123,13 @@ files:
|
|
121
123
|
- lib/changeful/models/changeful_content.rb
|
122
124
|
- lib/changeful/version.rb
|
123
125
|
- lib/generators/changeful/install_generator.rb
|
126
|
+
- lib/generators/changeful/model_generator.rb
|
127
|
+
- lib/generators/changeful/models/active_admin_generator.rb
|
128
|
+
- lib/generators/changeful/models/rails_admin_generator.rb
|
129
|
+
- lib/generators/changeful/templates/active_admin.rb
|
124
130
|
- lib/generators/changeful/templates/migration.rb
|
131
|
+
- lib/generators/changeful/templates/model.rb
|
132
|
+
- lib/generators/changeful/templates/rails_admin.rb
|
125
133
|
homepage: https://github.com/futureworkz/changeful
|
126
134
|
licenses:
|
127
135
|
- MIT
|
@@ -134,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
134
142
|
requirements:
|
135
143
|
- - ">="
|
136
144
|
- !ruby/object:Gem::Version
|
137
|
-
version:
|
145
|
+
version: 2.0.0
|
138
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
147
|
requirements:
|
140
148
|
- - ">="
|