camaleon_cms 1.1.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of camaleon_cms might be problematic. Click here for more details.

Files changed (635) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +27 -60
  3. data/app/apps/plugins/attack/admin_controller.rb +1 -1
  4. data/app/apps/plugins/attack/attack_helper.rb +4 -4
  5. data/app/apps/plugins/attack/config/config.json +1 -1
  6. data/app/apps/plugins/attack/config/custom_models.rb +1 -1
  7. data/app/apps/plugins/attack/views/admin/settings.html.erb +2 -2
  8. data/app/apps/plugins/contact_form/admin_forms_controller.rb +8 -7
  9. data/app/apps/plugins/contact_form/config/custom_models.rb +1 -1
  10. data/app/apps/plugins/contact_form/contact_form_helper.rb +4 -5
  11. data/app/apps/plugins/contact_form/contact_form_html_helper.rb +2 -2
  12. data/app/apps/plugins/contact_form/front_controller.rb +1 -1
  13. data/app/apps/plugins/contact_form/views/admin_forms/_form.html.erb +5 -5
  14. data/app/apps/plugins/contact_form/views/admin_forms/edit.html.erb +19 -35
  15. data/app/apps/plugins/contact_form/views/admin_forms/index.html.erb +3 -3
  16. data/app/apps/plugins/contact_form/views/admin_forms/responses.html.erb +6 -13
  17. data/app/apps/plugins/contact_form/views/forms_shorcode.html.erb +1 -1
  18. data/app/apps/plugins/contact_form/views/front/index.html.erb +1 -1
  19. data/app/apps/plugins/front_cache/admin_controller.rb +1 -1
  20. data/app/apps/plugins/front_cache/config/initializer.rb +1 -1
  21. data/app/apps/plugins/front_cache/front_cache_helper.rb +37 -42
  22. data/app/apps/plugins/front_cache/views/admin/settings.html.erb +3 -3
  23. data/app/apps/plugins/visibility_post/config/config.json +1 -1
  24. data/app/apps/plugins/visibility_post/visibility_post_helper.rb +21 -23
  25. data/app/apps/themes/camaleon_first/assets/css/main.css +1 -1
  26. data/app/apps/themes/camaleon_first/assets/js/main.js +1 -1
  27. data/app/apps/themes/camaleon_first/views/admin/settings.html.erb +1 -1
  28. data/app/apps/themes/default/views/admin/settings.html.erb +1 -1
  29. data/app/apps/themes/default/views/category.html.erb +1 -1
  30. data/app/apps/themes/default/views/layouts/index.html.erb +7 -7
  31. data/app/apps/themes/default/views/partials/_comments.html.erb +1 -1
  32. data/app/apps/themes/default/views/partials/_forms.html.erb +2 -2
  33. data/app/apps/themes/default/views/partials/_search_form.html.erb +4 -4
  34. data/app/apps/themes/default/views/post_tag.html.erb +1 -1
  35. data/app/apps/themes/default/views/post_type.html.erb +1 -1
  36. data/app/apps/themes/default/views/search.html.erb +1 -1
  37. data/app/apps/themes/new/assets/js/main.js +0 -1
  38. data/app/apps/themes/new/views/admin/settings.html.erb +1 -1
  39. data/app/apps/themes/new/views/category.html.erb +1 -1
  40. data/app/apps/themes/new/views/layouts/_footer.html.erb +0 -1
  41. data/app/apps/themes/new/views/layouts/_header.html.erb +7 -7
  42. data/app/apps/themes/new/views/layouts/index.html.erb +0 -1
  43. data/app/apps/themes/new/views/partials/_comments.html.erb +1 -1
  44. data/app/apps/themes/new/views/partials/_forms.html.erb +2 -2
  45. data/app/apps/themes/new/views/partials/_search_form.html.erb +2 -3
  46. data/app/apps/themes/new/views/post_tag.html.erb +1 -1
  47. data/app/apps/themes/new/views/post_type.html.erb +1 -1
  48. data/app/apps/themes/new/views/search.html.erb +1 -1
  49. data/app/assets/fonts/{glyphicons-halflings-regular.eot → camaleon_cms/glyphicons-halflings-regular.eot} +0 -0
  50. data/app/assets/fonts/{glyphicons-halflings-regular.svg → camaleon_cms/glyphicons-halflings-regular.svg} +0 -0
  51. data/app/assets/fonts/{glyphicons-halflings-regular.ttf → camaleon_cms/glyphicons-halflings-regular.ttf} +0 -0
  52. data/app/assets/fonts/{glyphicons-halflings-regular.woff → camaleon_cms/glyphicons-halflings-regular.woff} +0 -0
  53. data/app/assets/images/camaleon_cms/admin/admin_spinner.gif +0 -0
  54. data/app/assets/images/{admin → camaleon_cms/admin}/glyphicons-halflings.png +0 -0
  55. data/app/assets/images/{admin → camaleon_cms/admin}/intro/menus.png +0 -0
  56. data/app/assets/images/{admin → camaleon_cms/admin}/no_image.jpg +0 -0
  57. data/app/assets/images/{bg-tree.jpeg → camaleon_cms/bg-tree.jpeg} +0 -0
  58. data/app/assets/images/{camaleon-dark.png → camaleon_cms/camaleon-dark.png} +0 -0
  59. data/app/assets/images/camaleon_cms/camaleon.png +0 -0
  60. data/app/assets/images/{category-icon.png → camaleon_cms/category-icon.png} +0 -0
  61. data/app/assets/images/camaleon_cms/favicon.ico +0 -0
  62. data/app/assets/images/{image-not-found.png → camaleon_cms/image-not-found.png} +0 -0
  63. data/app/assets/images/{language → camaleon_cms/language}/de.png +0 -0
  64. data/app/assets/images/{language → camaleon_cms/language}/en.png +0 -0
  65. data/app/assets/images/{language → camaleon_cms/language}/es.png +0 -0
  66. data/app/assets/images/{language → camaleon_cms/language}/fr.png +0 -0
  67. data/app/assets/images/{language → camaleon_cms/language}/it.png +0 -0
  68. data/app/assets/images/{language → camaleon_cms/language}/pt.png +0 -0
  69. data/app/assets/images/camaleon_cms/language/pt_br.png +0 -0
  70. data/app/assets/images/{language → camaleon_cms/language}/zh.png +0 -0
  71. data/app/assets/images/{loader.gif → camaleon_cms/loader.gif} +0 -0
  72. data/app/assets/images/{users → camaleon_cms/users}/no-image.jpg +0 -0
  73. data/app/assets/javascripts/{admin/actions.js → camaleon_cms/admin/_actions.js} +3 -5
  74. data/app/assets/javascripts/camaleon_cms/admin/_custom_fields.js +178 -0
  75. data/app/assets/javascripts/{admin/data.js → camaleon_cms/admin/_data.js} +4 -9
  76. data/app/assets/javascripts/{admin/i18n.js → camaleon_cms/admin/_i18n.js} +10 -4
  77. data/app/assets/javascripts/{admin/jquery-ui.min.js → camaleon_cms/admin/_jquery-ui.min.js} +0 -0
  78. data/app/assets/javascripts/camaleon_cms/admin/_jquery.slugify.js +67 -0
  79. data/app/assets/javascripts/{admin/jquery.tagsinput.min.js → camaleon_cms/admin/_jquery.tagsinput.min.js} +0 -0
  80. data/app/assets/javascripts/camaleon_cms/admin/_libraries.js +339 -0
  81. data/app/assets/javascripts/{admin/modal.js → camaleon_cms/admin/_modal.js} +42 -25
  82. data/app/assets/javascripts/camaleon_cms/admin/_post.js +303 -0
  83. data/app/assets/javascripts/{admin/translator.js → camaleon_cms/admin/_translator.js} +4 -3
  84. data/app/assets/javascripts/{admin/underscore.js → camaleon_cms/admin/_underscore.js} +0 -0
  85. data/app/assets/javascripts/camaleon_cms/admin/admin-basic-manifest.js +3 -0
  86. data/app/assets/javascripts/{admin → camaleon_cms/admin}/admin-manifest.js +23 -18
  87. data/app/assets/javascripts/{admin → camaleon_cms/admin}/bootstrap-colorpicker.js +0 -0
  88. data/app/assets/javascripts/{admin → camaleon_cms/admin}/bootstrap-datepicker.js +0 -0
  89. data/app/assets/javascripts/{admin → camaleon_cms/admin}/bootstrap-datetimepicker.min.js +0 -0
  90. data/app/assets/javascripts/{admin → camaleon_cms/admin}/bootstrap-select.js +0 -0
  91. data/app/assets/javascripts/camaleon_cms/admin/custom_fields_form.js +69 -0
  92. data/app/assets/javascripts/{admin → camaleon_cms/admin}/form-builder/formbuilder.js +0 -0
  93. data/app/assets/javascripts/{admin → camaleon_cms/admin}/form-builder/vendor.js +0 -0
  94. data/app/assets/javascripts/{admin → camaleon_cms/admin}/form/cropper.min.js +0 -0
  95. data/app/assets/javascripts/{admin → camaleon_cms/admin}/form/jquery.form.js +0 -0
  96. data/app/assets/javascripts/{admin/introjs/intro.min.js → camaleon_cms/admin/introjs/_intro.min.js} +0 -0
  97. data/app/assets/javascripts/{admin → camaleon_cms/admin}/jquery-sieve.js +0 -0
  98. data/app/assets/javascripts/{admin → camaleon_cms/admin}/jquery.nestable.js +0 -0
  99. data/app/assets/javascripts/{admin → camaleon_cms/admin}/jquery.validate.js +0 -0
  100. data/app/assets/javascripts/{admin → camaleon_cms/admin/jquery_validate}/es.js +0 -0
  101. data/app/assets/javascripts/{admin → camaleon_cms/admin/jquery_validate}/it.js +0 -0
  102. data/app/assets/javascripts/camaleon_cms/admin/jquery_validate/pt_br.js +74 -0
  103. data/app/assets/javascripts/{admin → camaleon_cms/admin}/login.js.coffee +0 -0
  104. data/app/assets/javascripts/{admin → camaleon_cms/admin}/login_manifest.js +0 -0
  105. data/app/assets/javascripts/{admin → camaleon_cms/admin}/lte/app.js +0 -0
  106. data/app/assets/javascripts/{admin → camaleon_cms/admin}/nav-menu.js +5 -0
  107. data/app/assets/javascripts/{admin → camaleon_cms/admin}/plugins.js +0 -0
  108. data/app/assets/javascripts/{admin/tageditor/jquery.caret.min.js → camaleon_cms/admin/tageditor/_jquery.caret.min.js} +0 -0
  109. data/app/assets/javascripts/{admin/tageditor/jquery.tag-editor.js → camaleon_cms/admin/tageditor/_jquery.tag-editor.js} +0 -0
  110. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/langs/en.js +0 -0
  111. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/langs/es.js +0 -0
  112. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/langs/it.js +0 -0
  113. data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/pt_br.js +219 -0
  114. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/langs/readme.md +0 -0
  115. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/plugins/emoticons/img/smiley-cool.gif +0 -0
  116. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/plugins/emoticons/img/smiley-cry.gif +0 -0
  117. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/plugins/emoticons/img/smiley-embarassed.gif +0 -0
  118. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/plugins/emoticons/img/smiley-foot-in-mouth.gif +0 -0
  119. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/plugins/emoticons/img/smiley-frown.gif +0 -0
  120. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/plugins/emoticons/img/smiley-innocent.gif +0 -0
  121. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/plugins/emoticons/img/smiley-kiss.gif +0 -0
  122. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/plugins/emoticons/img/smiley-laughing.gif +0 -0
  123. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/plugins/emoticons/img/smiley-money-mouth.gif +0 -0
  124. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/plugins/emoticons/img/smiley-sealed.gif +0 -0
  125. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/plugins/emoticons/img/smiley-smile.gif +0 -0
  126. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/plugins/emoticons/img/smiley-surprised.gif +0 -0
  127. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/plugins/emoticons/img/smiley-tongue-out.gif +0 -0
  128. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/plugins/emoticons/img/smiley-undecided.gif +0 -0
  129. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/plugins/emoticons/img/smiley-wink.gif +0 -0
  130. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/plugins/emoticons/img/smiley-yell.gif +0 -0
  131. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/plugins/filemanager/plugin.min.js +3 -4
  132. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/plugins/visualblocks/css/visualblocks.css +0 -0
  133. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/skins/lightgray/content.min.css.scss +2 -2
  134. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/skins/lightgray/fonts/tinymce-small.eot +0 -0
  135. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/skins/lightgray/fonts/tinymce-small.svg +0 -0
  136. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/skins/lightgray/fonts/tinymce-small.ttf +0 -0
  137. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/skins/lightgray/fonts/tinymce-small.woff +0 -0
  138. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/skins/lightgray/fonts/tinymce.eot +0 -0
  139. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/skins/lightgray/fonts/tinymce.svg +0 -0
  140. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/skins/lightgray/fonts/tinymce.ttf +0 -0
  141. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/skins/lightgray/fonts/tinymce.woff +0 -0
  142. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/skins/lightgray/img/anchor.gif +0 -0
  143. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/skins/lightgray/img/loader.gif +0 -0
  144. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/skins/lightgray/img/object.gif +0 -0
  145. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/skins/lightgray/img/trans.gif +0 -0
  146. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/themes/modern/theme.min.js +0 -0
  147. data/app/assets/javascripts/{admin → camaleon_cms/admin}/tinymce/tinymce.min.js +0 -0
  148. data/app/assets/javascripts/camaleon_cms/admin/uploader/_jquery.uploadfile.min.js +8 -0
  149. data/app/assets/javascripts/camaleon_cms/admin/uploader/_media_manager.js.coffee +161 -0
  150. data/app/assets/javascripts/camaleon_cms/admin/uploader/uploader_manifest.js +2 -0
  151. data/app/assets/javascripts/camaleon_cms/admin/user_profile.js +70 -0
  152. data/app/assets/javascripts/{bootstrap.min.js → camaleon_cms/bootstrap.min.js} +0 -0
  153. data/app/assets/javascripts/{gibberish-aes.js → camaleon_cms/gibberish-aes.js} +0 -0
  154. data/app/assets/stylesheets/camaleon_cms/admin/_custom_admin.css.scss +267 -0
  155. data/app/assets/stylesheets/{admin/jquery.tagsinput.css → camaleon_cms/admin/_jquery.tagsinput.css} +0 -0
  156. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/admin-basic-manifest.css +3 -3
  157. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/admin-manifest.css +16 -8
  158. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/bootstrap-datepicker.css.scss +0 -0
  159. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/bootstrap-datetimepicker.css.scss +1 -1
  160. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/colorpicker.css.scss +4 -4
  161. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/cropper/cropper.min.css +0 -0
  162. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/form-builder/formbuilder.css +0 -0
  163. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/img/bg.png +0 -0
  164. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/img/colorpicker/alpha.png +0 -0
  165. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/img/colorpicker/hue.png +0 -0
  166. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/img/colorpicker/saturation.png +0 -0
  167. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/img/girls-1.jpg +0 -0
  168. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/img/jquery/resize-icon.png +0 -0
  169. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/img/loading.gif +0 -0
  170. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/img/logo-small.png +0 -0
  171. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/img/logo.png +0 -0
  172. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/img/no_image.jpg +0 -0
  173. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/img/rormeleon-white.png +0 -0
  174. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/img/thumb_no_found.jpg +0 -0
  175. data/app/assets/stylesheets/{admin/introjs/introjs.min.css → camaleon_cms/admin/introjs/_introjs.min.css} +0 -0
  176. data/app/assets/stylesheets/{admin/jquery/jquery-ui.scss → camaleon_cms/admin/jquery/_jquery-ui.scss} +16 -16
  177. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/jquery/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  178. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/jquery/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  179. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  180. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/jquery/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  181. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/jquery/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  182. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  183. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/jquery/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  184. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  185. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/jquery/images/ui-icons_222222_256x240.png +0 -0
  186. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/jquery/images/ui-icons_2e83ff_256x240.png +0 -0
  187. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/jquery/images/ui-icons_454545_256x240.png +0 -0
  188. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/jquery/images/ui-icons_888888_256x240.png +0 -0
  189. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/jquery/images/ui-icons_cd0a0a_256x240.png +0 -0
  190. data/app/assets/stylesheets/{admin/lte/admin.css.scss → camaleon_cms/admin/lte/_admin.css.scss} +4 -0
  191. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/lte/skins/skin-black-light.css +0 -0
  192. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/lte/skins/skin-black.css +0 -0
  193. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/lte/skins/skin-blue-light.css +0 -0
  194. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/lte/skins/skin-blue.css +0 -0
  195. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/lte/skins/skin-green-light.css +0 -0
  196. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/lte/skins/skin-green.css +0 -0
  197. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/lte/skins/skin-purple-light.css +0 -0
  198. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/lte/skins/skin-purple.css +0 -0
  199. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/lte/skins/skin-red-light.css +0 -0
  200. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/lte/skins/skin-red.css +0 -0
  201. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/lte/skins/skin-yellow-light.css +0 -0
  202. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/lte/skins/skin-yellow.css +0 -0
  203. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/nav-menu.css.scss +0 -0
  204. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/nestable/jquery.nestable.css +0 -0
  205. data/app/assets/stylesheets/{admin/tageditor/jquery.tag-editor.css.scss → camaleon_cms/admin/tageditor/_jquery.tag-editor.css.scss} +0 -0
  206. data/app/assets/stylesheets/camaleon_cms/admin/uploader/_uploadfile.css.scss +253 -0
  207. data/app/assets/stylesheets/{admin → camaleon_cms/admin}/widgets.css.scss +0 -0
  208. data/app/assets/stylesheets/camaleon_cms/bootstrap.min.css.scss +5 -0
  209. data/app/controllers/{admin → camaleon_cms/admin}/appearances/nav_menus_controller.rb +14 -11
  210. data/app/controllers/{admin → camaleon_cms/admin}/appearances/themes_controller.rb +4 -2
  211. data/app/controllers/{admin → camaleon_cms/admin}/appearances/widgets/assign_controller.rb +5 -5
  212. data/app/controllers/{admin → camaleon_cms/admin}/appearances/widgets/main_controller.rb +8 -6
  213. data/app/controllers/{admin → camaleon_cms/admin}/appearances/widgets/sidebar_controller.rb +9 -9
  214. data/app/controllers/{admin → camaleon_cms/admin}/categories_controller.rb +18 -10
  215. data/app/controllers/camaleon_cms/admin/comments_controller.rb +97 -0
  216. data/app/controllers/{admin → camaleon_cms/admin}/installers_controller.rb +10 -10
  217. data/app/controllers/camaleon_cms/admin/media_controller.rb +84 -0
  218. data/app/controllers/{admin → camaleon_cms/admin}/plugins_controller.rb +7 -6
  219. data/app/controllers/{admin → camaleon_cms/admin}/post_tags_controller.rb +18 -10
  220. data/app/controllers/{admin → camaleon_cms/admin}/posts/drafts_controller.rb +5 -5
  221. data/app/controllers/{admin → camaleon_cms/admin}/posts_controller.rb +40 -23
  222. data/app/controllers/{admin → camaleon_cms/admin}/sessions_controller.rb +45 -35
  223. data/app/controllers/{admin → camaleon_cms/admin}/settings/custom_fields_controller.rb +13 -12
  224. data/app/controllers/{admin → camaleon_cms/admin}/settings/post_types_controller.rb +14 -13
  225. data/app/controllers/{admin → camaleon_cms/admin}/settings/sites_controller.rb +17 -15
  226. data/app/controllers/{admin → camaleon_cms/admin}/settings_controller.rb +8 -5
  227. data/app/controllers/{admin → camaleon_cms/admin}/user_roles_controller.rb +12 -11
  228. data/app/controllers/{admin → camaleon_cms/admin}/users_controller.rb +42 -48
  229. data/app/controllers/{admin_controller.rb → camaleon_cms/admin_controller.rb} +28 -9
  230. data/app/controllers/{apps → camaleon_cms/apps}/plugins_admin_controller.rb +7 -3
  231. data/app/controllers/camaleon_cms/apps/plugins_front_controller.rb +38 -0
  232. data/app/controllers/{apps → camaleon_cms/apps}/themes_admin_controller.rb +1 -1
  233. data/app/controllers/{apps → camaleon_cms/apps}/themes_front_controller.rb +1 -1
  234. data/app/controllers/camaleon_cms/camaleon_controller.rb +99 -0
  235. data/app/controllers/{frontend_controller.rb → camaleon_cms/frontend_controller.rb} +56 -45
  236. data/app/controllers/concerns/{frontend_concern.rb → camaleon_cms/frontend_concern.rb} +8 -8
  237. data/app/decorators/{application_decorator.rb → camaleon_cms/application_decorator.rb} +5 -17
  238. data/app/decorators/{category_decorator.rb → camaleon_cms/category_decorator.rb} +8 -3
  239. data/app/decorators/{custom_field_decorator.rb → camaleon_cms/custom_field_decorator.rb} +1 -1
  240. data/app/decorators/{custom_fields_concern.rb → camaleon_cms/custom_fields_concern.rb} +4 -3
  241. data/app/decorators/{metas_decorator_methods.rb → camaleon_cms/metas_decorator_methods.rb} +1 -1
  242. data/app/decorators/{nav_menu_item_decorator.rb → camaleon_cms/nav_menu_item_decorator.rb} +2 -2
  243. data/app/decorators/{post_comment_decorator.rb → camaleon_cms/post_comment_decorator.rb} +3 -2
  244. data/app/decorators/{post_decorator.rb → camaleon_cms/post_decorator.rb} +61 -14
  245. data/app/decorators/{post_tag_decorator.rb → camaleon_cms/post_tag_decorator.rb} +8 -3
  246. data/app/decorators/{post_type_decorator.rb → camaleon_cms/post_type_decorator.rb} +29 -6
  247. data/app/decorators/{site_decorator.rb → camaleon_cms/site_decorator.rb} +24 -22
  248. data/app/decorators/{term_taxonomy_decorator.rb → camaleon_cms/term_taxonomy_decorator.rb} +15 -15
  249. data/app/decorators/{theme_decorator.rb → camaleon_cms/theme_decorator.rb} +1 -1
  250. data/app/decorators/{user_decorator.rb → camaleon_cms/user_decorator.rb} +23 -11
  251. data/app/decorators/{widget_decorator.rb → camaleon_cms/widget_decorator.rb} +2 -2
  252. data/app/helpers/{admin → camaleon_cms/admin}/application_helper.rb +17 -9
  253. data/app/helpers/{admin → camaleon_cms/admin}/breadcrumb_helper.rb +6 -20
  254. data/app/helpers/{admin → camaleon_cms/admin}/category_helper.rb +6 -3
  255. data/app/helpers/{admin → camaleon_cms/admin}/custom_fields_helper.rb +21 -20
  256. data/app/helpers/{admin → camaleon_cms/admin}/menus_helper.rb +26 -36
  257. data/app/helpers/{admin → camaleon_cms/admin}/post_type_helper.rb +4 -4
  258. data/app/helpers/{camaleon_helper.rb → camaleon_cms/camaleon_helper.rb} +23 -19
  259. data/app/helpers/{captcha_helper.rb → camaleon_cms/captcha_helper.rb} +21 -17
  260. data/app/helpers/camaleon_cms/comment_helper.rb +48 -0
  261. data/app/helpers/{content_helper.rb → camaleon_cms/content_helper.rb} +12 -10
  262. data/app/helpers/{frontend → camaleon_cms/frontend}/application_helper.rb +7 -7
  263. data/app/helpers/{frontend → camaleon_cms/frontend}/nav_menu_helper.rb +21 -34
  264. data/app/helpers/{frontend → camaleon_cms/frontend}/seo_helper.rb +5 -5
  265. data/app/helpers/{frontend → camaleon_cms/frontend}/site_helper.rb +17 -10
  266. data/app/helpers/{hooks_helper.rb → camaleon_cms/hooks_helper.rb} +1 -1
  267. data/app/helpers/camaleon_cms/html_helper.rb +106 -0
  268. data/app/helpers/{plugins_helper.rb → camaleon_cms/plugins_helper.rb} +49 -64
  269. data/app/helpers/{session_helper.rb → camaleon_cms/session_helper.rb} +29 -26
  270. data/app/helpers/{short_code_helper.rb → camaleon_cms/short_code_helper.rb} +50 -16
  271. data/app/helpers/{site_helper.rb → camaleon_cms/site_helper.rb} +14 -19
  272. data/app/helpers/{theme_helper.rb → camaleon_cms/theme_helper.rb} +37 -43
  273. data/app/helpers/camaleon_cms/uploader_helper.rb +366 -0
  274. data/app/helpers/{user_roles_helper.rb → camaleon_cms/user_roles_helper.rb} +3 -3
  275. data/app/mailers/{html_mailer.rb → camaleon_cms/html_mailer.rb} +7 -7
  276. data/app/models/{ability.rb → camaleon_cms/ability.rb} +3 -3
  277. data/app/models/{category.rb → camaleon_cms/category.rb} +15 -12
  278. data/app/models/{custom_field.rb → camaleon_cms/custom_field.rb} +8 -10
  279. data/app/models/{custom_field_group.rb → camaleon_cms/custom_field_group.rb} +12 -11
  280. data/app/models/{custom_fields_relationship.rb → camaleon_cms/custom_fields_relationship.rb} +4 -4
  281. data/app/models/{meta.rb → camaleon_cms/meta.rb} +2 -5
  282. data/app/models/{nav_menu.rb → camaleon_cms/nav_menu.rb} +14 -13
  283. data/app/models/{nav_menu_item.rb → camaleon_cms/nav_menu_item.rb} +18 -7
  284. data/app/models/{plugin.rb → camaleon_cms/plugin.rb} +3 -3
  285. data/app/models/{post.rb → camaleon_cms/post.rb} +57 -32
  286. data/app/models/{post_comment.rb → camaleon_cms/post_comment.rb} +10 -9
  287. data/app/models/{post_default.rb → camaleon_cms/post_default.rb} +24 -19
  288. data/app/models/{post_relationship.rb → camaleon_cms/post_relationship.rb} +5 -5
  289. data/app/models/{post_tag.rb → camaleon_cms/post_tag.rb} +4 -4
  290. data/app/models/{post_type.rb → camaleon_cms/post_type.rb} +49 -17
  291. data/app/models/{site.rb → camaleon_cms/site.rb} +38 -80
  292. data/app/models/{term_relationship.rb → camaleon_cms/term_relationship.rb} +6 -4
  293. data/app/models/camaleon_cms/term_taxonomy.rb +81 -0
  294. data/app/models/{theme.rb → camaleon_cms/theme.rb} +3 -3
  295. data/app/models/{user.rb → camaleon_cms/user.rb} +23 -37
  296. data/app/models/{user_relationship.rb → camaleon_cms/user_relationship.rb} +4 -4
  297. data/app/models/camaleon_cms/user_role.rb +140 -0
  298. data/app/models/{widget.rb → camaleon_cms/widget.rb} +1 -1
  299. data/app/models/{widget → camaleon_cms/widget}/assigned.rb +4 -4
  300. data/app/models/{widget → camaleon_cms/widget}/main.rb +5 -5
  301. data/app/models/{widget → camaleon_cms/widget}/sidebar.rb +3 -3
  302. data/app/models/concerns/{categories_tags_for_posts.rb → camaleon_cms/categories_tags_for_posts.rb} +3 -3
  303. data/app/models/concerns/{custom_fields_read.rb → camaleon_cms/custom_fields_read.rb} +10 -11
  304. data/app/models/concerns/camaleon_cms/metas.rb +135 -0
  305. data/app/views/camaleon_cms/404.html.erb +4 -0
  306. data/app/views/camaleon_cms/500.html.erb +4 -0
  307. data/app/views/{_flash_messages.html.erb → camaleon_cms/_flash_messages.html.erb} +0 -0
  308. data/app/views/camaleon_cms/admin/appearances/nav_menus/_custom_fields.html.erb +6 -0
  309. data/app/views/{admin → camaleon_cms/admin}/appearances/nav_menus/_custom_menus.html.erb +2 -2
  310. data/app/views/{admin → camaleon_cms/admin}/appearances/nav_menus/_external_menu.html.erb +3 -3
  311. data/app/views/camaleon_cms/admin/appearances/nav_menus/_menu_form.html.erb +36 -0
  312. data/app/views/{admin → camaleon_cms/admin}/appearances/nav_menus/_menu_list.html.erb +5 -5
  313. data/app/views/{admin → camaleon_cms/admin}/appearances/nav_menus/index.html.erb +8 -8
  314. data/app/views/{admin → camaleon_cms/admin}/appearances/themes/index.html.erb +7 -6
  315. data/app/views/{admin → camaleon_cms/admin}/appearances/themes/preview.html.erb +0 -0
  316. data/app/views/{admin → camaleon_cms/admin}/appearances/themes/theme_load_data.html.erb +1 -1
  317. data/app/views/{admin → camaleon_cms/admin}/appearances/widgets/assign/_form.html.erb +5 -5
  318. data/app/views/{admin → camaleon_cms/admin}/appearances/widgets/main/_sidebar.html.erb +4 -4
  319. data/app/views/camaleon_cms/admin/appearances/widgets/main/form.html.erb +27 -0
  320. data/app/views/camaleon_cms/admin/appearances/widgets/main/index.html.erb +41 -0
  321. data/app/views/{admin → camaleon_cms/admin}/appearances/widgets/sidebar/form.html.erb +5 -5
  322. data/app/views/camaleon_cms/admin/categories/_form.html.erb +42 -0
  323. data/app/views/{admin/settings/post_types → camaleon_cms/admin/categories}/edit.html.erb +1 -1
  324. data/app/views/{admin → camaleon_cms/admin}/categories/index.html.erb +16 -26
  325. data/app/views/camaleon_cms/admin/comments/form.html.erb +12 -0
  326. data/app/views/camaleon_cms/admin/comments/form_answer.html.erb +12 -0
  327. data/app/views/camaleon_cms/admin/comments/index.html.erb +21 -0
  328. data/app/views/camaleon_cms/admin/comments/list.html.erb +36 -0
  329. data/app/views/{admin/dashboard/index.html.erb → camaleon_cms/admin/dashboard.html.erb} +2 -2
  330. data/app/views/{admin → camaleon_cms/admin}/installers/form.html.erb +6 -6
  331. data/app/views/camaleon_cms/admin/installers/welcome.html.erb +8 -0
  332. data/app/views/camaleon_cms/admin/media/_files_list.html.erb +7 -0
  333. data/app/views/camaleon_cms/admin/media/_render_file_item.html.erb +27 -0
  334. data/app/views/camaleon_cms/admin/media/_render_folder_item.html.erb +13 -0
  335. data/app/views/camaleon_cms/admin/media/index.html.erb +25 -0
  336. data/app/views/{admin → camaleon_cms/admin}/plugins/_plugins_list.html.erb +10 -10
  337. data/app/views/{admin → camaleon_cms/admin}/plugins/index.html.erb +10 -6
  338. data/app/views/{admin → camaleon_cms/admin}/post_tags/_form.html.erb +8 -14
  339. data/app/views/{admin → camaleon_cms/admin}/post_tags/edit.html.erb +2 -2
  340. data/app/views/camaleon_cms/admin/post_tags/index.html.erb +58 -0
  341. data/app/views/camaleon_cms/admin/posts/_filter_posts.html.erb +5 -0
  342. data/app/views/{admin → camaleon_cms/admin}/posts/_sidebar.html.erb +34 -36
  343. data/app/views/camaleon_cms/admin/posts/form.html.erb +97 -0
  344. data/app/views/{admin → camaleon_cms/admin}/posts/index.html.erb +34 -31
  345. data/app/views/{admin → camaleon_cms/admin}/posts/show.html.erb +1 -1
  346. data/app/views/camaleon_cms/admin/search.html.erb +68 -0
  347. data/app/views/camaleon_cms/admin/sessions/forgot.html.erb +44 -0
  348. data/app/views/camaleon_cms/admin/sessions/login.html.erb +49 -0
  349. data/app/views/camaleon_cms/admin/sessions/register.html.erb +63 -0
  350. data/app/views/camaleon_cms/admin/settings/_configuration_settings.html.erb +35 -0
  351. data/app/views/camaleon_cms/admin/settings/_email_settings.html.erb +33 -0
  352. data/app/views/camaleon_cms/admin/settings/_file_system_settings.html.erb +23 -0
  353. data/app/views/camaleon_cms/admin/settings/_seo_settings.html.erb +22 -0
  354. data/app/views/{admin/settings/custom_fields/get_items.html.erb → camaleon_cms/admin/settings/custom_fields/_get_items.html.erb} +19 -39
  355. data/app/views/{admin → camaleon_cms/admin}/settings/custom_fields/_meta_data.html.erb +2 -2
  356. data/app/views/{admin → camaleon_cms/admin}/settings/custom_fields/_render.html.erb +25 -31
  357. data/app/views/{admin/settings/custom_fields/fields/audio.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_audio.html.erb} +1 -1
  358. data/app/views/{admin/settings/custom_fields/fields/checkbox.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_checkbox.html.erb} +0 -0
  359. data/app/views/{admin/settings/custom_fields/fields/checkboxes.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_checkboxes.html.erb} +0 -0
  360. data/app/views/{admin/settings/custom_fields/fields/colorpicker.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_colorpicker.html.erb} +0 -0
  361. data/app/views/{admin/settings/custom_fields/fields/date.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_date.html.erb} +0 -0
  362. data/app/views/{admin/settings/custom_fields/fields/editor.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_editor.html.erb} +0 -1
  363. data/app/views/{admin/settings/custom_fields/fields/email.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_email.html.erb} +0 -0
  364. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_field_attrs.html.erb +8 -0
  365. data/app/views/{admin/settings/custom_fields/fields/file.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_file.html.erb} +1 -1
  366. data/app/views/{admin/settings/custom_fields/fields/image.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_image.html.erb} +1 -1
  367. data/app/views/{admin/settings/custom_fields/fields/numeric.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_numeric.html.erb} +0 -0
  368. data/app/views/{admin/settings/custom_fields/fields/phone.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_phone.html.erb} +0 -0
  369. data/app/views/{admin/settings/custom_fields/fields/posts.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_posts.html.erb} +0 -0
  370. data/app/views/{admin/settings/custom_fields/fields/radio.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_radio.html.erb} +0 -0
  371. data/app/views/{admin/settings/custom_fields/fields/select.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_select.html.erb} +0 -0
  372. data/app/views/{admin/settings/custom_fields/fields/select_eval.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_select_eval.html.erb} +0 -0
  373. data/app/views/{admin/settings/custom_fields/fields/text_area.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_text_area.html.erb} +0 -0
  374. data/app/views/{admin/settings/custom_fields/fields/text_box.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_text_box.html.erb} +0 -0
  375. data/app/views/{admin/settings/custom_fields/fields/url.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_url.html.erb} +0 -0
  376. data/app/views/{admin/settings/custom_fields/fields/users.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_users.html.erb} +0 -0
  377. data/app/views/{admin/settings/custom_fields/fields/video.html.erb → camaleon_cms/admin/settings/custom_fields/fields/_video.html.erb} +1 -1
  378. data/app/views/camaleon_cms/admin/settings/custom_fields/form.html.erb +137 -0
  379. data/app/views/{admin → camaleon_cms/admin}/settings/custom_fields/index.html.erb +18 -14
  380. data/app/views/{admin → camaleon_cms/admin}/settings/languages.html.erb +7 -7
  381. data/app/views/camaleon_cms/admin/settings/post_types/_form.html.erb +134 -0
  382. data/app/views/{admin/categories → camaleon_cms/admin/settings/post_types}/edit.html.erb +2 -2
  383. data/app/views/camaleon_cms/admin/settings/post_types/index.html.erb +54 -0
  384. data/app/views/camaleon_cms/admin/settings/shortcodes.html.erb +37 -0
  385. data/app/views/camaleon_cms/admin/settings/site.html.erb +112 -0
  386. data/app/views/{admin → camaleon_cms/admin}/settings/sites/form.html.erb +9 -9
  387. data/app/views/camaleon_cms/admin/settings/sites/index.html.erb +58 -0
  388. data/app/views/camaleon_cms/admin/user_roles/form.html.erb +160 -0
  389. data/app/views/camaleon_cms/admin/user_roles/index.html.erb +51 -0
  390. data/app/views/camaleon_cms/admin/users/form.html.erb +233 -0
  391. data/app/views/camaleon_cms/admin/users/index.html.erb +55 -0
  392. data/app/views/camaleon_cms/admin/users/profile.html.erb +1 -0
  393. data/app/views/{admin → camaleon_cms/admin}/users/profile/_activity.html.erb +0 -0
  394. data/app/views/{admin → camaleon_cms/admin}/users/profile/_settings.html.erb +0 -0
  395. data/app/views/camaleon_cms/default_theme/admin/settings.html.erb +1 -0
  396. data/app/views/{default_theme → camaleon_cms/default_theme}/category.html.erb +0 -0
  397. data/app/views/{default_theme → camaleon_cms/default_theme}/category.rss.builder +0 -0
  398. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/audio.html.erb +0 -0
  399. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/checkbox.html.erb +0 -0
  400. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/checkboxes.html.erb +0 -0
  401. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/colorpicker.html.erb +0 -0
  402. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/date.html.erb +0 -0
  403. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/editor.html.erb +0 -0
  404. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/email.html.erb +0 -0
  405. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/field_attrs.html.erb +0 -0
  406. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/file.html.erb +0 -0
  407. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/image.html.erb +0 -0
  408. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/numeric.html.erb +0 -0
  409. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/phone.html.erb +0 -0
  410. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/posts.html.erb +0 -0
  411. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/radio.html.erb +0 -0
  412. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/select.html.erb +0 -0
  413. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/select_eval.html.erb +0 -0
  414. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/text_area.html.erb +0 -0
  415. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/text_box.html.erb +0 -0
  416. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/url.html.erb +0 -0
  417. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/users.html.erb +0 -0
  418. data/app/views/{default_theme → camaleon_cms/default_theme}/custom_fields/video.html.erb +0 -0
  419. data/app/views/{default_theme → camaleon_cms/default_theme}/index.html.erb +0 -0
  420. data/app/views/{default_theme → camaleon_cms/default_theme}/layouts/_footer.html.erb +0 -1
  421. data/app/views/{default_theme → camaleon_cms/default_theme}/layouts/_header.html.erb +7 -7
  422. data/app/views/{default_theme → camaleon_cms/default_theme}/layouts/index.html.erb +0 -0
  423. data/app/views/{default_theme → camaleon_cms/default_theme}/partials/_breadcrumb.html.erb +0 -0
  424. data/app/views/{default_theme → camaleon_cms/default_theme}/partials/_categories_list.html.erb +0 -0
  425. data/app/views/camaleon_cms/default_theme/partials/_comments.html.erb +33 -0
  426. data/app/views/{default_theme → camaleon_cms/default_theme}/partials/_comments_list.html.erb +0 -0
  427. data/app/views/{default_theme → camaleon_cms/default_theme}/partials/_flash_messages.html.erb +0 -0
  428. data/app/views/{default_theme → camaleon_cms/default_theme}/partials/_forms.html.erb +2 -2
  429. data/app/views/{default_theme → camaleon_cms/default_theme}/partials/_post_list_item.html.erb +0 -0
  430. data/app/views/{default_theme → camaleon_cms/default_theme}/partials/_render_custom_field.html.erb +0 -0
  431. data/app/views/{default_theme → camaleon_cms/default_theme}/partials/_search_form.html.erb +2 -4
  432. data/app/views/{default_theme → camaleon_cms/default_theme}/partials/_sidebar.html.erb +0 -0
  433. data/app/views/{default_theme → camaleon_cms/default_theme}/post_tag.html.erb +0 -0
  434. data/app/views/{default_theme → camaleon_cms/default_theme}/post_tag.rss.builder +0 -0
  435. data/app/views/{default_theme → camaleon_cms/default_theme}/post_type.html.erb +0 -0
  436. data/app/views/{default_theme → camaleon_cms/default_theme}/post_type.rss.builder +0 -0
  437. data/app/views/{default_theme → camaleon_cms/default_theme}/profile.html.erb +0 -0
  438. data/app/views/camaleon_cms/default_theme/robots.text.erb +1 -0
  439. data/app/views/{default_theme → camaleon_cms/default_theme}/rss.rss.builder +0 -0
  440. data/app/views/{default_theme → camaleon_cms/default_theme}/search.html.erb +0 -0
  441. data/app/views/{default_theme → camaleon_cms/default_theme}/single.html.erb +0 -0
  442. data/app/views/{default_theme → camaleon_cms/default_theme}/single.rss.builder +0 -0
  443. data/app/views/{default_theme → camaleon_cms/default_theme}/sitemap.html.erb +0 -0
  444. data/app/views/{default_theme → camaleon_cms/default_theme}/sitemap.xml.builder +0 -0
  445. data/app/views/{html_mailer → camaleon_cms/html_mailer}/mailer.html.erb +0 -0
  446. data/app/views/{shortcode_templates → camaleon_cms/shortcode_templates}/widget.html.erb +1 -1
  447. data/app/views/layouts/camaleon_cms/admin.html.erb +49 -0
  448. data/app/views/layouts/camaleon_cms/admin/_ajax.html.erb +6 -0
  449. data/app/views/layouts/{admin → camaleon_cms/admin}/_flash_messages.html.erb +9 -0
  450. data/app/views/layouts/{admin → camaleon_cms/admin}/_footer.html.erb +0 -0
  451. data/app/views/layouts/{admin → camaleon_cms/admin}/_form_error.html.erb +1 -1
  452. data/app/views/layouts/{admin → camaleon_cms/admin}/_header.html.erb +11 -11
  453. data/app/views/layouts/camaleon_cms/admin/_sidebar.html.erb +19 -0
  454. data/app/views/layouts/{admin → camaleon_cms/admin}/installer.html.erb +5 -5
  455. data/app/views/layouts/{application.html.erb → camaleon_cms/application.html.erb} +0 -0
  456. data/app/views/layouts/{login.html.erb → camaleon_cms/login.html.erb} +5 -4
  457. data/app/views/layouts/{mailer.html.erb → camaleon_cms/mailer.html.erb} +0 -0
  458. data/config/initializers/action_view.rb +31 -0
  459. data/config/initializers/active_record_extension.rb +52 -2
  460. data/config/initializers/assets.rb +0 -18
  461. data/config/initializers/custom_initializers.rb +7 -0
  462. data/config/locales/camaleon_cms/admin/en.yml +648 -0
  463. data/config/locales/camaleon_cms/admin/es.yml +597 -0
  464. data/config/locales/camaleon_cms/admin/it.yml +607 -0
  465. data/config/locales/camaleon_cms/admin/js.yml +127 -0
  466. data/config/locales/camaleon_cms/admin/pt_br.yml +610 -0
  467. data/config/locales/camaleon_cms/common.yml +193 -0
  468. data/config/locales/{languages.yml → camaleon_cms/languages.yml} +0 -0
  469. data/config/locales/{routes.yml → camaleon_cms/routes.yml} +8 -0
  470. data/config/locales/{pt.yml → pt-BR.yml} +1 -1
  471. data/config/routes.rb +8 -24
  472. data/config/routes/admin.rb +114 -98
  473. data/config/routes/frontend.rb +39 -27
  474. data/config/system.json +5 -3
  475. data/db/migrate/20150611161134_post_table_into_utf8.rb +15 -15
  476. data/db/migrate/20150926095310_rename_column_posts.rb +4 -4
  477. data/lib/camaleon_cms/engine.rb +6 -9
  478. data/lib/camaleon_cms/version.rb +1 -1
  479. data/lib/ext/string.rb +10 -45
  480. data/lib/ext/translator.rb +3 -2
  481. data/lib/generators/camaleon_cms/gem_plugin_generator.rb +90 -83
  482. data/lib/generators/camaleon_cms/gem_plugin_template/app/controllers/plugins/my_plugin/admin_controller.rb +1 -1
  483. data/lib/generators/camaleon_cms/gem_plugin_template/app/controllers/plugins/my_plugin/front_controller.rb +1 -1
  484. data/lib/generators/camaleon_cms/gem_plugin_template/app/views/plugins/my_plugin/admin/index.html.erb +9 -2
  485. data/lib/generators/camaleon_cms/gem_theme_generator.rb +97 -0
  486. data/lib/generators/{ctheme_template/app/apps/themes/my_theme/assets/images → camaleon_cms/gem_theme_template/app/assets/images/themes/my_plugin}/image.png +0 -0
  487. data/lib/generators/{ctheme_template/app/apps/themes/my_theme/assets/js → camaleon_cms/gem_theme_template/app/assets/javascripts/themes/my_plugin}/main.js +1 -1
  488. data/lib/generators/{ctheme_template/app/apps/themes/my_theme/assets/css → camaleon_cms/gem_theme_template/app/assets/stylesheets/themes/my_plugin}/main.css +1 -1
  489. data/lib/generators/camaleon_cms/gem_theme_template/app/helpers/themes/my_plugin/main_helper.rb +26 -0
  490. data/lib/generators/{ctheme_template/app/apps/themes/my_theme/views → camaleon_cms/gem_theme_template/app/views/themes/my_plugin}/admin/settings.html.erb +1 -1
  491. data/lib/generators/{ctheme_template/app/apps/themes/my_theme/views → camaleon_cms/gem_theme_template/app/views/themes/my_plugin}/index.html.erb +0 -0
  492. data/lib/generators/camaleon_cms/gem_theme_template/app/views/themes/my_plugin/layouts/index.html.erb +71 -0
  493. data/lib/generators/{ctheme_template/app/apps/themes/my_theme/views → camaleon_cms/gem_theme_template/app/views/themes/my_plugin}/partials/readme.txt +0 -0
  494. data/lib/generators/camaleon_cms/gem_theme_template/config/camaleon_theme.json +14 -0
  495. data/lib/generators/camaleon_cms/install_template/system.json +4 -2
  496. data/lib/generators/camaleon_cms/theme_generator.rb +71 -0
  497. data/lib/generators/camaleon_cms/theme_template/app/apps/themes/my_theme/assets/css/main.css +12 -0
  498. data/lib/generators/camaleon_cms/theme_template/app/apps/themes/my_theme/assets/images/image.png +0 -0
  499. data/lib/generators/camaleon_cms/theme_template/app/apps/themes/my_theme/assets/js/main.js +14 -0
  500. data/lib/generators/{ctheme_template → camaleon_cms/theme_template}/app/apps/themes/my_theme/config/config.json +0 -0
  501. data/lib/generators/{ctheme_template → camaleon_cms/theme_template}/app/apps/themes/my_theme/main_helper.rb +0 -0
  502. data/lib/generators/camaleon_cms/theme_template/app/apps/themes/my_theme/views/admin/settings.html.erb +4 -0
  503. data/lib/generators/camaleon_cms/theme_template/app/apps/themes/my_theme/views/index.html.erb +25 -0
  504. data/lib/generators/{ctheme_template → camaleon_cms/theme_template}/app/apps/themes/my_theme/views/layouts/index.html.erb +8 -8
  505. data/lib/generators/camaleon_cms/theme_template/app/apps/themes/my_theme/views/partials/readme.txt +1 -0
  506. data/lib/plugin_routes.rb +59 -28
  507. data/lib/tasks/camaleon_cms/rspec_test.rake +16 -0
  508. metadata +458 -548
  509. data/app/apps/plugins/contact_form/views/admin_forms/manual.html.erb +0 -59
  510. data/app/apps/themes/new/assets/js/plugins/modal_elfinder.js +0 -29
  511. data/app/assets/javascripts/admin/admin-basic-manifest.js +0 -3
  512. data/app/assets/javascripts/admin/custom_fields.js +0 -167
  513. data/app/assets/javascripts/admin/elfinder-manifest.js +0 -7
  514. data/app/assets/javascripts/admin/elfinder/elfinder.full.js +0 -12646
  515. data/app/assets/javascripts/admin/elfinder/i18n/elfinder.es.js +0 -294
  516. data/app/assets/javascripts/admin/elfinder/i18n/elfinder.fr.js +0 -298
  517. data/app/assets/javascripts/admin/elfinder/i18n/elfinder.it.js +0 -366
  518. data/app/assets/javascripts/admin/elfinder/proxy/elFinderSupportVer1.js +0 -338
  519. data/app/assets/javascripts/admin/elfinder/upload_elfinder.js +0 -237
  520. data/app/assets/javascripts/admin/jquery.slugify.js +0 -65
  521. data/app/assets/javascripts/admin/libraries.js +0 -266
  522. data/app/assets/javascripts/admin/post.js +0 -273
  523. data/app/assets/javascripts/admin/widgets.js +0 -54
  524. data/app/assets/javascripts/elfinder_front.js +0 -85
  525. data/app/assets/stylesheets/admin/custom_admin.css.scss +0 -193
  526. data/app/assets/stylesheets/admin/elfinder-manifest.css +0 -6
  527. data/app/assets/stylesheets/admin/elfinder/elfinder-theme.scss +0 -191
  528. data/app/assets/stylesheets/admin/elfinder/elfinder.css +0 -1922
  529. data/app/assets/stylesheets/admin/elfinder/images/arrows-active.png +0 -0
  530. data/app/assets/stylesheets/admin/elfinder/images/arrows-normal.png +0 -0
  531. data/app/assets/stylesheets/admin/elfinder/images/crop.gif +0 -0
  532. data/app/assets/stylesheets/admin/elfinder/images/dialogs.png +0 -0
  533. data/app/assets/stylesheets/admin/elfinder/images/icons-big.png +0 -0
  534. data/app/assets/stylesheets/admin/elfinder/images/icons-small.png +0 -0
  535. data/app/assets/stylesheets/admin/elfinder/images/logo.png +0 -0
  536. data/app/assets/stylesheets/admin/elfinder/images/progress.gif +0 -0
  537. data/app/assets/stylesheets/admin/elfinder/images/quicklook-bg.png +0 -0
  538. data/app/assets/stylesheets/admin/elfinder/images/quicklook-icons.png +0 -0
  539. data/app/assets/stylesheets/admin/elfinder/images/resize.png +0 -0
  540. data/app/assets/stylesheets/admin/elfinder/images/spinner-mini.gif +0 -0
  541. data/app/assets/stylesheets/admin/elfinder/images/toolbar.png +0 -0
  542. data/app/assets/stylesheets/admin/elfinder/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  543. data/app/assets/stylesheets/admin/elfinder/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  544. data/app/assets/stylesheets/admin/elfinder/images/ui-icons_222222_256x240.png +0 -0
  545. data/app/assets/stylesheets/bootstrap.min.css.scss +0 -5
  546. data/app/controllers/admin/appearances_controller.rb +0 -13
  547. data/app/controllers/admin/comments_controller.rb +0 -113
  548. data/app/controllers/admin/media_controller.rb +0 -53
  549. data/app/controllers/api/api_controller.rb +0 -31
  550. data/app/controllers/api/v1/category_controller.rb +0 -15
  551. data/app/controllers/api/v1/contact_form_controller.rb +0 -55
  552. data/app/controllers/api/v1/page_controller.rb +0 -8
  553. data/app/controllers/api/v1/post_controller.rb +0 -8
  554. data/app/controllers/apps/plugins_front_controller.rb +0 -20
  555. data/app/controllers/camaleon_controller.rb +0 -116
  556. data/app/helpers/html_helper.rb +0 -118
  557. data/app/helpers/uploader_helper.rb +0 -214
  558. data/app/models/concerns/metas.rb +0 -136
  559. data/app/models/grid_template.rb +0 -15
  560. data/app/models/term_taxonomy.rb +0 -157
  561. data/app/models/user_role.rb +0 -139
  562. data/app/serializers/api/base_serializer.rb +0 -9
  563. data/app/serializers/api/v1/category_serializer.rb +0 -8
  564. data/app/views/admin/appearances/nav_menus/_custom_fields.html.erb +0 -6
  565. data/app/views/admin/appearances/nav_menus/_menu_form.html.erb +0 -32
  566. data/app/views/admin/appearances/widgets/main/form.html.erb +0 -27
  567. data/app/views/admin/appearances/widgets/main/index.html.erb +0 -69
  568. data/app/views/admin/categories/_form.html.erb +0 -42
  569. data/app/views/admin/comments/form.html.erb +0 -52
  570. data/app/views/admin/comments/index.html.erb +0 -41
  571. data/app/views/admin/comments/reply.html.erb +0 -196
  572. data/app/views/admin/installers/welcome.html.erb +0 -8
  573. data/app/views/admin/media/iframe.html.erb +0 -33
  574. data/app/views/admin/media/index.html.erb +0 -19
  575. data/app/views/admin/post_tags/index.html.erb +0 -74
  576. data/app/views/admin/posts/_filter_posts.html.erb +0 -6
  577. data/app/views/admin/posts/form.html.erb +0 -103
  578. data/app/views/admin/sessions/forgot.html.erb +0 -45
  579. data/app/views/admin/sessions/login.html.erb +0 -49
  580. data/app/views/admin/sessions/register.html.erb +0 -62
  581. data/app/views/admin/settings/custom_fields/fields/field_attrs.html.erb +0 -8
  582. data/app/views/admin/settings/custom_fields/form.html.erb +0 -248
  583. data/app/views/admin/settings/post_types/_form.html.erb +0 -93
  584. data/app/views/admin/settings/post_types/index.html.erb +0 -72
  585. data/app/views/admin/settings/site.html.erb +0 -188
  586. data/app/views/admin/settings/sites/index.html.erb +0 -55
  587. data/app/views/admin/taxonomy/_form.html.erb +0 -62
  588. data/app/views/admin/taxonomy/edit.html.erb +0 -18
  589. data/app/views/admin/taxonomy/index.html.erb +0 -79
  590. data/app/views/admin/user_roles/form.html.erb +0 -167
  591. data/app/views/admin/user_roles/index.html.erb +0 -48
  592. data/app/views/admin/users/form.html.erb +0 -306
  593. data/app/views/admin/users/index.html.erb +0 -53
  594. data/app/views/admin/users/profile.html.erb +0 -118
  595. data/app/views/admin/users/profile_edit.html.erb +0 -312
  596. data/app/views/default_theme/admin/settings.html.erb +0 -1
  597. data/app/views/default_theme/partials/_comments.html.erb +0 -33
  598. data/app/views/default_theme/robots.text.erb +0 -1
  599. data/app/views/layouts/admin.html.erb +0 -56
  600. data/app/views/layouts/admin/_ajax.html.erb +0 -2
  601. data/app/views/layouts/admin/_sidebar.html.erb +0 -22
  602. data/app/views/shortcode_templates/form.html.erb +0 -1
  603. data/config/initializers/cache_helper.rb +0 -17
  604. data/config/initializers/doorkeeper.rb +0 -128
  605. data/config/initializers/elfinder.rb +0 -63
  606. data/config/initializers/page_caching.rb +0 -42
  607. data/config/initializers/rufus_cron.rb +0 -33
  608. data/config/initializers/swagger.rb +0 -18
  609. data/config/locales/admin/en.yml +0 -618
  610. data/config/locales/admin/es.yml +0 -584
  611. data/config/locales/admin/it.yml +0 -605
  612. data/config/locales/admin/js.yml +0 -118
  613. data/config/locales/common.yml +0 -189
  614. data/config/locales/doorkeeper.en.yml +0 -123
  615. data/db/migrate/20150930115030_doorkeeper_configuration.rb +0 -45
  616. data/lib/generators/camaleon_cms/install_template/apps/plugins/readme.txt +0 -1
  617. data/lib/generators/camaleon_cms/install_template/apps/themes/readme.txt +0 -1
  618. data/lib/generators/cplugin_generator.rb +0 -82
  619. data/lib/generators/cplugin_template/app/apps/plugins/my_plugin/admin_controller.rb +0 -8
  620. data/lib/generators/cplugin_template/app/apps/plugins/my_plugin/assets/css/readme.txt +0 -1
  621. data/lib/generators/cplugin_template/app/apps/plugins/my_plugin/assets/images/readme.txt +0 -1
  622. data/lib/generators/cplugin_template/app/apps/plugins/my_plugin/assets/js/readme.txt +0 -1
  623. data/lib/generators/cplugin_template/app/apps/plugins/my_plugin/config/config.json +0 -21
  624. data/lib/generators/cplugin_template/app/apps/plugins/my_plugin/config/locales/readme.txt +0 -1
  625. data/lib/generators/cplugin_template/app/apps/plugins/my_plugin/config/routes_admin.txt +0 -1
  626. data/lib/generators/cplugin_template/app/apps/plugins/my_plugin/config/routes_front.txt +0 -1
  627. data/lib/generators/cplugin_template/app/apps/plugins/my_plugin/front_controller.rb +0 -8
  628. data/lib/generators/cplugin_template/app/apps/plugins/my_plugin/main_helper.rb +0 -22
  629. data/lib/generators/cplugin_template/app/apps/plugins/my_plugin/models/my_plugin.rb +0 -7
  630. data/lib/generators/cplugin_template/app/apps/plugins/my_plugin/views/admin/index.html.erb +0 -2
  631. data/lib/generators/cplugin_template/app/apps/plugins/my_plugin/views/front/index.html.erb +0 -2
  632. data/lib/generators/cplugin_template/app/apps/plugins/my_plugin/views/layouts/readme.txt +0 -2
  633. data/lib/generators/ctheme_generator.rb +0 -65
  634. data/lib/tasks/camaleon_cms_tasks.rake +0 -23
  635. data/lib/tasks/precompile_overrides.rake +0 -6
@@ -6,7 +6,7 @@
6
6
  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
7
  See the GNU Affero General Public License (GPLv3) for more details.
8
8
  =end
9
- module ShortCodeHelper
9
+ module CamaleonCms::ShortCodeHelper
10
10
  # Internal method
11
11
  def shortcodes_init
12
12
  @_shortcodes = []
@@ -44,18 +44,26 @@ module ShortCodeHelper
44
44
  },
45
45
  "Permit to generate specific data of a post.
46
46
  Attributes:
47
- object: (String, defaut post) Model name: post | post_type | category | post_tag | site | user
47
+ object: (String, defaut post) Model name: post | posttype | category | posttag | site | user |theme | navmenu
48
48
  id: (Integer) Post id
49
49
  key: (String) Post slug
50
50
  field: (String) Custom field key, you can add render_field='true' to render field as html element, also you can add index=2 to indicate the value in position 2 for multitple values
51
- attr: (String) attribute name: title | created_at | excerpt | url | link | thumb | updated_at | author_name | author_url
52
- Note: If id and key is not present, then will be rendered of current model
51
+ attrs: (String) attribute name
52
+ post: title | created_at | excerpt | url | link | thumb | updated_at | author_name | author_url
53
+ posttype: title | created_at | excerpt | url | link | thumb | updated_at
54
+ category: title | created_at | excerpt | url | link | thumb | updated_at
55
+ posttag: title | created_at | excerpt | url | link | thumb | updated_at
56
+ site: title | created_at | excerpt | url | link | thumb | updated_at
57
+ user: title | created_at | excerpt | url | link | thumb | updated_at
58
+ theme: title | created_at | excerpt | url | link | thumb | updated_at
59
+ navmenu: title | created_at | excerpt | url | link | thumb | updated_at
60
+ Note: If id and key is not present, then will be rendered for current model
53
61
  Sample:
54
62
  [data id='122' attr='title'] ==> return the title of post with id = 122
55
63
  [data key='contact' attr='url'] ==> return the url of post with slug = contact
56
64
  [data key='contact' attr='link'] ==> return the link with title as text of the link of post with slug = contact
57
65
  [data object='site' attr='url'] ==> return the url of currrent site
58
- [data key='page' object='post_type' attr='url'] ==> return the url of post_type with slug = page
66
+ [data key='page' object='posttype' attr='url'] ==> return the url of post_type with slug = page
59
67
  [data field=icon index=2] ==> return the second value (multiple values) for this custom field with key=icon of current object
60
68
  [data key='contact' field='sub_title'] ==> return the value of the custom_field with key=sub_title registered for post.slug = contact
61
69
  [data object='site' field='sub_title'] ==> return the value of the custom_field with key=sub_title registered for current_site")
@@ -88,11 +96,14 @@ module ShortCodeHelper
88
96
  # run all shortcodes in the content
89
97
  # content: (string) text to find a short codes
90
98
  # args: custom arguments to pass for short codes render, sample: {owner: my_model, a: true}
91
- # if args != Hash, this will re send as args = {owner: args}
99
+ # if args != Hash, this will re send as args = {owner: args}
100
+ # args should be include the owner model who is doing the action to optimize DB queries
101
+ # sample: do_shortcode("hello [greeting 'world']!", @my_post) ==> "hello world!"
102
+ # sample: do_shortcode("hello [greeting 'world']", {attr1: 'asd', owner: @my_post})
103
+ # return rendered string
92
104
  def do_shortcode(content, args = {})
93
105
  args = {owner: args} unless args.is_a?(Hash)
94
106
  content.scan(/#{cama_reg_shortcode}/) do |item|
95
- # content.scan(/(\[(#{@_shortcodes.join("|")})\s?(.*?)\])/) do |item|
96
107
  shortcode, code, space, attrs = item
97
108
  content = content.sub(shortcode, _eval_shortcode(code, attrs, args))
98
109
  end
@@ -161,9 +172,13 @@ module ShortCodeHelper
161
172
  # execute shortcode data
162
173
  def cama_shortcode_data(attrs, args)
163
174
  res = ""
164
- object = attrs["object"] || "post"
175
+ object = attrs["object"].downcase || "post"
165
176
  attr = attrs["attr"] || "title"
166
- model = cama_shortcode_model_parser(object, attrs) || args[:owner]
177
+ if (args[:owner].present? && object == args[:owner].class.name.parseCamaClass.downcase) || !attrs["object"].present?
178
+ model = args[:owner]
179
+ else
180
+ model = cama_shortcode_model_parser(object, attrs) || args[:owner]
181
+ end
167
182
  return res unless model.present?
168
183
 
169
184
  if attrs["field"].present? # model custom fields
@@ -202,10 +217,21 @@ module ShortCodeHelper
202
217
  else
203
218
  res = model.the_thumb_url
204
219
  end
205
- when "author_name"
206
- res = object=="post" ? model.the_author.the_name : ""
207
- when "author_url"
208
- res = object=="post" ? model.the_author.the_url : ""
220
+ else
221
+ case object
222
+ when 'site'
223
+ case attr
224
+ when "title"
225
+ when "title"
226
+ end
227
+ when 'post'
228
+ case attr
229
+ when "author_name"
230
+ res = model.the_author.the_name rescue ''
231
+ when "author_url"
232
+ res = model.the_author.the_name rescue ''
233
+ end
234
+ end
209
235
  end
210
236
  end
211
237
  res
@@ -214,12 +240,12 @@ module ShortCodeHelper
214
240
  # return the model object according to the type
215
241
  def cama_shortcode_model_parser(object, attrs)
216
242
  model = nil
217
- case object
243
+ case object.downcase
218
244
  when "post"
219
245
  model = current_site.the_post(attrs["id"].to_i) if attrs["id"].present?
220
246
  model = current_site.the_post(attrs["key"].to_s) if attrs["key"].present?
221
247
 
222
- when "post_type"
248
+ when "posttype"
223
249
  model = current_site.the_post_type(attrs["id"].to_i) if attrs["id"].present?
224
250
  model = current_site.the_post_type(attrs["key"].to_s) if attrs["key"].present?
225
251
 
@@ -227,12 +253,20 @@ module ShortCodeHelper
227
253
  model = current_site.the_category(attrs["id"].to_i) if attrs["id"].present?
228
254
  model = current_site.the_category(attrs["key"].to_s) if attrs["key"].present?
229
255
 
230
- when "post_tag"
256
+ when "posttag"
231
257
  model = current_site.the_tag(attrs["id"].to_i) if attrs["id"].present?
232
258
  model = current_site.the_tag(attrs["key"].to_s) if attrs["key"].present?
233
259
 
234
260
  when "site"
235
261
  model = current_site
262
+
263
+ when "theme"
264
+ model = current_theme
265
+
266
+ when "navmenu"
267
+ model = current_site.nav_menu_items.find(attrs["id"]) if attrs["id"].present?
268
+ model = current_site.nav_menu_items.find_by_slug(attrs["key"]) if attrs["key"].present?
269
+
236
270
  when "user"
237
271
  model = current_site.the_user(attrs["id"].to_i) if attrs["id"].present?
238
272
  model = current_site.the_user(attrs["key"].to_s) if attrs["key"].present?
@@ -6,42 +6,37 @@
6
6
  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
7
  See the GNU Affero General Public License (GPLv3) for more details.
8
8
  =end
9
- module SiteHelper
9
+ module CamaleonCms::SiteHelper
10
10
  # return current site or assign a site as a current site
11
11
  def current_site(site = nil)
12
12
  @current_site = site.decorate if site.present?
13
13
  return $current_site if defined?($current_site)
14
14
  return @current_site if defined?(@current_site)
15
- all_sites = Site.all
15
+ all_sites = CamaleonCms::Site.all
16
16
  if all_sites.size == 1
17
17
  site = all_sites.first.decorate
18
18
  else
19
19
  host = request.original_url.to_s.parse_domain
20
20
  if host == PluginRoutes.system_info["base_domain"]
21
- site = Site.first.decorate rescue nil
21
+ site = CamaleonCms::Site.first.decorate rescue nil
22
22
  else
23
23
  s = [host]
24
24
  s << request.subdomain if request.subdomain.present?
25
- site = Site.where(slug: s).first.decorate rescue nil
25
+ site = CamaleonCms::Site.where(slug: s).first.decorate rescue nil
26
26
  end
27
27
  end
28
- puts "============================ Please define the $current_site = Site.first.decorate " unless site.present?
28
+ puts "============================ Please define the $current_site = CamaleonCms::Site.first.decorate " unless site.present?
29
29
  @current_site = site
30
30
  end
31
31
 
32
- # initialize ability for current user
33
- def current_ability
34
- @current_ability ||= Ability.new(current_user, current_site)
35
- end
36
-
37
32
  # check if current site exist, if not, this will be redirected to main domain
38
- def site_check_existence()
33
+ def cama_site_check_existence()
39
34
  if !current_site.present?
40
- if (site = Site.first).present?
41
- base_domain = PluginRoutes.system_info["base_domain"]
42
- redirect_to root_url(host: base_domain.split(":").first, port: (base_domain.split(":")[1] rescue nil))
35
+ if (PluginRoutes.main_site).present?
36
+ base_domain = PluginRoutes.main_site.slug
37
+ redirect_to cama_root_url(host: base_domain.split(":").first, port: (base_domain.split(":")[1] rescue nil))
43
38
  else
44
- redirect_to admin_installers_path
39
+ redirect_to cama_admin_installers_path
45
40
  end
46
41
  end
47
42
  end
@@ -52,7 +47,7 @@ module SiteHelper
52
47
  end
53
48
 
54
49
  # get list templates files of current theme
55
- def get_list_template_files
50
+ def cama_get_list_template_files
56
51
  contained_files = []
57
52
  Dir[File.join(current_theme.settings["path"], "views", '*')].each do |path|
58
53
  f_name = File.basename(path)
@@ -63,7 +58,7 @@ module SiteHelper
63
58
 
64
59
  # get list layouts files of current theme
65
60
  # return an array of layouts for current theme
66
- def get_list_layouts_files
61
+ def cama_get_list_layouts_files
67
62
  contained_files = []
68
63
  Dir[File.join(current_theme.settings["path"], "views", "layouts", '*')].each do |path|
69
64
  f_name = File.basename(path)
@@ -86,9 +81,9 @@ module SiteHelper
86
81
  theme_key ||= site.get_theme_slug
87
82
  _s = current_site
88
83
  current_site(site)
89
- PluginRoutes.system_info[:default_plugins].each{|p| plugin_install(p) } # auto install plugins
84
+ PluginRoutes.system_info["default_plugins"].each{|p| plugin_install(p) } # auto install plugins
90
85
  site_install_theme(theme_key)
91
- current_site(_s)
86
+ current_site(_s) if _s.present?
92
87
  end
93
88
 
94
89
  # install theme for current site
@@ -6,32 +6,31 @@
6
6
  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
7
  See the GNU Affero General Public License (GPLv3) for more details.
8
8
  =end
9
- module ThemeHelper
9
+ module CamaleonCms::ThemeHelper
10
10
  def theme_init()
11
11
  @_front_breadcrumb = []
12
12
  end
13
13
 
14
- # assign the layout for this request
15
- # asset: asset file name, if asset is present return full path to this asset
16
- # layout_name: layout name
17
- def theme_layout(layout_name, theme_name = nil)
18
- path = "#{theme_name || current_theme.slug}/views/layouts/#{layout_name}"
19
- self.class.send(:layout, path)
20
- path
21
- end
22
-
23
14
  # return theme full asset path
24
15
  # theme_name: theme name, if nil, then will use current theme
25
16
  # asset: asset file name, if asset is present return full path to this asset
26
17
  # sample: <script src="<%= theme_asset_path("js/admin.js") %>"></script> => return: /assets/themes/my_theme/assets/css/main-54505620f.css
27
18
  def theme_asset_path(asset = nil, theme_name = nil)
28
- p = "themes/#{theme_name || current_theme.slug }/assets/#{asset}"
29
- begin
30
- asset_url(p)
31
- rescue NoMethodError => e
32
- p
19
+ if theme_name.present? && theme_name.include?("/")
20
+ return theme_asset_url(theme_name, current_theme.slug)
21
+ end
22
+
23
+ settings = theme_name.present? ? PluginRoutes.theme_info(theme_name) : current_theme.settings
24
+ folder_name = settings["key"]
25
+ if settings["gem_mode"]
26
+ p = "themes/#{folder_name}/#{asset}"
27
+ else
28
+ p = "themes/#{folder_name}/assets/#{asset}"
33
29
  end
30
+ p
34
31
  end
32
+ alias_method :theme_asset, :theme_asset_path
33
+ alias_method :theme_gem_asset, :theme_asset_path
35
34
 
36
35
  # return the full url for asset of current theme:
37
36
  # asset: (String) asset name
@@ -39,7 +38,7 @@ module ThemeHelper
39
38
  # sample:
40
39
  # theme_asset_url("css/main.css") => return: http://myhost.com/assets/themes/my_theme/assets/css/main-54505620f.css
41
40
  def theme_asset_url(asset, theme_name = nil)
42
- p = "themes/#{theme_name || current_theme.slug }/assets/#{asset}"
41
+ p = theme_asset_path(asset, theme_name)
43
42
  begin
44
43
  asset_url(p)
45
44
  rescue NoMethodError => e
@@ -47,42 +46,37 @@ module ThemeHelper
47
46
  end
48
47
  end
49
48
 
50
- # built asset file for current theme
51
- # theme_name: theme key, if nill will be used current_theme.slug
52
- # return (String), sample: theme_asset("css/mains.css") => themes/my_theme/assets/css/main.css
53
- def theme_asset(asset, theme_name = nil)
54
- "themes/#{theme_name || self_theme_key || current_theme.slug }/assets/#{asset}"
55
- end
56
-
57
- # built asset file for current theme
58
- # theme_name: theme key, if nill will be used current_theme.slug
59
- # return (String), sample: theme_asset("mains.css") => themes/my_theme/main.css
60
- def theme_gem_asset(asset, theme_name = nil)
61
- "themes/#{theme_name || self_theme_key || current_theme.slug }/#{asset}"
49
+ # return theme view path including the path of current theme
50
+ # view_name: name of the view or template
51
+ # sample: theme_view("index") => "themes/my_theme/index"
52
+ def theme_view(view_name, deprecated_attr = "")
53
+ view_name = deprecated_attr if deprecated_attr.present?
54
+ if current_theme.settings["gem_mode"]
55
+ "themes/#{current_theme.slug}/#{view_name}"
56
+ else
57
+ "themes/#{current_theme.slug}/views/#{view_name}"
58
+ end
62
59
  end
63
60
 
64
- # return theme full view path
65
- # theme_key: theme folder name
66
- # view_name: name of the view or template
67
- def theme_view(theme_key, view_name)
68
- begin
69
- p = "themes/" if request.env['PATH_INFO'].start_with?("/admin")
70
- rescue
71
- p = ""
61
+ # assign the layout for this request
62
+ # asset: asset file name, if asset is present return full path to this asset
63
+ # layout_name: layout name
64
+ def theme_layout(layout_name, theme_name = nil)
65
+ if current_theme.settings["gem_mode"]
66
+ "themes/#{current_theme.slug}/layouts/#{layout_name}"
67
+ else
68
+ "themes/#{current_theme.slug}/views/layouts/#{layout_name}"
72
69
  end
73
- "#{p if p.present?}#{theme_key}/views/#{view_name}"
74
70
  end
75
71
 
76
72
  # return theme key for current theme file (helper|controller|view)
77
- def self_theme_key
78
- # k = "app/apps/themes/"
73
+ # DEPRECATED, instead use: current_theme
74
+ # index: internal control
75
+ def self_theme_key(index = 0)
79
76
  k = "/themes/"
80
- f = caller[0]
81
- f2 = caller[1]
77
+ f = caller[index]
82
78
  if f.include?(k)
83
79
  f.split(k).last.split("/").first
84
- elsif f2.include?(k)
85
- f2.split(k).last.split("/").first
86
80
  end
87
81
  end
88
82
 
@@ -0,0 +1,366 @@
1
+ =begin
2
+ Camaleon CMS is a content management system
3
+ Copyright (C) 2015 by Owen Peredo Diaz
4
+ Email: owenperedo@gmail.com
5
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
+ See the GNU Affero General Public License (GPLv3) for more details.
8
+ =end
9
+ module CamaleonCms::UploaderHelper
10
+ # upload a file into server
11
+ # settings:
12
+ # folder: Directory where the file will be saved (default: "")
13
+ # sample: temporal => will save in /rails_path/public/temporal
14
+ # generate_thumb: true, # generate thumb image if this is image format (default true)
15
+ # maximum: maximum bytes permitted to upload (default: 1000MG)
16
+ # formats: extensions permitted, sample: jpg,png,... or generic: images | videos | audios | documents (default *)
17
+ # remove_source: Boolean (delete source file after saved if this is true, default false)
18
+ # same_name: Boolean (save the file with the same name if defined true, else search for a non used name)
19
+ # temporal_time: if great than 0 seconds, then this file will expire (removed) in that time (default: 0)
20
+ # To manage jobs, please check http://edgeguides.rubyonrails.org/active_job_basics.html
21
+ # Note: if you are using temporal_time, you will need to copy the file to another directory later
22
+ # sample: upload_file(params[:my_file], {formats: "images", folder: "temporal"})
23
+ # sample: upload_file(params[:my_file], {formats: "jpg,png,gif,mp3,mp4", temporal_time: 10.minutes, maximum: 10.megabytes})
24
+ def upload_file(uploaded_io, settings = {})
25
+ unless uploaded_io.present?
26
+ return {error: "File is empty", file: nil, size: nil}
27
+ end
28
+ uploaded_io = File.open(uploaded_io) if uploaded_io.is_a?(String)
29
+ cama_uploader_init_connection(true)
30
+ settings = settings.to_sym
31
+ settings = {
32
+ folder: "",
33
+ maximum: 100.megabytes,
34
+ formats: "*",
35
+ generate_thumb: true,
36
+ temporal_time: 0,
37
+ filename: (uploaded_io.original_filename rescue uploaded_io.path.split("/").last).parameterize(".").downcase.gsub(" ", "-"),
38
+ file_size: File.size(uploaded_io.to_io),
39
+ remove_source: false,
40
+ same_name: false
41
+ }.merge(settings)
42
+
43
+ res = {error: nil}
44
+
45
+ # formats validations
46
+ if settings[:formats] != "*"
47
+ case settings[:formats]
48
+ when "images"
49
+ settings[:formats] = "jpg,jpeg,png,gif,bmp"
50
+ when "videos"
51
+ settings[:formats] = "flv,webm,wmv,avi,swf,mp4"
52
+ when "audios"
53
+ settings[:formats] = "mp3,ogg"
54
+ when "documents"
55
+ settings[:formats] = "pdf,xls,xlsx,doc,docx,ppt,pptx,html,txt"
56
+ when "compresed"
57
+ settings[:formats] = "zip,7z,rar,tar,bz2,gz,rar2"
58
+ end
59
+
60
+ unless settings[:formats].downcase.split(",").include?(File.extname(file_path).sub(".", "").downcase)
61
+ res[:error] = ct("file_format_error")
62
+ return res
63
+ end
64
+ end
65
+
66
+ # file size validations
67
+ if settings[:maximum] < settings[:file_size]
68
+ res[:error] = ct("file_size_exceeded")
69
+ return res
70
+ end
71
+
72
+ # save file
73
+ if settings[:same_name]
74
+ partial_path = "#{"#{current_site.id}"}/#{"#{settings[:folder]}/" if settings[:folder].present?}#{settings[:filename]}"
75
+ else
76
+ partial_path = "#{"#{current_site.id}"}/#{cama_uploader_check_name("#{"#{settings[:folder]}/" if settings[:folder].present?}#{settings[:filename]}")}"
77
+ end
78
+ partial_path = partial_path.gsub(/(\/){2,}/, "/")
79
+ file = @fog_connection_bucket_dir.files.create({:key => partial_path, :body => uploaded_io, :public => true})
80
+
81
+ if settings[:temporal_time] > 0 # temporal file upload (always put as local for temporal files)
82
+ Thread.new do
83
+ sleep(settings[:temporal_time])
84
+ file.destroy
85
+ ActiveRecord::Base.connection.close
86
+ end
87
+ end
88
+
89
+ res = cama_uploader_parse_file(file)
90
+
91
+ # generate thumb
92
+ if settings[:generate_thumb] && res["format"] == "image" && File.extname(file.key) != ".gif"
93
+ thumb_name = cama_parse_for_thumb_name(file.key)
94
+ path_thumb = cama_resize_and_crop(uploaded_io.path, @fog_connection_hook_res[:thumb][:w], @fog_connection_hook_res[:thumb][:h], {overwrite: false, output_name: thumb_name.split("/").last})
95
+ thumb_res = upload_file(path_thumb, {generate_thumb: false, same_name: true, remove_source: true, folder: settings[:folder].split("/").push(@fog_connection_hook_res[:thumb_folder_name]).join("/")})
96
+ end
97
+ FileUtils.rm_f(uploaded_io.path) if settings[:remove_source]
98
+ res
99
+ end
100
+
101
+ # destroy file from fog
102
+ # sample: "owen/campaign-date-picker_1.png"
103
+ def cama_uploader_destroy_file(file_path, destroy_thumb = true)
104
+ cama_uploader_init_connection(true)
105
+ file = @fog_connection_bucket_dir.files.head("#{current_site.id}/#{file_path}".gsub(/(\/){2,}/, "/"))
106
+ _file = cama_uploader_parse_file(file)
107
+ if destroy_thumb && _file["format"] == "image" && File.extname(file_path) != ".gif" # destroy thumb
108
+ cama_uploader_destroy_file("#{File.dirname(file_path)}/#{cama_parse_for_thumb_name(file.key)}", false) rescue ""
109
+ end
110
+ file.destroy
111
+ end
112
+
113
+ # destroy a folder from fog
114
+ def cama_uploader_destroy_folder(folder)
115
+ cama_uploader_init_connection(true)
116
+ if @fog_connection.class.name.include?("AWS")
117
+ dir = @fog_connection.directories.get(@fog_connection_hook_res[:bucket_name], prefix: "#{current_site.id}/#{folder}".gsub(/(\/){2,}/, "/"))
118
+ dir.files.each{|f| f.destroy }
119
+ end
120
+ @fog_connection_bucket_dir.files.head("#{current_site.id}/#{folder}/".gsub(/(\/){2,}/, "/")).destroy rescue ""
121
+ end
122
+
123
+ # add a new folder in fog
124
+ def cama_uploader_add_folder(folder)
125
+ cama_uploader_init_connection(true)
126
+ @fog_connection_bucket_dir.files.create({:key => "#{current_site.id}/#{folder}/".gsub(/(\/){2,}/, "/"), content: "", :public => true})
127
+ end
128
+
129
+ # initialize fog uploader and trigger hook to customize fog storage
130
+ def cama_uploader_init_connection(clear_cache = false)
131
+ server = current_site.get_option("filesystem_type", "local")
132
+ @fog_connection_hook_res ||= {server: server, connection: nil, thumb_folder_name: "thumb", bucket_name: server == "local" ? "media" : current_site.get_option("filesystem_s3_bucket_name"), thumb: {w: 100, h: 100}}; hooks_run("on_uploader", @fog_connection_hook_res)
133
+ case server
134
+ when "local"
135
+ Dir.mkdir(Rails.root.join("public", "media").to_s) unless Dir.exist?(Rails.root.join("public", "media").to_s)
136
+ @fog_connection ||= !@fog_connection_hook_res[:connection].present? ? Fog::Storage.new({ :local_root => Rails.root.join("public").to_s, :provider => 'Local', endpoint: (root_url rescue cama_root_url) }) : @fog_connection_hook_res[:connection]
137
+ when "s3"
138
+ @fog_connection ||= !@fog_connection_hook_res[:connection].present? ? Fog::Storage.new({ :aws_access_key_id => current_site.get_option("filesystem_s3_access_key"), :provider => 'AWS', aws_secret_access_key: current_site.get_option("filesystem_s3_secret_key"), :region => current_site.get_option("filesystem_region") }) : @fog_connection_hook_res[:connection]
139
+ end
140
+ @fog_connection_bucket_dir ||= @fog_connection.directories.get(@fog_connection_hook_res[:bucket_name])
141
+ current_site.set_meta("cache_browser_files_#{@fog_connection_hook_res}", nil) if clear_cache
142
+ end
143
+
144
+ # verify if this file name already exist
145
+ # if the file is already exist, return a new name for this file
146
+ # sample: cama_uploader_check_name("my_file/file.txt")
147
+ def cama_uploader_check_name(partial_path)
148
+ cama_uploader_init_connection()
149
+ files = @fog_connection_bucket_dir.files
150
+ res = partial_path
151
+ if files.head("#{current_site.id}/#{res}".gsub(/(\/){2,}/, "/")).present?
152
+ dirname = "#{File.dirname(partial_path)}/" if partial_path.include?("/")
153
+ (1..999).each do |i|
154
+ res = "#{dirname}#{File.basename(partial_path, File.extname(partial_path))}_#{i}#{File.extname(partial_path)}"
155
+ break unless files.head("#{current_site.id}/#{res}".gsub(/(\/){2,}/, "/")).present?
156
+ end
157
+ end
158
+ res.gsub(/(\/){2,}/, "/")
159
+ end
160
+
161
+ # Generate Hash structure of files from FOG
162
+ def cama_uploader_browser_files(load_cache = true)
163
+ if load_cache
164
+ cache_res = current_site.get_meta("cache_browser_files_#{@fog_connection_hook_res}")
165
+ return cache_res.with_indifferent_access if cache_res.present?
166
+ end
167
+
168
+ @browser_files = {folders: {}, files: [], path: ""}
169
+ cama_uploader_init_connection()
170
+ @fog_connection_bucket_dir.files.all.each do |file|
171
+ cama_uploader_browser_files_parse_file(@browser_files, File.dirname(file.key), file)
172
+ end
173
+ current_site.set_meta("cache_browser_files_#{@fog_connection_hook_res}", @browser_files)
174
+ end
175
+
176
+ # add full file path into browser structure
177
+ # sample: 1/500_3.html => {folders: { 1:{ folders:{}, files: [{name: 503.html, ..}] } } }
178
+ def cama_uploader_browser_files_parse_file(folder_src, folder_dst, file)
179
+ if folder_dst.present?
180
+ return "" if folder_dst.start_with?(@fog_connection_hook_res[:thumb_folder_name]) # thumb folders ignored
181
+ f = folder_dst.split("/").first
182
+ folder_src[:folders][f] = {folders: {}, files: []} unless folder_src[:folders].keys.include?(f)
183
+ cama_uploader_browser_files_parse_file(folder_src[:folders][f], folder_dst.split("/").from(1).join("/"), file)
184
+ else
185
+ if file.key.end_with?("/")
186
+ folder_src[:folders][file.key.split("/").last] = {folders: {}, files: []}
187
+ else
188
+ r_file = cama_uploader_parse_file(file)
189
+ folder_src[:files] << r_file if r_file["url"].present? # skip non public url files (protected)
190
+ end
191
+ end
192
+ end
193
+
194
+ # search a folder by path and return all folders and files
195
+ # sample: cama_media_find_folder("test/exit")
196
+ def cama_media_find_folder(path = "")
197
+ res = nil
198
+ folder = cama_uploader_browser_files[:folders]
199
+ "#{current_site.id}/#{path}".gsub(/(\/){2,}/, "/").split("/").each do |k|
200
+ if k.present?
201
+ begin
202
+ res = folder[k]
203
+ folder = folder[k][:folders]
204
+ rescue
205
+ break
206
+ end
207
+ end
208
+ end
209
+ res || {folders: {}, files: []}
210
+ end
211
+
212
+ # parse file information of FOG file
213
+ def cama_uploader_parse_file(file)
214
+ res = {"name"=> File.basename(file.key), "size"=> file.content_length, "url"=> (file.public_url rescue "#{@fog_connection.endpoint}/#{file.key}"), "deleteUrl"=> "" }
215
+ ext = File.extname(file.key).sub(".", "").downcase
216
+ res["format"] = "unknown"
217
+ if "jpg,jpeg,png,gif,bmp".split(",").include?(ext)
218
+ if File.extname(res["name"]) == ".gif"
219
+ res["thumb"] = res["url"]
220
+ else
221
+ res["thumb"] = "#{File.dirname(res["url"])}/#{cama_parse_for_thumb_name(file.key)}" rescue ""
222
+ end
223
+ res["format"] = "image"
224
+ end
225
+ if "flv,webm,wmv,avi,swf,mp4".split(",").include?(ext)
226
+ res["format"] = "video"
227
+ end
228
+ if "mp3,ogg".split(",").include?(ext)
229
+ res["format"] = "audio"
230
+ end
231
+ if "pdf,xls,xlsx,doc,docx,ppt,pptx,html,txt".split(",").include?(ext)
232
+ res["format"] = "doc"
233
+ end
234
+ if "zip,7z,rar,tar,bz2,gz,rar2".split(",").include?(ext)
235
+ res["format"] = "compress"
236
+ end
237
+ res["type"] = (MIME::Types.type_for(file.key).first.content_type rescue "")
238
+ res
239
+ end
240
+
241
+ # helper to find an available filename for file_path in that directory
242
+ # sample: uploader_verify_name("/var/www/my_image.jpg")
243
+ # return "/var/www/my_image_1.jpg" => if "/var/www/my_image.jpg" exist
244
+ # return "/var/www/my_image.jpg" => if "/var/www/my_image.jpg" doesn't exist
245
+ def uploader_verify_name(file_path)
246
+ dir, filename = File.dirname(file_path), File.basename(file_path)
247
+ files = Dir.entries(dir)
248
+ if files.include?(filename)
249
+ i, _filename = 1, filename
250
+ while files.include?(_filename) do
251
+ _filename = "#{File.basename(filename, File.extname(filename))}_#{i}#{File.extname(filename)}"
252
+ i += 1
253
+ end
254
+ filename = _filename
255
+ end
256
+ "#{File.dirname(file_path)}/#{filename}"
257
+ end
258
+
259
+ # convert downloaded file path into public url
260
+ def cama_file_path_to_url(file_path)
261
+ file_path.sub(Rails.public_path.to_s, (root_url rescue cama_root_url))
262
+ end
263
+
264
+ # convert public url to file path
265
+ def cama_url_to_file_path(url)
266
+ File.join(Rails.public_path, URI(url.to_s).path)
267
+ end
268
+
269
+ # crop and image and saved as imagename_crop.ext
270
+ # file: file path
271
+ # w: new width
272
+ # h: new height
273
+ # w_offset: left offset
274
+ # w_offset: top offset
275
+ # resize: true/false
276
+ # (true => resize the image to this dimension)
277
+ # (false => crop the image with this dimension)
278
+ # replace: Boolean (replace current image or create another file)
279
+ def cama_crop_image(file_path, w, h, w_offset, h_offset, resize = nil , replace: true)
280
+ image = MiniMagick::Image.open(file_path)
281
+ image.combine_options do |i|
282
+ i.resize(resize) if resize.present?
283
+ i.crop "#{w.to_i}x#{h.to_i}+#{w_offset}+#{h_offset}!"
284
+ end
285
+
286
+ res = file_path
287
+ if replace
288
+ ext = File.extname(file_path)
289
+ res = file_path.gsub(ext, "_crop#{ext}")
290
+ end
291
+ image.write res
292
+ res
293
+ end
294
+
295
+ # resize and crop a file
296
+ # Params:
297
+ # file: (String) File path
298
+ # w: (Integer) width
299
+ # h: (Integer) height
300
+ # settings:
301
+ # gravity: (Sym, default :north_east) Crop position: :north_west, :north, :north_east, :east, :south_east, :south, :south_west, :west, :center
302
+ # overwrite: (Boolean, default true) true for overwrite current image with resized resolutions, false: create other file called with prefix "crop_"
303
+ # output_name: (String, default prefixd name with crop_), permit to define the output name of the thumbnail if overwrite = true
304
+ # Return: (String) file path where saved this cropped
305
+ # sample: cama_resize_and_crop(my_file, 200, 200, {gravity: :north_east, overwrite: false})
306
+ def cama_resize_and_crop(file, w, h, settings = {})
307
+ settings = {gravity: :north_east, overwrite: true, output_name: ""}.merge(settings)
308
+ img = MiniMagick::Image.open(file)
309
+ w_original, h_original = [img[:width].to_f, img[:height].to_f]
310
+
311
+ # check proportions
312
+ if w_original * h < h_original * w
313
+ op_resize = "#{w.to_i}x"
314
+ w_result = w
315
+ h_result = (h_original * w / w_original)
316
+ else
317
+ op_resize = "x#{h.to_i}"
318
+ w_result = (w_original * h / h_original)
319
+ h_result = h
320
+ end
321
+
322
+ w_offset, h_offset = cama_crop_offsets_by_gravity(settings[:gravity], [w_result, h_result], [ w, h])
323
+ img.combine_options do |i|
324
+ i.resize(op_resize)
325
+ i.gravity(settings[:gravity])
326
+ i.crop "#{w.to_i}x#{h.to_i}+#{w_offset}+#{h_offset}!"
327
+ end
328
+
329
+ img.write(file) if settings[:overwrite]
330
+ unless settings[:overwrite]
331
+ if settings[:output_name].present?
332
+ img.write(file = File.join(File.dirname(file), settings[:output_name]).to_s)
333
+ else
334
+ img.write(file = uploader_verify_name(File.join(File.dirname(file), "crop_#{File.basename(file)}")))
335
+ end
336
+ end
337
+ file
338
+ end
339
+
340
+ private
341
+ # helper for resize and crop method
342
+ def cama_crop_offsets_by_gravity(gravity, original_dimensions, cropped_dimensions)
343
+ original_width, original_height = original_dimensions
344
+ cropped_width, cropped_height = cropped_dimensions
345
+
346
+ vertical_offset = case gravity
347
+ when :north_west, :north, :north_east then 0
348
+ when :center, :east, :west then [ ((original_height - cropped_height) / 2.0).to_i, 0 ].max
349
+ when :south_west, :south, :south_east then (original_height - cropped_height).to_i
350
+ end
351
+
352
+ horizontal_offset = case gravity
353
+ when :north_west, :west, :south_west then 0
354
+ when :center, :north, :south then [ ((original_width - cropped_width) / 2.0).to_i, 0 ].max
355
+ when :north_east, :east, :south_east then (original_width - cropped_width).to_i
356
+ end
357
+
358
+ return [ horizontal_offset, vertical_offset ]
359
+ end
360
+
361
+ # convert file path into thumb path format
362
+ # return the image name into thumb format: owewen.png into thumb/owen-png.png
363
+ def cama_parse_for_thumb_name(file_path)
364
+ "#{@fog_connection_hook_res[:thumb_folder_name]}/#{File.basename(file_path).parameterize}#{File.extname(file_path)}"
365
+ end
366
+ end