├── VERSION ├── config ├── routes.rb ├── environment.rb ├── roles.yml ├── boot.rb ├── cms_routes.rb ├── database.yml ├── cms │ └── fortress │ │ └── global_settings.yml ├── secrets.yml ├── initializers │ ├── secret_token.rb │ └── cms_fortress.rb ├── environments │ ├── development.rb │ └── test.rb ├── application.rb └── locales │ ├── devise.en.yml │ ├── devise.de.yml │ ├── en.yml │ ├── da.yml │ ├── fr.yml │ ├── it.yml │ ├── ja.yml │ ├── nl.yml │ ├── pl.yml │ ├── sv.yml │ ├── pt-BR.yml │ ├── ru.yml │ ├── zh-CN.yml │ ├── es.yml │ └── de.yml ├── lib ├── assets │ └── .keep ├── tasks │ └── .keep ├── cms │ └── fortress │ │ ├── routing.rb │ │ ├── devise.rb │ │ ├── auth.rb │ │ ├── pages_controller_methods.rb │ │ ├── comfortable_mexican_sofa.rb │ │ ├── file_methods.rb │ │ ├── sites_controller_methods.rb │ │ ├── site_methods.rb │ │ ├── content_renderer.rb │ │ ├── routes │ │ └── admin.rb │ │ ├── page_methods.rb │ │ ├── rails │ │ └── engine.rb │ │ └── application_controller_methods.rb ├── generators │ └── cms │ │ ├── fortress │ │ ├── USAGE │ │ ├── upgrade │ │ │ ├── USAGE │ │ │ └── upgrade_generator.rb │ │ ├── templates │ │ │ └── README │ │ └── fortress_generator.rb │ │ └── comfy │ │ └── comfy_generator.rb ├── cms-fortress.rb └── comfortable_mexican_sofa │ └── fixture │ └── page.rb ├── app ├── views │ ├── cms │ │ └── fortress │ │ │ ├── admin │ │ │ ├── _left_nav.html.haml │ │ │ ├── _topnav.html.haml │ │ │ ├── _left_contents_nav.html.haml │ │ │ ├── _left_designs_nav.html.haml │ │ │ ├── _left_settings_nav.html.haml │ │ │ ├── roles.html.haml │ │ │ ├── users.html.haml │ │ │ ├── unauthorised.html.haml │ │ │ ├── settings.html.haml │ │ │ ├── design.html.haml │ │ │ ├── contents.html.haml │ │ │ └── dashboard.html.haml │ │ │ ├── users │ │ │ ├── sessions │ │ │ │ ├── .DS_Store │ │ │ │ └── new.html.haml │ │ │ ├── new.html.haml │ │ │ ├── edit.html.haml │ │ │ ├── _form.html.haml │ │ │ ├── passwords │ │ │ │ ├── new.html.haml │ │ │ │ └── edit.html.haml │ │ │ └── index.html.haml │ │ │ ├── shared │ │ │ ├── _page_extend_js.html.haml │ │ │ ├── _navbar.html.haml │ │ │ ├── _page_extend.html.haml │ │ │ ├── _media_items.html.haml │ │ │ ├── _mediaboxes.html.haml │ │ │ ├── _dashboard_widget.html.haml │ │ │ └── _menu.html.haml │ │ │ ├── roles │ │ │ ├── _form.html.haml │ │ │ ├── new.html.haml │ │ │ ├── edit.html.haml │ │ │ ├── index.html.haml │ │ │ └── show.html.haml │ │ │ └── themes │ │ │ └── wide │ │ │ ├── _body.html.haml │ │ │ └── _menu.html.haml │ ├── comfy │ │ └── admin │ │ │ └── cms │ │ │ ├── partials │ │ │ └── _body_before.html.haml │ │ │ └── pages │ │ │ ├── edit.html.haml │ │ │ └── _form.html.haml │ ├── layouts │ │ ├── comfy │ │ │ └── admin │ │ │ │ └── cms │ │ │ │ ├── _footer.html.haml │ │ │ │ ├── _body.html.haml │ │ │ │ ├── _head.html.haml │ │ │ │ └── _left.html.haml │ │ └── cms │ │ │ └── fortress │ │ │ └── session.html.haml │ └── devise │ │ └── shared │ │ └── _links.html.haml ├── helpers │ ├── cms │ │ └── fortress │ │ │ ├── roles_helper.rb │ │ │ ├── sprocket_helper.rb │ │ │ └── application_helper.rb │ └── comfy │ │ └── admin │ │ └── cms │ │ └── pages_helper.rb ├── models │ ├── cms │ │ ├── fortress.rb │ │ └── fortress │ │ │ ├── role_detail.rb │ │ │ ├── error.rb │ │ │ ├── settings.rb │ │ │ ├── role.rb │ │ │ └── user.rb │ └── cms_ability.rb ├── assets │ ├── javascripts │ │ ├── cms │ │ │ └── fortress │ │ │ │ ├── themes │ │ │ │ └── wide.js.erb │ │ │ │ ├── site_selector.js.coffee │ │ │ │ └── media.js.coffee │ │ └── html5shiv.js │ └── stylesheets │ │ └── cms │ │ └── fortress │ │ ├── admin_overrides.css │ │ ├── themes │ │ └── wide.css.scss │ │ └── session.scss └── controllers │ └── cms │ └── fortress │ ├── users │ ├── sessions_controller.rb │ └── passwords_controller.rb │ ├── admin_controller.rb │ ├── roles_controller.rb │ └── users_controller.rb ├── Gemfile ├── .document ├── bin ├── rake ├── bundle └── rails ├── test ├── fixtures │ ├── comfy │ │ └── cms │ │ │ ├── categorizations.yml │ │ │ ├── categories.yml │ │ │ ├── sites.yml │ │ │ ├── snippets.yml │ │ │ ├── files.yml │ │ │ ├── blocks.yml │ │ │ ├── revisions.yml │ │ │ ├── layouts.yml │ │ │ └── pages.yml │ └── cms │ │ └── fortress │ │ ├── users.yml │ │ ├── roles.yml │ │ └── role_details.yml ├── models │ └── comfy │ │ └── cms │ │ ├── settings_test.rb │ │ └── page_test.rb ├── integration │ └── cms │ │ └── fortress │ │ └── users_controller_test.rb ├── test_helper.rb └── controllers │ ├── cms │ └── fortress │ │ ├── users_controller_test.rb │ │ └── roles_controller_test.rb │ └── comfy │ └── admin │ └── cms │ └── pages_controller_test.rb ├── docs └── screens │ ├── compact-layout-01.png │ ├── compact-layout-02.png │ ├── files-integration-01.png │ ├── files-integration-02.png │ ├── files-integration-03.png │ └── files-integration-04.png ├── config.ru ├── db └── migrate │ ├── 05_add_caching_info_to_pages.rb │ ├── 04_create_cms_page_workflows.rb │ ├── 02_create_cms_fortress_role_details.rb │ ├── 06_add_type_to_users.rb │ ├── 03_create_cms_fortress_roles.rb │ ├── 08_relax_user_uniqueness_on_email_and_site_id.rb │ ├── 07_integrate_workflow_into_cms_pages.rb │ └── 01_devise_create_cms_fortress_users.rb ├── .travis.yml ├── Rakefile ├── CONTRIBUTING.rdoc ├── LICENSE.txt ├── .gitignore └── cms-fortress.gemspec /VERSION: -------------------------------------------------------------------------------- 1 | 1.3.15 2 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/cms/fortress/admin/_left_nav.html.haml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/cms/fortress/admin/_topnav.html.haml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gemspec 4 | -------------------------------------------------------------------------------- /app/views/cms/fortress/admin/_left_contents_nav.html.haml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/cms/fortress/admin/_left_designs_nav.html.haml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/cms/fortress/admin/_left_settings_nav.html.haml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/cms/fortress/routing.rb: -------------------------------------------------------------------------------- 1 | require_relative 'routes/admin' 2 | -------------------------------------------------------------------------------- /app/views/cms/fortress/admin/roles.html.haml: -------------------------------------------------------------------------------- 1 | %h2= t('cms.fortress.admin.roles') 2 | -------------------------------------------------------------------------------- /app/views/cms/fortress/admin/users.html.haml: -------------------------------------------------------------------------------- 1 | %h2= t('cms.fortress.admin.users') 2 | -------------------------------------------------------------------------------- /.document: -------------------------------------------------------------------------------- 1 | lib/**/*.rb 2 | bin/* 3 | - 4 | features/**/*.feature 5 | LICENSE.txt 6 | -------------------------------------------------------------------------------- /app/helpers/cms/fortress/roles_helper.rb: -------------------------------------------------------------------------------- 1 | module Cms::Fortress::RolesHelper 2 | end 3 | -------------------------------------------------------------------------------- /lib/cms/fortress/devise.rb: -------------------------------------------------------------------------------- 1 | Devise.setup do |config| 2 | config.scoped_views = true 3 | end 4 | -------------------------------------------------------------------------------- /app/views/comfy/admin/cms/partials/_body_before.html.haml: -------------------------------------------------------------------------------- 1 | = render :partial => 'cms/fortress/shared/menu' 2 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /test/fixtures/comfy/cms/categorizations.yml: -------------------------------------------------------------------------------- 1 | default: 2 | category: default 3 | categorized: default (Comfy::Cms::File) -------------------------------------------------------------------------------- /app/models/cms/fortress.rb: -------------------------------------------------------------------------------- 1 | module Cms::Fortress 2 | def self.table_name_prefix 3 | 'cms_fortress_' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /app/views/cms/fortress/admin/unauthorised.html.haml: -------------------------------------------------------------------------------- 1 | .alert.alert-danger 2 | %h3= t('cms.fortress.admin.not_authorized') 3 | -------------------------------------------------------------------------------- /test/fixtures/comfy/cms/categories.yml: -------------------------------------------------------------------------------- 1 | default: 2 | site: default 3 | label: Default 4 | categorized_type: Comfy::Cms::File -------------------------------------------------------------------------------- /docs/screens/compact-layout-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melvinsembrano/cms-fortress/HEAD/docs/screens/compact-layout-01.png -------------------------------------------------------------------------------- /docs/screens/compact-layout-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melvinsembrano/cms-fortress/HEAD/docs/screens/compact-layout-02.png -------------------------------------------------------------------------------- /docs/screens/files-integration-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melvinsembrano/cms-fortress/HEAD/docs/screens/files-integration-01.png -------------------------------------------------------------------------------- /docs/screens/files-integration-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melvinsembrano/cms-fortress/HEAD/docs/screens/files-integration-02.png -------------------------------------------------------------------------------- /docs/screens/files-integration-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melvinsembrano/cms-fortress/HEAD/docs/screens/files-integration-03.png -------------------------------------------------------------------------------- /docs/screens/files-integration-04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melvinsembrano/cms-fortress/HEAD/docs/screens/files-integration-04.png -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /app/views/cms/fortress/users/sessions/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melvinsembrano/cms-fortress/HEAD/app/views/cms/fortress/users/sessions/.DS_Store -------------------------------------------------------------------------------- /app/views/cms/fortress/admin/settings.html.haml: -------------------------------------------------------------------------------- 1 | %h3= t('cms.fortress.admin.users') 2 | %p 3 | %small= t('cms.fortress.admin.settings_dashboard') 4 | %hr 5 | 6 | -------------------------------------------------------------------------------- /test/fixtures/comfy/cms/sites.yml: -------------------------------------------------------------------------------- 1 | default: 2 | label: Default Site 3 | identifier: default-site 4 | hostname: test.host 5 | path: 6 | is_mirrored: false 7 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path('../../config/application', __FILE__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /app/views/cms/fortress/admin/design.html.haml: -------------------------------------------------------------------------------- 1 | %h3= t('cms.fortress.admin.design_dashboard') 2 | %p 3 | %small= t('cms.fortress.admin.design_related_information') 4 | %hr 5 | -------------------------------------------------------------------------------- /app/views/cms/fortress/shared/_page_extend_js.html.haml: -------------------------------------------------------------------------------- 1 | :coffeescript 2 | dateControl = $("#page_published_date") 3 | dateControl.datepicker(dateFormat: "d MM, yy") 4 | 5 | -------------------------------------------------------------------------------- /app/views/cms/fortress/admin/contents.html.haml: -------------------------------------------------------------------------------- 1 | %h3= t('cms.fortress.admin.content_dashboard') 2 | %p 3 | %small= t('cms.fortress.admin.content_related_information') 4 | %hr 5 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /test/fixtures/comfy/cms/snippets.yml: -------------------------------------------------------------------------------- 1 | default: 2 | site: default 3 | label: Default Snippet 4 | identifier: default 5 | content: default_snippet_content 6 | position: 0 7 | -------------------------------------------------------------------------------- /app/assets/javascripts/cms/fortress/themes/wide.js.erb: -------------------------------------------------------------------------------- 1 | 2 | //= require '../site_selector' 3 | $(document).ready( function() { 4 | $('.dropdown-toggle').dropdown(); 5 | }); 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/controllers/cms/fortress/users/sessions_controller.rb: -------------------------------------------------------------------------------- 1 | class Cms::Fortress::Users::SessionsController < Devise::SessionsController 2 | layout 'cms/fortress/session' 3 | 4 | end 5 | -------------------------------------------------------------------------------- /app/controllers/cms/fortress/users/passwords_controller.rb: -------------------------------------------------------------------------------- 1 | class Cms::Fortress::Users::PasswordsController < Devise::PasswordsController 2 | layout 'cms/fortress/session' 3 | 4 | end 5 | 6 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the rails application 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the rails application 5 | Cms::Fortress::Application.initialize! 6 | -------------------------------------------------------------------------------- /lib/generators/cms/fortress/USAGE: -------------------------------------------------------------------------------- 1 | Description: 2 | Explain the generator 3 | 4 | Example: 5 | rails generate fortress Thing 6 | 7 | This will create: 8 | what/will/it/create 9 | -------------------------------------------------------------------------------- /lib/generators/cms/fortress/upgrade/USAGE: -------------------------------------------------------------------------------- 1 | Description: 2 | Explain the generator 3 | 4 | Example: 5 | rails generate upgrade Thing 6 | 7 | This will create: 8 | what/will/it/create 9 | -------------------------------------------------------------------------------- /db/migrate/05_add_caching_info_to_pages.rb: -------------------------------------------------------------------------------- 1 | class AddCachingInfoToPages < ActiveRecord::Migration 2 | def change 3 | add_column :comfy_cms_pages, :cached_timeout, :integer, :default => 0 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /config/roles.yml: -------------------------------------------------------------------------------- 1 | contents: 2 | - pages 3 | - files 4 | - page.review 5 | - page.publish 6 | - page.draft 7 | designs: 8 | - layouts 9 | - snippets 10 | settings: 11 | - sites 12 | - roles 13 | - users 14 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | # Set up gems listed in the Gemfile. 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | 4 | require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) 5 | File.exists?(ENV['BUNDLE_GEMFILE']) 6 | -------------------------------------------------------------------------------- /config/cms_routes.rb: -------------------------------------------------------------------------------- 1 | Cms::Fortress::Application.routes.draw do 2 | 3 | cms_fortress_routes :path => '/cms-admin' 4 | comfy_route :cms_admin, :path => '/cms-admin' 5 | 6 | comfy_route :cms, :path => '/', :sitemap => false 7 | end 8 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: sqlite3 3 | database: db/development.sqlite3 4 | pool: 5 5 | timeout: 10000 6 | 7 | test: 8 | adapter: sqlite3 9 | database: db/test.sqlite3 10 | pool: 5 11 | timeout: 10000 12 | -------------------------------------------------------------------------------- /test/fixtures/comfy/cms/files.yml: -------------------------------------------------------------------------------- 1 | default: 2 | site: default 3 | block: 4 | label: Default File 5 | file_file_name: sample.jpg 6 | file_content_type: image/jpeg 7 | file_file_size: 20099 8 | description: Default Description 9 | position: 0 -------------------------------------------------------------------------------- /config/cms/fortress/global_settings.yml: -------------------------------------------------------------------------------- 1 | default: &default 2 | title: "CMS Fortress" 3 | title_link: "#" 4 | use_tinymce: true 5 | 6 | development: 7 | <<: *default 8 | 9 | production: 10 | <<: *default 11 | 12 | test: 13 | <<: *default 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 2.1.5 4 | 5 | install: bundle install --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle} 6 | 7 | branches: 8 | only: 9 | - master 10 | 11 | # cache: bundler 12 | before_install: 13 | - gem install bundler 14 | -------------------------------------------------------------------------------- /lib/cms/fortress/auth.rb: -------------------------------------------------------------------------------- 1 | module Cms 2 | module Fortress 3 | module Auth 4 | def authenticate 5 | unless current_cms_fortress_user 6 | redirect_to new_cms_fortress_user_session_path 7 | end 8 | end 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /app/models/cms/fortress/role_detail.rb: -------------------------------------------------------------------------------- 1 | class Cms::Fortress::RoleDetail < ActiveRecord::Base 2 | self.table_name = "cms_fortress_role_details" 3 | 4 | belongs_to :role 5 | 6 | default_scope { order(:command) } 7 | 8 | def can_manage? 9 | can_create? 10 | end 11 | 12 | end 13 | -------------------------------------------------------------------------------- /app/views/cms/fortress/roles/_form.html.haml: -------------------------------------------------------------------------------- 1 | = form.text_field :name 2 | = form.text_area :description, :rows => 2 3 | 4 | = form.form_group :class => 'form-actions' do 5 | = form.submit @cms_fortress_role.new_record? ? t('cms.fortress.create') : t('cms.fortress.update'), :class => 'btn btn-primary' 6 | 7 | -------------------------------------------------------------------------------- /app/views/cms/fortress/users/new.html.haml: -------------------------------------------------------------------------------- 1 | .page-header 2 | = link_to t('cms.fortress.cancel'), cms_fortress_users_path, class: 'btn btn-default btn-sm, pull-right' 3 | 4 | %h3= t('cms.fortress.users.new_title') 5 | 6 | = comfy_form_for @cms_fortress_user, url: {action: :create} do |form| 7 | = render form 8 | 9 | -------------------------------------------------------------------------------- /db/migrate/04_create_cms_page_workflows.rb: -------------------------------------------------------------------------------- 1 | class CreateCmsPageWorkflows < ActiveRecord::Migration 2 | def change 3 | create_table :cms_page_workflows do |t| 4 | t.integer :cms_page_id 5 | t.integer :status_id 6 | t.date :published_date 7 | 8 | t.timestamps 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /app/views/cms/fortress/users/edit.html.haml: -------------------------------------------------------------------------------- 1 | .page-header 2 | = link_to t('cms.fortress.cancel'), cms_fortress_users_path, class: 'btn btn-default btn-sm pull-right' 3 | 4 | %h3= t('cms.fortress.users.new_title') 5 | 6 | = comfy_form_for @cms_fortress_user, url: {action: :update} do |form| 7 | = render form 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/views/cms/fortress/roles/new.html.haml: -------------------------------------------------------------------------------- 1 | .page-header 2 | .btn-group.pull-right 3 | = link_to t('cms.fortress.cancel'), cms_fortress_roles_path, :class => 'btn btn-default' 4 | 5 | %h3= t('cms.fortress.roles.new_title') 6 | 7 | = comfy_form_for @cms_fortress_role, url: {action: :create} do |form| 8 | = render form 9 | 10 | -------------------------------------------------------------------------------- /app/views/cms/fortress/roles/edit.html.haml: -------------------------------------------------------------------------------- 1 | .page-header 2 | .btn-group.pull-right 3 | = link_to t('cms.fortress.cancel'), cms_fortress_roles_path, :class => 'btn btn-default' 4 | 5 | %h3= t('cms.fortress.roles.edit_title') 6 | 7 | = comfy_form_for @cms_fortress_role, url: {action: :update} do |form| 8 | = render form 9 | 10 | -------------------------------------------------------------------------------- /test/fixtures/cms/fortress/users.yml: -------------------------------------------------------------------------------- 1 | one: 2 | email: 'bla@blub.de' 3 | encrypted_password: asdf '_blank' 12 | %span.version= ComfortableMexicanSofa::VERSION 13 | -------------------------------------------------------------------------------- /db/migrate/02_create_cms_fortress_role_details.rb: -------------------------------------------------------------------------------- 1 | class CreateCmsFortressRoleDetails < ActiveRecord::Migration 2 | def change 3 | create_table :cms_fortress_role_details do |t| 4 | t.string :name 5 | t.string :command 6 | t.boolean :can_create 7 | t.boolean :can_update 8 | t.boolean :can_delete 9 | t.boolean :can_view 10 | t.integer :role_id 11 | 12 | t.timestamps 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/cms/fortress/pages_controller_methods.rb: -------------------------------------------------------------------------------- 1 | module Cms 2 | module Fortress 3 | module PagesControllerMethods 4 | 5 | def transit_to_state 6 | @page.send(params.fetch(:transition)) if params[:transition].present? 7 | end 8 | 9 | def self.included(base) 10 | base.class_eval do 11 | before_action :transit_to_state, only: [:create, :update] 12 | end 13 | end 14 | 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /db/migrate/06_add_type_to_users.rb: -------------------------------------------------------------------------------- 1 | class AddTypeToUsers < ActiveRecord::Migration 2 | def change 3 | add_column :cms_fortress_users, :type_id, :integer 4 | add_column :cms_fortress_users, :site_id, :integer 5 | add_column :cms_fortress_roles, :site_id, :integer 6 | add_column :cms_fortress_role_details, :site_id, :integer 7 | add_column :cms_page_workflows, :site_id, :integer 8 | 9 | Cms::Fortress::User.update_all(type_id: 1) 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /app/assets/javascripts/cms/fortress/site_selector.js.coffee: -------------------------------------------------------------------------------- 1 | class SiteSelector 2 | constructor: -> 3 | @initialize_event_handler() 4 | 5 | initialize_event_handler: -> 6 | @site_selector() 7 | 8 | site_selector: -> 9 | ($ '#js_site_selector').on 'change', (event) => 10 | page_id = ($ event.target).val() 11 | locale = location.search 12 | location.href = "/cms-admin/sites/#{page_id}/pages#{locale}" 13 | 14 | $ -> 15 | site_selector = new SiteSelector 16 | -------------------------------------------------------------------------------- /app/views/cms/fortress/admin/dashboard.html.haml: -------------------------------------------------------------------------------- 1 | .page-header 2 | %h2 3 | = "#{ t(".title") } /" 4 | = @site.label 5 | 6 | .container-fluid 7 | .row 8 | .col-sm-6 9 | = dashboard_widget t(".draft_widget"), @site.pages.drafted.order(updated_at: :desc).limit(5) 10 | = dashboard_widget t(".updated_pages"), @site.pages.order(updated_at: :desc).limit(5) 11 | .col-sm-6 12 | = dashboard_widget t(".reviewed_widget"), @site.pages.reviewed.order(updated_at: :desc).limit(5) 13 | -------------------------------------------------------------------------------- /test/models/comfy/cms/settings_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class Cms::Fortress::SettingsTest < ActiveSupport::TestCase 4 | 5 | test "it_should_raise_MissingConfigFile_exception" do 6 | assert_raises (Cms::Fortress::Error::MissingSettingsFile) { 7 | Cms::Fortress::Settings.new(:bla) 8 | } 9 | end 10 | 11 | test "test_it_should_return_the_config_file" do 12 | settings = Cms::Fortress::Settings.new(:global_settings) 13 | assert_equal(settings.title, 'CMS Fortress') 14 | end 15 | 16 | end 17 | -------------------------------------------------------------------------------- /app/views/cms/fortress/shared/_navbar.html.haml: -------------------------------------------------------------------------------- 1 | %nav.navbar.navbar-default(role="navigation") 2 | .container-fluid 3 | .navbar-header 4 | %button.navbar-toggle(type="button" data-toggle="collapse" data-target="#main-nav") 5 | %span.sr-only= t('cms.fortress.toggle_navigation') 6 | %span.icon-bar 7 | %span.icon-bar 8 | %span.icon-bar 9 | = link_to settings.title, settings.title_link, class: 'navbar-brand' 10 | 11 | .collapse.navbar-collapse#main-nav 12 | %ul.nav.navbar-nav 13 | 14 | -------------------------------------------------------------------------------- /lib/cms/fortress/comfortable_mexican_sofa.rb: -------------------------------------------------------------------------------- 1 | ComfortableMexicanSofa.configure do |config| 2 | config.admin_auth = 'Cms::Fortress::Auth' 3 | config.cms_title = 'CMS Fortress (Powered by ComfortableMexicanSofa)' 4 | end 5 | 6 | ComfortableMexicanSofa::ViewHooks.add(:header, 'cms/fortress/shared/admin_topnav') 7 | # ComfortableMexicanSofa::ViewHooks.add(:navigation, '/layouts/admin/navigation') 8 | # ComfortableMexicanSofa::ViewHooks.add(:html_head, '/layouts/admin/html_head') 9 | # ComfortableMexicanSofa::ViewHooks.add(:page_form, '/layouts/admin/page_form') 10 | -------------------------------------------------------------------------------- /test/integration/cms/fortress/users_controller_test.rb: -------------------------------------------------------------------------------- 1 | # http://api.rubyonrails.org/classes/ActionDispatch/IntegrationTest.html 2 | require 'test_helper' 3 | 4 | class Cms::Fortress::UsersControllerIntegrationTest < ActionDispatch::IntegrationTest 5 | setup do 6 | @comfy_cms_site = comfy_cms_sites(:default) 7 | end 8 | 9 | test "it should redirect to login if unauthenticated" do 10 | get "/cms-admin/" 11 | follow_redirect! 12 | follow_redirect! 13 | assert_equal 200, status 14 | assert_equal "/cms-admin/login", path 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/views/layouts/cms/fortress/session.html.haml: -------------------------------------------------------------------------------- 1 | !!! 2 | %html{:lang => "en"} 3 | %head 4 | %meta{:charset => "utf-8"}/ 5 | %title= t('cms.fortress.title') 6 | %meta{:content => "width=device-width, initial-scale=1.0", :name => "viewport"}/ 7 | %meta{:content => "", :name => "description"}/ 8 | %meta{:content => "", :name => "author"}/ 9 | = stylesheet_link_tag 'cms/fortress/session.css' 10 | / HTML5 shim, for IE6-8 support of HTML5 elements 11 | /[if lt IE 9] 12 | = javascript_include_tag 'html5shiv.js' 13 | %body 14 | = yield 15 | -------------------------------------------------------------------------------- /test/fixtures/cms/fortress/roles.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html 2 | 3 | Administrator: 4 | name: Administrator 5 | description: Administrator 6 | site: default 7 | 8 | Author: 9 | name: Author 10 | description: Author 11 | site: default 12 | 13 | Contributor: 14 | name: Contributor 15 | description: Contributor 16 | site: default 17 | 18 | one: 19 | name: MyString 20 | description: MyText 21 | site: default 22 | 23 | two: 24 | name: MyString 25 | description: MyText 26 | site: default 27 | -------------------------------------------------------------------------------- /app/models/cms/fortress/error.rb: -------------------------------------------------------------------------------- 1 | module Cms::Fortress::Error 2 | def self.log_error(name, message) 3 | Rails.logger.fatal("[ERROR:] in #{name} with message: #{message}\n\n") 4 | end 5 | 6 | class MissingRoleConfigFile < StandardError 7 | def initialize 8 | Cms::Fortress::Error.log_error(self, "missing the roles.yml file in config/roles.yml") 9 | end 10 | end 11 | 12 | class MissingSettingsFile < StandardError 13 | def initialize 14 | Cms::Fortress::Error.log_error(self, "missing cms-fortress settings file") 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /app/views/cms/fortress/users/_form.html.haml: -------------------------------------------------------------------------------- 1 | = form.text_field :last_name 2 | = form.text_field :first_name 3 | = form.text_field :email 4 | 5 | - unless @super_user 6 | = form.select :role_id, @site.roles.collect {|role| [role.name, role.id]} 7 | - if @cms_fortress_user.new_record? 8 | = form.hidden_field :type_id 9 | 10 | = form.password_field :password 11 | = form.password_field :password_confirmation 12 | 13 | = form.form_group :class => 'form-actions' do 14 | = form.submit @cms_fortress_user.new_record? ? t('cms.fortress.create') : t('cms.fortress.update'), :class => 'btn btn-primary' 15 | 16 | -------------------------------------------------------------------------------- /lib/cms/fortress/file_methods.rb: -------------------------------------------------------------------------------- 1 | module Cms 2 | module Fortress 3 | module FileMethods 4 | 5 | def self.included(base) 6 | 7 | base.class_eval do 8 | image_mimetypes = %w(gif jpeg pjpeg png tiff).collect{|subtype| "image/#{subtype}"} 9 | video_mimetypes = %w(mp4 ogg webm).collect{|subtype| "video/#{subtype}"} 10 | 11 | scope :videos, -> { where(:file_content_type => video_mimetypes) } 12 | scope :others, -> { where('file_content_type NOT IN (?)', image_mimetypes + video_mimetypes) } 13 | 14 | end 15 | 16 | end 17 | 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/cms/fortress/sites_controller_methods.rb: -------------------------------------------------------------------------------- 1 | require 'active_support/concern' 2 | module Cms 3 | module Fortress 4 | module SiteControllerMethods 5 | extend ActiveSupport::Concern 6 | 7 | included do 8 | before_action do 9 | authorize! :manage, Comfy::Cms::Site 10 | end 11 | before_action only: [:new, :create] do 12 | raise CanCan::AccessDenied.new("You are not allowed to create a site.") unless current_cms_fortress_user.type.eql?(:super_user) 13 | end 14 | end 15 | 16 | module ClassMethods 17 | 18 | end 19 | 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /app/models/cms/fortress/settings.rb: -------------------------------------------------------------------------------- 1 | class Cms::Fortress::Settings < OpenStruct 2 | def initialize(config_file_base_name) 3 | @config_file_base_name = config_file_base_name 4 | super(load_settings) 5 | end 6 | 7 | private 8 | 9 | def load_settings 10 | raise Cms::Fortress::Error::MissingSettingsFile unless config_file_exists? 11 | YAML.load(ERB.new(File.read(Rails.root.join("config/cms/fortress", "#{@config_file_base_name}.yml"))).result)[Rails.env] 12 | end 13 | 14 | def config_file_exists? 15 | File.exist?(File.join(Rails.root, "config/cms/fortress", "#{@config_file_base_name}.yml")) 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /app/views/cms/fortress/shared/_page_extend.html.haml: -------------------------------------------------------------------------------- 1 | - if Cms::Fortress.configuration.enable_page_workflow && can?(:manage, 'contents.page.schedule') && !@page.new_record? 2 | = form.text_field :published_date, label: (@page.published? ? t('cms.fortress.published_date') : t('cms.fortress.schedule_date')), control_col: "col-sm-3", class: "status-control", :data => {:utc_date => (@page.published_date.nil? ? Time.now : @page.published_date).strftime("%d %B, %Y") } 3 | 4 | - if Cms::Fortress.configuration.enable_page_caching 5 | = form.select :cached_timeout, cached_timeout_for_select, {label: t('cms.fortress.cache_timeout'), control_col: "col-sm-3"}, {class: 'status-control'} 6 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | require 'bundler' 3 | Bundler.setup 4 | 5 | require 'rake/testtask' 6 | require 'rdoc/task' 7 | 8 | Rake::TestTask.new do |t| 9 | t.libs << 'test' 10 | t.test_files = FileList['test/**/*_test.rb'] 11 | t.verbose = false 12 | end 13 | 14 | require_relative 'config/application' 15 | Cms::Fortress::Application.load_tasks 16 | 17 | task :default => :test 18 | 19 | Rake::RDocTask.new do |rdoc| 20 | version = File.exist?('VERSION') ? File.read('VERSION') : "" 21 | 22 | rdoc.rdoc_dir = 'rdoc' 23 | rdoc.title = "cms-fortress #{version}" 24 | rdoc.rdoc_files.include('README*') 25 | rdoc.rdoc_files.include('lib/**/*.rb') 26 | end 27 | -------------------------------------------------------------------------------- /app/views/cms/fortress/users/passwords/new.html.haml: -------------------------------------------------------------------------------- 1 | = render :partial => 'cms/fortress/shared/navbar' 2 | .container 3 | .row 4 | .col-sm-6.col-sm-offset-3 5 | = form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post, role: 'form', class: 'form-reset-password' }) do |f| 6 | %h3= t('login.forgot_your_password') 7 | = devise_error_messages! 8 | .form-group 9 | = f.label :email 10 | = f.email_field :email, autofocus: true, class: 'form-control' 11 | 12 | = f.submit t('login.send_me_reset_password_instructions'), class: 'btn btn-default' 13 | 14 | = render "devise/shared/links" 15 | -------------------------------------------------------------------------------- /lib/generators/cms/comfy/comfy_generator.rb: -------------------------------------------------------------------------------- 1 | require 'rails/generators' 2 | require 'generators/comfy/cms/cms_generator' 3 | 4 | class Cms::ComfyGenerator < Comfy::Generators::CmsGenerator 5 | spec = Gem::Specification.find_by_name("comfortable_mexican_sofa") 6 | source_root spec.gem_dir # File.expand_path('../../../../..', __FILE__) 7 | 8 | def generate_routing 9 | route_string = " comfy_route :cms_admin, :path => '/cms-admin'\n\n" 10 | route_string << " # Make sure this routeset is defined last\n" 11 | route_string << " comfy_route :cms, :path => '/', :sitemap => false\n" 12 | route route_string[2..-1] 13 | end 14 | 15 | def show_readme 16 | 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /CONTRIBUTING.rdoc: -------------------------------------------------------------------------------- 1 | = Contributing to cms-fortress 2 | 3 | * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet. 4 | * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it. 5 | * Fork the project. 6 | * Start a feature/bugfix branch. 7 | * Commit and push until you are happy with your contribution. 8 | * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally. 9 | * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it. -------------------------------------------------------------------------------- /config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rake secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | test: 14 | secret_key_base: a8fb39f9880722d803b8c64f445123d50e9d408a8a5b9f70072849ff8bafd51b6d615f549b3a5d08a55f66f52384e2aa6fca0d3c24ea19a2340b3c6daa1d590b 15 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV['RAILS_ENV'] ||= 'test' 2 | require File.expand_path('../../config/environment', __FILE__) 3 | require 'rails/test_help' 4 | require 'rails/all' 5 | require 'cms-fortress' 6 | require 'minitest/pride' 7 | require 'minitest/reporters' 8 | 9 | # test without creating a test database. 10 | ActiveRecord::Base.establish_connection( 11 | :adapter => 'sqlite3', 12 | :database => ':memory:' 13 | ) 14 | 15 | MiniTest::Reporters.use! [Minitest::Reporters::SpecReporter.new] 16 | 17 | load File.dirname(__FILE__) + '/../db/schema.rb' 18 | 19 | class ActiveSupport::TestCase 20 | fixtures :all 21 | end 22 | 23 | class ActionController::TestCase 24 | include Devise::TestHelpers 25 | end 26 | -------------------------------------------------------------------------------- /app/views/cms/fortress/shared/_media_items.html.haml: -------------------------------------------------------------------------------- 1 | .row 2 | - media.each do |m| 3 | - if type.eql?(:image) 4 | .col-xs-6.col-md-3 5 | .thumbnail 6 | = image_item(m) 7 | .caption 8 | %p 9 | = image_styles(m) 10 | 11 | - elsif type.eql?(:video) 12 | .col-xs-6.col-md-3 13 | .thumbnail 14 | 15 | %a.editor-video(href='#{ m.file.url }') 16 | %video(width='128' height='90' data-video-title="#{ m.label }") 17 | %source(src="#{ m.file.url }") 18 | 19 | %p 20 | %strong= m.label 21 | %p 22 | %small 23 | = truncate m.description, length: 60 24 | 25 | 26 | -------------------------------------------------------------------------------- /db/migrate/03_create_cms_fortress_roles.rb: -------------------------------------------------------------------------------- 1 | class CreateCmsFortressRoles < ActiveRecord::Migration 2 | 3 | def migrate(direction) 4 | super 5 | 6 | # Create default users 7 | { 8 | :administrator => { 9 | 10 | }, 11 | :author => { 12 | 13 | }, 14 | :contributor => { 15 | 16 | } 17 | }.each do |k, roles| 18 | role = Cms::Fortress::Role.create!(:name => k.to_s.humanize, :description => k.to_s.humanize) 19 | role.load_defaults 20 | role.save 21 | end 22 | end 23 | 24 | 25 | def change 26 | create_table :cms_fortress_roles do |t| 27 | t.string :name 28 | t.text :description 29 | 30 | t.timestamps 31 | end 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /app/views/cms/fortress/shared/_mediaboxes.html.haml: -------------------------------------------------------------------------------- 1 | #media-box-dialog.modal.fade 2 | .modal-dialog 3 | .modal-content 4 | .modal-header 5 | %button(type="button" class="close" data-dismiss="modal" aria-hidden="true") x 6 | %h5.title= t('cms.fortress.image_selector') 7 | #modal-body.modal-body 8 | =# render partial: 'cms/fortress/shared/media_items', locals: {media: media} 9 | 10 | .modal-footer 11 | %small.muted 12 | = t('cms.fortress.insert_item') 13 | 14 | :coffeescript 15 | CmsFortress.media.imagesPath = "#{ media_files_path(:image) }" 16 | CmsFortress.media.videosPath = "#{ media_files_path(:video) }" 17 | CmsFortress.media.othersPath = "#{ media_files_path(:others) }" 18 | 19 | 20 | -------------------------------------------------------------------------------- /db/migrate/08_relax_user_uniqueness_on_email_and_site_id.rb: -------------------------------------------------------------------------------- 1 | class RelaxUserUniquenessOnEmailAndSiteId < ActiveRecord::Migration 2 | def migrate(direction) 3 | super 4 | # Create default Site 5 | Comfy::Cms::Site.reset_column_information 6 | Cms::Fortress::Role.reset_column_information 7 | Comfy::Cms::Site.create!(label: "Default", identifier: "default") 8 | # Create default cms-admin user 9 | Cms::Fortress::User.create!(:email => 'admin@cmsfortress.com', :password => '1234qwer', :password_confirmation => '1234qwer', :type_id => 1) if direction == :up 10 | end 11 | 12 | def change 13 | remove_index :cms_fortress_users, :email 14 | add_index :cms_fortress_users, [:email, :site_id], :unique => true 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /test/fixtures/comfy/cms/revisions.yml: -------------------------------------------------------------------------------- 1 | layout: 2 | record: default (Comfy::Cms::Layout) 3 | data: <%= { 4 | 'content' => 'revision {{cms:page:default_page_text}}', 5 | 'css' => 'revision css', 6 | 'js' => 'revision js' }.to_yaml.inspect %> 7 | 8 | page: 9 | record: default (Comfy::Cms::Page) 10 | data: <%= { 11 | 'blocks_attributes' => [ 12 | { 'identifier' => 'default_page_text', 13 | 'content' => 'revision page content' }, 14 | { 'identifier' => 'default_field_text', 15 | 'content' => 'revision field content'} 16 | ]}.to_yaml.inspect %> 17 | 18 | snippet: 19 | record: default (Comfy::Cms::Snippet) 20 | data: <%= { 21 | 'content' => 'revision content' }.to_yaml.inspect %> -------------------------------------------------------------------------------- /lib/generators/cms/fortress/upgrade/upgrade_generator.rb: -------------------------------------------------------------------------------- 1 | class Cms::Fortress::UpgradeGenerator < Rails::Generators::Base 2 | source_root File.expand_path('../../../../../..', __FILE__) 3 | 4 | def generate_migrations 5 | rake("cms_fortress_engine:install:migrations") 6 | end 7 | 8 | def copy_files 9 | log 'Copying files...' 10 | files = [ 11 | 'config/cms/fortress/global_settings.yml' 12 | ] 13 | files.each do |file| 14 | copy_file file, file unless File.exist?(file) 15 | end 16 | end 17 | 18 | def done 19 | # puts "\r\n\r\n!!! IMPORTANT NOTE: Review your existing users since they set to super users as default. Review and assign site roles accordingly." 20 | puts "Upgrade complete..." 21 | puts "\r\n\r\n" 22 | end 23 | 24 | end 25 | -------------------------------------------------------------------------------- /config/initializers/secret_token.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rake secret` to generate a secure secret key. 9 | 10 | # Make sure your secret_key_base is kept private 11 | # if you're sharing your code publicly. 12 | if defined?(Cms::Fortress::Application) 13 | Cms::Fortress::Application.config.secret_key_base = 'cbc6b791655e760b3088f30198289fdc9cc321c024d04b56b4f24ae65a53bb934002c7047e714af25d36be7d54db40e7965a298314f7f7d5f0bb72cc18db7080' 14 | end 15 | -------------------------------------------------------------------------------- /app/views/layouts/comfy/admin/cms/_body.html.haml: -------------------------------------------------------------------------------- 1 | %body#comfy{:class => "c-#{params[:controller].slugify} a-#{params[:action].slugify}"} 2 | 3 | = render 'comfy/admin/cms/partials/body_before' 4 | 5 | - if default_theme? 6 | .body-wrapper 7 | .left-column 8 | .left-column-content 9 | = render 'layouts/comfy/admin/cms/left' 10 | .right-column 11 | .right-column-content 12 | = render 'layouts/comfy/admin/cms/right' 13 | .center-column 14 | = render 'layouts/comfy/admin/cms/flash' 15 | .center-column-content 16 | = yield 17 | = render 'layouts/comfy/admin/cms/footer' 18 | 19 | 20 | 21 | - else 22 | = themed_partial('body') 23 | 24 | = render partial: 'cms/fortress/shared/mediaboxes' 25 | = render :partial => 'layouts/comfy/admin/cms/footer_js' 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/views/comfy/admin/cms/pages/edit.html.haml: -------------------------------------------------------------------------------- 1 | .page-header 2 | 3 | = link_to t('.revision', :count => @page.revisions.count), comfy_admin_cms_site_page_revisions_path(@site, @page), :class => 'btn btn-default pull-right' 4 | 5 | %h2.pull-right 6 | -if @page.drafted? 7 | %span.label.label-info 8 | =t('.drafted') 9 | -if @page.reviewed? 10 | %span.label.label-primary 11 | =t('.reviewed') 12 | -if @page.scheduled? 13 | %span.label.label-warning 14 | =t('.scheduled') 15 | -if @page.published? 16 | %span.label.label-success 17 | =t('.published') 18 | %h2= t('.title') 19 | 20 | - content_for :right_column do 21 | = render 'comfy/admin/cms/sites/mirrors', :object => @page 22 | 23 | = comfy_form_for @page, :as => :page, :url => {:action => :update}, :html => {:multipart => true} do |form| 24 | = render form 25 | -------------------------------------------------------------------------------- /app/assets/stylesheets/cms/fortress/admin_overrides.css: -------------------------------------------------------------------------------- 1 | 2 | .alert-notice { 3 | background-color: #dff0d8; 4 | border-color: #d6e9c6; 5 | color: #3c763d; 6 | } 7 | 8 | .alert-error { 9 | background-color: #f2dede; 10 | border-color: #eed3d7; 11 | color: #b94a48; 12 | text-align: center; 13 | } 14 | 15 | .alert-notice hr { 16 | border-top-color: #c9e2b3; 17 | } 18 | 19 | .alert-notice .alert-link { 20 | color: #2b542c; 21 | } 22 | 23 | .current-site-info { 24 | margin-top: -1.2em; 25 | margin-bottom: 0.3em; 26 | } 27 | 28 | .site_selector { 29 | width: 250px; 30 | } 31 | 32 | h2.pull-right{ 33 | font-size: 27px; 34 | } 35 | .btn-scheduled, .btn-drafted, .btn-reviewed, .btn-published{color:#fff;} 36 | .btn-scheduled{background-color:#f0ad4e;} 37 | .btn-drafted{background-color:#5bc0de;} 38 | .btn-reviewed{background-color:#428bca;} 39 | .btn-published{background-color:#5cb85c;} 40 | -------------------------------------------------------------------------------- /test/fixtures/comfy/cms/layouts.yml: -------------------------------------------------------------------------------- 1 | default: 2 | site: default 3 | label: Default Layout 4 | identifier: default 5 | parent: 6 | content: |- 7 | {{cms:field:default_field_text:text}} 8 | layout_content_a 9 | {{cms:page:default_page_text:text}} 10 | layout_content_b 11 | {{cms:snippet:default}} 12 | layout_content_c 13 | css: default_css 14 | js: default_js 15 | position: 0 16 | 17 | nested: 18 | site: default 19 | label: Nested Layout 20 | identifier: nested 21 | parent: 22 | content: |- 23 | {{cms:page:header}} 24 | {{cms:page:content}} 25 | css: nested_css 26 | js: nested_js 27 | position: 0 28 | 29 | child: 30 | site: default 31 | label: Child Layout 32 | identifier: child 33 | parent: nested 34 | content: |- 35 | {{cms:page:left_column}} 36 | {{cms:page:right_column}} 37 | css: child_css 38 | js: child_js 39 | position: 0 40 | 41 | -------------------------------------------------------------------------------- /app/views/cms/fortress/users/passwords/edit.html.haml: -------------------------------------------------------------------------------- 1 | = render :partial => 'cms/fortress/shared/navbar' 2 | .container 3 | .row 4 | .col-sm-6.col-sm-offset-3 5 | 6 | = form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put, role: 'form', class: 'form-reset-password' }) do |f| 7 | %h3= t('login.change_your_password') 8 | = devise_error_messages! 9 | = f.hidden_field :reset_password_token 10 | .form-group 11 | = f.label :password, t('login.new_password') 12 | = f.password_field :password, autofocus: true, autocomplete: "off", class: 'form-control' 13 | .form-group 14 | = f.label :password_confirmation, t('login.confirm_new_password') 15 | = f.password_field :password_confirmation, autocomplete: "off", class: 'form-control' 16 | 17 | = f.submit t('login.change_my_password') 18 | 19 | = render "devise/shared/links" 20 | -------------------------------------------------------------------------------- /lib/cms/fortress/site_methods.rb: -------------------------------------------------------------------------------- 1 | require 'active_support/concern' 2 | 3 | module Cms 4 | module Fortress 5 | module SiteMethods 6 | extend ActiveSupport::Concern 7 | 8 | included do 9 | after_create :generate_defaults 10 | 11 | has_many :users, class_name: "Cms::Fortress::User", foreign_key: :site_id 12 | has_many :roles, class_name: "Cms::Fortress::Role", foreign_key: :site_id 13 | has_many :role_details, class_name: "Cms::Fortress::RoleDetail", foreign_key: :site_id 14 | end 15 | 16 | # generate default roles specific for the site 17 | def generate_defaults 18 | #TODO: implement I18n below 19 | role = Cms::Fortress::Role.create!(:site_id => id, :name => "#{label} Administrator", :description => "#{ label } administrator users") 20 | role.load_defaults 21 | role.save 22 | end 23 | 24 | module ClassMethods 25 | 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/generators/cms/fortress/templates/README: -------------------------------------------------------------------------------- 1 | 2 | 3 | FORTIFIED: 4 | 5 | ____ __ _ _ _ 6 | / ___|___ _ __ ___ / _| ___ _ __| |_ __ _| |__ | | ___ 7 | | | / _ \| '_ ` _ \| |_ / _ \| '__| __/ _` | '_ \| |/ _ \ 8 | | |__| (_) | | | | | | _| (_) | | | || (_| | |_) | | __/ 9 | \____\___/|_| |_| |_|_| \___/|_| \__\__,_|_.__/|_|\___| 10 | __ __ _ ____ __ 11 | | \/ | _____ _(_) ___ __ _ _ __ / ___| ___ / _| __ _ 12 | | |\/| |/ _ \ \/ / |/ __/ _` | '_ \ \___ \ / _ \| |_ / _` | 13 | | | | | __/> <| | (_| (_| | | | | ___) | (_) | _| (_| | 14 | |_| |_|\___/_/\_\_|\___\__,_|_| |_| |____/ \___/|_| \__,_| 15 | 16 | 17 | Hey! Everything is almost done. Please don't forget to 18 | 19 | * run migrations -> `rake db:migrate` 20 | 21 | After that go to http://your-awesome-app/cms-admin to start populating content. 22 | Default username and password are: admin@cmsfortress.com // 1234qwer 23 | 24 | -------------------------------------------------------------------------------- /app/views/cms/fortress/roles/index.html.haml: -------------------------------------------------------------------------------- 1 | .page-header 2 | = link_to t('cms.fortress.roles.new_link'), new_cms_fortress_role_path, :class => 'btn btn-primary btn-sm pull-right' 3 | %h2= t('cms.fortress.roles.title') 4 | 5 | %table.table.table-hover.table-bordered.table-striped 6 | %tr 7 | %th= t('cms.fortress.roles.name') 8 | %th{:style => 'width: 60%;'}= t('cms.fortress.roles.description') 9 | %th 10 | 11 | - @cms_fortress_roles.each do |cms_fortress_role| 12 | %tr 13 | %td= cms_fortress_role.name 14 | %td= cms_fortress_role.description 15 | %td 16 | .btn-group.pull-right 17 | = link_to t('cms.fortress.roles.show_access_rights'), cms_fortress_role, :class => 'btn btn-sm btn-info' 18 | = link_to t('cms.fortress.edit'), edit_cms_fortress_role_path(cms_fortress_role), :class => 'btn btn-sm btn-default' 19 | = link_to t('cms.fortress.delete'), cms_fortress_role, :method => :delete, :data => { :confirm => 'Are you sure?' }, :class => 'btn btn-sm btn-danger' 20 | 21 | -------------------------------------------------------------------------------- /app/views/cms/fortress/roles/show.html.haml: -------------------------------------------------------------------------------- 1 | .page-header 2 | .btn-group.pull-right 3 | =# link_to t('.edit'), edit_cms_fortress_role_path(@cms_fortress_role), :class => 'btn' 4 | = link_to t('cms.fortress.roles.load'), refresh_cms_fortress_role_path(@cms_fortress_role), :class => 'btn btn-primary', :method => :post 5 | = link_to t('cms.fortress.roles.back'), cms_fortress_roles_path, :class => 'btn btn-default' 6 | %h3= "#{t('cms.fortress.roles.role')}: #{ @cms_fortress_role.name }" 7 | %p= @cms_fortress_role.description 8 | 9 | 10 | = form_for @cms_fortress_role, :html => {:class => ''} do |f| 11 | %table.table 12 | %tr 13 | %th 14 | %th= t('cms.fortress.roles.show') 15 | %th= t('cms.fortress.roles.manage') 16 | = f.fields_for :role_details do |role| 17 | %tr 18 | %td= role_display(role.object.command) 19 | %td= role.check_box :can_view 20 | %td= role.check_box :can_create 21 | 22 | .form-actions 23 | = f.submit t('cms.fortress.roles.save'), :class => 'btn btn-primary' 24 | 25 | -------------------------------------------------------------------------------- /app/assets/stylesheets/cms/fortress/themes/wide.css.scss: -------------------------------------------------------------------------------- 1 | body#comfy { 2 | background-color: inherit; 3 | 4 | small.site-button-label { 5 | color: #999; 6 | } 7 | 8 | strong.site-button-label { 9 | margin-left: 10px; 10 | margin-right: 1em; 11 | } 12 | 13 | /** 14 | font-size: 13px; 15 | line-height: 18px; 16 | 17 | h1 { font-size: 32px; } 18 | 19 | h2 { font-size: 24px; } 20 | h3 { font-size: 22px; } 21 | h4 { font-size: 18px; } 22 | h5 { font-size: 16px; } 23 | 24 | .wide-body { 25 | width: 98%; 26 | min-height: 100%; 27 | height: auto !important; 28 | height: 100%; 29 | margin: 0 auto; 30 | padding-top: 48px; 31 | } 32 | 33 | .page-header { 34 | } 35 | 36 | .spacer { 37 | height: 20px; 38 | } 39 | 40 | **/ 41 | .footer { 42 | height: 60px; 43 | padding: 20px 10px 10px; 44 | 45 | p { 46 | text-align: center; 47 | padding-top: 10px; 48 | border-top: solid 1px #f5f5f5; 49 | } 50 | } 51 | 52 | .revision-list { 53 | margin-top: 1em; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /app/views/devise/shared/_links.html.haml: -------------------------------------------------------------------------------- 1 | - if controller_name != 'sessions' 2 | = link_to t('login.log_in'), new_session_path(resource_name) 3 | 4 | - if devise_mapping.registerable? && controller_name != 'registrations' 5 | = link_to t('login.sign_up'), new_registration_path(resource_name) 6 | 7 | - if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' 8 | = link_to t('login.forgot_your_password'), new_password_path(resource_name) 9 | 10 | - if devise_mapping.confirmable? && controller_name != 'confirmations' 11 | = link_to t('login.didnt_receive_confirmation_instructions'), new_confirmation_path(resource_name) 12 | 13 | - if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' 14 | = link_to t('login.didnt_receive_unlock_instructions'), new_unlock_path(resource_name) 15 | 16 | - if devise_mapping.omniauthable? 17 | - resource_class.omniauth_providers.each do |provider| 18 | = link_to t('login.sign_in_with'), omniauth_authorize_path(resource_name, provider) 19 | -------------------------------------------------------------------------------- /lib/cms/fortress/content_renderer.rb: -------------------------------------------------------------------------------- 1 | module Cms 2 | module Fortress 3 | module ContentRenderer 4 | 5 | def self.included(base) 6 | 7 | base.class_eval do 8 | 9 | def render_page(status = 200) 10 | cached_timeout = @cms_page.cached_timeout.to_i 11 | 12 | if cached_timeout > 0 13 | fresh_when etag: @cms_page, last_modified: @cms_page.updated_at.utc, public: true 14 | response.cache_control[:max_age] = cached_timeout.seconds 15 | end 16 | 17 | if @cms_layout = @cms_page.layout 18 | 19 | app_layout = (@cms_layout.app_layout.blank? || request.xhr?) ? false : @cms_layout.app_layout 20 | render(:inline => @cms_page.content_cache, :layout => app_layout, :status => status, :content_type => mime_type) unless cached_timeout > 0 && performed? 21 | else 22 | render :text => I18n.t('cms.content.layout_not_found'), :status => 404 23 | end 24 | end 25 | 26 | end 27 | end 28 | 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /app/controllers/cms/fortress/admin_controller.rb: -------------------------------------------------------------------------------- 1 | class Cms::Fortress::AdminController < Comfy::Admin::Cms::BaseController 2 | 3 | def dashboard 4 | 5 | end 6 | 7 | def roles 8 | @roles = Role.all 9 | end 10 | 11 | def images 12 | @files = Comfy::Cms::File.images 13 | respond_to do |format| 14 | format.html { render partial: 'cms/fortress/shared/media_items', locals: {media: @files, type: :image} } 15 | format.json { render json: @files } 16 | end 17 | end 18 | 19 | def videos 20 | @files = Comfy::Cms::File.videos 21 | respond_to do |format| 22 | format.html { render partial: 'cms/fortress/shared/media_items', locals: {media: @files, type: :video} } 23 | format.json { render json: @files } 24 | end 25 | end 26 | 27 | def other_files 28 | @files = Comfy::Cms::File.others.map {|f| {title: f.label, value: f.file.url}} 29 | respond_to do |format| 30 | format.html { render partial: 'cms/fortress/shared/media_items', locals: {media: @files, type: :others} } 31 | format.json { render json: @files } 32 | end 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Melvin Sembrano 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /app/views/layouts/comfy/admin/cms/_head.html.haml: -------------------------------------------------------------------------------- 1 | %head 2 | %meta{'http-equiv' => "Content-type", :content => "text/html; charset=utf-8"} 3 | %title= settings.title 4 | = csrf_meta_tag 5 | 6 | = stylesheet_link_tag 'comfy/admin/cms/application', 'data-turbolinks-track' => true 7 | = stylesheet_link_tag "cms/fortress/admin_overrides", 'data-turbolinks-track' => true 8 | 9 | - unless default_theme? 10 | = stylesheet_link_tag "cms/fortress/themes/#{ theme_name }" 11 | 12 | 13 | = javascript_include_tag 'comfy/admin/cms/application', 'data-turbolinks-track' => true 14 | = javascript_include_tag 'cms/fortress/media', 'data-turbolinks-track' => true 15 | 16 | - unless default_theme? 17 | = javascript_include_tag "cms/fortress/themes/#{ theme_name }" 18 | 19 | - if @site && @site.persisted? 20 | 21 | :javascript 22 | CMS.file_upload_path = '#{comfy_admin_cms_site_files_path(@site)}'; 23 | CMS.pages_path = '#{comfy_admin_cms_site_pages_path(@site)}'; 24 | CMS.locale = '#{I18n.locale}'; 25 | 26 | 27 | = yield :head 28 | 29 | = render 'comfy/admin/cms/partials/html_head' 30 | -------------------------------------------------------------------------------- /app/helpers/comfy/admin/cms/pages_helper.rb: -------------------------------------------------------------------------------- 1 | module Comfy::Admin::Cms::PagesHelper 2 | def page_actions(page) 3 | events = page.aasm.events(permitted: true).map(&:name) 4 | events.select! do |event| 5 | can?(:manage, 'contents.page.' + event.to_s) 6 | end 7 | events 8 | end 9 | 10 | def cached_timeout_for_select 11 | { 12 | "Uncached" => 0, 13 | "15 minutes" => 15.minutes, 14 | "30 minutes" => 30.minutes, 15 | "1 hour" => 1.hour, 16 | "3 hours" => 3.hours, 17 | "24 hours" => 1.day, 18 | "15 days" => 15.days, 19 | "30 days" => 30.days 20 | }.map {|k,v| [k, v.to_i] } 21 | end 22 | 23 | def site_selector 24 | select_tag( 25 | :sites, 26 | options_for_select(sites_for_select, params[:site_id]), 27 | {class: 'form-control input-sm site_selector', id: 'js_site_selector'} 28 | ) 29 | end 30 | 31 | def sites_for_select 32 | all_sites.map { |site| [site.label, site.id] } 33 | end 34 | 35 | def all_sites 36 | Comfy::Cms::Site.all 37 | end 38 | 39 | def multiple_sites? 40 | all_sites.size > 1 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /config/initializers/cms_fortress.rb: -------------------------------------------------------------------------------- 1 | Cms::Fortress.configure do |config| 2 | # comment the line below if you want to use the default layout 3 | config.theme = :wide 4 | 5 | # Turn on site selector on login page 6 | # config.login_site_selector = true 7 | 8 | # Turn off page workflow options 9 | # config.enable_page_workflow = false 10 | # Turn off page caching options 11 | # config.enable_page_caching = false 12 | 13 | # Add new resource to contents 14 | # config.content_resources << { 15 | # name: 'my_role_detail', 16 | # title: 'i18n.label.title', # this is passed to the t() function - can be plain text 17 | # path: 'admin_my_role_details_path' 18 | # } 19 | 20 | # Add new resource to settings 21 | # config.settings_resources << { 22 | # name: 'my_role_detail', 23 | # title: 'i18n.label.title', # this is passed to the t() function - can be plain text 24 | # path: 'admin_my_role_details_path' 25 | # } 26 | 27 | # Add new resource to design 28 | # config.design_resources << { 29 | # name: 'my_role_detail', 30 | # title: 'i18n.label.title', # this is passed to the t() function - can be plain text 31 | # path: 'admin_my_role_details_path' 32 | # } 33 | 34 | end 35 | -------------------------------------------------------------------------------- /db/migrate/07_integrate_workflow_into_cms_pages.rb: -------------------------------------------------------------------------------- 1 | class IntegrateWorkflowIntoCmsPages < ActiveRecord::Migration 2 | class Cms::PageWorkflow < ActiveRecord::Base 3 | self.table_name = 'cms_page_workflows' 4 | belongs_to :page, :class_name => 'Comfy::Cms::Page', :foreign_key => 'cms_page_id' 5 | end 6 | 7 | def change 8 | 9 | add_column :comfy_cms_pages, :aasm_state, :string, default: 'new' 10 | add_column :comfy_cms_pages, :published_date, :date 11 | 12 | Comfy::Cms::Page.reset_column_information 13 | 14 | Cms::PageWorkflow.all.each do |workflow| 15 | page = Comfy::Cms::Page.where(id: workflow.cms_page_id).first 16 | if page 17 | page.aasm_state = case workflow.status_id.to_i 18 | when 0 19 | 'drafted' 20 | when 1 21 | 'reviewed' 22 | when 2 23 | 'scheduled' 24 | when 3 25 | 'published' 26 | else 27 | 'drafted' 28 | end 29 | page.published_date = workflow.published_date 30 | page.save! 31 | end 32 | end 33 | 34 | # TODO: Just to make it safe workflow table will be removed on the 5th patch release 35 | # drop_table :cms_page_workflows 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /app/views/cms/fortress/shared/_dashboard_widget.html.haml: -------------------------------------------------------------------------------- 1 | .panel-group(id="accordion-#{ title.parameterize }") 2 | .panel.panel-default 3 | .panel-heading 4 | = title 5 | %a.btn.btn-xs.btn-default.pull-right(data-toggle="collapse" href="#cl-#{ title.parameterize }" data-parent="#accordion-#{ title.parameterize }") 6 | %span.glyphicon.glyphicon-minus 7 | 8 | .panel-collapse.collapse.in(id="cl-#{ title.parameterize }") 9 | .panel-body 10 | %ul.list-group 11 | - collection.each do |c| 12 | %li.list-group-item 13 | .row 14 | .col-xs-6 15 | = c.label 16 | %br 17 | %small 18 | ( 19 | = c.full_path 20 | ) 21 | .col-xs-6 22 | = link_to edit_comfy_admin_cms_site_page_path(@site, c), class: "btn btn-xs btn-default" do 23 | %span.glyphicon.glyphicon-edit 24 | Edit 25 | 26 | = link_to comfy_admin_cms_site_page_path(@site, c, preview: true), target: "_blank", method: :put, class: "btn btn-xs btn-default" do 27 | %span.glyphicon.glyphicon-search 28 | Preview 29 | 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # rcov generated 2 | coverage 3 | coverage.data 4 | 5 | # rdoc generated 6 | rdoc 7 | 8 | # yard generated 9 | doc 10 | .yardoc 11 | 12 | # bundler 13 | .bundle 14 | 15 | # jeweler generated 16 | pkg 17 | 18 | # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore: 19 | # 20 | # * Create a file at ~/.gitignore 21 | # * Include files you want ignored 22 | # * Run: git config --global core.excludesfile ~/.gitignore 23 | # 24 | # After doing this, these files will be ignored in all your git projects, 25 | # saving you from having to 'pollute' every project you touch with them 26 | # 27 | # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line) 28 | # 29 | # For MacOS: 30 | # 31 | .DS_Store 32 | 33 | .rbenv-gemsets 34 | .ruby-version 35 | 36 | # For TextMate 37 | #*.tmproj 38 | #tmtags 39 | 40 | # For emacs: 41 | #*~ 42 | #\#* 43 | #.\#* 44 | 45 | # For vim: 46 | #*.swp 47 | 48 | # For redcar: 49 | #.redcar 50 | 51 | # For rubinius: 52 | #*.rbc 53 | 54 | #For Rubymine 55 | .idea 56 | 57 | # Rails stuff 58 | .rvmrc 59 | db/test.sqlite3 60 | log/ 61 | /tmp/cache 62 | /.idea/ 63 | 64 | 00_create_cms.rb 65 | 66 | /db/development.sqlite3 67 | 68 | *.gem 69 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | defined?(Cms::Fortress::Application) && Cms::Fortress::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports and disable caching. 13 | config.consider_all_requests_local = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Don't care if the mailer can't send. 17 | config.action_mailer.raise_delivery_errors = false 18 | 19 | # Print deprecation notices to the Rails logger. 20 | config.active_support.deprecation = :log 21 | 22 | # Raise an error on page load if there are pending migrations 23 | config.active_record.migration_error = :page_load 24 | 25 | # Debug mode disables concatenation and preprocessing of assets. 26 | # This option may cause significant delays in view rendering with a large 27 | # number of complex assets. 28 | config.assets.debug = true 29 | end 30 | -------------------------------------------------------------------------------- /app/assets/stylesheets/cms/fortress/session.scss: -------------------------------------------------------------------------------- 1 | @import "bootstrap-sprockets"; 2 | @import "bootstrap"; 3 | 4 | body { 5 | padding-bottom: 40px; 6 | background-color: #f5f5f5; 7 | } 8 | 9 | .form-signin { 10 | padding: 19px 29px 29px; 11 | margin: 3em auto 20px; 12 | background-color: #fff; 13 | border: 1px solid #e5e5e5; 14 | -webkit-border-radius: 5px; 15 | -moz-border-radius: 5px; 16 | border-radius: 5px; 17 | -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05); 18 | -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05); 19 | box-shadow: 0 1px 2px rgba(0,0,0,.05); 20 | } 21 | 22 | .form-reset-password { 23 | padding: 19px 29px 29px; 24 | margin: 3em auto 20px; 25 | background-color: #fff; 26 | border: 1px solid #e5e5e5; 27 | -webkit-border-radius: 5px; 28 | -moz-border-radius: 5px; 29 | border-radius: 5px; 30 | -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05); 31 | -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05); 32 | box-shadow: 0 1px 2px rgba(0,0,0,.05); 33 | } 34 | 35 | .form-signin .form-signin-heading, 36 | .form-signin .checkbox { 37 | margin-bottom: 10px; 38 | } 39 | 40 | .form-signin input[type="text"], 41 | .form-signin input[type="password"] { 42 | font-size: 16px; 43 | height: auto; 44 | margin-bottom: 15px; 45 | } 46 | 47 | /* 48 | */ 49 | -------------------------------------------------------------------------------- /app/models/cms/fortress/role.rb: -------------------------------------------------------------------------------- 1 | class Cms::Fortress::Role < ActiveRecord::Base 2 | # set_table_name :cms_fortress_roles 3 | self.table_name = "cms_fortress_roles" 4 | # attr_accessible :description, :name 5 | has_many :users 6 | has_many :role_details 7 | belongs_to :site, class_name: "Comfy::Cms::Site", foreign_key: :site_id 8 | accepts_nested_attributes_for :role_details, allow_destroy: true 9 | 10 | def load_defaults 11 | # load user custom roles 12 | if File.exist?(file = File.join(Rails.root, "config", "roles.yml")) 13 | load_from_file(file) 14 | else 15 | errors[:base] << I18n.t('cms.fortress.admin.errors.missing_roles_yaml_file') 16 | raise Cms::Fortress::Error::MissingRoleConfigurationFile 17 | end 18 | end 19 | 20 | private 21 | 22 | def load_from_file(file) 23 | data = YAML.load_file(file) 24 | data.each do |k,v| 25 | v.each do |m| 26 | description = m.split('.').map(&:humanize).join(' - ') 27 | role_details.build( 28 | :name => description, 29 | :command => "#{k}.#{m}", 30 | :can_create => true, 31 | :can_update => true, 32 | :can_delete => true, 33 | :can_view => true 34 | ) unless role_details.map(&:command).include?("#{k}.#{m}") 35 | end 36 | end 37 | 38 | end 39 | end 40 | 41 | 42 | -------------------------------------------------------------------------------- /app/views/cms/fortress/users/sessions/new.html.haml: -------------------------------------------------------------------------------- 1 | = render :partial => 'cms/fortress/shared/navbar' 2 | .container 3 | .row 4 | .col-sm-6.col-sm-offset-3 5 | = form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => {:role => "form", :class => "form-signin" }) do |f| 6 | %h3.form-signin-heading= t('cms.fortress.users.sessions.new.sign_in') 7 | .form-group 8 | = f.label :email 9 | = f.email_field :email, :autofocus => true, :placeholder => t('cms.fortress.users.sessions.new.email_address'), :class => "form-control" 10 | .form-group 11 | = f.label :password 12 | = f.password_field :password, :placeholder => t('cms.fortress.users.sessions.new.password'), :class => "form-control" 13 | .form-group(class="#{ "hide" unless Comfy::Cms::Site.count > 1 && Cms::Fortress.configuration.login_site_selector }") 14 | = f.label :site 15 | = f.select :site_id, Comfy::Cms::Site.all.collect{ |s| [s.label, s.id] }, :class => "form-control" 16 | 17 | - if devise_mapping.rememberable? 18 | .checkbox 19 | %label.checkbox 20 | = f.check_box :remember_me 21 | = t('cms.fortress.users.sessions.new.remember_me') 22 | = f.submit t('cms.fortress.users.sessions.new.sign_in'), :class => "btn btn-primary btn-md" 23 | = render "devise/shared/links" 24 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | require 'rails/all' 4 | 5 | # Assets should be precompiled for production (so we don't need the gems loaded then) 6 | Bundler.require(*Rails.groups(assets: %w(development test))) 7 | 8 | module Cms 9 | module Fortress 10 | class Application < Rails::Application 11 | 12 | require_relative '../lib/cms-fortress' 13 | 14 | # Settings in config/environments/* take precedence over those specified here. 15 | # Application configuration should go into files in config/initializers 16 | # -- all .rb files in that directory are automatically loaded. 17 | 18 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 19 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 20 | # config.time_zone = 'Central Time (US & Canada)' 21 | 22 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 23 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 24 | # config.i18n.default_locale = :de 25 | 26 | # Making sure we don't load our dev routes as part of the engine 27 | config.paths['config/routes.rb'] << 'config/cms_routes.rb' 28 | 29 | config.i18n.enforce_available_locales = true 30 | 31 | config.secret_key_base = 'secrets.yml' 32 | end 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /app/views/cms/fortress/users/index.html.haml: -------------------------------------------------------------------------------- 1 | .page-header 2 | - unless @super_user 3 | = link_to t('cms.fortress.users.new_link'), new_cms_fortress_user_path, :class => 'btn btn-primary btn-sm pull-right' 4 | - else 5 | = link_to t('cms.fortress.users.new_super_link'), super_new_cms_fortress_users_path, :class => 'btn btn-primary btn-sm pull-right' 6 | 7 | %h3 8 | - unless @super_user 9 | = t('cms.fortress.users.title') 10 | - else 11 | = t('cms.fortress.admin.super_user.title') 12 | 13 | %table.table.table-hover.table-bordered 14 | %tr 15 | %th= t('cms.fortress.users.last_name') 16 | %th= t('cms.fortress.users.first_name') 17 | %th= t('cms.fortress.users.email') 18 | - unless @super_user 19 | %th= t('cms.fortress.users.role') 20 | %th 21 | 22 | - @cms_fortress_users.each do |cms_fortress_user| 23 | %tr 24 | %td= cms_fortress_user.last_name 25 | %td= cms_fortress_user.first_name 26 | %td= cms_fortress_user.email 27 | - unless @super_user 28 | - if cms_fortress_user.role 29 | %td= cms_fortress_user.role.name 30 | %td 31 | .btn-group.pull-right 32 | = link_to t('cms.fortress.edit'), edit_cms_fortress_user_path(cms_fortress_user), :class => 'btn btn-sm btn-default' 33 | = link_to t('cms.fortress.delete'), cms_fortress_user, method: :delete, data: { confirm: t('cms.fortress.are_you_sure') }, :class => 'btn btn-sm btn-danger' 34 | 35 | -------------------------------------------------------------------------------- /lib/cms/fortress/routes/admin.rb: -------------------------------------------------------------------------------- 1 | class ActionDispatch::Routing::Mapper 2 | 3 | def cms_fortress_routes(options = {}) 4 | path = options[:path] || "cms-admin" 5 | 6 | devise_for "cms/fortress/users", 7 | :path => path, 8 | :path_names => { 9 | :sign_in => 'login', :sign_out => 'logout' 10 | }, 11 | :controllers => { 12 | :sessions => 'cms/fortress/users/sessions', 13 | :passwords => 'cms/fortress/users/passwords' 14 | } 15 | 16 | scope path, module: 'cms/fortress' do 17 | resources :roles, :as => 'cms_fortress_roles' do 18 | member do 19 | post :refresh 20 | end 21 | end 22 | 23 | resources :users, :except => :show, :as => 'cms_fortress_users' do 24 | collection do 25 | get :super 26 | get "super/new", action: "new_super" 27 | end 28 | end 29 | 30 | get 'settings/users' => 'admin#users', as: 'cms_fortress_user_settings' 31 | get 'unauthorised' => 'admin#unauthorised', as: 'cms_fortress_unauthorised' 32 | 33 | get 'sites/:site_id/files/images' => 'admin#images', as: 'cms_fortress_files_images' 34 | get 'sites/:site_id/files/videos' => 'admin#videos', as: 'cms_fortress_files_videos' 35 | get 'sites/:site_id/files/others' => 'admin#other_files', as: 'cms_fortress_files_others' 36 | 37 | # Site Resource routes 38 | get 'site/dashboard' => 'admin#dashboard', as: 'dashboard_site' 39 | end 40 | 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /app/views/layouts/comfy/admin/cms/_left.html.haml: -------------------------------------------------------------------------------- 1 | = render 'comfy/admin/cms/partials/navigation_before' 2 | 3 | %ul.navigation 4 | - if admin_page? 5 | - Cms::Fortress.configuration.settings_resources.each do |resource| 6 | - if resource[:super_user] 7 | - if current_cms_fortress_user.type.eql?(:super_user) 8 | = topnav_resource_item("settings", resource) 9 | - else 10 | = topnav_resource_item("settings", resource) 11 | 12 | = render 'cms/fortress/admin/left_settings_nav' 13 | 14 | - elsif design_page? 15 | - Cms::Fortress.configuration.design_resources.each do |resource| 16 | - if resource[:super_user] 17 | - if current_cms_fortress_user.type.eql?(:super_user) 18 | = topnav_resource_item("designs", resource) 19 | - else 20 | = topnav_resource_item("designs", resource) 21 | 22 | = render 'cms/fortress/admin/left_designs_nav' 23 | 24 | - elsif content_page? 25 | - Cms::Fortress.configuration.content_resources.each do |resource| 26 | - if resource[:super_user] 27 | - if current_cms_fortress_user.type.eql?(:super_user) 28 | = topnav_resource_item("contents", resource) 29 | - else 30 | = topnav_resource_item("contents", resource) 31 | 32 | = render 'cms/fortress/admin/left_contents_nav' 33 | = cms_hook :navigation 34 | 35 | - else 36 | = render 'cms/fortress/admin/left_nav' 37 | 38 | = render 'comfy/admin/cms/partials/navigation_inner' 39 | 40 | = render 'comfy/admin/cms/partials/navigation_after' 41 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | defined?(Cms::Fortress::Application) && Cms::Fortress::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure static asset server for tests with Cache-Control for performance. 16 | config.serve_static_assets = true 17 | config.static_cache_control = "public, max-age=3600" 18 | 19 | # Show full error reports and disable caching. 20 | config.consider_all_requests_local = true 21 | config.action_controller.perform_caching = false 22 | 23 | # Raise exceptions instead of rendering exception templates. 24 | config.action_dispatch.show_exceptions = false 25 | 26 | # Disable request forgery protection in test environment. 27 | config.action_controller.allow_forgery_protection = false 28 | 29 | # Tell Action Mailer not to deliver emails to the real world. 30 | # The :test delivery method accumulates sent emails in the 31 | # ActionMailer::Base.deliveries array. 32 | config.action_mailer.delivery_method = :test 33 | 34 | # Print deprecation notices to the stderr. 35 | config.active_support.deprecation = :stderr 36 | end 37 | -------------------------------------------------------------------------------- /cms-fortress.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | 3 | Gem::Specification.new do |s| 4 | s.name = "cms-fortress" 5 | s.version = "1.3.15" 6 | 7 | s.authors = ["Melvin Sembrano"] 8 | s.date = "2016-05-24" 9 | s.description = "Comfortable Mexican Sofa (CMS) - User and role management extension" 10 | s.email = "melvinsembrano@gmail.com" 11 | s.extra_rdoc_files = [ "LICENSE.txt", "README.rdoc" ] 12 | 13 | s.homepage = "http://github.com/melvinsembrano/cms-fortress" 14 | s.licenses = "MIT" 15 | s.summary = "Comfortable Mexican Sofa (CMS) - User and role management extension" 16 | 17 | s.files = `git ls-files`.split($/) 18 | s.executables = [] 19 | s.test_files = s.files.grep(%r{^(test|spec|features)/}) 20 | s.require_paths = ["lib"] 21 | 22 | s.add_dependency 'rails', '~> 4.0', '>= 4.0.0' 23 | s.add_dependency 'comfortable_mexican_sofa', '~> 1.12', '>= 1.12.5' 24 | s.add_dependency 'devise', '~> 3.2' 25 | s.add_dependency 'cancancan', '~> 1.9' 26 | s.add_dependency 'delayed_job', '~> 4' 27 | s.add_dependency 'tinymce-rails', '~> 4.1', '>= 4.1.0' 28 | s.add_dependency 'tinymce-rails-langs', '~> 4.0' 29 | s.add_dependency 'aasm', '~> 4.0' 30 | 31 | s.add_development_dependency 'rdoc' 32 | s.add_development_dependency 'bundler' 33 | s.add_development_dependency 'simplecov' 34 | s.add_development_dependency 'minitest', '~> 4.7', '>= 4.7.3' 35 | s.add_development_dependency 'minitest-rails' 36 | s.add_development_dependency 'minitest-spec-rails' 37 | s.add_development_dependency 'minitest-reporters' 38 | s.add_development_dependency 'sqlite3' 39 | end 40 | -------------------------------------------------------------------------------- /test/controllers/cms/fortress/users_controller_test.rb: -------------------------------------------------------------------------------- 1 | # http://api.rubyonrails.org/classes/ActionController/TestCase.html 2 | require 'test_helper' 3 | 4 | class Cms::Fortress::UsersControllerTest < ActionController::TestCase 5 | def setup 6 | @comfy_cms_site = comfy_cms_sites(:default) 7 | @cms_fortress_user = cms_fortress_users(:one) 8 | @cms_fortress_role_details = cms_fortress_role_details(:one) 9 | sign_in Cms::Fortress::User, @cms_fortress_user 10 | end 11 | 12 | def test_it_should_get_index 13 | get :index 14 | assert_not_nil assigns(:cms_fortress_users) 15 | end 16 | 17 | test "should get new" do 18 | get :new 19 | assert_response :success 20 | end 21 | 22 | test "should create cms_fortress_user" do 23 | assert_difference('Cms::Fortress::User.count') do 24 | post :create, cms_fortress_user: { email: 'foo@bar.com', password: 'foobar123', password_confirmation: 'foobar123' } 25 | end 26 | 27 | assert_redirected_to cms_fortress_users_path 28 | end 29 | 30 | test "should get edit" do 31 | get :edit, id: @cms_fortress_user 32 | assert_response :success 33 | end 34 | 35 | test "should update cms_fortress_user" do 36 | put :update, id: @cms_fortress_user, cms_fortress_user: { email: @cms_fortress_user.email, password: @cms_fortress_user.password, password_confirmation: @cms_fortress_user.password_confirmation } 37 | #assert_redirected_to cms_fortress_user_path(assigns(:cms_fortress_user)) 38 | assert_redirected_to cms_fortress_users_path() 39 | end 40 | 41 | test "should destroy cms_fortress_user" do 42 | assert_difference('Cms::Fortress::User.count', -1) do 43 | delete :destroy, id: @cms_fortress_user 44 | end 45 | 46 | assert_redirected_to cms_fortress_users_path 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /test/controllers/cms/fortress/roles_controller_test.rb: -------------------------------------------------------------------------------- 1 | # http://api.rubyonrails.org/classes/ActionController/TestCase.html 2 | require 'test_helper' 3 | 4 | 5 | class Cms::Fortress::RolesControllerTest < ActionController::TestCase 6 | def setup 7 | @comfy_cms_site = comfy_cms_sites(:default) 8 | @cms_fortress_user = cms_fortress_users(:one) 9 | @cms_fortress_role = cms_fortress_roles(:one) 10 | sign_in Cms::Fortress::User, @cms_fortress_user 11 | end 12 | 13 | def test_should_get_index 14 | get :index 15 | assert_response :success 16 | assert_not_nil assigns(:cms_fortress_roles) 17 | end 18 | 19 | test "should get new" do 20 | get :new 21 | assert_response :success 22 | end 23 | 24 | test "should create cms_fortress_role" do 25 | assert_difference('Cms::Fortress::Role.count') do 26 | post :create, cms_fortress_role: { description: @cms_fortress_role.description, name: @cms_fortress_role.name } 27 | end 28 | 29 | assert_redirected_to cms_fortress_role_path(assigns(:cms_fortress_role)) 30 | end 31 | 32 | test "should show cms_fortress_role" do 33 | get :show, id: @cms_fortress_role 34 | assert_response :success 35 | end 36 | 37 | test "should get edit" do 38 | get :edit, id: @cms_fortress_role 39 | assert_response :success 40 | end 41 | 42 | test "should update cms_fortress_role" do 43 | put :update, id: @cms_fortress_role, cms_fortress_role: { description: @cms_fortress_role.description, name: @cms_fortress_role.name } 44 | assert_redirected_to cms_fortress_role_path(assigns(:cms_fortress_role)) 45 | end 46 | 47 | test "should destroy cms_fortress_role" do 48 | assert_difference('Cms::Fortress::Role.count', -1) do 49 | delete :destroy, id: @cms_fortress_role 50 | end 51 | 52 | assert_redirected_to cms_fortress_roles_path 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /app/models/cms/fortress/user.rb: -------------------------------------------------------------------------------- 1 | class Cms::Fortress::User < ActiveRecord::Base 2 | # set_table_name :cms_fortress_users 3 | self.table_name = "cms_fortress_users" 4 | 5 | # Include default devise modules. Others available are: 6 | # :token_authenticatable, :confirmable, 7 | # :lockable, :timeoutable and :omniauthable 8 | # manually add :validatable validations because uniqueness does not include :site_id 9 | validates_presence_of :email, if: :email_required? 10 | validates_uniqueness_of :email, scope: :site_id, allow_blank: true, if: :email_changed? 11 | validates_format_of :email, with: Devise.email_regexp, allow_blank: true, if: :email_changed? 12 | validates_presence_of :password, if: :password_required? 13 | validates_confirmation_of :password, if: :password_required? 14 | validates_length_of :password, within: Devise.password_length, allow_blank: true 15 | devise :database_authenticatable, 16 | :recoverable, :rememberable, :trackable, :timeoutable, 17 | :authentication_keys => -> {Cms::Fortress.configuration.login_site_selector ? [:email, :site_id] : [:email]}.call 18 | 19 | belongs_to :role 20 | belongs_to :site, class_name: "Comfy::Cms::Site", foreign_key: :site_id 21 | 22 | scope :all_super, -> { where(type_id: 1) } 23 | 24 | def self.types 25 | { 26 | 1 => :super_user, 27 | 2 => :site_user 28 | } 29 | end 30 | 31 | def self.find_for_authentication(warden_conditions) 32 | where(:email => warden_conditions[:email], :site_id => warden_conditions[:site_id]).first || where(:email => warden_conditions[:email]).first 33 | end 34 | 35 | def type 36 | self.class.types[type_id] 37 | end 38 | 39 | def display_name 40 | "#{ email } (#{ type.to_s.titleize })" 41 | end 42 | 43 | protected 44 | 45 | def password_required? 46 | !persisted? || !password.nil? || !password_confirmation.nil? 47 | end 48 | 49 | def email_required? 50 | true 51 | end 52 | 53 | end 54 | -------------------------------------------------------------------------------- /app/models/cms_ability.rb: -------------------------------------------------------------------------------- 1 | # Create a generator for an override file for this class 2 | # sample below: 3 | # class Ability < CmsAbility 4 | # 5 | # def setup_role(role_detail, user) 6 | # if role_detail.command.eql?('contents.blog') 7 | # can :manage, Blog 8 | # else 9 | # warn "#{ role_detail.command } is not yet handled." 10 | # end 11 | # end 12 | # 13 | # end 14 | class CmsAbility 15 | include CanCan::Ability 16 | 17 | def initialize(user) 18 | 19 | if user 20 | if user.type.eql?(:super_user) 21 | can :manage, :all 22 | else 23 | if user.role && user.role.role_details 24 | user.role.role_details.each do |role_detail| 25 | can :view, role_detail.command if role_detail.can_view? 26 | can :manage, role_detail.command if role_detail.can_manage? 27 | 28 | if role_detail.can_manage? 29 | case role_detail.command 30 | when 'settings.roles' 31 | can :manage, Cms::Fortress::Role, site_id: user.site_id 32 | when 'settings.sites' 33 | can :update, Comfy::Cms::Site, site_id: user.site_id 34 | when 'settings.users' 35 | can :manage, Cms::Fortress::User, site_id: user.site_id 36 | when 'contents.pages' 37 | can :manage, Comfy::Cms::Page, site_id: user.site_id 38 | when 'contents.files' 39 | can :manage, Comfy::Cms::File, site_id: user.site_id 40 | when 'designs.layouts' 41 | can :manage, Comfy::Cms::Layout, site_id: user.site_id 42 | when 'designs.snippets' 43 | can :manage, Comfy::Cms::Snippet, site_id: user.site_id 44 | else 45 | setup_role(role_detail, user) if defined?(setup_role) 46 | end 47 | end 48 | end 49 | end 50 | end 51 | 52 | end 53 | 54 | end 55 | 56 | end 57 | -------------------------------------------------------------------------------- /app/helpers/cms/fortress/sprocket_helper.rb: -------------------------------------------------------------------------------- 1 | module Cms::Fortress::SprocketHelper 2 | include TinyMCE::Rails::Helper 3 | 4 | def tinymce_init 5 | config = Cms::Fortress::Settings.new(:tinymce).to_h rescue {} 6 | 7 | options = { 8 | menubar: "tools format view", 9 | toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table | fullscreen code | image fmedia link", 10 | toolbar2: "", 11 | plugins: ["code", "fullscreen", "media", "link", "table"], 12 | language: "en" 13 | }.merge(config) 14 | 15 | <<-EOF 16 | tinymce.init({ 17 | #{configuration_from_options(options)} 18 | #{configuration_from_options_as_string(options)} 19 | selector: 'textarea[data-cms-rich-text]', 20 | link_list: CmsFortress.media.othersUrl(), 21 | 22 | setup: function(ed) { 23 | ed.addButton('image', { 24 | title: 'Insert Image', 25 | onclick: function() { 26 | return CmsFortress.media.showImageDialog(ed); 27 | } 28 | }); 29 | 30 | return ed.addButton('fmedia', { 31 | tooltip: 'Insert Video', 32 | icon: 'media', 33 | stateSelector: ['img[data-mce-object=video]', 'img[data-mce-object=iframe]'], 34 | onclick: function() { 35 | return CmsFortress.media.showVideoDialog(ed); 36 | } 37 | }); 38 | } 39 | }); 40 | EOF 41 | end 42 | 43 | private 44 | 45 | def configuration_from_options_as_string(options) 46 | config = options.map do |k, v| 47 | "#{k.to_s.gsub('[plain]', '')}: #{v}," if k.to_s =~ /\[plain\]/ 48 | end 49 | config.join() if config.present? 50 | end 51 | 52 | def configuration_from_options(options) 53 | config = options.map do |k, v| 54 | unless k.to_s =~ /\[plain\]/ 55 | v.is_a?(Array) ? "#{k}: #{v}," : "#{k}: #{boolean_value(v)}," 56 | end 57 | end 58 | config.join() 59 | end 60 | 61 | def boolean_value(v) 62 | [true, false].include?(v) ? "#{v}" : "'#{v}'" 63 | end 64 | end 65 | -------------------------------------------------------------------------------- /lib/cms/fortress/page_methods.rb: -------------------------------------------------------------------------------- 1 | module Cms 2 | module Fortress 3 | module PageMethods 4 | 5 | def self.included(base) 6 | 7 | base.extend ClassMethods 8 | 9 | base.class_eval do 10 | before_create { self.draft if self.new? } 11 | 12 | include AASM 13 | 14 | aasm do 15 | state :new, initial: true 16 | state :drafted 17 | state :reviewed 18 | state :scheduled 19 | state :published, before_enter: :check_publish_date 20 | 21 | event :draft do 22 | after :publish_page? 23 | transitions from: :new, to: :drafted 24 | end 25 | 26 | event :review do 27 | after :publish_page? 28 | transitions from: [:new, :drafted], to: :reviewed 29 | end 30 | 31 | event :schedule do 32 | after :publish_page? 33 | transitions from: [:new, :drafted, :reviewed], to: :scheduled, guard: :published_date? 34 | end 35 | 36 | event :publish do 37 | after :publish_page? 38 | transitions from: [:new, :drafted, :reviewed, :scheduled], to: :published 39 | end 40 | 41 | event :reset do 42 | after :publish_page? 43 | transitions from: [:reviewed, :scheduled, :published], to: :drafted 44 | end 45 | end 46 | 47 | def check_publish_date 48 | self.published_date = Time.now unless self.published_date 49 | end 50 | 51 | def publish_page? 52 | ret = false 53 | if self.published? 54 | ret = true 55 | else 56 | if self.scheduled? && self.published_date.present? && self.published_date <= Date.today 57 | ret = true 58 | end 59 | end 60 | self.is_published = ret 61 | end 62 | 63 | end 64 | 65 | end 66 | 67 | module ClassMethods 68 | def updated_scheduled 69 | 70 | end 71 | end 72 | 73 | 74 | end 75 | end 76 | end 77 | -------------------------------------------------------------------------------- /db/migrate/01_devise_create_cms_fortress_users.rb: -------------------------------------------------------------------------------- 1 | class DeviseCreateCmsFortressUsers < ActiveRecord::Migration 2 | 3 | # move creation of default user to the 08 migration 4 | # def migrate(direction) 5 | # super 6 | 7 | # # Create default cms-admin user 8 | # Cms::Fortress::User.create!(:email => 'admin@cmsfortress.com', :password => '1234qwer', :password_confirmation => '1234qwer', :role_id => 1) if direction == :up 9 | # end 10 | 11 | def change 12 | create_table(:cms_fortress_users) do |t| 13 | ## Database authenticatable 14 | t.string :email, :null => false, :default => "" 15 | t.string :encrypted_password, :null => false, :default => "" 16 | 17 | t.integer :role_id 18 | 19 | ## Recoverable 20 | t.string :reset_password_token 21 | t.datetime :reset_password_sent_at 22 | 23 | ## Rememberable 24 | t.datetime :remember_created_at 25 | 26 | ## Trackable 27 | t.integer :sign_in_count, :default => 0 28 | t.datetime :current_sign_in_at 29 | t.datetime :last_sign_in_at 30 | t.string :current_sign_in_ip 31 | t.string :last_sign_in_ip 32 | 33 | t.string :first_name, :last_name 34 | 35 | ## Confirmable 36 | # t.string :confirmation_token 37 | # t.datetime :confirmed_at 38 | # t.datetime :confirmation_sent_at 39 | # t.string :unconfirmed_email # Only if using reconfirmable 40 | 41 | ## Lockable 42 | # t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts 43 | # t.string :unlock_token # Only if unlock strategy is :email or :both 44 | # t.datetime :locked_at 45 | 46 | ## Token authenticatable 47 | # t.string :authentication_token 48 | 49 | 50 | t.timestamps 51 | end 52 | 53 | add_index :cms_fortress_users, :email, :unique => true 54 | add_index :cms_fortress_users, :reset_password_token, :unique => true 55 | # add_index :cms_fortress_users, :confirmation_token, :unique => true 56 | # add_index :cms_fortress_users, :unlock_token, :unique => true 57 | # add_index :cms_fortress_users, :authentication_token, :unique => true 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /app/views/cms/fortress/shared/_menu.html.haml: -------------------------------------------------------------------------------- 1 | - if default_theme? 2 | %nav.navbar.navbar-default(role="navigation") 3 | .container-fluid 4 | .navbar-header 5 | %button.navbar-toggle(type="button" data-toggle="collapse" data-target="#main-nav") 6 | %span.sr-only= t('cms.fortress.toggle_navigation') 7 | %span.icon-bar 8 | %span.icon-bar 9 | %span.icon-bar 10 | = link_to settings.title, settings.title_link, class: 'navbar-brand' 11 | 12 | .collapse.navbar-collapse#main-nav 13 | %ul.nav.navbar-nav 14 | - if @site && !@site.new_record? 15 | %li= topnav_item "Dashboard", dashboard_site_path, current_page?(dashboard_site_path) 16 | 17 | - if Cms::Fortress.configuration.content_resources.any? {|resource| can? :view, "contents.#{resource[:name]}" } 18 | = topnav_item t("cms.fortress.contents"), | 19 | @site && !@site.new_record? ? comfy_admin_cms_site_pages_path(@site) : comfy_admin_cms_sites_pages_path, | 20 | content_page? 21 | 22 | - if Cms::Fortress.configuration.design_resources.any? {|resource| can? :view, "designs.#{resource[:name]}" } 23 | = topnav_item t("cms.fortress.design"), | 24 | @site && !@site.new_record? ? comfy_admin_cms_site_layouts_path(@site) : comfy_admin_cms_sites_pages_path, | 25 | design_page? 26 | 27 | - if Cms::Fortress.configuration.settings_resources.any? {|resource| can? :view, "settings.#{resource[:name]}" } 28 | = topnav_item t("cms.fortress.settings"), comfy_admin_cms_sites_path, admin_page? 29 | 30 | = render 'cms/fortress/admin/topnav' 31 | 32 | - if current_cms_fortress_user 33 | .btn-group.pull-right(style="margin-top: 8px;") 34 | %button.btn.btn-default.dropdown-toggle(type="button" data-toggle="dropdown") 35 | = current_cms_fortress_user.display_name 36 | %span.caret 37 | %ul.dropdown-menu(role="menu") 38 | %li 39 | = link_to t('cms.fortress.logout'), destroy_cms_fortress_user_session_path, :method => 'delete' 40 | 41 | - else 42 | = themed_partial('menu') 43 | 44 | -------------------------------------------------------------------------------- /test/fixtures/cms/fortress/role_details.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html 2 | 3 | admin_pages: 4 | name: Pages 5 | command: contents.pages 6 | can_create: 1 7 | can_update: 1 8 | can_delete: 1 9 | can_view: 1 10 | role: Administrator 11 | 12 | admin_files: 13 | name: Files 14 | command: contents.files 15 | can_create: 1 16 | can_update: 1 17 | can_delete: 1 18 | can_view: 1 19 | role: Administrator 20 | 21 | admin_page_review: 22 | name: Page - Review 23 | command: contents.page.review 24 | can_create: 1 25 | can_update: 1 26 | can_delete: 1 27 | can_view: 1 28 | role: Administrator 29 | 30 | admin_page_publish: 31 | name: Page - Publish 32 | command: contents.page.publish 33 | can_create: 1 34 | can_update: 1 35 | can_delete: 1 36 | can_view: 1 37 | role: Administrator 38 | 39 | admin_layouts: 40 | name: Layouts 41 | command: designs.layouts 42 | can_create: 1 43 | can_update: 1 44 | can_delete: 1 45 | can_view: 1 46 | role: Administrator 47 | 48 | admin_snippets: 49 | name: Snippets 50 | command: designs.snippets 51 | can_create: 1 52 | can_update: 1 53 | can_delete: 1 54 | can_view: 1 55 | role: Administrator 56 | 57 | admin_sites: 58 | name: Sites 59 | command: settings.sites 60 | can_create: 1 61 | can_update: 1 62 | can_delete: 1 63 | can_view: 1 64 | role: Administrator 65 | 66 | admin_roles: 67 | name: Roles 68 | command: settings.roles 69 | can_create: 1 70 | can_update: 1 71 | can_delete: 1 72 | can_view: 1 73 | role: Administrator 74 | 75 | admin_users: 76 | name: Users 77 | command: settings.users 78 | can_create: 1 79 | can_update: 1 80 | can_delete: 1 81 | can_view: 1 82 | role: Administrator 83 | 84 | one: 85 | name: MyString 86 | command: MyString 87 | can_create: false 88 | can_update: false 89 | can_delete: false 90 | can_view: false 91 | 92 | two: 93 | name: MyString 94 | command: MyString 95 | can_create: false 96 | can_update: false 97 | can_delete: false 98 | can_view: false 99 | -------------------------------------------------------------------------------- /app/views/comfy/admin/cms/pages/_form.html.haml: -------------------------------------------------------------------------------- 1 | - content_for :right_column do 2 | #form-save.box 3 | %label.checkbox-inline 4 | %input{:type => 'checkbox'} 5 | = ::Comfy::Cms::Page.human_attribute_name(:is_published) 6 | %button.btn.btn-sm.btn-primary.pull-right 7 | 8 | - if Cms::Fortress.configuration.enable_page_workflow && !@page.new_record? 9 | .container-fluid 10 | .btn-group 11 | %span.btn.btn-success= t('.' + @page.aasm_state) 12 | - page_actions(@page).each do |page_action| 13 | = form.button t('.'+page_action.to_s), :class => 'btn btn-default', :value => page_action, :name => 'transition' 14 | %hr 15 | 16 | = render 'comfy/admin/cms/partials/page_form_before', :form => form 17 | 18 | = form.text_field :label, :data => {:slugify => @page.new_record?} 19 | 20 | - if @page.parent.present? 21 | = form.text_field :slug, :data => {:slug => true}, :prepend => @page.parent.full_path 22 | 23 | - if (options = ::Comfy::Cms::Layout.options_for_select(@site)).present? 24 | = form.select :layout_id, options, {}, 'data-url' => form_blocks_comfy_admin_cms_site_page_path(@site, @page.id.to_i) 25 | 26 | - if (options = ::Comfy::Cms::Page.options_for_select(@site, @page)).present? 27 | = form.select :parent_id, options 28 | 29 | - if (options = ::Comfy::Cms::Page.options_for_select(@site, @page, nil, 0, false)).present? 30 | = form.select :target_page_id, [["---- #{t('.select_target_page')} ----", nil]] + options 31 | 32 | 33 | = render 'comfy/admin/cms/partials/page_form_inner', :form => form 34 | 35 | = render 'comfy/admin/cms/categories/form', :form => form 36 | 37 | = render 'form_blocks' 38 | 39 | - unless Cms::Fortress.configuration.enable_page_workflow 40 | = form.check_box :is_published, :label => t('.is_published') 41 | 42 | = render :partial => 'cms/fortress/shared/page_extend', :locals => {form: form} 43 | 44 | = render 'comfy/admin/cms/partials/page_form_after', :form => form 45 | 46 | = form.form_group :class => 'form-actions' do 47 | = form.submit t('.preview'), :name => 'preview', :id => nil, :class => 'btn btn-default' 48 | = form.submit t(@page.new_record?? '.create' : '.update'), :class => 'btn btn-primary' 49 | = link_to t('.cancel'), comfy_admin_cms_site_pages_path, :class => 'btn btn-link' 50 | 51 | 52 | -------------------------------------------------------------------------------- /app/assets/javascripts/html5shiv.js: -------------------------------------------------------------------------------- 1 | /* 2 | HTML5 Shiv v3.6.2pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | (function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag(); 5 | a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/\w+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsByTagName("head")[0]||d.documentElement;c.innerHTML="x"; 6 | c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode|| 7 | "undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",version:"3.6.2pre",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f);if(g)return a.createDocumentFragment(); 8 | for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d 3 | this.dlg = $("#media-box-dialog") 4 | # this.dlg.modal(show: false, backdrop: false) 5 | @eventListeners() 6 | 7 | eventListeners: -> 8 | ($ 'button.js-blank').on 'click', (e) => 9 | ($ e.target).closest('form').attr('target', '_blank') 10 | 11 | loading: "

Loading...

" 12 | 13 | othersUrl: -> 14 | this.othersPath 15 | 16 | showImageDialog: (ed) -> 17 | this.ed = ed 18 | this.dlg.modal(show: true, backdrop: false) 19 | #.css("left", $(document).width() - (this.dlg.width() / 2)) 20 | .find(".title").html("Image Selector") 21 | 22 | $("#modal-body").html(this.loading).load this.imagesPath, -> 23 | media.attachImageEvents() 24 | 25 | 26 | 27 | showVideoDialog: (ed) -> 28 | this.ed = ed 29 | this.dlg.modal(show: true, backdrop: false) 30 | #.css("left", $(document).width() - (this.dlg.width() / 2)) 31 | .find(".title").html("Video Selector") 32 | 33 | $("#modal-body").html(this.loading).load this.videosPath, -> 34 | media.attachVideoEvents() 35 | 36 | 37 | attachVideoEvents: -> 38 | $('.editor-video').on 'click', (e)-> 39 | e.preventDefault() 40 | media.attachVideo($(this).attr("href"), $(this).data('contentType')) 41 | media.dlg.modal('hide') 42 | 43 | 44 | attachImageEvents: -> 45 | $('.editor-image').on 'click', -> 46 | data = $(this).data() 47 | url = data.original 48 | 49 | media.attachImage(url) 50 | media.dlg.modal('hide') 51 | 52 | $('.editor-image-style').on 'click', (e)-> 53 | media.attachImage($(this).attr("href")) 54 | e.preventDefault() 55 | media.dlg.modal('hide') 56 | 57 | 58 | 59 | attachImage: (url) -> 60 | this.ed.focus() 61 | img = "" 62 | this.ed.selection.setContent(img) 63 | 64 | attachVideo: (url, type) -> 65 | this.ed.focus() 66 | img = '' 67 | this.ed.selection.setContent(img) 68 | this.ed.nodeChanged() 69 | 70 | window.CmsFortress = window.CmsFortress || {} 71 | 72 | window.CmsFortress.media = media 73 | 74 | $(document).ready -> 75 | CmsFortress.media.init() 76 | -------------------------------------------------------------------------------- /lib/generators/cms/fortress/fortress_generator.rb: -------------------------------------------------------------------------------- 1 | require 'generators/cms/comfy/comfy_generator' 2 | require 'fileutils' 3 | 4 | class Cms::FortressGenerator < Rails::Generators::Base 5 | include Thor::Actions 6 | 7 | # source_root File.expand_path('../templates', __FILE__) 8 | source_root File.expand_path('../../../../..', __FILE__) 9 | class_option :comfy, type: :boolean, default: true, description: "Generate Comfy" 10 | class_option :routes, type: :boolean, default: true, description: "Generate routes" 11 | class_option :migration, type: :boolean, default: true, description: "Generate migration" 12 | class_option :devise, type: :boolean, default: true, description: "Generate devise" 13 | class_option :development , default: false, desc: "Copy files that are necessary for development and testing of cms-fortress.", aliases: "-d" 14 | 15 | def install_devise 16 | generate("devise:install") if options.devise? && !options.development? 17 | end 18 | 19 | def install_comfortable_mexican_sofa 20 | Cms::ComfyGenerator.start if options.comfy? && !options.development? 21 | end 22 | 23 | def generate_migrations 24 | rake("cms_fortress_engine:install:migrations") if options.migration? 25 | end 26 | 27 | def generate_initialization 28 | copy_file 'config/initializers/cms_fortress.rb', 'config/initializers/cms_fortress.rb' 29 | end 30 | 31 | def copy_development_files 32 | if options[:development] == "development" 33 | copy_file Gem::Specification.find_by_name('comfortable_mexican_sofa').gem_dir+'/db/migrate/01_create_cms.rb', 34 | 'db/migrate/00_create_cms.rb' 35 | end 36 | end 37 | 38 | def generate_routing 39 | if options.routes? 40 | route_string = "" 41 | route_string << " cms_fortress_routes :path => '/cms-admin'\n" 42 | route route_string[2..-1] 43 | end 44 | end 45 | 46 | def copy_files 47 | log 'Copying files...' 48 | files = [ 49 | 'config/roles.yml', 50 | 'config/cms/fortress/global_settings.yml' 51 | ] 52 | files.each do |file| 53 | copy_file file, file 54 | end 55 | end 56 | =begin 57 | def generate_assets 58 | directory 'app/assets/javascripts/cms/fortress', 59 | 'app/assets/javascripts/cms/fortress' 60 | 61 | directory 'app/assets/stylesheets/cms/fortress', 62 | 'app/assets/stylesheets/cms/fortress' 63 | end 64 | =end 65 | def show_readme 66 | readme 'lib/generators/cms/fortress/templates/README' 67 | end 68 | 69 | end 70 | -------------------------------------------------------------------------------- /test/fixtures/comfy/cms/pages.yml: -------------------------------------------------------------------------------- 1 | default: 2 | site: default 3 | parent: 4 | target_page: 5 | layout: default 6 | label: Default Page 7 | slug: 8 | full_path: '/' 9 | children_count: 1 10 | position: 0 11 | is_published: 0 12 | content_cache: |- 13 | 14 | layout_content_a 15 | default_page_text_content_a 16 | default_snippet_content 17 | default_page_text_content_b 18 | layout_content_b 19 | default_snippet_content 20 | layout_content_c 21 | 22 | child: 23 | site: default 24 | parent: default 25 | target_page: 26 | layout: default 27 | label: Child Page 28 | slug: 'child-page' 29 | full_path: '/child-page' 30 | children_count: 0 31 | position: 0 32 | is_published: 0 33 | content_cache: |- 34 | 35 | layout_content_a 36 | 37 | layout_content_b 38 | default_snippet_content 39 | layout_content_c 40 | 41 | drafted: 42 | site: default 43 | parent: 44 | target_page: 45 | layout: default 46 | label: Drafted Page 47 | slug: 'drafted' 48 | full_path: '/' 49 | children_count: 1 50 | position: 0 51 | is_published: false 52 | content_cache: |- 53 | 54 | layout_content_a 55 | default_page_text_content_a 56 | default_snippet_content 57 | default_page_text_content_b 58 | layout_content_b 59 | default_snippet_content 60 | layout_content_c 61 | aasm_state: drafted 62 | 63 | reviewed: 64 | site: default 65 | parent: 66 | target_page: 67 | layout: default 68 | label: Reviewed Page 69 | slug: 'reviewed' 70 | full_path: '/' 71 | children_count: 0 72 | position: 0 73 | is_published: false 74 | content_cache: |- 75 | 76 | layout_content_a 77 | default_page_text_content_a 78 | default_snippet_content 79 | default_page_text_content_b 80 | layout_content_b 81 | default_snippet_content 82 | layout_content_c 83 | aasm_state: reviewed 84 | 85 | published: 86 | site: default 87 | parent: 88 | target_page: 89 | layout: default 90 | label: Published Page 91 | slug: 'published' 92 | full_path: '/' 93 | children_count: 0 94 | position: 0 95 | is_published: true 96 | content_cache: |- 97 | 98 | layout_content_a 99 | default_page_text_content_a 100 | default_snippet_content 101 | default_page_text_content_b 102 | layout_content_b 103 | default_snippet_content 104 | layout_content_c 105 | aasm_state: published -------------------------------------------------------------------------------- /app/views/cms/fortress/themes/wide/_body.html.haml: -------------------------------------------------------------------------------- 1 | - unless @site.nil? || @site.new_record? 2 | .container-fluid.current-site-info 3 | - if super_user? && multiple_sites? 4 | .btn-group(style="margin-top: 8px;") 5 | %button.btn.btn-default.btn-sm.dropdown-toggle(type='button' data-toggle="dropdown") 6 | %small.site-button-label 7 | %em 8 | = t('cms.fortress.current_site') 9 | %strong.site-button-label 10 | = current_site 11 | %b.caret 12 | %ul.dropdown-menu 13 | - all_sites.each do |site| 14 | = topnav_item site.label, comfy_admin_cms_site_pages_path(site), @site.id.eql?(site.id) 15 | - else 16 | .btn.btn-default.btn-sm 17 | %small.site-button-label 18 | %em 19 | = t('cms.fortress.current_site') 20 | %strong.site-button-label 21 | = current_site 22 | 23 | 24 | .container-fluid.wide-body 25 | - if controller_name.eql?('revisions') 26 | .row 27 | .col-sm-9 28 | =# render :partial => 'layouts/comfy/admin/cms/center' 29 | = yield 30 | .col-sm-3 31 | .panel.panel-default.revision-list 32 | .panel-heading 33 | Revisions 34 | .panel-body 35 | = yield :right_column 36 | - else 37 | =# render :partial => 'layouts/comfy/admin/cms/center' 38 | = yield 39 | 40 | = render :partial => 'layouts/comfy/admin/cms/footer' 41 | 42 | :coffeescript 43 | ### iconize delete and edit links ### 44 | $(".wide-body div.btn-group a:contains(Delete)").prepend(" ").attr("title", "Delete") #.tooltip(placement: 'left') 45 | $(".wide-body div.btn-group a:contains(Edit)").prepend(" ").attr("title", "Edit") #.tooltip(placement: 'left') 46 | $(".wide-body div.btn-group a:contains(Add Child)").html(" Child").attr("title", "Add Child") #.tooltip(placement: 'left') 47 | 48 | $(".wide-body .page-header a:contains(Create New Page)").html(" New Page").attr("title", "Create New Page").tooltip(placement: 'left') 49 | 50 | - unless @no_back_button 51 | :coffeescript 52 | index_path = "#{ back_path }" 53 | $(".wide-body .page-header h2:contains(New), .wide-body .page-header h2:contains(Editing)").parent() 54 | .prepend(' Back ') 55 | 56 | $(".wide-body .page-header .btn").removeClass("pull-right").wrapAll("
") 57 | -------------------------------------------------------------------------------- /lib/cms/fortress/rails/engine.rb: -------------------------------------------------------------------------------- 1 | module Cms 2 | module Fortress 3 | class Engine < ::Rails::Engine 4 | 5 | initializer 'cms-fortress.setup' do |app| 6 | app.config.to_prepare do 7 | # Devise::SessionsController.layout "cms/fortress/session" 8 | ApplicationController.helper(Cms::Fortress::ApplicationHelper) 9 | 10 | Sprockets::Context.send :include, Cms::Fortress::SprocketHelper 11 | 12 | Comfy::Cms::ContentController.send(:include, Cms::Fortress::ContentRenderer) 13 | Comfy::Admin::Cms::PagesController.send(:include, Cms::Fortress::PagesControllerMethods) 14 | Comfy::Cms::Page.send(:include, Cms::Fortress::PageMethods) 15 | Comfy::Cms::File.send(:include, Cms::Fortress::FileMethods) 16 | Comfy::Cms::Site.send(:include, Cms::Fortress::SiteMethods) 17 | 18 | 19 | Comfy::Admin::Cms::BaseController.class_eval do 20 | before_action do 21 | if current_cms_fortress_user && current_cms_fortress_user.type.eql?(:site_user) 22 | @site = current_cms_fortress_user.site 23 | session[:site_id] = @site.id if @site 24 | end 25 | end 26 | end 27 | 28 | # Insert Roles 29 | Comfy::Admin::Cms::SitesController.send :include, Cms::Fortress::SiteControllerMethods 30 | 31 | Comfy::Admin::Cms::LayoutsController.class_eval do 32 | before_action do 33 | authorize! :manage, Comfy::Cms::Layout 34 | end 35 | end 36 | Comfy::Admin::Cms::SnippetsController.class_eval do 37 | before_action do 38 | authorize! :manage, Comfy::Cms::Snippet 39 | end 40 | end 41 | Comfy::Admin::Cms::PagesController.class_eval do 42 | before_action do 43 | authorize! :manage, Comfy::Cms::Page 44 | end 45 | end 46 | Comfy::Admin::Cms::FilesController.class_eval do 47 | before_action do 48 | authorize! :manage, Comfy::Cms::File 49 | end 50 | end 51 | 52 | end 53 | app.config.railties_order = [ :all, ComfortableMexicanSofa::Engine, Cms::Fortress::Engine ] 54 | 55 | ActiveSupport.on_load(:action_controller) do 56 | include Cms::Fortress::ApplicationControllerMethods 57 | end 58 | end 59 | 60 | initializer :assets do |config| 61 | Rails.application.config.assets.precompile += %w( cms/fortress/admin_overrides.css cms/fortress/session.css cms/fortress/themes/wide.css cms/fortress/themes/wide.js cms/fortress/media.js html5shiv.js) 62 | end 63 | end 64 | end 65 | end 66 | 67 | -------------------------------------------------------------------------------- /lib/cms/fortress/application_controller_methods.rb: -------------------------------------------------------------------------------- 1 | module Cms 2 | module Fortress 3 | module ApplicationControllerMethods 4 | 5 | def after_sign_in_path_for(resource) 6 | if resource.class.eql?(Cms::Fortress::User) 7 | session[:site_id] = resource.site_id 8 | #comfy_admin_cms_path 9 | dashboard_site_path 10 | else 11 | begin 12 | stored_location_for(resource) || send("after_sign_in_path_for_#{ resource.class.name.underscore }", resource) 13 | rescue 14 | raise "Cannot find `after_sign_in_path_for_#{ resource.class.name.underscore }` in your ApplicationController class." 15 | end 16 | end 17 | end 18 | 19 | def after_sign_out_path_for(resource_or_scope) 20 | # request.referrer 21 | if resource_or_scope.eql?(:cms_fortress_user) 22 | # comfy_admin_cms_path 23 | dashboard_site_path 24 | else 25 | begin 26 | stored_location_for(resource_or_scope) || send("after_sign_out_path_for_#{ resource_or_scope.to_s }", resource_or_scope) 27 | rescue 28 | raise "Cannot find `after_sign_out_path_for_#{ resource.class.name.underscore }` in your ApplicationController class." 29 | end 30 | end 31 | end 32 | 33 | def ability_class 34 | 35 | if defined?(Ability) 36 | Ability 37 | else 38 | CmsAbility 39 | end 40 | end 41 | 42 | def current_ability 43 | @current_ability ||= ability_class.new(current_cms_fortress_user) 44 | end 45 | 46 | def self.included(base) 47 | base.class_eval do 48 | 49 | before_action :configure_permitted_parameters, if: :devise_controller? 50 | 51 | rescue_from CanCan::AccessDenied do |ex| 52 | # if cannot view page check if can on files 53 | if controller_name.eql?('pages') 54 | if can? :view, Comfy::Cms::File 55 | redirect_to comfy_admin_cms_site_files_path 56 | else 57 | redirect_to cms_fortress_unauthorised_path 58 | end 59 | elsif controller_name.eql?('layouts') 60 | if can? :view, Comfy::Cms::Snippet 61 | redirect_to comfy_admin_cms_site_snippets_path 62 | else 63 | redirect_to cms_fortress_unauthorised_path 64 | end 65 | elsif controller_name.eql?('sites') 66 | if can? :view, Cms::Fortress::Role 67 | redirect_to cms_fortress_roles_path 68 | else 69 | redirect_to cms_fortress_unauthorised_path 70 | end 71 | else 72 | redirect_to cms_fortress_unauthorised_path #, :alert => ex.message 73 | end 74 | end 75 | 76 | protected 77 | 78 | def configure_permitted_parameters 79 | devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:email, :password, :remember_me, :site_id) } 80 | end 81 | 82 | end 83 | end 84 | 85 | end 86 | end 87 | end 88 | -------------------------------------------------------------------------------- /lib/cms-fortress.rb: -------------------------------------------------------------------------------- 1 | require 'comfortable_mexican_sofa' 2 | require 'devise' 3 | require 'cancan' 4 | require 'aasm' 5 | require 'tinymce-rails' 6 | require 'tinymce-rails-langs' 7 | 8 | require_relative 'comfortable_mexican_sofa/fixture/page' 9 | 10 | require_relative 'cms/fortress/application_controller_methods' 11 | require_relative 'cms/fortress/sites_controller_methods' 12 | require_relative 'cms/fortress/pages_controller_methods' 13 | require_relative 'cms/fortress/page_methods' 14 | require_relative 'cms/fortress/file_methods' 15 | require_relative 'cms/fortress/site_methods' 16 | require_relative 'cms/fortress/rails/engine' 17 | require_relative 'cms/fortress/auth' 18 | require_relative 'cms/fortress/content_renderer' 19 | require_relative 'cms/fortress/comfortable_mexican_sofa' 20 | require_relative 'cms/fortress/devise' 21 | require_relative 'cms/fortress/routing' 22 | require_relative '../app/models/cms_ability' 23 | 24 | module Cms 25 | module Fortress 26 | class Configuration 27 | 28 | attr_accessor :content_resources 29 | attr_accessor :design_resources 30 | attr_accessor :settings_resources 31 | attr_accessor :enable_page_workflow 32 | attr_accessor :enable_page_caching 33 | attr_accessor :theme 34 | attr_accessor :login_site_selector 35 | 36 | def initialize 37 | self.class.send(:include, Rails.application.routes.url_helpers) 38 | @theme = :default 39 | @enable_page_workflow = true 40 | @enable_page_caching = true 41 | @login_site_selector = false 42 | @content_resources = [ 43 | {:name => 'pages', :title => 'comfy.admin.cms.base.pages', 44 | :path => 'comfy_admin_cms_site_pages_path(@site) if @site && !@site.new_record?'}, 45 | {:name => 'files', :title => 'comfy.admin.cms.base.files', 46 | :path => 'comfy_admin_cms_site_files_path(@site) if @site && !@site.new_record?'} 47 | ] 48 | @design_resources = [ 49 | {:name => 'layouts', :title => 'comfy.admin.cms.base.layouts', 50 | :path => 'comfy_admin_cms_site_layouts_path(@site) if @site && !@site.new_record?' 51 | }, 52 | {:name => 'snippets', :title => 'comfy.admin.cms.base.snippets', 53 | :path => 'comfy_admin_cms_site_snippets_path(@site) if @site && !@site.new_record?'} 54 | ] 55 | @settings_resources = [ 56 | {name: 'dropdown-header', title: "cms.fortress.admin.super_user.menu_header", super_user: true}, 57 | {:name => 'sites', :title => 'comfy.admin.cms.base.sites', 58 | :path => 'comfy_admin_cms_sites_path', :super_user => true}, 59 | {:name => 'super_users', :title => 'cms.fortress.admin.super_user.title', 60 | :path => 'super_cms_fortress_users_path', :super_user => true}, 61 | {name: 'divider', super_user: true}, 62 | {name: 'dropdown-header', title: "cms.fortress.admin.sites.menu_header"}, 63 | {:name => 'roles', :title => 'cms.fortress.roles.title', 64 | :path => 'cms_fortress_roles_path'}, 65 | {:name => 'users', :title => 'cms.fortress.users.title', 66 | :path => 'cms_fortress_users_path'} 67 | ] 68 | end 69 | 70 | end 71 | 72 | class << self 73 | def configure 74 | yield configuration 75 | end 76 | 77 | def configuration 78 | @configuration ||= Configuration.new 79 | end 80 | 81 | end 82 | 83 | end 84 | end 85 | -------------------------------------------------------------------------------- /app/views/cms/fortress/themes/wide/_menu.html.haml: -------------------------------------------------------------------------------- 1 | %nav.navbar.navbar-default(role="navigation") 2 | .container-fluid 3 | .navbar-header 4 | %button.navbar-toggle(type="button" data-toggle="collapse" data-target="#main-nav") 5 | %span.sr-only= t('cms.fortress.toggle_navigation') 6 | %span.icon-bar 7 | %span.icon-bar 8 | %span.icon-bar 9 | = link_to settings.title, settings.title_link, class: 'navbar-brand' 10 | 11 | .collapse.navbar-collapse#main-nav 12 | %ul.nav.navbar-nav 13 | 14 | - if @site && !@site.new_record? 15 | %li= topnav_item t("cms.fortress.admin.dashboard.title"), dashboard_site_path, current_page?(dashboard_site_path) 16 | 17 | - if Cms::Fortress.configuration.content_resources.any? {|resource| can? :view, "contents.#{resource[:name]}" } 18 | %li.dropdown(class="#{ "active" if content_page? }") 19 | %a.dropdown-toggle(data-toggle='dropdown' href='#') 20 | = t("cms.fortress.contents") 21 | %b.caret 22 | %ul.dropdown-menu 23 | 24 | - Cms::Fortress.configuration.content_resources.each do |resource| 25 | - if resource[:super_user] 26 | - if current_cms_fortress_user.type.eql?(:super_user) 27 | = topnav_resource_item("contents", resource) 28 | - else 29 | = topnav_resource_item("contents", resource) 30 | 31 | - if Cms::Fortress.configuration.design_resources.any? {|resource| can? :view, "designs.#{resource[:name]}" } 32 | %li.dropdown(class="#{ "active" if design_page? }") 33 | %a.dropdown-toggle(data-toggle='dropdown' href='#') 34 | = t("cms.fortress.design") 35 | %b.caret 36 | %ul.dropdown-menu 37 | - Cms::Fortress.configuration.design_resources.each do |resource| 38 | - if resource[:super_user] 39 | - if current_cms_fortress_user.type.eql?(:super_user) 40 | = topnav_resource_item("designs", resource) 41 | - else 42 | = topnav_resource_item("designs", resource) 43 | 44 | - if Cms::Fortress.configuration.settings_resources.any? {|resource| can? :view, "settings.#{resource[:name]}" } 45 | %li.dropdown(class="#{ "active" if admin_page? }") 46 | %a.dropdown-toggle(data-toggle='dropdown' href='#') 47 | = t("cms.fortress.settings") 48 | %b.caret 49 | %ul.dropdown-menu 50 | - Cms::Fortress.configuration.settings_resources.each do |resource| 51 | - if resource[:super_user] 52 | - if current_cms_fortress_user.type.eql?(:super_user) 53 | = topnav_resource_item("settings", resource) 54 | - else 55 | = topnav_resource_item("settings", resource) 56 | 57 | 58 | = render 'cms/fortress/admin/topnav' 59 | 60 | 61 | - if current_cms_fortress_user 62 | .btn-group.pull-right(style="margin-top: 8px;") 63 | %button.btn.btn-default.dropdown-toggle(type="button" data-toggle="dropdown") 64 | = current_cms_fortress_user.display_name 65 | %span.caret 66 | %ul.dropdown-menu(role="menu") 67 | %li 68 | = link_to t('cms.fortress.logout'), destroy_cms_fortress_user_session_path, :method => 'delete' 69 | 70 | 71 | -------------------------------------------------------------------------------- /app/controllers/cms/fortress/roles_controller.rb: -------------------------------------------------------------------------------- 1 | class Cms::Fortress::RolesController < Comfy::Admin::Cms::BaseController 2 | before_filter do 3 | authorize! :manage, Cms::Fortress::Role 4 | end 5 | before_action :set_role, only: [:show, :edit, :update, :destroy, :refresh] 6 | 7 | # GET /cms/fortress/roles 8 | # GET /cms/fortress/roles.json 9 | def index 10 | @cms_fortress_roles = @site.roles 11 | end 12 | 13 | # GET /cms/fortress/roles/1 14 | # GET /cms/fortress/roles/1.json 15 | def show 16 | @no_back_button = true 17 | respond_to do |format| 18 | format.html # show.html.erb 19 | format.json { render json: @cms_fortress_role } 20 | end 21 | end 22 | 23 | def refresh 24 | # @cms_fortress_role = Cms::Fortress::Role.find(params[:id]) 25 | @cms_fortress_role.load_defaults 26 | 27 | respond_to do |format| 28 | if @cms_fortress_role.save 29 | format.html { redirect_to @cms_fortress_role } 30 | format.json { render json: @cms_fotress_role } 31 | else 32 | format.html { render action: "show" } 33 | format.json { render json: @cms_fortress_role.errors, status: :unprocessable_entity } 34 | end 35 | end 36 | end 37 | 38 | # GET /cms/fortress/roles/new 39 | # GET /cms/fortress/roles/new.json 40 | def new 41 | @cms_fortress_role = @site.roles.build 42 | end 43 | 44 | # GET /cms/fortress/roles/1/edit 45 | def edit 46 | end 47 | 48 | # POST /cms/fortress/roles 49 | # POST /cms/fortress/roles.json 50 | def create 51 | @cms_fortress_role = @site.roles.build(role_params) 52 | begin 53 | @cms_fortress_role.load_defaults 54 | rescue Cms::Fortress::Error::MissingRoleConfigurationFile 55 | flash[:error] = @cms_fortress_role.errors.messages[:base].first 56 | render action: "new" and return 57 | end 58 | 59 | respond_to do |format| 60 | if @cms_fortress_role.save 61 | flash[:success] = "Role was successfully created." 62 | format.html { redirect_to @cms_fortress_role } 63 | format.json { render json: @cms_fortress_role, status: :created, location: @cms_fortress_role } 64 | else 65 | format.html { render action: "new" } 66 | format.json { render json: @cms_fortress_role.errors, status: :unprocessable_entity } 67 | end 68 | end 69 | end 70 | 71 | # PUT /cms/fortress/roles/1 72 | # PUT /cms/fortress/roles/1.json 73 | def update 74 | respond_to do |format| 75 | if @cms_fortress_role.update_attributes(role_params) 76 | flash[:success] = "Role was successfully updated." 77 | format.html { redirect_to @cms_fortress_role } 78 | format.json { head :no_content } 79 | else 80 | format.html { render action: "edit" } 81 | format.json { render json: @cms_fortress_role.errors, status: :unprocessable_entity } 82 | end 83 | end 84 | end 85 | 86 | # DELETE /cms/fortress/roles/1 87 | # DELETE /cms/fortress/roles/1.json 88 | def destroy 89 | @cms_fortress_role.destroy 90 | 91 | respond_to do |format| 92 | format.html { redirect_to cms_fortress_roles_url } 93 | format.json { head :no_content } 94 | end 95 | end 96 | 97 | private 98 | 99 | def set_role 100 | @cms_fortress_role = @site.roles.where(id: params[:id]).first 101 | end 102 | 103 | def role_params 104 | params.require(:cms_fortress_role).permit! #(:name, :description, :role_details_attributes) 105 | end 106 | end 107 | -------------------------------------------------------------------------------- /config/locales/devise.en.yml: -------------------------------------------------------------------------------- 1 | # Additional translations at https://github.com/plataformatec/devise/wiki/I18n 2 | 3 | en: 4 | devise: 5 | confirmations: 6 | confirmed: "Your account was successfully confirmed." 7 | send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes." 8 | send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes." 9 | failure: 10 | already_authenticated: "You are already signed in." 11 | inactive: "Your account is not activated yet." 12 | invalid: "Invalid email or password." 13 | locked: "Your account is locked." 14 | last_attempt: "You have one more attempt before your account will be locked." 15 | not_found_in_database: "Invalid email or password." 16 | timeout: "Your session expired. Please sign in again to continue." 17 | unauthenticated: "You need to sign in or sign up before continuing." 18 | unconfirmed: "You have to confirm your account before continuing." 19 | mailer: 20 | confirmation_instructions: 21 | subject: "Confirmation instructions" 22 | reset_password_instructions: 23 | subject: "Reset password instructions" 24 | unlock_instructions: 25 | subject: "Unlock Instructions" 26 | omniauth_callbacks: 27 | failure: "Could not authenticate you from %{kind} because \"%{reason}\"." 28 | success: "Successfully authenticated from %{kind} account." 29 | passwords: 30 | no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." 31 | send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes." 32 | send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes." 33 | updated: "Your password was changed successfully. You are now signed in." 34 | updated_not_active: "Your password was changed successfully." 35 | registrations: 36 | destroyed: "Bye! Your account was successfully cancelled. We hope to see you again soon." 37 | signed_up: "Welcome! You have signed up successfully." 38 | signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." 39 | signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." 40 | signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please open the link to activate your account." 41 | update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address." 42 | updated: "You updated your account successfully." 43 | sessions: 44 | signed_in: "Signed in successfully." 45 | signed_out: "Signed out successfully." 46 | unlocks: 47 | send_instructions: "You will receive an email with instructions about how to unlock your account in a few minutes." 48 | send_paranoid_instructions: "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes." 49 | unlocked: "Your account has been unlocked successfully. Please sign in to continue." 50 | errors: 51 | messages: 52 | already_confirmed: "was already confirmed, please try signing in" 53 | confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" 54 | expired: "has expired, please request a new one" 55 | not_found: "not found" 56 | not_locked: "was not locked" 57 | not_saved: 58 | one: "1 error prohibited this %{resource} from being saved:" 59 | other: "%{count} errors prohibited this %{resource} from being saved:" 60 | -------------------------------------------------------------------------------- /app/helpers/cms/fortress/application_helper.rb: -------------------------------------------------------------------------------- 1 | require 'cms/fortress/settings' 2 | require 'cms/fortress/error' 3 | 4 | module Cms::Fortress::ApplicationHelper 5 | 6 | def current_site 7 | @site.label 8 | end 9 | 10 | def super_user? 11 | current_cms_fortress_user && current_cms_fortress_user.type.eql?(:super_user) 12 | end 13 | 14 | def dashboard_widget(title, collection, partial="cms/fortress/shared/dashboard_widget") 15 | render partial: partial, locals: {title: title, collection: collection} 16 | end 17 | 18 | def role_display(command) 19 | res = command.split(".") 20 | raw "#{content_tag(:strong, t("cms.fortress.roles.#{res.first}")) } / #{ res[1..-1].map {|r| t("cms.fortress.roles.#{r}")}.join(" - ") }" 21 | end 22 | 23 | def theme_name 24 | Cms::Fortress.configuration.theme.to_s 25 | end 26 | 27 | def default_theme? 28 | theme_name.to_s.eql?('default') 29 | end 30 | 31 | def themed_partial(partial) 32 | render partial: "cms/fortress/themes/#{ theme_name }/#{ partial }" 33 | end 34 | 35 | def back_path 36 | case controller_name 37 | when "pages" 38 | comfy_admin_cms_site_pages_path(@site) 39 | when "files" 40 | comfy_admin_cms_site_files_path(@site) 41 | when "layouts" 42 | comfy_admin_cms_site_layouts_path(@site) 43 | when "snippets" 44 | comfy_admin_cms_site_snippets_path(@site) 45 | else 46 | "" 47 | end 48 | end 49 | 50 | def topnav_resource_item(key, resource) 51 | if ["divider", "dropdown-header"].include?(resource[:name]) 52 | title = resource[:title].nil? ? "" : t(resource[:title], site_name: @site.label) 53 | content_tag(:li, title, class: resource[:name], role: "presentation") 54 | else 55 | if can? :view, "#{ key }.#{ resource[:name] }" 56 | if path = resource_path(resource[:path]) 57 | topnav_item t(resource[:title]), path, current_page?(path) 58 | end 59 | end 60 | end 61 | end 62 | 63 | def resource_path(path) 64 | begin 65 | eval(path) 66 | rescue 67 | end 68 | end 69 | 70 | def media_files_path(type) 71 | if params[:site_id] 72 | if type.eql?(:image) 73 | cms_fortress_files_images_path 74 | elsif type.eql?(:video) 75 | cms_fortress_files_videos_path 76 | else 77 | cms_fortress_files_others_path(format: :json) 78 | end 79 | end 80 | end 81 | 82 | def image_item(m) 83 | styles = {original: m.file.url} 84 | m.file.styles.keys.each {|k,v| styles[k] = m.file.url(k) } 85 | link_to image_tag(m.file.url(:cms_thumb), alt: m.label, class: 'editor-image', data: styles), "#" 86 | end 87 | 88 | def image_styles(m) 89 | links = [] 90 | links << link_to("Original", m.file.url, class: 'label label-primary editor-image-style', target: '_blank', title: "Select original size") 91 | i = 0 92 | m.file.styles.each {|k,v| links << link_to("#{ i+=1 }", m.file.url(k), class: 'label label-primary editor-image-style', target: '_blank', title: "Select #{ k.to_s.titleize }") } 93 | raw links.join(" ") 94 | end 95 | 96 | def topnav_item(title, path, is_current = false) 97 | css_class = is_current ? "active" : "" 98 | content_tag(:li, link_to(title, path), class: css_class, role: "presentation") 99 | end 100 | 101 | def leftnav_item(title, path, options = {}) 102 | content_tag(:li, active_link_to(title, path, options)) 103 | end 104 | 105 | 106 | def admin_page? 107 | controller_name.eql?('admin') && %w{roles users}.include?(action_name) || 108 | Cms::Fortress.configuration.settings_resources. 109 | map { |resource| resource[:name] }. 110 | include?(controller_name) 111 | end 112 | 113 | def design_page? 114 | Cms::Fortress.configuration.design_resources. 115 | map { |resource| resource[:name] }. 116 | include?(controller_name) 117 | end 118 | 119 | def content_page? 120 | Cms::Fortress.configuration.content_resources. 121 | map { |resource| resource[:name] }. 122 | include?(controller_name) 123 | end 124 | 125 | def settings(type = :global_settings) 126 | Cms::Fortress::Settings.new(type) 127 | end 128 | end 129 | 130 | -------------------------------------------------------------------------------- /config/locales/devise.de.yml: -------------------------------------------------------------------------------- 1 | de: 2 | devise: 3 | confirmations: 4 | confirmed: "Vielen Dank für Ihre Registrierung. Bitte melden Sie sich jetzt an." 5 | confirmed_and_signed_in: "Vielen Dank für Ihre Registrierung. Sie sind jetzt angemeldet." 6 | send_instructions: "Sie erhalten in wenigen Minuten eine E-Mail, mit der Sie Ihre Registrierung bestätigen können." 7 | send_paranoid_instructions: "Falls Ihre E-Mail-Adresse in unserer Datenbank existiert erhalten Sie in wenigen Minuten eine E-Mail mit der Sie Ihre Registrierung bestätigen können." 8 | failure: 9 | already_authenticated: "Sie sind bereits angemeldet." 10 | inactive: "Ihr Account ist nicht aktiv." 11 | invalid: "Ungültige Anmeldedaten." 12 | invalid_token: "Der Anmelde-Token ist ungültig." 13 | locked: "Ihr Account ist gesperrt." 14 | not_found_in_database: "E-Mail-Adresse oder Passwort ungültig." 15 | timeout: "Ihre Sitzung ist abgelaufen, bitte melden Sie sich erneut an." 16 | unauthenticated: "Sie müssen sich anmelden oder registrieren, bevor Sie fortfahren können." 17 | unconfirmed: "Sie müssen Ihren Account bestätigen, bevor Sie fortfahren können." 18 | mailer: 19 | confirmation_instructions: 20 | subject: "Anleitung zur Bestätigung Ihres Accounts" 21 | reset_password_instructions: 22 | subject: "Anleitung um Ihr Passwort zurückzusetzen" 23 | unlock_instructions: 24 | subject: "Anleitung um Ihren Account freizuschalten" 25 | omniauth_callbacks: 26 | failure: "Sie konnten nicht mit Ihrem %{kind}-Account angemeldet werden, weil '%{reason}'." 27 | success: "Sie haben sich erfolgreich mit Ihrem %{kind}-Account angemeldet." 28 | passwords: 29 | no_token: "Sie können diese Seite nur von dem Link aus einer E-Mail zum Passwort-Zurücksetzen aufrufen. Wenn Sie einen solchen Link aufgerufen haben, stellen Sie bitte sicher, dass Sie die vollständige Adresse aufrufen." 30 | send_instructions: "Sie erhalten in wenigen Minuten eine E-Mail mit der Anleitung, wie Sie Ihr Passwort zurücksetzen können." 31 | send_paranoid_instructions: "Falls Ihre E-Mail-Adresse in unserer Datenbank existiert erhalten Sie in wenigen Minuten eine E-Mail mit der Anleitung, wie Sie Ihr Passwort zurücksetzen können." 32 | updated: "Ihr Passwort wurde geändert. Sie sind jetzt angemeldet." 33 | updated_not_active: "Ihr Passwort wurde geändert." 34 | registrations: 35 | destroyed: "Ihr Account wurde gelöscht." 36 | signed_up: "Sie haben sich erfolgreich registriert." 37 | signed_up_but_inactive: "Sie haben sich erfolgreich registriert. Wir konnten Sie noch nicht anmelden, da Ihr Account inaktiv ist." 38 | signed_up_but_locked: "Sie haben sich erfolgreich registriert. Wir konnten Sie noch nicht anmelden, da Ihr Account gesperrt ist." 39 | signed_up_but_unconfirmed: "Sie haben sich erfolgreich registriert. Wir konnten Sie noch nicht anmelden, da Ihr Account noch nicht bestätigt ist. Sie erhalten in Kürze eine E-Mail mit der Anleitung, wie Sie Ihren Account freischalten können." 40 | update_needs_confirmation: "Ihre Daten wurden aktualisiert, aber Sie müssen Ihre neue E-Mail-Adresse bestätigen. Sie erhalten in wenigen Minuten eine E-Mail, mit der Sie die Änderung Ihrer E-Mail-Adresse abschliessen können." 41 | updated: "Ihre Daten wurden aktualisiert." 42 | sessions: 43 | signed_in: "Erfolgreich angemeldet." 44 | signed_out: "Erfolgreich abgemeldet." 45 | unlocks: 46 | send_instructions: "Sie erhalten in wenigen Minuten eine E-Mail mit der Anleitung, wie Sie Ihren Account entsperren können." 47 | send_paranoid_instructions: "Falls Ihre E-Mail-Adresse in unserer Datenbank existiert erhalten Sie in wenigen Minuten eine E-Mail mit der Anleitung, wie Sie Ihren Account entsperren können." 48 | unlocked: "Ihr Account wurde entsperrt. Sie sind jetzt angemeldet." 49 | errors: 50 | messages: 51 | already_confirmed: "wurde bereits bestätigt" 52 | confirmation_period_expired: "muss innerhalb %{period} bestätigt werden, bitte fordern Sie einen neuen Link an" 53 | expired: "ist abgelaufen, bitte neu anfordern" 54 | not_found: "nicht gefunden" 55 | not_locked: "ist nicht gesperrt" 56 | not_saved: 57 | one: "Konnte %{resource} nicht speichern: ein Fehler." 58 | other: "Konnte %{resource} nicht speichern: %{count} Fehler." -------------------------------------------------------------------------------- /app/controllers/cms/fortress/users_controller.rb: -------------------------------------------------------------------------------- 1 | class Cms::Fortress::UsersController < Comfy::Admin::Cms::BaseController 2 | before_action do 3 | authorize! :manage, Cms::Fortress::User 4 | end 5 | before_action :set_user, :valid_super, only: [:show, :edit, :update, :destroy] 6 | before_action :check_super, only: [:super, :new_super] 7 | 8 | # GET /cms/fortress/users 9 | # GET /cms/fortress/users.json 10 | def index 11 | @super_user = false 12 | @cms_fortress_users = @site.users 13 | end 14 | 15 | def super 16 | @super_user = true 17 | @cms_fortress_users = Cms::Fortress::User.all_super 18 | render action: :index 19 | end 20 | 21 | # GET /cms/fortress/users/1 22 | # GET /cms/fortress/users/1.json 23 | def show 24 | end 25 | 26 | # GET /cms/fortress/users/new 27 | # GET /cms/fortress/users/new.json 28 | def new 29 | @super_user = false 30 | @cms_fortress_user = @site.users.build(type_id: 2) 31 | end 32 | 33 | def new_super 34 | @super_user = true 35 | @cms_fortress_user = Cms::Fortress::User.new(type_id: 1) 36 | render action: :new 37 | end 38 | 39 | # GET /cms/fortress/users/1/edit 40 | def edit 41 | end 42 | 43 | # POST /cms/fortress/users 44 | # POST /cms/fortress/users.json 45 | def create 46 | @cms_fortress_user = @site.users.build(user_params) 47 | raise CanCan::AccessDenied.new("Your are not allowed to create a super user.") if @cms_fortress_user.type.eql?(:super_user) && !current_cms_fortress_user.type.eql?(:super_user) 48 | @cms_fortress_user.site_id = nil if @cms_fortress_user.type.eql?(:super_user) 49 | 50 | if @cms_fortress_user.save 51 | flash[:success] = "User was successfully created." 52 | respond_to do |format| 53 | format.html { redirect_to @cms_fortress_user.type.eql?(:super_user) ? super_cms_fortress_users_path : cms_fortress_users_path } 54 | format.json { render json: @cms_fortress_user, status: :created, location: @cms_fortress_user } 55 | end 56 | else 57 | respond_to do |format| 58 | format.html { render action: "new" } 59 | format.json { render json: @cms_fortress_user.errors, status: :unprocessable_entity } 60 | end 61 | end 62 | end 63 | 64 | # PUT /cms/fortress/users/1 65 | # PUT /cms/fortress/users/1.json 66 | def update 67 | user = user_params 68 | 69 | raise CanCan::AccessDenied.new("Your are not allowed to create a super user.") if user[:type_id].eql?(1) && !current_cms_fortress_user.type.eql?(:super_user) 70 | 71 | if user[:password].blank? 72 | user.delete(:password) 73 | user.delete(:password_confirmation) if user[:password_confirmation].blank? 74 | end 75 | 76 | respond_to do |format| 77 | if @cms_fortress_user.update_attributes(user) 78 | flash[:success] = "User was successfully updated." 79 | format.html { redirect_to @cms_fortress_user.type.eql?(:super_user) ? super_cms_fortress_users_path : cms_fortress_users_path } 80 | format.json { head :no_content } 81 | else 82 | format.html { render action: "edit" } 83 | format.json { render json: @cms_fortress_user.errors, status: :unprocessable_entity } 84 | end 85 | end 86 | end 87 | 88 | # DELETE /cms/fortress/users/1 89 | # DELETE /cms/fortress/users/1.json 90 | def destroy 91 | @cms_fortress_user.destroy 92 | 93 | respond_to do |format| 94 | format.html { redirect_to @cms_fortress_user.type.eql?(:super_user) ? super_cms_fortress_users_path : cms_fortress_users_path } 95 | format.json { head :no_content } 96 | end 97 | end 98 | 99 | private 100 | 101 | def valid_super 102 | raise CanCan::AccessDenied.new("Your are not authorised to execute this process.") if @cms_fortress_user.type.eql?(:super_user) && !current_cms_fortress_user.type.eql?(:super_user) 103 | @super_user = @cms_fortress_user.type.eql?(:super_user) 104 | end 105 | 106 | def check_super 107 | raise CanCan::AccessDenied.new("Your are not authorised to execute this process.") unless current_cms_fortress_user.type.eql?(:super_user) 108 | # @super_user = current_cms_fortress_user.type.eql?(:super_user) 109 | end 110 | 111 | def set_user 112 | @cms_fortress_user = Cms::Fortress::User.find(params[:id]) # @site.users.where(id: params[:id]).first 113 | end 114 | 115 | def user_params 116 | params.require(:cms_fortress_user).permit(:last_name, :first_name, :email, :type_id, :role_id, :password, :password_confirmation) 117 | end 118 | end 119 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | cms: 3 | fortress: 4 | page_title: CMS Fortress Admin 5 | title: CMS Fortress 6 | contents: Contents 7 | design: Design 8 | admin: Admin 9 | login: Logout 10 | logout: Logout 11 | create: Create 12 | update: Update 13 | delete: Delete 14 | edit: Edit 15 | are_you_sure: Are you sure? 16 | cancel: Cancel 17 | published: Published 18 | published_date: Published At 19 | schedule_date: Scheduled Publication 20 | cache_timeout: Cached Timeout 21 | toggle_navigation: Toggle Navigation 22 | image_selector: Image Selector 23 | insert_item: Click the thumbnail to insert item to the selected editor. 24 | settings: Settings 25 | current_site: Current Site 26 | 27 | admin: 28 | 29 | dashboard: 30 | title: Dashboard 31 | draft_widget: Draft Pages 32 | reviewed_widget: Reviewed Pages 33 | updated_pages: Recently Updated Pages 34 | 35 | sites: 36 | menu_header: "Site/ %{site_name}" 37 | super_user: 38 | title: Super Users 39 | menu_header: Super Users Only 40 | 41 | users: Users 42 | not_authorized: You are not authorized to access this functionality 43 | settings_dashboard: Settings Dashboard 44 | roles: Roles 45 | design_dashboard: Design Dashboard 46 | design_related_information: This page will show design related information. 47 | content_dashboard: Content Dashboard 48 | content_related_information: "This page will show contents related information (history, graphs, analytics and etc.)" 49 | errors: 50 | missing_roles_yaml_file: "The configuration file config/roles.yml is missing." 51 | 52 | roles: 53 | title: Roles 54 | new_link: New Role 55 | edit_title: Edit Role 56 | new_title: Create New Role 57 | back: Back 58 | load: Load New Roles 59 | role: Role 60 | show: Show 61 | manage: Manage 62 | save: Save 63 | description: Description 64 | show_access_rights: Show Access Rights 65 | name: Name 66 | contents: Contents 67 | designs: Designs 68 | settings: Settings 69 | files: Files 70 | page: Page 71 | publish: publish 72 | review: review 73 | pages: Pages 74 | layouts: Layouts 75 | snippets: Snippets 76 | roles: Roles 77 | sites: Sites 78 | users: Users 79 | 80 | users: 81 | title: Users 82 | new_link: New User 83 | new_super_link: New Super User 84 | edit_title: Edit User 85 | new_title: Create New User 86 | last_name: Lastname 87 | first_name: Firstname 88 | email: Email 89 | role: Role 90 | sessions: 91 | new: 92 | sign_in: Sign In 93 | email_address: Email Address 94 | password: Password 95 | remember_me: Remember me 96 | 97 | comfy: 98 | admin: 99 | cms: 100 | pages: 101 | form: &pages_form 102 | review: Approve 103 | reviewed: Reviewed 104 | schedule: Publish Date 105 | scheduled: Scheduled 106 | publish: Publish Now 107 | published: Published 108 | draft: save as draft 109 | drafted: Draft 110 | reset: Reset to Draft 111 | 112 | edit: 113 | <<: *pages_form 114 | 115 | files: 116 | form: 117 | are_you_sure: Are you sure to delete? 118 | delete: Delete! 119 | 120 | activerecord: 121 | attributes: 122 | cms/fortress/user: 123 | last_name: Lastname 124 | first_name: Firstname 125 | email: Email 126 | role_id: Role 127 | password: Password 128 | password_confirmation: Password Confirmation 129 | cms/fortress/role: 130 | name: Name 131 | description: Description 132 | cms/fortress/role_detail: 133 | contents: Contents 134 | comfy/cms/page: 135 | full_path: Path 136 | parent_id: Parent page 137 | slug: Slug 138 | login: 139 | forgot_your_password: Forgot your password? 140 | send_me_reset_password_instructions: Send me reset password instructions 141 | change_your_password: Change your password 142 | new_password: New password 143 | confirm_new_password: Confirm new password 144 | change_my_password: Change my password 145 | log_in: Log in 146 | sign_up: Sign up 147 | didnt_receive_confirmation_instructions: Didn't receive confirmation instructions? 148 | didnt_receive_unlock_instructions: Didn't receive unlock instructions? 149 | sign_in_with: Sign in with #{provider.to_s.titleize} 150 | -------------------------------------------------------------------------------- /config/locales/da.yml: -------------------------------------------------------------------------------- 1 | da: 2 | cms: 3 | fortress: 4 | page_title: CMS Fortress Admin 5 | title: CMS Fortress 6 | contents: Contents 7 | design: Design 8 | admin: Admin 9 | login: Logout 10 | logout: Logout 11 | create: Create 12 | update: Update 13 | delete: Delete 14 | edit: Edit 15 | are_you_sure: Are you sure? 16 | cancel: Cancel 17 | published: Published 18 | published_date: Published At 19 | schedule_date: Scheduled Publication 20 | cache_timeout: Cached Timeout 21 | toggle_navigation: Toggle Navigation 22 | image_selector: Image Selector 23 | insert_item: Click the thumbnail to insert item to the selected editor. 24 | settings: Settings 25 | current_site: Current Site 26 | 27 | admin: 28 | 29 | dashboard: 30 | title: Dashboard 31 | draft_widget: Draft Pages 32 | reviewed_widget: Reviewed Pages 33 | updated_pages: Recently Updated Pages 34 | 35 | sites: 36 | menu_header: "Site/ %{site_name}" 37 | super_user: 38 | title: Super Users 39 | menu_header: Super Users Only 40 | 41 | users: Users 42 | not_authorized: You are not authorized to access this functionality 43 | settings_dashboard: Settings Dashboard 44 | roles: Roles 45 | design_dashboard: Design Dashboard 46 | design_related_information: This page will show design related information. 47 | content_dashboard: Content Dashboard 48 | content_related_information: "This page will show contents related information (history, graphs, analytics and etc.)" 49 | errors: 50 | missing_roles_yaml_file: "The configuration file config/roles.yml is missing." 51 | 52 | roles: 53 | title: Roles 54 | new_link: New Role 55 | edit_title: Edit Role 56 | new_title: Create New Role 57 | back: Back 58 | load: Load New Roles 59 | role: Role 60 | show: Show 61 | manage: Manage 62 | save: Save 63 | description: Description 64 | show_access_rights: Show Access Rights 65 | name: Name 66 | contents: Contents 67 | designs: Designs 68 | settings: Settings 69 | files: Files 70 | page: Page 71 | publish: publish 72 | review: review 73 | pages: Pages 74 | layouts: Layouts 75 | snippets: Snippets 76 | roles: Roles 77 | sites: Sites 78 | users: Users 79 | 80 | users: 81 | title: Users 82 | new_link: New User 83 | new_super_link: New Super User 84 | edit_title: Edit User 85 | new_title: Create New User 86 | last_name: Lastname 87 | first_name: Firstname 88 | email: Email 89 | role: Role 90 | sessions: 91 | new: 92 | sign_in: Sign In 93 | email_address: Email Address 94 | password: Password 95 | remember_me: Remember me 96 | 97 | comfy: 98 | admin: 99 | cms: 100 | pages: 101 | form: &pages_form 102 | review: Approve 103 | reviewed: Reviewed 104 | schedule: Publish Date 105 | scheduled: Scheduled 106 | publish: Publish Now 107 | published: Published 108 | draft: save as draft 109 | drafted: Draft 110 | reset: Reset to Draft 111 | 112 | edit: 113 | <<: *pages_form 114 | 115 | files: 116 | form: 117 | are_you_sure: Are you sure to delete? 118 | delete: Delete! 119 | 120 | activerecord: 121 | attributes: 122 | cms/fortress/user: 123 | last_name: Lastname 124 | first_name: Firstname 125 | email: Email 126 | role_id: Role 127 | password: Password 128 | password_confirmation: Password Confirmation 129 | cms/fortress/role: 130 | name: Name 131 | description: Description 132 | cms/fortress/role_detail: 133 | contents: Contents 134 | comfy/cms/page: 135 | full_path: Path 136 | parent_id: Parent page 137 | slug: Slug 138 | 139 | login: 140 | forgot_your_password: Forgot your password? 141 | send_me_reset_password_instructions: Send me reset password instructions 142 | change_your_password: Change your password 143 | new_password: New password 144 | confirm_new_password: Confirm new password 145 | change_my_password: Change my password 146 | log_in: Log in 147 | sign_up: Sign up 148 | didnt_receive_confirmation_instructions: Didn't receive confirmation instructions? 149 | didnt_receive_unlock_instructions: Didn't receive unlock instructions? 150 | sign_in_with: Sign in with #{provider.to_s.titleize} 151 | -------------------------------------------------------------------------------- /config/locales/fr.yml: -------------------------------------------------------------------------------- 1 | fr: 2 | cms: 3 | fortress: 4 | page_title: CMS Fortress Admin 5 | title: CMS Fortress 6 | contents: Contents 7 | design: Design 8 | admin: Admin 9 | login: Logout 10 | logout: Logout 11 | create: Create 12 | update: Update 13 | delete: Delete 14 | edit: Edit 15 | are_you_sure: Are you sure? 16 | cancel: Cancel 17 | published: Published 18 | published_date: Published At 19 | schedule_date: Scheduled Publication 20 | cache_timeout: Cached Timeout 21 | toggle_navigation: Toggle Navigation 22 | image_selector: Image Selector 23 | insert_item: Click the thumbnail to insert item to the selected editor. 24 | settings: Settings 25 | current_site: Current Site 26 | 27 | admin: 28 | 29 | dashboard: 30 | title: Dashboard 31 | draft_widget: Draft Pages 32 | reviewed_widget: Reviewed Pages 33 | updated_pages: Recently Updated Pages 34 | 35 | sites: 36 | menu_header: "Site/ %{site_name}" 37 | super_user: 38 | title: Super Users 39 | menu_header: Super Users Only 40 | 41 | users: Users 42 | not_authorized: You are not authorized to access this functionality 43 | settings_dashboard: Settings Dashboard 44 | roles: Roles 45 | design_dashboard: Design Dashboard 46 | design_related_information: This page will show design related information. 47 | content_dashboard: Content Dashboard 48 | content_related_information: "This page will show contents related information (history, graphs, analytics and etc.)" 49 | errors: 50 | missing_roles_yaml_file: "The configuration file config/roles.yml is missing." 51 | 52 | roles: 53 | title: Roles 54 | new_link: New Role 55 | edit_title: Edit Role 56 | new_title: Create New Role 57 | back: Back 58 | load: Load New Roles 59 | role: Role 60 | show: Show 61 | manage: Manage 62 | save: Save 63 | description: Description 64 | show_access_rights: Show Access Rights 65 | name: Name 66 | contents: Contents 67 | designs: Designs 68 | settings: Settings 69 | files: Files 70 | page: Page 71 | publish: publish 72 | review: review 73 | pages: Pages 74 | layouts: Layouts 75 | snippets: Snippets 76 | roles: Roles 77 | sites: Sites 78 | users: Users 79 | 80 | users: 81 | title: Users 82 | new_link: New User 83 | new_super_link: New Super User 84 | edit_title: Edit User 85 | new_title: Create New User 86 | last_name: Lastname 87 | first_name: Firstname 88 | email: Email 89 | role: Role 90 | sessions: 91 | new: 92 | sign_in: Sign In 93 | email_address: Email Address 94 | password: Password 95 | remember_me: Remember me 96 | 97 | comfy: 98 | admin: 99 | cms: 100 | pages: 101 | form: &pages_form 102 | review: Approve 103 | reviewed: Reviewed 104 | schedule: Publish Date 105 | scheduled: Scheduled 106 | publish: Publish Now 107 | published: Published 108 | draft: save as draft 109 | drafted: Draft 110 | reset: Reset to Draft 111 | 112 | edit: 113 | <<: *pages_form 114 | 115 | files: 116 | form: 117 | are_you_sure: Are you sure to delete? 118 | delete: Delete! 119 | 120 | activerecord: 121 | attributes: 122 | cms/fortress/user: 123 | last_name: Lastname 124 | first_name: Firstname 125 | email: Email 126 | role_id: Role 127 | password: Password 128 | password_confirmation: Password Confirmation 129 | cms/fortress/role: 130 | name: Name 131 | description: Description 132 | cms/fortress/role_detail: 133 | contents: Contents 134 | comfy/cms/page: 135 | full_path: Path 136 | parent_id: Parent page 137 | slug: Slug 138 | 139 | login: 140 | forgot_your_password: Forgot your password? 141 | send_me_reset_password_instructions: Send me reset password instructions 142 | change_your_password: Change your password 143 | new_password: New password 144 | confirm_new_password: Confirm new password 145 | change_my_password: Change my password 146 | log_in: Log in 147 | sign_up: Sign up 148 | didnt_receive_confirmation_instructions: Didn't receive confirmation instructions? 149 | didnt_receive_unlock_instructions: Didn't receive unlock instructions? 150 | sign_in_with: Sign in with #{provider.to_s.titleize} 151 | -------------------------------------------------------------------------------- /config/locales/it.yml: -------------------------------------------------------------------------------- 1 | it: 2 | cms: 3 | fortress: 4 | page_title: CMS Fortress Admin 5 | title: CMS Fortress 6 | contents: Contents 7 | design: Design 8 | admin: Admin 9 | login: Logout 10 | logout: Logout 11 | create: Create 12 | update: Update 13 | delete: Delete 14 | edit: Edit 15 | are_you_sure: Are you sure? 16 | cancel: Cancel 17 | published: Published 18 | published_date: Published At 19 | schedule_date: Scheduled Publication 20 | cache_timeout: Cached Timeout 21 | toggle_navigation: Toggle Navigation 22 | image_selector: Image Selector 23 | insert_item: Click the thumbnail to insert item to the selected editor. 24 | settings: Settings 25 | current_site: Current Site 26 | 27 | admin: 28 | 29 | dashboard: 30 | title: Dashboard 31 | draft_widget: Draft Pages 32 | reviewed_widget: Reviewed Pages 33 | updated_pages: Recently Updated Pages 34 | 35 | sites: 36 | menu_header: "Site/ %{site_name}" 37 | super_user: 38 | title: Super Users 39 | menu_header: Super Users Only 40 | 41 | users: Users 42 | not_authorized: You are not authorized to access this functionality 43 | settings_dashboard: Settings Dashboard 44 | roles: Roles 45 | design_dashboard: Design Dashboard 46 | design_related_information: This page will show design related information. 47 | content_dashboard: Content Dashboard 48 | content_related_information: "This page will show contents related information (history, graphs, analytics and etc.)" 49 | errors: 50 | missing_roles_yaml_file: "The configuration file config/roles.yml is missing." 51 | 52 | roles: 53 | title: Roles 54 | new_link: New Role 55 | edit_title: Edit Role 56 | new_title: Create New Role 57 | back: Back 58 | load: Load New Roles 59 | role: Role 60 | show: Show 61 | manage: Manage 62 | save: Save 63 | description: Description 64 | show_access_rights: Show Access Rights 65 | name: Name 66 | contents: Contents 67 | designs: Designs 68 | settings: Settings 69 | files: Files 70 | page: Page 71 | publish: publish 72 | review: review 73 | pages: Pages 74 | layouts: Layouts 75 | snippets: Snippets 76 | roles: Roles 77 | sites: Sites 78 | users: Users 79 | 80 | users: 81 | title: Users 82 | new_link: New User 83 | new_super_link: New Super User 84 | edit_title: Edit User 85 | new_title: Create New User 86 | last_name: Lastname 87 | first_name: Firstname 88 | email: Email 89 | role: Role 90 | sessions: 91 | new: 92 | sign_in: Sign In 93 | email_address: Email Address 94 | password: Password 95 | remember_me: Remember me 96 | 97 | comfy: 98 | admin: 99 | cms: 100 | pages: 101 | form: &pages_form 102 | review: Approve 103 | reviewed: Reviewed 104 | schedule: Publish Date 105 | scheduled: Scheduled 106 | publish: Publish Now 107 | published: Published 108 | draft: save as draft 109 | drafted: Draft 110 | reset: Reset to Draft 111 | 112 | edit: 113 | <<: *pages_form 114 | 115 | files: 116 | form: 117 | are_you_sure: Are you sure to delete? 118 | delete: Delete! 119 | 120 | activerecord: 121 | attributes: 122 | cms/fortress/user: 123 | last_name: Lastname 124 | first_name: Firstname 125 | email: Email 126 | role_id: Role 127 | password: Password 128 | password_confirmation: Password Confirmation 129 | cms/fortress/role: 130 | name: Name 131 | description: Description 132 | cms/fortress/role_detail: 133 | contents: Contents 134 | comfy/cms/page: 135 | full_path: Path 136 | parent_id: Parent page 137 | slug: Slug 138 | 139 | login: 140 | forgot_your_password: Forgot your password? 141 | send_me_reset_password_instructions: Send me reset password instructions 142 | change_your_password: Change your password 143 | new_password: New password 144 | confirm_new_password: Confirm new password 145 | change_my_password: Change my password 146 | log_in: Log in 147 | sign_up: Sign up 148 | didnt_receive_confirmation_instructions: Didn't receive confirmation instructions? 149 | didnt_receive_unlock_instructions: Didn't receive unlock instructions? 150 | sign_in_with: Sign in with #{provider.to_s.titleize} 151 | -------------------------------------------------------------------------------- /config/locales/ja.yml: -------------------------------------------------------------------------------- 1 | ja: 2 | cms: 3 | fortress: 4 | page_title: CMS Fortress Admin 5 | title: CMS Fortress 6 | contents: Contents 7 | design: Design 8 | admin: Admin 9 | login: Logout 10 | logout: Logout 11 | create: Create 12 | update: Update 13 | delete: Delete 14 | edit: Edit 15 | are_you_sure: Are you sure? 16 | cancel: Cancel 17 | published: Published 18 | published_date: Published At 19 | schedule_date: Scheduled Publication 20 | cache_timeout: Cached Timeout 21 | toggle_navigation: Toggle Navigation 22 | image_selector: Image Selector 23 | insert_item: Click the thumbnail to insert item to the selected editor. 24 | settings: Settings 25 | current_site: Current Site 26 | 27 | admin: 28 | 29 | dashboard: 30 | title: Dashboard 31 | draft_widget: Draft Pages 32 | reviewed_widget: Reviewed Pages 33 | updated_pages: Recently Updated Pages 34 | 35 | sites: 36 | menu_header: "Site/ %{site_name}" 37 | super_user: 38 | title: Super Users 39 | menu_header: Super Users Only 40 | 41 | users: Users 42 | not_authorized: You are not authorized to access this functionality 43 | settings_dashboard: Settings Dashboard 44 | roles: Roles 45 | design_dashboard: Design Dashboard 46 | design_related_information: This page will show design related information. 47 | content_dashboard: Content Dashboard 48 | content_related_information: "This page will show contents related information (history, graphs, analytics and etc.)" 49 | errors: 50 | missing_roles_yaml_file: "The configuration file config/roles.yml is missing." 51 | 52 | roles: 53 | title: Roles 54 | new_link: New Role 55 | edit_title: Edit Role 56 | new_title: Create New Role 57 | back: Back 58 | load: Load New Roles 59 | role: Role 60 | show: Show 61 | manage: Manage 62 | save: Save 63 | description: Description 64 | show_access_rights: Show Access Rights 65 | name: Name 66 | contents: Contents 67 | designs: Designs 68 | settings: Settings 69 | files: Files 70 | page: Page 71 | publish: publish 72 | review: review 73 | pages: Pages 74 | layouts: Layouts 75 | snippets: Snippets 76 | roles: Roles 77 | sites: Sites 78 | users: Users 79 | 80 | users: 81 | title: Users 82 | new_link: New User 83 | new_super_link: New Super User 84 | edit_title: Edit User 85 | new_title: Create New User 86 | last_name: Lastname 87 | first_name: Firstname 88 | email: Email 89 | role: Role 90 | sessions: 91 | new: 92 | sign_in: Sign In 93 | email_address: Email Address 94 | password: Password 95 | remember_me: Remember me 96 | 97 | comfy: 98 | admin: 99 | cms: 100 | pages: 101 | form: &pages_form 102 | review: Approve 103 | reviewed: Reviewed 104 | schedule: Publish Date 105 | scheduled: Scheduled 106 | publish: Publish Now 107 | published: Published 108 | draft: save as draft 109 | drafted: Draft 110 | reset: Reset to Draft 111 | 112 | edit: 113 | <<: *pages_form 114 | 115 | files: 116 | form: 117 | are_you_sure: Are you sure to delete? 118 | delete: Delete! 119 | 120 | activerecord: 121 | attributes: 122 | cms/fortress/user: 123 | last_name: Lastname 124 | first_name: Firstname 125 | email: Email 126 | role_id: Role 127 | password: Password 128 | password_confirmation: Password Confirmation 129 | cms/fortress/role: 130 | name: Name 131 | description: Description 132 | cms/fortress/role_detail: 133 | contents: Contents 134 | comfy/cms/page: 135 | full_path: Path 136 | parent_id: Parent page 137 | slug: Slug 138 | 139 | login: 140 | forgot_your_password: Forgot your password? 141 | send_me_reset_password_instructions: Send me reset password instructions 142 | change_your_password: Change your password 143 | new_password: New password 144 | confirm_new_password: Confirm new password 145 | change_my_password: Change my password 146 | log_in: Log in 147 | sign_up: Sign up 148 | didnt_receive_confirmation_instructions: Didn't receive confirmation instructions? 149 | didnt_receive_unlock_instructions: Didn't receive unlock instructions? 150 | sign_in_with: Sign in with #{provider.to_s.titleize} 151 | -------------------------------------------------------------------------------- /config/locales/nl.yml: -------------------------------------------------------------------------------- 1 | nl: 2 | cms: 3 | fortress: 4 | page_title: CMS Fortress Admin 5 | title: CMS Fortress 6 | contents: Contents 7 | design: Design 8 | admin: Admin 9 | login: Logout 10 | logout: Logout 11 | create: Create 12 | update: Update 13 | delete: Delete 14 | edit: Edit 15 | are_you_sure: Are you sure? 16 | cancel: Cancel 17 | published: Published 18 | published_date: Published At 19 | schedule_date: Scheduled Publication 20 | cache_timeout: Cached Timeout 21 | toggle_navigation: Toggle Navigation 22 | image_selector: Image Selector 23 | insert_item: Click the thumbnail to insert item to the selected editor. 24 | settings: Settings 25 | current_site: Current Site 26 | 27 | admin: 28 | 29 | dashboard: 30 | title: Dashboard 31 | draft_widget: Draft Pages 32 | reviewed_widget: Reviewed Pages 33 | updated_pages: Recently Updated Pages 34 | 35 | sites: 36 | menu_header: "Site/ %{site_name}" 37 | super_user: 38 | title: Super Users 39 | menu_header: Super Users Only 40 | 41 | users: Users 42 | not_authorized: You are not authorized to access this functionality 43 | settings_dashboard: Settings Dashboard 44 | roles: Roles 45 | design_dashboard: Design Dashboard 46 | design_related_information: This page will show design related information. 47 | content_dashboard: Content Dashboard 48 | content_related_information: "This page will show contents related information (history, graphs, analytics and etc.)" 49 | errors: 50 | missing_roles_yaml_file: "The configuration file config/roles.yml is missing." 51 | 52 | roles: 53 | title: Roles 54 | new_link: New Role 55 | edit_title: Edit Role 56 | new_title: Create New Role 57 | back: Back 58 | load: Load New Roles 59 | role: Role 60 | show: Show 61 | manage: Manage 62 | save: Save 63 | description: Description 64 | show_access_rights: Show Access Rights 65 | name: Name 66 | contents: Contents 67 | designs: Designs 68 | settings: Settings 69 | files: Files 70 | page: Page 71 | publish: publish 72 | review: review 73 | pages: Pages 74 | layouts: Layouts 75 | snippets: Snippets 76 | roles: Roles 77 | sites: Sites 78 | users: Users 79 | 80 | users: 81 | title: Users 82 | new_link: New User 83 | new_super_link: New Super User 84 | edit_title: Edit User 85 | new_title: Create New User 86 | last_name: Lastname 87 | first_name: Firstname 88 | email: Email 89 | role: Role 90 | sessions: 91 | new: 92 | sign_in: Sign In 93 | email_address: Email Address 94 | password: Password 95 | remember_me: Remember me 96 | 97 | comfy: 98 | admin: 99 | cms: 100 | pages: 101 | form: &pages_form 102 | review: Approve 103 | reviewed: Reviewed 104 | schedule: Publish Date 105 | scheduled: Scheduled 106 | publish: Publish Now 107 | published: Published 108 | draft: save as draft 109 | drafted: Draft 110 | reset: Reset to Draft 111 | 112 | edit: 113 | <<: *pages_form 114 | 115 | files: 116 | form: 117 | are_you_sure: Are you sure to delete? 118 | delete: Delete! 119 | 120 | activerecord: 121 | attributes: 122 | cms/fortress/user: 123 | last_name: Lastname 124 | first_name: Firstname 125 | email: Email 126 | role_id: Role 127 | password: Password 128 | password_confirmation: Password Confirmation 129 | cms/fortress/role: 130 | name: Name 131 | description: Description 132 | cms/fortress/role_detail: 133 | contents: Contents 134 | comfy/cms/page: 135 | full_path: Path 136 | parent_id: Parent page 137 | slug: Slug 138 | 139 | login: 140 | forgot_your_password: Forgot your password? 141 | send_me_reset_password_instructions: Send me reset password instructions 142 | change_your_password: Change your password 143 | new_password: New password 144 | confirm_new_password: Confirm new password 145 | change_my_password: Change my password 146 | log_in: Log in 147 | sign_up: Sign up 148 | didnt_receive_confirmation_instructions: Didn't receive confirmation instructions? 149 | didnt_receive_unlock_instructions: Didn't receive unlock instructions? 150 | sign_in_with: Sign in with #{provider.to_s.titleize} 151 | -------------------------------------------------------------------------------- /config/locales/pl.yml: -------------------------------------------------------------------------------- 1 | pl: 2 | cms: 3 | fortress: 4 | page_title: CMS Fortress Admin 5 | title: CMS Fortress 6 | contents: Contents 7 | design: Design 8 | admin: Admin 9 | login: Logout 10 | logout: Logout 11 | create: Create 12 | update: Update 13 | delete: Delete 14 | edit: Edit 15 | are_you_sure: Are you sure? 16 | cancel: Cancel 17 | published: Published 18 | published_date: Published At 19 | schedule_date: Scheduled Publication 20 | cache_timeout: Cached Timeout 21 | toggle_navigation: Toggle Navigation 22 | image_selector: Image Selector 23 | insert_item: Click the thumbnail to insert item to the selected editor. 24 | settings: Settings 25 | current_site: Current Site 26 | 27 | admin: 28 | 29 | dashboard: 30 | title: Dashboard 31 | draft_widget: Draft Pages 32 | reviewed_widget: Reviewed Pages 33 | updated_pages: Recently Updated Pages 34 | 35 | sites: 36 | menu_header: "Site/ %{site_name}" 37 | super_user: 38 | title: Super Users 39 | menu_header: Super Users Only 40 | 41 | users: Users 42 | not_authorized: You are not authorized to access this functionality 43 | settings_dashboard: Settings Dashboard 44 | roles: Roles 45 | design_dashboard: Design Dashboard 46 | design_related_information: This page will show design related information. 47 | content_dashboard: Content Dashboard 48 | content_related_information: "This page will show contents related information (history, graphs, analytics and etc.)" 49 | errors: 50 | missing_roles_yaml_file: "The configuration file config/roles.yml is missing." 51 | 52 | roles: 53 | title: Roles 54 | new_link: New Role 55 | edit_title: Edit Role 56 | new_title: Create New Role 57 | back: Back 58 | load: Load New Roles 59 | role: Role 60 | show: Show 61 | manage: Manage 62 | save: Save 63 | description: Description 64 | show_access_rights: Show Access Rights 65 | name: Name 66 | contents: Contents 67 | designs: Designs 68 | settings: Settings 69 | files: Files 70 | page: Page 71 | publish: publish 72 | review: review 73 | pages: Pages 74 | layouts: Layouts 75 | snippets: Snippets 76 | roles: Roles 77 | sites: Sites 78 | users: Users 79 | 80 | users: 81 | title: Users 82 | new_link: New User 83 | new_super_link: New Super User 84 | edit_title: Edit User 85 | new_title: Create New User 86 | last_name: Lastname 87 | first_name: Firstname 88 | email: Email 89 | role: Role 90 | sessions: 91 | new: 92 | sign_in: Sign In 93 | email_address: Email Address 94 | password: Password 95 | remember_me: Remember me 96 | 97 | comfy: 98 | admin: 99 | cms: 100 | pages: 101 | form: &pages_form 102 | review: Approve 103 | reviewed: Reviewed 104 | schedule: Publish Date 105 | scheduled: Scheduled 106 | publish: Publish Now 107 | published: Published 108 | draft: save as draft 109 | drafted: Draft 110 | reset: Reset to Draft 111 | 112 | edit: 113 | <<: *pages_form 114 | 115 | files: 116 | form: 117 | are_you_sure: Are you sure to delete? 118 | delete: Delete! 119 | 120 | activerecord: 121 | attributes: 122 | cms/fortress/user: 123 | last_name: Lastname 124 | first_name: Firstname 125 | email: Email 126 | role_id: Role 127 | password: Password 128 | password_confirmation: Password Confirmation 129 | cms/fortress/role: 130 | name: Name 131 | description: Description 132 | cms/fortress/role_detail: 133 | contents: Contents 134 | comfy/cms/page: 135 | full_path: Path 136 | parent_id: Parent page 137 | slug: Slug 138 | 139 | login: 140 | forgot_your_password: Forgot your password? 141 | send_me_reset_password_instructions: Send me reset password instructions 142 | change_your_password: Change your password 143 | new_password: New password 144 | confirm_new_password: Confirm new password 145 | change_my_password: Change my password 146 | log_in: Log in 147 | sign_up: Sign up 148 | didnt_receive_confirmation_instructions: Didn't receive confirmation instructions? 149 | didnt_receive_unlock_instructions: Didn't receive unlock instructions? 150 | sign_in_with: Sign in with #{provider.to_s.titleize} 151 | -------------------------------------------------------------------------------- /config/locales/sv.yml: -------------------------------------------------------------------------------- 1 | sv: 2 | cms: 3 | fortress: 4 | page_title: CMS Fortress Admin 5 | title: CMS Fortress 6 | contents: Contents 7 | design: Design 8 | admin: Admin 9 | login: Logout 10 | logout: Logout 11 | create: Create 12 | update: Update 13 | delete: Delete 14 | edit: Edit 15 | are_you_sure: Are you sure? 16 | cancel: Cancel 17 | published: Published 18 | published_date: Published At 19 | schedule_date: Scheduled Publication 20 | cache_timeout: Cached Timeout 21 | toggle_navigation: Toggle Navigation 22 | image_selector: Image Selector 23 | insert_item: Click the thumbnail to insert item to the selected editor. 24 | settings: Settings 25 | current_site: Current Site 26 | 27 | admin: 28 | 29 | dashboard: 30 | title: Dashboard 31 | draft_widget: Draft Pages 32 | reviewed_widget: Reviewed Pages 33 | updated_pages: Recently Updated Pages 34 | 35 | sites: 36 | menu_header: "Site/ %{site_name}" 37 | super_user: 38 | title: Super Users 39 | menu_header: Super Users Only 40 | 41 | users: Users 42 | not_authorized: You are not authorized to access this functionality 43 | settings_dashboard: Settings Dashboard 44 | roles: Roles 45 | design_dashboard: Design Dashboard 46 | design_related_information: This page will show design related information. 47 | content_dashboard: Content Dashboard 48 | content_related_information: "This page will show contents related information (history, graphs, analytics and etc.)" 49 | errors: 50 | missing_roles_yaml_file: "The configuration file config/roles.yml is missing." 51 | 52 | roles: 53 | title: Roles 54 | new_link: New Role 55 | edit_title: Edit Role 56 | new_title: Create New Role 57 | back: Back 58 | load: Load New Roles 59 | role: Role 60 | show: Show 61 | manage: Manage 62 | save: Save 63 | description: Description 64 | show_access_rights: Show Access Rights 65 | name: Name 66 | contents: Contents 67 | designs: Designs 68 | settings: Settings 69 | files: Files 70 | page: Page 71 | publish: publish 72 | review: review 73 | pages: Pages 74 | layouts: Layouts 75 | snippets: Snippets 76 | roles: Roles 77 | sites: Sites 78 | users: Users 79 | 80 | users: 81 | title: Users 82 | new_link: New User 83 | new_super_link: New Super User 84 | edit_title: Edit User 85 | new_title: Create New User 86 | last_name: Lastname 87 | first_name: Firstname 88 | email: Email 89 | role: Role 90 | sessions: 91 | new: 92 | sign_in: Sign In 93 | email_address: Email Address 94 | password: Password 95 | remember_me: Remember me 96 | 97 | comfy: 98 | admin: 99 | cms: 100 | pages: 101 | form: &pages_form 102 | review: Approve 103 | reviewed: Reviewed 104 | schedule: Publish Date 105 | scheduled: Scheduled 106 | publish: Publish Now 107 | published: Published 108 | draft: save as draft 109 | drafted: Draft 110 | reset: Reset to Draft 111 | 112 | edit: 113 | <<: *pages_form 114 | 115 | files: 116 | form: 117 | are_you_sure: Are you sure to delete? 118 | delete: Delete! 119 | 120 | activerecord: 121 | attributes: 122 | cms/fortress/user: 123 | last_name: Lastname 124 | first_name: Firstname 125 | email: Email 126 | role_id: Role 127 | password: Password 128 | password_confirmation: Password Confirmation 129 | cms/fortress/role: 130 | name: Name 131 | description: Description 132 | cms/fortress/role_detail: 133 | contents: Contents 134 | comfy/cms/page: 135 | full_path: Path 136 | parent_id: Parent page 137 | slug: Slug 138 | 139 | login: 140 | forgot_your_password: Forgot your password? 141 | send_me_reset_password_instructions: Send me reset password instructions 142 | change_your_password: Change your password 143 | new_password: New password 144 | confirm_new_password: Confirm new password 145 | change_my_password: Change my password 146 | log_in: Log in 147 | sign_up: Sign up 148 | didnt_receive_confirmation_instructions: Didn't receive confirmation instructions? 149 | didnt_receive_unlock_instructions: Didn't receive unlock instructions? 150 | sign_in_with: Sign in with #{provider.to_s.titleize} 151 | -------------------------------------------------------------------------------- /config/locales/pt-BR.yml: -------------------------------------------------------------------------------- 1 | pt-BR: 2 | cms: 3 | fortress: 4 | page_title: CMS Fortress Admin 5 | title: CMS Fortress 6 | contents: Contents 7 | design: Design 8 | admin: Admin 9 | login: Logout 10 | logout: Logout 11 | create: Create 12 | update: Update 13 | delete: Delete 14 | edit: Edit 15 | are_you_sure: Are you sure? 16 | cancel: Cancel 17 | published: Published 18 | published_date: Published At 19 | schedule_date: Scheduled Publication 20 | cache_timeout: Cached Timeout 21 | toggle_navigation: Toggle Navigation 22 | image_selector: Image Selector 23 | insert_item: Click the thumbnail to insert item to the selected editor. 24 | settings: Settings 25 | current_site: Current Site 26 | 27 | admin: 28 | 29 | dashboard: 30 | title: Dashboard 31 | draft_widget: Draft Pages 32 | reviewed_widget: Reviewed Pages 33 | updated_pages: Recently Updated Pages 34 | 35 | sites: 36 | menu_header: "Site/ %{site_name}" 37 | super_user: 38 | title: Super Users 39 | menu_header: Super Users Only 40 | 41 | users: Users 42 | not_authorized: You are not authorized to access this functionality 43 | settings_dashboard: Settings Dashboard 44 | roles: Roles 45 | design_dashboard: Design Dashboard 46 | design_related_information: This page will show design related information. 47 | content_dashboard: Content Dashboard 48 | content_related_information: "This page will show contents related information (history, graphs, analytics and etc.)" 49 | errors: 50 | missing_roles_yaml_file: "The configuration file config/roles.yml is missing." 51 | 52 | roles: 53 | title: Roles 54 | new_link: New Role 55 | edit_title: Edit Role 56 | new_title: Create New Role 57 | back: Back 58 | load: Load New Roles 59 | role: Role 60 | show: Show 61 | manage: Manage 62 | save: Save 63 | description: Description 64 | show_access_rights: Show Access Rights 65 | name: Name 66 | contents: Contents 67 | designs: Designs 68 | settings: Settings 69 | files: Files 70 | page: Page 71 | publish: publish 72 | review: review 73 | pages: Pages 74 | layouts: Layouts 75 | snippets: Snippets 76 | roles: Roles 77 | sites: Sites 78 | users: Users 79 | 80 | users: 81 | title: Users 82 | new_link: New User 83 | new_super_link: New Super User 84 | edit_title: Edit User 85 | new_title: Create New User 86 | last_name: Lastname 87 | first_name: Firstname 88 | email: Email 89 | role: Role 90 | sessions: 91 | new: 92 | sign_in: Sign In 93 | email_address: Email Address 94 | password: Password 95 | remember_me: Remember me 96 | 97 | comfy: 98 | admin: 99 | cms: 100 | pages: 101 | form: &pages_form 102 | review: Approve 103 | reviewed: Reviewed 104 | schedule: Publish Date 105 | scheduled: Scheduled 106 | publish: Publish Now 107 | published: Published 108 | draft: save as draft 109 | drafted: Draft 110 | reset: Reset to Draft 111 | 112 | edit: 113 | <<: *pages_form 114 | 115 | files: 116 | form: 117 | are_you_sure: Are you sure to delete? 118 | delete: Delete! 119 | 120 | activerecord: 121 | attributes: 122 | cms/fortress/user: 123 | last_name: Lastname 124 | first_name: Firstname 125 | email: Email 126 | role_id: Role 127 | password: Password 128 | password_confirmation: Password Confirmation 129 | cms/fortress/role: 130 | name: Name 131 | description: Description 132 | cms/fortress/role_detail: 133 | contents: Contents 134 | comfy/cms/page: 135 | full_path: Path 136 | parent_id: Parent page 137 | slug: Slug 138 | 139 | login: 140 | forgot_your_password: Forgot your password? 141 | send_me_reset_password_instructions: Send me reset password instructions 142 | change_your_password: Change your password 143 | new_password: New password 144 | confirm_new_password: Confirm new password 145 | change_my_password: Change my password 146 | log_in: Log in 147 | sign_up: Sign up 148 | didnt_receive_confirmation_instructions: Didn't receive confirmation instructions? 149 | didnt_receive_unlock_instructions: Didn't receive unlock instructions? 150 | sign_in_with: Sign in with #{provider.to_s.titleize} 151 | -------------------------------------------------------------------------------- /config/locales/ru.yml: -------------------------------------------------------------------------------- 1 | ru: 2 | cms: 3 | fortress: 4 | page_title: CMS Fortress Admin 5 | title: CMS Fortress 6 | contents: Contents 7 | design: Design 8 | admin: Admin 9 | login: Logout 10 | logout: Logout 11 | create: Create 12 | update: Update 13 | delete: Delete 14 | edit: Edit 15 | are_you_sure: Are you sure? 16 | cancel: Cancel 17 | published: Published 18 | published_date: Published At 19 | schedule_date: Scheduled Publication 20 | cache_timeout: Cached Timeout 21 | toggle_navigation: Toggle Navigation 22 | image_selector: Image Selector 23 | insert_item: Click the thumbnail to insert item to the selected editor. 24 | settings: Settings 25 | current_site: Current Site 26 | 27 | admin: 28 | 29 | dashboard: 30 | title: Dashboard 31 | draft_widget: Draft Pages 32 | reviewed_widget: Reviewed Pages 33 | updated_pages: Recently Updated Pages 34 | 35 | sites: 36 | menu_header: "Site/ %{site_name}" 37 | super_user: 38 | title: Super Users 39 | menu_header: Super Users Only 40 | 41 | users: Users 42 | not_authorized: You are not authorized to access this functionality 43 | settings_dashboard: Settings Dashboard 44 | roles: Roles 45 | design_dashboard: Design Dashboard 46 | design_related_information: This page will show design related information. 47 | content_dashboard: Content Dashboard 48 | content_related_information: "This page will show contents related information (history, graphs, analytics and etc.)" 49 | errors: 50 | missing_roles_yaml_file: "The configuration file config/roles.yml is missing." 51 | 52 | roles: 53 | title: Roles 54 | new_link: New Role 55 | edit_title: Edit Role 56 | new_title: Create New Role 57 | back: Back 58 | load: Load New Roles 59 | role: Role 60 | show: Show 61 | manage: Manage 62 | save: Save 63 | description: Description 64 | show_access_rights: Show Access Rights 65 | name: Name 66 | contents: Contents 67 | designs: Designs 68 | settings: Settings 69 | files: Files 70 | page: Page 71 | publish: publish 72 | review: review 73 | pages: Pages 74 | layouts: Layouts 75 | snippets: Snippets 76 | roles: Roles 77 | sites: Sites 78 | users: Users 79 | 80 | users: 81 | title: Users 82 | new_link: New User 83 | new_super_link: New Super User 84 | edit_title: Edit User 85 | new_title: Create New User 86 | last_name: Lastname 87 | first_name: Firstname 88 | email: Email 89 | role: Role 90 | sessions: 91 | new: 92 | sign_in: Sign In 93 | email_address: Email Address 94 | password: Password 95 | remember_me: Remember me 96 | 97 | comfy: 98 | admin: 99 | cms: 100 | pages: 101 | form: &pages_form 102 | review: Approve 103 | reviewed: Reviewed 104 | schedule: Publish Date 105 | scheduled: Scheduled 106 | publish: Publish Now 107 | published: Published 108 | draft: save as draft 109 | drafted: Draft 110 | reset: Reset to Draft 111 | 112 | edit: 113 | <<: *pages_form 114 | 115 | files: 116 | form: 117 | are_you_sure: Are you sure to delete? 118 | delete: Delete! 119 | 120 | 121 | activerecord: 122 | attributes: 123 | cms/fortress/user: 124 | last_name: Lastname 125 | first_name: Firstname 126 | email: Email 127 | role_id: Role 128 | password: Password 129 | password_confirmation: Password Confirmation 130 | cms/fortress/role: 131 | name: Name 132 | description: Description 133 | cms/fortress/role_detail: 134 | contents: Contents 135 | comfy/cms/page: 136 | full_path: Path 137 | parent_id: Parent page 138 | slug: Slug 139 | 140 | login: 141 | forgot_your_password: Forgot your password? 142 | send_me_reset_password_instructions: Send me reset password instructions 143 | change_your_password: Change your password 144 | new_password: New password 145 | confirm_new_password: Confirm new password 146 | change_my_password: Change my password 147 | log_in: Log in 148 | sign_up: Sign up 149 | didnt_receive_confirmation_instructions: Didn't receive confirmation instructions? 150 | didnt_receive_unlock_instructions: Didn't receive unlock instructions? 151 | sign_in_with: Sign in with #{provider.to_s.titleize} 152 | -------------------------------------------------------------------------------- /config/locales/zh-CN.yml: -------------------------------------------------------------------------------- 1 | zh-CN: 2 | cms: 3 | fortress: 4 | page_title: CMS Fortress Admin 5 | title: CMS Fortress 6 | contents: Contents 7 | design: Design 8 | admin: Admin 9 | login: Logout 10 | logout: Logout 11 | create: Create 12 | update: Update 13 | delete: Delete 14 | edit: Edit 15 | are_you_sure: Are you sure? 16 | cancel: Cancel 17 | published: Published 18 | published_date: Published At 19 | schedule_date: Scheduled Publication 20 | cache_timeout: Cached Timeout 21 | toggle_navigation: Toggle Navigation 22 | image_selector: Image Selector 23 | insert_item: Click the thumbnail to insert item to the selected editor. 24 | settings: Settings 25 | current_site: Current Site 26 | 27 | admin: 28 | 29 | dashboard: 30 | title: Dashboard 31 | draft_widget: Draft Pages 32 | reviewed_widget: Reviewed Pages 33 | updated_pages: Recently Updated Pages 34 | 35 | sites: 36 | menu_header: "Site/ %{site_name}" 37 | super_user: 38 | title: Super Users 39 | menu_header: Super Users Only 40 | 41 | users: Users 42 | not_authorized: You are not authorized to access this functionality 43 | settings_dashboard: Settings Dashboard 44 | roles: Roles 45 | design_dashboard: Design Dashboard 46 | design_related_information: This page will show design related information. 47 | content_dashboard: Content Dashboard 48 | content_related_information: "This page will show contents related information (history, graphs, analytics and etc.)" 49 | errors: 50 | missing_roles_yaml_file: "The configuration file config/roles.yml is missing." 51 | 52 | roles: 53 | title: Roles 54 | new_link: New Role 55 | edit_title: Edit Role 56 | new_title: Create New Role 57 | back: Back 58 | load: Load New Roles 59 | role: Role 60 | show: Show 61 | manage: Manage 62 | save: Save 63 | description: Description 64 | show_access_rights: Show Access Rights 65 | name: Name 66 | contents: Contents 67 | designs: Designs 68 | settings: Settings 69 | files: Files 70 | page: Page 71 | publish: publish 72 | review: review 73 | pages: Pages 74 | layouts: Layouts 75 | snippets: Snippets 76 | roles: Roles 77 | sites: Sites 78 | users: Users 79 | 80 | users: 81 | title: Users 82 | new_link: New User 83 | new_super_link: New Super User 84 | edit_title: Edit User 85 | new_title: Create New User 86 | last_name: Lastname 87 | first_name: Firstname 88 | email: Email 89 | role: Role 90 | sessions: 91 | new: 92 | sign_in: Sign In 93 | email_address: Email Address 94 | password: Password 95 | remember_me: Remember me 96 | 97 | comfy: 98 | admin: 99 | cms: 100 | pages: 101 | form: &pages_form 102 | review: Approve 103 | reviewed: Reviewed 104 | schedule: Publish Date 105 | scheduled: Scheduled 106 | publish: Publish Now 107 | published: Published 108 | draft: save as draft 109 | drafted: Draft 110 | reset: Reset to Draft 111 | 112 | edit: 113 | <<: *pages_form 114 | 115 | files: 116 | form: 117 | are_you_sure: Are you sure to delete? 118 | delete: Delete! 119 | 120 | activerecord: 121 | attributes: 122 | cms/fortress/user: 123 | last_name: Lastname 124 | first_name: Firstname 125 | email: Email 126 | role_id: Role 127 | password: Password 128 | password_confirmation: Password Confirmation 129 | cms/fortress/role: 130 | name: Name 131 | description: Description 132 | cms/fortress/role_detail: 133 | contents: Contents 134 | comfy/cms/page: 135 | full_path: Path 136 | parent_id: Parent page 137 | slug: Slug 138 | 139 | login: 140 | forgot_your_password: Forgot your password? 141 | send_me_reset_password_instructions: Send me reset password instructions 142 | change_your_password: Change your password 143 | new_password: New password 144 | confirm_new_password: Confirm new password 145 | change_my_password: Change my password 146 | log_in: Log in 147 | sign_up: Sign up 148 | didnt_receive_confirmation_instructions: Didn't receive confirmation instructions? 149 | didnt_receive_unlock_instructions: Didn't receive unlock instructions? 150 | sign_in_with: Sign in with #{provider.to_s.titleize} 151 | -------------------------------------------------------------------------------- /test/controllers/comfy/admin/cms/pages_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class Comfy::Admin::Cms::PagesControllerTest < ActionController::TestCase 4 | def setup 5 | @comfy_cms_site = comfy_cms_sites(:default) 6 | @cms_fortress_user = cms_fortress_users(:one) 7 | @cms_fortress_role = cms_fortress_roles(:one) 8 | sign_in Cms::Fortress::User, @cms_fortress_user 9 | end 10 | 11 | test "new page should be drafted" do 12 | assert_difference 'Comfy::Cms::Page.count' do 13 | assert_difference 'Comfy::Cms::Block.count', 2 do 14 | post :create, :site_id => @comfy_cms_site, :page => { 15 | :label => 'Test Page', 16 | :slug => 'test-page', 17 | :parent_id => comfy_cms_pages(:default).id, 18 | :layout_id => comfy_cms_layouts(:default).id, 19 | :blocks_attributes => [ 20 | { :identifier => 'default_page_text', 21 | :content => 'content content' }, 22 | { :identifier => 'default_field_text', 23 | :content => 'title content' } 24 | ] 25 | } 26 | page = Comfy::Cms::Page.last 27 | assert_equal @comfy_cms_site, page.site 28 | assert page.drafted? 29 | assert_redirected_to edit_comfy_admin_cms_site_page_url(id: page, site_id: page.site) 30 | assert_equal 'Page created', flash[:success] 31 | end 32 | end 33 | end 34 | 35 | test "new page should be published" do 36 | assert_difference 'Comfy::Cms::Page.count' do 37 | assert_difference 'Comfy::Cms::Block.count', 2 do 38 | post :create, :site_id => @comfy_cms_site, :page => { 39 | :label => 'Test Page', 40 | :slug => 'test-page', 41 | :parent_id => comfy_cms_pages(:default).id, 42 | :layout_id => comfy_cms_layouts(:default).id, 43 | :blocks_attributes => [ 44 | { :identifier => 'default_page_text', 45 | :content => 'content content' }, 46 | { :identifier => 'default_field_text', 47 | :content => 'title content' } 48 | ] 49 | }, :transition => 'publish' 50 | page = Comfy::Cms::Page.last 51 | assert_equal @comfy_cms_site, page.site 52 | assert page.published? 53 | assert_redirected_to edit_comfy_admin_cms_site_page_url(id: page, site_id: page.site) 54 | assert_equal 'Page created', flash[:success] 55 | end 56 | end 57 | end 58 | 59 | test "drafted page should become reviewed" do 60 | page = comfy_cms_pages(:drafted) 61 | assert_no_difference 'Comfy::Cms::Block.count' do 62 | put :update, :site_id => page.site, :id => page, :transition => 'review' 63 | assert_response :redirect 64 | assert_redirected_to :action => :edit, :id => page 65 | assert_equal 'Page updated', flash[:success] 66 | assert assigns(:page).reviewed? 67 | end 68 | end 69 | 70 | test "drafted page should become published" do 71 | page = comfy_cms_pages(:drafted) 72 | assert_no_difference 'Comfy::Cms::Block.count' do 73 | put :update, :site_id => page.site, :id => page, :transition => 'publish' 74 | assert_response :redirect 75 | assert_redirected_to :action => :edit, :id => page 76 | assert_equal 'Page updated', flash[:success] 77 | assert assigns(:page).published? 78 | end 79 | end 80 | 81 | test "reviewed page should become published" do 82 | page = comfy_cms_pages(:reviewed) 83 | assert_no_difference 'Comfy::Cms::Block.count' do 84 | put :update, :site_id => page.site, :id => page, :transition => 'publish' 85 | assert_response :redirect 86 | assert_redirected_to :action => :edit, :id => page 87 | assert_equal 'Page updated', flash[:success] 88 | assert assigns(:page).published? 89 | end 90 | end 91 | 92 | test "published page should become drafted" do 93 | page = comfy_cms_pages(:published) 94 | assert_no_difference 'Comfy::Cms::Block.count' do 95 | put :update, :site_id => page.site, :id => page, :transition => 'reset' 96 | assert_response :redirect 97 | assert_redirected_to :action => :edit, :id => page 98 | assert_equal 'Page updated', flash[:success] 99 | assert assigns(:page).drafted? 100 | end 101 | end 102 | 103 | test "saving a page should'nt change status of a page" do 104 | page = comfy_cms_pages(:drafted) 105 | label = 'Arrr' 106 | put :update, :site_id => page.site, :id => page, :commit => 'save', :page => { 107 | :label => label, 108 | } 109 | assert_response :redirect 110 | assert_redirected_to :action => :edit, :id => page 111 | assert_equal 'Page updated', flash[:success] 112 | assert assigns(:page).drafted? 113 | assert_equal assigns(:page).label, label 114 | end 115 | end 116 | -------------------------------------------------------------------------------- /config/locales/es.yml: -------------------------------------------------------------------------------- 1 | es: 2 | cms: 3 | fortress: 4 | page_title: CMS Fortress Admin 5 | title: CMS Fortress 6 | contents: Contenido 7 | design: Diseño 8 | admin: Administración 9 | login: Inicio de sesión 10 | logout: Salir 11 | create: Crear 12 | update: Actualización 13 | delete: Borrar 14 | edit: Editar 15 | are_you_sure: ¿Está seguro? 16 | cancel: Cancelar 17 | published: Publicado 18 | published_date: Publicado En 19 | schedule_date: Scheduled Publication 20 | cache_timeout: Tiempo de espera de caché 21 | toggle_navigation: Toggle Navigation 22 | image_selector: Image Selector 23 | insert_item: Click the thumbnail to insert item to the selected editor. 24 | settings: Configuración 25 | current_site: Sitio Actual 26 | 27 | admin: 28 | 29 | dashboard: 30 | title: Salpicadero 31 | draft_widget: Proyecto de Páginas 32 | reviewed_widget: Comentado Páginas 33 | updated_pages: Páginas Actualizado Recientemente 34 | 35 | sites: 36 | menu_header: "Sitio/ %{site_name}" 37 | super_user: 38 | title: Estupendo Usuarios 39 | menu_header: único Estupendo Usuario 40 | 41 | users: Users 42 | not_authorized: You are not authorized to access this functionality 43 | settings_dashboard: Settings Dashboard 44 | roles: Roles 45 | design_dashboard: Design Dashboard 46 | design_related_information: This page will show design related information. 47 | content_dashboard: Content Dashboard 48 | content_related_information: "This page will show contents related information (history, graphs, analytics and etc.)" 49 | errors: 50 | missing_roles_yaml_file: "The configuration file config/roles.yml is missing." 51 | 52 | roles: 53 | title: Rol 54 | new_link: Nuevo Rol 55 | edit_title: Editar Rol 56 | new_title: Crear nuevo Rol 57 | back: Espalda 58 | load: Cargue Nuevo Rol 59 | role: Rol 60 | show: Mostar 61 | manage: Gestionar 62 | save: Ahorrar 63 | description: Description 64 | show_access_rights: Mostrar Derechos de Consulta 65 | name: Nombre 66 | contents: Contenido 67 | designs: Diseño 68 | settings: Configuración 69 | files: Archivos 70 | page: Página 71 | publish: Publicar 72 | review: Revisión 73 | pages: Páginas 74 | layouts: Layouts 75 | snippets: Snippets 76 | roles: Rol 77 | sites: Sitios 78 | users: Usuarios 79 | 80 | users: 81 | title: Usuarios 82 | new_link: Nuevo Usuario 83 | new_super_link: Nuevo Estupendo Usuario 84 | edit_title: Edit User 85 | new_title: Create New User 86 | last_name: Lastname 87 | first_name: Firstname 88 | email: Email 89 | role: Role 90 | sessions: 91 | new: 92 | sign_in: Sign In 93 | email_address: Email Address 94 | password: Password 95 | remember_me: Remember me 96 | 97 | comfy: 98 | admin: 99 | cms: 100 | pages: 101 | form: &pages_form 102 | review: Approve 103 | reviewed: Reviewed 104 | schedule: Publish Date 105 | scheduled: Scheduled 106 | publish: Publish Now 107 | published: Published 108 | draft: save as draft 109 | drafted: Draft 110 | reset: Reset to Draft 111 | 112 | edit: 113 | <<: *pages_form 114 | 115 | files: 116 | form: 117 | are_you_sure: Are you sure to delete? 118 | delete: Delete! 119 | 120 | activerecord: 121 | attributes: 122 | cms/fortress/user: 123 | last_name: Lastname 124 | first_name: Firstname 125 | email: Email 126 | role_id: Role 127 | password: Password 128 | password_confirmation: Password Confirmation 129 | cms/fortress/role: 130 | name: Name 131 | description: Description 132 | cms/fortress/role_detail: 133 | contents: Contents 134 | comfy/cms/page: 135 | full_path: Path 136 | parent_id: Parent page 137 | slug: Slug 138 | 139 | login: 140 | forgot_your_password: Forgot your password? 141 | send_me_reset_password_instructions: Send me reset password instructions 142 | change_your_password: Change your password 143 | new_password: New password 144 | confirm_new_password: Confirm new password 145 | change_my_password: Change my password 146 | log_in: Log in 147 | sign_up: Sign up 148 | didnt_receive_confirmation_instructions: Didn't receive confirmation instructions? 149 | didnt_receive_unlock_instructions: Didn't receive unlock instructions? 150 | sign_in_with: Sign in with #{provider.to_s.titleize} 151 | -------------------------------------------------------------------------------- /config/locales/de.yml: -------------------------------------------------------------------------------- 1 | de: 2 | cms: 3 | fortress: 4 | page_title: CMS Fortress Admin 5 | title: CMS Fortress 6 | contents: Inhalte 7 | design: Design 8 | admin: Admin 9 | login: Logout 10 | logout: Logout 11 | create: Erstellen 12 | update: Aktualisieren 13 | delete: Löschen 14 | edit: Bearbeiten 15 | are_you_sure: Sind Sie sicher? 16 | cancel: Abbrechen 17 | published: Publiziert 18 | published_date: Publiziert am 19 | schedule_date: geplante Publizierung 20 | cache_timeout: Cache Dauer 21 | toggle_navigation: Navigation einklappen 22 | image_selector: Bildauswahl 23 | insert_item: Ein Bild anklicken um es in den ausgewählten Editor einzufügen. 24 | settings: Einstellungen 25 | current_site: Aktuelle Seite 26 | 27 | admin: 28 | dashboard: 29 | title: Dashboard 30 | draft_widget: Seiten im Entwurf 31 | reviewed_widget: Überprüfte Seite 32 | updated_pages: Kürzlich bearbeitete Seiten 33 | 34 | sites: 35 | menu_header: "Site/ %{site_name}" 36 | super_user: 37 | title: Super Users 38 | menu_header: Nur Super User 39 | 40 | users: Benutzer 41 | not_authorized: Sie sind nicht berechtigt diese Funktionalität zu nutzen 42 | settings_dashboard: Dashboard für Einstellungen 43 | roles: Rollen 44 | design_dashboard: Dashboard für Designs 45 | design_related_information: Diese Seite wird Design spezifische Einstellungen zeigen. 46 | content_dashboard: Dashboard für Inhalte 47 | content_related_information: "Diese Seite wird Inhalt spezifische Einstellungen zeigen (Historie, Graphen, Analytics und andere.)" 48 | errors: 49 | missing_roles_yaml_file: "Die Konfigurationsdatei config/roles.yml ist nicht vorhanden." 50 | 51 | roles: 52 | title: Rollen 53 | new_link: Neue Rolle 54 | edit_title: Rolle bearbeiten 55 | new_title: Neue Rolle erstellen 56 | back: Zurück 57 | load: Neue Rollen laden 58 | role: Rolle 59 | show: Anzeigen 60 | manage: Verwalten 61 | save: Speichern 62 | description: Beschreibung 63 | show_access_rights: Zugriffsrechte anzeigen 64 | name: Name 65 | contents: Inhalte 66 | designs: Designs 67 | settings: Einstellungen 68 | files: Dateien 69 | page: Seite 70 | publish: publizieren 71 | review: reviewen 72 | pages: Seiten 73 | layouts: Layouts 74 | snippets: Schnipsel 75 | roles: Rollen 76 | sites: Seiten 77 | users: Benutzer 78 | 79 | users: 80 | title: Benutzer 81 | new_link: Neuer Benutzer 82 | edit_title: Benutzer bearbeiten 83 | new_title: Neuen Benutzer erstellen 84 | last_name: Nachname 85 | first_name: Vorname 86 | email: E-Mail 87 | role: Rolle 88 | sessions: 89 | new: 90 | sign_in: Anmelden 91 | email_address: E-Mail Adresse 92 | password: Password 93 | remember_me: Angemeldet bleiben 94 | comfy: 95 | admin: 96 | cms: 97 | pages: 98 | form: &pages_form 99 | review: Freigeben 100 | reviewed: Freigegeben 101 | schedule: Publizierung planen 102 | scheduled: Geplant 103 | publish: Jetzt publizieren 104 | published: Publiziert 105 | draft: Als Entwurf speichern 106 | drafted: Entwurf 107 | reset: Auf Entwurf zurücksetzen 108 | 109 | edit: 110 | <<: *pages_form 111 | files: 112 | form: 113 | are_you_sure: Wirklich löschen? 114 | delete: Löschen! 115 | 116 | activerecord: 117 | attributes: 118 | cms/fortress/user: 119 | last_name: Nachname 120 | first_name: Vorname 121 | email: E-Mail 122 | role_id: Rolle 123 | password: Passwort 124 | password_confirmation: Passwort Bestätigung 125 | cms/fortress/role: 126 | name: Name 127 | description: Beschreibung 128 | cms/fortress/role_detail: 129 | contents: Inhalte 130 | comfy/cms/page: 131 | full_path: Pfad 132 | parent_id: Übergeordnete Seite 133 | slug: URL-Pfad 134 | 135 | login: 136 | forgot_your_password: Passwort vergessen? 137 | send_me_reset_password_instructions: Passwort-Reset Anweisungen senden 138 | change_your_password: Ändern Sie Ihr Passwort 139 | new_password: neues Passwort 140 | confirm_new_password: Neuse Passwort bestätigen 141 | change_my_password: Passwort ändern 142 | log_in: Einloggen 143 | sign_up: Registrieren 144 | didnt_receive_confirmation_instructions: Sie haben keine Passwort-Reset Anweisungen erhalten? 145 | didnt_receive_unlock_instructions: Sie haben keine Anweisungen zum entsperren erhalten? 146 | sign_in_with: Anmelden mit #{provider.to_s.titleize} -------------------------------------------------------------------------------- /lib/comfortable_mexican_sofa/fixture/page.rb: -------------------------------------------------------------------------------- 1 | module ComfortableMexicanSofa::Fixture::Page 2 | class Importer < ComfortableMexicanSofa::Fixture::Importer 3 | 4 | attr_accessor :target_pages 5 | 6 | def import!(path = self.path, parent = nil) 7 | Dir["#{path}*/"].each do |path| 8 | slug = path.split('/').last 9 | 10 | page = if parent 11 | parent.children.where(:slug => slug).first || site.pages.new(:parent => parent, :slug => slug) 12 | else 13 | site.pages.root || site.pages.new(:slug => slug) 14 | end 15 | 16 | # setting attributes 17 | categories = [] 18 | if File.exists?(attrs_path = File.join(path, 'attributes.yml')) 19 | if fresh_fixture?(page, attrs_path) 20 | attrs = get_attributes(attrs_path) 21 | 22 | page.label = attrs['label'] 23 | page.layout = site.layouts.where(:identifier => attrs['layout']).first || parent.try(:layout) 24 | page.is_published = attrs['is_published'].nil?? true : attrs['is_published'] 25 | page.position = attrs['position'] if attrs['position'] 26 | 27 | page.cached_timeout = attrs['cached_timeout'] 28 | page.aasm_state = attrs['aasm_state'] 29 | page.published_date = attrs['published_date'] 30 | 31 | categories = attrs['categories'] 32 | 33 | if attrs['target_page'] 34 | self.target_pages ||= {} 35 | self.target_pages[page] = attrs['target_page'] 36 | end 37 | end 38 | end 39 | 40 | # setting content 41 | blocks_to_clear = page.blocks.collect(&:identifier) 42 | blocks_attributes = [ ] 43 | file_extentions = %w(html haml jpg png gif) 44 | Dir.glob("#{path}/*.{#{file_extentions.join(',')}}").each do |block_path| 45 | extention = File.extname(block_path)[1..-1] 46 | identifier = block_path.split('/').last.gsub(/\.(#{file_extentions.join('|')})\z/, '') 47 | blocks_to_clear.delete(identifier) 48 | if fresh_fixture?(page, block_path) 49 | content = case extention 50 | when 'jpg', 'png', 'gif' 51 | ::File.open(block_path) 52 | when 'haml' 53 | Haml::Engine.new(::File.open(block_path).read).render.rstrip 54 | else 55 | ::File.open(block_path).read 56 | end 57 | blocks_attributes << { 58 | :identifier => identifier, 59 | :content => content 60 | } 61 | end 62 | end 63 | 64 | # deleting removed blocks 65 | page.blocks.where(:identifier => blocks_to_clear).destroy_all 66 | 67 | page.blocks_attributes = blocks_attributes if blocks_attributes.present? 68 | 69 | # saving 70 | if page.changed? || page.blocks_attributes_changed || self.force_import 71 | if page.save 72 | save_categorizations!(page, categories) 73 | ComfortableMexicanSofa.logger.info("[FIXTURES] Imported Page \t #{page.full_path}") 74 | else 75 | ComfortableMexicanSofa.logger.warn("[FIXTURES] Failed to import Page \n#{page.errors.inspect}") 76 | end 77 | end 78 | 79 | self.fixture_ids << page.id 80 | 81 | # importing child pages 82 | import!(path, page) 83 | end 84 | 85 | # linking up target pages 86 | if self.target_pages.present? 87 | self.target_pages.each do |page, target| 88 | if target_page = self.site.pages.where(:full_path => target).first 89 | page.target_page = target_page 90 | page.save 91 | end 92 | end 93 | end 94 | 95 | # cleaning up 96 | unless parent 97 | self.site.pages.where('id NOT IN (?)', self.fixture_ids).each{ |s| s.destroy } 98 | end 99 | end 100 | end 101 | 102 | class Exporter < ComfortableMexicanSofa::Fixture::Exporter 103 | def export! 104 | prepare_folder!(self.path) 105 | 106 | self.site.pages.each do |page| 107 | page.slug = 'index' if page.slug.blank? 108 | page_path = File.join(path, page.ancestors.reverse.collect{|p| p.slug.blank?? 'index' : p.slug}, page.slug) 109 | FileUtils.mkdir_p(page_path) 110 | 111 | open(File.join(page_path, 'attributes.yml'), 'w') do |f| 112 | f.write({ 113 | 'label' => page.label, 114 | 'layout' => page.layout.try(:identifier), 115 | 'parent' => page.parent && (page.parent.slug.present?? page.parent.slug : 'index'), 116 | 'target_page' => page.target_page.try(:full_path), 117 | 'categories' => page.categories.map{|c| c.label}, 118 | 'is_published' => page.is_published, 119 | 'position' => page.position, 120 | 'cached_timeout' => page.cached_timeout, 121 | 'aasm_state' => page.aasm_state, 122 | 'published_date' => page.published_date 123 | }.to_yaml) 124 | end 125 | page.blocks_attributes.each do |block| 126 | open(File.join(page_path, "#{block[:identifier]}.html"), 'w') do |f| 127 | f.write(block[:content]) 128 | end 129 | end 130 | 131 | ComfortableMexicanSofa.logger.info("[FIXTURES] Exported Page \t #{page.full_path}") 132 | end 133 | end 134 | end 135 | end 136 | --------------------------------------------------------------------------------