shoestrap 1.0.2 → 1.1.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 +4 -0
- data/lib/generators/shoestrap/cms_generator.rb +15 -14
- data/lib/generators/shoestrap/gem_install_generator.rb +0 -1
- data/lib/shoestrap/cms_model.rb +25 -0
- data/lib/shoestrap/version.rb +1 -1
- data/spec/shoestrap/cms_model.rb +29 -0
- data/templates/cms_generator/inherited_views/base/_form.html.haml +2 -2
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5160f485c9d7e9e55efcb16dd0fb1d197fa9be3
|
4
|
+
data.tar.gz: 57c03550346f52fa0794c28bd105b21c6b00c4d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c13e977d49958f335020cd0e5a37f5faf25e5e87ec8014bdc6f763c616ac0d2df9a610821b0ad300c840ba2d71b612263342af84802816223706e49127d9ea2d
|
7
|
+
data.tar.gz: 90f4bc4bbc510478a72a7a8742a4f99e60638f0fe80e50ba4bc814806e519bf775cd6899867ec036ffda1162e154d824b67ebe01f24987a4018d26be7ebc3cb4
|
data/CHANGELOG.md
CHANGED
@@ -29,20 +29,21 @@ module Shoestrap
|
|
29
29
|
|
30
30
|
def add_model_and_migration
|
31
31
|
generate 'model', model_name
|
32
|
-
|
32
|
+
inject_into_file "app/models/#{model_name}.rb", before: 'class' do
|
33
|
+
"require 'shoestrap/cms_model'\n\n"
|
34
|
+
end
|
35
|
+
|
33
36
|
inject_into_file "app/models/#{model_name}.rb", before: 'end' do
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end\n
|
45
|
-
"
|
37
|
+
<<-eos.gsub(/^ {8}/, '').chomp
|
38
|
+
include Shoestrap::CMSModel
|
39
|
+
|
40
|
+
# TODO: Define what attributes are shown in the form and permitted by strong parameters
|
41
|
+
# editable_attributes :title, :body
|
42
|
+
|
43
|
+
# TODO: Define what attributes are shown in the index view
|
44
|
+
# index_attributes :id, :title
|
45
|
+
|
46
|
+
eos
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
@@ -58,7 +59,7 @@ module Shoestrap
|
|
58
59
|
private
|
59
60
|
|
60
61
|
def shoestrap_cms_already_installed?
|
61
|
-
File.exists?
|
62
|
+
File.exists?('app/controllers/shoestrap/base_controller.rb') && File.exists?('config/cms_navigation.rb')
|
62
63
|
end
|
63
64
|
|
64
65
|
def setup_base_controller
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Shoestrap
|
2
|
+
module CMSModel
|
3
|
+
def self.included(base)
|
4
|
+
base.extend(ClassMethods)
|
5
|
+
end
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def index_attributes(*attributes)
|
9
|
+
if attributes.empty?
|
10
|
+
instance_variable_get(:@shoestrap_index_attributes)
|
11
|
+
else
|
12
|
+
instance_variable_set(:@shoestrap_index_attributes, attributes)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def editable_attributes(*attributes)
|
17
|
+
if attributes.empty?
|
18
|
+
instance_variable_get(:@shoestrap_editable_attributes)
|
19
|
+
else
|
20
|
+
instance_variable_set(:@shoestrap_editable_attributes, attributes)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/shoestrap/version.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative '../../lib/shoestrap/cms_model'
|
2
|
+
require_relative '../spec_helper'
|
3
|
+
|
4
|
+
module Shoestrap
|
5
|
+
describe CMSModel do
|
6
|
+
|
7
|
+
describe 'index_attributes class macro' do
|
8
|
+
let(:dummy) { class Dummy; include Shoestrap::CMSModel; end }
|
9
|
+
|
10
|
+
it 'is a class macro' do
|
11
|
+
expect{ dummy.class_eval { index_attributes :title, :created_at } }.not_to raise_error
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'allows to define attribute names that should be shown in the index table' do
|
15
|
+
dummy.class_eval { index_attributes :title, :created_at }
|
16
|
+
expect(dummy.instance_variable_get('@shoestrap_index_attributes')).to eq [:title, :created_at]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'index attributes class method' do
|
21
|
+
let(:dummy) { class Dummy; include Shoestrap::CMSModel; end }
|
22
|
+
|
23
|
+
it 'returns the attribute names defined with class macro' do
|
24
|
+
dummy.class_eval { index_attributes :title, :created_at }
|
25
|
+
expect(dummy.index_attributes).to eq [:title, :created_at]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
= simple_form_for([:cms, resource]
|
1
|
+
= simple_form_for([:cms, resource], wrapper: :bootstrap) do |f|
|
2
2
|
= f.error_notification
|
3
3
|
|
4
4
|
.form-inputs
|
5
|
-
- resource.class.
|
5
|
+
- resource.class.editable_attributes.each do |column_name|
|
6
6
|
= f.input column_name
|
7
7
|
|
8
8
|
.form-actions
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoestrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felipe Kaufmann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -214,12 +214,14 @@ files:
|
|
214
214
|
- lib/shoestrap.rb
|
215
215
|
- lib/shoestrap/application_generator.rb
|
216
216
|
- lib/shoestrap/cli.rb
|
217
|
+
- lib/shoestrap/cms_model.rb
|
217
218
|
- lib/shoestrap/railtie.rb
|
218
219
|
- lib/shoestrap/shell.rb
|
219
220
|
- lib/shoestrap/version.rb
|
220
221
|
- shoestrap.gemspec
|
221
222
|
- spec/shoestrap/application_generator_spec.rb
|
222
223
|
- spec/shoestrap/cli_spec.rb
|
224
|
+
- spec/shoestrap/cms_model.rb
|
223
225
|
- spec/spec_helper.rb
|
224
226
|
- templates/application_generator/_typekit.html.haml
|
225
227
|
- templates/application_generator/application.html.haml
|
@@ -303,4 +305,5 @@ test_files:
|
|
303
305
|
- features/shoestrap/generators/view_files_generator_spec.rb
|
304
306
|
- spec/shoestrap/application_generator_spec.rb
|
305
307
|
- spec/shoestrap/cli_spec.rb
|
308
|
+
- spec/shoestrap/cms_model.rb
|
306
309
|
- spec/spec_helper.rb
|