home_page 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/home_page/application.js +8 -1
  3. data/app/assets/javascripts/home_page/base.js.coffee.erb +44 -0
  4. data/app/assets/javascripts/home_page/lib/jquery.multisortable.js +254 -0
  5. data/app/assets/javascripts/home_page/page_module_collections/index.js.coffee +14 -0
  6. data/app/assets/javascripts/home_page/shared/sortable_list.js.coffee +44 -0
  7. data/app/assets/stylesheets/home_page/application.css +4 -0
  8. data/app/assets/stylesheets/home_page/bootswatch.css.less +4 -0
  9. data/app/assets/stylesheets/vendors/keen/dashboards.css +59 -0
  10. data/app/controllers/home_page/application_controller.rb +24 -0
  11. data/app/controllers/page_module_collections_controller.rb +96 -0
  12. data/app/controllers/page_module_collections_modules_controller.rb +43 -0
  13. data/app/controllers/page_modules_controller.rb +121 -0
  14. data/app/controllers/settings_controller.rb +30 -0
  15. data/app/controllers/users_controller.rb +7 -3
  16. data/app/helpers/home_page/application_helper.rb +22 -0
  17. data/app/helpers/home_page/form_helper.rb +23 -0
  18. data/app/helpers/home_page/show_helper.rb +67 -0
  19. data/app/models/page_module.rb +78 -0
  20. data/app/models/page_module_collection.rb +24 -0
  21. data/app/models/page_module_collection_module.rb +8 -0
  22. data/app/models/setting.rb +26 -0
  23. data/app/views/apis/volontariat/_settings.html.erb +5 -0
  24. data/app/views/layouts/application.html.erb +2 -1
  25. data/app/views/layouts/fluid/without_rows.html.erb +17 -0
  26. data/app/views/layouts/shared/_foot.html.erb +9 -1
  27. data/app/views/layouts/shared/_modal.html.erb +16 -0
  28. data/app/views/page_module_collections/_collection.html.erb +18 -0
  29. data/app/views/page_module_collections/_form.html.erb +29 -0
  30. data/app/views/page_module_collections/_page_module.html.erb +27 -0
  31. data/app/views/page_module_collections/_page_module_collection.html.erb +41 -0
  32. data/app/views/page_module_collections/destroy.js.erb +9 -0
  33. data/app/views/page_module_collections/edit.html.erb +3 -0
  34. data/app/views/page_module_collections/index.html.erb +67 -0
  35. data/app/views/page_module_collections/new.html.erb +3 -0
  36. data/app/views/page_module_collections/show.html.erb +44 -0
  37. data/app/views/page_module_collections/update.js.erb +11 -0
  38. data/app/views/page_module_collections_modules/_fields.html.erb +10 -0
  39. data/app/views/page_module_collections_modules/create.js.erb +8 -0
  40. data/app/views/page_module_collections_modules/destroy.js.erb +9 -0
  41. data/app/views/page_module_collections_modules/new.html.erb +27 -0
  42. data/app/views/page_modules/_actions.html.erb +26 -0
  43. data/app/views/page_modules/_collection.html.erb +19 -0
  44. data/app/views/page_modules/_fields.html.erb +52 -0
  45. data/app/views/page_modules/_form.html.erb +25 -0
  46. data/app/views/page_modules/_page_module.html.erb +14 -0
  47. data/app/views/page_modules/_tab.html.erb +39 -0
  48. data/app/views/page_modules/destroy.js.erb +9 -0
  49. data/app/views/page_modules/edit.html.erb +3 -0
  50. data/app/views/page_modules/new.html.erb +3 -0
  51. data/app/views/page_modules/update.js.erb +11 -0
  52. data/app/views/settings/_apis.html.erb +20 -0
  53. data/app/views/settings/index.html.erb +13 -0
  54. data/app/views/settings/plugins/home_page/_panel.html.erb +42 -0
  55. data/app/views/settings/plugins/home_page/tabs/_apis.html.erb +24 -0
  56. data/app/views/shared/_javascript_response.js.erb +50 -0
  57. data/app/views/shared/layouts/_modal.html.erb +14 -0
  58. data/app/views/users/index.html.erb +5 -1
  59. data/app/views/users/show.html.erb +5 -0
  60. data/config/initializers/default_settings.rb +8 -0
  61. data/config/locales/general/en.yml +33 -2
  62. data/config/locales/resources/page_module/en.yml +34 -0
  63. data/config/locales/resources/page_module_collection/en.yml +21 -0
  64. data/config/locales/resources/setting/en.yml +26 -0
  65. data/config/routes.rb +18 -1
  66. data/db/migrate/20150307193102_create_friendly_id_slugs.rb +3 -3
  67. data/db/migrate/20150313154924_create_settings.rb +17 -0
  68. data/db/migrate/20150315082328_create_page_modules_and_page_module_collections.rb +43 -0
  69. data/lib/home_page.rb +9 -0
  70. data/lib/home_page/api_provider_host.rb +54 -0
  71. data/lib/home_page/engine.rb +1 -0
  72. data/lib/home_page/navigation.rb +62 -21
  73. data/lib/home_page/pagination_metadata.rb +1 -2
  74. data/lib/home_page/simple_navigation_renderer/breadcrumbs_without_method_links.rb +6 -2
  75. data/lib/home_page/version.rb +1 -1
  76. metadata +242 -50
  77. data/README.rdoc +0 -3
  78. data/config/initializers/volontariat.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 216c9a840f44595c1fc4074de0f13ee34b4fe7ef
4
- data.tar.gz: 8201fae5624b35aba4b059968280f3aa86433af5
3
+ metadata.gz: b87c5eb464183a160fc080f26583fc2d14899ec8
4
+ data.tar.gz: 3bd3f333626ce73c5ef79a4c95418380562b8ecb
5
5
  SHA512:
6
- metadata.gz: e24ab9f5fef20adfd8e12ef8ba3f7ee44167892f23d4669633a6b320b2c99cddc278015aebebbc94f5b8921d56242115c55a8c32646b449eecc457b48042e767
7
- data.tar.gz: dcea08ef0341c3243c4469420124c85e9b3f9fb6ce9b6cefdedd636e59f61ae14033b4c439e57f05414bc39a5ce64487136c2a2b491f5a868f5bbb221c87491b
6
+ metadata.gz: d75ac19b561e3078003f5937a5e150ec91107c72797d867357081ed0eddfda244842ce0219ba849cc9c34bd91ad533e7cf03fbf7f78677956267d96372c7d33e
7
+ data.tar.gz: 4b64d5866b335530849a868e6db2ae865e98be40477a954259716d3148d4f27aea04121f6e26fcca3eb987a92df611b55b9bd64ddc43ade822b9f0604410be54
@@ -1,3 +1,10 @@
1
1
  //= require jquery
2
2
  //= require jquery_ujs
3
- //= require home_page/loader
3
+ //= require jquery-ui
4
+ //= require moment
5
+ //= require_tree ./lib
6
+ //= require home_page/loader
7
+ //= require selectize
8
+ //= require bootstrap-datetimepicker
9
+ //= require_tree ./shared
10
+ //= require home_page/base
@@ -0,0 +1,44 @@
1
+ $(document).ready ->
2
+ $('[data-toggle="tabajax"]').click (e) ->
3
+ $this = $(this)
4
+ url = $this.attr('href')
5
+ target = $this.attr('data-target')
6
+
7
+ $.get url, (data) ->
8
+ $(target).html data
9
+
10
+ $this.tab 'show'
11
+
12
+ false
13
+
14
+ $(document.body).on 'show.bs.modal', '#modal', (event) ->
15
+ button = $(event.relatedTarget)
16
+ url = button.data('url')
17
+ modal = $(this)
18
+ modal.find('.modal-title').text button.data('title')
19
+ modal.find('.modal-body').html "<img src='<%= asset_path('home_page/spinner.gif') %>'/>"
20
+
21
+ if button.data('only-update-body') == true
22
+ modal.find('.modal-body').load url
23
+ else
24
+ modal.find('.modal-content').load url
25
+
26
+ $(document.body).on 'change', '#page_module_plugin', (event) ->
27
+ $('#page_module_partial_path').empty()
28
+
29
+ plugin = $(this).val()
30
+ plugin = if plugin == 'home' then 'home_page' else 'home_page_' + plugin
31
+
32
+ $.getJSON $(this).data('setting-url').replace(/x/, "#{plugin}.general.partial_paths"), (data) ->
33
+ options = []
34
+
35
+ $.each data, (index, value) ->
36
+ options.push "<option value='#{value}'>#{value}</option>"
37
+
38
+ $('#page_module_partial_path').html(options.join(''))
39
+
40
+ $('.datetime_picker').datetimepicker()
41
+
42
+ $('.selectize_select').selectize
43
+ create: true,
44
+ sortField: 'text'
@@ -0,0 +1,254 @@
1
+ /**
2
+ * jquery.multisortable.js - v0.2
3
+ * https://github.com/shvetsgroup/jquery.multisortable
4
+ *
5
+ * Author: Ethan Atlakson, Jay Hayes, Gabriel Such, Alexander Shvets
6
+ * Last Revision 3/16/2012
7
+ * multi-selectable, multi-sortable jQuery plugin
8
+ */
9
+
10
+ !function($) {
11
+
12
+ $.fn.multiselectable = function(options) {
13
+ if (!options) {
14
+ options = {}
15
+ }
16
+ options = $.extend({}, $.fn.multiselectable.defaults, options);
17
+
18
+ function mouseDown(e) {
19
+ var item = $(this),
20
+ parent = item.parent(),
21
+ myIndex = item.index();
22
+
23
+ var prev = parent.find('.multiselectable-previous');
24
+ // If no previous selection found, start selecting from first selected item.
25
+ prev = prev.length ? prev : $(parent.find('.' + options.selectedClass)[0]).addClass('multiselectable-previous');
26
+ var prevIndex = prev.index();
27
+
28
+ if (e.ctrlKey || e.metaKey) {
29
+ if (item.hasClass(options.selectedClass)) {
30
+ item.removeClass(options.selectedClass).removeClass('multiselectable-previous')
31
+ if (item.not('.child').length) {
32
+ item.nextUntil(':not(.child)').removeClass(options.selectedClass);
33
+ }
34
+ }
35
+ else {
36
+ parent.find('.multiselectable-previous').removeClass('multiselectable-previous');
37
+ item.addClass(options.selectedClass).addClass('multiselectable-previous')
38
+ if (item.not('.child').length) {
39
+ item.nextUntil(':not(.child)').addClass(options.selectedClass);
40
+ }
41
+ }
42
+ }
43
+
44
+ if (e.shiftKey) {
45
+ var last_shift_range = parent.find('.multiselectable-shift');
46
+ last_shift_range.removeClass(options.selectedClass).removeClass('multiselectable-shift');
47
+
48
+ var shift_range;
49
+ if (prevIndex < myIndex) {
50
+ shift_range = item.prevUntil('.multiselectable-previous').add(prev).add(item);
51
+ }
52
+ else if (prevIndex > myIndex) {
53
+ shift_range = item.nextUntil('.multiselectable-previous').add(prev).add(item);
54
+ }
55
+ shift_range.addClass(options.selectedClass).addClass('multiselectable-shift');
56
+ }
57
+ else {
58
+ parent.find('.multiselectable-shift').removeClass('multiselectable-shift');
59
+ }
60
+
61
+ if (!e.ctrlKey && !e.metaKey && !e.shiftKey) {
62
+ parent.find('.multiselectable-previous').removeClass('multiselectable-previous');
63
+ if (!item.hasClass(options.selectedClass)) {
64
+ parent.find('.' + options.selectedClass).removeClass(options.selectedClass);
65
+ item.addClass(options.selectedClass).addClass('multiselectable-previous');
66
+ if (item.not('.child').length) {
67
+ item.nextUntil(':not(.child)').addClass(options.selectedClass);
68
+ }
69
+ }
70
+ }
71
+
72
+ options.mousedown(e, item);
73
+ }
74
+
75
+ function click(e) {
76
+ if ( $(this).is('.ui-draggable-dragging') ) {
77
+ return;
78
+ }
79
+
80
+ var item = $(this), parent = item.parent();
81
+
82
+ // If item wasn't draged and is not multiselected, it should reset selection for other items.
83
+ if (!e.ctrlKey && !e.metaKey && !e.shiftKey) {
84
+ parent.find('.multiselectable-previous').removeClass('multiselectable-previous');
85
+ parent.find('.' + options.selectedClass).removeClass(options.selectedClass);
86
+ item.addClass(options.selectedClass).addClass('multiselectable-previous');
87
+ if (item.not('.child').length) {
88
+ item.nextUntil(':not(.child)').addClass(options.selectedClass);
89
+ }
90
+ }
91
+
92
+ options.click(e, item);
93
+ }
94
+
95
+ return this.each(function() {
96
+ var list = $(this);
97
+
98
+ if (!list.data('multiselectable')) {
99
+ list.data('multiselectable', true)
100
+ .delegate(options.items, 'mousedown', mouseDown)
101
+ .delegate(options.items, 'click', click)
102
+ .disableSelection();
103
+ }
104
+ })
105
+ };
106
+
107
+ $.fn.multiselectable.defaults = {
108
+ click: function(event, elem) {},
109
+ mousedown: function(event, elem) {},
110
+ selectedClass: 'selected',
111
+ items: 'li'
112
+ };
113
+
114
+
115
+ $.fn.multisortable = function(options) {
116
+ if (!options) {
117
+ options = {}
118
+ }
119
+ var settings = $.extend({}, $.fn.multisortable.defaults, options);
120
+
121
+ function regroup(item, list) {
122
+ if (list.find('.' + settings.selectedClass).length > 0) {
123
+ var myIndex = item.data('i');
124
+
125
+ var itemsBefore = list.find('.' + settings.selectedClass).filter(function() {
126
+ return $(this).data('i') < myIndex
127
+ }).css({
128
+ position: '',
129
+ width: '',
130
+ left: '',
131
+ top: '',
132
+ zIndex: ''
133
+ });
134
+
135
+ item.before(itemsBefore);
136
+
137
+ var itemsAfter = list.find('.' + settings.selectedClass).filter(function() {
138
+ return $(this).data('i') > myIndex
139
+ }).css({
140
+ position: '',
141
+ width: '',
142
+ left: '',
143
+ top: '',
144
+ zIndex: ''
145
+ });
146
+
147
+ item.after(itemsAfter);
148
+
149
+ setTimeout(function() {
150
+ itemsAfter.add(itemsBefore).addClass(settings.selectedClass);
151
+ }, 0);
152
+ }
153
+ }
154
+
155
+ return this.each(function() {
156
+ var list = $(this);
157
+
158
+ //enable multi-selection
159
+ list.multiselectable({
160
+ selectedClass: settings.selectedClass,
161
+ click: settings.click,
162
+ items: settings.items,
163
+ mousedown: settings.mousedown
164
+ });
165
+
166
+ //enable sorting
167
+ options.cancel = settings.items + ':not(.' + settings.selectedClass + ')';
168
+ options.placeholder = settings.placeholder;
169
+ options.start = function(event, ui) {
170
+ if (ui.item.hasClass(settings.selectedClass)) {
171
+ var parent = ui.item.parent();
172
+
173
+ //assign indexes to all selected items
174
+ parent.find('.' + settings.selectedClass).each(function(i) {
175
+ $(this).data('i', i);
176
+ });
177
+
178
+ // adjust placeholder size to be size of items
179
+ var height = parent.find('.' + settings.selectedClass).length * ui.item.outerHeight();
180
+ ui.placeholder.height(height);
181
+ }
182
+
183
+ settings.start(event, ui);
184
+ };
185
+
186
+ options.stop = function(event, ui) {
187
+ regroup(ui.item, ui.item.parent());
188
+ settings.stop(event, ui);
189
+ };
190
+
191
+ options.sort = function(event, ui) {
192
+ var parent = ui.item.parent(),
193
+ myIndex = ui.item.data('i'),
194
+ top = parseInt(ui.item.css('top').replace('px', '')),
195
+ left = parseInt(ui.item.css('left').replace('px', ''));
196
+
197
+ // fix to keep compatibility using prototype.js and jquery together
198
+ $.fn.reverse = Array.prototype._reverse || Array.prototype.reverse
199
+
200
+ var height = 0;
201
+ $('.' + settings.selectedClass, parent).filter(function() {
202
+ return $(this).data('i') < myIndex;
203
+ }).reverse().each(function() {
204
+ height += $(this).outerHeight();
205
+ $(this).css({
206
+ left: left,
207
+ top: top - height,
208
+ position: 'absolute',
209
+ zIndex: 1000,
210
+ width: ui.item.width()
211
+ })
212
+ });
213
+
214
+ height = ui.item.outerHeight();
215
+ $('.' + settings.selectedClass, parent).filter(function() {
216
+ return $(this).data('i') > myIndex;
217
+ }).each(function() {
218
+ var item = $(this);
219
+ item.css({
220
+ left: left,
221
+ top: top + height,
222
+ position: 'absolute',
223
+ zIndex: 1000,
224
+ width: ui.item.width()
225
+ });
226
+
227
+ height += item.outerHeight();
228
+ });
229
+
230
+ settings.sort(event, ui);
231
+ };
232
+
233
+ options.receive = function(event, ui) {
234
+ regroup(ui.item, ui.sender);
235
+ settings.receive(event, ui);
236
+ };
237
+
238
+ list.sortable(options).disableSelection();
239
+ })
240
+ };
241
+
242
+ $.fn.multisortable.defaults = {
243
+ start: function(event, ui) {},
244
+ stop: function(event, ui) {},
245
+ sort: function(event, ui) {},
246
+ receive: function(event, ui) {},
247
+ click: function(event, elem) {},
248
+ mousedown: function(event, elem) {},
249
+ selectedClass: 'selected',
250
+ placeholder: 'placeholder',
251
+ items: 'li'
252
+ };
253
+
254
+ }(jQuery);
@@ -0,0 +1,14 @@
1
+ $(document).ready ->
2
+ $(document.body).on 'click', '.page_module_collection_show_link', (event) ->
3
+ $this = $(this)
4
+ $this.find('.ajax_spinner').show()
5
+
6
+ $.ajax(url: $this.attr('href'), type: 'GET', dataType: 'html').done((data) =>
7
+ $this.find('.ajax_spinner').hide()
8
+ $($this.data('replace')).html(data)
9
+ new window.HomePage.Shared.SortableList('#page_module_collection_modules')
10
+ ).fail((data) =>
11
+ $this.find('.ajax_spinner').hide()
12
+ alert 'Failed to load page!'
13
+ )
14
+ event.preventDefault()
@@ -0,0 +1,44 @@
1
+ window.HomePage or= {}; window.HomePage.Shared or= {}
2
+
3
+ window.HomePage.Shared.SortableList = class SortableList
4
+ constructor: (selector) ->
5
+ $(selector).multisortable
6
+ start: (event, ui) =>
7
+ window.HomePage.Shared.SortableList.showSpinnerForSelectedItems(ui.item.data('sortable_selector'))
8
+
9
+ update: (event, ui) =>
10
+ $(ui.item.data('sortable_selector')).sortable('disable')
11
+ url = $(ui.item.data('sortable_selector')).data('url')
12
+ setTimeout (->
13
+ window.HomePage.Shared.SortableList.putPositions ui.item.data('sortable_selector'), ui.item.data('id'), url
14
+ return
15
+ ), 1000
16
+
17
+ @showSpinnerForSelectedItems: (selector) ->
18
+ $.each $("#{selector} li.selected"), (index, element) ->
19
+ $(element).find('.sorting_spinner').show()
20
+
21
+ @hideSpinnerForSelectedItems: (selector) ->
22
+ $.each $("#{selector} li.selected"), (index, element) ->
23
+ $(element).find('.sorting_spinner').hide()
24
+
25
+ @putPositions: (selector, id, url) ->
26
+ window.HomePage.Shared.SortableList.resetPositions(selector)
27
+
28
+ positions = {}
29
+
30
+ $.each $("#{selector} li.selected"), (index, element) ->
31
+ positions[$(element).data('position')] = $(element).data('id')
32
+
33
+ $.post(url, { _method: 'put', positions: positions }).always(=>
34
+ $(selector).sortable('enable')
35
+ window.HomePage.Shared.SortableList.hideSpinnerForSelectedItems()
36
+ )
37
+
38
+ @resetPositions: (selector) ->
39
+ current_position = 1
40
+
41
+ $.each $("#{selector} li"), (index, element) ->
42
+ $(element).data('position', current_position)
43
+ $(element).find('.item_position').html(current_position)
44
+ current_position += 1
@@ -1,8 +1,12 @@
1
1
  /*
2
2
  *= require_self
3
+ *= require jquery-ui
3
4
  *= require home_page/variables
4
5
  *= require home_page/loader
5
6
  *= require home_page/bootswatch
7
+ *= require bootstrap-datetimepicker
8
+ *= require selectize
9
+ *= require selectize.bootstrap3
6
10
  *= require home_page/pygments
7
11
  *= require home_page/socialicious
8
12
  */
@@ -7,3 +7,7 @@ body {
7
7
  p {
8
8
  margin: 10px 0;
9
9
  }
10
+
11
+ .list-striped li:nth-child(odd) {
12
+ background-color: #F9F9F9;
13
+ }
@@ -0,0 +1,59 @@
1
+
2
+ /*
3
+ * Full-page application style
4
+ */
5
+
6
+ body.application {
7
+ padding: 60px 20px 0;
8
+ }
9
+
10
+ body.application > .container-fluid {
11
+ padding-left: 0;
12
+ padding-right: 0;
13
+ }
14
+ body.application div[class^="col-"] {
15
+ padding-left: 5px;
16
+ padding-right: 5px;
17
+ }
18
+ body.application div[class^="col-"] div[class^="col-"] {
19
+ padding-left: 15px;
20
+ padding-right: 15px;
21
+ }
22
+
23
+ body.application hr {
24
+ border-color: #d7d7d7;
25
+ margin: 10px 0;
26
+ }
27
+
28
+ .return-link, .return-link:focus, .return-link:hover {
29
+ text-decoration: none;
30
+ }
31
+
32
+ .chart-wrapper {
33
+ background: #fff;
34
+ border: 1px solid #e2e2e2;
35
+ border-radius: 3px;
36
+ margin-bottom: 10px;
37
+ }
38
+ .chart-wrapper .chart-title {
39
+ border-bottom: 1px solid #d7d7d7;
40
+ color: #666;
41
+ font-size: 14px;
42
+ font-weight: 200;
43
+ padding: 7px 10px 4px;
44
+ }
45
+
46
+ .chart-wrapper .chart-stage {
47
+ /*min-height: 240px;*/
48
+ overflow: hidden;
49
+ padding: 5px 10px;
50
+ position: relative;
51
+ }
52
+
53
+ .chart-wrapper .chart-notes {
54
+ background: #fbfbfb;
55
+ border-top: 1px solid #e2e2e2;
56
+ color: #808080;
57
+ font-size: 12px;
58
+ padding: 8px 10px 5px;
59
+ }