godmin 0.12.3 → 0.12.4

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: 7ca2bcb850c5153d711926873311e9bcd6b097cc
4
- data.tar.gz: dd1743579d7a139f5d46fe46fc9ba531d9944a45
3
+ metadata.gz: 23cb0a9e87abfb6bc2aac4b0185a5951ac29d558
4
+ data.tar.gz: 015627e42d6d719cf8d8c1e38d8d0ddd47aef510
5
5
  SHA512:
6
- metadata.gz: a1631d2deb602e75080c84ede97d5b8a019f50730679102fc9f254410c66e0d9d161796bad023618771d1b568662fab72ee920512cc4e5c9aa04fce482bb6d38
7
- data.tar.gz: b3e86c7325e55d74cab0e5b54c1f9eb63c88cf27a7591c61da97f50f8b9dd6c9bac83870920f50da8c8e6afb253ceabf2eb2e548ffc7e7eb6bfc8b5800d23bb2
6
+ metadata.gz: 5dbf6f79d8127cd2cf3d6434050be4c1270c0500912e92a23bde6fb98417335c9c91228def598cd9f14b03233908b4ab2b8db9832503c83df3c1513c0591a441
7
+ data.tar.gz: 1026fb15383f4b75be2bfa98160dad0340864c92510ec389c4725c464d9bc422fe1e68dbb0a8043f3742cfa46057d7f06987854652a215014ac27777f43a0421
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ### 0.12.4 - 2015-10-21
4
+ Bug fixes
5
+ - Fixes a bug which made it impossible to override the datetimepicker locale (https://github.com/varvet/godmin/issues/132)
6
+
3
7
  ### 0.12.3 - 2015-09-18
4
8
  Bug fixes
5
9
  - Adds support for plural engines (https://github.com/varvet/godmin/pull/128)
data/README.md CHANGED
@@ -44,6 +44,11 @@ Godmin supports two common admin scenarios:
44
44
  1. Standalone installation
45
45
  2. Engine installation
46
46
 
47
+ If you want to set up an example app that you can play around with, run the following:
48
+ ```sh
49
+ rails new sandbox -m https://raw.githubusercontent.com/varvet/godmin/master/template.rb
50
+ ```
51
+
47
52
  ### Standalone installation
48
53
  Use for admin-only applications, or for architectures where the admin lives in its own app. E.g. you want to access the admin section at `localhost:3000`.
49
54
 
@@ -817,7 +822,7 @@ Godmin.Datetimepickers.initializeDatetimepicker($el, {
817
822
  });
818
823
  ```
819
824
 
820
- If you wish to translate the datetimepicker, add the following to your `app/assets/javascripts/application.js`:
825
+ If you wish to translate the datetimepicker, change `moment/en-gb` in your `app/assets/javascripts/application.js` to your desired locale:
821
826
 
822
827
  ```js
823
828
  //= require moment
@@ -12,8 +12,6 @@
12
12
  //
13
13
  //= require jquery
14
14
  //= require jquery_ujs
15
- //= require moment
16
- //= require moment/en-gb
17
15
  //= require bootstrap-sprockets
18
16
  //= require bootstrap-datetimepicker
19
17
  //= require selectize
@@ -25,7 +25,11 @@ class Godmin::InstallGenerator < Godmin::Generators::Base
25
25
  application_js = File.join("app/assets/javascripts", namespaced_path, "application.js")
26
26
 
27
27
  inject_into_file application_js, before: "//= require_tree ." do
28
- "//= require godmin\n"
28
+ <<-END.strip_heredoc
29
+ //= require moment
30
+ //= require moment/en-gb
31
+ //= require godmin
32
+ END
29
33
  end
30
34
 
31
35
  gsub_file application_js, /\/\/= require turbolinks\n/, ""
@@ -1,3 +1,3 @@
1
1
  module Godmin
2
- VERSION = "0.12.3"
2
+ VERSION = "0.12.4"
3
3
  end
data/template.rb ADDED
@@ -0,0 +1,147 @@
1
+ require "active_support/all"
2
+
3
+ def install_standalone
4
+ gem "godmin", "> 0.12"
5
+
6
+ after_bundle do
7
+ generate_model
8
+ generate("godmin:install")
9
+ generate("godmin:resource", "article")
10
+
11
+ modify_controller
12
+ modify_service
13
+
14
+ migrate_and_seed
15
+ end
16
+ end
17
+
18
+ def install_engine
19
+ run_ruby_script("bin/rails plugin new admin --mountable")
20
+
21
+ gsub_file "admin/admin.gemspec", "TODO: ", ""
22
+ gsub_file "admin/admin.gemspec", "TODO", ""
23
+
24
+ inject_into_file "admin/admin.gemspec", before: /^end/ do
25
+ <<-END.strip_heredoc.indent(2)
26
+ s.add_dependency "godmin", "> 0.12"
27
+ END
28
+ end
29
+
30
+ gem "admin", path: "admin"
31
+
32
+ after_bundle do
33
+ generate_model
34
+ run_ruby_script("admin/bin/rails g godmin:install")
35
+ run_ruby_script("admin/bin/rails g godmin:resource article")
36
+
37
+ inject_into_file "config/routes.rb", before: /^end/ do
38
+ <<-END.strip_heredoc.indent(2)
39
+ mount Admin::Engine, at: "admin"
40
+ END
41
+ end
42
+
43
+ modify_controller("admin")
44
+ modify_service("admin")
45
+
46
+ migrate_and_seed
47
+ end
48
+ end
49
+
50
+ def generate_model
51
+ generate(:model, "article title:string body:text published:boolean published_at:datetime")
52
+
53
+ append_to_file "db/seeds.rb" do
54
+ <<-END.strip_heredoc
55
+ Article.create! title: "The first article", published: false
56
+ Article.create! title: "The second article", published: false
57
+ Article.create! title: "The third article", published: true, published_at: Time.zone.now
58
+ END
59
+ end
60
+ end
61
+
62
+ def modify_controller(namespace = nil)
63
+ articles_controller =
64
+ if namespace
65
+ "admin/app/controllers/admin/articles_controller.rb"
66
+ else
67
+ "app/controllers/articles_controller.rb"
68
+ end
69
+
70
+ inject_into_file articles_controller, after: "Godmin::Resources::ResourceController\n" do
71
+ <<-END.strip_heredoc.indent(namespace ? 4 : 2)
72
+
73
+ private
74
+
75
+ def redirect_after_batch_action_unpublish
76
+ articles_path(scope: :unpublished)
77
+ end
78
+
79
+ def redirect_after_batch_action_publish
80
+ articles_path(scope: :published)
81
+ end
82
+ END
83
+ end
84
+ end
85
+
86
+ def modify_service(namespace = nil)
87
+ article_service =
88
+ if namespace
89
+ "admin/app/services/admin/article_service.rb"
90
+ else
91
+ "app/services/article_service.rb"
92
+ end
93
+
94
+ gsub_file article_service, "attrs_for_index", "attrs_for_index :title, :published_at"
95
+ gsub_file article_service, "attrs_for_show", "attrs_for_show :title, :body, :published, :published_at"
96
+ gsub_file article_service, "attrs_for_form", "attrs_for_form :title, :body, :published, :published_at"
97
+
98
+ inject_into_file article_service, after: "attrs_for_form :title, :body, :published, :published_at \n" do
99
+ <<-END.strip_heredoc.indent(namespace ? 4 : 2)
100
+ attrs_for_export :id, :title, :published, :published_at
101
+
102
+ scope :unpublished
103
+ scope :published
104
+
105
+ def scope_unpublished(articles)
106
+ articles.where(published: false)
107
+ end
108
+
109
+ def scope_published(articles)
110
+ articles.where(published: true)
111
+ end
112
+
113
+ filter :title
114
+
115
+ def filter_title(articles, value)
116
+ articles.where(title: value)
117
+ end
118
+
119
+ batch_action :unpublish, except: [:unpublished]
120
+ batch_action :publish, except: [:published]
121
+ batch_action :destroy, confirm: true
122
+
123
+ def batch_action_unpublish(articles)
124
+ articles.each { |a| a.update(published: false) }
125
+ end
126
+
127
+ def batch_action_publish(articles)
128
+ articles.each { |a| a.update(published: true) }
129
+ end
130
+
131
+ def batch_action_destroy(articles)
132
+ articles.each { |a| a.destroy }
133
+ end
134
+ END
135
+ end
136
+ end
137
+
138
+ def migrate_and_seed
139
+ rake("db:migrate")
140
+ rake("db:seed")
141
+ end
142
+
143
+ if yes?("Place godmin in admin engine?")
144
+ install_engine
145
+ else
146
+ install_standalone
147
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: godmin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.3
4
+ version: 0.12.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Ljungblad
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-09-18 00:00:00.000000000 Z
13
+ date: 2015-10-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bcrypt
@@ -335,6 +335,7 @@ files:
335
335
  - lib/godmin/version.rb
336
336
  - lib/tasks/godmin_tasks.rake
337
337
  - screenshot.png
338
+ - template.rb
338
339
  - test/dummy/Rakefile
339
340
  - test/dummy/admin/Rakefile
340
341
  - test/dummy/admin/admin.gemspec