lato_blog 2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +27 -0
  4. data/Rakefile +5 -0
  5. data/app/assets/config/lato_blog_manifest.js +2 -0
  6. data/app/assets/javascripts/lato_blog/application.js +19 -0
  7. data/app/assets/javascripts/lato_blog/initializers/Fields.js +56 -0
  8. data/app/assets/javascripts/lato_blog/initializers/Posts.js +54 -0
  9. data/app/assets/stylesheets/lato_blog/_helpers.scss +37 -0
  10. data/app/assets/stylesheets/lato_blog/application.scss +20 -0
  11. data/app/assets/stylesheets/lato_blog/fields/_composed.scss +7 -0
  12. data/app/assets/stylesheets/lato_blog/fields/_datetime.scss +0 -0
  13. data/app/assets/stylesheets/lato_blog/fields/_editor.scss +3 -0
  14. data/app/assets/stylesheets/lato_blog/fields/_fields.scss +8 -0
  15. data/app/assets/stylesheets/lato_blog/fields/_general.scss +9 -0
  16. data/app/assets/stylesheets/lato_blog/fields/_geolocalization.scss +3 -0
  17. data/app/assets/stylesheets/lato_blog/fields/_image.scss +3 -0
  18. data/app/assets/stylesheets/lato_blog/fields/_relay.scss +121 -0
  19. data/app/assets/stylesheets/lato_blog/fields/_text.scss +3 -0
  20. data/app/assets/stylesheets/lato_blog/pages/_categories.scss +18 -0
  21. data/app/assets/stylesheets/lato_blog/pages/_pages.scss +2 -0
  22. data/app/assets/stylesheets/lato_blog/pages/_posts.scss +25 -0
  23. data/app/assets/stylesheets/lato_blog/theme.scss.erb +12 -0
  24. data/app/assets/stylesheets/lato_blog/widgets/_switchlang.scss +3 -0
  25. data/app/assets/stylesheets/lato_blog/widgets/_widgets.scss +1 -0
  26. data/app/controllers/lato_blog/api/api_controller.rb +5 -0
  27. data/app/controllers/lato_blog/api/categories_controller.rb +51 -0
  28. data/app/controllers/lato_blog/api/posts_controller.rb +93 -0
  29. data/app/controllers/lato_blog/application_controller.rb +13 -0
  30. data/app/controllers/lato_blog/back/back_controller.rb +45 -0
  31. data/app/controllers/lato_blog/back/categories_controller.rb +141 -0
  32. data/app/controllers/lato_blog/back/post_fields_controller.rb +86 -0
  33. data/app/controllers/lato_blog/back/posts_controller.rb +340 -0
  34. data/app/controllers/lato_blog/doc/doc_controller.rb +16 -0
  35. data/app/controllers/lato_blog/doc/fields_controller.rb +19 -0
  36. data/app/controllers/lato_blog/doc/general_controller.rb +11 -0
  37. data/app/helpers/lato_blog/application_helper.rb +13 -0
  38. data/app/helpers/lato_blog/fields_helper.rb +100 -0
  39. data/app/jobs/lato_blog/application_job.rb +4 -0
  40. data/app/mailers/lato_blog/application_mailer.rb +6 -0
  41. data/app/models/lato_blog/application_record.rb +5 -0
  42. data/app/models/lato_blog/category.rb +119 -0
  43. data/app/models/lato_blog/category/entity_helpers.rb +55 -0
  44. data/app/models/lato_blog/category/serializer_helpers.rb +66 -0
  45. data/app/models/lato_blog/category_parent.rb +9 -0
  46. data/app/models/lato_blog/category_post.rb +35 -0
  47. data/app/models/lato_blog/post.rb +112 -0
  48. data/app/models/lato_blog/post/entity_helpers.rb +42 -0
  49. data/app/models/lato_blog/post/serializer_helpers.rb +85 -0
  50. data/app/models/lato_blog/post_field.rb +50 -0
  51. data/app/models/lato_blog/post_field/entity_helpers.rb +5 -0
  52. data/app/models/lato_blog/post_field/serializer_helpers.rb +127 -0
  53. data/app/models/lato_blog/post_parent.rb +20 -0
  54. data/app/views/lato_blog/back/back/switch_current_language.js +2 -0
  55. data/app/views/lato_blog/back/categories/edit.html.erb +44 -0
  56. data/app/views/lato_blog/back/categories/index.html.erb +18 -0
  57. data/app/views/lato_blog/back/categories/new.html.erb +40 -0
  58. data/app/views/lato_blog/back/categories/shared/_form.html.erb +38 -0
  59. data/app/views/lato_blog/back/categories/shared/edit/_edit_child_tree.html.erb +23 -0
  60. data/app/views/lato_blog/back/categories/shared/edit/_edit_child_tree_level.html.erb +7 -0
  61. data/app/views/lato_blog/back/categories/shared/edit/_edit_informations.html.erb +24 -0
  62. data/app/views/lato_blog/back/categories/shared/edit/_edit_languages.html.erb +38 -0
  63. data/app/views/lato_blog/back/categories/shared/new/_new_informations.html.erb +21 -0
  64. data/app/views/lato_blog/back/post_fields/create_relay_field.js.erb +14 -0
  65. data/app/views/lato_blog/back/post_fields/destroy_relay_field.js.erb +14 -0
  66. data/app/views/lato_blog/back/post_fields/fields/_composed.html.erb +24 -0
  67. data/app/views/lato_blog/back/post_fields/fields/_datetime.html.erb +17 -0
  68. data/app/views/lato_blog/back/post_fields/fields/_editor.html.erb +17 -0
  69. data/app/views/lato_blog/back/post_fields/fields/_geolocalization.html.erb +22 -0
  70. data/app/views/lato_blog/back/post_fields/fields/_image.html.erb +18 -0
  71. data/app/views/lato_blog/back/post_fields/fields/_relay.html.erb +39 -0
  72. data/app/views/lato_blog/back/post_fields/fields/_text.html.erb +17 -0
  73. data/app/views/lato_blog/back/post_fields/index.html.erb +28 -0
  74. data/app/views/lato_blog/back/posts/edit.html.erb +48 -0
  75. data/app/views/lato_blog/back/posts/index.html.erb +38 -0
  76. data/app/views/lato_blog/back/posts/new.html.erb +40 -0
  77. data/app/views/lato_blog/back/posts/shared/_fields.html.erb +13 -0
  78. data/app/views/lato_blog/back/posts/shared/_form.html.erb +69 -0
  79. data/app/views/lato_blog/back/posts/shared/edit/_edit_categories.html.erb +36 -0
  80. data/app/views/lato_blog/back/posts/shared/edit/_edit_informations.html.erb +26 -0
  81. data/app/views/lato_blog/back/posts/shared/edit/_edit_languages.html.erb +40 -0
  82. data/app/views/lato_blog/back/posts/shared/edit/_edit_pubblication_datetime.html.erb +24 -0
  83. data/app/views/lato_blog/back/posts/shared/edit/_edit_status_switch.html.erb +27 -0
  84. data/app/views/lato_blog/back/posts/shared/index/_index.html.erb +28 -0
  85. data/app/views/lato_blog/back/posts/shared/index/_index_informations.html.erb +37 -0
  86. data/app/views/lato_blog/back/posts/shared/index/_index_status_switch.html.erb +29 -0
  87. data/app/views/lato_blog/back/posts/shared/new/_new_informations.html.erb +21 -0
  88. data/app/views/lato_blog/doc/doc/index.html.erb +83 -0
  89. data/app/views/lato_blog/doc/fields/composed.html.erb +87 -0
  90. data/app/views/lato_blog/doc/fields/datetime.html.erb +0 -0
  91. data/app/views/lato_blog/doc/fields/editor.html.erb +1 -0
  92. data/app/views/lato_blog/doc/fields/geolocalization.html.erb +1 -0
  93. data/app/views/lato_blog/doc/fields/image.html.erb +70 -0
  94. data/app/views/lato_blog/doc/fields/relay.html.erb +87 -0
  95. data/app/views/lato_blog/doc/fields/text.html.erb +70 -0
  96. data/app/views/lato_blog/doc/general/api.html.erb +0 -0
  97. data/app/views/lato_blog/doc/general/installation.html.erb +49 -0
  98. data/app/views/lato_blog/doc/general/personalization.html.erb +0 -0
  99. data/app/views/lato_blog/partials/_relay_destroy_button.html.erb +5 -0
  100. data/app/views/lato_blog/widgets/_switchlang.html.erb +20 -0
  101. data/config/configs.yml +109 -0
  102. data/config/initializers/assets.rb +4 -0
  103. data/config/initializers/init_system.rb +22 -0
  104. data/config/languages/default.yml +87 -0
  105. data/config/languages/it.yml +87 -0
  106. data/config/routes.rb +16 -0
  107. data/config/routes/api.rb +11 -0
  108. data/config/routes/back.rb +17 -0
  109. data/config/routes/doc.rb +19 -0
  110. data/db/migrate/20170504222008_create_lato_blog_posts.rb +19 -0
  111. data/db/migrate/20170504223521_create_lato_blog_post_parents.rb +9 -0
  112. data/db/migrate/20170516063317_create_lato_blog_categories.rb +16 -0
  113. data/db/migrate/20170516063320_create_lato_blog_category_parents.rb +9 -0
  114. data/db/migrate/20170516063330_create_lato_blog_category_posts.rb +10 -0
  115. data/db/migrate/20170516063330_create_lato_blog_post_fields.rb +18 -0
  116. data/lib/lato_blog.rb +6 -0
  117. data/lib/lato_blog/engine.rb +15 -0
  118. data/lib/lato_blog/interface.rb +17 -0
  119. data/lib/lato_blog/interfaces/categories.rb +34 -0
  120. data/lib/lato_blog/interfaces/fields.rb +195 -0
  121. data/lib/lato_blog/interfaces/languages.rb +15 -0
  122. data/lib/lato_blog/interfaces/posts.rb +13 -0
  123. data/lib/lato_blog/version.rb +3 -0
  124. data/lib/tasks/lato_blog_tasks.rake +4 -0
  125. metadata +223 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d458228c2534ab38377611c32c79dc316e6a2af5
4
+ data.tar.gz: 0f16e5fdecc84317b3479ddf6e3e8ec1a00292fb
5
+ SHA512:
6
+ metadata.gz: 15c718bacb4756e2e76a42fb5fc4e21781474d952945728dbc996400d85bb9a28da580a4d3e4ed3eb51b565248566f3abc51d623d3eccce5727051e04f29e14d
7
+ data.tar.gz: 356c7f952826ee180415c8a688924d7ac0244fa6acd7a9316837f4608af594cdc03fb830af6dd0d251d049db4704d2b1c8254a0d200a4571d07dca2c378a84d0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2017 Gregorio
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # Lato Blog
2
+
3
+ ## Installation
4
+
5
+ Add the lato_blog gem on your Gemfile
6
+
7
+ ```ruby
8
+ gem 'lato_blog'
9
+ ```
10
+
11
+ Install the gem
12
+
13
+ ```console
14
+ bundle install
15
+ ```
16
+
17
+ Copy the migrations
18
+
19
+ ```console
20
+ rails lato_blog:install:migrations
21
+ ```
22
+
23
+ Exec migrations
24
+
25
+ ```console
26
+ bundle exec rake db:migrate
27
+ ```
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/lato_blog .js
2
+ //= link_directory ../stylesheets/lato_blog .css
@@ -0,0 +1,19 @@
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_tree ./initializers
14
+
15
+
16
+ $(window).load(function () {
17
+ BlogFieldsInitializer.init()
18
+ BlogPostsInitializer.init()
19
+ })
@@ -0,0 +1,56 @@
1
+ var BlogFieldsInitializer = (function () {
2
+
3
+ function initializeRelayNewButton () {
4
+ $('.fields-relay__menu-add').click(function (e) {
5
+ // save current status with form submit
6
+ _relaySubmitUpdateBeforeAction()
7
+ // open - close menu
8
+ var parent = $(this).parent()
9
+ var menu = $(parent).find('.fields-relay__menu')
10
+ $(menu).toggleClass('fields-relay__menu--active')
11
+ e.preventDefault()
12
+ })
13
+ }
14
+
15
+ function initializeRelayDestroy () {
16
+ $('.fields-relay__sortableblock .js-sortable__main-container').each(function (i, el) {
17
+ $(el).find('.js-sortable__element').each(function (index, element) {
18
+ var fieldId = $(element).find('.fields__container').data('field-id')
19
+ var destroyButton = $('.js-related-field__destroy.is-first')
20
+ var href = destroyButton.attr('href')
21
+ var newHref = href + '?id=' + fieldId
22
+ var cloneButton = destroyButton.clone(true)
23
+ $(cloneButton).removeClass('is-first').attr('href', newHref)
24
+ $(element).find('.c-sortable__handle').after(cloneButton)
25
+ // listen onclick to save current status
26
+ $(cloneButton).click(function () {
27
+ _relaySubmitUpdateBeforeAction()
28
+ })
29
+ })
30
+ })
31
+ }
32
+
33
+ function _relaySubmitUpdateBeforeAction () {
34
+ var formInput = $('.posts__form-autosave')
35
+ var form = $(formInput).parent()
36
+ if ($(formInput).val('false')) {
37
+ $(formInput).val('true')
38
+ $(form).attr('data-remote', true)
39
+ $.rails.handleRemote($(form))
40
+ $(formInput).val('false')
41
+ $(form).attr('data-remote', false)
42
+ }
43
+ }
44
+
45
+ // Init:
46
+
47
+ function init () {
48
+ initializeRelayNewButton()
49
+ initializeRelayDestroy()
50
+ }
51
+
52
+ return {
53
+ init: init
54
+ }
55
+
56
+ })()
@@ -0,0 +1,54 @@
1
+ var BlogPostsInitializer = (function () {
2
+
3
+ function initializeAutosave () {
4
+ var formInput = $('.posts__form-autosave')
5
+
6
+ if (formInput) {
7
+ var form = $(formInput).parent()
8
+ setInterval(function () {
9
+ if ($(formInput).val('false')) {
10
+ $(formInput).val('true')
11
+ $(form).attr('data-remote', true)
12
+ $.rails.handleRemote($(form))
13
+ $(formInput).val('false')
14
+ $(form).attr('data-remote', false)
15
+ }
16
+ }, 10000)
17
+ }
18
+ }
19
+
20
+ function initializeCategoriesAutosave () {
21
+ var form = $('.posts__edit-categories').find('form')
22
+ $(form).find('input').change(function () {
23
+ $(form).submit()
24
+ })
25
+ }
26
+
27
+ function initializePublicationDatetimeAutosave () {
28
+ var form = $('.posts__edit-publication-datetime').find('form')
29
+ $(form).find('input').change(function () {
30
+ $(form).submit()
31
+ })
32
+ }
33
+
34
+ function initializeStatusSwitchAutosave () {
35
+ var form = $('.posts__edit-status-switch').find('form')
36
+ $(form).find('select').change(function () {
37
+ $(form).submit()
38
+ })
39
+ }
40
+
41
+ // Init:
42
+
43
+ function init () {
44
+ initializeAutosave()
45
+ initializeCategoriesAutosave()
46
+ initializePublicationDatetimeAutosave()
47
+ initializeStatusSwitchAutosave()
48
+ }
49
+
50
+ return {
51
+ init: init
52
+ }
53
+
54
+ })()
@@ -0,0 +1,37 @@
1
+ // Clearfix
2
+ @mixin clearfix {
3
+ &:after {
4
+ content: "";
5
+ display: table;
6
+ clear: both;
7
+ }
8
+ }
9
+
10
+ // Center an element (need position: relative to the container)
11
+ @mixin centerElement($xy) {
12
+ position: absolute;
13
+ @if $xy == xy {
14
+ left: 50%;
15
+ top: 50%;
16
+ bottom: auto;
17
+ right: auto;
18
+ transform: translate(-50%, -50%);
19
+ }
20
+ @else if $xy == x {
21
+ left: 50%;
22
+ right: auto;
23
+ transform: translateX(-50%);
24
+ }
25
+ @else if $xy == y {
26
+ top: 50%;
27
+ bottom: auto;
28
+ transform: translateY(-50%);
29
+ }
30
+ }
31
+
32
+ // Set text to one line.
33
+ @mixin oneLineText {
34
+ overflow: hidden;
35
+ white-space: nowrap;
36
+ text-overflow: ellipsis;
37
+ }
@@ -0,0 +1,20 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ */
14
+
15
+ @import "theme";
16
+ @import "helpers";
17
+ @import "widgets/widgets";
18
+ @import "fields/fields";
19
+ @import "pages/pages";
20
+
@@ -0,0 +1,7 @@
1
+ .fields-composed {
2
+
3
+ }
4
+
5
+ .fields-composed__label {
6
+
7
+ }
@@ -0,0 +1,3 @@
1
+ .fields-editor {
2
+
3
+ }
@@ -0,0 +1,8 @@
1
+ @import "general";
2
+ @import "text";
3
+ @import "datetime";
4
+ @import "editor";
5
+ @import "geolocalization";
6
+ @import "image";
7
+ @import "composed";
8
+ @import "relay";
@@ -0,0 +1,9 @@
1
+ .fields__container {
2
+ @include clearfix;
3
+ }
4
+
5
+ .fields__label {
6
+ color: $color_black;
7
+ border-bottom: solid 1px $color_grey;
8
+ padding-bottom: 3px;
9
+ }
@@ -0,0 +1,3 @@
1
+ .fields-geolocalizations {
2
+
3
+ }
@@ -0,0 +1,3 @@
1
+ .fields-image {
2
+
3
+ }
@@ -0,0 +1,121 @@
1
+ .fields-relay {
2
+
3
+ }
4
+
5
+ .fields-relay__sortableblock {
6
+ @include clearfix;
7
+
8
+ // fix images height
9
+ .elements-preview__container {
10
+ padding-bottom: 40%;
11
+ }
12
+ }
13
+
14
+ .fields-relay__menu-container {
15
+ margin-top: 10px;
16
+ width: 100%;
17
+ position: relative;
18
+ }
19
+
20
+ .fields-relay__menu-add {
21
+ width: 25px;
22
+ height: 25px;
23
+ margin: 0 auto;
24
+ background: $color_white;
25
+ border-radius: 50%;
26
+ color: $color_main;
27
+ border: 1px solid $color_main;
28
+ cursor: pointer;
29
+ text-align: center;
30
+ position: relative;
31
+ transition: all 0.3s;
32
+ &:hover, &:focus {
33
+ background-color: $color_main;
34
+ color: $color_white;
35
+ }
36
+ }
37
+
38
+ .fields-relay__menu-add-icon {
39
+ position: absolute;
40
+ top: 50%;
41
+ left: 50%;
42
+ transform: translate(-50%, -50%);
43
+ font-size: 20px;
44
+ z-index: 10;
45
+ }
46
+
47
+ .fields-relay__menu {
48
+ box-shadow: 0px 11px 20px rgba(41,59,90,0.08);
49
+ display: block;
50
+ position: absolute;
51
+ top: 120%;
52
+ left: 50%;
53
+ transform: translateX(-50%);
54
+ min-width: 250px;
55
+ border: 1px solid $color_grey;
56
+ list-style: none;
57
+ padding: 0;
58
+ margin: 0;
59
+ z-index: 10;
60
+ display: none;
61
+ border-radius: 10px;
62
+ overflow: hidden;
63
+ margin-bottom: 10px;
64
+ }
65
+
66
+ .fields-relay__menu--active {
67
+ display: block;
68
+ }
69
+
70
+ .fields-relay__menu-item {
71
+ text-align: center;
72
+ margin: 0;
73
+
74
+ a {
75
+ font-size: 1em;
76
+ display: block;
77
+ padding: 6px;
78
+ background: $color_white;
79
+ color: $color_black;
80
+ text-decoration: none;
81
+ &:hover {
82
+ background-color: $color_grey;
83
+ }
84
+ }
85
+ }
86
+
87
+ .js-related-field__destroy {
88
+ position: absolute;
89
+ top: 0;
90
+ left: 35px;
91
+ opacity: 0;
92
+ width: 25px;
93
+ height: 25px;
94
+ background: #ecf0f1;
95
+ border-radius: 3px;
96
+ text-align: center;
97
+ transition: all 0.3s;
98
+ svg {
99
+ display: block;
100
+ width: 15px;
101
+ height: 15px;
102
+ margin: 5px auto 0 auto;
103
+ path {
104
+ transition: all 0.3s;
105
+ }
106
+ }
107
+ &:hover {
108
+ background-color: $color_danger;
109
+ svg {
110
+ path {
111
+ fill: white;
112
+ }
113
+ }
114
+ }
115
+ }
116
+
117
+ .c-sortable__element:hover {
118
+ .js-related-field__destroy {
119
+ opacity: 1;
120
+ }
121
+ }
@@ -0,0 +1,3 @@
1
+ .fields-text {
2
+
3
+ }
@@ -0,0 +1,18 @@
1
+ .categories__edit-child-tree {
2
+
3
+ .child-tree-container {
4
+ background-color: $color_grey;
5
+ width: 100%;
6
+ padding: 5px 0;
7
+
8
+ ul {
9
+
10
+ }
11
+
12
+ li {
13
+ color: darken($color_grey, 50);
14
+ margin-bottom: 10px;
15
+ font-size: 0.8em;
16
+ }
17
+ }
18
+ }