billy_cms 0.0.2

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.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.travis.yml +4 -0
  4. data/CODE_OF_CONDUCT.md +49 -0
  5. data/Gemfile +8 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +41 -0
  8. data/Rakefile +10 -0
  9. data/app/assets/images/billy_cms/32px.png +0 -0
  10. data/app/assets/images/billy_cms/40px.png +0 -0
  11. data/app/assets/images/billy_cms/fileicon.png +0 -0
  12. data/app/assets/images/billy_cms/throbber.gif +0 -0
  13. data/app/assets/javascripts/billy_cms/backend/app.js.erb +217 -0
  14. data/app/assets/javascripts/billy_cms/backend/attributes.js +33 -0
  15. data/app/assets/javascripts/billy_cms/backend/billy_object.js +41 -0
  16. data/app/assets/javascripts/billy_cms/backend/directives/ng-jstree.js +200 -0
  17. data/app/assets/javascripts/billy_cms/backend/jstree.js +7781 -0
  18. data/app/assets/javascripts/billy_cms/backend/ngfileupload.js +2506 -0
  19. data/app/assets/javascripts/billy_cms/backend/page_type.js +11 -0
  20. data/app/assets/javascripts/billy_cms/backend/ui-router.js +4370 -0
  21. data/app/assets/javascripts/billy_cms/backend.js +15 -0
  22. data/app/assets/javascripts/billy_cms/frontend/api_connector.js +5 -0
  23. data/app/assets/javascripts/billy_cms/frontend/editing.es6 +120 -0
  24. data/app/assets/javascripts/billy_cms/frontend/google_maps.js +13 -0
  25. data/app/assets/javascripts/billy_cms/frontend/navbar.js +0 -0
  26. data/app/assets/javascripts/billy_cms/frontend/slick.es6 +8 -0
  27. data/app/assets/javascripts/billy_cms.js +16 -0
  28. data/app/assets/stylesheets/billy_cms/backend/index.scss +17 -0
  29. data/app/assets/stylesheets/billy_cms/editmode.scss +78 -0
  30. data/app/assets/stylesheets/billy_cms/index.scss +5 -0
  31. data/app/assets/stylesheets/billy_cms/jstree.scss +1061 -0
  32. data/app/assets/stylesheets/billy_cms.css +15 -0
  33. data/app/controllers/billy_cms/api/api_controller.rb +25 -0
  34. data/app/controllers/billy_cms/api/attributes_controller.rb +65 -0
  35. data/app/controllers/billy_cms/api/page_types_controller.rb +13 -0
  36. data/app/controllers/billy_cms/api/pages_controller.rb +63 -0
  37. data/app/controllers/billy_cms/backend_controller.rb +10 -0
  38. data/app/controllers/billy_cms/base_controller.rb +23 -0
  39. data/app/helpers/billy_cms/cms_path_helper.rb +8 -0
  40. data/app/helpers/billy_cms/content_helper.rb +17 -0
  41. data/app/helpers/billy_cms/permission_helper.rb +24 -0
  42. data/app/models/billy_cms/additional_attribute.rb +6 -0
  43. data/app/models/billy_cms/additional_attributes_page_types.rb +6 -0
  44. data/app/models/billy_cms/page.rb +61 -0
  45. data/app/models/billy_cms/page_type.rb +7 -0
  46. data/app/models/billy_router.rb +20 -0
  47. data/app/serializers/billy_cms/additional_attribute_serializer.rb +6 -0
  48. data/app/serializers/billy_cms/page_serializer.rb +15 -0
  49. data/app/serializers/billy_cms/page_type_serializer.rb +5 -0
  50. data/app/views/billy_cms/_edit_page_button.html.erb +1 -0
  51. data/app/views/billy_cms/_page_settings_form.html.erb +25 -0
  52. data/app/views/billy_cms/_page_settings_modal.html.erb +19 -0
  53. data/app/views/billy_cms/_settings_page_button.html.erb +4 -0
  54. data/app/views/billy_cms/backend/_attributes.html.erb +12 -0
  55. data/app/views/billy_cms/backend/_header.html.erb +84 -0
  56. data/app/views/billy_cms/backend/_tree.html.erb +58 -0
  57. data/app/views/billy_cms/backend/index.html.erb +19 -0
  58. data/billy_cms.gemspec +32 -0
  59. data/bin/console +14 -0
  60. data/bin/setup +8 -0
  61. data/lib/billy_cms/version.rb +3 -0
  62. data/lib/billy_cms.rb +5 -0
  63. metadata +147 -0
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery_ujs
14
+ //= require ./backend/app
15
+ //= require_tree ./backend
@@ -0,0 +1,5 @@
1
+ var BillyCms = BillyCms || {};
2
+
3
+ BillyCms.ApiConnector = {
4
+
5
+ };
@@ -0,0 +1,120 @@
1
+ 'use strict';
2
+
3
+ var BillyCms = window.BillyCms || {};
4
+
5
+ BillyCms.API_BASE_URL = '/billy_cms/api/pages';
6
+
7
+ BillyCms.Editing = {
8
+ isEditModeOn: false,
9
+
10
+ setEditMode(state) {
11
+ this.isEditModeOn = state;
12
+ var editableFields = $('[contenteditable]');
13
+ var container = $('.container');
14
+ if (state === true) {
15
+ container.addClass('edit-mode-enabled');
16
+ editableFields.attr('contenteditable', true);
17
+ } else {
18
+ container.removeClass('edit-mode-enabled');
19
+ editableFields.attr('contenteditable', false);
20
+ }
21
+ },
22
+
23
+ savePageProperty(page_id, property, content) {
24
+ return $.ajax({
25
+ url: `${BillyCms.API_BASE_URL}/${page_id}`,
26
+ method: 'PATCH',
27
+ data: {
28
+ page: {
29
+ [property]: content
30
+ }
31
+ }
32
+ }).done(data => {
33
+ if (data.success) {
34
+ console.log('page saved.');
35
+ console.log(data.page);
36
+ } else {
37
+ alert(`Es hat sich ein Fehler ereignet: ${data.error}`);
38
+ }
39
+ }).fail((jqXHR, textStatus, error) => {
40
+ alert(`Es hat sich ein Fehler ereignet: ${error}`);
41
+ });
42
+ }
43
+ };
44
+
45
+ $(function() {
46
+ $('.billycms_edit_button').on('click', function() {
47
+ BillyCms.Editing.setEditMode(!BillyCms.Editing.isEditModeOn);
48
+ });
49
+
50
+ $('.page-content-binary input[type=file]').on('change', function(evt) {
51
+ if (BillyCms.Editing.isEditModeOn) {
52
+ var container = $(this).parent('.page-content-binary');
53
+ var pageId = parseInt(container.attr('billycms-page'), 10);
54
+ var files = this.files;
55
+ if (files.length < 1) { return; }
56
+ var file = files[0];
57
+ var reader = new FileReader();
58
+ var image = container.find('img');
59
+
60
+ reader.onloadend = function() {
61
+ var result = reader.result;
62
+ BillyCms.Editing.savePageProperty(pageId, 'content', result)
63
+ .done(function() {
64
+ image.attr('src', result);
65
+ })
66
+ }
67
+ reader.readAsDataURL(file);
68
+ }
69
+ });
70
+
71
+ $('[contenteditable]').on('blur', function() {
72
+ if (BillyCms.Editing.isEditModeOn) {
73
+ let el = $(this),
74
+ id = el.attr('billycms-page'),
75
+ attribute = el.attr('billycms-attribute');
76
+ BillyCms.Editing.savePageProperty(id, attribute, el.html())
77
+ }
78
+ });
79
+
80
+ $('.page-settings-modal').each((index, modalElement) => {
81
+ let pageSettingsModal = $(modalElement);
82
+ let pageSettingsForm = pageSettingsModal.find('form').first();
83
+ let pageSettingsButton = pageSettingsModal.find('.btn.btn-primary').last();
84
+ let saveSettingsFn = function() {
85
+ let form = pageSettingsForm;
86
+ let id = form.attr('billycms-id');
87
+ if (!id) {
88
+ return alert('Diese Seite existiert nicht.');
89
+ }
90
+ id = form.attr('billycms-id');
91
+ let page = {};
92
+ form.find('input').not('[type=hidden]').not('[disabled]').each((i, element) => {
93
+ let el = $(element);
94
+ let name = el.attr('name');
95
+ let val = el.val();
96
+ if (name) {
97
+ page[name] = val;
98
+ }
99
+ });
100
+ console.log(page);
101
+ $.ajax({
102
+ url: `${BillyCms.API_BASE_URL}/${id}`,
103
+ method: 'PATCH',
104
+ data: { page }
105
+ }).done(data => {
106
+ if (data.success) {
107
+ console.log('page saved.');
108
+ console.log(data.page);
109
+ pageSettingsModal.modal('hide');
110
+ } else {
111
+ alert(`Es hat sich ein Fehler ereignet: ${data.error}`);
112
+ }
113
+ }).fail((jqXHR, textStatus, error) => {
114
+ alert(`Es hat sich ein Fehler ereignet: ${error}`);
115
+ });
116
+ };
117
+ pageSettingsButton.on('click', saveSettingsFn);
118
+ pageSettingsForm.on('submit', saveSettingsFn);
119
+ });
120
+ });
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ $(function() {
4
+ $('.google-map-embedded').each(function(i, mapBox) {
5
+ var mapOptions = JSON.parse($($(mapBox).attr('data-box-content')).text());
6
+ var map = new google.maps.Map(mapBox, mapOptions);
7
+
8
+ if (mapOptions.marker) {
9
+ mapOptions.marker.map = map;
10
+ var marker = new google.maps.Marker(mapOptions.marker);
11
+ }
12
+ });
13
+ });
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ $(function() {
4
+ $('.slick-carousel').slick({
5
+ autoplay: true,
6
+ autoplaySpeed: 3500,
7
+ });
8
+ });
@@ -0,0 +1,16 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ // require turbolinks
16
+ //= require_tree ./billy_cms/frontend
@@ -0,0 +1,17 @@
1
+ .file-wrapper {
2
+ position: relative;
3
+ cursor: pointer;
4
+ > input[type=file] {
5
+ border: red 1px solid;
6
+ position: absolute;
7
+ width: 100%;
8
+ height: 100%;
9
+ opacity: 0;
10
+ cursor: pointer;
11
+ }
12
+ }
13
+
14
+ i.jstree-icon.binary-type {
15
+ background: url(/assets/billy_cms/fileicon.png);
16
+ background-size: 80% 80%;
17
+ }
@@ -0,0 +1,78 @@
1
+ @mixin editbutton {
2
+ border: 1px solid #AFADAD;
3
+ border-radius: 3px;
4
+ padding: 5px 10px 5px 10px;
5
+ font-size: 13px;
6
+ background-color: #C1C1C1;
7
+ color: #fff;
8
+ position: absolute;
9
+ font-weight: 100px;
10
+ left: 1em;
11
+ min-width: 85px;
12
+ outline: none;
13
+ &:hover {
14
+ background-color: #E6B0B0;
15
+ border: 1px solid #DC8888;
16
+ }
17
+ }
18
+ @mixin editbutton-current {
19
+ background-color: #BFE2BB;
20
+ border: 1px solid #6DB145;
21
+ color: #6DB145;
22
+ &:focus {
23
+ box-shadow: 0px 0px 5px green;
24
+ }
25
+ }
26
+
27
+ .edit-mode-enabled {
28
+ [contenteditable], .page-content-binary {
29
+ border: 1px solid #F3B9B9;
30
+ background-color: #FFF0F0;
31
+ min-height: 1em;
32
+ border-radius: 3px;
33
+ padding: 5px;
34
+ outline: none;
35
+ input[type=file] {
36
+ display: block;
37
+ }
38
+ &:focus {
39
+ box-shadow: 0px 0px 5px red;
40
+ }
41
+ }
42
+ }
43
+
44
+ .page-content-binary {
45
+ position: relative;
46
+ input[type=file] {
47
+ width: 100%;
48
+ height: 100%;
49
+ position: absolute;
50
+ top: 0;
51
+ left: 0;
52
+ opacity: 0;
53
+ display: none;
54
+ }
55
+ }
56
+
57
+ .billycms_edit_button {
58
+ @include editbutton;
59
+ right: 2em;
60
+ &::before {
61
+ content: 'bearbeiten';
62
+ }
63
+ }
64
+ .edit-mode-enabled .billycms_edit_button {
65
+ @include editbutton-current;
66
+ &::before {
67
+ content: 'fertig';
68
+ }
69
+ }
70
+
71
+ .billycms_settings_button {
72
+ @include editbutton;
73
+ top: 12em;
74
+ z-index: 100;
75
+ &::before {
76
+ content: 'Seiteneinstellungen';
77
+ }
78
+ }
@@ -0,0 +1,5 @@
1
+ @import "jstree";
2
+
3
+ @import "editmode";
4
+
5
+ @import "backend/index";