Module: CamaleonCms::SiteDefaultSettings
- Extended by:
- ActiveSupport::Concern
- Included in:
- Site
- Defined in:
- app/models/concerns/camaleon_cms/site_default_settings.rb
Instance Method Summary collapse
-
#default_settings ⇒ Object
default structure for each new site.
-
#set_default_user_roles(post_type = nil) ⇒ Object
auto create default user roles.
Instance Method Details
#default_settings ⇒ Object
default structure for each new site
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/models/concerns/camaleon_cms/site_default_settings.rb', line 5 def default_settings default_post_type = [ { name: 'Post', description: 'Posts', options: { has_category: true, has_tags: true, not_deleted: true, has_summary: true, has_content: true, has_comments: true, has_picture: true, has_template: true } }, { name: 'Page', description: 'Pages', options: { has_category: false, has_tags: false, not_deleted: true, has_summary: false, has_content: true, has_comments: false, has_picture: true, has_template: true, has_layout: true } } ] default_post_type.each do |pt| post_types.create({ name: pt[:name], slug: pt[:name].to_s.parameterize, description: pt[:description], data_options: pt[:options] }) end # nav menus @nav_menu = .new({ name: 'Main Menu', slug: 'main_menu' }) if @nav_menu.save post_types.all.each do |pt| if pt.slug == 'post' title = 'Sample Post' slug = 'sample-post' content = '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer pharetra ut augue in posuere. Nulla non malesuada dui. Sed egestas tortor ut purus tempor sodales. Duis non sollicitudin nulla, quis mollis neque. Integer sit amet augue ac neque varius auctor. Vestibulum malesuada leo leo, at semper libero efficitur nec. Etiam semper nisi ac nisi ullamcorper, sed tincidunt purus elementum. Mauris ac congue nibh. Quisque pretium eget leo nec suscipit. </p> <p> Vestibulum ultrices orci ut congue interdum. Morbi dolor nunc, imperdiet vel risus semper, tempor dapibus urna. Phasellus luctus pharetra enim quis volutpat. Integer tristique urna nec malesuada ullamcorper. Curabitur dictum, lectus id ultrices rhoncus, ante neque auctor erat, ut sodales nisi odio sit amet lorem. In hac habitasse platea dictumst. Quisque orci orci, hendrerit at luctus tristique, lobortis in diam. Curabitur ligula enim, rhoncus ut vestibulum a, consequat sit amet nisi. Aliquam bibendum fringilla ultrices. Aliquam erat volutpat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In justo mi, congue in rhoncus lobortis, facilisis in est. Nam et rhoncus purus. </p> <p> Sed sagittis auctor lectus at rutrum. Morbi ultricies felis mi, ut scelerisque augue facilisis eu. In molestie quam ex. Quisque ut sapien sed odio tempus imperdiet. In id accumsan massa. Morbi quis nunc ullamcorper, interdum enim eu, finibus purus. Vestibulum ac fermentum augue, at tempus ante. Aliquam ultrices, purus ut porttitor gravida, dui augue dignissim massa, ac tempor ante dolor at arcu. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse placerat risus est, eget varius mi ultricies in. Duis non odio ut felis dapibus eleifend. In fringilla enim lobortis placerat efficitur. </p> <p> Nulla sodales faucibus urna, quis viverra dolor facilisis sollicitudin. Aenean ac egestas nibh. Nam non tortor eget nibh scelerisque fermentum. Etiam ornare, nunc ut luctus mollis, ante dolor consectetur augue, non scelerisque odio est a nulla. Nullam cursus egestas nulla, nec commodo nibh suscipit ut. Mauris ut felis sem. Aenean at mi at nisi dictum blandit sit amet at erat. Etiam eget lobortis tellus. Curabitur in commodo arcu, at vehicula tortor. </p>' else title = 'Welcome' slug = 'welcome' content = "<p style='text-align: center;'><img width='155' height='155' src='https://camaleon.website/media/132/logo2.png' alt='logo' /></p><p><strong>Camaleon CMS</strong> is a free and open-source tool and a fexible content management system (CMS) based on <a href='https://rubyonrails.org'>Ruby on Rails</a>.</p> <p>With Camaleon you can do the following:</p> <ul> <li>Create instantly a lot of sites in the same installation</li> <li>Manage your content information in several languages</li> <li>Extend current functionality by plugins (MVC structure and no more echo or prints anywhere)</li> <li>Create or install different themes for each site</li> <li>Create your own structure without coding anything (adapt Camaleon as you want and not you for Camaleon)</li> <li>Create your store and start to sell your products using our plugins</li> <li>Avoid web attacks</li> <li>Compare the speed and enjoy the speed of your new Camaleon site</li> <li>Customize or create your themes for mobile support</li> <li>Support more visitors at the same time</li> <li>Manage your information with a panel like wordpress </li> <li>All urls are oriented for SEO</li> <li>Multiples roles of users</li> </ul>" end user = users.admin_scope.first unless user.present? user = users.admin_scope.create({ email: 'admin@local.com', username: 'admin', password: 'admin123', password_confirmation: 'admin123', first_name: 'Administrator' }) end post = pt.add_post({ title: title, slug: slug, content: content, user_id: user.id, status: 'published' }) @nav_menu.({ label: title, type: 'post', link: post.id }) end end get_anonymous_user end |
#set_default_user_roles(post_type = nil) ⇒ Object
auto create default user roles
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'app/models/concerns/camaleon_cms/site_default_settings.rb', line 43 def set_default_user_roles(post_type = nil) user_role = user_roles.where({ slug: 'admin', term_group: -1 }).first_or_create({ name: 'Administrator', description: 'Default roles admin' }) if user_role.valid? d = {} m = {} pts = post_types.all.pluck(:id) CamaleonCms::UserRole::ROLES[:post_type].each { |value| d[value[:key]] = pts } CamaleonCms::UserRole::ROLES[:manager].each { |value| m[value[:key]] = 1 } user_role.("_post_type_#{id}", d || {}) user_role.("_manager_#{id}", m || {}) end user_role = user_roles.where({ slug: 'editor' }).first_or_create({ name: 'Editor', description: 'Editor Role' }) if user_role.valid? d = {} if post_type.present? d = user_role.("_post_type_#{id}", {}) CamaleonCms::UserRole::ROLES[:post_type].each do |value| value_old = d[value[:key].to_sym] || [] d[value[:key].to_sym] = value_old + [post_type.id] end else pts = post_types.all.pluck(:id) CamaleonCms::UserRole::ROLES[:post_type].each { |value| d[value[:key]] = pts } end user_role.("_post_type_#{id}", d || {}) end user_role = user_roles.where({ slug: 'contributor' }).first_or_create({ name: 'Contributor', description: 'Contributor Role' }) if user_role.valid? d = {} if post_type.present? d = user_role.("_post_type_#{id}", {}) CamaleonCms::UserRole::ROLES[:post_type].each do |value| value_old = d[value[:key].to_sym] || [] d[value[:key].to_sym] = value_old + [post_type.id] if value[:key].to_s == 'edit' end else pts = post_types.all.pluck(:id) CamaleonCms::UserRole::ROLES[:post_type].each { |value| d[value[:key]] = pts if value[:key].to_s == 'edit' } end user_role.("_post_type_#{id}", d || {}) end return if post_type.present? user_role = user_roles.where({ slug: 'client', term_group: -1 }).first_or_create({ name: 'Client', description: 'Default roles client' }) return unless user_role.valid? user_role.("_post_type_#{id}", {}) user_role.("_manager_#{id}", {}) end |