mokio 0.0.15 → 2.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. checksums.yaml +5 -5
  2. data/app/assets/javascripts/backend.js +6 -3
  3. data/app/assets/javascripts/backend/datatable.js.coffee.erb +28 -26
  4. data/app/assets/javascripts/backend/head.js +1 -0
  5. data/app/assets/javascripts/backend/main.js +69 -44
  6. data/app/assets/javascripts/backend/mokio_dynamic_fields.js +20 -0
  7. data/app/assets/javascripts/backend/vendors/select2/select2.min.js +2 -0
  8. data/app/assets/stylesheets/backend.scss +6 -2
  9. data/app/assets/stylesheets/backend/custom.scss +13 -1
  10. data/app/assets/stylesheets/backend/main.scss +74 -73
  11. data/app/assets/stylesheets/backend/plugins/forms/select2/select2.scss +4 -0
  12. data/app/assets/stylesheets/backend/plugins/tables/dataTables/{jquery.dataTables.scss → jquery.dataTables.css} +7 -7
  13. data/app/assets/stylesheets/backend/theme/main.scss +413 -0
  14. data/app/assets/stylesheets/backend/theme/nice-select/_nice-select-prefixed.scss +190 -0
  15. data/app/assets/stylesheets/backend/theme/nice-select/nice-select.scss +178 -0
  16. data/app/assets/stylesheets/backend/theme/nice-select/style.scss +20 -0
  17. data/app/assets/stylesheets/backend/vendors/select2/select2.min.css +1 -0
  18. data/app/datatables/commons_datatable.rb +56 -36
  19. data/app/helpers/mokio/backend/backend_helper.rb +27 -1
  20. data/app/helpers/mokio/backend/common_helper.rb +9 -4
  21. data/app/helpers/mokio/backend/dynamic_fields_helper.rb +91 -0
  22. data/app/models/devise_custom_failure.rb +9 -0
  23. data/app/models/mokio/article.rb +0 -1
  24. data/app/models/mokio/contact.rb +0 -1
  25. data/app/models/mokio/content.rb +0 -1
  26. data/app/models/mokio/menu.rb +0 -1
  27. data/app/models/mokio/mov_gallery.rb +0 -1
  28. data/app/models/mokio/pic_gallery.rb +0 -1
  29. data/app/models/mokio/seo_tag.rb +5 -0
  30. data/app/models/mokio/support.rb +0 -1
  31. data/app/uploaders/ckeditor_picture_uploader.rb +2 -2
  32. data/app/views/devise/sessions/new.html.haml +2 -1
  33. data/app/views/mokio/articles/_form.html.slim +6 -3
  34. data/app/views/mokio/common/_form_content.html.slim +4 -4
  35. data/app/views/mokio/common/edit.html.slim +1 -5
  36. data/app/views/mokio/common/index.html.slim +3 -0
  37. data/app/views/mokio/common/modals/_modal_seo_tags.html.slim +47 -0
  38. data/app/views/mokio/common/new.html.slim +1 -4
  39. data/app/views/mokio/contacts/_form.html.slim +9 -7
  40. data/app/views/mokio/contents/new.html.slim +1 -2
  41. data/app/views/mokio/data_files/_file_upload.html.erb +1 -6
  42. data/app/views/mokio/layout/sidebar.html.slim +6 -13
  43. data/app/views/mokio/menus/_form.html.slim +97 -0
  44. data/app/views/mokio/menus/{_form.html.haml → _old_form.html.haml} +5 -6
  45. data/app/views/mokio/menus/{_form_slim.html.slim → _old_form_slim.html.slim} +8 -10
  46. data/app/views/mokio/menus/new_menu_position.slim +1 -1
  47. data/app/views/mokio/mov_galleries/_form_inputs.html.slim +3 -3
  48. data/app/views/mokio/pic_galleries/_form_inputs.html.slim +3 -3
  49. data/app/views/mokio/static_modules/_form.html.slim +2 -1
  50. data/config/initializers/frontend.rb +3 -0
  51. data/config/initializers/simple_form.rb +9 -0
  52. data/config/locales/en.yml +16 -26
  53. data/config/locales/pl.yml +11 -20
  54. data/db/migrate/20140422135850_add_mokio_to_application.rb +22 -24
  55. data/db/migrate/20191217135611_create_mokio_seo_tags.rb +11 -0
  56. data/lib/mokio.rb +37 -10
  57. data/lib/mokio/concerns.rb +3 -13
  58. data/lib/mokio/concerns/common/controller_functions.rb +1 -15
  59. data/lib/mokio/concerns/common/controller_object.rb +2 -2
  60. data/lib/mokio/concerns/common/seo_tags.rb +32 -0
  61. data/lib/mokio/concerns/common/services/sitemap_service.rb +196 -0
  62. data/lib/mokio/concerns/controllers/application.rb +5 -5
  63. data/lib/mokio/concerns/controllers/base.rb +12 -12
  64. data/lib/mokio/concerns/controllers/common.rb +6 -4
  65. data/lib/mokio/concerns/controllers/data_files.rb +3 -3
  66. data/lib/mokio/concerns/controllers/menus.rb +11 -13
  67. data/lib/mokio/concerns/controllers/mov_galleries.rb +1 -2
  68. data/lib/mokio/concerns/controllers/photos.rb +10 -10
  69. data/lib/mokio/concerns/controllers/pic_galleries.rb +2 -3
  70. data/lib/mokio/concerns/controllers/users.rb +4 -3
  71. data/lib/mokio/concerns/controllers/youtubes.rb +7 -7
  72. data/lib/mokio/concerns/models/available_module.rb +3 -3
  73. data/lib/mokio/concerns/models/common.rb +1 -29
  74. data/lib/mokio/concerns/models/contact_template.rb +0 -4
  75. data/lib/mokio/concerns/models/content.rb +15 -7
  76. data/lib/mokio/concerns/models/data_file.rb +3 -9
  77. data/lib/mokio/concerns/models/lang.rb +11 -7
  78. data/lib/mokio/concerns/models/menu.rb +4 -4
  79. data/lib/mokio/concerns/models/module_position.rb +1 -1
  80. data/lib/mokio/concerns/models/recipient.rb +0 -2
  81. data/lib/mokio/concerns/models/seo_tag.rb +118 -0
  82. data/lib/mokio/concerns/models/static_module.rb +2 -2
  83. data/lib/mokio/concerns/models/user.rb +1 -1
  84. data/lib/mokio/engine.rb +7 -17
  85. data/lib/mokio/frontend_helpers.rb +1 -0
  86. data/lib/mokio/frontend_helpers/seo_tag_helper.rb +33 -0
  87. data/lib/mokio/simple-form-wrappers.rb +11 -0
  88. data/lib/mokio/version.rb +1 -1
  89. data/lib/tasks/mokio_install.rake +37 -9
  90. data/spec/dummy/Rakefile +1 -3
  91. data/spec/dummy/app/controllers/application_controller.rb +1 -1
  92. data/spec/dummy/config.ru +1 -2
  93. data/spec/dummy/config/application.rb +9 -12
  94. data/spec/dummy/config/database.yml +18 -0
  95. data/spec/dummy/config/environment.rb +1 -1
  96. data/spec/dummy/log/development.log +0 -0
  97. data/spec/dummy/log/development_mokio.log +9 -0
  98. data/spec/models/content_spec.rb +0 -1
  99. data/spec/models/menu_spec.rb +8 -9
  100. data/spec/models/mov_gallery_spec.rb +0 -1
  101. data/spec/models/pic_gallery_spec.rb +0 -1
  102. metadata +212 -407
  103. data/README.rdoc +0 -47
  104. data/app/assets/javascripts/backend/plugins/forms/select/select2.js +0 -2195
  105. data/app/assets/javascripts/backend/plugins/forms/select/select2.min.js +0 -76
  106. data/app/assets/javascripts/backend/plugins/tables/dataTables/jquery.dataTables.js +0 -12099
  107. data/app/assets/javascripts/backend/plugins/tables/dataTables/jquery.dataTables.min.js +0 -155
  108. data/app/controllers/mokio/base_articles_controller.rb +0 -3
  109. data/app/controllers/mokio/base_contacts_controller.rb +0 -5
  110. data/app/controllers/mokio/base_contents_controller.rb +0 -3
  111. data/app/controllers/mokio/base_mov_galleries_controller.rb +0 -3
  112. data/app/controllers/mokio/base_pic_galleries_controller.rb +0 -4
  113. data/app/controllers/passwords_controller.rb +0 -14
  114. data/app/models/mokio/base_article.rb +0 -29
  115. data/app/models/mokio/base_contact.rb +0 -30
  116. data/app/models/mokio/base_content.rb +0 -5
  117. data/app/models/mokio/base_mov_gallery.rb +0 -30
  118. data/app/models/mokio/base_pic_gallery.rb +0 -30
  119. data/app/models/mokio/meta.rb +0 -24
  120. data/app/views/mokio/backend/articles/_form.html.haml +0 -9
  121. data/app/views/mokio/backend/common/_form_content.html.haml +0 -36
  122. data/app/views/mokio/backend/common/_gmap.html.haml +0 -39
  123. data/app/views/mokio/backend/common/_main_pic.html.haml +0 -4
  124. data/app/views/mokio/backend/common/_meta.html.haml +0 -51
  125. data/app/views/mokio/backend/common/_notice.html.haml +0 -3
  126. data/app/views/mokio/backend/common/_obj.html.haml +0 -16
  127. data/app/views/mokio/backend/common/copy.html.haml +0 -5
  128. data/app/views/mokio/backend/common/edit.html.haml +0 -6
  129. data/app/views/mokio/backend/common/index.html.haml +0 -19
  130. data/app/views/mokio/backend/common/new.html.haml +0 -6
  131. data/app/views/mokio/backend/contacts/_form.html.haml +0 -42
  132. data/app/views/mokio/backend/contents/_content_info_widget.html.haml +0 -22
  133. data/app/views/mokio/backend/dashboard/_content.html.haml +0 -9
  134. data/app/views/mokio/backend/dashboard/show.html.haml +0 -35
  135. data/app/views/mokio/backend/dashboard/tbl_content.html.haml +0 -24
  136. data/app/views/mokio/backend/data_files/_file_upload.html.erb +0 -71
  137. data/app/views/mokio/backend/data_files/uploader.html.haml +0 -15
  138. data/app/views/mokio/backend/errors/404.html.haml +0 -45
  139. data/app/views/mokio/backend/errors/unauthorized.html.haml +0 -11
  140. data/app/views/mokio/backend/layout/_user_widget.html.haml +0 -8
  141. data/app/views/mokio/backend/layout/header.html.haml +0 -14
  142. data/app/views/mokio/backend/layout/sidebar.html.haml +0 -59
  143. data/app/views/mokio/backend/menus/_form.html.haml +0 -66
  144. data/app/views/mokio/backend/menus/_menu.html.haml +0 -24
  145. data/app/views/mokio/backend/menus/index.html.haml +0 -53
  146. data/app/views/mokio/backend/menus/index.json.jbuilder +0 -4
  147. data/app/views/mokio/backend/menus/lang_changed.js.haml +0 -6
  148. data/app/views/mokio/backend/menus/sort.html.haml +0 -1
  149. data/app/views/mokio/backend/menus/update_menu_breadcrumps.js.haml +0 -1
  150. data/app/views/mokio/backend/mov_galleries/_form.html.haml +0 -17
  151. data/app/views/mokio/backend/mov_galleries/_form_inputs.html.haml +0 -8
  152. data/app/views/mokio/backend/photos/_gallery.html.haml +0 -25
  153. data/app/views/mokio/backend/photos/create.js.haml +0 -1
  154. data/app/views/mokio/backend/photos/crop_photo.js.haml +0 -10
  155. data/app/views/mokio/backend/photos/crop_thumb.js.haml +0 -11
  156. data/app/views/mokio/backend/photos/destroy.js.haml +0 -1
  157. data/app/views/mokio/backend/photos/from_external_link.html.haml +0 -19
  158. data/app/views/mokio/backend/photos/get_photo.js.haml +0 -1
  159. data/app/views/mokio/backend/photos/get_thumb.js.haml +0 -1
  160. data/app/views/mokio/backend/photos/photo.html.haml +0 -54
  161. data/app/views/mokio/backend/photos/remove_thumb.js.haml +0 -10
  162. data/app/views/mokio/backend/photos/rotate_photo.js.haml +0 -10
  163. data/app/views/mokio/backend/photos/rotate_thumb.js.haml +0 -11
  164. data/app/views/mokio/backend/photos/thumb.html.haml +0 -9
  165. data/app/views/mokio/backend/photos/update_thumb.js.haml +0 -11
  166. data/app/views/mokio/backend/photos/upload_external_links.js.haml +0 -4
  167. data/app/views/mokio/backend/pic_galleries/_form.html.haml +0 -16
  168. data/app/views/mokio/backend/pic_galleries/_form_inputs.html.haml +0 -9
  169. data/app/views/mokio/backend/site_helper/first_login.html.haml +0 -14
  170. data/app/views/mokio/backend/static_modules/_form.html.haml +0 -9
  171. data/app/views/mokio/backend/users/_form.html.haml +0 -11
  172. data/app/views/mokio/backend/users/edit_password.html.haml +0 -13
  173. data/app/views/mokio/backend/youtubes/_edit.html.haml +0 -49
  174. data/app/views/mokio/backend/youtubes/_gallery.html.haml +0 -24
  175. data/app/views/mokio/backend/youtubes/_new.html.haml +0 -4
  176. data/app/views/mokio/backend/youtubes/_preview_movie.html.haml +0 -1
  177. data/app/views/mokio/backend/youtubes/_search_yt.html.haml +0 -8
  178. data/app/views/mokio/backend/youtubes/_search_yt_body.html.haml +0 -11
  179. data/app/views/mokio/backend/youtubes/find.js.haml +0 -1
  180. data/app/views/mokio/backend/youtubes/preview.html.haml +0 -36
  181. data/app/views/mokio/backend/youtubes/preview_movie.js.haml +0 -5
  182. data/app/views/mokio/backend/youtubes/thumb.html.haml +0 -14
  183. data/app/views/mokio/backend/youtubes/uploader.html.haml +0 -10
  184. data/app/views/mokio/backend/youtubes/youtube.html.haml +0 -12
  185. data/app/views/mokio/base_articles/_multi_lang_form.html.slim +0 -18
  186. data/app/views/mokio/base_contacts/_multi_lang_form.html.slim +0 -48
  187. data/app/views/mokio/base_contents/update_content_form.js.slim +0 -1
  188. data/app/views/mokio/base_pic_galleries/_multi_lang_form.html.slim +0 -13
  189. data/app/views/mokio/common/_meta.html.slim +0 -50
  190. data/app/views/mokio/common/_multi_lang_gmap.html.slim +0 -41
  191. data/app/views/mokio/common/_multi_lang_meta.html.slim +0 -50
  192. data/app/views/mokio/common/multi_lang_form_content.html.slim +0 -56
  193. data/db/migrate/20140731061227_create_mokio_external_scripts.rb +0 -12
  194. data/db/migrate/20141009125027_alter_external_scripts.rb +0 -13
  195. data/db/migrate/20141024131942_migrate_external_codes_to_external_scripts.rb +0 -25
  196. data/db/migrate/20141209072051_change_data_type_for_display_dates.rb +0 -8
  197. data/db/migrate/20141209101853_add_menu_css_options.rb +0 -6
  198. data/db/migrate/20150220071158_add_subtitle_to_contents.rb +0 -7
  199. data/db/migrate/20150220091326_add_main_pic_to_mokio_menu.rb +0 -5
  200. data/db/migrate/20150408074951_create_mokio_base_contents.rb +0 -17
  201. data/db/migrate/20150408075454_add_base_content_id_to_mokio_contents.mokio.rb +0 -6
  202. data/db/migrate/20150414054139_add_name_to_mokio_users.rb +0 -6
  203. data/db/migrate/20150414070406_add_author_and_editor_to_mokio_content.rb +0 -6
  204. data/db/migrate/20150528104851_add_base_content_id_to_mokio_data_files.rb +0 -5
  205. data/lib/mokio/concerns/controllers/base_articles.rb +0 -31
  206. data/lib/mokio/concerns/controllers/base_contacts.rb +0 -32
  207. data/lib/mokio/concerns/controllers/base_contents.rb +0 -167
  208. data/lib/mokio/concerns/controllers/base_mov_galleries.rb +0 -48
  209. data/lib/mokio/concerns/controllers/base_pic_galleries.rb +0 -32
  210. data/lib/mokio/concerns/models/base_article.rb +0 -21
  211. data/lib/mokio/concerns/models/base_contact.rb +0 -36
  212. data/lib/mokio/concerns/models/base_content.rb +0 -51
  213. data/lib/mokio/concerns/models/base_mov_gallery.rb +0 -19
  214. data/lib/mokio/concerns/models/base_pic_gallery.rb +0 -22
  215. data/lib/mokio/concerns/models/meta.rb +0 -39
  216. data/spec/factories/meta.rb +0 -37
  217. data/spec/models/meta_spec.rb +0 -26
@@ -1,4 +1,4 @@
1
- class AddMokioToApplication < ActiveRecord::Migration
1
+ class AddMokioToApplication < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  create_table "mokio_available_modules" do |t|
4
4
  t.datetime "created_at"
@@ -46,6 +46,7 @@ class AddMokioToApplication < ActiveRecord::Migration
46
46
 
47
47
  create_table "mokio_contents" do |t|
48
48
  t.string "title"
49
+ t.text "subtitle"
49
50
  t.text "intro"
50
51
  t.text "content"
51
52
  t.string "type"
@@ -57,11 +58,12 @@ class AddMokioToApplication < ActiveRecord::Migration
57
58
  t.string "gallery_type"
58
59
  t.boolean "editable", default: true
59
60
  t.boolean "deletable", default: true
60
- t.date "display_from"
61
- t.date "display_to"
61
+ t.datetime "display_from"
62
+ t.datetime "display_to"
62
63
  t.datetime "created_at"
64
+ t.integer "created_by"
63
65
  t.datetime "updated_at"
64
- t.integer "meta_id"
66
+ t.integer "updated_by"
65
67
  t.integer "gmap_id"
66
68
  t.string "comment_type"
67
69
  t.datetime "etag"
@@ -69,7 +71,6 @@ class AddMokioToApplication < ActiveRecord::Migration
69
71
  end
70
72
 
71
73
  add_index "mokio_contents", ["gmap_id"], name: "index_mokio_contents_on_gmap_id", using: :btree
72
- add_index "mokio_contents", ["meta_id"], name: "index_mokio_contents_on_meta_id", using: :btree
73
74
 
74
75
  create_table "mokio_data_files" do |t|
75
76
  t.string "name"
@@ -122,7 +123,9 @@ class AddMokioToApplication < ActiveRecord::Migration
122
123
  end
123
124
 
124
125
  create_table "mokio_menus" do |t|
126
+ t.string "main_pic"
125
127
  t.string "name"
128
+ t.text "subtitle"
126
129
  t.boolean "active", default: true
127
130
  t.integer "seq"
128
131
  t.string "target"
@@ -139,31 +142,15 @@ class AddMokioToApplication < ActiveRecord::Migration
139
142
  t.boolean "content_editable", default: true
140
143
  t.boolean "modules_editable", default: true
141
144
  t.boolean "fake", default: false
142
- t.integer "meta_id"
143
- t.boolean "follow"
145
+ t.boolean "follow"
144
146
  t.string "slug"
147
+ t.string "css_class"
148
+ t.string "css_body_class"
145
149
  end
146
150
 
147
151
  add_index "mokio_menus", ["ancestry"], name: "index_mokio_menus_on_ancestry", using: :btree
148
- add_index "mokio_menus", ["meta_id"], name: "index_mokio_menus_on_meta_id", using: :btree
149
152
  add_index "mokio_menus", ["slug"], name: "index_mokio_menus_on_slug", unique: true, using: :btree
150
153
 
151
- create_table "mokio_meta" do |t|
152
- t.string "g_title"
153
- t.string "g_desc"
154
- t.string "g_keywords"
155
- t.string "g_author"
156
- t.string "g_copyright"
157
- t.string "g_application_name"
158
- t.string "f_title"
159
- t.string "f_type"
160
- t.string "f_image"
161
- t.string "f_url"
162
- t.string "f_desc"
163
- t.datetime "created_at"
164
- t.datetime "updated_at"
165
- end
166
-
167
154
  create_table "mokio_module_positions" do |t|
168
155
  t.string "name"
169
156
  t.string "tpl"
@@ -192,6 +179,7 @@ class AddMokioToApplication < ActiveRecord::Migration
192
179
  create_table "mokio_static_modules" do |t|
193
180
  t.integer "available_modules_id"
194
181
  t.string "title"
182
+ t.text "subtitle"
195
183
  t.text "content"
196
184
  t.string "external_link"
197
185
  t.integer "lang_id"
@@ -209,6 +197,8 @@ class AddMokioToApplication < ActiveRecord::Migration
209
197
 
210
198
  create_table "mokio_users" do |t|
211
199
  t.string "email", default: "", null: false
200
+ t.string "first_name"
201
+ t.string "last_name"
212
202
  t.string "encrypted_password", default: "", null: false
213
203
  t.string "reset_password_token"
214
204
  t.datetime "reset_password_sent_at"
@@ -225,5 +215,13 @@ class AddMokioToApplication < ActiveRecord::Migration
225
215
 
226
216
  add_index "mokio_users", ["email"], name: "index_mokio_users_on_email", unique: true, using: :btree
227
217
  add_index "mokio_users", ["reset_password_token"], name: "index_mokio_users_on_reset_password_token", unique: true, using: :btree
218
+
219
+ create_table :mokio_external_scripts do |t|
220
+ t.string "name"
221
+ t.text "script"
222
+ t.boolean "editable",default: true
223
+ t.boolean "deletable",default: true
224
+ end
225
+
228
226
  end
229
227
  end
@@ -0,0 +1,11 @@
1
+
2
+ class CreateMokioSeoTags < ActiveRecord::Migration[5.0]
3
+ def change
4
+ create_table :mokio_seo_tags do |t|
5
+ t.string :tag_key
6
+ t.text :tag_value
7
+ t.references :seo_tagable, polymorphic: true, index: true
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -9,7 +9,7 @@ require "jquery-fileupload-rails"
9
9
  require 'amoeba'
10
10
  require 'fancybox2-rails'
11
11
  require "bootstrap-switch-rails"
12
- require 'youtube_it'
12
+ # require 'youtube_it'
13
13
  require 'ancestry'
14
14
  require 'acts_as_list'
15
15
  require 'jquery-datatables-rails'
@@ -38,7 +38,7 @@ module Mokio
38
38
  #
39
39
  # Rails version supported by Mokio
40
40
  #
41
- SUPPORTED_RAILS = 4
41
+ SUPPORTED_RAILS = 6
42
42
 
43
43
  #
44
44
  # Array of content types
@@ -109,10 +109,10 @@ module Mokio
109
109
  self.backend_gmap_enabled = ["Mokio::Contact"]
110
110
 
111
111
  #
112
- # Enable adding meta tags for listed models
112
+ # Language CMS
113
113
  #
114
- mattr_accessor :backend_meta_enabled
115
- self.backend_meta_enabled = ["Mokio::Menu"] + Mokio::CONTENT_TYPES
114
+ mattr_accessor :cms_locale
115
+ self.cms_locale = :pl
116
116
 
117
117
  #
118
118
  # How much records are listed in dashboard boxes
@@ -207,7 +207,7 @@ module Mokio
207
207
  #
208
208
  # For developers, enable/disable debuging
209
209
  # use it for testing purposes
210
- #
210
+ #
211
211
  mattr_accessor :debug_all
212
212
  self.debug_all = false
213
213
 
@@ -220,12 +220,9 @@ module Mokio
220
220
  mattr_accessor :solr_enabled
221
221
  self.solr_enabled = false
222
222
 
223
- mattr_accessor :mokio_log_level
223
+ mattr_accessor :mokio_log_level
224
224
  self.mokio_log_level = Logger::DEBUG
225
225
 
226
- mattr_accessor :multi_lang_contents
227
- self.multi_lang_contents = false
228
-
229
226
  mattr_accessor :mokio_gems_parameters
230
227
  self.mokio_gems_parameters = {}
231
228
 
@@ -235,6 +232,36 @@ module Mokio
235
232
  mattr_accessor :after_sign_out_path
236
233
  self.after_sign_out_path = {:user => {}}
237
234
 
235
+ # Enable/disable sitemap generation
236
+ # include Mokio::Concerns::Common::Services::Sitemap::Model
237
+ mattr_accessor :mokio_sitemap_generator_enable
238
+ self.mokio_sitemap_generator_enable = true
239
+
240
+ # List of static routes it should be included in sitemap
241
+ # -------------------------------------------------
242
+ # loc: url (required)
243
+ # lastmod: last modification date ( can be nil )
244
+ # priority: ( can be nil ) ( default 1.0 )
245
+ # -------------------------
246
+ # example self.mokio_sitemap_generator_static =
247
+ # [{loc: "www.exmaple.loc",lastmod: "YYYY-MM-DD HH-MM-SS+0000",priority: "1.0"}]
248
+ # -------------------------------------------------
249
+
250
+ mattr_accessor :mokio_sitemap_generator_static
251
+ self.mokio_sitemap_generator_static = []
252
+
253
+ # sitemap.xml path ( filename or subfolder path)
254
+ # example: www.example.loc/location/sitemap_custom.xml
255
+ # self.mokio_sitemap_generator_path = "location/sitemap_custom"
256
+
257
+ mattr_accessor :mokio_sitemap_generator_path
258
+ self.mokio_sitemap_generator_path = ""
259
+
260
+ # Enabled models list
261
+ # self.mokio_sitemap_enabled_models = ["Mokio::Content"]
262
+ mattr_accessor :mokio_sitemap_enabled_models
263
+ self.mokio_sitemap_enabled_models = ["Mokio::Content"]
264
+
238
265
  #
239
266
  # Default way to configure Mokio
240
267
  #
@@ -27,7 +27,6 @@ require "mokio/concerns/models/data_file"
27
27
  require "mokio/concerns/models/gmap"
28
28
  require "mokio/concerns/models/lang"
29
29
  require "mokio/concerns/models/mailer"
30
- require "mokio/concerns/models/meta"
31
30
  require "mokio/concerns/models/module_position"
32
31
  require "mokio/concerns/models/mov_gallery"
33
32
  require "mokio/concerns/models/photo"
@@ -38,11 +37,7 @@ require "mokio/concerns/models/static_module"
38
37
  require "mokio/concerns/models/user"
39
38
  require "mokio/concerns/models/youtube"
40
39
  require "mokio/concerns/models/external_script"
41
- require "mokio/concerns/models/base_content"
42
- require "mokio/concerns/models/base_article"
43
- require "mokio/concerns/models/base_pic_gallery"
44
- require "mokio/concerns/models/base_mov_gallery"
45
- require "mokio/concerns/models/base_contact"
40
+ require "mokio/concerns/models/seo_tag"
46
41
 
47
42
  #
48
43
  # CommonController extensions
@@ -50,11 +45,11 @@ require "mokio/concerns/models/base_contact"
50
45
  require "mokio/concerns/common/controller_object"
51
46
  require "mokio/concerns/common/controller_functions"
52
47
  require "mokio/concerns/common/controller_translations"
53
-
48
+ require "mokio/concerns/common/seo_tags"
49
+ require "mokio/concerns/common/services/sitemap_service"
54
50
  #
55
51
  # Controllers
56
52
  #
57
- require "mokio/concerns/controllers/base_contents"
58
53
  require "mokio/concerns/controllers/application"
59
54
  require "mokio/concerns/controllers/articles"
60
55
  require "mokio/concerns/controllers/base"
@@ -73,11 +68,6 @@ require "mokio/concerns/controllers/youtubes"
73
68
  require "mokio/concerns/controllers/external_scripts"
74
69
  require "mokio/concerns/controllers/module_positions"
75
70
  require "mokio/concerns/controllers/langs"
76
- require "mokio/concerns/controllers/base_contents"
77
- require "mokio/concerns/controllers/base_articles"
78
- require "mokio/concerns/controllers/base_pic_galleries"
79
- require "mokio/concerns/controllers/base_mov_galleries"
80
- require "mokio/concerns/controllers/base_contacts"
81
71
  require "mokio/concerns/controllers/main_pics"
82
72
 
83
73
 
@@ -8,22 +8,10 @@ module Mokio
8
8
  extend ActiveSupport::Concern
9
9
 
10
10
  included do
11
-
12
11
  after_action :back_to_edit, only: [:create, :update]
13
- after_action :meta_info, only: [:create, :update]
14
-
15
12
  end
16
13
 
17
14
  private
18
- #
19
- # <b>after_action</b>, Info message about autocompleted meta tags
20
- #
21
- def meta_info #:doc:
22
- if flash[:notice].present?
23
- flash[:notice] += " #{t("meta.auto_completed")}" if obj.respond_to?(:empty_meta) && obj.empty_meta && obj.id
24
- end
25
- end
26
-
27
15
  #
28
16
  # <b>after_action</b>, Info message about possible back to edit
29
17
  #
@@ -35,7 +23,6 @@ module Mokio
35
23
 
36
24
  def build_enabled(obj)
37
25
  obj.build_gmap if obj.class.has_gmap_enabled?
38
- obj.build_meta if obj.class.has_meta_enabled?
39
26
  end
40
27
 
41
28
  # @TODO - move here data_files_attributes ?
@@ -46,8 +33,7 @@ module Mokio
46
33
  def extended_parameters #:doc:
47
34
  parameters = {}
48
35
  parameters[:gmap_attributes] = Mokio::Gmap.gmap_attributes if @obj_class.has_gmap_enabled?
49
- parameters[:meta_attributes] = Mokio::Meta.meta_attributes if @obj_class.has_meta_enabled?
50
-
36
+ parameters[:seo_tags_attributes] = Mokio::SeoTag.seo_tag_attributes if @obj_class.has_seo_tagable_enabled?
51
37
  parameters
52
38
  end
53
39
 
@@ -8,7 +8,7 @@ module Mokio
8
8
  extend ActiveSupport::Concern
9
9
 
10
10
  included do
11
- before_filter :set_obj_class
11
+ before_action :set_obj_class
12
12
  before_action :set_obj, only: [:update, :destroy, :edit, :show, :copy, :update_active]
13
13
 
14
14
  helper_method :obj # Method obj must be also a helper method for usage in views
@@ -71,7 +71,7 @@ module Mokio
71
71
 
72
72
  #
73
73
  # Setting constant parsed from controller name to @obj_class variable.
74
- # Our controllers are named to match model name. <b>before_filter</b> in CommonController
74
+ # Our controllers are named to match model name. <b>before_action</b> in CommonController
75
75
  #
76
76
  def set_obj_class #:doc:
77
77
 
@@ -0,0 +1,32 @@
1
+ module Mokio
2
+ module Concerns
3
+ module Common
4
+ module SeoTags
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ has_many :seo_tags, as: :seo_tagable, :class_name => 'Mokio::SeoTag'
9
+ accepts_nested_attributes_for :seo_tags, reject_if: :all_blank, allow_destroy: true
10
+ end
11
+
12
+ module ClassMethods
13
+ def has_seo_tagable_enabled?
14
+ true
15
+ end
16
+
17
+ def render_label(name)
18
+ el = Mokio::SeoTag.seo_tags_list.select{|value| value[:key] == name }
19
+ "<meta #{el[0][:type]}='#{el[0][:key]}' />"
20
+ end
21
+
22
+ def seo_tagable_columns
23
+ columns = Mokio::SeoTag.seo_tags_list_keys
24
+ columns - self.seo_tagable_custom_columns if self.respond_to?("seo_tagable_custom_columns")
25
+ columns
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,196 @@
1
+ module Mokio
2
+ module Concerns #:nodoc:
3
+ module Common #:nodoc:
4
+ module Services
5
+ module Sitemap
6
+ module Service
7
+ extend ActiveSupport::Concern
8
+ attr_accessor :regenerate_sitemap
9
+
10
+ def self.regenerate_sitemap
11
+ begin
12
+ sitemap_enabled = Mokio.mokio_sitemap_generator_enable || false
13
+ return unless sitemap_enabled
14
+
15
+ mokio_cfg_sitemap_enabled_models = Mokio.mokio_sitemap_enabled_models
16
+ mokio_cfg_routes = Mokio.mokio_sitemap_generator_static
17
+ mokio_cfg_path = Mokio.mokio_sitemap_generator_path
18
+
19
+ @sitemap_generator_enabled_models = (mokio_cfg_sitemap_enabled_models.any?) ? mokio_cfg_sitemap_enabled_models : []
20
+ @sitemap_generator_static_routes = (mokio_cfg_routes.any?) ? mokio_cfg_routes : []
21
+ @sitemap_generator_path = (mokio_cfg_path.present?) ? mokio_cfg_path : "sitemap.xml"
22
+ @sitemap_generator_base_url = parse_base_url
23
+
24
+ @static_content_priority = 1
25
+ @dynamic_content_priority = 1
26
+
27
+ @default_date = DateTime.now.strftime("%Y-%m-%dT%H:%M:%S%:z")
28
+ generate_sitemap
29
+
30
+ rescue StandardError => e
31
+ Rails.logger.error "Sitemap service: error"
32
+ Rails.logger.error "Rescued: #{e.inspect}"
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def self.parse_base_url
39
+ root_url = ENV['APP_HOST']
40
+ if root_url.blank?
41
+ "/"
42
+ else
43
+ root_url = root_url.strip
44
+ root_url = "#{root_url}/" if root_url.last != "/"
45
+ root_url
46
+ end
47
+ end
48
+
49
+ def self.generate_sitemap
50
+ puts "Sitemap service: call"
51
+ generate_xml
52
+ end
53
+
54
+ def self.generate_static_sitemap(xml)
55
+ puts "Sitemap service: Generate static sitemap: start"
56
+ return xml_static_collection(xml)
57
+ return nil
58
+ end
59
+
60
+ def self.generate_dynamic_sitemap(xml)
61
+
62
+ puts "Sitemap service: Generate dynamic sitemap: start"
63
+ data = []
64
+
65
+ @sitemap_generator_enabled_models.each do |model_name|
66
+ model = model_name.classify.constantize
67
+ model.all.each do |rec|
68
+ if rec.can_add_to_sitemap?
69
+ data << rec.sitemap_url_strategy_default
70
+ end
71
+ end
72
+ end
73
+
74
+ puts "Sitemap service: empty collection" if data.nil?
75
+ return xml_dynamic_collection(data,xml) if data.present?
76
+ return nil
77
+ end
78
+
79
+ def self.generate_xml
80
+ puts "Sitemap service: Generate new xml file"
81
+
82
+ begin
83
+ xml = Nokogiri::XML::Builder.new { |xml|
84
+ xml.urlset('xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",:xmlns => "http://www.sitemaps.org/schemas/sitemap/0.9") do
85
+ generate_static_sitemap(xml)
86
+ generate_dynamic_sitemap(xml)
87
+ end
88
+ }.to_xml
89
+
90
+ path_file = "#{Rails.public_path}/#{@sitemap_generator_path}"
91
+ puts "Sitemap service: Save xml file to public #{@sitemap_generator_path} - #{path_file}"
92
+ file = File.new(path_file, "w")
93
+ file.write(xml)
94
+ file.close
95
+ return true
96
+ rescue StandardError => e
97
+ Rails.logger.error "Sitemap service: error"
98
+ Rails.logger.error "Rescued: #{e.inspect}"
99
+ end
100
+ end
101
+
102
+ def self.xml_dynamic_collection(obj,xml)
103
+ obj.each do |item|
104
+ path = item[:loc]
105
+ if item[:lastmod]
106
+ date = item[:lastmod].strftime("%Y-%m-%dT%H:%M:%S%:z")
107
+ else
108
+ date = @default_date
109
+ end
110
+
111
+ if path.present?
112
+ xml.url do
113
+ xml.loc parse_url(path)
114
+ xml.lastmod date
115
+ xml.priority @dynamic_content_priority
116
+ end
117
+ end
118
+ end
119
+ end
120
+
121
+ def self.xml_static_collection(xml)
122
+ @sitemap_generator_static_routes.each do |item|
123
+ path = item[:loc]
124
+ date = item[:lastmod] || @default_date
125
+ if path.present?
126
+ xml.url do
127
+ xml.loc parse_url(path)
128
+ xml.priority item[:priority] || @static_content_priority
129
+ xml.lastmod date
130
+ end
131
+ end
132
+ end
133
+ end
134
+
135
+ def self.parse_url(path)
136
+ if path.first == "/"
137
+ result_path = path
138
+ else
139
+ result_path = "/#{path}"
140
+ end
141
+ base_url = @sitemap_generator_base_url[0...-1] if @sitemap_generator_base_url.last == "/"
142
+ "#{base_url}#{result_path}"
143
+ end
144
+ end
145
+
146
+ module Model
147
+ extend ActiveSupport::Concern
148
+
149
+ included do
150
+ after_save :regenerate_sitemap
151
+ after_destroy :regenerate_sitemap
152
+ end
153
+
154
+ def regenerate_sitemap
155
+ Service.regenerate_sitemap
156
+ end
157
+
158
+ def can_add_to_sitemap?
159
+ true
160
+ end
161
+
162
+ def sitemap_url_strategy_default
163
+ if self.respond_to? :sitemap_url_strategy
164
+ return self.sitemap_url_strategy
165
+ else
166
+ if self.respond_to? :title
167
+ value = self.title
168
+ elsif self.respond_to? :name
169
+ value = self.name
170
+ elsif self.respond_to? :columns_for_table
171
+ first_column = self.class.columns_for_table.first
172
+ value = self.send("#{first_column }")
173
+ else
174
+ raise "sitemap_url_strategy not found in #{self.class} and service can't find any compatible columns for path generation"
175
+ end
176
+
177
+ return {loc: "#{value}", priority: 1, lastmod: self.updated_at }
178
+ end
179
+ end
180
+
181
+ # EXAMPLE USAGE OF sitemap_url_strategy METHOD IN INCLUDED MODEL
182
+ # def sitemap_url_strategy(obj)
183
+ # {loc: "#{self.title}",priority: 1,lastmod: self.updated_at }
184
+ # end
185
+
186
+ # EXAMPLE USAGE OF sitemapable METHOD IN INCLUDED MODEL
187
+ # def sitemapable
188
+ # (self.title == "title2") ? true : false
189
+ # end
190
+
191
+ end
192
+ end
193
+ end
194
+ end
195
+ end
196
+ end