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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa995530b08a1b27bae9dde22b5b2fc9b30a9078
4
- data.tar.gz: 898b7a74ab585b3a2b5436e69c0f2b77b7fb7925
3
+ metadata.gz: 82dad8cdeb433e1a3211c81eea7ff0a61bb82fa6
4
+ data.tar.gz: 489504cc58fbf58bbcf9dde4fd0bb7aa3efdf45e
5
5
  SHA512:
6
- metadata.gz: 84c648d6662c2f964a1721c9dd2d0ca4a9d34532b59d76e3cc2887724e844e703c787d35d22b99c44bac2ab41700a505ad8527ae689506ae581fd105c1cea41d
7
- data.tar.gz: 568cd1deb6c9253a5f708b477b9ec932f2849ceec02264cc263a1adae9b79d218920e9fc936d1c138526281a226f1fac5f34ae06827bcc552a0282941a4497d4
6
+ metadata.gz: f2c2f7810a5c4e0591efee8d30e36b830b2f736c84d264214b0ec7aed89a15a00b6e2992e9a16c121c8281e5cacc7e602b8636e3cef883865602e0782963fb8c
7
+ data.tar.gz: c76ceec2047a4f2e3aecae0bc673b2fce543bd3ade3faff7d170ab150d28dc03e17a1e303c8ffe5aa4fcdbc269d97d18b8255117e33e8a42ea5953fffe76cf3b
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # 0.2.0 (16-09-15)
2
+ - Added:
3
+ - Support Rails Admin with built-in generator.
4
+ - Required ruby version to be 2.0.0.
5
+
6
+ - Refactor
7
+ - Convert ActiveAdmin into a generator for easy access to default configuration.
data/Gemfile CHANGED
@@ -3,3 +3,5 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in changeful.gemspec
4
4
 
5
5
  gemspec
6
+
7
+ gem 'codeclimate-test-reporter', group: :test, require: nil
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Changeful
2
-
2
+ [![Gem Version](https://badge.fury.io/rb/changeful.svg)](http://badge.fury.io/rb/changeful)
3
3
  [![Build Status](https://travis-ci.org/futureworkz/changeful.svg?branch=master)](https://travis-ci.org/futureworkz/changeful)
4
4
  [![Dependency Status](https://gemnasium.com/futureworkz/changeful.svg)](https://gemnasium.com/futureworkz/changeful)
5
5
  [![Code Climate](https://codeclimate.com/github/futureworkz/changeful/badges/gpa.svg)](https://codeclimate.com/github/futureworkz/changeful)
@@ -21,36 +21,35 @@ gem 'changeful'
21
21
 
22
22
  And then execute:
23
23
 
24
- ```ruby
24
+ ```
25
25
  $ bundle install
26
26
  ```
27
27
 
28
28
  Or install it yourself as:
29
29
 
30
- ```ruby
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
- ```ruby
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
- ```ruby
45
- rake db:migrate
44
+ ```
45
+ $ rake db:migrate
46
46
  ```
47
47
 
48
48
  ## Usage
49
49
 
50
50
  ### ERB
51
- ```ruby
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
- ```ruby
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
- ```ruby
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
- Currently it only work well with ActiveAdmin
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
- Register the model with ActiveAdmin
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
- rails g active_admin:resource Changeful::Content
113
- ```
122
+ # config/initializers/rails_admin.rb
123
+
124
+ config.included_models = ["Changeful::Content", "YourOwnModel", "YourAnotherModel" ]
125
+ ```
114
126
 
115
- By default it will create `changeful_content.rb` in `app/admin` folder
127
+ OR you can run the following CLI to generate the model.
116
128
 
117
- #### Configuration for ActiveAdmin
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
- Copy the setup below to `changeful_content.rb`
135
+ Note: The default configuration for text editor assumes you are using the `ckeditor` gem, replace the editor accordingly.
120
136
 
121
- Note: the example below is using `ckeditor` gem, replace the editor accordingly.
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
- ActiveAdmin.register Changeful::Content do
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
- show do
138
- attributes_table do
139
- row :id
140
- row :file_path
141
- row :key
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
- form do |f|
148
- f.inputs 'Details' do
149
- input :key, input_html: { disabled: true }
150
- if f.object.view_type == 'html'
151
- input :content, as: :ckeditor
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 = "changeful"
7
+ spec.name = 'changeful'
8
8
  spec.version = Changeful::VERSION
9
- spec.authors = ["Wayne Tng"]
10
- spec.email = ["wayne@futureworkz.com"]
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 = "https://github.com/futureworkz/changeful"
15
- spec.license = "MIT"
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 = "exe"
18
+ spec.bindir = 'exe'
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
20
+ spec.require_paths = ['lib']
21
+ spec.required_ruby_version = '>= 2.0.0'
21
22
 
22
- spec.add_dependency "rails", "> 4.2.0"
23
+ spec.add_dependency 'rails', '> 4.2.0'
23
24
 
24
- spec.add_development_dependency "rake", "~> 10.0"
25
- spec.add_development_dependency "sqlite3"
26
- spec.add_development_dependency "rspec-rails"
27
- spec.add_development_dependency "generator_spec"
28
- spec.add_development_dependency "shoulda-matchers"
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 "changeful/version"
2
- require "changeful/models/changeful_content"
3
- require "changeful/helpers/view_helpers"
4
- require "active_support/lazy_load_hooks"
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
- include Changeful::ViewHelpers
7
+ include Changeful::ViewHelpers
8
8
  end
9
9
 
10
10
  module Changeful # :nodoc:
11
- # Your code goes here...
12
11
  end
@@ -1,3 +1,3 @@
1
1
  module Changeful
2
- VERSION = "0.1.0"
2
+ VERSION = '0.2.0'
3
3
  end
@@ -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
@@ -1,4 +1,4 @@
1
- class CreateChangefulContents < ActiveRecord::Migration # :nodoc:
1
+ class CreateChangefulContents < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :changeful_contents do |t|
4
4
  t.string :key
@@ -0,0 +1,3 @@
1
+ class ChangefulContent < ActiveRecord::Base
2
+
3
+ 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.1.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-07 00:00:00.000000000 Z
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: '0'
145
+ version: 2.0.0
138
146
  required_rubygems_version: !ruby/object:Gem::Requirement
139
147
  requirements:
140
148
  - - ">="