upmin 0.0.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +34 -0
  3. data/app/assets/images/upmin/logo_large.png +0 -0
  4. data/app/assets/images/upmin/logo_small.png +0 -0
  5. data/app/assets/javascripts/upmin/application.js +38 -0
  6. data/app/assets/javascripts/upmin/jquery-clockpicker.js +729 -0
  7. data/app/assets/javascripts/upmin/models.js +23 -0
  8. data/app/assets/javascripts/upmin/pikaday.js +997 -0
  9. data/app/assets/stylesheets/upmin/application.css +16 -0
  10. data/app/assets/stylesheets/upmin/base.css.scss +24 -0
  11. data/app/assets/stylesheets/upmin/button_mixins.scss +37 -0
  12. data/app/assets/stylesheets/upmin/colors.scss +20 -0
  13. data/app/assets/stylesheets/upmin/instances.css.scss +91 -0
  14. data/app/assets/stylesheets/upmin/jquery-clockpicker.css +370 -0
  15. data/app/assets/stylesheets/upmin/models.css.scss +207 -0
  16. data/app/assets/stylesheets/upmin/pikaday.css +196 -0
  17. data/app/controllers/upmin/application_controller.rb +4 -0
  18. data/app/controllers/upmin/models_controller.rb +94 -0
  19. data/app/helpers/upmin/application_helper.rb +17 -0
  20. data/app/helpers/upmin/instances_helper.rb +13 -0
  21. data/app/helpers/upmin/models_helper.rb +4 -0
  22. data/app/views/layouts/upmin/_navbar.html.haml +15 -0
  23. data/app/views/layouts/upmin/application.html.haml +24 -0
  24. data/app/views/upmin/models/_search_result.html.haml +25 -0
  25. data/app/views/upmin/models/dashboard.html.haml +9 -0
  26. data/app/views/upmin/models/search.html.haml +20 -0
  27. data/app/views/upmin/models/show.html.haml +21 -0
  28. data/app/views/upmin/search_boxes/_unknown.html.haml +31 -0
  29. data/app/views/upmin/search_fields/_string.html.haml +3 -0
  30. data/app/views/upmin/types/_datetime.html.haml +95 -0
  31. data/app/views/upmin/types/_integer.html.haml +6 -0
  32. data/app/views/upmin/types/_string.html.haml +7 -0
  33. data/app/views/upmin/types/_unknown.html.haml +2 -0
  34. data/app/views/upmin/types/_unknown_collection.html.haml +18 -0
  35. data/app/views/upmin/types/_unknown_model.html.haml +57 -0
  36. data/app/views/upmin/types/_unknown_model_badge.html.haml +3 -0
  37. data/app/views/upmin/types/_unknown_model_nested.html.haml +24 -0
  38. data/app/views/upmin/types/_unknown_model_search_result.html.haml +31 -0
  39. data/config/routes.rb +19 -0
  40. data/lib/tasks/accordive_rails_tasks.rake +4 -0
  41. data/lib/tasks/upmin_tasks.rake +4 -0
  42. data/lib/upmin.rb +44 -0
  43. data/lib/upmin/engine.rb +7 -0
  44. data/lib/upmin/graph/collection_node.rb +72 -0
  45. data/lib/upmin/graph/data_node.rb +69 -0
  46. data/lib/upmin/graph/model_node.rb +151 -0
  47. data/lib/upmin/graph/node.rb +98 -0
  48. data/lib/upmin/model.rb +131 -0
  49. data/lib/upmin/railtie.rb +19 -0
  50. data/lib/upmin/railties/active_record.rb +156 -0
  51. data/lib/upmin/railties/render.rb +56 -0
  52. data/lib/upmin/railties/render_helpers.rb +57 -0
  53. data/lib/upmin/version.rb +3 -0
  54. data/test/controllers/upmin/model_controller_test.rb +11 -0
  55. data/test/dummy/README.rdoc +28 -0
  56. data/test/dummy/Rakefile +6 -0
  57. data/test/dummy/app/assets/javascripts/application.js +13 -0
  58. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  59. data/test/dummy/app/controllers/application_controller.rb +5 -0
  60. data/test/dummy/app/helpers/application_helper.rb +2 -0
  61. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  62. data/test/dummy/bin/bundle +3 -0
  63. data/test/dummy/bin/rails +4 -0
  64. data/test/dummy/bin/rake +4 -0
  65. data/test/dummy/config.ru +4 -0
  66. data/test/dummy/config/application.rb +23 -0
  67. data/test/dummy/config/boot.rb +5 -0
  68. data/test/dummy/config/database.yml +25 -0
  69. data/test/dummy/config/environment.rb +5 -0
  70. data/test/dummy/config/environments/development.rb +37 -0
  71. data/test/dummy/config/environments/production.rb +83 -0
  72. data/test/dummy/config/environments/test.rb +39 -0
  73. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  74. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  75. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  76. data/test/dummy/config/initializers/inflections.rb +16 -0
  77. data/test/dummy/config/initializers/mime_types.rb +4 -0
  78. data/test/dummy/config/initializers/session_store.rb +3 -0
  79. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  80. data/test/dummy/config/locales/en.yml +23 -0
  81. data/test/dummy/config/routes.rb +4 -0
  82. data/test/dummy/config/secrets.yml +22 -0
  83. data/test/dummy/public/404.html +67 -0
  84. data/test/dummy/public/422.html +67 -0
  85. data/test/dummy/public/500.html +66 -0
  86. data/test/dummy/public/favicon.ico +0 -0
  87. data/test/helpers/upmin/model_helper_test.rb +6 -0
  88. data/test/integration/navigation_test.rb +10 -0
  89. data/test/test_helper.rb +15 -0
  90. data/test/upmin_test.rb +7 -0
  91. metadata +253 -0
@@ -0,0 +1,207 @@
1
+ .c-models {
2
+
3
+ &.a-search {
4
+
5
+ a.search-result-link {
6
+ color: #333;
7
+ text-decoration: none;
8
+
9
+ &:hover,
10
+ &:active {
11
+ color: #333;
12
+ }
13
+ }
14
+
15
+ .search-container {
16
+ padding-top: 7px;
17
+ }
18
+
19
+ .search-results {
20
+ .search-result {
21
+ background-color: white;
22
+ margin-bottom: 8px;
23
+ position: relative;
24
+ padding-left: 40px;
25
+ min-height: 110px;
26
+
27
+ dl.dl-horizontal {
28
+ margin-bottom: 4px;
29
+ }
30
+
31
+ em {
32
+ font-weight: bold;
33
+ color: #18BC9C;
34
+ font-style: normal;
35
+ }
36
+
37
+ .icon-outer {
38
+ position: absolute;
39
+ top: 10px;
40
+ left: -40px;
41
+
42
+ .icon-upper {
43
+ color: white;
44
+ border-radius: 8px 8px 0 0;
45
+ padding: 0px 4px 0px 4px;
46
+ width: 80px;
47
+ height: 68px;
48
+
49
+ .icon-letter {
50
+ color: white;
51
+ font-size: 48px;
52
+ text-align: center;
53
+ line-height: 40px;
54
+ padding-top: 4px;
55
+ }
56
+
57
+ .icon-name {
58
+ color: white;
59
+ font-size: 13px;
60
+ text-align: center;
61
+ padding-top: 4px;
62
+ }
63
+ }
64
+
65
+ .icon-lower {
66
+ border-radius: 0 0 8px 8px;
67
+ background-color: white;
68
+ text-align: center;
69
+ }
70
+
71
+ &.yellow {
72
+ .icon-upper {
73
+ background-color: #F1C40F;
74
+ }
75
+ .icon-lower {
76
+ border: 1px solid #F1C40F;
77
+ color: #F1C40F;
78
+ }
79
+ }
80
+ &.orange {
81
+ .icon-upper {
82
+ background-color: #F39C12;
83
+ }
84
+ .icon-lower {
85
+ border: 1px solid #F39C12;
86
+ color: #F39C12;
87
+ }
88
+ }
89
+ &.red {
90
+ .icon-upper {
91
+ background-color: #E74C3C;
92
+ }
93
+ .icon-lower {
94
+ border: 1px solid #E74C3C;
95
+ color: #E74C3C;
96
+ }
97
+ }
98
+ &.dark_red {
99
+ .icon-upper {
100
+ background-color: #AB3326;
101
+ }
102
+ .icon-lower {
103
+ border: 1px solid #AB3326;
104
+ color: #AB3326;
105
+ }
106
+ }
107
+ &.purple {
108
+ .icon-upper {
109
+ background-color: #9B59B6;
110
+ }
111
+ .icon-lower {
112
+ border: 1px solid #9B59B6;
113
+ color: #9B59B6;
114
+ }
115
+ }
116
+ &.dark_blue {
117
+ .icon-upper {
118
+ background-color: #2C3E50;
119
+ }
120
+ .icon-lower {
121
+ border: 1px solid #2C3E50;
122
+ color: #2C3E50;
123
+ }
124
+ }
125
+ &.light_blue {
126
+ .icon-upper {
127
+ background-color: #3498DB;
128
+ }
129
+ .icon-lower {
130
+ border: 1px solid #3498DB;
131
+ color: #3498DB;
132
+ }
133
+ }
134
+ &.blue_green {
135
+ .icon-upper {
136
+ background-color: #18BC9C;
137
+ }
138
+ .icon-lower {
139
+ border: 1px solid #18BC9C;
140
+ color: #18BC9C;
141
+ }
142
+ }
143
+ &.green {
144
+ .icon-upper {
145
+ background-color: #01C94F;
146
+ }
147
+ .icon-lower {
148
+ border: 1px solid #01C94F;
149
+ color: #01C94F;
150
+ }
151
+ }
152
+ }
153
+ }
154
+ }
155
+
156
+
157
+ .list-model-facets {
158
+ li:before {
159
+ content: "]";
160
+ padding-left: 1px;
161
+ }
162
+
163
+ li {
164
+ padding-left: 2px;
165
+
166
+ &.yellow:before {
167
+ color: #F1C40F;
168
+ background-color: #F1C40F;
169
+ }
170
+ &.orange:before {
171
+ color: #F39C12;
172
+ background-color: #F39C12;
173
+ }
174
+ &.red:before {
175
+ color: #E74C3C;
176
+ background-color: #E74C3C;
177
+ }
178
+ &.dark_red:before {
179
+ color: #AB3326;
180
+ background-color: #AB3326;
181
+ }
182
+ &.purple:before {
183
+ color: #9B59B6;
184
+ background-color: #9B59B6;
185
+ }
186
+ &.dark_blue:before {
187
+ color: #2C3E50;
188
+ background-color: #2C3E50;
189
+ }
190
+ &.light_blue:before {
191
+ color: #3498DB;
192
+ background-color: #3498DB;
193
+ }
194
+ &.blue_green:before {
195
+ color: #18BC9C;
196
+ background-color: #18BC9C;
197
+ }
198
+ &.green:before {
199
+ color: #01C94F;
200
+ background-color: #01C94F;
201
+ }
202
+
203
+ }
204
+ }
205
+ }
206
+
207
+ }
@@ -0,0 +1,196 @@
1
+ @charset "UTF-8";
2
+
3
+ /*!
4
+ * Pikaday
5
+ * Copyright © 2014 David Bushell | BSD & MIT license | http://dbushell.com/
6
+ */
7
+
8
+ .pika-single {
9
+ z-index: 9999;
10
+ display: block;
11
+ position: relative;
12
+ color: #333;
13
+ background: #fff;
14
+ border: 1px solid #ccc;
15
+ border-bottom-color: #bbb;
16
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
17
+ }
18
+
19
+ /*
20
+ clear child float (pika-lendar), using the famous micro clearfix hack
21
+ http://nicolasgallagher.com/micro-clearfix-hack/
22
+ */
23
+ .pika-single:before,
24
+ .pika-single:after {
25
+ content: " ";
26
+ display: table;
27
+ }
28
+ .pika-single:after { clear: both }
29
+ .pika-single { *zoom: 1 }
30
+
31
+ .pika-single.is-hidden {
32
+ display: none;
33
+ }
34
+
35
+ .pika-single.is-bound {
36
+ position: absolute;
37
+ box-shadow: 0 5px 15px -5px rgba(0,0,0,.5);
38
+ }
39
+
40
+ .pika-lendar {
41
+ float: left;
42
+ width: 240px;
43
+ margin: 8px;
44
+ }
45
+
46
+ .pika-title {
47
+ position: relative;
48
+ text-align: center;
49
+ }
50
+
51
+ .pika-label {
52
+ display: inline-block;
53
+ *display: inline;
54
+ position: relative;
55
+ z-index: 9999;
56
+ overflow: hidden;
57
+ margin: 0;
58
+ padding: 5px 3px;
59
+ font-size: 14px;
60
+ line-height: 20px;
61
+ font-weight: bold;
62
+ background-color: #fff;
63
+ }
64
+ .pika-title select {
65
+ cursor: pointer;
66
+ position: absolute;
67
+ z-index: 9998;
68
+ margin: 0;
69
+ left: 0;
70
+ top: 5px;
71
+ filter: alpha(opacity=0);
72
+ opacity: 0;
73
+ }
74
+
75
+ .pika-prev,
76
+ .pika-next {
77
+ display: block;
78
+ cursor: pointer;
79
+ position: relative;
80
+ outline: none;
81
+ border: 0;
82
+ padding: 0;
83
+ width: 20px;
84
+ height: 30px;
85
+ /* hide text using text-indent trick, using width value (it's enough) */
86
+ text-indent: 20px;
87
+ white-space: nowrap;
88
+ overflow: hidden;
89
+ background-color: transparent;
90
+ background-position: center center;
91
+ background-repeat: no-repeat;
92
+ background-size: 75% 75%;
93
+ opacity: .5;
94
+ *position: absolute;
95
+ *top: 0;
96
+ }
97
+
98
+ .pika-prev:hover,
99
+ .pika-next:hover {
100
+ opacity: 1;
101
+ }
102
+
103
+ .pika-prev,
104
+ .is-rtl .pika-next {
105
+ float: left;
106
+ background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAAUklEQVR42u3VMQoAIBADQf8Pgj+OD9hG2CtONJB2ymQkKe0HbwAP0xucDiQWARITIDEBEnMgMQ8S8+AqBIl6kKgHiXqQqAeJepBo/z38J/U0uAHlaBkBl9I4GwAAAABJRU5ErkJggg==');
107
+ *left: 0;
108
+ }
109
+
110
+ .pika-next,
111
+ .is-rtl .pika-prev {
112
+ float: right;
113
+ background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAAU0lEQVR42u3VOwoAMAgE0dwfAnNjU26bYkBCFGwfiL9VVWoO+BJ4Gf3gtsEKKoFBNTCoCAYVwaAiGNQGMUHMkjGbgjk2mIONuXo0nC8XnCf1JXgArVIZAQh5TKYAAAAASUVORK5CYII=');
114
+ *right: 0;
115
+ }
116
+
117
+ .pika-prev.is-disabled,
118
+ .pika-next.is-disabled {
119
+ cursor: default;
120
+ opacity: .2;
121
+ }
122
+
123
+ .pika-select {
124
+ display: inline-block;
125
+ *display: inline;
126
+ }
127
+
128
+ .pika-table {
129
+ width: 100%;
130
+ border-collapse: collapse;
131
+ border-spacing: 0;
132
+ border: 0;
133
+ }
134
+
135
+ .pika-table th,
136
+ .pika-table td {
137
+ width: 14.285714285714286%;
138
+ padding: 0;
139
+ }
140
+
141
+ .pika-table th {
142
+ color: #999;
143
+ font-size: 12px;
144
+ line-height: 25px;
145
+ font-weight: bold;
146
+ text-align: center;
147
+ }
148
+
149
+ .pika-button {
150
+ cursor: pointer;
151
+ display: block;
152
+ box-sizing: border-box;
153
+ -moz-box-sizing: border-box;
154
+ outline: none;
155
+ border: 0;
156
+ margin: 0;
157
+ width: 100%;
158
+ padding: 5px;
159
+ color: #666;
160
+ font-size: 12px;
161
+ line-height: 15px;
162
+ text-align: right;
163
+ background: #f5f5f5;
164
+ }
165
+
166
+ .pika-week {
167
+ font-size: 11px;
168
+ color: #999;
169
+ }
170
+
171
+ .is-today .pika-button {
172
+ color: #33aaff;
173
+ font-weight: bold;
174
+ }
175
+
176
+ .is-selected .pika-button {
177
+ color: #fff;
178
+ font-weight: bold;
179
+ background: #33aaff;
180
+ box-shadow: inset 0 1px 3px #178fe5;
181
+ border-radius: 3px;
182
+ }
183
+
184
+ .is-disabled .pika-button {
185
+ pointer-events: none;
186
+ cursor: default;
187
+ color: #999;
188
+ opacity: .3;
189
+ }
190
+
191
+ .pika-button:hover {
192
+ color: #fff !important;
193
+ background: #ff8000 !important;
194
+ box-shadow: none !important;
195
+ border-radius: 3px !important;
196
+ }
@@ -0,0 +1,4 @@
1
+ module Upmin
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,94 @@
1
+ require_dependency "upmin/application_controller"
2
+
3
+ module Upmin
4
+ class ModelsController < ApplicationController
5
+ before_action :set_model, only: [:show, :update, :search, :action]
6
+ before_action :set_instance, only: [:show, :update, :action]
7
+ before_action :set_method, only: [:action]
8
+ before_action :set_arguments, only: [:action]
9
+
10
+ def dashboard
11
+ end
12
+
13
+ # GET /:model_name/:id
14
+ def show
15
+ end
16
+
17
+ # PUT /:model_name/:id
18
+ def update
19
+ form_name = @model.form_name
20
+ updates = params[form_name]
21
+
22
+ transforms = updates.delete(:transforms) || {}
23
+ updates.each do |key, value|
24
+ # TODO(jon): Figure out a better way to do transforms.
25
+ # This could cause issues and is exploitable, but it
26
+ # should be fine for now since this is only on admin pages
27
+ if transforms[key]
28
+ value = transform(transforms, key, value)
29
+ end
30
+
31
+ @instance.send("#{key}=", value)
32
+ end
33
+
34
+ if @instance.save
35
+ flash[:notice] = "#{params[:model_name]} updated successfully."
36
+ redirect_to(upmin_model_path(model_name: @model.to_s, id: @instance.id))
37
+ else
38
+ flash.now[:alert] = "#{params[:model_name]} was NOT updated."
39
+ render(:show)
40
+ end
41
+ end
42
+
43
+ def search
44
+ # if @model.methods.include?(:ransack)
45
+ puts params[:q]
46
+ @q = @model.ransack(params[:q])
47
+ # else
48
+ # @q = @model.search(params[:q])
49
+ # end
50
+ @results = @q.result(distinct: true)
51
+ end
52
+
53
+ def action
54
+ # begin
55
+ puts "arguments is: #{@arguments.inspect}"
56
+ response = @model.perform_action(@instance, @method, @arguments)
57
+ flash[:notice] = "Action successfully performed with a response of: #{response}"
58
+ redirect_to(upmin_model_path(model_name: params[:model_name], id: params[:id]))
59
+ # rescue Exception => e
60
+ # flash.now[:alert] = "Action failed with the error message: #{e.message}"
61
+ # render(:show)
62
+ # end
63
+ end
64
+
65
+ private
66
+
67
+ def set_model
68
+ @model = Upmin::Model.find(params[:model_name])
69
+ end
70
+
71
+ def set_instance
72
+ @instance = @model.find(params[:id])
73
+ end
74
+
75
+ def set_method
76
+ @method = params[:method].to_sym
77
+ end
78
+
79
+ def set_arguments
80
+ arguments = params[@method] || {}
81
+ @arguments = arguments.select{|k, v| !v.empty? } || {}
82
+ end
83
+
84
+ # TODO(jon): Figure out a better way to do transforms that is easy to extend.
85
+ def transform(transforms, key, value)
86
+ split = transforms[key].split('#')
87
+ klass = eval(split[0])
88
+ method = split[1]
89
+ return klass.send(method, value)
90
+ end
91
+
92
+ end
93
+ end
94
+