camaleon_cms 0.2.1 → 1.0

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 (266) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +266 -0
  3. data/app/apps/plugins/attack/config/config.json +1 -1
  4. data/app/apps/plugins/contact_form/config/config.json +1 -1
  5. data/app/apps/plugins/contact_form/contact_form_html_helper.rb +15 -10
  6. data/app/apps/plugins/contact_form/front_controller.rb +1 -0
  7. data/app/apps/plugins/contact_form/views/admin_forms/edit.html.erb +1 -2
  8. data/app/apps/plugins/contact_form/views/admin_forms/index.html.erb +1 -1
  9. data/app/apps/plugins/contact_form/views/admin_forms/responses.html.erb +1 -1
  10. data/app/apps/plugins/contact_form/views/forms_shorcode.html.erb +6 -6
  11. data/app/apps/plugins/front_cache/config/config.json +1 -1
  12. data/app/apps/plugins/front_cache/views/admin/settings.html.erb +1 -1
  13. data/app/apps/plugins/visibility_post/config/config.json +1 -1
  14. data/app/apps/themes/camaleon_first/assets/css/style-ver.css.scss +59 -32
  15. data/app/apps/themes/camaleon_first/views/layouts/index.html.erb +2 -2
  16. data/app/apps/themes/default/assets/css/style.css.scss +3 -0
  17. data/app/apps/themes/default/views/category.html.erb +1 -1
  18. data/app/apps/themes/default/views/post_tag.html.erb +1 -1
  19. data/app/apps/themes/default/views/post_type.html.erb +1 -1
  20. data/app/apps/themes/default/views/search.html.erb +1 -1
  21. data/app/apps/themes/new/views/category.html.erb +1 -1
  22. data/app/apps/themes/new/views/layouts/index.html.erb +2 -2
  23. data/app/apps/themes/new/views/post_tag.html.erb +1 -1
  24. data/app/apps/themes/new/views/post_type.html.erb +1 -1
  25. data/app/apps/themes/new/views/search.html.erb +1 -1
  26. data/app/assets/{stylesheets/admin/bootstrap/images → images/admin}/glyphicons-halflings.png +0 -0
  27. data/app/assets/javascripts/admin/actions.js +12 -205
  28. data/app/assets/javascripts/admin/admin-basic-manifest.js +3 -0
  29. data/app/assets/javascripts/admin/admin-manifest.js +14 -4
  30. data/app/assets/javascripts/admin/custom_fields.js +4 -2
  31. data/app/assets/javascripts/admin/data.js +49 -20
  32. data/app/assets/javascripts/admin/elfinder/upload_elfinder.js +4 -4
  33. data/app/assets/javascripts/admin/grid-editor.js +390 -113
  34. data/app/assets/javascripts/admin/i18n.js +22 -0
  35. data/app/assets/javascripts/admin/jquery.validate.js +2 -54
  36. data/app/assets/javascripts/admin/{core.js → libraries.js} +92 -76
  37. data/app/assets/javascripts/admin/login_manifest.js +0 -3
  38. data/app/assets/javascripts/admin/lte/app.js +758 -0
  39. data/app/assets/javascripts/admin/modal.js +76 -22
  40. data/app/assets/javascripts/admin/nav-menu.js +98 -39
  41. data/app/assets/javascripts/admin/post.js +28 -29
  42. data/app/assets/javascripts/admin/tinymce/skins/lightgray/content.min.css.scss +1 -1
  43. data/app/assets/javascripts/admin/tinymce/tinymce.min.js +11 -11
  44. data/app/assets/javascripts/admin/translator.js +9 -7
  45. data/app/assets/javascripts/admin/widgets.js +1 -0
  46. data/app/assets/stylesheets/admin/admin-basic-manifest.css +15 -0
  47. data/app/assets/stylesheets/admin/admin-manifest.css +7 -11
  48. data/app/assets/stylesheets/admin/bootstrap-datepicker.css.scss +472 -0
  49. data/app/assets/stylesheets/admin/bootstrap-datetimepicker.css.scss +339 -0
  50. data/app/assets/stylesheets/admin/colorpicker.css.scss +95 -0
  51. data/app/assets/stylesheets/admin/custom_admin.css.scss +160 -0
  52. data/app/assets/stylesheets/admin/elfinder-manifest.css +1 -1
  53. data/app/assets/stylesheets/admin/grid-editor.css.scss +14 -299
  54. data/app/assets/stylesheets/admin/lte/admin.css.scss +4747 -0
  55. data/app/assets/stylesheets/admin/lte/skins/skin-black-light.css +176 -0
  56. data/app/assets/stylesheets/admin/lte/skins/skin-black.css +154 -0
  57. data/app/assets/stylesheets/admin/lte/skins/skin-blue-light.css +167 -0
  58. data/app/assets/stylesheets/admin/lte/skins/skin-blue.css +142 -0
  59. data/app/assets/stylesheets/admin/lte/skins/skin-green-light.css +156 -0
  60. data/app/assets/stylesheets/admin/lte/skins/skin-green.css +134 -0
  61. data/app/assets/stylesheets/admin/lte/skins/skin-purple-light.css +156 -0
  62. data/app/assets/stylesheets/admin/lte/skins/skin-purple.css +134 -0
  63. data/app/assets/stylesheets/admin/lte/skins/skin-red-light.css +156 -0
  64. data/app/assets/stylesheets/admin/lte/skins/skin-red.css +134 -0
  65. data/app/assets/stylesheets/admin/lte/skins/skin-yellow-light.css +156 -0
  66. data/app/assets/stylesheets/admin/lte/skins/skin-yellow.css +134 -0
  67. data/app/assets/stylesheets/admin/nav-menu.css.scss +33 -0
  68. data/app/controllers/admin/appearances/nav_menus_controller.rb +13 -10
  69. data/app/controllers/admin/appearances/themes_controller.rb +1 -2
  70. data/app/controllers/admin/appearances_controller.rb +0 -4
  71. data/app/controllers/admin/categories_controller.rb +9 -15
  72. data/app/controllers/admin/comments_controller.rb +8 -14
  73. data/app/controllers/admin/grid_editor_controller.rb +55 -0
  74. data/app/controllers/admin/installers_controller.rb +1 -1
  75. data/app/controllers/admin/media_controller.rb +1 -3
  76. data/app/controllers/admin/plugins_controller.rb +2 -2
  77. data/app/controllers/admin/post_tags_controller.rb +9 -18
  78. data/app/controllers/admin/posts/drafts_controller.rb +1 -9
  79. data/app/controllers/admin/posts_controller.rb +12 -15
  80. data/app/controllers/admin/sessions_controller.rb +6 -7
  81. data/app/controllers/admin/settings/custom_fields_controller.rb +4 -9
  82. data/app/controllers/admin/settings/post_types_controller.rb +6 -16
  83. data/app/controllers/admin/settings/sites_controller.rb +5 -7
  84. data/app/controllers/admin/settings_controller.rb +0 -4
  85. data/app/controllers/admin/user_roles_controller.rb +8 -8
  86. data/app/controllers/admin/users_controller.rb +8 -9
  87. data/app/controllers/admin_controller.rb +4 -5
  88. data/app/controllers/apps/plugins_admin_controller.rb +3 -3
  89. data/app/controllers/apps/plugins_front_controller.rb +2 -2
  90. data/app/controllers/apps/themes_admin_controller.rb +2 -2
  91. data/app/controllers/apps/themes_front_controller.rb +2 -2
  92. data/app/controllers/camaleon_controller.rb +0 -1
  93. data/app/controllers/concerns/frontend_concern.rb +1 -2
  94. data/app/controllers/frontend_controller.rb +25 -9
  95. data/app/decorators/category_decorator.rb +0 -1
  96. data/app/decorators/custom_field_decorator.rb +0 -1
  97. data/app/decorators/custom_fields_concern.rb +9 -3
  98. data/app/decorators/post_comment_decorator.rb +0 -1
  99. data/app/decorators/post_decorator.rb +10 -4
  100. data/app/decorators/post_tag_decorator.rb +0 -1
  101. data/app/decorators/post_type_decorator.rb +0 -1
  102. data/app/decorators/site_decorator.rb +35 -11
  103. data/app/decorators/term_taxonomy_decorator.rb +1 -3
  104. data/app/decorators/theme_decorator.rb +0 -1
  105. data/app/decorators/user_decorator.rb +7 -5
  106. data/app/decorators/widget_decorator.rb +0 -1
  107. data/app/helpers/admin/application_helper.rb +14 -0
  108. data/app/helpers/admin/menus_helper.rb +8 -8
  109. data/app/helpers/camaleon_helper.rb +10 -3
  110. data/app/helpers/captcha_helper.rb +2 -2
  111. data/app/helpers/frontend/application_helper.rb +0 -1
  112. data/app/helpers/frontend/nav_menu_helper.rb +2 -1
  113. data/app/helpers/frontend/seo_helper.rb +1 -2
  114. data/app/helpers/frontend/site_helper.rb +4 -4
  115. data/app/helpers/hooks_helper.rb +2 -5
  116. data/app/helpers/html_helper.rb +9 -7
  117. data/app/helpers/plugins_helper.rb +34 -8
  118. data/app/helpers/session_helper.rb +1 -2
  119. data/app/helpers/short_code_helper.rb +91 -10
  120. data/app/helpers/site_helper.rb +17 -8
  121. data/app/helpers/theme_helper.rb +34 -7
  122. data/app/helpers/uploader_helper.rb +6 -2
  123. data/app/mailers/html_mailer.rb +15 -6
  124. data/app/models/category.rb +2 -1
  125. data/app/models/concerns/custom_fields_read.rb +14 -3
  126. data/app/models/concerns/metas.rb +7 -4
  127. data/app/models/custom_field_group.rb +3 -0
  128. data/app/models/{concerns/metas_saved.rb → grid_template.rb} +7 -2
  129. data/app/models/meta.rb +0 -1
  130. data/app/models/nav_menu.rb +15 -1
  131. data/app/models/nav_menu_item.rb +10 -0
  132. data/app/models/post.rb +100 -6
  133. data/app/models/post_comment.rb +6 -0
  134. data/app/models/post_default.rb +9 -8
  135. data/app/models/post_relationship.rb +2 -0
  136. data/app/models/post_type.rb +36 -24
  137. data/app/models/site.rb +7 -16
  138. data/app/models/term_taxonomy.rb +3 -2
  139. data/app/models/theme.rb +5 -0
  140. data/app/models/widget/assigned.rb +3 -2
  141. data/app/views/admin/appearances/nav_menus/_custom_fields.html.erb +6 -0
  142. data/app/views/admin/appearances/{_external_menu.html.erb → nav_menus/_external_menu.html.erb} +8 -10
  143. data/app/views/admin/appearances/nav_menus/_menu_form.html.erb +35 -0
  144. data/app/views/admin/appearances/nav_menus/_menu_list.html.erb +22 -0
  145. data/app/views/admin/appearances/nav_menus/index.html.erb +110 -0
  146. data/app/views/admin/appearances/themes/index.html.erb +4 -3
  147. data/app/views/admin/appearances/widgets/main/_sidebar.html.erb +29 -0
  148. data/app/views/admin/appearances/widgets/main/form.html.erb +1 -1
  149. data/app/views/admin/appearances/widgets/main/index.html.erb +19 -41
  150. data/app/views/admin/categories/edit.html.erb +2 -6
  151. data/app/views/admin/categories/index.html.erb +7 -11
  152. data/app/views/admin/comments/form.html.erb +4 -7
  153. data/app/views/admin/comments/index.html.erb +24 -41
  154. data/app/views/admin/comments/reply.html.erb +9 -10
  155. data/app/views/admin/grid_editor/form.html.erb +31 -0
  156. data/app/views/admin/grid_editor/index.html.erb +29 -0
  157. data/app/views/admin/media/index.html.erb +3 -15
  158. data/app/views/admin/plugins/_plugins_list.html.erb +1 -2
  159. data/app/views/admin/post_tags/edit.html.erb +2 -6
  160. data/app/views/admin/post_tags/index.html.erb +3 -8
  161. data/app/views/admin/posts/_sidebar.html.erb +136 -0
  162. data/app/views/admin/posts/form.html.erb +87 -281
  163. data/app/views/admin/posts/index.html.erb +89 -104
  164. data/app/views/admin/sessions/forgot.html.erb +7 -13
  165. data/app/views/admin/sessions/login.html.erb +21 -11
  166. data/app/views/admin/sessions/register.html.erb +3 -6
  167. data/app/views/admin/settings/custom_fields/_meta_data.html.erb +1 -1
  168. data/app/views/admin/settings/custom_fields/_render.html.erb +6 -14
  169. data/app/views/admin/settings/custom_fields/fields/audio.html.erb +1 -1
  170. data/app/views/admin/settings/custom_fields/fields/field_attrs.html.erb +3 -5
  171. data/app/views/admin/settings/custom_fields/fields/file.html.erb +1 -1
  172. data/app/views/admin/settings/custom_fields/fields/image.html.erb +1 -1
  173. data/app/views/admin/settings/custom_fields/fields/posts.html.erb +1 -1
  174. data/app/views/admin/settings/custom_fields/fields/select.html.erb +1 -1
  175. data/app/views/admin/settings/custom_fields/fields/users.html.erb +1 -1
  176. data/app/views/admin/settings/custom_fields/fields/video.html.erb +1 -1
  177. data/app/views/admin/settings/custom_fields/form.html.erb +11 -9
  178. data/app/views/admin/settings/custom_fields/get_items.html.erb +3 -6
  179. data/app/views/admin/settings/custom_fields/index.html.erb +3 -10
  180. data/app/views/admin/settings/languages.html.erb +2 -10
  181. data/app/views/admin/settings/post_types/_form.html.erb +1 -1
  182. data/app/views/admin/settings/post_types/edit.html.erb +2 -6
  183. data/app/views/admin/settings/post_types/index.html.erb +4 -12
  184. data/app/views/admin/settings/site.html.erb +143 -149
  185. data/app/views/admin/settings/sites/form.html.erb +4 -19
  186. data/app/views/admin/settings/sites/index.html.erb +8 -9
  187. data/app/views/admin/taxonomy/index.html.erb +1 -1
  188. data/app/views/admin/user_roles/form.html.erb +2 -3
  189. data/app/views/admin/user_roles/index.html.erb +2 -8
  190. data/app/views/admin/users/form.html.erb +14 -9
  191. data/app/views/admin/users/index.html.erb +3 -8
  192. data/app/views/admin/users/profile_edit.html.erb +21 -14
  193. data/app/views/default_theme/custom_fields/audio.html.erb +3 -0
  194. data/app/views/default_theme/custom_fields/checkbox.html.erb +3 -0
  195. data/app/views/default_theme/custom_fields/checkboxes.html.erb +3 -0
  196. data/app/views/default_theme/custom_fields/colorpicker.html.erb +3 -0
  197. data/app/views/default_theme/custom_fields/date.html.erb +3 -0
  198. data/app/views/default_theme/custom_fields/editor.html.erb +3 -0
  199. data/app/views/default_theme/custom_fields/email.html.erb +3 -0
  200. data/app/views/default_theme/custom_fields/field_attrs.html.erb +3 -0
  201. data/app/views/default_theme/custom_fields/file.html.erb +3 -0
  202. data/app/views/default_theme/custom_fields/image.html.erb +3 -0
  203. data/app/views/default_theme/custom_fields/numeric.html.erb +3 -0
  204. data/app/views/default_theme/custom_fields/phone.html.erb +3 -0
  205. data/app/views/default_theme/custom_fields/posts.html.erb +3 -0
  206. data/app/views/default_theme/custom_fields/radio.html.erb +3 -0
  207. data/app/views/default_theme/custom_fields/select.html.erb +3 -0
  208. data/app/views/default_theme/custom_fields/select_eval.html.erb +3 -0
  209. data/app/views/default_theme/custom_fields/text_area.html.erb +3 -0
  210. data/app/views/default_theme/custom_fields/text_box.html.erb +3 -0
  211. data/app/views/default_theme/custom_fields/url.html.erb +3 -0
  212. data/app/views/default_theme/custom_fields/users.html.erb +3 -0
  213. data/app/views/default_theme/custom_fields/video.html.erb +3 -0
  214. data/app/views/default_theme/layouts/index.html.erb +2 -2
  215. data/app/views/default_theme/{post.html.erb → single.html.erb} +1 -1
  216. data/app/views/default_theme/{post.rss.builder → single.rss.builder} +0 -0
  217. data/app/views/layouts/admin.html.erb +35 -133
  218. data/app/views/layouts/admin/_flash_messages.html.erb +1 -15
  219. data/app/views/layouts/admin/_footer.html.erb +6 -0
  220. data/app/views/layouts/admin/_header.html.erb +51 -0
  221. data/app/views/layouts/admin/_sidebar.html.erb +21 -30
  222. data/app/views/layouts/admin/installer.html.erb +2 -2
  223. data/app/views/layouts/login.html.erb +15 -33
  224. data/config/initializers/active_record_extension.rb +14 -2
  225. data/config/initializers/assets.rb +21 -7
  226. data/config/initializers/page_caching.rb +1 -2
  227. data/config/locales/admin/en.yml +17 -9
  228. data/config/locales/admin/es.yml +8 -3
  229. data/config/locales/admin/it.yml +4 -2
  230. data/config/locales/admin/js.yml +147 -0
  231. data/config/routes/admin.rb +4 -4
  232. data/config/routes/frontend.rb +2 -2
  233. data/config/system.json +1 -0
  234. data/db/migrate/20150926095310_rename_column_posts.rb +18 -0
  235. data/lib/camaleon_cms.rb +1 -1
  236. data/lib/camaleon_cms/engine.rb +17 -2
  237. data/lib/camaleon_cms/version.rb +1 -1
  238. data/lib/generators/camaleon_cms/gem_plugin_generator.rb +122 -0
  239. data/lib/generators/camaleon_cms/gem_plugin_template/app/controllers/plugins/my_plugin/admin_controller.rb +8 -0
  240. data/lib/generators/camaleon_cms/gem_plugin_template/app/controllers/plugins/my_plugin/front_controller.rb +8 -0
  241. data/lib/generators/camaleon_cms/gem_plugin_template/app/helpers/plugins/my_plugin/main_helper.rb +22 -0
  242. data/lib/generators/camaleon_cms/gem_plugin_template/app/models/plugins/my_plugin/my_plugin.rb +12 -0
  243. data/lib/generators/camaleon_cms/gem_plugin_template/app/views/plugins/my_plugin/admin/index.html.erb +2 -0
  244. data/lib/generators/camaleon_cms/gem_plugin_template/app/views/plugins/my_plugin/front/index.html.erb +2 -0
  245. data/lib/generators/camaleon_cms/gem_plugin_template/app/views/plugins/my_plugin/layouts/readme.txt +2 -0
  246. data/lib/generators/camaleon_cms/gem_plugin_template/config/camaleon_plugin.json +21 -0
  247. data/lib/generators/camaleon_cms/install_generator.rb +1 -2
  248. data/lib/generators/camaleon_cms/install_template/plugin_routes.rb +1 -10
  249. data/lib/generators/ctheme_template/app/apps/themes/my_theme/config/config.json +5 -5
  250. data/lib/generators/ctheme_template/app/apps/themes/my_theme/main_helper.rb +6 -5
  251. data/lib/generators/ctheme_template/app/apps/themes/my_theme/views/layouts/index.html.erb +2 -2
  252. data/lib/plugin_routes.rb +40 -2
  253. metadata +257 -22
  254. data/app/assets/stylesheets/admin/animate/animate.min.css +0 -6
  255. data/app/assets/stylesheets/admin/bootstrap/bootstrap-datetimepicker.css.scss +0 -339
  256. data/app/assets/stylesheets/admin/bootstrap/bootstrap.min.css +0 -5
  257. data/app/assets/stylesheets/admin/core.scss +0 -349
  258. data/app/assets/stylesheets/admin/fonts/OpenSans-Regular-webfont.eot +0 -0
  259. data/app/assets/stylesheets/admin/fonts/OpenSans-Regular-webfont.svg +0 -1831
  260. data/app/assets/stylesheets/admin/fonts/OpenSans-Regular-webfont.ttf +0 -0
  261. data/app/assets/stylesheets/admin/fonts/OpenSans-Regular-webfont.woff +0 -0
  262. data/app/assets/stylesheets/admin/nav-menu.css +0 -54
  263. data/app/assets/stylesheets/admin/theme-default.scss +0 -8462
  264. data/app/models/concerns/site_public.rb +0 -23
  265. data/app/views/admin/appearances/menu.html.erb +0 -199
  266. data/lib/Gemfile +0 -25
@@ -28,6 +28,8 @@ class PostComment < ActiveRecord::Base
28
28
  scope :approveds, -> { where(:approved => 'approved') }
29
29
 
30
30
  validates :content, :presence => true
31
+ after_create :update_counter
32
+ after_destroy :update_counter
31
33
 
32
34
  # return the owner of this comment
33
35
  def comment_user
@@ -40,5 +42,9 @@ class PostComment < ActiveRecord::Base
40
42
  end
41
43
 
42
44
  private
45
+ def update_counter
46
+ p = self.post
47
+ p.set_meta("comments_count", p.comments.count) if p.present?
48
+ end
43
49
 
44
50
  end
@@ -13,15 +13,14 @@ class PostDefault < ActiveRecord::Base
13
13
 
14
14
  #extend FriendlyId
15
15
  attr_accessible :user_id, :title, :slug, :content, :content_filtered, :status, :visibility, :visibility_value, :post_order,
16
- :post_type_key, :comment_count, :published_at, :post_parent
16
+ :post_type_key, :taxonomy_id, :published_at, :post_parent, :post_order
17
17
  attr_accessor :draft_id
18
18
 
19
19
 
20
20
  has_many :term_relationships, class_name: "TermRelationship", foreign_key: :objectid, dependent: :destroy, primary_key: :id #, :autosave => true
21
- has_many :parent_taxonomy, foreign_key: :term_taxonomy_id, class_name: "TermTaxonomy", through: :term_relationships, :source => :term_taxonomies
22
21
  has_many :children, class_name: "PostDefault", foreign_key: :post_parent, dependent: :destroy, primary_key: :id
23
22
 
24
- validates :title,:slug, presence: true
23
+ validates :title, :slug, presence: true
25
24
 
26
25
  # relations
27
26
 
@@ -30,6 +29,7 @@ class PostDefault < ActiveRecord::Base
30
29
  before_save :before_saved
31
30
  before_destroy :destroy_dependencies
32
31
 
32
+ # find a content by slug (support multi language)
33
33
  def self.find_by_slug(slug)
34
34
  self.where("posts.slug = ? OR posts.slug LIKE ? ", slug, "%-->#{slug}<!--%").reorder("").first
35
35
  end
@@ -39,6 +39,7 @@ class PostDefault < ActiveRecord::Base
39
39
  end
40
40
 
41
41
 
42
+ # return the author of this Content
42
43
  def author
43
44
  begin
44
45
  User.find(self.user_id)
@@ -47,30 +48,30 @@ class PostDefault < ActiveRecord::Base
47
48
  end
48
49
  end
49
50
 
50
- def term_taxonomies
51
- TermTaxonomy.where("id IN (?)",self.term_relationships.pluck(:term_taxonomy_id))
52
- end
53
-
51
+ # save meta values passed from form
54
52
  def set_meta_from_form(data_metas)
55
53
  data_metas.each do |key, value|
56
54
  self.set_meta(key, value)
57
55
  end
58
56
  end
59
57
 
58
+ # return all menu items in which this post was assigned
60
59
  def in_nav_menu_items
61
60
  NavMenuItem.joins(:metas).where("value LIKE ?","%\"object_id\":\"#{self.id}\"%").where("value LIKE ?","%\"type\":\"post\"%").readonly(false)
62
61
  end
63
62
 
64
63
  private
65
-
66
64
  def before_validating
67
65
  #self.slug = self.title if self.slug.blank?
68
66
  #self.slug = self.slug.to_s.parameterize
69
67
  end
68
+
69
+ # do all before actions to save the content
70
70
  def before_saved
71
71
  self.content_filtered = content.to_s.include?('<!--:-->') ? content.translations.inject({}) { |h, (key, value)| h[key] = value.squish.strip_tags; h }.to_translate : content.to_s.squish.strip_tags
72
72
  end
73
73
 
74
+ # destroy all dependencies of this content
74
75
  def destroy_dependencies
75
76
  in_nav_menu_items.destroy_all
76
77
  end
@@ -6,6 +6,8 @@
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
+
10
+ # DEPRECATED, NOT USED ANY MORE
9
11
  class PostRelationship < ActiveRecord::Base
10
12
  self.table_name = "term_relationships"
11
13
  attr_accessible :objectid, :term_taxonomy_id, :term_order
@@ -12,8 +12,8 @@ class PostType < TermTaxonomy
12
12
  has_many :metas, ->{ where(object_class: 'PostType')}, :class_name => "Meta", foreign_key: :objectid, dependent: :destroy
13
13
  has_many :categories, :class_name => "Category", foreign_key: :parent_id, dependent: :destroy
14
14
  has_many :post_tags, :class_name => "PostTag", foreign_key: :parent_id, dependent: :destroy
15
- has_many :post_relationships, :class_name => "PostRelationship", dependent: :destroy, :foreign_key => :term_taxonomy_id, inverse_of: :post_type
16
- has_many :posts, foreign_key: :objectid, through: :post_relationships, :source => :posts, dependent: :destroy
15
+ has_many :posts, class_name: "Post", foreign_key: :taxonomy_id, dependent: :destroy
16
+ has_many :posts_draft, class_name: "Post", foreign_key: :taxonomy_id, dependent: :destroy, source: :drafts
17
17
  has_many :field_group_taxonomy, -> {where("object_class LIKE ?","PostType_%")}, :class_name => "CustomField", foreign_key: :objectid, dependent: :destroy
18
18
 
19
19
  belongs_to :owner, class_name: "User", foreign_key: :user_id
@@ -47,10 +47,20 @@ class PostType < TermTaxonomy
47
47
  end
48
48
 
49
49
  # assign settings for this post type
50
- # default: {has_category: false, has_tags: false, has_summary: false, has_content: true, has_comments: false, has_picture: true, has_template: false, has_keywords: false}.merge(settings)
50
+ # default values: {
51
+ # has_category: false,
52
+ # has_tags: false,
53
+ # has_summary: true,
54
+ # has_content: true,
55
+ # has_comments: false,
56
+ # has_picture: true,
57
+ # has_template: true,
58
+ # has_keywords: true
59
+ # }
51
60
  def set_settings(settings = {})
52
- settings = {has_category: false, has_tags: false, has_summary: true, has_content: true, has_comments: false, has_picture: true, has_template: false, has_keywords: true}.merge(settings)
53
- self.set_meta("_default", settings)
61
+ settings.each do |key, val|
62
+ self.set_setting(key, val)
63
+ end
54
64
  end
55
65
 
56
66
  # set or update a setting for this post type
@@ -58,19 +68,6 @@ class PostType < TermTaxonomy
58
68
  self.set_option(key, value)
59
69
  end
60
70
 
61
- # object: [category, post, post_tags]
62
- def field_object_values(key, object)
63
- field = fields.where(slug: key).first
64
- field.present? ? field.values.where(objectid: object.id, object_class: object.class.to_s.gsub("Decorator","")).pluck(:value) : []
65
- end
66
- def field_object_value(key, object)
67
- field_object_values(key, object).first
68
- end
69
-
70
- def get_post_content(key)
71
- posts.rewhere(post_type: key)
72
- end
73
-
74
71
  # select full_categories for the post type, include all children categories
75
72
  def full_categories
76
73
  s = self.site
@@ -94,18 +91,32 @@ class PostType < TermTaxonomy
94
91
  # title: title for post, => required
95
92
  # content: html text content, => required
96
93
  # thumb: image url, => default (empty). check http://camaleon.tuzitio.com/api-methods.html#section_fileuploads
97
- # has_comments: 0|1, => default (0)
98
94
  # categories: [1,3,4,5], => default (empty)
99
95
  # tags: String comma separated, => default (empty)
100
96
  # slug: string key for post, => default (empty)
101
- # summary: String resume (optional)} => default (empty)
97
+ # summary: String resume (optional) => default (empty)
98
+ # order_position: Integer to define the order position in the list (optional)
99
+ # fields: Hash of values for custom fields, sample => fields: {subtitle: 'abc', icon: 'test' } (optional)
100
+ # settings: Hash of post settings, sample => settings: {has_content: false, has_summary: true } (optional, see more in post.set_setting(...))
102
101
  # return created post if it was created, else return errors
103
102
  def add_post(args)
104
- p = self.posts.new({has_comments: 0}.merge(args))
103
+ _fields = args.delete(:fields)
104
+ _settings = args.delete(:settings)
105
+ _summary = args.delete(:summary)
106
+ _order_position = args.delete(:order_position)
107
+ _categories = args.delete(:categories)
108
+ _tags = args.delete(:tags)
109
+ _thumb = args.delete(:thumb)
110
+ p = self.posts.new(args)
105
111
  p.slug = self.site.get_valid_post_slug(p.title.parameterize) unless p.slug.present?
106
- if p.save
107
- p.assign_category(args[:categories]) if args[:categories].present? && self.manage_categories?
108
- p.assign_tags(args[:tags]) if args[:tags].present? && self.manage_tags?
112
+ if p.save!
113
+ _settings.each{ |k, v| p.set_setting(k, v) } if _settings.present?
114
+ p.assign_category(_categories) if _categories.present? && self.manage_categories?
115
+ p.assign_tags(_tags) if _tags.present? && self.manage_tags?
116
+ p.set_position(_order_position) if _order_position.present?
117
+ p.set_summary(_summary) if _summary.present?
118
+ p.set_thumb(_thumb) if _thumb.present?
119
+ _fields.each{ |k, v| p.save_field_value(k, v) } if _fields.present?
109
120
  return p
110
121
  else
111
122
  p.errors
@@ -113,6 +124,7 @@ class PostType < TermTaxonomy
113
124
  end
114
125
 
115
126
  private
127
+ # assign default roles for this post type
116
128
  def set_default_site_user_roles
117
129
  self.site.set_default_user_roles(self)
118
130
  end
@@ -7,7 +7,6 @@
7
7
  See the GNU Affero General Public License (GPLv3) for more details.
8
8
  =end
9
9
  class Site < TermTaxonomy
10
- include SitePublic
11
10
  # attrs: [name, description, slug]
12
11
  default_scope { where(taxonomy: :site).reorder(term_group: :desc) }
13
12
  has_many :metas, ->{ where(object_class: 'Site')}, :class_name => "Meta", foreign_key: :objectid, dependent: :destroy
@@ -21,9 +20,10 @@ class Site < TermTaxonomy
21
20
  # has_many :post_tags, :class_name => "PostTag", through: :post_types, :source => :post_tags , dependent: :destroy, as: "posttag"
22
21
  has_many :term_taxonomies, :class_name => "TermTaxonomy", foreign_key: :parent_id
23
22
 
24
- #has_many :posts, through: :post_types, :source => :posts
23
+ has_many :posts, through: :post_types, :source => :posts
25
24
  has_many :plugins, :class_name => "Plugin", foreign_key: :parent_id, dependent: :destroy
26
25
  has_many :themes, :class_name => "Theme", foreign_key: :parent_id, dependent: :destroy
26
+ has_many :grid_templates, foreign_key: :parent_id, dependent: :destroy
27
27
 
28
28
  after_create :default_settings
29
29
  after_create :set_all_users
@@ -32,6 +32,7 @@ class Site < TermTaxonomy
32
32
  before_destroy :destroy_site
33
33
  validates_uniqueness_of :slug, scope: :taxonomy
34
34
 
35
+ # all user roles for this site
35
36
  def user_roles
36
37
  if PluginRoutes.system_info["users_share_sites"]
37
38
  Site.first.user_roles_rel
@@ -40,11 +41,6 @@ class Site < TermTaxonomy
40
41
  end
41
42
  end
42
43
 
43
- # all post fix
44
- def posts
45
- Post.joins(:post_types).where("term_taxonomy.id" => self.post_types.pluck(:id)).order("term_relationships.term_order asc, posts.id DESC")
46
- end
47
-
48
44
  #select full_categories for the site, include all children categories
49
45
  def full_categories
50
46
  Category.where({term_group: self.id})
@@ -60,13 +56,6 @@ class Site < TermTaxonomy
60
56
  Category.includes(:post_type_parent).where(post_type_parent: self.post_types.pluck(:id))
61
57
  end
62
58
 
63
- # all posts for this site (faster mode)
64
- # alternative for Site.posts (no manage default order)
65
- # deprecated for select posts from scratch
66
- def posts2
67
- Post.joins(:post_types).where("term_taxonomy.id" => self.post_types.pluck(:id)).where("term_taxonomy.slug = ?", "post")
68
- end
69
-
70
59
  # return all languages configured by the admin
71
60
  # if it is empty, then return default locale
72
61
  def get_languages
@@ -242,6 +231,7 @@ class Site < TermTaxonomy
242
231
  FileUtils.rm_rf(upload_directory) # destroy current media directory
243
232
  end
244
233
 
234
+ # default structure for each new site
245
235
  def default_settings
246
236
  default_post_type = [
247
237
  {
@@ -289,9 +279,8 @@ class Site < TermTaxonomy
289
279
  end
290
280
 
291
281
  # nav menus
292
- @sidebar = self.sidebars.new({name: 'default sidebar', slug: 'default-sidebar'})
282
+ # @sidebar = self.sidebars.new({name: 'default sidebar', slug: 'default-sidebar'})
293
283
  @nav_menu = self.nav_menus.new({name: "Main Menu", slug: "main_menu"})
294
- @sidebar.save
295
284
 
296
285
  if @nav_menu.save
297
286
  self.post_types.all.each do |pt|
@@ -316,6 +305,7 @@ class Site < TermTaxonomy
316
305
  # self.set_option('_theme', PluginRoutes.system_info["default_template"])
317
306
  end
318
307
 
308
+ # assign all users to this new site
319
309
  def set_all_users
320
310
  User.all.each do |user|
321
311
  self.assign_user(user)
@@ -323,6 +313,7 @@ class Site < TermTaxonomy
323
313
  end
324
314
 
325
315
  # update all routes of the system
316
+ # reload system routes for this site
326
317
  def update_routes
327
318
  if self.id == Site.first.id
328
319
  PluginRoutes.system_info_set("base_domain", self.slug) if self.slug.present?
@@ -16,7 +16,7 @@ class TermTaxonomy < ActiveRecord::Base
16
16
  include Metas
17
17
  include CustomFieldsRead
18
18
  self.table_name = "term_taxonomy"
19
- attr_accessible :taxonomy, :description, :parent_id, :count, :name, :slug, :term_group, :status, :term_order
19
+ attr_accessible :taxonomy, :description, :parent_id, :count, :name, :slug, :term_group, :status, :term_order, :user_id
20
20
 
21
21
  # callbacks
22
22
 
@@ -69,7 +69,7 @@ class TermTaxonomy < ActiveRecord::Base
69
69
  has_tags: false,
70
70
  has_summary: true,
71
71
  has_content: true,
72
- has_comments: true,
72
+ has_comments: false,
73
73
  has_picture: true,
74
74
  has_template: true,
75
75
  not_deleted: false
@@ -121,6 +121,7 @@ class TermTaxonomy < ActiveRecord::Base
121
121
  end
122
122
  end
123
123
 
124
+ # return all menu items in which this taxonomy was assigned
124
125
  def in_nav_menu_items
125
126
  NavMenuItem.joins(:metas).where("value LIKE ?","%\"object_id\":\"#{self.id}\"%").where("value LIKE ?","%\"type\":\"#{self.taxonomy}\"%").readonly(false)
126
127
  end
@@ -21,6 +21,11 @@ class Theme < TermTaxonomy
21
21
  PluginRoutes.theme_info(self.slug)
22
22
  end
23
23
 
24
+ # return the path to the settings file for current theme
25
+ def settings_file
26
+ File.join(self.settings["path"], "views/admin/settings.html.erb").to_s
27
+ end
28
+
24
29
  private
25
30
  def fix_name
26
31
  self.name = self.slug unless self.name.present?
@@ -7,13 +7,14 @@
7
7
  See the GNU Affero General Public License (GPLv3) for more details.
8
8
  =end
9
9
  class Widget::Assigned < PostDefault
10
- default_scope ->{ where(post_class: self.name).order(:comment_count) }
10
+ default_scope ->{ where(post_class: self.name).order(:taxonomy_id) }
11
11
  # post_parent: sidebar_id
12
12
  # visibility: widget_id
13
13
  # comment_count: item_order
14
+ # TODO rename all attribute names (changed comment_count into taxonomy_id)
14
15
  alias_attribute :widget_id, :visibility
15
16
  alias_attribute :sidebar_id, :post_parent
16
- alias_attribute :item_order, :comment_count
17
+ alias_attribute :item_order, :taxonomy_id
17
18
 
18
19
  attr_accessible :widget_id, :sidebar_id, :item_order
19
20
 
@@ -0,0 +1,6 @@
1
+ <form class="menus_field_form required">
2
+ <%= render partial: "admin/settings/custom_fields/render", locals: {record: @nav_menu, field_groups: @nav_menu.get_field_groups()} %>
3
+ <div class="text-right">
4
+ <button class="btn btn-primary" type="submit"><%= t("admin.button.submit") %> <i class="fa fa-arrow-right"></i></button>
5
+ </div>
6
+ </form>
@@ -1,16 +1,14 @@
1
- <%= raw (submit)? '<form class="modal-body overflow-visible form-horizontal">' : '' %>
2
- <div class="panel-body" id="menu_external_link">
1
+ <form class="form-custom-link validate <%= submit ? "" : "panel-body" %>">
3
2
  <div class="alert alert-info">You can use root_url as main url.</div>
4
3
  <div class="form-group">
5
- <label><%= t('admin.menus.link_url')%></label>
6
- <input id="external_url" class="form-control" name="external_url" />
4
+ <label><%= t('admin.menus.name_link')%></label>
5
+ <input id="external_label" class="form-control translatable required" name="external_label" />
7
6
  </div>
8
7
  <div class="form-group">
9
- <label><%= t('admin.menus.name_link')%></label>
10
- <input id="external_label" class="form-control translatable" name="external_label" />
8
+ <label><%= t('admin.menus.link_url')%></label>
9
+ <input id="external_url" class="form-control" name="external_url" />
11
10
  </div>
12
- <div class="panel-footer">
13
- <a href="#" id="add_external_link" class="btn btn-default pull-right"><%= t('admin.button.add_menu')%> <i class="fa fa-arrow-right"></i></a>
11
+ <div class="text-right">
12
+ <button type="submit" id="add_external_link" class="btn btn-primary"><%= t('admin.button.add_menu')%> <i class="fa fa-arrow-right"></i></button>
14
13
  </div>
15
- </div>
16
- <%= raw (submit)? '</form">' : '' %>
14
+ </form>
@@ -0,0 +1,35 @@
1
+ <div class="col-md-7">
2
+ <%= form_for @nav_menu, url: {action: :save}, html: {method: "post", id: "menu_form"} do |f| %>
3
+ <%= f.hidden_field :id %>
4
+ <!-- START PANEL WITH CONTROL CLASSES -->
5
+ <div class="panel panel-info">
6
+ <div class="panel-heading">
7
+ <label><%= t('admin.menus.name_menu') %>:</label>
8
+ <%= f.text_field :name, class: 'form-control menu-input-title' %>
9
+ <label>Slug:</label>
10
+ <%= f.text_field :slug, class: 'form-control menu-input-slug slug', 'data-parent' => 'nav_menu_name' %>
11
+ <% if @nav_menu.new_record? %>
12
+ <button class="btn btn-primary pull-right" type=""><%= @nav_menu.new_record? ? t('admin.button.create_menu') : t('admin.button.update_menu') %></button>
13
+ <% end %>
14
+ </div>
15
+ <% unless @nav_menu.new_record? %>
16
+ <div class="panel-body">
17
+ <div class="callout callout-info"><%= t('admin.message.add_menus') %></div>
18
+ <div class="dd" id="nestable">
19
+ <ol class="dd-list"></ol>
20
+ </div>
21
+ </div>
22
+ <div class="panel-body">
23
+
24
+ </div>
25
+ <div class="panel-footer">
26
+ <%= content_tag(:div, (raw @nav_menu.description), class: "callout callout-info") if @nav_menu.description.present? %>
27
+ <%= link_to raw("<i class='fa fa-times'></i> #{t('admin.button.delete')}"), {action: :menu, id: @nav_menu.id}, method: :delete, data: {confirm: t('admin.message.delete')}, class: "btn btn-danger btn-sm pull-left", title: "Delete" unless @nav_menu.new_record? %>
28
+ <button class="btn btn-primary btn-sm pull-right" type=""><%= @nav_menu.new_record? ? t('admin.button.create_menu') : t('admin.button.update_menu') %></button>
29
+ </div>
30
+ <% end %>
31
+
32
+ </div>
33
+ <!-- END PANEL WITH CONTROL CLASSES -->
34
+ <% end %>
35
+ </div>
@@ -0,0 +1,22 @@
1
+ <div class="manage-menus panel panel-primary">
2
+ <div class="panel-body">
3
+ <form action="<%= admin_appearances_nav_menus_menu_path %>" method="get" class="">
4
+ <div class="form-group">
5
+ <label class="selected-menu" for="menu"><%= t('admin.menus.select_edit') %></label>
6
+ </div>
7
+ <div class="input-group input-group-sm">
8
+ <select id="menu" class="select form-control" name="id">
9
+ <option value=""><%= t('admin.menus.select') %></option>
10
+ <% @nav_menus.each do |menu| %>
11
+ <option value="<%= menu.id %>" <%= 'selected' if !@nav_menu.new_record? && @nav_menu.id == menu.id %> ><%= menu.name %></option>
12
+ <% end %>
13
+ </select>
14
+ <span class="input-group-btn">
15
+ <button class="btn btn-primary btn-flat" type="submit"><%= t('admin.menus.select') %></button>
16
+ <a class="btn btn-default" href="<%= admin_appearances_nav_menus_menu_path({new: 1}) %>"> <%= t('admin.menus.create_new') %></a>
17
+ </span>
18
+ </div>
19
+ </form>
20
+ </div>
21
+
22
+ </div>
@@ -0,0 +1,110 @@
1
+ <div class="page-title">
2
+ <h2><%= t('admin.menus.menus') %></h2>
3
+ </div>
4
+ <div class="page-content-wrap">
5
+ <div class="row">
6
+ <div id="menu_content" data-fields_support="<%= @nav_menu.get_field_groups.any? %>">
7
+ <div id="menu_items" class="col-md-5">
8
+ <%= render "menu_list" %>
9
+ <!-- START ACCORDION -->
10
+ <div class="panel-group <%= "disabled" if @nav_menu.new_record? %>">
11
+ <% @post_types.each do |pt|
12
+ pt = pt.decorate %>
13
+ <div class="panel panel-default <%= 'panel-toggled' if pt.slug != 'post' %>">
14
+ <div class="panel-heading">
15
+ <h4 class="panel-title class_type" data-type="post_type">
16
+ <label class=" nowrap class_slug" data-post_link_edit="">
17
+ <input type="checkbox" name="pt[]" value="<%= pt.id %>">
18
+ <span class="lbl hidden"><%= pt.the_title %></span>
19
+ </label>
20
+ <%= pt.the_title %>
21
+ </h4>
22
+ <ul class="panel-controls">
23
+ <!--<li><a href="#" class="panel-fullscreen"><span class="fa fa-expand"></span></a></li>-->
24
+ <li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a>
25
+ </li>
26
+ </ul>
27
+ </div>
28
+ <div class="panel-body nav-tabs-vertical0" id="acc-<%= pt.slug %>" style="padding: 0">
29
+ <div class="tabs">
30
+ <ul class="nav nav-tabs ">
31
+ <li class="active">
32
+ <a href="#tab-<%= pt.slug %>-posts" role="tab" data-toggle="tab"><%= t('admin.post_type.posts') %></a>
33
+ </li>
34
+ <% if pt.manage_categories? %>
35
+ <li>
36
+ <a href="#tab-<%= pt.slug %>-categories" role="tab" data-toggle="tab"><%= t('admin.post_type.categories') %></a>
37
+ </li>
38
+ <% end %>
39
+ <% if pt.manage_tags? %>
40
+ <li>
41
+ <a href="#tab-<%= pt.slug %>-tags" role="tab" data-toggle="tab"><%= t('admin.post_type.tags') %></a>
42
+ </li>
43
+ <% end %>
44
+ </ul>
45
+ <div class=" tab-content">
46
+ <div class="tab-pane active class_type" id="tab-<%= pt.slug %>-posts" data-type="post" data-post_type="<%= pt.slug %>">
47
+ <ul class="categorychecklist">
48
+ <% pt.posts.published.each do |p|
49
+ p = p.decorate
50
+ %>
51
+ <li>
52
+ <label class="class_slug" data-post_link_edit="<%= p.the_edit_url %>">
53
+ <input type="checkbox" value="<%= p.id %>">
54
+ <%= p.the_title %>
55
+ </label>
56
+ </li>
57
+ <% end %>
58
+ </ul>
59
+ </div>
60
+ <% if pt.manage_categories? %>
61
+ <div class="tab-pane class_type" id="tab-<%= pt.slug %>-categories" data-type="category" data-post_type="<%= pt.slug %>">
62
+ <%= raw post_type_html_inputs(pt, "categories", "categories", "checkbox", [], "categorychecklist") %>
63
+ </div>
64
+ <% end %>
65
+ <% if pt.manage_tags? %>
66
+ <div class="tab-pane class_type" id="tab-<%= pt.slug %>-tags" data-type="post_tag" data-post_type="<%= pt.slug %>">
67
+ <%= raw post_type_html_inputs(pt, "post_tags", "post_tags", "checkbox", [], "categorychecklist") %>
68
+ </div>
69
+ <% end %>
70
+ </div>
71
+ </div>
72
+ <div class="panel-footer">
73
+ <button class="add_links_to_menu btn btn-primary pull-right" type=""><%= t('admin.button.add_menu') %>
74
+ <i class="fa fa-arrow-right"></i></button>
75
+ </div>
76
+ </div>
77
+ </div>
78
+ <% end %>
79
+ <div class="panel panel-default panel-toggled">
80
+ <div class="panel-heading">
81
+ <h4 class="panel-title"><%= t('admin.menus.external_link') %></h4>
82
+ <ul class="panel-controls">
83
+ <!--<li><a href="#" class="panel-fullscreen"><span class="fa fa-expand"></span></a></li>-->
84
+ <li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
85
+ </ul>
86
+ </div>
87
+ <%= render partial: "external_menu", locals: {submit: false} %>
88
+ </div>
89
+ </div>
90
+ <!-- END ACCORDION -->
91
+
92
+ </div>
93
+
94
+
95
+ <%= render "menu_form" %>
96
+
97
+ <!--/form-->
98
+ </div>
99
+ </div>
100
+ <!-- END PAGE CONTENT WRAPPER -->
101
+ </div>
102
+
103
+ <script>
104
+ var RENDER_FORM = '<%= admin_appearances_nav_menus_form_path(menu_id: @nav_menu.id) %>';
105
+ var main_menus_panel;
106
+ jQuery(function(){
107
+ main_menus_panel = $("#menu_content");
108
+ render_menu(<%= raw (@items.to_json)%>);
109
+ });
110
+ </script>