diff --git a/.gitignore b/.gitignore index 59dd9583..e94e5d3a 100644 --- a/.gitignore +++ b/.gitignore @@ -34,5 +34,5 @@ sites/ permanent doc/bushido *.swp - +.sass-cache/ diff --git a/Gemfile b/Gemfile index 2703fa34..77796d11 100644 --- a/Gemfile +++ b/Gemfile @@ -11,7 +11,7 @@ gem 'cancan', '~> 1.6.7' gem 'mongoid', '~> 2.3.2' gem 'bson_ext', '~> 1.3.1' -gem 'locomotive_mongoid_acts_as_tree', '0.1.5.7', :require => 'mongoid_acts_as_tree' +gem 'locomotive_mongoid_acts_as_tree', '0.1.5.7', :require => 'mongoid_acts_as_tree', :path => '../gems/acts_as_tree' # TODO: REPLACE IT gem 'custom_fields', '~> 1.1.0.rc1' gem 'will_paginate', '~> 3.0.2' @@ -42,7 +42,7 @@ gem 'rubyzip' gem 'actionmailer-with-request', '~> 0.3.0', :require => 'actionmailer_with_request' gem 'httparty', '~> 0.8.1' -gem 'delayed_job', '~> 3.0.0.pre2' +gem 'delayed_job', '~> 2.1.1' gem 'delayed_job_mongoid', '~> 1.0.4' gem 'SystemTimer', :platforms => :ruby_18 diff --git a/Gemfile.lock b/Gemfile.lock index 9b2033f1..fc5a16df 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,58 +1,75 @@ +GIT + remote: git://github.com/chriseppstein/compass.git + revision: 22e2458b77519e8eb8463170c1a1fe4bab105f3e + branch: rails31 + specs: + compass (0.12.0.alpha.0.22e2458) + chunky_png (~> 1.2) + fssm (>= 0.2.7) + sass (~> 3.1) + +GIT + remote: git://github.com/yabawock/handlebars-rails.git + revision: a09077aa91f10e08403af84586b2f2f0b38d9e2f + specs: + handlebars-rails (0.9.1) + +PATH + remote: ../gems/acts_as_tree + specs: + locomotive_mongoid_acts_as_tree (0.1.5.7) + GEM remote: http://rubygems.org/ specs: - POpen4 (0.1.4) - Platform (>= 0.4.0) - open4 - Platform (0.4.0) RedCloth (4.2.8) SystemTimer (1.2.3) ZenTest (4.6.2) - abstract (1.0.0) - actionmailer (3.0.10) - actionpack (= 3.0.10) - mail (~> 2.2.19) + actionmailer (3.1.1) + actionpack (= 3.1.1) + mail (~> 2.3.0) actionmailer-with-request (0.3.0) rails (>= 3) - actionpack (3.0.10) - activemodel (= 3.0.10) - activesupport (= 3.0.10) - builder (~> 2.1.2) - erubis (~> 2.6.6) - i18n (~> 0.5.0) - rack (~> 1.2.1) - rack-mount (~> 0.6.14) - rack-test (~> 0.5.7) - tzinfo (~> 0.3.23) - activemodel (3.0.10) - activesupport (= 3.0.10) - builder (~> 2.1.2) - i18n (~> 0.5.0) - activerecord (3.0.10) - activemodel (= 3.0.10) - activesupport (= 3.0.10) - arel (~> 2.0.10) - tzinfo (~> 0.3.23) - activeresource (3.0.10) - activemodel (= 3.0.10) - activesupport (= 3.0.10) - activesupport (3.0.10) + actionpack (3.1.1) + activemodel (= 3.1.1) + activesupport (= 3.1.1) + builder (~> 3.0.0) + erubis (~> 2.7.0) + i18n (~> 0.6) + rack (~> 1.3.2) + rack-cache (~> 1.1) + rack-mount (~> 0.8.2) + rack-test (~> 0.6.1) + sprockets (~> 2.0.2) + activemodel (3.1.1) + activesupport (= 3.1.1) + builder (~> 3.0.0) + i18n (~> 0.6) + activerecord (3.1.1) + activemodel (= 3.1.1) + activesupport (= 3.1.1) + arel (~> 2.2.1) + tzinfo (~> 0.3.29) + activeresource (3.1.1) + activemodel (= 3.1.1) + activesupport (= 3.1.1) + activesupport (3.1.1) + multi_json (~> 1.0) + addressable (2.2.6) archive-tar-minitar (0.5.2) - arel (2.0.10) + arel (2.2.1) autotest (4.4.6) ZenTest (>= 4.4.1) - bcrypt-ruby (2.1.4) - bson (1.4.0) - bson_ext (1.4.0) - builder (2.1.2) + bcrypt-ruby (3.0.1) + bson (1.4.1) + bson_ext (1.3.1) + builder (3.0.0) bushido (0.0.35) highline (>= 1.6.1) json (>= 1.4.6) orm_adapter (~> 0.0.3) rest-client (>= 1.6.1) - bushido_stub (0.0.3) - activesupport (>= 3.0.7) - cancan (1.6.5) + cancan (1.6.7) capybara (1.1.1) mime-types (>= 1.16) nokogiri (>= 1.3.3) @@ -60,16 +77,22 @@ GEM rack-test (>= 0.5.4) selenium-webdriver (~> 2.0) xpath (~> 0.1.4) - carrierwave (0.5.6) + carrierwave (0.5.7) activesupport (~> 3.0) - cells (3.6.6) + carrierwave-mongoid (0.1.3) + carrierwave (>= 0.5.6) + mongoid (~> 2.1) + cells (3.7.0) actionpack (~> 3.0) railties (~> 3.0) childprocess (0.2.2) ffi (~> 1.0.6) + chunky_png (1.2.5) + coffee-script (2.2.0) + coffee-script-source + execjs + coffee-script-source (1.1.2) columnize (0.3.4) - configuration (1.3.1) - crack (0.1.8) cucumber (1.1.0) builder (>= 2.1.2) diff-lcs (>= 1.1.2) @@ -80,133 +103,134 @@ GEM capybara (>= 1.1.1) cucumber (>= 1.1.0) nokogiri (>= 1.5.0) - custom_fields (1.0.0.beta.25) - activesupport (~> 3.0.9) - mongoid (= 2.0.2) + custom_fields (1.1.0.rc1) + activesupport (~> 3.1.1) + carrierwave-mongoid (~> 0.1.3) + mongoid (= 2.3.2) daemons (1.1.4) database_cleaner (0.6.7) delayed_job (2.1.4) activesupport (~> 3.0) daemons - delayed_job_mongoid (1.0.2) + delayed_job_mongoid (1.0.4) delayed_job (~> 2.1.1) - mongoid (~> 2.0.0.rc) - devise (1.3.4) - bcrypt-ruby (~> 2.1.2) + mongoid (>= 2.0) + devise (1.4.9) + bcrypt-ruby (~> 3.0) orm_adapter (~> 0.0.3) warden (~> 1.0.3) - devise_bushido_authenticatable (1.0.0.alpha10) - devise - devise (>= 1.0.6) - rubycas-client (>= 2.2.1) diff-lcs (1.1.3) dragonfly (0.9.8) rack - erubis (2.6.6) - abstract (>= 1.0.0) - excon (0.6.6) - factory_girl (2.1.2) + ejs (1.0.0) + erubis (2.7.0) + excon (0.7.6) + execjs (1.2.9) + multi_json (~> 1.0) + factory_girl (2.2.0) activesupport - factory_girl_rails (1.2.0) - factory_girl (~> 2.1.0) + factory_girl_rails (1.3.0) + factory_girl (~> 2.2.0) railties (>= 3.0.0) ffi (1.0.9) - fog (0.8.2) + fog (1.0.0) builder - excon (~> 0.6.1) - formatador (>= 0.1.3) - json + excon (~> 0.7.3) + formatador (~> 0.2.0) mime-types - net-ssh (>= 2.1.3) - nokogiri (>= 1.4.4) + multi_json (~> 1.0.3) + net-scp (~> 1.0.4) + net-ssh (~> 2.1.4) + nokogiri (~> 1.5.0) ruby-hmac formatador (0.2.1) formtastic (1.2.4) actionpack (>= 2.3.7) activesupport (>= 2.3.7) i18n (~> 0.4) - gherkin (2.5.2) + fssm (0.2.7) + gherkin (2.5.4) json (>= 1.4.6) growl-glue (1.0.7) - haml (3.1.2) + haml (3.1.3) has_scope (0.5.1) - heroku (1.19.1) - activesupport (>= 2.1.0) - launchy (~> 0.3.2) - rest-client (>= 1.4.0, < 1.7.0) highline (1.6.2) - httparty (0.7.8) - crack (= 0.1.8) - i18n (0.5.0) - inherited_resources (1.1.2) + hike (1.2.1) + httparty (0.8.1) + multi_json + multi_xml + i18n (0.6.0) + inherited_resources (1.3.0) has_scope (~> 0.5.0) responders (~> 0.6.0) - jammit (0.6.3) - yui-compressor (>= 0.9.3) + jquery-rails (1.0.16) + railties (~> 3.0) + thor (~> 0.14) json (1.6.1) json_pure (1.6.1) kgio (2.6.0) - launchy (0.3.7) - configuration (>= 0.0.5) - rake (>= 0.8.1) + launchy (2.0.5) + addressable (~> 2.2.6) linecache (0.43) linecache19 (0.5.12) ruby_core_source (>= 0.1.4) - locomotive_jammit-s3 (0.5.4.4) - jammit (>= 0.5.4) - mimemagic (>= 0.1.7) - s3 (>= 0.3.7) locomotive_liquid (2.2.2) - locomotive_mongoid_acts_as_tree (0.1.5.7) - mongoid (= 2.0.2) - mail (2.2.19) - activesupport (>= 2.3.6) + mail (2.3.0) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) - mime-types (1.16) - mimemagic (0.1.8) + mime-types (1.17.2) mimetype-fu (0.1.2) mocha (0.9.12) - mongo (1.4.0) - bson (= 1.4.0) - mongoid (2.0.2) - activemodel (~> 3.0) - mongo (~> 1.3) + mongo (1.4.1) + bson (= 1.4.1) + mongoid (2.3.2) + activemodel (~> 3.1) + mongo (~> 1.4) tzinfo (~> 0.3.22) - net-ssh (2.2.1) + multi_json (1.0.3) + multi_xml (0.4.1) + net-scp (1.0.4) + net-ssh (>= 1.99.1) + net-ssh (2.1.4) nokogiri (1.5.0) - open4 (1.1.0) orm_adapter (0.0.5) pickle (0.4.10) cucumber (>= 0.8) rake polyglot (0.3.2) - proxies (0.2.1) - rack (1.2.4) + rack (1.3.5) rack-cache (1.1) rack (>= 0.4) - rack-mount (0.6.14) + rack-mount (0.8.3) rack (>= 1.0.0) - rack-test (0.5.7) + rack-ssl (1.3.2) + rack + rack-test (0.6.1) rack (>= 1.0) - rails (3.0.10) - actionmailer (= 3.0.10) - actionpack (= 3.0.10) - activerecord (= 3.0.10) - activeresource (= 3.0.10) - activesupport (= 3.0.10) + rails (3.1.1) + actionmailer (= 3.1.1) + actionpack (= 3.1.1) + activerecord (= 3.1.1) + activeresource (= 3.1.1) + activesupport (= 3.1.1) bundler (~> 1.0) - railties (= 3.0.10) - railties (3.0.10) - actionpack (= 3.0.10) - activesupport (= 3.0.10) + railties (= 3.1.1) + rails-backbone (0.5.4) + coffee-script (~> 2.2.0) + ejs (~> 1.0.0) + rails (~> 3.1.0) + railties (3.1.1) + actionpack (= 3.1.1) + activesupport (= 3.1.1) + rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) - thor (~> 0.14.4) - raindrops (0.7.0) + thor (~> 0.14.6) + raindrops (0.8.0) rake (0.9.2) - rdoc (3.9.4) + rdoc (3.11) + json (~> 1.4) responders (0.6.4) rest-client (1.6.7) mime-types (>= 1.16) @@ -215,8 +239,7 @@ GEM rspec-core (~> 2.6.0) rspec-expectations (~> 2.6.0) rspec-mocks (~> 2.6.0) - rspec-cells (0.0.5) - cells (~> 3.4) + rspec-cells (0.1.0) rails (~> 3.0) rspec-rails (~> 2.2) rspec-core (2.6.4) @@ -244,82 +267,91 @@ GEM ruby-hmac (0.4.0) ruby_core_source (0.1.5) archive-tar-minitar (>= 0.5.2) - rubycas-client (2.2.1) - activesupport rubyzip (0.9.4) - s3 (0.3.8) - proxies (~> 0.2.0) sanitize (2.0.3) - nokogiri (>= 1.4.4, < 1.6) - sass (3.1.2) - selenium-webdriver (2.8.0) + nokogiri (< 1.6, >= 1.4.4) + sass (3.1.10) + sass-rails (3.1.4) + actionpack (~> 3.1.0) + railties (~> 3.1.0) + sass (>= 3.1.4) + sprockets (~> 2.0.0) + tilt (~> 1.3.2) + selenium-webdriver (2.10.0) childprocess (>= 0.2.1) - ffi (>= 1.0.7) + ffi (= 1.0.9) json_pure rubyzip spork (0.9.0.rc9) + sprockets (2.0.3) + hike (~> 1.2) + rack (~> 1.0) + tilt (!= 1.3.0, ~> 1.1) term-ansicolor (1.0.7) thor (0.14.6) + tilt (1.3.3) treetop (1.4.10) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.29) + tzinfo (0.3.30) + uglifier (1.0.4) + execjs (>= 0.3.0) + multi_json (>= 1.0.2) unicorn (4.1.1) kgio (~> 2.4) rack raindrops (~> 0.6) - warden (1.0.5) + warden (1.0.6) rack (>= 1.0) will_paginate (3.0.2) xpath (0.1.4) nokogiri (~> 1.3) - yui-compressor (0.9.6) - POpen4 (>= 0.1.4) PLATFORMS ruby DEPENDENCIES - RedCloth (= 4.2.8) + RedCloth (~> 4.2.8) SystemTimer ZenTest - actionmailer-with-request + actionmailer-with-request (~> 0.3.0) autotest - bson_ext (~> 1.4.0) + bson_ext (~> 1.3.1) bushido (= 0.0.35) - bushido_stub (= 0.0.3) - cancan + cancan (~> 1.6.7) capybara - carrierwave (= 0.5.6) - cells + carrierwave-mongoid (~> 0.1.3) + cells (~> 3.7.0) + coffee-script (~> 2.2.0) + compass! cucumber-rails - custom_fields (= 1.0.0.beta.25) + custom_fields (~> 1.1.0.rc1) database_cleaner - delayed_job (= 2.1.4) - delayed_job_mongoid (= 1.0.2) - devise (= 1.3.4) - devise_bushido_authenticatable (= 1.0.0.alpha10) - dragonfly (~> 0.9.1) + delayed_job (~> 2.1.1) + delayed_job_mongoid (~> 1.0.4) + devise (~> 1.4.9) + dragonfly (~> 0.9.8) factory_girl_rails (~> 1.1) - fog (= 0.8.2) + fog (~> 1.0.0) formtastic (~> 1.2.3) growl-glue - haml (= 3.1.2) - heroku (= 1.19.1) - highline - httparty (= 0.7.8) - inherited_resources (~> 1.1.2) + haml (~> 3.1.3) + handlebars-rails! + highline (~> 1.6.2) + httparty (~> 0.8.1) + inherited_resources (~> 1.3.0) + jquery-rails (~> 1.0.16) launchy linecache (= 0.43) - locomotive_jammit-s3 locomotive_liquid (= 2.2.2) - locomotive_mongoid_acts_as_tree (= 0.1.5.7) - mimetype-fu + locomotive_mongoid_acts_as_tree (= 0.1.5.7)! + mimetype-fu (~> 0.1.2) mocha (= 0.9.12) - mongoid (~> 2.0.2) + mongoid (~> 2.3.2) pickle - rack-cache - rails (= 3.0.10) + rack-cache (~> 1.1) + rails (~> 3.1.1) + rails-backbone (= 0.5.4) rake (= 0.9.2) rmagick (= 2.12.2) rspec-cells @@ -327,10 +359,10 @@ DEPENDENCIES ruby-debug ruby-debug19 rubyzip - sanitize - sass (= 3.1.2) + sanitize (~> 2.0.3) + sass-rails (~> 3.1.4) spork (~> 0.9.0.rc) + uglifier (~> 1.0.4) unicorn - warden - will_paginate (~> 3.0.0) + will_paginate (~> 3.0.2) xpath (~> 0.1.4) diff --git a/app/cells/admin/global_actions_cell.rb b/app/cells/admin/global_actions_cell.rb deleted file mode 100644 index a0310f2f..00000000 --- a/app/cells/admin/global_actions_cell.rb +++ /dev/null @@ -1,34 +0,0 @@ -class Admin::GlobalActionsCell < ::Admin::MenuCell - - attr_reader :current_admin, :current_site_url - - def show(args) - @current_admin = args[:current_admin] - @current_site_url = args[:current_site_url] - super - end - - protected - - def build_list - add :welcome, :url => edit_admin_my_account_url, :i18n_options => { - :key => 'admin.shared.header.welcome', - :arg => :name, - :value => @current_admin.name - } - - add :see, :url => current_site_url, :id => 'viewsite', :target => '_blank' - - if Locomotive.config.multi_sites? && current_admin.sites.size > 1 - add :switch, :url => '#', :id => 'sites-picker-link' - end - - add :help, :url => '#', :class => 'tutorial', :id => 'help' - add :logout, :url => destroy_admin_session_url, :confirm => t('admin.messages.confirm') - end - - def localize_label(label, options = {}) - I18n.t("admin.shared.header.#{label}", options) - end - -end diff --git a/app/cells/admin/main_menu_cell.rb b/app/cells/admin/main_menu_cell.rb deleted file mode 100644 index e5cc66db..00000000 --- a/app/cells/admin/main_menu_cell.rb +++ /dev/null @@ -1,10 +0,0 @@ -class Admin::MainMenuCell < ::Admin::MenuCell - - protected - - def build_list - add :contents, :url => admin_pages_url - add :settings, :url => edit_admin_current_site_url - end - -end diff --git a/app/cells/admin/settings_menu_cell.rb b/app/cells/admin/settings_menu_cell.rb deleted file mode 100644 index 3da2659d..00000000 --- a/app/cells/admin/settings_menu_cell.rb +++ /dev/null @@ -1,17 +0,0 @@ -class Admin::SettingsMenuCell < ::Admin::SubMenuCell #::Admin::MenuCell - - protected - - def build_list - add :site, :url => edit_admin_current_site_url - add :theme_assets, :url => admin_theme_assets_url - add :account, :url => edit_admin_my_account_url - end - - # def build_item(name, attributes) - # item = super - # enhanced_class = "#{'on' if name.to_s == sections(:sub)} #{item[:class]}" - # item.merge(:class => enhanced_class) - # end - -end diff --git a/app/cells/admin/global_actions/show.html.haml b/app/cells/locomotive/global_actions/show.html.haml similarity index 100% rename from app/cells/admin/global_actions/show.html.haml rename to app/cells/locomotive/global_actions/show.html.haml diff --git a/app/cells/locomotive/global_actions_cell.rb b/app/cells/locomotive/global_actions_cell.rb new file mode 100644 index 00000000..d921fae1 --- /dev/null +++ b/app/cells/locomotive/global_actions_cell.rb @@ -0,0 +1,34 @@ +class Locomotive::GlobalActionsCell < ::Locomotive::MenuCell + + attr_reader :current_account, :current_site_url + + def show(args) + @current_account = args[:current_account] + @current_site_url = args[:current_site_url] + super + end + + protected + + def build_list + add :welcome, :url => edit_locomotive_my_account_url, :i18n_options => { + :key => 'locomotive.shared.header.welcome', + :arg => :name, + :value => @current_account.name + } + + add :see, :url => current_site_url, :id => 'viewsite', :target => '_blank' + + if Locomotive.config.multi_sites? && current_account.sites.size > 1 + add :switch, :url => '#', :id => 'sites-picker-link' + end + + add :help, :url => '#', :class => 'tutorial', :id => 'help' + add :logout, :url => destroy_locomotive_session_url, :confirm => t('locomotive.messages.confirm') + end + + def localize_label(label, options = {}) + I18n.t("locomotive.shared.header.#{label}", options) + end + +end diff --git a/app/cells/admin/main_menu/show.html.haml b/app/cells/locomotive/main_menu/show.html.haml similarity index 100% rename from app/cells/admin/main_menu/show.html.haml rename to app/cells/locomotive/main_menu/show.html.haml diff --git a/app/cells/locomotive/main_menu_cell.rb b/app/cells/locomotive/main_menu_cell.rb new file mode 100644 index 00000000..c6c4b4b5 --- /dev/null +++ b/app/cells/locomotive/main_menu_cell.rb @@ -0,0 +1,10 @@ +class Locomotive::MainMenuCell < ::Locomotive::MenuCell + + protected + + def build_list + add :contents, :url => locomotive_pages_url + add :settings, :url => edit_locomotive_current_site_url + end + +end diff --git a/app/cells/admin/menu/show.html.haml b/app/cells/locomotive/menu/show.html.haml similarity index 100% rename from app/cells/admin/menu/show.html.haml rename to app/cells/locomotive/menu/show.html.haml diff --git a/app/cells/admin/menu_cell.rb b/app/cells/locomotive/menu_cell.rb similarity index 96% rename from app/cells/admin/menu_cell.rb rename to app/cells/locomotive/menu_cell.rb index 1d6c920b..1c0d9df9 100644 --- a/app/cells/admin/menu_cell.rb +++ b/app/cells/locomotive/menu_cell.rb @@ -1,4 +1,4 @@ -class Admin::MenuCell < Cell::Base +class Locomotive::MenuCell < Cell::Base include ::Rails.application.routes.url_helpers @@ -94,7 +94,7 @@ class Admin::MenuCell < Cell::Base end def localize_label(label) - I18n.t("admin.shared.menu.#{label}") + I18n.t("locomotive.shared.menu.#{label}") end end \ No newline at end of file diff --git a/app/cells/locomotive/settings_menu_cell.rb b/app/cells/locomotive/settings_menu_cell.rb new file mode 100644 index 00000000..ec1271ca --- /dev/null +++ b/app/cells/locomotive/settings_menu_cell.rb @@ -0,0 +1,11 @@ +class Locomotive::SettingsMenuCell < ::Locomotive::SubMenuCell + + protected + + def build_list + add :site, :url => edit_locomotive_current_site_url + add :theme_assets, :url => locomotive_theme_assets_url + add :account, :url => edit_locomotive_my_account_url + end + +end diff --git a/app/cells/admin/sub_menu/show.html.haml b/app/cells/locomotive/sub_menu/show.html.haml similarity index 100% rename from app/cells/admin/sub_menu/show.html.haml rename to app/cells/locomotive/sub_menu/show.html.haml diff --git a/app/cells/admin/sub_menu_cell.rb b/app/cells/locomotive/sub_menu_cell.rb similarity index 78% rename from app/cells/admin/sub_menu_cell.rb rename to app/cells/locomotive/sub_menu_cell.rb index 4884bcd7..9e8dd1e0 100644 --- a/app/cells/admin/sub_menu_cell.rb +++ b/app/cells/locomotive/sub_menu_cell.rb @@ -1,4 +1,4 @@ -class Admin::SubMenuCell < ::Admin::MenuCell +class Locomotive::SubMenuCell < ::Locomotive::MenuCell protected diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb deleted file mode 100644 index 6947e663..00000000 --- a/app/controllers/application_controller.rb +++ /dev/null @@ -1,11 +0,0 @@ -class ApplicationController < ActionController::Base - protect_from_forgery - - protected - - # rescue_from Exception, :with => :render_error - # - # def render_error - # render :template => "/admin/errors/500", :layout => '/admin/layouts/box', :status => 500 - # end -end diff --git a/app/controllers/admin/accounts_controller.rb b/app/controllers/locomotive/accounts_controller.rb similarity index 77% rename from app/controllers/admin/accounts_controller.rb rename to app/controllers/locomotive/accounts_controller.rb index 1bd2d58f..6bb618a8 100644 --- a/app/controllers/admin/accounts_controller.rb +++ b/app/controllers/locomotive/accounts_controller.rb @@ -1,4 +1,4 @@ -module Admin +module Locomotive class AccountsController < BaseController sections 'settings' @@ -11,7 +11,7 @@ module Admin @account = Account.create(params[:account]) current_site.memberships.create(:account => @account) if @account.errors.empty? - respond_with @account, :location => edit_admin_current_site_url + respond_with @account, :location => edit_locomotive_current_site_url end end diff --git a/app/controllers/admin/api_contents_controller.rb b/app/controllers/locomotive/api_contents_controller.rb similarity index 98% rename from app/controllers/admin/api_contents_controller.rb rename to app/controllers/locomotive/api_contents_controller.rb index bf605690..7c3fa35f 100644 --- a/app/controllers/admin/api_contents_controller.rb +++ b/app/controllers/locomotive/api_contents_controller.rb @@ -1,4 +1,4 @@ -module Admin +module Locomotive class ApiContentsController < ActionController::Base include Locomotive::Routing::SiteDispatcher diff --git a/app/controllers/admin/assets_controller.rb b/app/controllers/locomotive/assets_controller.rb similarity index 94% rename from app/controllers/admin/assets_controller.rb rename to app/controllers/locomotive/assets_controller.rb index 4daf9015..403681cf 100644 --- a/app/controllers/admin/assets_controller.rb +++ b/app/controllers/locomotive/assets_controller.rb @@ -1,4 +1,4 @@ -module Admin +module Locomotive class AssetsController < BaseController include ActionView::Helpers::SanitizeHelper @@ -48,7 +48,7 @@ module Admin :content_type => asset.content_type, :url => asset.source.url, :vignette_url => asset.vignette_url, - :destroy_url => admin_asset_url(asset, :json) + :destroy_url => locomotive_asset_url(asset, :json) } end diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/locomotive/base_controller.rb similarity index 82% rename from app/controllers/admin/base_controller.rb rename to app/controllers/locomotive/base_controller.rb index 048234c7..f6ac3607 100644 --- a/app/controllers/admin/base_controller.rb +++ b/app/controllers/locomotive/base_controller.rb @@ -1,11 +1,11 @@ -module Admin +module Locomotive class BaseController < InheritedResources::Base include Locomotive::Routing::SiteDispatcher - layout '/admin/layouts/application' + layout '/locomotive/layouts/application' - before_filter :require_admin + before_filter :require_account before_filter :require_site @@ -21,12 +21,12 @@ module Admin # https://rails.lighthouseapp.com/projects/8994/tickets/1905-apphelpers-within-plugin-not-being-mixed-in Dir[File.dirname(__FILE__) + "/../../helpers/**/*_helper.rb"].each do |file| - helper "admin/#{File.basename(file, '.rb').gsub(/_helper$/, '')}" + helper "locomotive/#{File.basename(file, '.rb').gsub(/_helper$/, '')}" end self.responder = Locomotive::AdminResponder # custom responder - defaults :route_prefix => 'admin' + defaults :route_prefix => 'locomotive' respond_to :html @@ -38,23 +38,23 @@ module Admin else flash[:alert] = exception.message - redirect_to admin_pages_url + redirect_to locomotive_pages_url end end protected def set_current_thread_variables - Thread.current[:admin] = current_admin + Thread.current[:account] = current_account Thread.current[:site] = current_site end def current_ability - @current_ability ||= Ability.new(current_admin, current_site) + @current_ability ||= Ability.new(current_account, current_site) end - def require_admin - authenticate_admin! + def require_account + authenticate_account! end def begin_of_association_chain @@ -78,7 +78,7 @@ module Admin end def set_locale - I18n.locale = current_admin.locale rescue Locomotive.config.default_locale + I18n.locale = current_account.locale rescue Locomotive.config.default_locale end # ___ site/page urls builder ___ diff --git a/app/controllers/admin/content_types_controller.rb b/app/controllers/locomotive/content_types_controller.rb similarity index 65% rename from app/controllers/admin/content_types_controller.rb rename to app/controllers/locomotive/content_types_controller.rb index 1cc9582d..e0e5f444 100644 --- a/app/controllers/admin/content_types_controller.rb +++ b/app/controllers/locomotive/content_types_controller.rb @@ -1,10 +1,10 @@ -module Admin +module Locomotive class ContentTypesController < BaseController sections 'contents' def destroy - destroy! { admin_pages_url } + destroy! { locomotive_pages_url } end end diff --git a/app/controllers/admin/contents_controller.rb b/app/controllers/locomotive/contents_controller.rb similarity index 76% rename from app/controllers/admin/contents_controller.rb rename to app/controllers/locomotive/contents_controller.rb index 0ba3cddc..8ae5170b 100644 --- a/app/controllers/admin/contents_controller.rb +++ b/app/controllers/locomotive/contents_controller.rb @@ -1,4 +1,4 @@ -module Admin +module Locomotive class ContentsController < BaseController sections 'contents' @@ -36,11 +36,11 @@ module Admin def sort @content_type.sort_contents!(params[:children]) - respond_with(@content_type, :location => admin_contents_url(@content_type.slug)) + respond_with(@content_type, :location => locomotive_contents_url(@content_type.slug)) end def destroy - destroy! { admin_contents_url(@content_type.slug) } + destroy! { locomotive_contents_url(@content_type.slug) } end protected @@ -55,7 +55,7 @@ module Admin def after_create_or_update_url if params[:breadcrumb_alias].blank? - edit_admin_content_url(@content_type.slug, @content.id) + edit_locomotive_content_url(@content_type.slug, @content.id) else self.breadcrumb_url end @@ -72,11 +72,11 @@ module Admin end def breadcrumb_url - edit_admin_content_url(self.breadcrumb_root._parent.slug, self.breadcrumb_root) + edit_locomotive_content_url(self.breadcrumb_root._parent.slug, self.breadcrumb_root) end def back_url - self.breadcrumb_root ? self.breadcrumb_url : admin_contents_url(@content_type.slug) + self.breadcrumb_root ? self.breadcrumb_url : locomotive_contents_url(@content_type.slug) end end diff --git a/app/controllers/admin/cross_domain_sessions_controller.rb b/app/controllers/locomotive/cross_domain_sessions_controller.rb similarity index 66% rename from app/controllers/admin/cross_domain_sessions_controller.rb rename to app/controllers/locomotive/cross_domain_sessions_controller.rb index aad86fe1..0354239e 100644 --- a/app/controllers/admin/cross_domain_sessions_controller.rb +++ b/app/controllers/locomotive/cross_domain_sessions_controller.rb @@ -1,25 +1,25 @@ -module Admin +module Locomotive class CrossDomainSessionsController < BaseController - layout '/admin/layouts/box' + layout '/locomotive/layouts/box' skip_before_filter :verify_authenticity_token skip_before_filter :validate_site_membership - before_filter :require_admin, :only => :new + before_filter :require_account, :only => :new skip_load_and_authorize_resource def new - if site = current_admin.sites.detect { |s| s._id.to_s == params[:target_id] } + if site = current_account.sites.detect { |s| s._id.to_s == params[:target_id] } if Rails.env == 'development' @target = site.full_subdomain else @target = site.domains_without_subdomain.first || site.full_subdomain end - current_admin.reset_switch_site_token! + current_account.reset_switch_site_token! else redirect_to admin_pages_path end @@ -31,7 +31,7 @@ module Admin sign_in(account) redirect_to admin_pages_path else - redirect_to new_admin_session_path, :alert => t('flash.admin.cross_domain_sessions.create.alert') + redirect_to new_admin_session_path, :alert => t('fash.locomotive.cross_domain_sessions.create.alert') end end diff --git a/app/controllers/admin/current_site_controller.rb b/app/controllers/locomotive/current_site_controller.rb similarity index 84% rename from app/controllers/admin/current_site_controller.rb rename to app/controllers/locomotive/current_site_controller.rb index a54267c7..efa499c1 100644 --- a/app/controllers/admin/current_site_controller.rb +++ b/app/controllers/locomotive/current_site_controller.rb @@ -1,4 +1,4 @@ -module Admin +module Locomotive class CurrentSiteController < BaseController defaults :instance_name => 'site' @@ -15,7 +15,7 @@ module Admin def update update! do |success, failure| - success.html { redirect_to edit_admin_current_site_url(new_host_if_subdomain_changed) } + success.html { redirect_to edit_locomotive_current_site_url(new_host_if_subdomain_changed) } end end diff --git a/app/controllers/admin/custom_fields_controller.rb b/app/controllers/locomotive/custom_fields_controller.rb similarity index 85% rename from app/controllers/admin/custom_fields_controller.rb rename to app/controllers/locomotive/custom_fields_controller.rb index d5ca67a7..cc7e4148 100644 --- a/app/controllers/admin/custom_fields_controller.rb +++ b/app/controllers/locomotive/custom_fields_controller.rb @@ -1,4 +1,4 @@ -module Admin +module Locomotive class CustomFieldsController < BaseController layout false @@ -18,7 +18,7 @@ module Admin if @field.update_attributes(params[:custom_field]) render :json => @field.to_json else - render :json => { :error => t('flash.admin.custom_fields.update.alert') } + render :json => { :error => t('flash.locomotive.custom_fields.update.alert') } end end diff --git a/app/controllers/admin/export_controller.rb b/app/controllers/locomotive/export_controller.rb similarity index 94% rename from app/controllers/admin/export_controller.rb rename to app/controllers/locomotive/export_controller.rb index 8f28f2a5..78081fcd 100644 --- a/app/controllers/admin/export_controller.rb +++ b/app/controllers/locomotive/export_controller.rb @@ -1,4 +1,4 @@ -module Admin +module Locomotive class ExportController < BaseController skip_load_and_authorize_resource diff --git a/app/controllers/admin/import_controller.rb b/app/controllers/locomotive/import_controller.rb similarity index 73% rename from app/controllers/admin/import_controller.rb rename to app/controllers/locomotive/import_controller.rb index 67ef810f..f47f1a55 100644 --- a/app/controllers/admin/import_controller.rb +++ b/app/controllers/locomotive/import_controller.rb @@ -1,4 +1,4 @@ -module Admin +module Locomotive class ImportController < BaseController sections 'settings', 'site' @@ -14,7 +14,7 @@ module Admin respond_to do |format| format.html do - redirect_to new_admin_import_url if @job.nil? + redirect_to new_locomotive_import_url if @job.nil? end format.json { render :json => { :step => @job.nil? ? 'done' : @job.step, @@ -32,14 +32,14 @@ module Admin :reset => Boolean.set(params[:reset]) }) - flash[:notice] = t("flash.admin.import.create.#{Locomotive.config.delayed_job ? 'notice' : 'done'}") + flash[:notice] = t("fash.locomotive.import.create.#{Locomotive.config.delayed_job ? 'notice' : 'done'}") - redirect_to Locomotive.config.delayed_job ? admin_import_url : new_admin_import_url + redirect_to Locomotive.config.delayed_job ? locomotive_import_url : new_locomotive_import_url rescue Exception => e logger.error "[Locomotive import] #{e.message} / #{e.backtrace}" @error = e.message - flash[:alert] = t('flash.admin.import.create.alert') + flash[:alert] = t('fash.locomotive.import.create.alert') render 'new' end diff --git a/app/controllers/admin/installation_controller.rb b/app/controllers/locomotive/installation_controller.rb similarity index 76% rename from app/controllers/admin/installation_controller.rb rename to app/controllers/locomotive/installation_controller.rb index f4c5b0eb..633471ee 100644 --- a/app/controllers/admin/installation_controller.rb +++ b/app/controllers/locomotive/installation_controller.rb @@ -1,11 +1,11 @@ -module Admin +module Locomotive class InstallationController < BaseController - layout '/admin/layouts/box' + layout '/locomotive/layouts/box' skip_before_filter :require_site - skip_before_filter :require_admin + skip_before_filter :require_account skip_before_filter :verify_authenticity_token @@ -36,7 +36,7 @@ module Admin when 1 # create account @account = Account.create(params[:account]) if @account.valid? - redirect_to admin_installation_step_url(2) + redirect_to locomotive_installation_step_url(2) else render 'step_1' end @@ -58,7 +58,7 @@ module Admin case params[:step].to_i when 1 # already an account in db if account = Account.first - @step_done = I18n.t('admin.installation.step_1.done', :name => account.name, :email => account.email) + @step_done = I18n.t('locomotive.installation.step_1.done', :name => account.name, :email => account.email) render 'step_1' and return false end else @@ -67,14 +67,14 @@ module Admin end def allow_installation? - redirect_to admin_pages_url if Site.count > 0 && Account.count > 0 + redirect_to locomotive_pages_url if Site.count > 0 && Account.count > 0 end def last_url if Locomotive.config.manage_domains? - admin_session_url(:host => Site.first.domains.first, :port => request.port) + locomotive_session_url(:host => Site.first.domains.first, :port => request.port) else - admin_session_url + locomotive_session_url end end diff --git a/app/controllers/admin/memberships_controller.rb b/app/controllers/locomotive/memberships_controller.rb similarity index 50% rename from app/controllers/admin/memberships_controller.rb rename to app/controllers/locomotive/memberships_controller.rb index d977884f..a4a75289 100644 --- a/app/controllers/admin/memberships_controller.rb +++ b/app/controllers/locomotive/memberships_controller.rb @@ -1,4 +1,4 @@ -module Admin +module Locomotive class MembershipsController < BaseController sections 'settings' @@ -8,18 +8,18 @@ module Admin case resource.process! when :create_account - redirect_to new_admin_account_url(:email => resource.email) + redirect_to new_locomotive_account_url(:email => resource.email) when :save_it - respond_with resource, :location => edit_admin_current_site_url + respond_with resource, :location => edit_locomotive_current_site_url when :error respond_with resource, :flash => true when :already_created - respond_with resource, :alert => t('flash.admin.memberships.create.already_created'), :location => edit_admin_current_site_url + respond_with resource, :alert => t('flash.locomotive.memberships.create.already_created'), :location => edit_locomotive_current_site_url end end def destroy - destroy! { edit_admin_current_site_url } + destroy! { edit_locomotive_current_site_url } end end diff --git a/app/controllers/admin/my_account_controller.rb b/app/controllers/locomotive/my_account_controller.rb similarity index 77% rename from app/controllers/admin/my_account_controller.rb rename to app/controllers/locomotive/my_account_controller.rb index 950cb5c2..44fc4e0a 100644 --- a/app/controllers/admin/my_account_controller.rb +++ b/app/controllers/locomotive/my_account_controller.rb @@ -1,4 +1,4 @@ -module Admin +module Locomotive class MyAccountController < BaseController sections 'settings', 'account' @@ -10,13 +10,13 @@ module Admin skip_load_and_authorize_resource def update - update! { edit_admin_my_account_url } + update! { edit_locomotive_my_account_url } end protected def resource - @account = current_admin + @account = current_account end def begin_of_association_chain; nil; end # not related directly to current_site diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/locomotive/pages_controller.rb similarity index 82% rename from app/controllers/admin/pages_controller.rb rename to app/controllers/locomotive/pages_controller.rb index a0030484..9de1f432 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/locomotive/pages_controller.rb @@ -1,4 +1,4 @@ -module Admin +module Locomotive class PagesController < BaseController sections 'contents' @@ -17,9 +17,9 @@ module Admin update! do |success, failure| success.json do render :json => { - :notice => t('flash.admin.pages.update.notice'), + :notice => t('flash.locomotive.pages.update.notice'), :editable_elements => @page.template_changed ? - render_to_string(:partial => 'admin/pages/editable_elements.html.haml') : '' + render_to_string(:partial => 'locomotive/pages/editable_elements.html.haml') : '' } end end diff --git a/app/controllers/admin/passwords_controller.rb b/app/controllers/locomotive/passwords_controller.rb similarity index 60% rename from app/controllers/admin/passwords_controller.rb rename to app/controllers/locomotive/passwords_controller.rb index 6625a73e..6408eb9f 100644 --- a/app/controllers/admin/passwords_controller.rb +++ b/app/controllers/locomotive/passwords_controller.rb @@ -1,13 +1,13 @@ -module Admin +module Locomotive class PasswordsController < Devise::PasswordsController include Locomotive::Routing::SiteDispatcher - layout '/admin/layouts/box' + layout '/locomotive/layouts/box' before_filter :require_site - helper 'admin/base', 'admin/box' + helper 'locomotive/base', 'locomotive/box' end end diff --git a/app/controllers/admin/rendering_controller.rb b/app/controllers/locomotive/rendering_controller.rb similarity index 95% rename from app/controllers/admin/rendering_controller.rb rename to app/controllers/locomotive/rendering_controller.rb index 2d92200a..cfd7bc00 100644 --- a/app/controllers/admin/rendering_controller.rb +++ b/app/controllers/locomotive/rendering_controller.rb @@ -1,4 +1,4 @@ -module Admin +module Locomotive class RenderingController < ActionController::Base include Locomotive::Routing::SiteDispatcher diff --git a/app/controllers/admin/robots_controller.rb b/app/controllers/locomotive/robots_controller.rb similarity index 94% rename from app/controllers/admin/robots_controller.rb rename to app/controllers/locomotive/robots_controller.rb index c8be3e6d..6dabb317 100644 --- a/app/controllers/admin/robots_controller.rb +++ b/app/controllers/locomotive/robots_controller.rb @@ -1,4 +1,4 @@ -module Admin +module Locomotive class RobotsController < ActionController::Base include Locomotive::Routing::SiteDispatcher diff --git a/app/controllers/admin/sessions_controller.rb b/app/controllers/locomotive/sessions_controller.rb similarity index 70% rename from app/controllers/admin/sessions_controller.rb rename to app/controllers/locomotive/sessions_controller.rb index efd40f73..af4a0b6b 100644 --- a/app/controllers/admin/sessions_controller.rb +++ b/app/controllers/locomotive/sessions_controller.rb @@ -1,18 +1,18 @@ -module Admin +module Locomotive class SessionsController < Devise::SessionsController include Locomotive::Routing::SiteDispatcher - layout '/admin/layouts/box' + layout '/locomotive/layouts/box' before_filter :require_site - helper 'admin/base', 'admin/box' + helper 'locomotive/base', 'locomotive/box' protected def after_sign_in_path_for(resource) - admin_pages_url + locomotive_pages_url end def after_sign_out_path_for(resource) diff --git a/app/controllers/admin/sitemaps_controller.rb b/app/controllers/locomotive/sitemaps_controller.rb similarity index 68% rename from app/controllers/admin/sitemaps_controller.rb rename to app/controllers/locomotive/sitemaps_controller.rb index 98e8e9a3..f840aa90 100644 --- a/app/controllers/admin/sitemaps_controller.rb +++ b/app/controllers/locomotive/sitemaps_controller.rb @@ -1,7 +1,7 @@ -module Admin +module Locomotive class SitemapsController < BaseController - skip_before_filter :require_admin, :validate_site_membership, :set_locale + skip_before_filter :require_account, :validate_site_membership, :set_locale before_filter :require_site diff --git a/app/controllers/admin/sites_controller.rb b/app/controllers/locomotive/sites_controller.rb similarity index 63% rename from app/controllers/admin/sites_controller.rb rename to app/controllers/locomotive/sites_controller.rb index 6496f78b..b3866787 100644 --- a/app/controllers/admin/sites_controller.rb +++ b/app/controllers/locomotive/sites_controller.rb @@ -1,4 +1,4 @@ -module Admin +module Locomotive class SitesController < BaseController defaults :instance_name => 'site' @@ -7,13 +7,13 @@ module Admin def create @site = Site.new(params[:site]) - @site.memberships.build :account => @current_admin, :role => 'admin' + @site.memberships.build :account => @current_account, :role => 'admin' - create! { edit_admin_my_account_url } + create! { edit_locomotive_my_account_url } end def destroy - @site = current_admin.sites.find(params[:id]) + @site = current_account.sites.find(params[:id]) if @site != current_site @site.destroy @@ -21,7 +21,7 @@ module Admin @site.errors.add(:base, 'Can not destroy the site you are logging in now') end - respond_with @site, :location => edit_admin_my_account_url + respond_with @site, :location => edit_locomotive_my_account_url end protected diff --git a/app/controllers/admin/snippets_controller.rb b/app/controllers/locomotive/snippets_controller.rb similarity index 70% rename from app/controllers/admin/snippets_controller.rb rename to app/controllers/locomotive/snippets_controller.rb index c9dbb1d3..6fcd2852 100644 --- a/app/controllers/admin/snippets_controller.rb +++ b/app/controllers/locomotive/snippets_controller.rb @@ -1,4 +1,4 @@ -module Admin +module Locomotive class SnippetsController < BaseController sections 'settings', 'theme_assets' @@ -7,7 +7,7 @@ module Admin def destroy destroy! do |format| - format.html { redirect_to admin_theme_assets_url } + format.html { redirect_to locomotive_theme_assets_url } end end diff --git a/app/controllers/admin/theme_assets_controller.rb b/app/controllers/locomotive/theme_assets_controller.rb similarity index 98% rename from app/controllers/admin/theme_assets_controller.rb rename to app/controllers/locomotive/theme_assets_controller.rb index 45313c1d..a715b1db 100644 --- a/app/controllers/admin/theme_assets_controller.rb +++ b/app/controllers/locomotive/theme_assets_controller.rb @@ -1,4 +1,4 @@ -module Admin +module Locomotive class ThemeAssetsController < BaseController include ActionView::Helpers::SanitizeHelper diff --git a/app/helpers/admin/accounts_helper.rb b/app/helpers/locomotive/accounts_helper.rb similarity index 70% rename from app/helpers/admin/accounts_helper.rb rename to app/helpers/locomotive/accounts_helper.rb index c6406965..88ca46f9 100644 --- a/app/helpers/admin/accounts_helper.rb +++ b/app/helpers/locomotive/accounts_helper.rb @@ -1,7 +1,7 @@ -module Admin::AccountsHelper +module Locomotive::AccountsHelper def admin_on?(site = current_site) - site.memberships.detect { |m| m.admin? && m.account == current_admin } + site.memberships.detect { |m| m.admin? && m.account == current_account } end end diff --git a/app/helpers/admin/assets_helper.rb b/app/helpers/locomotive/assets_helper.rb similarity index 96% rename from app/helpers/admin/assets_helper.rb rename to app/helpers/locomotive/assets_helper.rb index b0d358fa..ced9f04b 100644 --- a/app/helpers/admin/assets_helper.rb +++ b/app/helpers/locomotive/assets_helper.rb @@ -1,4 +1,4 @@ -module Admin::AssetsHelper +module Locomotive::AssetsHelper def vignette_tag(asset) if asset.image? diff --git a/app/helpers/admin/base_helper.rb b/app/helpers/locomotive/base_helper.rb similarity index 93% rename from app/helpers/admin/base_helper.rb rename to app/helpers/locomotive/base_helper.rb index b3f858c4..64288568 100644 --- a/app/helpers/admin/base_helper.rb +++ b/app/helpers/locomotive/base_helper.rb @@ -1,4 +1,4 @@ -module Admin::BaseHelper +module Locomotive::BaseHelper def title(title = nil) if title.nil? @@ -15,7 +15,7 @@ module Admin::BaseHelper css = "#{'on' if name == sections(:sub)} #{options[:css]}" - label_link = default_options[:i18n] ? t("admin.shared.menu.#{name}") : name + label_link = default_options[:i18n] ? t("locomotive.shared.menu.#{name}") : name if block_given? popup = content_tag(:div, capture(&block), :class => 'popup', :style => 'display: none') link = link_to(content_tag(:span, preserve(label_link) + content_tag(:em)) + content_tag(:em), url, :class => css) diff --git a/app/helpers/admin/box_helper.rb b/app/helpers/locomotive/box_helper.rb similarity index 70% rename from app/helpers/admin/box_helper.rb rename to app/helpers/locomotive/box_helper.rb index ef0ec0a5..97e332ea 100644 --- a/app/helpers/admin/box_helper.rb +++ b/app/helpers/locomotive/box_helper.rb @@ -1,4 +1,4 @@ -module Admin::BoxHelper +module Locomotive::BoxHelper def box_flash_message if not flash.empty? @@ -15,7 +15,7 @@ module Admin::BoxHelper end def next_installation_step_link(step = 1, label = nil) - link_to(content_tag(:span, label || t('admin.installation.common.next')), admin_installation_step_url(step), :class => 'button') + link_to(content_tag(:span, label || t('locomotive.installation.common.next')), locomotive_installation_step_url(step), :class => 'button') end end diff --git a/app/helpers/admin/content_types_helper.rb b/app/helpers/locomotive/content_types_helper.rb similarity index 94% rename from app/helpers/admin/content_types_helper.rb rename to app/helpers/locomotive/content_types_helper.rb index 377fb024..a0869a10 100644 --- a/app/helpers/admin/content_types_helper.rb +++ b/app/helpers/locomotive/content_types_helper.rb @@ -1,4 +1,4 @@ -module Admin::ContentTypesHelper +module Locomotive::ContentTypesHelper MAX_DISPLAYED_CONTENTS = 4 @@ -42,7 +42,7 @@ module Admin::ContentTypesHelper item_on = (content_type.slug == @content_type.slug) rescue nil label = truncate(content_type.name, :length => 15) - url = admin_contents_url(content_type.slug) + url = locomotive_contents_url(content_type.slug) css = @content_type && content_type.slug == @content_type.slug ? 'on' : '' html = admin_content_menu_item(label, url, :i18n => false, :css => css) do @@ -79,7 +79,7 @@ module Admin::ContentTypesHelper registers = { :controller => self, :site => current_site, - :current_admin => current_admin + :current_account => current_account } preserve(content._parent.item_template.render(::Liquid::Context.new({}, assigns, registers))) diff --git a/app/helpers/admin/custom_fields_helper.rb b/app/helpers/locomotive/custom_fields_helper.rb similarity index 88% rename from app/helpers/admin/custom_fields_helper.rb rename to app/helpers/locomotive/custom_fields_helper.rb index 61140c6d..1e8cc36c 100644 --- a/app/helpers/admin/custom_fields_helper.rb +++ b/app/helpers/locomotive/custom_fields_helper.rb @@ -1,4 +1,4 @@ -module Admin::CustomFieldsHelper +module Locomotive::CustomFieldsHelper def options_for_field_kind %w(string text category boolean date file has_one has_many).map do |kind| @@ -8,14 +8,14 @@ module Admin::CustomFieldsHelper def options_for_order_by(content_type, collection_name) options = %w{created_at updated_at _position_in_list}.map do |type| - [t("admin.content_types.form.order_by.#{type.gsub(/^_/, '')}"), type] + [t("locomotive.content_types.form.order_by.#{type.gsub(/^_/, '')}"), type] end options + options_for_highlighted_field(content_type, collection_name) end def options_for_order_direction %w(asc desc).map do |direction| - [t("admin.content_types.form.order_direction.#{direction}"), direction] + [t("locomotive.content_types.form.order_direction.#{direction}"), direction] end end @@ -35,7 +35,7 @@ module Admin::CustomFieldsHelper def options_for_text_formatting options = %w(none html).map do |option| - [t("admin.custom_fields.text_formatting.#{option}"), option] + [t("locomotive.custom_fields.text_formatting.#{option}"), option] end end @@ -128,10 +128,10 @@ module Admin::CustomFieldsHelper options.merge!( :new_item => { - :label => t('admin.contents.form.has_many.new_item'), - :url => new_admin_content_url(field.target_klass._parent.slug, url_options) + :label => t('locomotive.contents.form.has_many.new_item'), + :url => new_locomotive_content_url(field.target_klass._parent.slug, url_options) }, - :edit_item_url => edit_admin_content_url(field.target_klass._parent.slug, 42, url_options) + :edit_item_url => edit_locomotive_content_url(field.target_klass._parent.slug, 42, url_options) ) end diff --git a/app/helpers/admin/pages_helper.rb b/app/helpers/locomotive/pages_helper.rb similarity index 96% rename from app/helpers/admin/pages_helper.rb rename to app/helpers/locomotive/pages_helper.rb index 16da4278..0fb48917 100644 --- a/app/helpers/admin/pages_helper.rb +++ b/app/helpers/locomotive/pages_helper.rb @@ -1,4 +1,4 @@ -module Admin::PagesHelper +module Locomotive::PagesHelper def parent_pages_options roots = current_site.pages.roots.where(:slug.ne => '404').and(:_id.ne => @page.id) diff --git a/app/helpers/admin/sites_helper.rb b/app/helpers/locomotive/sites_helper.rb similarity index 95% rename from app/helpers/admin/sites_helper.rb rename to app/helpers/locomotive/sites_helper.rb index c3d58d2f..99875ba6 100644 --- a/app/helpers/admin/sites_helper.rb +++ b/app/helpers/locomotive/sites_helper.rb @@ -1,4 +1,4 @@ -module Admin::SitesHelper +module Locomotive::SitesHelper def application_domain domain = Locomotive.config.domain diff --git a/app/mailers/admin/notifications.rb b/app/mailers/locomotive/notifications.rb similarity index 61% rename from app/mailers/admin/notifications.rb rename to app/mailers/locomotive/notifications.rb index 54a2b67e..e4dc6a01 100644 --- a/app/mailers/admin/notifications.rb +++ b/app/mailers/locomotive/notifications.rb @@ -1,4 +1,4 @@ -module Admin +module Locomotive class Notifications < ActionMailer::Base default :from => Locomotive.config.mailer_sender @@ -6,7 +6,7 @@ module Admin def new_content_instance(account, content) @account, @content = account, content - subject = t('admin.notifications.new_content_instance.subject', :type => content.content_type.name, :locale => account.locale) + subject = t('locomotive.notifications.new_content_instance.subject', :type => content.content_type.name, :locale => account.locale) mail :subject => subject, :to => account.email end diff --git a/app/models/ability.rb b/app/models/ability.rb deleted file mode 100644 index 745bb03d..00000000 --- a/app/models/ability.rb +++ /dev/null @@ -1,83 +0,0 @@ -class Ability - include CanCan::Ability - - ROLES = %w(admin designer author) - - def initialize(account, site) - @account, @site = account, site - - alias_action :index, :show, :edit, :update, :to => :touch - - @membership = @site.memberships.where(:account_id => @account.id).first - - return false if @membership.blank? - - if @membership.admin? - setup_admin_permissions! - else - setup_default_permissions! - - setup_designer_permissions! if @membership.designer? - - setup_author_permissions! if @membership.author? - end - end - - def setup_default_permissions! - cannot :manage, :all - end - - def setup_author_permissions! - can :touch, [Page, ThemeAsset] - can :sort, Page - - can :manage, [ContentInstance, Asset] - - can :touch, Site do |site| - site == @site - end - end - - def setup_designer_permissions! - can :manage, Page - - can :manage, ContentInstance - - can :manage, ContentType - - can :manage, Snippet - - can :manage, ThemeAsset - - can :manage, Asset - - can :manage, Site do |site| - site == @site - end - - can :import, Site - - can :export, Site - - can :point, Site - - cannot :create, Site - - can :manage, Membership - - cannot :grant_admin, Membership - - cannot [:update, :destroy], Membership do |membership| - @membership.account_id == membership.account_id || # can not edit myself - membership.admin? # can not modify an administrator - end - end - - def setup_admin_permissions! - can :manage, :all - - cannot [:update, :destroy], Membership do |membership| - @membership.account_id == membership.account_id # can not edit myself - end - end -end diff --git a/app/models/account.rb b/app/models/account.rb deleted file mode 100644 index b50e9aa3..00000000 --- a/app/models/account.rb +++ /dev/null @@ -1,60 +0,0 @@ -require 'digest' - -class Account - - include Locomotive::Mongoid::Document - - devise *Locomotive.config.devise_modules - - ## attributes ## - field :name - field :locale, :default => Locomotive.config.default_locale.to_s or 'en' - field :switch_site_token - - ## validations ## - validates_presence_of :name - - ## associations ## - - ## callbacks ## - before_destroy :remove_memberships! - - ## methods ## - - def sites - @sites ||= Site.where({ 'memberships.account_id' => self._id }) - end - - def reset_switch_site_token! - self.switch_site_token = ActiveSupport::SecureRandom.base64(8).gsub("/", "_").gsub(/=+$/, "") - self.save - end - - def self.find_using_switch_site_token(token, age = 1.minute) - return if token.blank? - self.where(:switch_site_token => token, :updated_at.gt => age.ago.utc).first - end - - def self.find_using_switch_site_token!(token, age = 1.minute) - self.find_using_switch_site_token(token, age) || raise(Mongoid::Errors::DocumentNotFound.new(self, token)) - end - - protected - - def password_required? - !persisted? || !password.blank? || !password_confirmation.blank? - end - - def remove_memberships! - self.sites.each do |site| - membership = site.memberships.where(:account_id => self._id).first - - if site.admin_memberships.size == 1 && membership.admin? - raise I18n.t('errors.messages.needs_admin_account') - else - membership.destroy - end - end - end - -end diff --git a/app/models/asset.rb b/app/models/asset.rb deleted file mode 100644 index 9305f5cf..00000000 --- a/app/models/asset.rb +++ /dev/null @@ -1,39 +0,0 @@ -class Asset - - include Mongoid::Document - include Mongoid::Timestamps - - ## extensions ## - include Extensions::Asset::Types - include Extensions::Asset::Vignette - - ## fields ## - field :content_type, :type => String - field :width, :type => Integer - field :height, :type => Integer - field :size, :type => Integer - field :position, :type => Integer, :default => 0 - mount_uploader :source, AssetUploader - - ## associations ## - referenced_in :site - - ## validations ## - validates_presence_of :source - - ## behaviours ## - - ## methods ## - - alias :name :source_filename - - def extname - return nil unless self.source? - File.extname(self.source_filename).gsub(/^\./, '') - end - - def to_liquid - { :url => self.source.url }.merge(self.attributes).stringify_keys - end - -end diff --git a/app/models/content_instance.rb b/app/models/content_instance.rb deleted file mode 100644 index 527c76ba..00000000 --- a/app/models/content_instance.rb +++ /dev/null @@ -1,125 +0,0 @@ -class ContentInstance - - include Mongoid::Document - include Mongoid::Timestamps - - ## extensions ## - include CustomFields::ProxyClassEnabler - include Extensions::Shared::Seo - - ## fields (dynamic fields) ## - field :_slug - field :_position_in_list, :type => Integer, :default => 0 - field :_visible, :type => Boolean, :default => true - - ## validations ## - validate :require_highlighted_field - validate :validate_uniqueness_of_slug - validates_presence_of :_slug - - ## associations ## - embedded_in :content_type, :inverse_of => :contents - - ## callbacks ## - before_validation :set_slug - before_save :set_visibility - before_create :add_to_list_bottom - after_create :send_notifications - - ## named scopes ## - scope :latest_updated, :order_by => :updated_at.desc, :limit => Locomotive.config.lastest_items_nb - - ## methods ## - - delegate :site, :to => :content_type - - alias :visible? :_visible? - alias :_permalink :_slug - alias :_permalink= :_slug= - - def site_id # needed by the uploader of custom fields - self.content_type.site_id - end - - def highlighted_field_value - self.send(self.content_type.highlighted_field_name) - end - - alias :_label :highlighted_field_value - - def visible? - self._visible || self._visible.nil? - end - - def next - content_type.contents.where(:_position_in_list => _position_in_list + 1).first() - end - - def previous - content_type.contents.where(:_position_in_list => _position_in_list - 1).first() - end - - def errors_to_hash - Hash.new.replace(self.errors) - end - - def reload_parent! - self.class.reload_parent! - end - - def self.reload_parent! - self._parent = self._parent.reload - end - - def to_liquid - Locomotive::Liquid::Drops::Content.new(self) - end - - protected - - def set_slug - self._slug = self.highlighted_field_value.dup if self._slug.blank? && self.highlighted_field_value.present? - self._slug.permalink! if self._slug.present? - end - - def set_visibility - field = self.content_type.content_custom_fields.detect { |f| %w{visible active}.include?(f._alias) } - self._visible = self.send(field._name) rescue true - end - - def add_to_list_bottom - self._position_in_list = self.content_type.contents.size - end - - def require_highlighted_field - _alias = self.highlighted_field_alias - if self.send(_alias).blank? - self.errors.add(_alias, :blank) - end - end - - def validate_uniqueness_of_slug - if self._parent.contents.any? { |c| c._id != self._id && c._slug == self._slug } - self.errors.add(:_slug, :taken) - end - end - - def highlighted_field_alias - self.content_type.highlighted_field._alias.to_sym - end - - def send_notifications - return unless self.content_type.api_enabled? && !self.content_type.api_accounts.blank? - - accounts = self.content_type.site.accounts.to_a - - self.content_type.api_accounts.each do |account_id| - next if account_id.blank? - - account = accounts.detect { |a| a.id.to_s == account_id.to_s } - - Admin::Notifications.new_content_instance(account, self).deliver - end - end - -end diff --git a/app/models/content_type.rb b/app/models/content_type.rb deleted file mode 100644 index d56c02ba..00000000 --- a/app/models/content_type.rb +++ /dev/null @@ -1,145 +0,0 @@ -class ContentType - - include Locomotive::Mongoid::Document - - ## extensions ## - include Extensions::ContentType::ItemTemplate - - ## fields ## - field :name - field :description - field :slug - field :order_by - field :order_direction, :default => 'asc' - field :highlighted_field_name - field :group_by_field_name - field :api_enabled, :type => Boolean, :default => false - field :api_accounts, :type => Array - - ## associations ## - referenced_in :site - embeds_many :contents, :class_name => 'ContentInstance', :validate => false do - def visible - @target.find_all { |c| c.visible? } - end - end - - ## named scopes ## - scope :ordered, :order_by => :updated_at.desc - - ## indexes ## - index [[:site_id, Mongo::ASCENDING], [:slug, Mongo::ASCENDING]] - - ## callbacks ## - before_validation :normalize_slug - before_save :set_default_values - after_destroy :remove_uploaded_files - - ## validations ## - validates_presence_of :site, :name, :slug - validates_uniqueness_of :slug, :scope => :site_id - validates_size_of :content_custom_fields, :minimum => 1, :message => :array_too_short - - ## behaviours ## - custom_fields_for :contents - - ## methods ## - - def groupable? - self.group_by_field && group_by_field.category? - end - - def order_manually? - self.order_by == '_position_in_list' - end - - def asc_order? - self.order_direction.blank? || self.order_direction == 'asc' - end - - def list_or_group_contents - if self.groupable? - groups = self.contents.klass.send(:"group_by_#{self.group_by_field._alias}", :ordered_contents) - - # look for items with no category or unknown ones - items_without_category = self.contents.find_all { |c| !self.group_by_field.category_ids.include?(c.send(self.group_by_field_name)) } - if not items_without_category.empty? - groups << { :name => nil, :items => items_without_category } - else - groups - end - else - self.ordered_contents - end - end - - def latest_updated_contents - self.contents.latest_updated.reject { |c| !c.persisted? } - end - - def ordered_contents(conditions = {}) - column = self.order_by.to_sym - - list = (if conditions.nil? || conditions.empty? - self.contents - else - conditions_with_names = {} - - conditions.each do |key, value| - # convert alias (key) to name - field = self.content_custom_fields.detect { |f| f._alias == key } - - case field.kind.to_sym - when :category - if (category_item = field.category_items.where(:name => value).first).present? - conditions_with_names[field._name.to_sym] = category_item._id - end - else - conditions_with_names[field._name.to_sym] = value - end - end - - self.contents.where(conditions_with_names) - end).sort { |a, b| (a.send(column) || 0) <=> (b.send(column) || 0) } - - return list if self.order_manually? - - self.asc_order? ? list : list.reverse - end - - def sort_contents!(ids) - ids.each_with_index do |id, position| - self.contents.find(BSON::ObjectId(id))._position_in_list = position - end - self.save - end - - def highlighted_field - self.content_custom_fields.detect { |f| f._name == self.highlighted_field_name } - end - - def group_by_field - @group_by_field ||= self.content_custom_fields.detect { |f| f._name == self.group_by_field_name } - end - - protected - - def set_default_values - self.order_by ||= 'created_at' - self.highlighted_field_name ||= self.content_custom_fields.first._name - end - - def normalize_slug - self.slug = self.name.clone if self.slug.blank? && self.name.present? - self.slug.permalink! if self.slug.present? - end - - def remove_uploaded_files # callbacks are not called on each content so we do it manually - self.contents.each do |content| - self.content_custom_fields.each do |field| - content.send(:"remove_#{field._name}!") if field.kind == 'file' - end - end - end - -end diff --git a/app/models/editable_element.rb b/app/models/editable_element.rb deleted file mode 100644 index dff80b1d..00000000 --- a/app/models/editable_element.rb +++ /dev/null @@ -1,27 +0,0 @@ -class EditableElement - - include Mongoid::Document - - ## fields ## - field :slug - field :block - field :default_content - field :default_attribute - field :hint - field :priority, :type => Integer, :default => 0 - field :disabled, :type => Boolean, :default => false - field :assignable, :type => Boolean, :default => true - field :from_parent, :type => Boolean, :default => false - - ## associations ## - embedded_in :page, :inverse_of => :editable_elements - - ## validations ## - validates_presence_of :slug - - ## scopes ## - scope :by_priority, :order_by => [[:priority, :desc]] - - ## methods ## - -end \ No newline at end of file diff --git a/app/models/editable_file.rb b/app/models/editable_file.rb deleted file mode 100644 index f96fa619..00000000 --- a/app/models/editable_file.rb +++ /dev/null @@ -1,9 +0,0 @@ -class EditableFile < EditableElement - - mount_uploader :source, EditableFileUploader - - def content - self.source? ? self.source.url : self.default_content - end - -end \ No newline at end of file diff --git a/app/models/editable_long_text.rb b/app/models/editable_long_text.rb deleted file mode 100644 index 2481aadc..00000000 --- a/app/models/editable_long_text.rb +++ /dev/null @@ -1,3 +0,0 @@ -class EditableLongText < EditableShortText - -end \ No newline at end of file diff --git a/app/models/editable_short_text.rb b/app/models/editable_short_text.rb deleted file mode 100644 index 5e57a193..00000000 --- a/app/models/editable_short_text.rb +++ /dev/null @@ -1,12 +0,0 @@ -class EditableShortText < EditableElement - - ## fields ## - field :content - - ## methods ## - - def content - self.read_attribute(:content).blank? ? self.default_content : self.read_attribute(:content) - end - -end \ No newline at end of file diff --git a/app/models/extensions/asset/types.rb b/app/models/extensions/asset/types.rb deleted file mode 100644 index 7c8a94f6..00000000 --- a/app/models/extensions/asset/types.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Extensions - module Asset - module Types - - extend ActiveSupport::Concern - - included do - %w{media image stylesheet javascript font pdf}.each do |type| - scope :"only_#{type}", where(:content_type => type) - - define_method("#{type}?") do - self.content_type.to_s == type - end - end - end - - end - end -end \ No newline at end of file diff --git a/app/models/extensions/asset/vignette.rb b/app/models/extensions/asset/vignette.rb deleted file mode 100644 index 2cb16027..00000000 --- a/app/models/extensions/asset/vignette.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Extensions - module Asset - module Vignette - - def vignette_url - if self.image? - if self.width < 80 && self.height < 80 - self.source.url - else - Locomotive::Dragonfly.resize_url(self.source, '80x80#') - end - end - end - - end - end -end \ No newline at end of file diff --git a/app/models/extensions/content_type/item_template.rb b/app/models/extensions/content_type/item_template.rb deleted file mode 100644 index 6ee5f5db..00000000 --- a/app/models/extensions/content_type/item_template.rb +++ /dev/null @@ -1,49 +0,0 @@ -module Extensions - module ContentType - module ItemTemplate - - extend ActiveSupport::Concern - - included do - field :raw_item_template - field :serialized_item_template, :type => Binary - - before_validation :serialize_item_template - - validate :item_template_must_be_valid - end - - module InstanceMethods - - def item_template - @item_template ||= Marshal.load(read_attribute(:serialized_item_template).to_s) rescue nil - end - - protected - - def serialize_item_template - if self.new_record? || self.raw_item_template_changed? - @item_parsing_errors = [] - - begin - self._parse_and_serialize_item_template - rescue ::Liquid::SyntaxError => error - @item_parsing_errors << I18n.t(:liquid_syntax, :error => error.to_s, :scope => [:errors, :messages]) - end - end - end - - def _parse_and_serialize_item_template - item_template = ::Liquid::Template.parse(self.raw_item_template, {}) - self.serialized_item_template = BSON::Binary.new(Marshal.dump(item_template)) - end - - def item_template_must_be_valid - @item_parsing_errors.try(:each) { |msg| self.errors.add :item_template, msg } - end - - end - - end - end -end \ No newline at end of file diff --git a/app/models/extensions/page/editable_elements.rb b/app/models/extensions/page/editable_elements.rb deleted file mode 100644 index 38c9a5fe..00000000 --- a/app/models/extensions/page/editable_elements.rb +++ /dev/null @@ -1,118 +0,0 @@ -module Extensions - module Page - module EditableElements - - extend ActiveSupport::Concern - - included do - embeds_many :editable_elements - - after_save :remove_disabled_editable_elements - - # editable file callbacks - after_save :store_file_sources! - before_save :write_file_source_identifiers - after_destroy :remove_file_sources! - - accepts_nested_attributes_for :editable_elements - end - - module InstanceMethods - - def disable_parent_editable_elements(block) - self.editable_elements.each { |el| el.disabled = true if el.from_parent? && el.block == block } - end - - def disable_all_editable_elements - self.editable_elements.each { |el| el.disabled = true } - end - - def editable_element_blocks - self.editable_elements.collect(&:block) - end - - def editable_elements_grouped_by_blocks - all_enabled = self.editable_elements.by_priority.reject { |el| el.disabled? } - groups = all_enabled.group_by(&:block) - groups.delete_if { |block, elements| elements.empty? } - end - - def find_editable_element(block, slug) - self.editable_elements.detect { |el| el.block == block && el.slug == slug } - end - - def find_editable_files - self.editable_elements.find_all { |el| el.respond_to?(:source) } - end - - def add_or_update_editable_element(attributes, type) - element = self.find_editable_element(attributes[:block], attributes[:slug]) - - if element - element.attributes = attributes - else - self.editable_elements.build(attributes, type) - end - end - - def enable_editable_elements(block) - self.editable_elements.each { |el| el.disabled = false if el.block == block } - end - - def merge_editable_elements_from_page(source) - source.editable_elements.each do |el| - next if el.disabled? or !el.assignable? - - existing_el = self.find_editable_element(el.block, el.slug) - - if existing_el.nil? # new one from parents - new_attributes = el.attributes.merge(:from_parent => true) - - if new_attributes['default_attribute'].present? - new_attributes['default_content'] = self.send(new_attributes['default_attribute']) || el.content - else - if el.respond_to?(:content) # only for text - new_attributes['default_content'] = el.content - end - end - - self.editable_elements.build(new_attributes, el.class) - elsif existing_el.default_attribute.nil? - existing_el.attributes = { :disabled => false, :default_content => el.content } - else - existing_el.attributes = { :disabled => false } - end - end - end - - def remove_disabled_editable_elements - return unless self.editable_elements.any? { |el| el.disabled? } - - # super fast way to remove useless elements all in once (TODO callbacks) - self.collection.update(self._selector, '$pull' => { 'editable_elements' => { 'disabled' => true } }) - end - - protected - - ## callbacks for editable files - - # equivalent to "after_save :store_source!" in EditableFile - def store_file_sources! - self.find_editable_files.collect(&:store_source!) - end - - # equivalent to "before_save :write_source_identifier" in EditableFile - def write_file_source_identifiers - self.find_editable_files.collect(&:write_source_identifier) - end - - # equivalent to "after_destroy :remove_source!" in EditableFile - def remove_file_sources! - self.find_editable_files.collect(&:remove_source!) - end - - end - - end - end -end \ No newline at end of file diff --git a/app/models/extensions/page/listed.rb b/app/models/extensions/page/listed.rb deleted file mode 100644 index b4c5e952..00000000 --- a/app/models/extensions/page/listed.rb +++ /dev/null @@ -1,15 +0,0 @@ -module Extensions - module Page - module Listed - - extend ActiveSupport::Concern - - included do - - field :listed, :type => Boolean, :default => true - - end - - end - end -end \ No newline at end of file diff --git a/app/models/extensions/page/parse.rb b/app/models/extensions/page/parse.rb deleted file mode 100644 index 14b47b33..00000000 --- a/app/models/extensions/page/parse.rb +++ /dev/null @@ -1,111 +0,0 @@ -module Extensions - module Page - module Parse - - extend ActiveSupport::Concern - - included do - field :serialized_template, :type => Binary - field :template_dependencies, :type => Array, :default => [] - field :snippet_dependencies, :type => Array, :default => [] - - attr_reader :template_changed - - before_validation :serialize_template - after_save :update_template_descendants - - validate :template_must_be_valid - - scope :pages, lambda { |domain| { :any_in => { :domains => [*domain] } } } - end - - module InstanceMethods - - def template - @template ||= Marshal.load(read_attribute(:serialized_template).to_s) rescue nil - end - - protected - - def serialize_template - if self.new_record? || self.raw_template_changed? - @template_changed = true - - @parsing_errors = [] - - begin - self._parse_and_serialize_template - rescue ::Liquid::SyntaxError => error - @parsing_errors << I18n.t(:liquid_syntax, :fullpath => self.fullpath, :error => error.to_s, :scope => [:errors, :messages, :page]) - rescue ::Locomotive::Liquid::PageNotFound => error - @parsing_errors << I18n.t(:liquid_extend, :fullpath => self.fullpath, :scope => [:errors, :messages, :page]) - end - end - end - - def _parse_and_serialize_template(context = {}) - self.parse(context) - self._serialize_template - end - - def _serialize_template - self.serialized_template = BSON::Binary.new(Marshal.dump(@template)) - end - - def parse(context = {}) - self.disable_all_editable_elements - - default_context = { :site => self.site, :page => self, :templates => [], :snippets => [] } - - context = default_context.merge(context) - - @template = ::Liquid::Template.parse(self.raw_template, context) - - self.template_dependencies = context[:templates] - self.snippet_dependencies = context[:snippets] - - @template.root.context.clear - end - - def template_must_be_valid - @parsing_errors.try(:each) { |msg| self.errors.add :template, msg } - end - - def update_template_descendants - return unless @template_changed == true - - # we admit at this point that the current template is up-to-date - template_descendants = self.site.pages.any_in(:template_dependencies => [self.id]).to_a - - # group them by fullpath for better performance - cached = template_descendants.inject({}) { |memo, page| memo[page.fullpath] = page; memo } - - self._update_direct_template_descendants(template_descendants.clone, cached) - - # finally save them all - ::Page.without_callback(:save, :after, :update_template_descendants) do - template_descendants.each do |page| - page.save(:validate => false) - end - end - end - - def _update_direct_template_descendants(template_descendants, cached) - direct_descendants = template_descendants.select do |page| - ((self.template_dependencies || []) + [self._id]) == (page.template_dependencies || []) - end - - direct_descendants.each do |page| - page.send(:_parse_and_serialize_template, { :cached_parent => self, :cached_pages => cached }) - - template_descendants.delete(page) # no need to loop over it next time - - page.send(:_update_direct_template_descendants, template_descendants, cached) # move down - end - end - - end - - end - end -end \ No newline at end of file diff --git a/app/models/extensions/page/redirect.rb b/app/models/extensions/page/redirect.rb deleted file mode 100644 index ee18d624..00000000 --- a/app/models/extensions/page/redirect.rb +++ /dev/null @@ -1,21 +0,0 @@ -module Extensions - module Page - module Redirect - - extend ActiveSupport::Concern - - included do - - field :redirect, :type => Boolean, :default => false - - field :redirect_url, :type => String - - validates_presence_of :redirect_url, :if => :redirect - - validates_format_of :redirect_url, :with => Locomotive::Regexps::URL, :allow_blank => true - - end - - end - end -end \ No newline at end of file diff --git a/app/models/extensions/page/render.rb b/app/models/extensions/page/render.rb deleted file mode 100644 index 81494e46..00000000 --- a/app/models/extensions/page/render.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Extensions - module Page - module Render - - def render(context) - self.template.render(context) - end - - end - end -end \ No newline at end of file diff --git a/app/models/extensions/page/templatized.rb b/app/models/extensions/page/templatized.rb deleted file mode 100644 index 500fa418..00000000 --- a/app/models/extensions/page/templatized.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Extensions - module Page - module Templatized - - extend ActiveSupport::Concern - - included do - - referenced_in :content_type - - field :templatized, :type => Boolean, :default => false - - field :content_type_visible_column - - before_validation :set_slug_if_templatized - end - - module InstanceMethods - - def set_slug_if_templatized - self.slug = 'content_type_template' if self.templatized? - end - - end - - end - end -end \ No newline at end of file diff --git a/app/models/extensions/page/tree.rb b/app/models/extensions/page/tree.rb deleted file mode 100644 index 6970269a..00000000 --- a/app/models/extensions/page/tree.rb +++ /dev/null @@ -1,158 +0,0 @@ -module Extensions - module Page - module Tree - - extend ActiveSupport::Concern - - included do - include Mongoid::Acts::Tree - - ## fields ## - field :position, :type => Integer - - ## indexes ## - index :position - index [[:depth, :asc], [:position, :asc]] - - ## behaviours ## - acts_as_tree :order => ['position', 'asc'] - - ## callbacks ## - before_validation :reset_parent - before_save { |p| p.send(:write_attribute, :parent_id, nil) if p.parent_id.blank? } - before_save :change_parent - before_create { |p| p.send(:fix_position, false) } - before_create :add_to_list_bottom - before_destroy :remove_from_list - - # Fixme (Didier L.): Instances methods are defined before the include itself - alias :fix_position :hacked_fix_position - alias :descendants :hacked_descendants - end - - module ClassMethods - - # Warning: should be used only in read-only - def quick_tree(site, minimal_attributes = true) - pages = (minimal_attributes ? site.pages.minimal_attributes : site.pages).order_by([[:depth, :asc], [:position, :asc]]).to_a - - tmp = [] - - while !pages.empty? - tmp << _quick_tree(pages.delete_at(0), pages) - end - - tmp - end - - def _quick_tree(current_page, pages) - i, children = 0, [] - - while !pages.empty? - page = pages[i] - - break if page.nil? - - if page.parent_id == current_page.id - page = pages.delete_at(i) - - children << _quick_tree(page, pages) - else - i += 1 - end - end - - current_page.instance_eval do - def children=(list); @children = list; end - def children; @children || []; end - end - - current_page.children = children - - current_page - end - - end - - module InstanceMethods - - def children? - self.class.where(self.parent_id_field => self.id).count - end - - def children_with_minimal_attributes - self.class.where(self.parent_id_field => self.id). - order_by(self.tree_order). - minimal_attributes - end - - def sort_children!(ids) - ids.each_with_index do |id, position| - child = self.children.detect { |p| p._id == BSON::ObjectId(id) } - child.position = position - child.save - end - end - - def parent=(owner) # missing in acts_as_tree - @_parent = owner - self.fix_position(false) - self.instance_variable_set :@_will_move, true - end - - def hacked_descendants - return [] if new_record? - self.class.all_in(path_field => [self._id]).order_by tree_order - end - - protected - - def change_parent - if self.parent_id_changed? - self.fix_position(false) - - unless self.parent_id_was.nil? - self.position = nil # make it move to bottom - self.add_to_list_bottom - end - - self.instance_variable_set :@_will_move, true - end - end - - def hacked_fix_position(perform_save = true) - if parent.nil? - self.write_attribute parent_id_field, nil - self[path_field] = [] - self[depth_field] = 0 - else - self.write_attribute parent_id_field, parent._id - self[path_field] = parent[path_field] + [parent._id] - self[depth_field] = parent[depth_field] + 1 - self.save if perform_save - end - end - - def reset_parent - if self.parent_id_changed? - @_parent = nil - end - end - - def add_to_list_bottom - self.position ||= (::Page.where(:_id.ne => self._id).and(:parent_id => self.parent_id).max(:position) || 0) + 1 - end - - def remove_from_list - return if (self.site rescue nil).nil? - - ::Page.where(:parent_id => self.parent_id).and(:position.gt => self.position).each do |p| - p.position -= 1 - p.save - end - end - - end - end - end -end \ No newline at end of file diff --git a/app/models/extensions/shared/seo.rb b/app/models/extensions/shared/seo.rb deleted file mode 100644 index be386296..00000000 --- a/app/models/extensions/shared/seo.rb +++ /dev/null @@ -1,14 +0,0 @@ -module Extensions - module Shared - module Seo - extend ActiveSupport::Concern - - included do - field :seo_title, :type => String - field :meta_keywords, :type => String - field :meta_description, :type => String - end - - end # Seo - end # Shared -end # Extensions diff --git a/app/models/extensions/site/first_installation.rb b/app/models/extensions/site/first_installation.rb deleted file mode 100644 index 3679f663..00000000 --- a/app/models/extensions/site/first_installation.rb +++ /dev/null @@ -1,36 +0,0 @@ -module Extensions - module Site - module FirstInstallation - - # only called during the installation workflow, just after the admin account has been created - def create_first_one(attributes) - site = self.new(attributes) - - site.memberships.build :account => Account.first, :role => 'admin' - - site.save - - site - end - - def install_template(site, options = {}) - default_template = Boolean.set(options.delete(:default_site_template)) || false - - zipfile = options.delete(:zipfile) - - # do not try to process anything if said so - return unless default_template || zipfile.present? - - # default template options has a higher priority than the zipfile - source = default_template ? Locomotive.default_site_template_path : zipfile - - begin - Locomotive::Import::Job.run!(source, site, { :samples => true }) - rescue Exception => e - Rails.logger.error "The import of the site template failed because of #{e.message}" - end - end - - end - end -end \ No newline at end of file diff --git a/app/models/extensions/site/subdomain_domains.rb b/app/models/extensions/site/subdomain_domains.rb deleted file mode 100644 index aefdc227..00000000 --- a/app/models/extensions/site/subdomain_domains.rb +++ /dev/null @@ -1,84 +0,0 @@ -module Extensions - module Site - module SubdomainDomains - - def enable_subdomain_n_domains_if_multi_sites - # puts "multi_sites? #{Locomotive.config.multi_sites?} / manage_domains? #{Locomotive.config.manage_domains?} / heroku? #{Locomotive.heroku?} / bushido? #{Locomotive.bushido?}" - - if Locomotive.config.multi_sites? || Locomotive.config.manage_domains? - - ## fields ## - field :subdomain - field :domains, :type => Array, :default => [] - - ## indexes - index :domains - - ## validations ## - validates_presence_of :subdomain - validates_uniqueness_of :subdomain - validates_exclusion_of :subdomain, :in => Locomotive.config.reserved_subdomains - validates_format_of :subdomain, :with => Locomotive::Regexps::SUBDOMAIN, :allow_blank => true - validate :domains_must_be_valid_and_unique - - ## callbacks ## - before_save :add_subdomain_to_domains - - ## named scopes ## - scope :match_domain, lambda { |domain| { :any_in => { :domains => [*domain] } } } - scope :match_domain_with_exclusion_of, lambda { |domain, site| - { :any_in => { :domains => [*domain] }, :where => { :_id.ne => site.id } } - } - - send :include, InstanceMethods - end - end - - module InstanceMethods - - def domains=(array) - array = [] if array.blank?; super(array) - end - - def add_subdomain_to_domains - self.domains ||= [] - (self.domains << self.full_subdomain).uniq! - end - - def domains_without_subdomain - (self.domains || []) - [self.full_subdomain_was] - [self.full_subdomain] - end - - def domains_with_subdomain - ((self.domains || []) + [self.full_subdomain]).uniq - end - - def full_subdomain - "#{self.subdomain}.#{Locomotive.config.domain}" - end - - def full_subdomain_was - "#{self.subdomain_was}.#{Locomotive.config.domain}" - end - - protected - - def domains_must_be_valid_and_unique - return if self.domains.empty? - - self.domains_without_subdomain.each do |domain| - if self.class.match_domain_with_exclusion_of(domain, self).any? - self.errors.add(:domains, :domain_taken, :value => domain) - end - - if not domain =~ Locomotive::Regexps::DOMAIN - self.errors.add(:domains, :invalid_domain, :value => domain) - end - end - end - - end - - end - end -end diff --git a/app/models/locomotive/ability.rb b/app/models/locomotive/ability.rb new file mode 100644 index 00000000..05a0f72e --- /dev/null +++ b/app/models/locomotive/ability.rb @@ -0,0 +1,85 @@ +Locomotive + class Ability + include CanCan::Ability + + ROLES = %w(admin designer author) + + def initialize(account, site) + @account, @site = account, site + + alias_action :index, :show, :edit, :update, :to => :touch + + @membership = @site.memberships.where(:account_id => @account.id).first + + return false if @membership.blank? + + if @membership.admin? + setup_admin_permissions! + else + setup_default_permissions! + + setup_designer_permissions! if @membership.designer? + + setup_author_permissions! if @membership.author? + end + end + + def setup_default_permissions! + cannot :manage, :all + end + + def setup_author_permissions! + can :touch, [Page, ThemeAsset] + can :sort, Page + + can :manage, [ContentInstance, Asset] + + can :touch, Site do |site| + site == @site + end + end + + def setup_designer_permissions! + can :manage, Page + + can :manage, ContentInstance + + can :manage, ContentType + + can :manage, Snippet + + can :manage, ThemeAsset + + can :manage, Asset + + can :manage, Site do |site| + site == @site + end + + can :import, Site + + can :export, Site + + can :point, Site + + cannot :create, Site + + can :manage, Membership + + cannot :grant_admin, Membership + + cannot [:update, :destroy], Membership do |membership| + @membership.account_id == membership.account_id || # can not edit myself + membership.admin? # can not modify an administrator + end + end + + def setup_admin_permissions! + can :manage, :all + + cannot [:update, :destroy], Membership do |membership| + @membership.account_id == membership.account_id # can not edit myself + end + end + end +end \ No newline at end of file diff --git a/app/models/locomotive/account.rb b/app/models/locomotive/account.rb new file mode 100644 index 00000000..cfcf025b --- /dev/null +++ b/app/models/locomotive/account.rb @@ -0,0 +1,62 @@ +require 'digest' + +module Locomotive + class Account + + include Locomotive::Mongoid::Document + + devise *Locomotive.config.devise_modules + + ## attributes ## + field :name + field :locale, :default => Locomotive.config.default_locale.to_s or 'en' + field :switch_site_token + + ## validations ## + validates_presence_of :name + + ## associations ## + + ## callbacks ## + before_destroy :remove_memberships! + + ## methods ## + + def sites + @sites ||= Site.where({ 'memberships.account_id' => self._id }) + end + + def reset_switch_site_token! + self.switch_site_token = ActiveSupport::SecureRandom.base64(8).gsub("/", "_").gsub(/=+$/, "") + self.save + end + + def self.find_using_switch_site_token(token, age = 1.minute) + return if token.blank? + self.where(:switch_site_token => token, :updated_at.gt => age.ago.utc).first + end + + def self.find_using_switch_site_token!(token, age = 1.minute) + self.find_using_switch_site_token(token, age) || raise(Mongoid::Errors::DocumentNotFound.new(self, token)) + end + + protected + + def password_required? + !persisted? || !password.blank? || !password_confirmation.blank? + end + + def remove_memberships! + self.sites.each do |site| + membership = site.memberships.where(:account_id => self._id).first + + if site.admin_memberships.size == 1 && membership.admin? + raise I18n.t('errors.messages.needs_admin_account') + else + membership.destroy + end + end + end + + end +end \ No newline at end of file diff --git a/app/models/locomotive/asset.rb b/app/models/locomotive/asset.rb new file mode 100644 index 00000000..4feb71aa --- /dev/null +++ b/app/models/locomotive/asset.rb @@ -0,0 +1,41 @@ +module Locomotive + class Asset + + include Mongoid::Document + include Mongoid::Timestamps + + ## extensions ## + include Extensions::Asset::Types + include Extensions::Asset::Vignette + + ## fields ## + field :content_type, :type => String + field :width, :type => Integer + field :height, :type => Integer + field :size, :type => Integer + field :position, :type => Integer, :default => 0 + mount_uploader :source, AssetUploader + + ## associations ## + referenced_in :site + + ## validations ## + validates_presence_of :source + + ## behaviours ## + + ## methods ## + + alias :name :source_filename + + def extname + return nil unless self.source? + File.extname(self.source_filename).gsub(/^\./, '') + end + + def to_liquid + { :url => self.source.url }.merge(self.attributes).stringify_keys + end + + end +end \ No newline at end of file diff --git a/app/models/locomotive/content_instance.rb b/app/models/locomotive/content_instance.rb new file mode 100644 index 00000000..46db6faa --- /dev/null +++ b/app/models/locomotive/content_instance.rb @@ -0,0 +1,127 @@ +module Locomotive + class ContentInstance + + include Mongoid::Document + include Mongoid::Timestamps + + ## extensions ## + include CustomFields::ProxyClassEnabler + include Extensions::Shared::Seo + + ## fields (dynamic fields) ## + field :_slug + field :_position_in_list, :type => Integer, :default => 0 + field :_visible, :type => Boolean, :default => true + + ## validations ## + validate :require_highlighted_field + validate :validate_uniqueness_of_slug + validates_presence_of :_slug + + ## associations ## + embedded_in :content_type, :inverse_of => :contents + + ## callbacks ## + before_validation :set_slug + before_save :set_visibility + before_create :add_to_list_bottom + after_create :send_notifications + + ## named scopes ## + scope :latest_updated, :order_by => :updated_at.desc, :limit => Locomotive.config.lastest_items_nb + + ## methods ## + + delegate :site, :to => :content_type + + alias :visible? :_visible? + alias :_permalink :_slug + alias :_permalink= :_slug= + + def site_id # needed by the uploader of custom fields + self.content_type.site_id + end + + def highlighted_field_value + self.send(self.content_type.highlighted_field_name) + end + + alias :_label :highlighted_field_value + + def visible? + self._visible || self._visible.nil? + end + + def next + content_type.contents.where(:_position_in_list => _position_in_list + 1).first() + end + + def previous + content_type.contents.where(:_position_in_list => _position_in_list - 1).first() + end + + def errors_to_hash + Hash.new.replace(self.errors) + end + + def reload_parent! + self.class.reload_parent! + end + + def self.reload_parent! + self._parent = self._parent.reload + end + + def to_liquid + Locomotive::Liquid::Drops::Content.new(self) + end + + protected + + def set_slug + self._slug = self.highlighted_field_value.dup if self._slug.blank? && self.highlighted_field_value.present? + self._slug.permalink! if self._slug.present? + end + + def set_visibility + field = self.content_type.content_custom_fields.detect { |f| %w{visible active}.include?(f._alias) } + self._visible = self.send(field._name) rescue true + end + + def add_to_list_bottom + self._position_in_list = self.content_type.contents.size + end + + def require_highlighted_field + _alias = self.highlighted_field_alias + if self.send(_alias).blank? + self.errors.add(_alias, :blank) + end + end + + def validate_uniqueness_of_slug + if self._parent.contents.any? { |c| c._id != self._id && c._slug == self._slug } + self.errors.add(:_slug, :taken) + end + end + + def highlighted_field_alias + self.content_type.highlighted_field._alias.to_sym + end + + def send_notifications + return unless self.content_type.api_enabled? && !self.content_type.api_accounts.blank? + + accounts = self.content_type.site.accounts.to_a + + self.content_type.api_accounts.each do |account_id| + next if account_id.blank? + + account = accounts.detect { |a| a.id.to_s == account_id.to_s } + + Locomotive::Notifications.new_content_instance(account, self).deliver + end + end + + end +end \ No newline at end of file diff --git a/app/models/locomotive/content_type.rb b/app/models/locomotive/content_type.rb new file mode 100644 index 00000000..efecc7dd --- /dev/null +++ b/app/models/locomotive/content_type.rb @@ -0,0 +1,147 @@ +module Locomotive + class ContentType + + include Locomotive::Mongoid::Document + + ## extensions ## + include Extensions::ContentType::ItemTemplate + + ## fields ## + field :name + field :description + field :slug + field :order_by + field :order_direction, :default => 'asc' + field :highlighted_field_name + field :group_by_field_name + field :api_enabled, :type => Boolean, :default => false + field :api_accounts, :type => Array + + ## associations ## + referenced_in :site + embeds_many :contents, :class_name => 'Locomotive::ContentInstance', :validate => false do + def visible + @target.find_all { |c| c.visible? } + end + end + + ## named scopes ## + scope :ordered, :order_by => :updated_at.desc + + ## indexes ## + index [[:site_id, Mongo::ASCENDING], [:slug, Mongo::ASCENDING]] + + ## callbacks ## + before_validation :normalize_slug + before_save :set_default_values + after_destroy :remove_uploaded_files + + ## validations ## + validates_presence_of :site, :name, :slug + validates_uniqueness_of :slug, :scope => :site_id + validates_size_of :content_custom_fields, :minimum => 1, :message => :array_too_short + + ## behaviours ## + custom_fields_for :contents + + ## methods ## + + def groupable? + self.group_by_field && group_by_field.category? + end + + def order_manually? + self.order_by == '_position_in_list' + end + + def asc_order? + self.order_direction.blank? || self.order_direction == 'asc' + end + + def list_or_group_contents + if self.groupable? + groups = self.contents.klass.send(:"group_by_#{self.group_by_field._alias}", :ordered_contents) + + # look for items with no category or unknown ones + items_without_category = self.contents.find_all { |c| !self.group_by_field.category_ids.include?(c.send(self.group_by_field_name)) } + if not items_without_category.empty? + groups << { :name => nil, :items => items_without_category } + else + groups + end + else + self.ordered_contents + end + end + + def latest_updated_contents + self.contents.latest_updated.reject { |c| !c.persisted? } + end + + def ordered_contents(conditions = {}) + column = self.order_by.to_sym + + list = (if conditions.nil? || conditions.empty? + self.contents + else + conditions_with_names = {} + + conditions.each do |key, value| + # convert alias (key) to name + field = self.content_custom_fields.detect { |f| f._alias == key } + + case field.kind.to_sym + when :category + if (category_item = field.category_items.where(:name => value).first).present? + conditions_with_names[field._name.to_sym] = category_item._id + end + else + conditions_with_names[field._name.to_sym] = value + end + end + + self.contents.where(conditions_with_names) + end).sort { |a, b| (a.send(column) || 0) <=> (b.send(column) || 0) } + + return list if self.order_manually? + + self.asc_order? ? list : list.reverse + end + + def sort_contents!(ids) + ids.each_with_index do |id, position| + self.contents.find(BSON::ObjectId(id))._position_in_list = position + end + self.save + end + + def highlighted_field + self.content_custom_fields.detect { |f| f._name == self.highlighted_field_name } + end + + def group_by_field + @group_by_field ||= self.content_custom_fields.detect { |f| f._name == self.group_by_field_name } + end + + protected + + def set_default_values + self.order_by ||= 'created_at' + self.highlighted_field_name ||= self.content_custom_fields.first._name + end + + def normalize_slug + self.slug = self.name.clone if self.slug.blank? && self.name.present? + self.slug.permalink! if self.slug.present? + end + + def remove_uploaded_files # callbacks are not called on each content so we do it manually + self.contents.each do |content| + self.content_custom_fields.each do |field| + content.send(:"remove_#{field._name}!") if field.kind == 'file' + end + end + end + + end +end \ No newline at end of file diff --git a/app/models/locomotive/editable_element.rb b/app/models/locomotive/editable_element.rb new file mode 100644 index 00000000..5a62b1a6 --- /dev/null +++ b/app/models/locomotive/editable_element.rb @@ -0,0 +1,29 @@ +module Locomotive + class EditableElement + + include Mongoid::Document + + ## fields ## + field :slug + field :block + field :default_content + field :default_attribute + field :hint + field :priority, :type => Integer, :default => 0 + field :disabled, :type => Boolean, :default => false + field :assignable, :type => Boolean, :default => true + field :from_parent, :type => Boolean, :default => false + + ## associations ## + embedded_in :page, :inverse_of => :editable_elements + + ## validations ## + validates_presence_of :slug + + ## scopes ## + scope :by_priority, :order_by => [[:priority, :desc]] + + ## methods ## + + end +end \ No newline at end of file diff --git a/app/models/locomotive/editable_file.rb b/app/models/locomotive/editable_file.rb new file mode 100644 index 00000000..a92a0e6c --- /dev/null +++ b/app/models/locomotive/editable_file.rb @@ -0,0 +1,11 @@ +module Locomotive + class EditableFile < EditableElement + + mount_uploader :source, EditableFileUploader + + def content + self.source? ? self.source.url : self.default_content + end + + end +end \ No newline at end of file diff --git a/app/models/locomotive/editable_long_text.rb b/app/models/locomotive/editable_long_text.rb new file mode 100644 index 00000000..93d0dac4 --- /dev/null +++ b/app/models/locomotive/editable_long_text.rb @@ -0,0 +1,5 @@ +module Locomotive + class EditableLongText < EditableShortText + + end +end \ No newline at end of file diff --git a/app/models/locomotive/editable_short_text.rb b/app/models/locomotive/editable_short_text.rb new file mode 100644 index 00000000..52e2d680 --- /dev/null +++ b/app/models/locomotive/editable_short_text.rb @@ -0,0 +1,14 @@ +module Locomotive + class EditableShortText < EditableElement + + ## fields ## + field :content + + ## methods ## + + def content + self.read_attribute(:content).blank? ? self.default_content : self.read_attribute(:content) + end + + end +end \ No newline at end of file diff --git a/app/models/locomotive/extensions/asset/types.rb b/app/models/locomotive/extensions/asset/types.rb new file mode 100644 index 00000000..1595374c --- /dev/null +++ b/app/models/locomotive/extensions/asset/types.rb @@ -0,0 +1,21 @@ +module Locomotive + module Extensions + module Asset + module Types + + extend ActiveSupport::Concern + + included do + %w{media image stylesheet javascript font pdf}.each do |type| + scope :"only_#{type}", where(:content_type => type) + + define_method("#{type}?") do + self.content_type.to_s == type + end + end + end + + end + end + end +end \ No newline at end of file diff --git a/app/models/locomotive/extensions/asset/vignette.rb b/app/models/locomotive/extensions/asset/vignette.rb new file mode 100644 index 00000000..e95870f3 --- /dev/null +++ b/app/models/locomotive/extensions/asset/vignette.rb @@ -0,0 +1,19 @@ +module Locomotive + module Extensions + module Asset + module Vignette + + def vignette_url + if self.image? + if self.width < 80 && self.height < 80 + self.source.url + else + Locomotive::Dragonfly.resize_url(self.source, '80x80#') + end + end + end + + end + end + end +end \ No newline at end of file diff --git a/app/models/locomotive/extensions/content_type/item_template.rb b/app/models/locomotive/extensions/content_type/item_template.rb new file mode 100644 index 00000000..336f7afe --- /dev/null +++ b/app/models/locomotive/extensions/content_type/item_template.rb @@ -0,0 +1,51 @@ +module Locomotive + module Extensions + module ContentType + module ItemTemplate + + extend ActiveSupport::Concern + + included do + field :raw_item_template + field :serialized_item_template, :type => Binary + + before_validation :serialize_item_template + + validate :item_template_must_be_valid + end + + module InstanceMethods + + def item_template + @item_template ||= Marshal.load(read_attribute(:serialized_item_template).to_s) rescue nil + end + + protected + + def serialize_item_template + if self.new_record? || self.raw_item_template_changed? + @item_parsing_errors = [] + + begin + self._parse_and_serialize_item_template + rescue ::Liquid::SyntaxError => error + @item_parsing_errors << I18n.t(:liquid_syntax, :error => error.to_s, :scope => [:errors, :messages]) + end + end + end + + def _parse_and_serialize_item_template + item_template = ::Liquid::Template.parse(self.raw_item_template, {}) + self.serialized_item_template = BSON::Binary.new(Marshal.dump(item_template)) + end + + def item_template_must_be_valid + @item_parsing_errors.try(:each) { |msg| self.errors.add :item_template, msg } + end + + end + + end + end + end +end \ No newline at end of file diff --git a/app/models/locomotive/extensions/page/editable_elements.rb b/app/models/locomotive/extensions/page/editable_elements.rb new file mode 100644 index 00000000..685fba84 --- /dev/null +++ b/app/models/locomotive/extensions/page/editable_elements.rb @@ -0,0 +1,120 @@ +module Locomotive + module Extensions + module Page + module EditableElements + + extend ActiveSupport::Concern + + included do + embeds_many :editable_elements + + after_save :remove_disabled_editable_elements + + # editable file callbacks + after_save :store_file_sources! + before_save :write_file_source_identifiers + after_destroy :remove_file_sources! + + accepts_nested_attributes_for :editable_elements + end + + module InstanceMethods + + def disable_parent_editable_elements(block) + self.editable_elements.each { |el| el.disabled = true if el.from_parent? && el.block == block } + end + + def disable_all_editable_elements + self.editable_elements.each { |el| el.disabled = true } + end + + def editable_element_blocks + self.editable_elements.collect(&:block) + end + + def editable_elements_grouped_by_blocks + all_enabled = self.editable_elements.by_priority.reject { |el| el.disabled? } + groups = all_enabled.group_by(&:block) + groups.delete_if { |block, elements| elements.empty? } + end + + def find_editable_element(block, slug) + self.editable_elements.detect { |el| el.block == block && el.slug == slug } + end + + def find_editable_files + self.editable_elements.find_all { |el| el.respond_to?(:source) } + end + + def add_or_update_editable_element(attributes, type) + element = self.find_editable_element(attributes[:block], attributes[:slug]) + + if element + element.attributes = attributes + else + self.editable_elements.build(attributes, type) + end + end + + def enable_editable_elements(block) + self.editable_elements.each { |el| el.disabled = false if el.block == block } + end + + def merge_editable_elements_from_page(source) + source.editable_elements.each do |el| + next if el.disabled? or !el.assignable? + + existing_el = self.find_editable_element(el.block, el.slug) + + if existing_el.nil? # new one from parents + new_attributes = el.attributes.merge(:from_parent => true) + + if new_attributes['default_attribute'].present? + new_attributes['default_content'] = self.send(new_attributes['default_attribute']) || el.content + else + if el.respond_to?(:content) # only for text + new_attributes['default_content'] = el.content + end + end + + self.editable_elements.build(new_attributes, el.class) + elsif existing_el.default_attribute.nil? + existing_el.attributes = { :disabled => false, :default_content => el.content } + else + existing_el.attributes = { :disabled => false } + end + end + end + + def remove_disabled_editable_elements + return unless self.editable_elements.any? { |el| el.disabled? } + + # super fast way to remove useless elements all in once (TODO callbacks) + self.collection.update(self._selector, '$pull' => { 'editable_elements' => { 'disabled' => true } }) + end + + protected + + ## callbacks for editable files + + # equivalent to "after_save :store_source!" in EditableFile + def store_file_sources! + self.find_editable_files.collect(&:store_source!) + end + + # equivalent to "before_save :write_source_identifier" in EditableFile + def write_file_source_identifiers + self.find_editable_files.collect(&:write_source_identifier) + end + + # equivalent to "after_destroy :remove_source!" in EditableFile + def remove_file_sources! + self.find_editable_files.collect(&:remove_source!) + end + + end + + end + end + end +end \ No newline at end of file diff --git a/app/models/locomotive/extensions/page/listed.rb b/app/models/locomotive/extensions/page/listed.rb new file mode 100644 index 00000000..3503e24b --- /dev/null +++ b/app/models/locomotive/extensions/page/listed.rb @@ -0,0 +1,17 @@ +module Locomotive + module Extensions + module Page + module Listed + + extend ActiveSupport::Concern + + included do + + field :listed, :type => Boolean, :default => true + + end + + end + end + end +end \ No newline at end of file diff --git a/app/models/locomotive/extensions/page/parse.rb b/app/models/locomotive/extensions/page/parse.rb new file mode 100644 index 00000000..c19cba83 --- /dev/null +++ b/app/models/locomotive/extensions/page/parse.rb @@ -0,0 +1,113 @@ +module Locomotive + module Extensions + module Page + module Parse + + extend ActiveSupport::Concern + + included do + field :serialized_template, :type => Binary + field :template_dependencies, :type => Array, :default => [] + field :snippet_dependencies, :type => Array, :default => [] + + attr_reader :template_changed + + before_validation :serialize_template + after_save :update_template_descendants + + validate :template_must_be_valid + + scope :pages, lambda { |domain| { :any_in => { :domains => [*domain] } } } + end + + module InstanceMethods + + def template + @template ||= Marshal.load(read_attribute(:serialized_template).to_s) rescue nil + end + + protected + + def serialize_template + if self.new_record? || self.raw_template_changed? + @template_changed = true + + @parsing_errors = [] + + begin + self._parse_and_serialize_template + rescue ::Liquid::SyntaxError => error + @parsing_errors << I18n.t(:liquid_syntax, :fullpath => self.fullpath, :error => error.to_s, :scope => [:errors, :messages, :page]) + rescue ::Locomotive::Liquid::PageNotFound => error + @parsing_errors << I18n.t(:liquid_extend, :fullpath => self.fullpath, :scope => [:errors, :messages, :page]) + end + end + end + + def _parse_and_serialize_template(context = {}) + self.parse(context) + self._serialize_template + end + + def _serialize_template + self.serialized_template = BSON::Binary.new(Marshal.dump(@template)) + end + + def parse(context = {}) + self.disable_all_editable_elements + + default_context = { :site => self.site, :page => self, :templates => [], :snippets => [] } + + context = default_context.merge(context) + + @template = ::Liquid::Template.parse(self.raw_template, context) + + self.template_dependencies = context[:templates] + self.snippet_dependencies = context[:snippets] + + @template.root.context.clear + end + + def template_must_be_valid + @parsing_errors.try(:each) { |msg| self.errors.add :template, msg } + end + + def update_template_descendants + return unless @template_changed == true + + # we admit at this point that the current template is up-to-date + template_descendants = self.site.pages.any_in(:template_dependencies => [self.id]).to_a + + # group them by fullpath for better performance + cached = template_descendants.inject({}) { |memo, page| memo[page.fullpath] = page; memo } + + self._update_direct_template_descendants(template_descendants.clone, cached) + + # finally save them all + ::Page.without_callback(:save, :after, :update_template_descendants) do + template_descendants.each do |page| + page.save(:validate => false) + end + end + end + + def _update_direct_template_descendants(template_descendants, cached) + direct_descendants = template_descendants.select do |page| + ((self.template_dependencies || []) + [self._id]) == (page.template_dependencies || []) + end + + direct_descendants.each do |page| + page.send(:_parse_and_serialize_template, { :cached_parent => self, :cached_pages => cached }) + + template_descendants.delete(page) # no need to loop over it next time + + page.send(:_update_direct_template_descendants, template_descendants, cached) # move down + end + end + + end + + end + end + end +end \ No newline at end of file diff --git a/app/models/locomotive/extensions/page/redirect.rb b/app/models/locomotive/extensions/page/redirect.rb new file mode 100644 index 00000000..3ca00b08 --- /dev/null +++ b/app/models/locomotive/extensions/page/redirect.rb @@ -0,0 +1,23 @@ +module Locomotive + module Extensions + module Page + module Redirect + + extend ActiveSupport::Concern + + included do + + field :redirect, :type => Boolean, :default => false + + field :redirect_url, :type => String + + validates_presence_of :redirect_url, :if => :redirect + + validates_format_of :redirect_url, :with => Locomotive::Regexps::URL, :allow_blank => true + + end + + end + end + end +end \ No newline at end of file diff --git a/app/models/locomotive/extensions/page/render.rb b/app/models/locomotive/extensions/page/render.rb new file mode 100644 index 00000000..e7d601bd --- /dev/null +++ b/app/models/locomotive/extensions/page/render.rb @@ -0,0 +1,13 @@ +module Locomotive + module Extensions + module Page + module Render + + def render(context) + self.template.render(context) + end + + end + end + end +end \ No newline at end of file diff --git a/app/models/locomotive/extensions/page/templatized.rb b/app/models/locomotive/extensions/page/templatized.rb new file mode 100644 index 00000000..10d7c5fb --- /dev/null +++ b/app/models/locomotive/extensions/page/templatized.rb @@ -0,0 +1,30 @@ +module Locomotive + module Extensions + module Page + module Templatized + + extend ActiveSupport::Concern + + included do + + referenced_in :content_type + + field :templatized, :type => Boolean, :default => false + + field :content_type_visible_column + + before_validation :set_slug_if_templatized + end + + module InstanceMethods + + def set_slug_if_templatized + self.slug = 'content_type_template' if self.templatized? + end + + end + + end + end + end +end \ No newline at end of file diff --git a/app/models/locomotive/extensions/page/tree.rb b/app/models/locomotive/extensions/page/tree.rb new file mode 100644 index 00000000..2392c4a9 --- /dev/null +++ b/app/models/locomotive/extensions/page/tree.rb @@ -0,0 +1,160 @@ +module Locomotive + module Extensions + module Page + module Tree + + extend ActiveSupport::Concern + + included do + include ::Mongoid::Acts::Tree + + ## fields ## + field :position, :type => Integer + + ## indexes ## + index :position + index [[:depth, :asc], [:position, :asc]] + + ## behaviours ## + acts_as_tree :order => ['position', 'asc'] + + ## callbacks ## + before_validation :reset_parent + before_save { |p| p.send(:write_attribute, :parent_id, nil) if p.parent_id.blank? } + before_save :change_parent + before_create { |p| p.send(:fix_position, false) } + before_create :add_to_list_bottom + before_destroy :remove_from_list + + # Fixme (Didier L.): Instances methods are defined before the include itself + alias :fix_position :hacked_fix_position + alias :descendants :hacked_descendants + end + + module ClassMethods + + # Warning: should be used only in read-only + def quick_tree(site, minimal_attributes = true) + pages = (minimal_attributes ? site.pages.minimal_attributes : site.pages).order_by([[:depth, :asc], [:position, :asc]]).to_a + + tmp = [] + + while !pages.empty? + tmp << _quick_tree(pages.delete_at(0), pages) + end + + tmp + end + + def _quick_tree(current_page, pages) + i, children = 0, [] + + while !pages.empty? + page = pages[i] + + break if page.nil? + + if page.parent_id == current_page.id + page = pages.delete_at(i) + + children << _quick_tree(page, pages) + else + i += 1 + end + end + + current_page.instance_eval do + def children=(list); @children = list; end + def children; @children || []; end + end + + current_page.children = children + + current_page + end + + end + + module InstanceMethods + + def children? + self.class.where(self.parent_id_field => self.id).count + end + + def children_with_minimal_attributes + self.class.where(self.parent_id_field => self.id). + order_by(self.tree_order). + minimal_attributes + end + + def sort_children!(ids) + ids.each_with_index do |id, position| + child = self.children.detect { |p| p._id == BSON::ObjectId(id) } + child.position = position + child.save + end + end + + def parent=(owner) # missing in acts_as_tree + @_parent = owner + self.fix_position(false) + self.instance_variable_set :@_will_move, true + end + + def hacked_descendants + return [] if new_record? + self.class.all_in(path_field => [self._id]).order_by tree_order + end + + protected + + def change_parent + if self.parent_id_changed? + self.fix_position(false) + + unless self.parent_id_was.nil? + self.position = nil # make it move to bottom + self.add_to_list_bottom + end + + self.instance_variable_set :@_will_move, true + end + end + + def hacked_fix_position(perform_save = true) + if parent.nil? + self.write_attribute parent_id_field, nil + self[path_field] = [] + self[depth_field] = 0 + else + self.write_attribute parent_id_field, parent._id + self[path_field] = parent[path_field] + [parent._id] + self[depth_field] = parent[depth_field] + 1 + self.save if perform_save + end + end + + def reset_parent + if self.parent_id_changed? + @_parent = nil + end + end + + def add_to_list_bottom + self.position ||= (::Page.where(:_id.ne => self._id).and(:parent_id => self.parent_id).max(:position) || 0) + 1 + end + + def remove_from_list + return if (self.site rescue nil).nil? + + ::Page.where(:parent_id => self.parent_id).and(:position.gt => self.position).each do |p| + p.position -= 1 + p.save + end + end + + end + end + end + end +end \ No newline at end of file diff --git a/app/models/locomotive/extensions/shared/seo.rb b/app/models/locomotive/extensions/shared/seo.rb new file mode 100644 index 00000000..88414bc3 --- /dev/null +++ b/app/models/locomotive/extensions/shared/seo.rb @@ -0,0 +1,16 @@ +module Locomotive + module Extensions + module Shared + module Seo + extend ActiveSupport::Concern + + included do + field :seo_title, :type => String + field :meta_keywords, :type => String + field :meta_description, :type => String + end + + end # Seo + end # Shared + end # Extensions +end # Locomotive \ No newline at end of file diff --git a/app/models/locomotive/extensions/site/first_installation.rb b/app/models/locomotive/extensions/site/first_installation.rb new file mode 100644 index 00000000..9acdb13d --- /dev/null +++ b/app/models/locomotive/extensions/site/first_installation.rb @@ -0,0 +1,38 @@ +module Locomotive + module Extensions + module Site + module FirstInstallation + + # only called during the installation workflow, just after the admin account has been created + def create_first_one(attributes) + site = self.new(attributes) + + site.memberships.build :account => Account.first, :role => 'admin' + + site.save + + site + end + + def install_template(site, options = {}) + default_template = Boolean.set(options.delete(:default_site_template)) || false + + zipfile = options.delete(:zipfile) + + # do not try to process anything if said so + return unless default_template || zipfile.present? + + # default template options has a higher priority than the zipfile + source = default_template ? Locomotive.default_site_template_path : zipfile + + begin + Locomotive::Import::Job.run!(source, site, { :samples => true }) + rescue Exception => e + Rails.logger.error "The import of the site template failed because of #{e.message}" + end + end + + end + end + end +end \ No newline at end of file diff --git a/app/models/locomotive/extensions/site/subdomain_domains.rb b/app/models/locomotive/extensions/site/subdomain_domains.rb new file mode 100644 index 00000000..aa3d9d76 --- /dev/null +++ b/app/models/locomotive/extensions/site/subdomain_domains.rb @@ -0,0 +1,86 @@ +module Locomotive + module Extensions + module Site + module SubdomainDomains + + def enable_subdomain_n_domains_if_multi_sites + # puts "multi_sites? #{Locomotive.config.multi_sites?} / manage_domains? #{Locomotive.config.manage_domains?} / heroku? #{Locomotive.heroku?} / bushido? #{Locomotive.bushido?}" + + if Locomotive.config.multi_sites? || Locomotive.config.manage_domains? + + ## fields ## + field :subdomain + field :domains, :type => Array, :default => [] + + ## indexes + index :domains + + ## validations ## + validates_presence_of :subdomain + validates_uniqueness_of :subdomain + validates_exclusion_of :subdomain, :in => Locomotive.config.reserved_subdomains + validates_format_of :subdomain, :with => Locomotive::Regexps::SUBDOMAIN, :allow_blank => true + validate :domains_must_be_valid_and_unique + + ## callbacks ## + before_save :add_subdomain_to_domains + + ## named scopes ## + scope :match_domain, lambda { |domain| { :any_in => { :domains => [*domain] } } } + scope :match_domain_with_exclusion_of, lambda { |domain, site| + { :any_in => { :domains => [*domain] }, :where => { :_id.ne => site.id } } + } + + send :include, InstanceMethods + end + end + + module InstanceMethods + + def domains=(array) + array = [] if array.blank?; super(array) + end + + def add_subdomain_to_domains + self.domains ||= [] + (self.domains << self.full_subdomain).uniq! + end + + def domains_without_subdomain + (self.domains || []) - [self.full_subdomain_was] - [self.full_subdomain] + end + + def domains_with_subdomain + ((self.domains || []) + [self.full_subdomain]).uniq + end + + def full_subdomain + "#{self.subdomain}.#{Locomotive.config.domain}" + end + + def full_subdomain_was + "#{self.subdomain_was}.#{Locomotive.config.domain}" + end + + protected + + def domains_must_be_valid_and_unique + return if self.domains.empty? + + self.domains_without_subdomain.each do |domain| + if self.class.match_domain_with_exclusion_of(domain, self).any? + self.errors.add(:domains, :domain_taken, :value => domain) + end + + if not domain =~ Locomotive::Regexps::DOMAIN + self.errors.add(:domains, :invalid_domain, :value => domain) + end + end + end + + end + + end + end + end +end \ No newline at end of file diff --git a/app/models/locomotive/membership.rb b/app/models/locomotive/membership.rb new file mode 100644 index 00000000..cc3ad48a --- /dev/null +++ b/app/models/locomotive/membership.rb @@ -0,0 +1,75 @@ +module Locomotive + class Membership + + include Locomotive::Mongoid::Document + + ## fields ## + field :role, :default => 'author' + + ## associations ## + referenced_in :account, :validate => false + embedded_in :site, :inverse_of => :memberships + + ## validations ## + validates_presence_of :account + validate :can_change_role, :if => :role_changed? + + ## callbacks ## + before_save :define_role + + ## methods ## + + Ability::ROLES.each do |_role| + define_method("#{_role}?") do + self.role == _role + end + end + + def email; @email; end + + def email=(email) + @email = email + self.account = Account.where(:email => email).first + end + + def process! + if @email.blank? + self.errors.add_on_blank(:email) + :error + elsif self.account.blank? + :create_account + elsif self.site.memberships.any? { |m| m.account_id == self.account_id && m._id != self._id } + self.errors.add(:base, 'Already created') + :already_created + else + self.save + :save_it + end + end + + def ability + @ability ||= Ability.new(self.account, self.site) + end + + protected + + def define_role + self.role = Ability::ROLES.include?(role.downcase) ? role.downcase : Ability::ROLES.first + end + + # Users should not be able to set the role of another user to be higher than + # their own. A designer for example should not be able to set another user to + # be an administrator + def can_change_role + current_site = Thread.current[:site] + current_membership = current_site.memberships.where(:account_id => Thread.current[:account].id).first if current_site.present? + + if current_membership.present? + # The role cannot be set higher than the current one (we use the index in + # the roles array to check role presidence) + errors.add(:role, :invalid) if Ability::ROLES.index(role) < Ability::ROLES.index(current_membership.role) + end + end + + end +end \ No newline at end of file diff --git a/app/models/locomotive/page.rb b/app/models/locomotive/page.rb new file mode 100644 index 00000000..03549128 --- /dev/null +++ b/app/models/locomotive/page.rb @@ -0,0 +1,109 @@ +module Locomotive + class Page + + include Locomotive::Mongoid::Document + + ## Extensions ## + include Extensions::Page::Tree + include Extensions::Page::EditableElements + include Extensions::Page::Parse + include Extensions::Page::Render + include Extensions::Page::Templatized + include Extensions::Page::Redirect + include Extensions::Page::Listed + include Extensions::Shared::Seo + + ## fields ## + field :title + field :slug + field :fullpath + field :raw_template + field :published, :type => Boolean, :default => false + field :cache_strategy, :default => 'none' + + ## associations ## + referenced_in :site + + ## indexes ## + index :site_id + index :parent_id + index [[:fullpath, Mongo::ASCENDING], [:site_id, Mongo::ASCENDING]] + + ## callbacks ## + after_initialize :set_default_raw_template + before_validation :normalize_slug + before_save { |p| p.fullpath = p.fullpath(true) } + before_destroy :do_not_remove_index_and_404_pages + + ## validations ## + validates_presence_of :site, :title, :slug + validates_uniqueness_of :slug, :scope => [:site_id, :parent_id] + validates_exclusion_of :slug, :in => Locomotive.config.reserved_slugs, :if => Proc.new { |p| p.depth == 0 } + + ## named scopes ## + scope :latest_updated, :order_by => [[:updated_at, :desc]], :limit => Locomotive.config.lastest_items_nb + scope :root, :where => { :slug => 'index', :depth => 0 } + scope :not_found, :where => { :slug => '404', :depth => 0 } + scope :published, :where => { :published => true } + scope :fullpath, lambda { |fullpath| { :where => { :fullpath => fullpath } } } + scope :minimal_attributes, :only => %w(title slug fullpath position depth published templatized redirect listed parent_id created_at updated_at) + + ## methods ## + + def index? + self.slug == 'index' && self.depth.to_i == 0 + end + + def not_found? + self.slug == '404' && self.depth.to_i == 0 + end + + def index_or_not_found? + self.index? || self.not_found? + end + + def fullpath(force = false) + if read_attribute(:fullpath).present? && !force + return read_attribute(:fullpath) + end + + if self.index? || self.not_found? + self.slug + else + slugs = self.self_and_ancestors.sort_by(&:depth).map(&:slug) + slugs.shift unless slugs.size == 1 + File.join slugs + end + end + + def with_cache? + self.cache_strategy != 'none' + end + + def to_liquid + Locomotive::Liquid::Drops::Page.new(self) + end + + protected + + def do_not_remove_index_and_404_pages + return if self.site.nil? || self.site.destroyed? + + if self.index? || self.not_found? + self.errors[:base] << I18n.t('errors.messages.protected_page') + end + + self.errors.empty? + end + + def normalize_slug + self.slug = self.title.clone if self.slug.blank? && self.title.present? + self.slug.permalink! if self.slug.present? + end + + def set_default_raw_template + self.raw_template ||= I18n.t('attributes.defaults.pages.other.body') + end + + end +end \ No newline at end of file diff --git a/app/models/locomotive/site.rb b/app/models/locomotive/site.rb new file mode 100644 index 00000000..5101ec4b --- /dev/null +++ b/app/models/locomotive/site.rb @@ -0,0 +1,71 @@ +module Locomotive + class Site + + include Locomotive::Mongoid::Document + + ## Extensions ## + extend Extensions::Site::SubdomainDomains + extend Extensions::Site::FirstInstallation + include Extensions::Shared::Seo + + ## fields ## + field :name + field :robots_txt + + ## associations ## + references_many :pages, :validate => false + references_many :snippets, :dependent => :destroy, :validate => false + references_many :theme_assets, :dependent => :destroy, :validate => false + references_many :assets, :dependent => :destroy, :validate => false + references_many :content_types, :dependent => :destroy, :validate => false + embeds_many :memberships + + ## validations ## + validates_presence_of :name + + ## callbacks ## + after_create :create_default_pages! + after_destroy :destroy_pages + + ## behaviours ## + enable_subdomain_n_domains_if_multi_sites + accepts_nested_attributes_for :memberships + + ## methods ## + + def all_pages_in_once + Page.quick_tree(self) + end + + def accounts + Account.criteria.in(:_id => self.memberships.collect(&:account_id)) + end + + def admin_memberships + self.memberships.find_all { |m| m.admin? } + end + + def to_liquid + Locomotive::Liquid::Drops::Site.new(self) + end + + protected + + def create_default_pages! + %w{index 404}.each do |slug| + self.pages.create({ + :slug => slug, + :title => I18n.t("attributes.defaults.pages.#{slug}.title"), + :raw_template => I18n.t("attributes.defaults.pages.#{slug}.body"), + :published => true + }) + end + end + + def destroy_pages + # pages is a tree so we just need to delete the root (as well as the page not found page) + self.pages.root.first.try(:destroy) && self.pages.not_found.first.try(:destroy) + end + + end +end \ No newline at end of file diff --git a/app/models/locomotive/snippet.rb b/app/models/locomotive/snippet.rb new file mode 100644 index 00000000..2b44b470 --- /dev/null +++ b/app/models/locomotive/snippet.rb @@ -0,0 +1,65 @@ +module + class Snippet + + include Locomotive::Mongoid::Document + + ## fields ## + field :name + field :slug + field :template + + ## associations ## + referenced_in :site + + ## callbacks ## + before_validation :normalize_slug + after_save :update_templates + after_destroy :update_templates + + ## validations ## + validates_presence_of :site, :name, :slug, :template + validates_uniqueness_of :slug, :scope => :site_id + + ## methods ## + + protected + + def normalize_slug + # TODO: refactor it + self.slug = self.name.clone if self.slug.blank? && self.name.present? + self.slug.permalink! if self.slug.present? + end + + def update_templates + return unless (self.site rescue false) # not run if the site is being destroyed + + pages = self.site.pages.any_in(:snippet_dependencies => [self.slug]).to_a + + pages.each do |page| + self._change_snippet_inside_template(page.template.root) + + page.send(:_serialize_template) + + Page.without_callback(:save, :after, :update_template_descendants) do + page.save(:validate => false) + end + end + end + + def _change_snippet_inside_template(node) + case node + when Locomotive::Liquid::Tags::Snippet + node.refresh(self) if node.slug == self.slug + when Locomotive::Liquid::Tags::InheritedBlock + _change_snippet_inside_template(node.parent) if node.parent + end + # Walk the children of this entry if they're available. + if node.respond_to?(:nodelist) + (node.nodelist || []).each do |child| + self._change_snippet_inside_template(child) + end + end + end + + end +end \ No newline at end of file diff --git a/app/models/locomotive/theme_asset.rb b/app/models/locomotive/theme_asset.rb new file mode 100644 index 00000000..2e67db68 --- /dev/null +++ b/app/models/locomotive/theme_asset.rb @@ -0,0 +1,154 @@ +module Locomotive + class ThemeAsset + + include Locomotive::Mongoid::Document + + ## extensions ## + include Extensions::Asset::Types + + ## fields ## + field :local_path + field :content_type + field :width, :type => Integer + field :height, :type => Integer + field :size, :type => Integer + field :folder, :default => nil + mount_uploader :source, ThemeAssetUploader + + ## associations ## + referenced_in :site + + ## indexes ## + index :site_id + index [[:site_id, Mongo::ASCENDING], [:local_path, Mongo::ASCENDING]] + + ## callbacks ## + before_validation :store_plain_text + before_validation :sanitize_folder + before_validation :build_local_path + + ## validations ## + validates_presence_of :site, :source + validates_presence_of :plain_text_name, :if => Proc.new { |a| a.performing_plain_text? } + validates_uniqueness_of :local_path, :scope => :site_id + validates_integrity_of :source + validate :content_type_can_not_changed + + ## named scopes ## + + ## accessors ## + attr_accessor :plain_text_name, :plain_text, :plain_text_type, :performing_plain_text + + ## methods ## + + def stylesheet_or_javascript? + self.stylesheet? || self.javascript? + end + + def local_path(short = false) + if short + self.read_attribute(:local_path).gsub(/^#{self.content_type.to_s.pluralize}\//, '') + else + self.read_attribute(:local_path) + end + end + + def plain_text_name + if not @plain_text_name_changed + @plain_text_name ||= self.safe_source_filename + end + @plain_text_name.gsub(/(\.[a-z0-9A-Z]+)$/, '') rescue nil + end + + def plain_text_name=(name) + @plain_text_name_changed = true + @plain_text_name = name + end + + def plain_text + if RUBY_VERSION =~ /1\.9/ + @plain_text ||= (self.source.read.force_encoding('UTF-8') rescue nil) + else + @plain_text ||= self.source.read + end + end + + def plain_text_type + @plain_text_type || (stylesheet_or_javascript? ? self.content_type : nil) + end + + def performing_plain_text? + Boolean.set(self.performing_plain_text) || false + end + + def store_plain_text + self.content_type ||= @plain_text_type if self.performing_plain_text? + + data = self.performing_plain_text? ? self.plain_text : self.source.read + + return if !self.stylesheet_or_javascript? || self.plain_text_name.blank? || data.blank? + + sanitized_source = self.escape_shortcut_urls(data) + + self.source = CarrierWave::SanitizedFile.new({ + :tempfile => StringIO.new(sanitized_source), + :filename => "#{self.plain_text_name}.#{self.stylesheet? ? 'css' : 'js'}" + }) + end + + def to_liquid + { :url => self.source.url }.merge(self.attributes).stringify_keys + end + + def self.all_grouped_by_folder(site) + assets = site.theme_assets.order_by([[:slug, :asc]]) + assets.group_by { |a| a.folder.split('/').first.to_sym } + end + + protected + + def safe_source_filename + self.source_filename || self.source.send(:original_filename) rescue nil + end + + def sanitize_folder + self.folder = self.content_type.to_s.pluralize if self.folder.blank? + + # no accents, no spaces, no leading and ending trails + self.folder = ActiveSupport::Inflector.transliterate(self.folder).gsub(/(\s)+/, '_').gsub(/^\//, '').gsub(/\/$/, '') + + # folder should begin by a root folder + if (self.folder =~ /^(stylesheets|javascripts|images|medias|fonts)/).nil? + self.folder = File.join(self.content_type.to_s.pluralize, self.folder) + end + end + + def build_local_path + if filename = self.safe_source_filename + self.local_path = File.join(self.folder, filename) + else + nil + end + end + + def escape_shortcut_urls(text) + return if text.blank? + + text.gsub(/[("'](\/(stylesheets|javascripts|images|medias)\/(([^;.]+)\/)*([a-z_\-0-9]+)\.[a-z]{2,3})[)"']/) do |path| + + sanitized_path = path.gsub(/[("')]/, '').gsub(/^\//, '') + + if asset = self.site.theme_assets.where(:local_path => sanitized_path).first + "#{path.first}#{asset.source.url}#{path.last}" + else + path + end + end + end + + def content_type_can_not_changed + self.errors.add(:source, :extname_changed) if !self.new_record? && self.content_type_changed? + end + + end +end \ No newline at end of file diff --git a/app/models/membership.rb b/app/models/membership.rb deleted file mode 100644 index 208e7feb..00000000 --- a/app/models/membership.rb +++ /dev/null @@ -1,73 +0,0 @@ -class Membership - - include Locomotive::Mongoid::Document - - ## fields ## - field :role, :default => 'author' - - ## associations ## - referenced_in :account, :validate => false - embedded_in :site, :inverse_of => :memberships - - ## validations ## - validates_presence_of :account - validate :can_change_role, :if => :role_changed? - - ## callbacks ## - before_save :define_role - - ## methods ## - - Ability::ROLES.each do |_role| - define_method("#{_role}?") do - self.role == _role - end - end - - def email; @email; end - - def email=(email) - @email = email - self.account = Account.where(:email => email).first - end - - def process! - if @email.blank? - self.errors.add_on_blank(:email) - :error - elsif self.account.blank? - :create_account - elsif self.site.memberships.any? { |m| m.account_id == self.account_id && m._id != self._id } - self.errors.add(:base, 'Already created') - :already_created - else - self.save - :save_it - end - end - - def ability - @ability ||= Ability.new(self.account, self.site) - end - - protected - - def define_role - self.role = Ability::ROLES.include?(role.downcase) ? role.downcase : Ability::ROLES.first - end - - # Users should not be able to set the role of another user to be higher than - # their own. A designer for example should not be able to set another user to - # be an administrator - def can_change_role - current_site = Thread.current[:site] - current_membership = current_site.memberships.where(:account_id => Thread.current[:admin].id).first if current_site.present? - - if current_membership.present? - # The role cannot be set higher than the current one (we use the index in - # the roles array to check role presidence) - errors.add(:role, :invalid) if Ability::ROLES.index(role) < Ability::ROLES.index(current_membership.role) - end - end - -end diff --git a/app/models/page.rb b/app/models/page.rb deleted file mode 100644 index 733e3358..00000000 --- a/app/models/page.rb +++ /dev/null @@ -1,107 +0,0 @@ -class Page - - include Locomotive::Mongoid::Document - - ## Extensions ## - include Extensions::Page::Tree - include Extensions::Page::EditableElements - include Extensions::Page::Parse - include Extensions::Page::Render - include Extensions::Page::Templatized - include Extensions::Page::Redirect - include Extensions::Page::Listed - include Extensions::Shared::Seo - - ## fields ## - field :title - field :slug - field :fullpath - field :raw_template - field :published, :type => Boolean, :default => false - field :cache_strategy, :default => 'none' - - ## associations ## - referenced_in :site - - ## indexes ## - index :site_id - index :parent_id - index [[:fullpath, Mongo::ASCENDING], [:site_id, Mongo::ASCENDING]] - - ## callbacks ## - after_initialize :set_default_raw_template - before_validation :normalize_slug - before_save { |p| p.fullpath = p.fullpath(true) } - before_destroy :do_not_remove_index_and_404_pages - - ## validations ## - validates_presence_of :site, :title, :slug - validates_uniqueness_of :slug, :scope => [:site_id, :parent_id] - validates_exclusion_of :slug, :in => Locomotive.config.reserved_slugs, :if => Proc.new { |p| p.depth == 0 } - - ## named scopes ## - scope :latest_updated, :order_by => [[:updated_at, :desc]], :limit => Locomotive.config.lastest_items_nb - scope :root, :where => { :slug => 'index', :depth => 0 } - scope :not_found, :where => { :slug => '404', :depth => 0 } - scope :published, :where => { :published => true } - scope :fullpath, lambda { |fullpath| { :where => { :fullpath => fullpath } } } - scope :minimal_attributes, :only => %w(title slug fullpath position depth published templatized redirect listed parent_id created_at updated_at) - - ## methods ## - - def index? - self.slug == 'index' && self.depth.to_i == 0 - end - - def not_found? - self.slug == '404' && self.depth.to_i == 0 - end - - def index_or_not_found? - self.index? || self.not_found? - end - - def fullpath(force = false) - if read_attribute(:fullpath).present? && !force - return read_attribute(:fullpath) - end - - if self.index? || self.not_found? - self.slug - else - slugs = self.self_and_ancestors.sort_by(&:depth).map(&:slug) - slugs.shift unless slugs.size == 1 - File.join slugs - end - end - - def with_cache? - self.cache_strategy != 'none' - end - - def to_liquid - Locomotive::Liquid::Drops::Page.new(self) - end - - protected - - def do_not_remove_index_and_404_pages - return if self.site.nil? || self.site.destroyed? - - if self.index? || self.not_found? - self.errors[:base] << I18n.t('errors.messages.protected_page') - end - - self.errors.empty? - end - - def normalize_slug - self.slug = self.title.clone if self.slug.blank? && self.title.present? - self.slug.permalink! if self.slug.present? - end - - def set_default_raw_template - self.raw_template ||= I18n.t('attributes.defaults.pages.other.body') - end - -end diff --git a/app/models/site.rb b/app/models/site.rb deleted file mode 100644 index 6609aa25..00000000 --- a/app/models/site.rb +++ /dev/null @@ -1,69 +0,0 @@ -class Site - - include Locomotive::Mongoid::Document - - ## Extensions ## - extend Extensions::Site::SubdomainDomains - extend Extensions::Site::FirstInstallation - include Extensions::Shared::Seo - - ## fields ## - field :name - field :robots_txt - - ## associations ## - references_many :pages, :validate => false - references_many :snippets, :dependent => :destroy, :validate => false - references_many :theme_assets, :dependent => :destroy, :validate => false - references_many :assets, :dependent => :destroy, :validate => false - references_many :content_types, :dependent => :destroy, :validate => false - embeds_many :memberships - - ## validations ## - validates_presence_of :name - - ## callbacks ## - after_create :create_default_pages! - after_destroy :destroy_pages - - ## behaviours ## - enable_subdomain_n_domains_if_multi_sites - accepts_nested_attributes_for :memberships - - ## methods ## - - def all_pages_in_once - Page.quick_tree(self) - end - - def accounts - Account.criteria.in(:_id => self.memberships.collect(&:account_id)) - end - - def admin_memberships - self.memberships.find_all { |m| m.admin? } - end - - def to_liquid - Locomotive::Liquid::Drops::Site.new(self) - end - - protected - - def create_default_pages! - %w{index 404}.each do |slug| - self.pages.create({ - :slug => slug, - :title => I18n.t("attributes.defaults.pages.#{slug}.title"), - :raw_template => I18n.t("attributes.defaults.pages.#{slug}.body"), - :published => true - }) - end - end - - def destroy_pages - # pages is a tree so we just need to delete the root (as well as the page not found page) - self.pages.root.first.try(:destroy) && self.pages.not_found.first.try(:destroy) - end - -end diff --git a/app/models/snippet.rb b/app/models/snippet.rb deleted file mode 100644 index 0767bae0..00000000 --- a/app/models/snippet.rb +++ /dev/null @@ -1,63 +0,0 @@ -class Snippet - - include Locomotive::Mongoid::Document - - ## fields ## - field :name - field :slug - field :template - - ## associations ## - referenced_in :site - - ## callbacks ## - before_validation :normalize_slug - after_save :update_templates - after_destroy :update_templates - - ## validations ## - validates_presence_of :site, :name, :slug, :template - validates_uniqueness_of :slug, :scope => :site_id - - ## methods ## - - protected - - def normalize_slug - # TODO: refactor it - self.slug = self.name.clone if self.slug.blank? && self.name.present? - self.slug.permalink! if self.slug.present? - end - - def update_templates - return unless (self.site rescue false) # not run if the site is being destroyed - - pages = self.site.pages.any_in(:snippet_dependencies => [self.slug]).to_a - - pages.each do |page| - self._change_snippet_inside_template(page.template.root) - - page.send(:_serialize_template) - - Page.without_callback(:save, :after, :update_template_descendants) do - page.save(:validate => false) - end - end - end - - def _change_snippet_inside_template(node) - case node - when Locomotive::Liquid::Tags::Snippet - node.refresh(self) if node.slug == self.slug - when Locomotive::Liquid::Tags::InheritedBlock - _change_snippet_inside_template(node.parent) if node.parent - end - # Walk the children of this entry if they're available. - if node.respond_to?(:nodelist) - (node.nodelist || []).each do |child| - self._change_snippet_inside_template(child) - end - end - end - -end diff --git a/app/models/theme_asset.rb b/app/models/theme_asset.rb deleted file mode 100644 index d64135b5..00000000 --- a/app/models/theme_asset.rb +++ /dev/null @@ -1,152 +0,0 @@ -class ThemeAsset - - include Locomotive::Mongoid::Document - - ## extensions ## - include Extensions::Asset::Types - - ## fields ## - field :local_path - field :content_type - field :width, :type => Integer - field :height, :type => Integer - field :size, :type => Integer - field :folder, :default => nil - mount_uploader :source, ThemeAssetUploader - - ## associations ## - referenced_in :site - - ## indexes ## - index :site_id - index [[:site_id, Mongo::ASCENDING], [:local_path, Mongo::ASCENDING]] - - ## callbacks ## - before_validation :store_plain_text - before_validation :sanitize_folder - before_validation :build_local_path - - ## validations ## - validates_presence_of :site, :source - validates_presence_of :plain_text_name, :if => Proc.new { |a| a.performing_plain_text? } - validates_uniqueness_of :local_path, :scope => :site_id - validates_integrity_of :source - validate :content_type_can_not_changed - - ## named scopes ## - - ## accessors ## - attr_accessor :plain_text_name, :plain_text, :plain_text_type, :performing_plain_text - - ## methods ## - - def stylesheet_or_javascript? - self.stylesheet? || self.javascript? - end - - def local_path(short = false) - if short - self.read_attribute(:local_path).gsub(/^#{self.content_type.to_s.pluralize}\//, '') - else - self.read_attribute(:local_path) - end - end - - def plain_text_name - if not @plain_text_name_changed - @plain_text_name ||= self.safe_source_filename - end - @plain_text_name.gsub(/(\.[a-z0-9A-Z]+)$/, '') rescue nil - end - - def plain_text_name=(name) - @plain_text_name_changed = true - @plain_text_name = name - end - - def plain_text - if RUBY_VERSION =~ /1\.9/ - @plain_text ||= (self.source.read.force_encoding('UTF-8') rescue nil) - else - @plain_text ||= self.source.read - end - end - - def plain_text_type - @plain_text_type || (stylesheet_or_javascript? ? self.content_type : nil) - end - - def performing_plain_text? - Boolean.set(self.performing_plain_text) || false - end - - def store_plain_text - self.content_type ||= @plain_text_type if self.performing_plain_text? - - data = self.performing_plain_text? ? self.plain_text : self.source.read - - return if !self.stylesheet_or_javascript? || self.plain_text_name.blank? || data.blank? - - sanitized_source = self.escape_shortcut_urls(data) - - self.source = CarrierWave::SanitizedFile.new({ - :tempfile => StringIO.new(sanitized_source), - :filename => "#{self.plain_text_name}.#{self.stylesheet? ? 'css' : 'js'}" - }) - end - - def to_liquid - { :url => self.source.url }.merge(self.attributes).stringify_keys - end - - def self.all_grouped_by_folder(site) - assets = site.theme_assets.order_by([[:slug, :asc]]) - assets.group_by { |a| a.folder.split('/').first.to_sym } - end - - protected - - def safe_source_filename - self.source_filename || self.source.send(:original_filename) rescue nil - end - - def sanitize_folder - self.folder = self.content_type.to_s.pluralize if self.folder.blank? - - # no accents, no spaces, no leading and ending trails - self.folder = ActiveSupport::Inflector.transliterate(self.folder).gsub(/(\s)+/, '_').gsub(/^\//, '').gsub(/\/$/, '') - - # folder should begin by a root folder - if (self.folder =~ /^(stylesheets|javascripts|images|medias|fonts)/).nil? - self.folder = File.join(self.content_type.to_s.pluralize, self.folder) - end - end - - def build_local_path - if filename = self.safe_source_filename - self.local_path = File.join(self.folder, filename) - else - nil - end - end - - def escape_shortcut_urls(text) - return if text.blank? - - text.gsub(/[("'](\/(stylesheets|javascripts|images|medias)\/(([^;.]+)\/)*([a-z_\-0-9]+)\.[a-z]{2,3})[)"']/) do |path| - - sanitized_path = path.gsub(/[("')]/, '').gsub(/^\//, '') - - if asset = self.site.theme_assets.where(:local_path => sanitized_path).first - "#{path.first}#{asset.source.url}#{path.last}" - else - path - end - end - end - - def content_type_can_not_changed - self.errors.add(:source, :extname_changed) if !self.new_record? && self.content_type_changed? - end - -end diff --git a/app/uploaders/asset_uploader.rb b/app/uploaders/asset_uploader.rb deleted file mode 100644 index 041cca08..00000000 --- a/app/uploaders/asset_uploader.rb +++ /dev/null @@ -1,11 +0,0 @@ -# encoding: utf-8 - -class AssetUploader < CarrierWave::Uploader::Base - - include Locomotive::CarrierWave::Uploader::Asset - - def store_dir - self.build_store_dir('sites', model.site_id, 'assets', model.id) - end - -end diff --git a/app/uploaders/editable_file_uploader.rb b/app/uploaders/editable_file_uploader.rb deleted file mode 100644 index 47761b64..00000000 --- a/app/uploaders/editable_file_uploader.rb +++ /dev/null @@ -1,7 +0,0 @@ -class EditableFileUploader < ::CarrierWave::Uploader::Base - - def store_dir - self.build_store_dir('sites', model.page.site_id, 'pages', model.page.id, 'files') - end - -end \ No newline at end of file diff --git a/app/uploaders/locomotive/asset_uploader.rb b/app/uploaders/locomotive/asset_uploader.rb new file mode 100644 index 00000000..b2a8da72 --- /dev/null +++ b/app/uploaders/locomotive/asset_uploader.rb @@ -0,0 +1,13 @@ +# encoding: utf-8 + +module Locomotive + class AssetUploader < CarrierWave::Uploader::Base + + include Locomotive::CarrierWave::Uploader::Asset + + def store_dir + self.build_store_dir('sites', model.site_id, 'assets', model.id) + end + + end +end \ No newline at end of file diff --git a/app/uploaders/locomotive/editable_file_uploader.rb b/app/uploaders/locomotive/editable_file_uploader.rb new file mode 100644 index 00000000..547e64e0 --- /dev/null +++ b/app/uploaders/locomotive/editable_file_uploader.rb @@ -0,0 +1,11 @@ +# encoding: utf-8 + +module Locomotive + class EditableFileUploader < ::CarrierWave::Uploader::Base + + def store_dir + self.build_store_dir('sites', model.page.site_id, 'pages', model.page.id, 'files') + end + + end +end \ No newline at end of file diff --git a/app/uploaders/locomotive/theme_asset_uploader.rb b/app/uploaders/locomotive/theme_asset_uploader.rb new file mode 100644 index 00000000..80e838e3 --- /dev/null +++ b/app/uploaders/locomotive/theme_asset_uploader.rb @@ -0,0 +1,28 @@ +# encoding: utf-8 + +module Locomotive + class ThemeAssetUploader < CarrierWave::Uploader::Base + + include Locomotive::CarrierWave::Uploader::Asset + + def store_dir + self.build_store_dir('sites', model.site_id, 'theme', model.folder) + end + + def extension_white_list + %w(jpg jpeg gif png css js swf flv eot svg ttf woff otf ico htc) + end + + def self.url_for(site, path) + build(site, path).url + end + + def self.build(site, path) + asset = ThemeAsset.new(:site => site, :folder => File.dirname(path)) + uploader = ThemeAssetUploader.new(asset) + uploader.retrieve_from_store!(File.basename(path)) + uploader + end + + end +end \ No newline at end of file diff --git a/app/uploaders/locomotive/theme_uploader.rb b/app/uploaders/locomotive/theme_uploader.rb new file mode 100644 index 00000000..7e53968f --- /dev/null +++ b/app/uploaders/locomotive/theme_uploader.rb @@ -0,0 +1,19 @@ +# encoding: utf-8 + +module Locomotive + class ThemeUploader < ::CarrierWave::Uploader::Base + + def store_dir + if Locomotive.config.delayed_job + self.build_store_dir('sites', model.id.to_s, 'tmp', 'themes') + else + "#{Rails.root}/tmp/themes" + end + end + + def extension_white_list + %w(zip) + end + + end +end \ No newline at end of file diff --git a/app/uploaders/theme_asset_uploader.rb b/app/uploaders/theme_asset_uploader.rb deleted file mode 100644 index 965a3bdf..00000000 --- a/app/uploaders/theme_asset_uploader.rb +++ /dev/null @@ -1,26 +0,0 @@ -# encoding: utf-8 - -class ThemeAssetUploader < CarrierWave::Uploader::Base - - include Locomotive::CarrierWave::Uploader::Asset - - def store_dir - self.build_store_dir('sites', model.site_id, 'theme', model.folder) - end - - def extension_white_list - %w(jpg jpeg gif png css js swf flv eot svg ttf woff otf ico htc) - end - - def self.url_for(site, path) - build(site, path).url - end - - def self.build(site, path) - asset = ThemeAsset.new(:site => site, :folder => File.dirname(path)) - uploader = ThemeAssetUploader.new(asset) - uploader.retrieve_from_store!(File.basename(path)) - uploader - end - -end diff --git a/app/uploaders/theme_uploader.rb b/app/uploaders/theme_uploader.rb deleted file mode 100644 index cb052e00..00000000 --- a/app/uploaders/theme_uploader.rb +++ /dev/null @@ -1,15 +0,0 @@ -class ThemeUploader < ::CarrierWave::Uploader::Base - - def store_dir - if Locomotive.config.delayed_job - self.build_store_dir('sites', model.id.to_s, 'tmp', 'themes') - else - "#{Rails.root}/tmp/themes" - end - end - - def extension_white_list - %w(zip) - end - -end \ No newline at end of file diff --git a/app/views/admin/content_types/edit.html.haml b/app/views/admin/content_types/edit.html.haml deleted file mode 100644 index 0311b8ab..00000000 --- a/app/views/admin/content_types/edit.html.haml +++ /dev/null @@ -1,21 +0,0 @@ -- title t('.title') - -- content_for :submenu do - = render 'admin/shared/menu/contents' - -- content_for :actions do - = render 'admin/shared/actions/contents' - -- content_for :buttons do - = admin_button_tag :show_items, admin_contents_url(@content_type.slug_was), :class => 'show' - = admin_button_tag :new_item, new_admin_content_url(@content_type.slug_was), :class => 'new' - -%p!= t('.help') - -= semantic_form_for @content_type, :url => admin_content_type_url(@content_type) do |f| - - = render 'form', :f => f - - = render 'admin/shared/form_actions', :back_url => admin_contents_url(@content_type.slug_was), :button_label => :update - -= render 'admin/custom_fields/edit_field', :content_type => @content_type \ No newline at end of file diff --git a/app/views/admin/cross_domain_sessions/new.html.haml b/app/views/admin/cross_domain_sessions/new.html.haml deleted file mode 100644 index 1df452a5..00000000 --- a/app/views/admin/cross_domain_sessions/new.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -- title t('.title') - -= form_tag admin_cross_domain_sessions_url(:host => @target, :port => request.port), :method => 'post' do - - = hidden_field_tag 'token', current_admin.switch_site_token - - .inner - %p.notice= t('.notice') - - .footer - = box_button_tag t('admin.buttons.switch_to_site') - -:javascript - $(document).ready(function() { $('form').submit(); }); \ No newline at end of file diff --git a/app/views/admin/mailer/reset_password_instructions.html.haml b/app/views/admin/mailer/reset_password_instructions.html.haml deleted file mode 100644 index 9fa776a5..00000000 --- a/app/views/admin/mailer/reset_password_instructions.html.haml +++ /dev/null @@ -1,12 +0,0 @@ -%p - != t('admin.mailer.common.hello') - = @resource.email - \! -%p - != t('.reset_password_instruction') -%p - = link_to t('.change_my_password'), edit_admin_password_url(@resource, :reset_password_token => @resource.reset_password_token) -%p - != t('.wrong_request_instruction') -%p - != t('.unchange_password_message') diff --git a/app/views/admin/shared/_header.html.haml b/app/views/admin/shared/_header.html.haml deleted file mode 100644 index 5c9ba3c0..00000000 --- a/app/views/admin/shared/_header.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -%h1 - = link_to current_site.name, admin_pages_url, :class => 'single' - -= render_cell 'admin/global_actions', :show, :current_admin => current_admin, :current_site_url => current_site_url - -- if multi_sites? && current_admin.sites.size > 1 - #sites-picker{ :style => 'display: none' } - %ul - - current_admin.sites.each do |site| - - unless current_site._id == site._id - %li - = link_to site.name, new_admin_cross_domain_session_url(:target_id => site._id) - - - if can?(:manage, Site) - %p.action - = link_to t('admin.sites_picker.new'), new_admin_site_url \ No newline at end of file diff --git a/app/views/admin/shared/actions/_contents.html.haml b/app/views/admin/shared/actions/_contents.html.haml deleted file mode 100644 index 86d1b3bc..00000000 --- a/app/views/admin/shared/actions/_contents.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -- if can? :manage, ContentType - = link_to content_tag(:em) + content_tag(:span, t('admin.content_types.index.new')), new_admin_content_type_url \ No newline at end of file diff --git a/app/views/admin/sites/_form.html.haml b/app/views/admin/sites/_form.html.haml deleted file mode 100644 index dbb21976..00000000 --- a/app/views/admin/sites/_form.html.haml +++ /dev/null @@ -1,37 +0,0 @@ -- content_for :head do - = include_javascripts :site - -= f.foldable_inputs :name => :information, :style => "#{'display: none' unless @site.new_record?}" do - = f.input :name, :required => false - -- if manage_subdomain_or_domains? - = f.foldable_inputs :name => :access_points, :class => 'editable-list off' do - - = f.custom_input :subdomain, :css => 'path' do - %em - http:// - = f.text_field :subdomain - \. - %em - = application_domain - - - if manage_domains? - - @site.domains_without_subdomain.each_with_index do |name, index| - %li{ :class => "item added #{'last' if index == @site.domains.size - 1}" } - %em - http:// - = text_field_tag 'site[domains][]', name, :class => 'string label void domain' -   - = error_on_domain(@site, name) - %span.actions - = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove first', :confirm => t('admin.messages.confirm') - - %li.item.template - %em - http:// - = text_field_tag 'label', t('formtastic.hints.site.domain_name'), :class => 'string label void domain' -   - %span.actions - = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove first', :confirm => t('admin.messages.confirm') - %button{ :class => 'button light add', :type => 'button' } - %span!= t('admin.buttons.new_item') \ No newline at end of file diff --git a/app/views/admin/sites/new.html.haml b/app/views/admin/sites/new.html.haml deleted file mode 100644 index c4564ed2..00000000 --- a/app/views/admin/sites/new.html.haml +++ /dev/null @@ -1,12 +0,0 @@ -- title t('.title') - -- content_for :submenu do - = render_cell 'admin/settings_menu', :show - -%p!= t('.help') - -= semantic_form_for @site, :url => admin_sites_url do |form| - - = render 'form', :f => form - - = render 'admin/shared/form_actions', :back_url => edit_admin_my_account_url, :button_label => :create \ No newline at end of file diff --git a/app/views/admin/snippets/edit.html.haml b/app/views/admin/snippets/edit.html.haml deleted file mode 100644 index 7afd277e..00000000 --- a/app/views/admin/snippets/edit.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -- title t('.title') - -- content_for :submenu do - = render_cell 'admin/settings_menu', :show - -- content_for :buttons do - = admin_button_tag t('admin.snippets.index.new'), new_admin_snippet_url, :class => 'new' - -%p!= t('.help', :slug => @snippet.slug) - -= semantic_form_for @snippet, :url => admin_snippet_url(@snippet), :html => { :class => 'save-with-shortcut' } do |form| - - = render 'form', :f => form - - = render 'admin/shared/form_actions', :back_url => admin_theme_assets_url, :button_label => :update \ No newline at end of file diff --git a/app/views/admin/snippets/new.html.haml b/app/views/admin/snippets/new.html.haml deleted file mode 100644 index f589f1ff..00000000 --- a/app/views/admin/snippets/new.html.haml +++ /dev/null @@ -1,12 +0,0 @@ -- title t('.title') - -- content_for :submenu do - = render_cell 'admin/settings_menu', :show - -%p!= t('.help') - -= semantic_form_for @snippet, :url => admin_snippets_url do |form| - - = render 'form', :f => form - - = render 'admin/shared/form_actions', :back_url => admin_theme_assets_url, :button_label => :create \ No newline at end of file diff --git a/app/views/admin/theme_assets/new.html.haml b/app/views/admin/theme_assets/new.html.haml deleted file mode 100644 index 91819d29..00000000 --- a/app/views/admin/theme_assets/new.html.haml +++ /dev/null @@ -1,12 +0,0 @@ -- title t('.title') - -- content_for :submenu do - = render_cell 'admin/settings_menu', :show - -%p!= t('.help') - -= semantic_form_for @theme_asset, :url => admin_theme_assets_url, :html => { :multipart => true } do |form| - - = render 'form', :f => form - - = render 'admin/shared/form_actions', :back_url => admin_theme_assets_url, :button_label => :create \ No newline at end of file diff --git a/app/views/admin/accounts/new.html.haml b/app/views/locomotive/accounts/new.html.haml similarity index 73% rename from app/views/admin/accounts/new.html.haml rename to app/views/locomotive/accounts/new.html.haml index 720196e1..8e45cbd2 100644 --- a/app/views/admin/accounts/new.html.haml +++ b/app/views/locomotive/accounts/new.html.haml @@ -5,7 +5,7 @@ %p!= t('.help') -= semantic_form_for @account, :url => admin_accounts_url do |f| += semantic_form_for @account, :url => locomotive_accounts_url do |f| = f.foldable_inputs :name => :information do = f.input :name @@ -18,4 +18,4 @@ = f.input :password, :input_html => { :autocomplete => "off" } = f.input :password_confirmation, :input_html => { :autocomplete => "off" } - = render 'admin/shared/form_actions', :back_url => edit_admin_current_site_url, :button_label => :create \ No newline at end of file + = render 'admin/shared/form_actions', :back_url => edit_locomotive_current_site_url, :button_label => :create \ No newline at end of file diff --git a/app/views/admin/assets/_asset.html.haml b/app/views/locomotive/assets/_asset.html.haml similarity index 82% rename from app/views/admin/assets/_asset.html.haml rename to app/views/locomotive/assets/_asset.html.haml index 6390aed1..4da86182 100644 --- a/app/views/admin/assets/_asset.html.haml +++ b/app/views/locomotive/assets/_asset.html.haml @@ -2,4 +2,4 @@ %h4= link_to truncate(asset.name, :length => 17), edit_admin_asset_path(asset) = vignette_tag(asset) .actions - = link_to image_tag('admin/list/icons/cross.png'), '#', :class => 'remove', :confirm => t('admin.messages.confirm') \ No newline at end of file + = link_to image_tag('admin/list/icons/cross.png'), '#', :class => 'remove', :confirm => t('locomotive.messages.confirm') \ No newline at end of file diff --git a/app/views/admin/content_types/_form.html.haml b/app/views/locomotive/content_types/_form.html.haml similarity index 100% rename from app/views/admin/content_types/_form.html.haml rename to app/views/locomotive/content_types/_form.html.haml diff --git a/app/views/locomotive/content_types/edit.html.haml b/app/views/locomotive/content_types/edit.html.haml new file mode 100644 index 00000000..1f03219d --- /dev/null +++ b/app/views/locomotive/content_types/edit.html.haml @@ -0,0 +1,21 @@ +- title t('.title') + +- content_for :submenu do + = render 'admin/shared/menu/contents' + +- content_for :actions do + = render 'admin/shared/actions/contents' + +- content_for :buttons do + = admin_button_tag :show_items, locomotive_contents_url(@content_type.slug_was), :class => 'show' + = admin_button_tag :new_item, new_locomotive_content_url(@content_type.slug_was), :class => 'new' + +%p!= t('.help') + += semantic_form_for @content_type, :url => locomotive_content_type_url(@content_type) do |f| + + = render 'form', :f => f + + = render 'admin/shared/form_actions', :back_url => locomotive_contents_url(@content_type.slug_was), :button_label => :update + += render 'admin/custom_fields/edit_field', :content_type => @content_type \ No newline at end of file diff --git a/app/views/admin/content_types/new.html.haml b/app/views/locomotive/content_types/new.html.haml similarity index 58% rename from app/views/admin/content_types/new.html.haml rename to app/views/locomotive/content_types/new.html.haml index 5042ffc2..5889a5c8 100644 --- a/app/views/admin/content_types/new.html.haml +++ b/app/views/locomotive/content_types/new.html.haml @@ -8,10 +8,10 @@ %p!= t('.help') -= semantic_form_for @content_type, :url => admin_content_types_url do |f| += semantic_form_for @content_type, :url => locomotive_content_types_url do |f| = render 'form', :f => f - = render 'admin/shared/form_actions', :back_url => admin_pages_url, :button_label => :create + = render 'admin/shared/form_actions', :back_url => locomotive_pages_url, :button_label => :create = render 'admin/custom_fields/edit_field', :content_type => @content_type \ No newline at end of file diff --git a/app/views/admin/contents/_form.html.haml b/app/views/locomotive/contents/_form.html.haml similarity index 100% rename from app/views/admin/contents/_form.html.haml rename to app/views/locomotive/contents/_form.html.haml diff --git a/app/views/admin/contents/_list.html.haml b/app/views/locomotive/contents/_list.html.haml similarity index 65% rename from app/views/admin/contents/_list.html.haml rename to app/views/locomotive/contents/_list.html.haml index 40ba8e29..199520ff 100644 --- a/app/views/admin/contents/_list.html.haml +++ b/app/views/locomotive/contents/_list.html.haml @@ -1,5 +1,5 @@ - if contents.empty? - %p.no-items!= t('.no_items', :url => new_admin_content_url(@content_type.slug)) + %p.no-items!= t('.no_items', :url => new_locomotive_content_url(@content_type.slug)) - else %ul{ :id => 'contents-list', :class => "list #{'sortable' if @content_type.order_by == '_position_in_list'}", :'data-url' => sort_admin_contents_path(@content_type.slug, :json) } - contents.each do |content| @@ -9,7 +9,7 @@ = link_to content_label_for(content), edit_admin_content_path(@content_type.slug, content) .more %span - != t('admin.contents.index.updated_at') + != t('locomotive.contents.index.updated_at') = l content.updated_at, :format => :short rescue 'n/a' - = link_to image_tag('admin/list/icons/trash.png', :alt => t('admin.buttons.delete')), admin_content_path(@content_type.slug, content), :class => 'remove', :confirm => t('admin.messages.confirm'), :method => :delete \ No newline at end of file + = link_to image_tag('admin/list/icons/trash.png', :alt => t('locomotive.buttons.delete')), admin_content_path(@content_type.slug, content), :class => 'remove', :confirm => t('locomotive.messages.confirm'), :method => :delete \ No newline at end of file diff --git a/app/views/admin/contents/edit.html.haml b/app/views/locomotive/contents/edit.html.haml similarity index 55% rename from app/views/admin/contents/edit.html.haml rename to app/views/locomotive/contents/edit.html.haml index 2d6afd04..91f24f81 100644 --- a/app/views/admin/contents/edit.html.haml +++ b/app/views/locomotive/contents/edit.html.haml @@ -11,13 +11,13 @@ - content_for :buttons do - if can?(:manage, ContentType) - = admin_button_tag t('admin.contents.index.edit'), edit_admin_content_type_url(@content_type), :class => 'edit' + = admin_button_tag t('locomotive.contents.index.edit'), edit_locomotive_content_type_url(@content_type), :class => 'edit' - = admin_button_tag t('admin.contents.index.new'), new_admin_content_url(@content_type.slug), :class => 'new' + = admin_button_tag t('locomotive.contents.index.new'), new_locomotive_content_url(@content_type.slug), :class => 'new' %p= @content_type.description -= semantic_form_for @content, :as => :content, :url => admin_content_url(@content_type.slug, @content), :html => { :multipart => true, :class => 'save-with-shortcut' } do |form| += semantic_form_for @content, :as => :content, :url => locomotive_content_url(@content_type.slug, @content), :html => { :multipart => true, :class => 'save-with-shortcut' } do |form| = render 'form', :f => form diff --git a/app/views/admin/contents/index.html.haml b/app/views/locomotive/contents/index.html.haml similarity index 68% rename from app/views/admin/contents/index.html.haml rename to app/views/locomotive/contents/index.html.haml index ce7f0ed6..d149ea7c 100644 --- a/app/views/admin/contents/index.html.haml +++ b/app/views/locomotive/contents/index.html.haml @@ -11,9 +11,9 @@ - content_for :buttons do - if can?(:manage, ContentType) - = admin_button_tag :edit, edit_admin_content_type_url(@content_type), :class => 'edit' + = admin_button_tag :edit, edit_locomotive_content_type_url(@content_type), :class => 'edit' - = admin_button_tag :new, new_admin_content_url(@content_type.slug), :class => 'new' + = admin_button_tag :new, new_locomotive_content_url(@content_type.slug), :class => 'new' - if @content_type.description.present? %p= @content_type.description @@ -29,4 +29,4 @@ - if can?(:manage, ContentType) #local-actions-bottom-bar %p.tleft - = link_to(content_tag(:em, escape_once(' ')) + t('.destroy'), admin_content_type_url(@content_type), :confirm => t('admin.messages.confirm'), :method => :delete, :class => 'button small remove') + = link_to(content_tag(:em, escape_once(' ')) + t('.destroy'), locomotive_content_type_url(@content_type), :confirm => t('locomotive.messages.confirm'), :method => :delete, :class => 'button small remove') diff --git a/app/views/admin/contents/new.html.haml b/app/views/locomotive/contents/new.html.haml similarity index 65% rename from app/views/admin/contents/new.html.haml rename to app/views/locomotive/contents/new.html.haml index b4b247e0..ea7c8b73 100644 --- a/app/views/admin/contents/new.html.haml +++ b/app/views/locomotive/contents/new.html.haml @@ -11,11 +11,11 @@ - if can?(:manage, ContentType) - content_for :buttons do - = admin_button_tag t('admin.contents.index.edit'), edit_admin_content_type_url(@content_type), :class => 'edit' + = admin_button_tag t('locomotive.contents.index.edit'), edit_locomotive_content_type_url(@content_type), :class => 'edit' %p= @content_type.description -= semantic_form_for @content, :as => :content, :url => admin_contents_url(@content_type.slug), :html => { :multipart => true } do |form| += semantic_form_for @content, :as => :content, :url => locomotive_contents_url(@content_type.slug), :html => { :multipart => true } do |form| = render 'form', :f => form diff --git a/app/views/locomotive/cross_domain_sessions/new.html.haml b/app/views/locomotive/cross_domain_sessions/new.html.haml new file mode 100644 index 00000000..650cc29f --- /dev/null +++ b/app/views/locomotive/cross_domain_sessions/new.html.haml @@ -0,0 +1,14 @@ +- title t('.title') + += form_tag locomotive_cross_domain_sessions_url(:host => @target, :port => request.port), :method => 'post' do + + = hidden_field_tag 'token', current_account.switch_site_token + + .inner + %p.notice= t('.notice') + + .footer + = box_button_tag t('locomotive.buttons.switch_to_site') + +:javascript + $(document).ready(function() { $('form').submit(); }); \ No newline at end of file diff --git a/app/views/admin/current_site/_form.html.haml b/app/views/locomotive/current_site/_form.html.haml similarity index 75% rename from app/views/admin/current_site/_form.html.haml rename to app/views/locomotive/current_site/_form.html.haml index cb0426fb..0e4bbb94 100644 --- a/app/views/admin/current_site/_form.html.haml +++ b/app/views/locomotive/current_site/_form.html.haml @@ -30,7 +30,7 @@   = error_on_domain(@site, name) %span.actions - = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove first', :confirm => t('admin.messages.confirm') + = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove first', :confirm => t('locomotive.messages.confirm') %li.item.template %em @@ -38,9 +38,9 @@ = text_field_tag 'label', t('formtastic.hints.site.domain_name'), :class => 'string label void domain'   %span.actions - = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove first', :confirm => t('admin.messages.confirm') + = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove first', :confirm => t('locomotive.messages.confirm') %button{ :class => 'button light add', :type => 'button' } - %span!= t('admin.buttons.new_item') + %span!= t('locomotive.buttons.new_item') - if can?(:index, Membership) @@ -56,19 +56,19 @@ - if can?(:update, membership) .role - %em.editable= t("admin.memberships.roles.#{membership.role}") + %em.editable= t("locomotive.memberships.roles.#{membership.role}") - if can?(:grant_admin, membership) - = fm.select :role, Ability::ROLES.map { |r| [t("admin.memberships.roles.#{r}"), r] }, :include_blank => false + = fm.select :role, Ability::ROLES.map { |r| [t("locomotive.memberships.roles.#{r}"), r] }, :include_blank => false - else - = fm.select :role, (Ability::ROLES - ['admin']).map { |r| [t("admin.memberships.roles.#{r}"), r] }, :include_blank => false + = fm.select :role, (Ability::ROLES - ['admin']).map { |r| [t("locomotive.memberships.roles.#{r}"), r] }, :include_blank => false %span.actions - = link_to image_tag('admin/form/icons/trash.png'), admin_membership_url(membership), :class => 'remove first', :confirm =>t('admin.messages.confirm'), :method => :delete + = link_to image_tag('admin/form/icons/trash.png'), locomotive_membership_url(membership), :class => 'remove first', :confirm =>t('locomotive.messages.confirm'), :method => :delete - else .role - %em.locked= t("admin.memberships.roles.#{membership.role}") + %em.locked= t("locomotive.memberships.roles.#{membership.role}") - if can?(:manage, current_site) diff --git a/app/views/admin/current_site/edit.html.haml b/app/views/locomotive/current_site/edit.html.haml similarity index 53% rename from app/views/admin/current_site/edit.html.haml rename to app/views/locomotive/current_site/edit.html.haml index 5cbb6dc4..dd217f49 100644 --- a/app/views/admin/current_site/edit.html.haml +++ b/app/views/locomotive/current_site/edit.html.haml @@ -5,14 +5,14 @@ - content_for :buttons do - if can?(:manage, @site) - = admin_button_tag :export, new_admin_export_url, :class => 'new' - = admin_button_tag :import, new_admin_import_url, :class => 'new' + = admin_button_tag :export, new_locomotive_export_url, :class => 'new' + = admin_button_tag :import, new_locomotive_import_url, :class => 'new' - if can?(:create, Account) - = admin_button_tag t('.new_membership'), new_admin_membership_url, :class => 'new' + = admin_button_tag t('.new_membership'), new_locomotive_membership_url, :class => 'new' %p!= t('.help') -= semantic_form_for @site, :url => admin_current_site_url, :html => { :class => 'save-with-shortcut' } do |f| += semantic_form_for @site, :url => locomotive_current_site_url, :html => { :class => 'save-with-shortcut' } do |f| = render 'form', :f => f diff --git a/app/views/admin/custom_fields/_category_tmpl.html.haml b/app/views/locomotive/custom_fields/_category_tmpl.html.haml similarity index 89% rename from app/views/admin/custom_fields/_category_tmpl.html.haml rename to app/views/locomotive/custom_fields/_category_tmpl.html.haml index d8fdd765..f3bbd5a9 100644 --- a/app/views/admin/custom_fields/_category_tmpl.html.haml +++ b/app/views/locomotive/custom_fields/_category_tmpl.html.haml @@ -12,6 +12,6 @@ %input{ :name => '{{base_name}}[name]', :value => '{{{name}}}', :type => 'text', :'data-field' => 'name' } %span.actions - = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove', :confirm => t('admin.messages.confirm') + = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove', :confirm => t('locomotive.messages.confirm') %button{ :class => 'button light add', :type => 'button' } - %span!= t('admin.buttons.new_item') \ No newline at end of file + %span!= t('locomotive.buttons.new_item') \ No newline at end of file diff --git a/app/views/admin/custom_fields/_custom_form.html.haml b/app/views/locomotive/custom_fields/_custom_form.html.haml similarity index 100% rename from app/views/admin/custom_fields/_custom_form.html.haml rename to app/views/locomotive/custom_fields/_custom_form.html.haml diff --git a/app/views/admin/custom_fields/_edit_field.html.haml b/app/views/locomotive/custom_fields/_edit_field.html.haml similarity index 94% rename from app/views/admin/custom_fields/_edit_field.html.haml rename to app/views/locomotive/custom_fields/_edit_field.html.haml index fa85cbd7..58a6884a 100644 --- a/app/views/admin/custom_fields/_edit_field.html.haml +++ b/app/views/locomotive/custom_fields/_edit_field.html.haml @@ -14,7 +14,7 @@ .popup-actions %p %button.button.light{ :type => 'submit' } - %span= t('admin.shared.form_actions.update') + %span= t('locomotive.shared.form_actions.update') %script{ :type => 'text/javascript', :name => 'reverse_lookups' } != collection_to_js(options_for_reverse_lookups(content_type)) \ No newline at end of file diff --git a/app/views/admin/custom_fields/_index.html.haml b/app/views/locomotive/custom_fields/_index.html.haml similarity index 96% rename from app/views/admin/custom_fields/_index.html.haml rename to app/views/locomotive/custom_fields/_index.html.haml index 252cf0cb..055de105 100644 --- a/app/views/admin/custom_fields/_index.html.haml +++ b/app/views/locomotive/custom_fields/_index.html.haml @@ -44,9 +44,9 @@ %span.actions = link_to image_tag('admin/form/pen.png'), '#edit-custom-field', :class => 'edit first' - = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove', :confirm => t('admin.messages.confirm') + = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove', :confirm => t('locomotive.messages.confirm') %button{ :class => 'button light add', :type => 'button' } - %span!= t('admin.buttons.new_item') + %span!= t('locomotive.buttons.new_item') %script{ :type => 'text/javascript', :name => 'data' } != collection_to_js(ordered_custom_fields, :template => field_klass.new(:label => t('.default_label'), :_alias => '', :kind => 'string').to_hash) diff --git a/app/views/admin/custom_fields/edit_category.html.haml b/app/views/locomotive/custom_fields/edit_category.html.haml similarity index 67% rename from app/views/admin/custom_fields/edit_category.html.haml rename to app/views/locomotive/custom_fields/edit_category.html.haml index 6c02dfe8..78607a90 100644 --- a/app/views/admin/custom_fields/edit_category.html.haml +++ b/app/views/locomotive/custom_fields/edit_category.html.haml @@ -4,7 +4,7 @@ %p!= t('.help') - = semantic_form_for @field, :as => :custom_field, :url => admin_custom_field_url(@parent.class.model_name.underscore, @parent.slug, @field) do |f| + = semantic_form_for @field, :as => :custom_field, :url => locomotive_custom_field_url(@parent.class.model_name.underscore, @parent.slug, @field) do |f| = f.foldable_inputs :name => t('.collection_label'), :class => 'editable-list off' @@ -14,4 +14,4 @@ .popup-actions %p %button.button.light{ :type => 'submit' } - %span= t('admin.shared.form_actions.update') \ No newline at end of file + %span= t('locomotive.shared.form_actions.update') \ No newline at end of file diff --git a/app/views/admin/custom_fields/types/_boolean.html.haml b/app/views/locomotive/custom_fields/types/_boolean.html.haml similarity index 100% rename from app/views/admin/custom_fields/types/_boolean.html.haml rename to app/views/locomotive/custom_fields/types/_boolean.html.haml diff --git a/app/views/admin/custom_fields/types/_category.html.haml b/app/views/locomotive/custom_fields/types/_category.html.haml similarity index 100% rename from app/views/admin/custom_fields/types/_category.html.haml rename to app/views/locomotive/custom_fields/types/_category.html.haml diff --git a/app/views/admin/custom_fields/types/_date.html.haml b/app/views/locomotive/custom_fields/types/_date.html.haml similarity index 100% rename from app/views/admin/custom_fields/types/_date.html.haml rename to app/views/locomotive/custom_fields/types/_date.html.haml diff --git a/app/views/admin/custom_fields/types/_file.html.haml b/app/views/locomotive/custom_fields/types/_file.html.haml similarity index 100% rename from app/views/admin/custom_fields/types/_file.html.haml rename to app/views/locomotive/custom_fields/types/_file.html.haml diff --git a/app/views/admin/custom_fields/types/_has_many.html.haml b/app/views/locomotive/custom_fields/types/_has_many.html.haml similarity index 91% rename from app/views/admin/custom_fields/types/_has_many.html.haml rename to app/views/locomotive/custom_fields/types/_has_many.html.haml index f10a6218..5b110e72 100644 --- a/app/views/admin/custom_fields/types/_has_many.html.haml +++ b/app/views/locomotive/custom_fields/types/_has_many.html.haml @@ -27,7 +27,7 @@ = link_to image_tag('admin/form/pen.png'), '#', :class => 'edit first' = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove' %button{ :class => 'button light mini add', :type => 'button' } - %span!= t('admin.buttons.new_item') + %span!= t('locomotive.buttons.new_item') %script{ :type => 'text/javascript', :name => 'data' } != has_many_data_to_js(field, form.object) \ No newline at end of file diff --git a/app/views/admin/custom_fields/types/_has_one.html.haml b/app/views/locomotive/custom_fields/types/_has_one.html.haml similarity index 100% rename from app/views/admin/custom_fields/types/_has_one.html.haml rename to app/views/locomotive/custom_fields/types/_has_one.html.haml diff --git a/app/views/admin/custom_fields/types/_string.html.haml b/app/views/locomotive/custom_fields/types/_string.html.haml similarity index 100% rename from app/views/admin/custom_fields/types/_string.html.haml rename to app/views/locomotive/custom_fields/types/_string.html.haml diff --git a/app/views/admin/custom_fields/types/_text.html.haml b/app/views/locomotive/custom_fields/types/_text.html.haml similarity index 100% rename from app/views/admin/custom_fields/types/_text.html.haml rename to app/views/locomotive/custom_fields/types/_text.html.haml diff --git a/app/views/admin/errors/404.html.haml b/app/views/locomotive/errors/404.html.haml similarity index 55% rename from app/views/admin/errors/404.html.haml rename to app/views/locomotive/errors/404.html.haml index 6dad8500..177fc519 100644 --- a/app/views/admin/errors/404.html.haml +++ b/app/views/locomotive/errors/404.html.haml @@ -4,4 +4,4 @@ %p.notice= t('.notice') %p.link.tright - = link_to preserve(t('.link')), admin_pages_url + = link_to preserve(t('.link')), locomotive_pages_url diff --git a/app/views/admin/errors/500.html.haml b/app/views/locomotive/errors/500.html.haml similarity index 56% rename from app/views/admin/errors/500.html.haml rename to app/views/locomotive/errors/500.html.haml index 4055d2fd..d7482a0c 100644 --- a/app/views/admin/errors/500.html.haml +++ b/app/views/locomotive/errors/500.html.haml @@ -4,4 +4,4 @@ %p.notice= t('.notice') %p.link.tright - = link_to preserve(t('.link')), admin_pages_url \ No newline at end of file + = link_to preserve(t('.link')), locomotive_pages_url \ No newline at end of file diff --git a/app/views/admin/errors/no_page.html.haml b/app/views/locomotive/errors/no_page.html.haml similarity index 100% rename from app/views/admin/errors/no_page.html.haml rename to app/views/locomotive/errors/no_page.html.haml diff --git a/app/views/admin/errors/no_site.html.haml b/app/views/locomotive/errors/no_site.html.haml similarity index 100% rename from app/views/admin/errors/no_site.html.haml rename to app/views/locomotive/errors/no_site.html.haml diff --git a/app/views/admin/import/new.html.haml b/app/views/locomotive/import/new.html.haml similarity index 85% rename from app/views/admin/import/new.html.haml rename to app/views/locomotive/import/new.html.haml index 84b6752e..3aad3bb7 100644 --- a/app/views/admin/import/new.html.haml +++ b/app/views/locomotive/import/new.html.haml @@ -5,7 +5,7 @@ %p!= t('.help') -= form_tag admin_import_url, :multipart => true, :class => 'formtastic import' do += form_tag locomotive_import_url, :multipart => true, :class => 'formtastic import' do %fieldset.inputs %legend diff --git a/app/views/admin/import/show.html.haml b/app/views/locomotive/import/show.html.haml similarity index 63% rename from app/views/admin/import/show.html.haml rename to app/views/locomotive/import/show.html.haml index c07e8a14..c9c4a17f 100644 --- a/app/views/admin/import/show.html.haml +++ b/app/views/locomotive/import/show.html.haml @@ -8,7 +8,7 @@ %p!= t('.help') -%ul{ :id => 'import-steps', :class => 'list', :'data-url' => admin_import_url(:json), :'data-success-message' => t('.messages.success'), :'data-failure-message' => t('.messages.failure') } +%ul{ :id => 'import-steps', :class => 'list', :'data-url' => locomotive_import_url(:json), :'data-success-message' => t('.messages.success'), :'data-failure-message' => t('.messages.failure') } - %w(site content_types assets snippets pages).each do |step| %li{ :id => "#{step}-step" } %em diff --git a/app/views/admin/installation/step_1.html.haml b/app/views/locomotive/installation/step_1.html.haml similarity index 77% rename from app/views/admin/installation/step_1.html.haml rename to app/views/locomotive/installation/step_1.html.haml index 3448b25a..a25fc471 100644 --- a/app/views/admin/installation/step_1.html.haml +++ b/app/views/locomotive/installation/step_1.html.haml @@ -1,5 +1,5 @@ - content_for :head_title do - = t('admin.installation.common.title') + = t('locomotive.installation.common.title') - title t('.title') @@ -7,7 +7,7 @@ = include_stylesheets :installation - if @step_done.blank? - = semantic_form_for(@account, :url => admin_installation_step_url(1)) do |f| + = semantic_form_for(@account, :url => locomotive_installation_step_url(1)) do |f| .inner = f.inputs do = f.input :name, :label => t('.name'), :required => false diff --git a/app/views/admin/installation/step_2.html.haml b/app/views/locomotive/installation/step_2.html.haml similarity index 85% rename from app/views/admin/installation/step_2.html.haml rename to app/views/locomotive/installation/step_2.html.haml index a846a4d9..1c13700b 100644 --- a/app/views/admin/installation/step_2.html.haml +++ b/app/views/locomotive/installation/step_2.html.haml @@ -1,5 +1,5 @@ - content_for :head_title do - = t('admin.installation.common.title') + = t('locomotive.installation.common.title') - title t('.title') @@ -7,7 +7,7 @@ = include_stylesheets :installation = include_javascripts :installation -= semantic_form_for(@site, :url => admin_installation_step_url(2), :html => { :multipart => true }) do |f| += semantic_form_for(@site, :url => locomotive_installation_step_url(2), :html => { :multipart => true }) do |f| .inner %p.explanations diff --git a/app/views/admin/layouts/application.html.haml b/app/views/locomotive/layouts/application.html.haml similarity index 100% rename from app/views/admin/layouts/application.html.haml rename to app/views/locomotive/layouts/application.html.haml diff --git a/app/views/admin/layouts/box.html.haml b/app/views/locomotive/layouts/box.html.haml similarity index 100% rename from app/views/admin/layouts/box.html.haml rename to app/views/locomotive/layouts/box.html.haml diff --git a/app/views/admin/layouts/error.html.haml b/app/views/locomotive/layouts/error.html.haml similarity index 100% rename from app/views/admin/layouts/error.html.haml rename to app/views/locomotive/layouts/error.html.haml diff --git a/app/views/admin/mailer/confirmation_instructions.html.haml b/app/views/locomotive/mailer/confirmation_instructions.html.haml similarity index 84% rename from app/views/admin/mailer/confirmation_instructions.html.haml rename to app/views/locomotive/mailer/confirmation_instructions.html.haml index bec8765c..8c83e2d0 100644 --- a/app/views/admin/mailer/confirmation_instructions.html.haml +++ b/app/views/locomotive/mailer/confirmation_instructions.html.haml @@ -1,5 +1,5 @@ %p - != t('admin.mailer.common.hello') + != t('locomotive.mailer.common.hello') = @resource.email \! %p diff --git a/app/views/locomotive/mailer/reset_password_instructions.html.haml b/app/views/locomotive/mailer/reset_password_instructions.html.haml new file mode 100644 index 00000000..3c06c016 --- /dev/null +++ b/app/views/locomotive/mailer/reset_password_instructions.html.haml @@ -0,0 +1,12 @@ +%p + != t('locomotive.mailer.common.hello') + = @resource.email + \! +%p + != t('.reset_password_instruction') +%p + = link_to t('.change_my_password'), edit_locomotive_password_url(@resource, :reset_password_token => @resource.reset_password_token) +%p + != t('.wrong_request_instruction') +%p + != t('.unchange_password_message') diff --git a/app/views/admin/mailer/unlock_instructions.html.haml b/app/views/locomotive/mailer/unlock_instructions.html.haml similarity index 83% rename from app/views/admin/mailer/unlock_instructions.html.haml rename to app/views/locomotive/mailer/unlock_instructions.html.haml index 0b9aca52..c9eebffe 100644 --- a/app/views/admin/mailer/unlock_instructions.html.haml +++ b/app/views/locomotive/mailer/unlock_instructions.html.haml @@ -1,5 +1,5 @@ %p - != t('admin.mailer.common.hello') + != t('locomotive.mailer.common.hello') = @resource.email \! %p diff --git a/app/views/admin/memberships/new.html.haml b/app/views/locomotive/memberships/new.html.haml similarity index 60% rename from app/views/admin/memberships/new.html.haml rename to app/views/locomotive/memberships/new.html.haml index 024e6a35..559c8de2 100644 --- a/app/views/admin/memberships/new.html.haml +++ b/app/views/locomotive/memberships/new.html.haml @@ -5,11 +5,11 @@ %p!= t('.help') -= semantic_form_for @membership, :url => admin_memberships_url do |f| += semantic_form_for @membership, :url => locomotive_memberships_url do |f| = f.inputs :name => :membership_email, :class => 'inputs email' do = f.custom_input :email, { :css => 'string full', :with_label => false } do = f.text_field :email - = render 'admin/shared/form_actions', :back_url => edit_admin_current_site_url, :button_label => :create \ No newline at end of file + = render 'admin/shared/form_actions', :back_url => edit_locomotive_current_site_url, :button_label => :create \ No newline at end of file diff --git a/app/views/admin/my_account/edit.html.haml b/app/views/locomotive/my_account/edit.html.haml similarity index 81% rename from app/views/admin/my_account/edit.html.haml rename to app/views/locomotive/my_account/edit.html.haml index 7484bac1..f320ecc9 100644 --- a/app/views/admin/my_account/edit.html.haml +++ b/app/views/locomotive/my_account/edit.html.haml @@ -8,11 +8,11 @@ - if multi_sites? - content_for :buttons do - = admin_button_tag t('.new_site'), new_admin_site_url, :class => 'new' if can?(:create, Site) + = admin_button_tag t('.new_site'), new_locomotive_site_url, :class => 'new' if can?(:create, Site) %p= t('.help') -= semantic_form_for @account, :as => :my_account, :url => admin_my_account_url, :html => { :class => 'save-with-shortcut' } do |f| += semantic_form_for @account, :as => :my_account, :url => locomotive_my_account_url, :html => { :class => 'save-with-shortcut' } do |f| = f.foldable_inputs :name => :information, :style => 'display: none' do = f.input :name @@ -31,7 +31,7 @@ - if admin_on?(site) && site != current_site %span{ :class => 'actions' } - = link_to image_tag('admin/form/icons/trash.png'), admin_site_url(site), :class => 'remove first', :confirm => t('admin.messages.confirm'), :method => :delete + = link_to image_tag('admin/form/icons/trash.png'), locomotive_site_url(site), :class => 'remove first', :confirm => t('locomotive.messages.confirm'), :method => :delete = f.foldable_inputs :name => :language, :class => 'language' do = f.custom_input :language, { :css => 'full', :with_label => false } do diff --git a/app/views/admin/notifications/new_content_instance.html.haml b/app/views/locomotive/notifications/new_content_instance.html.haml similarity index 100% rename from app/views/admin/notifications/new_content_instance.html.haml rename to app/views/locomotive/notifications/new_content_instance.html.haml diff --git a/app/views/admin/pages/_editable_elements.html.haml b/app/views/locomotive/pages/_editable_elements.html.haml similarity index 86% rename from app/views/admin/pages/_editable_elements.html.haml rename to app/views/locomotive/pages/_editable_elements.html.haml index a482acc1..ccaf5b6d 100644 --- a/app/views/admin/pages/_editable_elements.html.haml +++ b/app/views/locomotive/pages/_editable_elements.html.haml @@ -5,7 +5,7 @@ #editable-elements .nav - grouped_editable_elements.keys.each_with_index do |name, index| - = link_to content_tag(:span, name.try(:humanize) || t('admin.pages.form.default_block')), "#block-#{index}", :id => "block-nav-#{index}", :class => "#{'on' if index == 0}" + = link_to content_tag(:span, name.try(:humanize) || t('locomotive.pages.form.default_block')), "#block-#{index}", :id => "block-nav-#{index}", :class => "#{'on' if index == 0}" .clear .wrapper @@ -31,5 +31,5 @@ = link_to File.basename(el.source.url), el.source.url %span  /  - != t('admin.pages.form.delete_file') + != t('locomotive.pages.form.delete_file') = g.check_box :remove_source \ No newline at end of file diff --git a/app/views/admin/pages/_form.html.haml b/app/views/locomotive/pages/_form.html.haml similarity index 87% rename from app/views/admin/pages/_form.html.haml rename to app/views/locomotive/pages/_form.html.haml index 444af1cd..e6851877 100644 --- a/app/views/admin/pages/_form.html.haml +++ b/app/views/locomotive/pages/_form.html.haml @@ -11,7 +11,7 @@ - if not @page.index? and not @page.not_found? = f.input :parent_id, :as => :select, :collection => parent_pages_options, :include_blank => false - = f.input :slug, :required => false, :hint => @page.slug.blank? ? ' ' : page_url(@page), :input_html => { :'data-url' => get_path_admin_pages_url, :disabled => @page.index? || @page.not_found? }, :wrapper_html => { :style => "#{'display: none' if @page.templatized?};" } + = f.input :slug, :required => false, :hint => @page.slug.blank? ? ' ' : page_url(@page), :input_html => { :'data-url' => get_path_locomotive_pages_url, :disabled => @page.index? || @page.not_found? }, :wrapper_html => { :style => "#{'display: none' if @page.templatized?};" } = render 'editable_elements', :page => @page @@ -51,4 +51,4 @@ = f.text_area :raw_template = f.errors_on :template .more - = link_to t('admin.image_picker.link'), admin_theme_assets_path, :id => 'image-picker-link', :class => 'picture' \ No newline at end of file + = link_to t('locomotive.image_picker.link'), admin_theme_assets_path, :id => 'image-picker-link', :class => 'picture' \ No newline at end of file diff --git a/app/views/admin/pages/_page.html.haml b/app/views/locomotive/pages/_page.html.haml similarity index 58% rename from app/views/admin/pages/_page.html.haml rename to app/views/locomotive/pages/_page.html.haml index ff88c451..80fd3fdd 100644 --- a/app/views/admin/pages/_page.html.haml +++ b/app/views/locomotive/pages/_page.html.haml @@ -8,16 +8,16 @@ = admin_item_toggler(page) %em - %strong= link_to truncate(page.title, :length => 80), edit_admin_page_url(page) + %strong= link_to truncate(page.title, :length => 80), edit_locomotive_page_url(page) .more %span!= t('.updated_at') = l page.updated_at, :format => :short - if !page.index_or_not_found? && can?(:manage, page) - = link_to image_tag('admin/list/icons/trash.png'), admin_page_url(page), :class => 'remove', :confirm => t('admin.messages.confirm'), :method => :delete + = link_to image_tag('admin/list/icons/trash.png'), locomotive_page_url(page), :class => 'remove', :confirm => t('locomotive.messages.confirm'), :method => :delete - if with_children - %ul{ :id => "folder-#{page._id}", :class => "folder depth-#{(page.depth || 0) + 1}", :'data-url' => sort_admin_page_url(page), :style => "display: #{cookies["folder-#{page._id}"] || 'block'}" } + %ul{ :id => "folder-#{page._id}", :class => "folder depth-#{(page.depth || 0) + 1}", :'data-url' => sort_locomotive_page_url(page), :style => "display: #{cookies["folder-#{page._id}"] || 'block'}" } = render children \ No newline at end of file diff --git a/app/views/admin/pages/edit.html.haml b/app/views/locomotive/pages/edit.html.haml similarity index 64% rename from app/views/admin/pages/edit.html.haml rename to app/views/locomotive/pages/edit.html.haml index 81f866e8..7a1d11a2 100644 --- a/app/views/admin/pages/edit.html.haml +++ b/app/views/locomotive/pages/edit.html.haml @@ -11,8 +11,8 @@ %p!= t('.help') -= semantic_form_for @page, :url => admin_page_url(@page), :html => { :class => 'save-with-shortcut', :multipart => true } do |form| += semantic_form_for @page, :url => locomotive_page_url(@page), :html => { :class => 'save-with-shortcut', :multipart => true } do |form| = render 'form', :f => form - = render 'admin/shared/form_actions', :back_url => admin_pages_url, :button_label => :update \ No newline at end of file + = render 'admin/shared/form_actions', :back_url => locomotive_pages_url, :button_label => :update \ No newline at end of file diff --git a/app/views/admin/pages/index.html.haml b/app/views/locomotive/pages/index.html.haml similarity index 69% rename from app/views/admin/pages/index.html.haml rename to app/views/locomotive/pages/index.html.haml index d4c41319..be1b31d9 100644 --- a/app/views/admin/pages/index.html.haml +++ b/app/views/locomotive/pages/index.html.haml @@ -11,12 +11,12 @@ - if can? :create, Page - content_for :buttons do - = admin_button_tag :new, new_admin_page_url, :class => 'new', :id => 'newpage' + = admin_button_tag :new, new_locomotive_page_url, :class => 'new', :id => 'newpage' %p!= t('.help') - if @pages.empty? - %p.no-items!= t('.no_items', :url => new_admin_page_url) + %p.no-items!= t('.no_items', :url => new_locomotive_page_url) - else %ul#pages-list = render @pages diff --git a/app/views/admin/pages/new.html.haml b/app/views/locomotive/pages/new.html.haml similarity index 55% rename from app/views/admin/pages/new.html.haml rename to app/views/locomotive/pages/new.html.haml index 6f75a40b..1ff51308 100644 --- a/app/views/admin/pages/new.html.haml +++ b/app/views/locomotive/pages/new.html.haml @@ -8,8 +8,8 @@ %p!= t('.help') -= semantic_form_for @page, :url => admin_pages_url do |form| += semantic_form_for @page, :url => locomotive_pages_url do |form| = render 'form', :f => form - = render 'admin/shared/form_actions', :back_url => admin_pages_url, :button_label => :create \ No newline at end of file + = render 'admin/shared/form_actions', :back_url => locomotive_pages_url, :button_label => :create \ No newline at end of file diff --git a/app/views/admin/passwords/edit.html.haml b/app/views/locomotive/passwords/edit.html.haml similarity index 89% rename from app/views/admin/passwords/edit.html.haml rename to app/views/locomotive/passwords/edit.html.haml index b1b4d5dc..194544c1 100644 --- a/app/views/admin/passwords/edit.html.haml +++ b/app/views/locomotive/passwords/edit.html.haml @@ -15,4 +15,4 @@ = link_to preserve(t('.link')), new_admin_session_path .footer - = box_button_tag t('admin.buttons.change_password') + = box_button_tag t('locomotive.buttons.change_password') diff --git a/app/views/admin/passwords/new.html.haml b/app/views/locomotive/passwords/new.html.haml similarity index 86% rename from app/views/admin/passwords/new.html.haml rename to app/views/locomotive/passwords/new.html.haml index 3970895b..bd6c37f5 100644 --- a/app/views/admin/passwords/new.html.haml +++ b/app/views/locomotive/passwords/new.html.haml @@ -14,4 +14,4 @@ = link_to preserve(t('.link')), new_admin_session_path .footer - = box_button_tag t('admin.buttons.send_password') \ No newline at end of file + = box_button_tag t('locomotive.buttons.send_password') \ No newline at end of file diff --git a/app/views/admin/sessions/new.html.haml b/app/views/locomotive/sessions/new.html.haml similarity index 89% rename from app/views/admin/sessions/new.html.haml rename to app/views/locomotive/sessions/new.html.haml index 9388bac7..324c2ef4 100644 --- a/app/views/admin/sessions/new.html.haml +++ b/app/views/locomotive/sessions/new.html.haml @@ -14,4 +14,4 @@ = link_to t('.link'), new_admin_password_path .footer - = box_button_tag t('admin.buttons.login') + = box_button_tag t('locomotive.buttons.login') diff --git a/app/views/admin/shared/_footer.html.haml b/app/views/locomotive/shared/_footer.html.haml similarity index 100% rename from app/views/admin/shared/_footer.html.haml rename to app/views/locomotive/shared/_footer.html.haml diff --git a/app/views/admin/shared/_form_actions.html.haml b/app/views/locomotive/shared/_form_actions.html.haml similarity index 100% rename from app/views/admin/shared/_form_actions.html.haml rename to app/views/locomotive/shared/_form_actions.html.haml diff --git a/app/views/admin/shared/_head.html.haml b/app/views/locomotive/shared/_head.html.haml similarity index 100% rename from app/views/admin/shared/_head.html.haml rename to app/views/locomotive/shared/_head.html.haml diff --git a/app/views/locomotive/shared/_header.html.haml b/app/views/locomotive/shared/_header.html.haml new file mode 100644 index 00000000..00e0b4ee --- /dev/null +++ b/app/views/locomotive/shared/_header.html.haml @@ -0,0 +1,16 @@ +%h1 + = link_to current_site.name, locomotive_pages_url, :class => 'single' + += render_cell 'admin/global_actions', :show, :current_account => current_account, :current_site_url => current_site_url + +- if multi_sites? && current_account.sites.size > 1 + #sites-picker{ :style => 'display: none' } + %ul + - current_account.sites.each do |site| + - unless current_site._id == site._id + %li + = link_to site.name, new_locomotive_cross_domain_session_url(:target_id => site._id) + + - if can?(:manage, Site) + %p.action + = link_to t('locomotive.sites_picker.new'), new_locomotive_site_url \ No newline at end of file diff --git a/app/views/locomotive/shared/actions/_contents.html.haml b/app/views/locomotive/shared/actions/_contents.html.haml new file mode 100644 index 00000000..3fd24d4e --- /dev/null +++ b/app/views/locomotive/shared/actions/_contents.html.haml @@ -0,0 +1,2 @@ +- if can? :manage, ContentType + = link_to content_tag(:em) + content_tag(:span, t('locomotive.content_types.index.new')), new_locomotive_content_type_url \ No newline at end of file diff --git a/app/views/admin/shared/menu/_contents.html.haml b/app/views/locomotive/shared/menu/_contents.html.haml similarity index 57% rename from app/views/admin/shared/menu/_contents.html.haml rename to app/views/locomotive/shared/menu/_contents.html.haml index 51dff9e2..4aa35656 100644 --- a/app/views/admin/shared/menu/_contents.html.haml +++ b/app/views/locomotive/shared/menu/_contents.html.haml @@ -1,24 +1,24 @@ -= admin_content_menu_item 'pages', admin_pages_url do += admin_content_menu_item 'pages', locomotive_pages_url do - if can? :manage, @page .header - %p= link_to t('admin.pages.index.new'), new_admin_page_url + %p= link_to t('locomotive.pages.index.new'), new_locomotive_page_url .inner - %h2!= t('admin.pages.index.lastest_items') + %h2!= t('locomotive.pages.index.lastest_items') %ul - current_site.pages.latest_updated.minimal_attributes.each do |page| %li - = link_to truncate(page.title, :length => 25), edit_admin_page_url(page) + = link_to truncate(page.title, :length => 25), edit_locomotive_page_url(page) %span= time_ago_in_words(page.updated_at) - each_content_type_menu_item do |content_type| .header - %p= link_to t('admin.contents.index.new'), new_admin_content_url(content_type.slug) + %p= link_to t('locomotive.contents.index.new'), new_locomotive_content_url(content_type.slug) - if can? :manage, content_type - %p.edit= link_to t('admin.contents.index.edit'), edit_admin_content_type_url(content_type) + %p.edit= link_to t('locomotive.contents.index.edit'), edit_locomotive_content_type_url(content_type) .inner - %h2!= t('admin.contents.index.lastest_items') + %h2!= t('locomotive.contents.index.lastest_items') %ul - content_type.latest_updated_contents.each do |content| %li @@ -30,4 +30,4 @@ %ul.big-links - content_types.each do |content_type| %li - = link_to truncate(content_type.name, :length => 20), admin_contents_url(content_type.slug) \ No newline at end of file + = link_to truncate(content_type.name, :length => 20), locomotive_contents_url(content_type.slug) \ No newline at end of file diff --git a/app/views/admin/sitemaps/show.xml.builder b/app/views/locomotive/sitemaps/show.xml.builder similarity index 100% rename from app/views/admin/sitemaps/show.xml.builder rename to app/views/locomotive/sitemaps/show.xml.builder diff --git a/app/views/admin/snippets/_form.html.haml b/app/views/locomotive/snippets/_form.html.haml similarity index 77% rename from app/views/admin/snippets/_form.html.haml rename to app/views/locomotive/snippets/_form.html.haml index abffcbf3..d8f305c0 100644 --- a/app/views/admin/snippets/_form.html.haml +++ b/app/views/locomotive/snippets/_form.html.haml @@ -11,4 +11,4 @@ %code{ :class => 'html' } = f.text_area :template .more - = link_to t('admin.image_picker.link'), admin_theme_assets_path, :id => 'image-picker-link', :class => 'picture' \ No newline at end of file + = link_to t('locomotive.image_picker.link'), admin_theme_assets_path, :id => 'image-picker-link', :class => 'picture' \ No newline at end of file diff --git a/app/views/admin/snippets/_snippet.html.haml b/app/views/locomotive/snippets/_snippet.html.haml similarity index 68% rename from app/views/admin/snippets/_snippet.html.haml rename to app/views/locomotive/snippets/_snippet.html.haml index 821fac37..8c24ce8d 100644 --- a/app/views/admin/snippets/_snippet.html.haml +++ b/app/views/locomotive/snippets/_snippet.html.haml @@ -5,4 +5,4 @@ %span!= t('.updated_at') = l snippet.updated_at, :format => :short - = link_to image_tag('admin/list/icons/trash.png'), admin_snippet_path(snippet), :class => 'remove', :confirm => t('admin.messages.confirm'), :method => :delete + = link_to image_tag('admin/list/icons/trash.png'), admin_snippet_path(snippet), :class => 'remove', :confirm => t('locomotive.messages.confirm'), :method => :delete diff --git a/app/views/locomotive/snippets/edit.html.haml b/app/views/locomotive/snippets/edit.html.haml new file mode 100644 index 00000000..79856448 --- /dev/null +++ b/app/views/locomotive/snippets/edit.html.haml @@ -0,0 +1,15 @@ +- title t('.title') + +- content_for :submenu do + = render_cell 'admin/settings_menu', :show + +- content_for :buttons do + = admin_button_tag t('locomotive.snippets.index.new'), new_locomotive_snippet_url, :class => 'new' + +%p!= t('.help', :slug => @snippet.slug) + += semantic_form_for @snippet, :url => locomotive_snippet_url(@snippet), :html => { :class => 'save-with-shortcut' } do |form| + + = render 'form', :f => form + + = render 'admin/shared/form_actions', :back_url => locomotive_theme_assets_url, :button_label => :update \ No newline at end of file diff --git a/app/views/locomotive/snippets/new.html.haml b/app/views/locomotive/snippets/new.html.haml new file mode 100644 index 00000000..4945bc9c --- /dev/null +++ b/app/views/locomotive/snippets/new.html.haml @@ -0,0 +1,12 @@ +- title t('.title') + +- content_for :submenu do + = render_cell 'admin/settings_menu', :show + +%p!= t('.help') + += semantic_form_for @snippet, :url => locomotive_snippets_url do |form| + + = render 'form', :f => form + + = render 'admin/shared/form_actions', :back_url => locomotive_theme_assets_url, :button_label => :create \ No newline at end of file diff --git a/app/views/admin/theme_assets/_asset.html.haml b/app/views/locomotive/theme_assets/_asset.html.haml similarity index 82% rename from app/views/admin/theme_assets/_asset.html.haml rename to app/views/locomotive/theme_assets/_asset.html.haml index 23a81e03..840e475e 100644 --- a/app/views/admin/theme_assets/_asset.html.haml +++ b/app/views/locomotive/theme_assets/_asset.html.haml @@ -10,4 +10,4 @@ %span.date= l asset.updated_at, :format => :short - if edit && can?(:destroy, asset) - = link_to image_tag('admin/list/icons/trash.png'), admin_theme_asset_path(asset), :class => 'remove', :confirm => t('admin.messages.confirm'), :method => :delete + = link_to image_tag('admin/list/icons/trash.png'), admin_theme_asset_path(asset), :class => 'remove', :confirm => t('locomotive.messages.confirm'), :method => :delete diff --git a/app/views/admin/theme_assets/_form.html.haml b/app/views/locomotive/theme_assets/_form.html.haml similarity index 81% rename from app/views/admin/theme_assets/_form.html.haml rename to app/views/locomotive/theme_assets/_form.html.haml index fcd9bb1e..5b284a61 100644 --- a/app/views/admin/theme_assets/_form.html.haml +++ b/app/views/locomotive/theme_assets/_form.html.haml @@ -10,7 +10,7 @@ - if allow_plain_text_editing?(@theme_asset) %span.alt - != t('admin.theme_assets.form.choose_plain_text') + != t('locomotive.theme_assets.form.choose_plain_text') - if allow_plain_text_editing?(@theme_asset) #text-selector{ :class => "selector #{'hidden' unless display_plain_text?(@theme_asset)}", :style => "#{'display: none' unless display_plain_text?(@theme_asset)}" } @@ -26,10 +26,10 @@ %code{ :class => (@theme_asset.size && @theme_asset.size > 40000 ? 'nude' : (@theme_asset.content_type || 'stylesheet')) } = f.text_area :plain_text .more - = link_to t('admin.image_picker.link'), admin_theme_assets_path, :id => 'image-picker-link', :class => 'picture' + = link_to t('locomotive.image_picker.link'), admin_theme_assets_path, :id => 'image-picker-link', :class => 'picture' %span.alt - != t('admin.theme_assets.form.choose_file') + != t('locomotive.theme_assets.form.choose_file') = f.foldable_inputs :name => :options do = f.input :folder \ No newline at end of file diff --git a/app/views/admin/theme_assets/edit.html.haml b/app/views/locomotive/theme_assets/edit.html.haml similarity index 57% rename from app/views/admin/theme_assets/edit.html.haml rename to app/views/locomotive/theme_assets/edit.html.haml index 3165d11d..73dbce3b 100644 --- a/app/views/admin/theme_assets/edit.html.haml +++ b/app/views/locomotive/theme_assets/edit.html.haml @@ -5,7 +5,7 @@ - if can?(:manage, ThemeAsset) - content_for :buttons do - = admin_button_tag t('admin.theme_assets.index.new'), new_admin_theme_asset_url, :class => 'new' + = admin_button_tag t('locomotive.theme_assets.index.new'), new_locomotive_theme_asset_url, :class => 'new' %p - if %w(image javascript stylesheet).include?(@theme_asset.content_type.to_s) @@ -14,8 +14,8 @@ != t('.help', :url => @theme_asset.source.url) -= semantic_form_for @theme_asset, :url => admin_theme_asset_url(@theme_asset), :html => { :multipart => true, :class => 'save-with-shortcut' } do |form| += semantic_form_for @theme_asset, :url => locomotive_theme_asset_url(@theme_asset), :html => { :multipart => true, :class => 'save-with-shortcut' } do |form| = render 'form', :f => form - = render 'admin/shared/form_actions', :back_url => admin_theme_assets_url, :button_label => :update \ No newline at end of file + = render 'admin/shared/form_actions', :back_url => locomotive_theme_assets_url, :button_label => :update \ No newline at end of file diff --git a/app/views/admin/theme_assets/images.html.haml b/app/views/locomotive/theme_assets/images.html.haml similarity index 70% rename from app/views/admin/theme_assets/images.html.haml rename to app/views/locomotive/theme_assets/images.html.haml index 24c0195a..e1d8f776 100644 --- a/app/views/admin/theme_assets/images.html.haml +++ b/app/views/locomotive/theme_assets/images.html.haml @@ -2,7 +2,7 @@ %h2!= t('.title') .actions - = admin_button_tag t('admin.theme_assets.index.new'), admin_theme_assets_url(:json), :class => 'button small add', :id => 'upload-link' + = admin_button_tag t('locomotive.theme_assets.index.new'), locomotive_theme_assets_url(:json), :class => 'button small add', :id => 'upload-link' - if @images.empty? %p.no-items!= t('.no_items') diff --git a/app/views/admin/theme_assets/index.html.haml b/app/views/locomotive/theme_assets/index.html.haml similarity index 66% rename from app/views/admin/theme_assets/index.html.haml rename to app/views/locomotive/theme_assets/index.html.haml index 0d311558..f3af8b74 100644 --- a/app/views/admin/theme_assets/index.html.haml +++ b/app/views/locomotive/theme_assets/index.html.haml @@ -4,15 +4,15 @@ = render_cell 'admin/settings_menu', :show - content_for :buttons do - = admin_button_tag t('admin.snippets.index.new'), new_admin_snippet_url, :class => 'new' if can?(:manage, Snippet) - = admin_button_tag :new, new_admin_theme_asset_url, :class => 'new' if can?(:manage, ThemeAsset) + = admin_button_tag t('locomotive.snippets.index.new'), new_locomotive_snippet_url, :class => 'new' if can?(:manage, Snippet) + = admin_button_tag :new, new_locomotive_theme_asset_url, :class => 'new' if can?(:manage, ThemeAsset) %p!= t('.help') - if can?(:manage, Snippet) %h3!= t('.snippets') - if @snippets.empty? - %p.no-items!= t('admin.snippets.index.no_items', :url => new_admin_snippet_url) + %p.no-items!= t('locomotive.snippets.index.no_items', :url => new_locomotive_snippet_url) - else %ul.list.theme-assets = render @snippets @@ -22,7 +22,7 @@ - if can?(:manage, ThemeAsset) %h3!= t('.css_and_js') - if @js_and_css_assets.empty? - %p.no-items!= t('.no_items', :url => new_admin_theme_asset_url) + %p.no-items!= t('.no_items', :url => new_locomotive_theme_asset_url) - else %ul.list.theme-assets = render :partial => 'asset', :collection => @js_and_css_assets @@ -31,7 +31,7 @@ %h3!= t('.images') - if @assets[:images].nil? - %p.no-items!= t('.no_items', :url => new_admin_theme_asset_url) + %p.no-items!= t('.no_items', :url => new_locomotive_theme_asset_url) - else %ul.list.theme-assets = render :partial => 'asset', :collection => @assets[:images] diff --git a/app/views/locomotive/theme_assets/new.html.haml b/app/views/locomotive/theme_assets/new.html.haml new file mode 100644 index 00000000..f42cb9bd --- /dev/null +++ b/app/views/locomotive/theme_assets/new.html.haml @@ -0,0 +1,12 @@ +- title t('.title') + +- content_for :submenu do + = render_cell 'admin/settings_menu', :show + +%p!= t('.help') + += semantic_form_for @theme_asset, :url => locomotive_theme_assets_url, :html => { :multipart => true } do |form| + + = render 'form', :f => form + + = render 'admin/shared/form_actions', :back_url => locomotive_theme_assets_url, :button_label => :create \ No newline at end of file diff --git a/config/boot.rb b/config/boot.rb deleted file mode 100644 index 8331c00d..00000000 --- a/config/boot.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'rubygems' - -# Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) - -require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) \ No newline at end of file diff --git a/config/bushido.json b/config/bushido.json deleted file mode 100644 index ce3aab1a..00000000 --- a/config/bushido.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "platform": "rails", - "platform_version": 3, - "ruby_version": "1.9.2", - "sql": false, - "mongodb": true, - "start_page": "admin/pages#guider=welcome", - "project_name": "locomotive" -} diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb deleted file mode 100644 index 59385cdf..00000000 --- a/config/initializers/backtrace_silencers.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. -# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } - -# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. -# Rails.backtrace_cleaner.remove_silencers! diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb index 23f689b6..09f75c6f 100644 --- a/config/initializers/carrierwave.rb +++ b/config/initializers/carrierwave.rb @@ -1,38 +1,38 @@ -require 'locomotive' - -# TODO: Make this store to RAILS_ROOT/permanent - -# On bushido, the app directory is destroyed on every update, so everything is lost. -# The only place this doesn't happen is the RAILS_ROOT/permanent folder. -# Also, RAILS_ROOT/permanent/store is symlinked to RAILS_ROOT/public/store on every update, -# so store your publicly-accessible files here (e.g. templates, etc.) - -CarrierWave.configure do |config| - - config.cache_dir = File.join(Rails.root, 'tmp', 'uploads') - - case Rails.env.to_sym - - when :development - config.storage = :file - config.root = File.join(Rails.root, 'public') - - when :production - if Locomotive.bushido? - config.storage = :file - config.root = File.join(Rails.root, 'public') - config.store_dir = 'store' - else - config.storage = :s3 - config.s3_access_key_id = ENV['S3_KEY_ID'] - config.s3_secret_access_key = ENV['S3_SECRET_KEY'] - config.s3_bucket = ENV['S3_BUCKET'] - # config.s3_cname = 'ENV['S3_CNAME'] - - # settings for the local filesystem - # config.storage = :file - # config.root = File.join(Rails.root, 'public') - end - end - -end unless Locomotive.engine? +# require 'locomotive' +# +# # TODO: Make this store to RAILS_ROOT/permanent +# +# # On bushido, the app directory is destroyed on every update, so everything is lost. +# # The only place this doesn't happen is the RAILS_ROOT/permanent folder. +# # Also, RAILS_ROOT/permanent/store is symlinked to RAILS_ROOT/public/store on every update, +# # so store your publicly-accessible files here (e.g. templates, etc.) +# +# CarrierWave.configure do |config| +# +# config.cache_dir = File.join(Rails.root, 'tmp', 'uploads') +# +# case Rails.env.to_sym +# +# when :development +# config.storage = :file +# config.root = File.join(Rails.root, 'public') +# +# when :production +# if Locomotive.bushido? +# config.storage = :file +# config.root = File.join(Rails.root, 'public') +# config.store_dir = 'store' +# else +# config.storage = :s3 +# config.s3_access_key_id = ENV['S3_KEY_ID'] +# config.s3_secret_access_key = ENV['S3_SECRET_KEY'] +# config.s3_bucket = ENV['S3_BUCKET'] +# # config.s3_cname = 'ENV['S3_CNAME'] +# +# # settings for the local filesystem +# # config.storage = :file +# # config.root = File.join(Rails.root, 'public') +# end +# end +# +# end unless Locomotive.engine? diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index b9439a66..ae7e0584 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -1,196 +1,196 @@ -require 'locomotive' - -# Use this hook to configure devise mailer, warden hooks and so forth. The first -# four configuration values can also be set straight in your models. -Devise.setup do |config| - # ==> Mailer Configuration - # Configure the e-mail address which will be shown in DeviseMailer. - config.mailer_sender = Locomotive.config.mailer_sender - - # Configure the class responsible to send e-mails. - # config.mailer = "Devise::Mailer" - - # ==> ORM configuration - # Load and configure the ORM. Supports :active_record (default) and - # :mongoid (bson_ext recommended) by default. Other ORMs may be - # available as additional gems. - require 'devise/orm/mongoid' - - # ==> Configuration for any authentication mechanism - # Configure which keys are used when authenticating a user. The default is - # just :email. You can configure it to use [:username, :subdomain], so for - # authenticating a user, both parameters are required. Remember that those - # parameters are used only when authenticating and not when retrieving from - # session. If you need permissions, you should implement that in a before filter. - # You can also supply a hash where the value is a boolean determining whether - # or not authentication should be aborted when the value is not present. - # config.authentication_keys = [ :email ] - - # Configure parameters from the request object used for authentication. Each entry - # given should be a request method and it will automatically be passed to the - # find_for_authentication method and considered in your model lookup. For instance, - # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. - # The same considerations mentioned for authentication_keys also apply to request_keys. - # config.request_keys = [] - - # Configure which authentication keys should be case-insensitive. - # These keys will be downcased upon creating or modifying a user and when used - # to authenticate or find a user. Default is :email. - config.case_insensitive_keys = [ :email ] - - # Tell if authentication through request.params is enabled. True by default. - # config.params_authenticatable = true - - # Tell if authentication through HTTP Basic Auth is enabled. False by default. - # config.http_authenticatable = false - - # If http headers should be returned for AJAX requests. True by default. - # config.http_authenticatable_on_xhr = true - - # The realm used in Http Basic Authentication. "Application" by default. - # config.http_authentication_realm = "Application" - - # ==> Configuration for :database_authenticatable - # For bcrypt, this is the cost for hashing the password and defaults to 10. If - # using other encryptors, it sets how many times you want the password re-encrypted. - config.stretches = 10 - - # Setup a pepper to generate the encrypted password. - # config.pepper = "de368d6a1517489510a2ae145328ff1c238f03b02da8f57032936a353835e2ca20561decfb5f7bfafad095fa73cee55b101ed11a0d0f913429d3d9bd114d810e" - - # ==> Configuration for :confirmable - # The time you want to give your user to confirm his account. During this time - # he will be able to access your application without confirming. Default is 0.days - # When confirm_within is zero, the user won't be able to sign in without confirming. - # You can use this to let your user access some features of your application - # without confirming the account, but blocking it after a certain period - # (ie 2 days). - # config.confirm_within = 2.days - - # Defines which key will be used when confirming an account - # config.confirmation_keys = [ :email ] - - # ==> Configuration for :rememberable - # The time the user will be remembered without asking for credentials again. - config.remember_for = 2.weeks - - # If true, a valid remember token can be re-used between multiple browsers. - # config.remember_across_browsers = true - - # If true, extends the user's remember period when remembered via cookie. - # config.extend_remember_period = false - - # If true, uses the password salt as remember token. This should be turned - # to false if you are not using database authenticatable. - config.use_salt_as_remember_token = true - - # Options to be passed to the created cookie. For instance, you can set - # :secure => true in order to force SSL only cookies. - # config.cookie_options = {} - - # ==> Configuration for :validatable - # Range for password length. Default is 6..128. - # config.password_length = 6..128 - - # Regex to use to validate the email address - # config.email_regexp = /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i - - # ==> Configuration for :timeoutable - # The time you want to timeout the user session without activity. After this - # time the user will be asked for credentials again. Default is 30 minutes. - # config.timeout_in = 30.minutes - - # ==> Configuration for :lockable - # Defines which strategy will be used to lock an account. - # :failed_attempts = Locks an account after a number of failed attempts to sign in. - # :none = No lock strategy. You should handle locking by yourself. - # config.lock_strategy = :failed_attempts - - # Defines which key will be used when locking and unlocking an account - # config.unlock_keys = [ :email ] - - # Defines which strategy will be used to unlock an account. - # :email = Sends an unlock link to the user email - # :time = Re-enables login after a certain amount of time (see :unlock_in below) - # :both = Enables both strategies - # :none = No unlock strategy. You should handle unlocking by yourself. - # config.unlock_strategy = :both - - # Number of authentication tries before locking an account if lock_strategy - # is failed attempts. - # config.maximum_attempts = 20 - - # Time interval to unlock the account if :time is enabled as unlock_strategy. - # config.unlock_in = 1.hour - - # ==> Configuration for :recoverable - # - # Defines which key will be used when recovering the password for an account - # config.reset_password_keys = [ :email ] - - # Time interval you can reset your password with a reset password key. - # Don't put a too small interval or your users won't have the time to - # change their passwords. - config.reset_password_within = 2.hours - - # ==> Configuration for :encryptable - # Allow you to use another encryption algorithm besides bcrypt (default). You can use - # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, - # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) - # and :restful_authentication_sha1 (then you should set stretches to 10, and copy - # REST_AUTH_SITE_KEY to pepper) - # config.encryptor = :sha1 - - # ==> Configuration for :token_authenticatable - # Defines name of the authentication token params key - # config.token_authentication_key = :auth_token - - # If true, authentication through token does not store user in session and needs - # to be supplied on each request. Useful if you are using the token as API token. - # config.stateless_token = false - - # ==> Scopes configuration - # Turn scoped views on. Before rendering "sessions/new", it will first check for - # "users/sessions/new". It's turned off by default because it's slower if you - # are using only default views. - config.scoped_views = true - - # Configure the default scope given to Warden. By default it's the first - # devise role declared in your routes (usually :user). - config.default_scope = :account - - # Configure sign_out behavior. - # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope). - # The default is true, which means any logout action will sign out all active scopes. - # config.sign_out_all_scopes = true - - # ==> Navigation configuration - # Lists the formats that should be treated as navigational. Formats like - # :html, should redirect to the sign in page when the user does not have - # access, but formats like :xml or :json, should return 401. - # - # If you have any extra navigational formats, like :iphone or :mobile, you - # should add them to the navigational formats lists. - # - # The :"*/*" and "*/*" formats below is required to match Internet - # Explorer requests. - # config.navigational_formats = [:"*/*", "*/*", :html] - - # The default HTTP method used to sign out a resource. Default is :get. - # config.sign_out_via = :get - - # ==> OmniAuth - # Add a new OmniAuth provider. Check the wiki for more information on setting - # up on your models and hooks. - # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo' - - # ==> Warden configuration - # If you want to use other strategies, that are not supported by Devise, or - # change the failure app, you can configure them inside the config.warden block. - # - # config.warden do |manager| - # manager.failure_app = AnotherApp - # manager.intercept_401 = false - # manager.default_strategies(:scope => :user).unshift :some_external_strategy - # end -end +# require 'locomotive' +# +# # Use this hook to configure devise mailer, warden hooks and so forth. The first +# # four configuration values can also be set straight in your models. +# Devise.setup do |config| +# # ==> Mailer Configuration +# # Configure the e-mail address which will be shown in DeviseMailer. +# config.mailer_sender = Locomotive.config.mailer_sender +# +# # Configure the class responsible to send e-mails. +# # config.mailer = "Devise::Mailer" +# +# # ==> ORM configuration +# # Load and configure the ORM. Supports :active_record (default) and +# # :mongoid (bson_ext recommended) by default. Other ORMs may be +# # available as additional gems. +# require 'devise/orm/mongoid' +# +# # ==> Configuration for any authentication mechanism +# # Configure which keys are used when authenticating a user. The default is +# # just :email. You can configure it to use [:username, :subdomain], so for +# # authenticating a user, both parameters are required. Remember that those +# # parameters are used only when authenticating and not when retrieving from +# # session. If you need permissions, you should implement that in a before filter. +# # You can also supply a hash where the value is a boolean determining whether +# # or not authentication should be aborted when the value is not present. +# # config.authentication_keys = [ :email ] +# +# # Configure parameters from the request object used for authentication. Each entry +# # given should be a request method and it will automatically be passed to the +# # find_for_authentication method and considered in your model lookup. For instance, +# # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. +# # The same considerations mentioned for authentication_keys also apply to request_keys. +# # config.request_keys = [] +# +# # Configure which authentication keys should be case-insensitive. +# # These keys will be downcased upon creating or modifying a user and when used +# # to authenticate or find a user. Default is :email. +# config.case_insensitive_keys = [ :email ] +# +# # Tell if authentication through request.params is enabled. True by default. +# # config.params_authenticatable = true +# +# # Tell if authentication through HTTP Basic Auth is enabled. False by default. +# # config.http_authenticatable = false +# +# # If http headers should be returned for AJAX requests. True by default. +# # config.http_authenticatable_on_xhr = true +# +# # The realm used in Http Basic Authentication. "Application" by default. +# # config.http_authentication_realm = "Application" +# +# # ==> Configuration for :database_authenticatable +# # For bcrypt, this is the cost for hashing the password and defaults to 10. If +# # using other encryptors, it sets how many times you want the password re-encrypted. +# config.stretches = 10 +# +# # Setup a pepper to generate the encrypted password. +# # config.pepper = "de368d6a1517489510a2ae145328ff1c238f03b02da8f57032936a353835e2ca20561decfb5f7bfafad095fa73cee55b101ed11a0d0f913429d3d9bd114d810e" +# +# # ==> Configuration for :confirmable +# # The time you want to give your user to confirm his account. During this time +# # he will be able to access your application without confirming. Default is 0.days +# # When confirm_within is zero, the user won't be able to sign in without confirming. +# # You can use this to let your user access some features of your application +# # without confirming the account, but blocking it after a certain period +# # (ie 2 days). +# # config.confirm_within = 2.days +# +# # Defines which key will be used when confirming an account +# # config.confirmation_keys = [ :email ] +# +# # ==> Configuration for :rememberable +# # The time the user will be remembered without asking for credentials again. +# config.remember_for = 2.weeks +# +# # If true, a valid remember token can be re-used between multiple browsers. +# # config.remember_across_browsers = true +# +# # If true, extends the user's remember period when remembered via cookie. +# # config.extend_remember_period = false +# +# # If true, uses the password salt as remember token. This should be turned +# # to false if you are not using database authenticatable. +# config.use_salt_as_remember_token = true +# +# # Options to be passed to the created cookie. For instance, you can set +# # :secure => true in order to force SSL only cookies. +# # config.cookie_options = {} +# +# # ==> Configuration for :validatable +# # Range for password length. Default is 6..128. +# # config.password_length = 6..128 +# +# # Regex to use to validate the email address +# # config.email_regexp = /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i +# +# # ==> Configuration for :timeoutable +# # The time you want to timeout the user session without activity. After this +# # time the user will be asked for credentials again. Default is 30 minutes. +# # config.timeout_in = 30.minutes +# +# # ==> Configuration for :lockable +# # Defines which strategy will be used to lock an account. +# # :failed_attempts = Locks an account after a number of failed attempts to sign in. +# # :none = No lock strategy. You should handle locking by yourself. +# # config.lock_strategy = :failed_attempts +# +# # Defines which key will be used when locking and unlocking an account +# # config.unlock_keys = [ :email ] +# +# # Defines which strategy will be used to unlock an account. +# # :email = Sends an unlock link to the user email +# # :time = Re-enables login after a certain amount of time (see :unlock_in below) +# # :both = Enables both strategies +# # :none = No unlock strategy. You should handle unlocking by yourself. +# # config.unlock_strategy = :both +# +# # Number of authentication tries before locking an account if lock_strategy +# # is failed attempts. +# # config.maximum_attempts = 20 +# +# # Time interval to unlock the account if :time is enabled as unlock_strategy. +# # config.unlock_in = 1.hour +# +# # ==> Configuration for :recoverable +# # +# # Defines which key will be used when recovering the password for an account +# # config.reset_password_keys = [ :email ] +# +# # Time interval you can reset your password with a reset password key. +# # Don't put a too small interval or your users won't have the time to +# # change their passwords. +# config.reset_password_within = 2.hours +# +# # ==> Configuration for :encryptable +# # Allow you to use another encryption algorithm besides bcrypt (default). You can use +# # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, +# # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) +# # and :restful_authentication_sha1 (then you should set stretches to 10, and copy +# # REST_AUTH_SITE_KEY to pepper) +# # config.encryptor = :sha1 +# +# # ==> Configuration for :token_authenticatable +# # Defines name of the authentication token params key +# # config.token_authentication_key = :auth_token +# +# # If true, authentication through token does not store user in session and needs +# # to be supplied on each request. Useful if you are using the token as API token. +# # config.stateless_token = false +# +# # ==> Scopes configuration +# # Turn scoped views on. Before rendering "sessions/new", it will first check for +# # "users/sessions/new". It's turned off by default because it's slower if you +# # are using only default views. +# config.scoped_views = true +# +# # Configure the default scope given to Warden. By default it's the first +# # devise role declared in your routes (usually :user). +# config.default_scope = :account +# +# # Configure sign_out behavior. +# # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope). +# # The default is true, which means any logout action will sign out all active scopes. +# # config.sign_out_all_scopes = true +# +# # ==> Navigation configuration +# # Lists the formats that should be treated as navigational. Formats like +# # :html, should redirect to the sign in page when the user does not have +# # access, but formats like :xml or :json, should return 401. +# # +# # If you have any extra navigational formats, like :iphone or :mobile, you +# # should add them to the navigational formats lists. +# # +# # The :"*/*" and "*/*" formats below is required to match Internet +# # Explorer requests. +# # config.navigational_formats = [:"*/*", "*/*", :html] +# +# # The default HTTP method used to sign out a resource. Default is :get. +# # config.sign_out_via = :get +# +# # ==> OmniAuth +# # Add a new OmniAuth provider. Check the wiki for more information on setting +# # up on your models and hooks. +# # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo' +# +# # ==> Warden configuration +# # If you want to use other strategies, that are not supported by Devise, or +# # change the failure app, you can configure them inside the config.warden block. +# # +# # config.warden do |manager| +# # manager.failure_app = AnotherApp +# # manager.intercept_401 = false +# # manager.default_strategies(:scope => :user).unshift :some_external_strategy +# # end +# end diff --git a/config/initializers/dragonfly.rb b/config/initializers/dragonfly.rb index 7b9a6a2b..6a8c6ad2 100644 --- a/config/initializers/dragonfly.rb +++ b/config/initializers/dragonfly.rb @@ -1,31 +1,31 @@ -require 'locomotive' - -unless Locomotive.engine? - - require 'dragonfly' - - ## initialize Dragonfly ## - - app = Dragonfly[:images] - app.configure_with(:rails) - app.configure_with(:imagemagick) - - ## configure it ## - - Dragonfly[:images].configure do |c| - # Convert absolute location needs to be specified - # to avoid issues with Phusion Passenger not using $PATH - convert = `which convert`.strip.presence || "/usr/local/bin/convert" - c.convert_command = convert - c.identify_command = convert - - c.allow_fetch_url = true - c.allow_fetch_file = true - - c.url_format = '/images/dynamic/:job/:basename.:format' - end - -end - - - +# require 'locomotive' +# +# unless Locomotive.engine? +# +# require 'dragonfly' +# +# ## initialize Dragonfly ## +# +# app = Dragonfly[:images] +# app.configure_with(:rails) +# app.configure_with(:imagemagick) +# +# ## configure it ## +# +# Dragonfly[:images].configure do |c| +# # Convert absolute location needs to be specified +# # to avoid issues with Phusion Passenger not using $PATH +# convert = `which convert`.strip.presence || "/usr/local/bin/convert" +# c.convert_command = convert +# c.identify_command = convert +# +# c.allow_fetch_url = true +# c.allow_fetch_file = true +# +# c.url_format = '/images/dynamic/:job/:basename.:format' +# end +# +# end +# +# +# diff --git a/config/initializers/formtastic.rb b/config/initializers/formtastic.rb index 985d11ae..0d55e881 100644 --- a/config/initializers/formtastic.rb +++ b/config/initializers/formtastic.rb @@ -1,5 +1,5 @@ -require 'formtastic' -require 'locomotive/misc_form_builder' -Formtastic::SemanticFormHelper.builder = Locomotive::MiscFormBuilder -Formtastic::SemanticFormBuilder.i18n_lookups_by_default = true - +# require 'formtastic' +# require 'locomotive/misc_form_builder' +# Formtastic::SemanticFormHelper.builder = Locomotive::MiscFormBuilder +# Formtastic::SemanticFormBuilder.i18n_lookups_by_default = true +# diff --git a/config/initializers/haml.rb b/config/initializers/haml.rb index df0b4de4..31febf8b 100644 --- a/config/initializers/haml.rb +++ b/config/initializers/haml.rb @@ -1 +1 @@ -Haml::Template.options[:ugly] = true # improve performance in dev \ No newline at end of file +# Haml::Template.options[:ugly] = true # improve performance in dev \ No newline at end of file diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index b684974c..436d3e60 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,14 +1,14 @@ -# Be sure to restart your server when you modify this file. - -# Add new inflection rules using the following format -# (all these examples are active by default): +# # Be sure to restart your server when you modify this file. +# +# # Add new inflection rules using the following format +# # (all these examples are active by default): +# # ActiveSupport::Inflector.inflections do |inflect| +# # inflect.plural /^(ox)$/i, '\1en' +# # inflect.singular /^(ox)en/i, '\1' +# # inflect.irregular 'person', 'people' +# # inflect.uncountable %w( fish sheep ) +# # end +# # ActiveSupport::Inflector.inflections do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' -# inflect.uncountable %w( fish sheep ) # end - -ActiveSupport::Inflector.inflections do |inflect| -end - +# diff --git a/config/initializers/locomotive.rb b/config/initializers/locomotive.rb index c61fb70d..6809a2ba 100644 --- a/config/initializers/locomotive.rb +++ b/config/initializers/locomotive.rb @@ -1,82 +1,82 @@ -require File.dirname(__FILE__) + '/../../lib/locomotive.rb' - -Locomotive.configure do |config| - - # A single locomotive instance can serve one single site or many. - # If you want to run many different websites, you will have to specify - # your own domain name (ex: locomotivehosting.com). - # - # Ex: - # config.multi_sites do |multi_sites| - # # each new website you add will have a default entry based on a subdomain - # # and the multi_site_domain value (ex: website_1.locomotivehosting.com). - # multi_sites.domain = 'example.com' #'myhostingplatform.com' - # - # # define the reserved subdomains - # # Ex: - # multi_sites.reserved_subdomains = %w(www admin email blog webmail mail support help site sites) - # end - config.multi_sites = false - - # configure the hosting target for the production environment. Locomotive can be installed in: - # - your own server - # - Heroku (you need to create an account in this case) - # - Bushi.do (see the bushi.do website for more explanations) - # - # the possible options are: server, heroku, bushido or auto (default) - # if you select 'auto', Locomotive will look after specific ENV variables to check - # the matching platform (Heroku and Bushido set their own ENV variables). - # - config.hosting = :auto - - # In case you host Locomotive in Heroku, the engine uses the heroku api to add / remove domains. - # there are 2 ways of passing heroku credentials to Locomotive - # - from ENV variables: HEROKU_LOGIN & HEROKU_PASSWORD - # - from this file, see the example below and uncomment it if needed - # config.heroku = { - # :login => '', - # :password => '' - # } - - # Locomotive uses the DelayedJob gem for the site import module. - # In case you want to deploy to Heroku, you will have to pay for an extra dyno. - # If you do not mind about importing theme without DelayedJob, disable it. - # - # Warning: this option is not used if you deploy on bushi.do and we set automatically the value to true. - config.delayed_job = false - - # configure how many items we display in sub menu in the "Contents" section. - # config.lastest_items_nb = 5 - - # default locale (for now, only en, de, fr, pt-BR and it are supported) - config.default_locale = :en - - # tell if logs are enabled. Useful for debug purpose. - config.enable_logs = true - - # Configure the e-mail address which will be shown in the DeviseMailer, NotificationMailer, ...etc - # if you do not put the domain name in the email, Locomotive will take the default domain name depending - # on your deployment target (server, Heroku, Bushido, ...etc) - # - # Ex: - # config.mailer_sender = 'support' - # # => 'support@heroku.com' (Heroku), 'support@bushi.do' (Bushido), 'support@example.com' (Dev) or 'support@' (Multi-sites) - config.mailer_sender = 'support' - - # allow apps using the engine to add their own Liquid drops, variables and similar available - # in Liquid templates, extending the assigns used while rendering. - # follow the Dependency Injection pattern - # config.context_assign_extensions = {} - - # Rack-cache settings, mainly used for the inline resizing image module. Default options: - # config.rack_cache = { - # :verbose => true, - # :metastore => URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/meta"), # URI encoded in case of spaces - # :entitystore => URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/body") - # } - # If you do want to disable it for good, just use the following syntax - # config.rack_cache = false - # - # Note: by default, rack/cache is disabled in the Heroku platform - -end unless Locomotive.engine? || Rails.env.test? +# require File.dirname(__FILE__) + '/../../lib/locomotive.rb' +# +# Locomotive.configure do |config| +# +# # A single locomotive instance can serve one single site or many. +# # If you want to run many different websites, you will have to specify +# # your own domain name (ex: locomotivehosting.com). +# # +# # Ex: +# # config.multi_sites do |multi_sites| +# # # each new website you add will have a default entry based on a subdomain +# # # and the multi_site_domain value (ex: website_1.locomotivehosting.com). +# # multi_sites.domain = 'example.com' #'myhostingplatform.com' +# # +# # # define the reserved subdomains +# # # Ex: +# # multi_sites.reserved_subdomains = %w(www admin email blog webmail mail support help site sites) +# # end +# config.multi_sites = false +# +# # configure the hosting target for the production environment. Locomotive can be installed in: +# # - your own server +# # - Heroku (you need to create an account in this case) +# # - Bushi.do (see the bushi.do website for more explanations) +# # +# # the possible options are: server, heroku, bushido or auto (default) +# # if you select 'auto', Locomotive will look after specific ENV variables to check +# # the matching platform (Heroku and Bushido set their own ENV variables). +# # +# config.hosting = :auto +# +# # In case you host Locomotive in Heroku, the engine uses the heroku api to add / remove domains. +# # there are 2 ways of passing heroku credentials to Locomotive +# # - from ENV variables: HEROKU_LOGIN & HEROKU_PASSWORD +# # - from this file, see the example below and uncomment it if needed +# # config.heroku = { +# # :login => '', +# # :password => '' +# # } +# +# # Locomotive uses the DelayedJob gem for the site import module. +# # In case you want to deploy to Heroku, you will have to pay for an extra dyno. +# # If you do not mind about importing theme without DelayedJob, disable it. +# # +# # Warning: this option is not used if you deploy on bushi.do and we set automatically the value to true. +# config.delayed_job = false +# +# # configure how many items we display in sub menu in the "Contents" section. +# # config.lastest_items_nb = 5 +# +# # default locale (for now, only en, de, fr, pt-BR and it are supported) +# config.default_locale = :en +# +# # tell if logs are enabled. Useful for debug purpose. +# config.enable_logs = true +# +# # Configure the e-mail address which will be shown in the DeviseMailer, NotificationMailer, ...etc +# # if you do not put the domain name in the email, Locomotive will take the default domain name depending +# # on your deployment target (server, Heroku, Bushido, ...etc) +# # +# # Ex: +# # config.mailer_sender = 'support' +# # # => 'support@heroku.com' (Heroku), 'support@bushi.do' (Bushido), 'support@example.com' (Dev) or 'support@' (Multi-sites) +# config.mailer_sender = 'support' +# +# # allow apps using the engine to add their own Liquid drops, variables and similar available +# # in Liquid templates, extending the assigns used while rendering. +# # follow the Dependency Injection pattern +# # config.context_assign_extensions = {} +# +# # Rack-cache settings, mainly used for the inline resizing image module. Default options: +# # config.rack_cache = { +# # :verbose => true, +# # :metastore => URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/meta"), # URI encoded in case of spaces +# # :entitystore => URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/body") +# # } +# # If you do want to disable it for good, just use the following syntax +# # config.rack_cache = false +# # +# # Note: by default, rack/cache is disabled in the Heroku platform +# +# end unless Locomotive.engine? || Rails.env.test? diff --git a/config/initializers/rspec_generator.rb b/config/initializers/rspec_generator.rb index 514eba18..7a56a129 100644 --- a/config/initializers/rspec_generator.rb +++ b/config/initializers/rspec_generator.rb @@ -1,8 +1,8 @@ -if Rails.env.test? && defined?(Locomotive::Application) # does not need it for the engine version - Locomotive::Application.configure do - config.generators do |g| - g.integration_tool :rspec - g.test_framework :rspec - end - end -end +# if Rails.env.test? && defined?(Locomotive::Application) # does not need it for the engine version +# Locomotive::Application.configure do +# config.generators do |g| +# g.integration_tool :rspec +# g.test_framework :rspec +# end +# end +# end diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index a127accc..814df916 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -1,10 +1,10 @@ -# Be sure to restart your server when you modify this file. -require 'digest/sha1' - -# Your secret key for verifying the integrity of signed cookies. -# If you change this key, all old signed cookies will become invalid! -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -token = ENV['BUSHIDO_SALT'] || 'aa84844b97e90edda8e005a686d82c3bef1f8e20a1255301f1d0886fc592a45ef2393d64b0c3d3ea858b1f6406ad6f15305666264716a79fcfa17de93ad0d69d' - -Rails.application.config.secret_token = Digest::SHA1.hexdigest(token) +# # Be sure to restart your server when you modify this file. +# require 'digest/sha1' +# +# # Your secret key for verifying the integrity of signed cookies. +# # If you change this key, all old signed cookies will become invalid! +# # Make sure the secret is at least 30 characters and all random, +# # no regular words or you'll be exposed to dictionary attacks. +# token = ENV['BUSHIDO_SALT'] || 'aa84844b97e90edda8e005a686d82c3bef1f8e20a1255301f1d0886fc592a45ef2393d64b0c3d3ea858b1f6406ad6f15305666264716a79fcfa17de93ad0d69d' +# +# Rails.application.config.secret_token = Digest::SHA1.hexdigest(token) diff --git a/config/initializers/will_paginate.rb b/config/initializers/will_paginate.rb index dfed3fe9..e78a36c5 100644 --- a/config/initializers/will_paginate.rb +++ b/config/initializers/will_paginate.rb @@ -1 +1 @@ -require 'will_paginate/array' +# require 'will_paginate/array' diff --git a/config/locales/admin_ui.de.yml b/config/locales/admin_ui.de.yml index 56910ae0..6c8aa5e4 100644 --- a/config/locales/admin_ui.de.yml +++ b/config/locales/admin_ui.de.yml @@ -1,5 +1,5 @@ de: - admin: + locomotive: buttons: login: Einloggen send_password: Senden diff --git a/config/locales/admin_ui.en.yml b/config/locales/admin_ui.en.yml index 511461d4..e3b60fb6 100644 --- a/config/locales/admin_ui.en.yml +++ b/config/locales/admin_ui.en.yml @@ -1,5 +1,5 @@ en: - admin: + locomotive: buttons: login: Log in send_password: Send @@ -152,7 +152,7 @@ en: memberships: roles: - admin: Administrator + locomotive: Administrator designer: Designer author: Author new: diff --git a/config/locales/admin_ui.es.yml b/config/locales/admin_ui.es.yml index 656a5675..f83284a9 100644 --- a/config/locales/admin_ui.es.yml +++ b/config/locales/admin_ui.es.yml @@ -1,5 +1,5 @@ es: - admin: + locomotive: errors: "500": title: Error de Aplicación @@ -150,7 +150,7 @@ es: memberships: roles: - admin: Administrador + locomotive: Administrador designer: Diseñador author: Autor new: diff --git a/config/locales/admin_ui.fr.yml b/config/locales/admin_ui.fr.yml index 067f4398..8c4adb40 100644 --- a/config/locales/admin_ui.fr.yml +++ b/config/locales/admin_ui.fr.yml @@ -1,5 +1,5 @@ fr: - admin: + locomotive: errors: "500": title: Erreur applicative @@ -153,7 +153,7 @@ fr: memberships: roles: - admin: Administrateur + locomotive: Administrateur designer: Designeur author: Auteur new: diff --git a/config/locales/admin_ui.it.yml b/config/locales/admin_ui.it.yml index a03dc757..5b599566 100644 --- a/config/locales/admin_ui.it.yml +++ b/config/locales/admin_ui.it.yml @@ -1,5 +1,5 @@ it: - admin: + locomotive: buttons: login: Entra send_password: Invia @@ -150,7 +150,7 @@ it: memberships: roles: - admin: Amministratore + locomotive: Amministratore designer: Designer author: Autore new: diff --git a/config/locales/admin_ui.nl.yml b/config/locales/admin_ui.nl.yml index 15dcc3a0..036194cb 100644 --- a/config/locales/admin_ui.nl.yml +++ b/config/locales/admin_ui.nl.yml @@ -1,5 +1,5 @@ nl: - admin: + locomotive: buttons: login: Inloggen send_password: Verstuur diff --git a/config/locales/admin_ui.no.yml b/config/locales/admin_ui.no.yml index 3e6ac46d..0402a87e 100644 --- a/config/locales/admin_ui.no.yml +++ b/config/locales/admin_ui.no.yml @@ -1,5 +1,5 @@ "no": - admin: + locomotive: buttons: login: Logg inn send_password: Send @@ -152,7 +152,7 @@ memberships: roles: - admin: Administrator + locomotive: Administrator designer: Designer author: Forfatter new: diff --git a/config/locales/admin_ui.pt-BR.yml b/config/locales/admin_ui.pt-BR.yml index 267806d9..4dd16446 100644 --- a/config/locales/admin_ui.pt-BR.yml +++ b/config/locales/admin_ui.pt-BR.yml @@ -1,5 +1,5 @@ pt-BR: - admin: + locomotive: buttons: login: Entrar send_password: Enviar diff --git a/config/locales/admin_ui.ru.yml b/config/locales/admin_ui.ru.yml index 8ec013c5..527fbc87 100644 --- a/config/locales/admin_ui.ru.yml +++ b/config/locales/admin_ui.ru.yml @@ -1,5 +1,5 @@ ru: - admin: + locomotive: buttons: login: Войти send_password: Отправить @@ -152,7 +152,7 @@ ru: memberships: roles: - admin: Администратор + locomotive: Администратор designer: Дизайнер author: Автор new: diff --git a/config/locales/devise.de.yml b/config/locales/devise.de.yml index aae91399..de0d8c47 100644 --- a/config/locales/devise.de.yml +++ b/config/locales/devise.de.yml @@ -7,7 +7,7 @@ de: devise: failure: - admin: + locomotive: unauthenticated: 'Du musst dich einloggen oder registrieren bevor es weiter geht.' unconfirmed: 'Du musst deinen Account aktivieren bevor es weiter geht.' locked: 'Dein Account ist gesperrt.' @@ -16,34 +16,34 @@ de: timeout: 'Deine Session ist abgelaufe. Bitte logge dich erneut ein, dann geht es weiter.' inactive: 'Dein Account wurde noch nicht aktiviert.' sessions: - admin: + locomotive: signed_in: 'Willkommen zu Hause!' signed_out: 'Bis zum nächsten Mal.' passwords: - admin: + locomotive: send_instructions: 'Du bekommst in ein paar Minuten eine Email mit einer genauen Anleitung, wie du dein Passwort zurücksetzen kannst.' updated: 'Dein Passwort wurde erfolgreich geändert. Du bist nun eingeloggt.' confirmations: - admin: + locomotive: send_instructions: 'Du bekommst in ein paar Minuten eine Email mit einer genauen Anleitung, wie du deinen Account aktivieren kannst.' confirmed: 'Dein Account wurde erfolgreich aktiviert. Du bist nun eingeloggt.' registrations: - admin: + locomotive: signed_up: 'Du hast dich erfolgreich registriert.' updated: 'Du hast deinen Account erfolgreich aktualisiert.' destroyed: 'Tschüss! Dein Account wurder erfolgreich gelöscht. Hoffentlich sehen wir dich bald wieder!' unlocks: - admin: + locomotive: send_instructions: 'Du bekommst in ein paar Minuten eine Email mit einer genauen Anleitung, wie du deinen Account entsperren kannst.' unlocked: 'Dein Account wurder erfolgreich entsperrt. Du bist nun eingeloggt.' mailer: - admin: + locomotive: confirmation_instructions: 'Anleitung zur Aktivierung' reset_password_instructions: 'Anleitung zum Zurücksetzen deines Passworts' unlock_instructions: 'Anleitung zur Entsperrung' - admin: + locomotive: mailer: common: hello: Hallo diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index 95f096d6..bba3fb40 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -7,7 +7,7 @@ en: devise: failure: - admin: + locomotive: unauthenticated: 'You need to sign in or sign up before continuing.' unconfirmed: 'You have to confirm your account before continuing.' locked: 'Your account is locked.' @@ -17,34 +17,34 @@ en: timeout: 'Your session expired, please sign in again to continue.' inactive: 'Your account was not activated yet.' sessions: - admin: + locomotive: signed_in: 'Signed in successfully.' signed_out: 'Signed out successfully.' passwords: - admin: + locomotive: send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.' updated: 'Your password was changed successfully. You are now signed in.' confirmations: - admin: + locomotive: send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.' confirmed: 'Your account was successfully confirmed. You are now signed in.' registrations: - admin: + locomotive: signed_up: 'You have signed up successfully.' updated: 'You updated your account successfully.' destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.' unlocks: - admin: + locomotive: send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.' unlocked: 'Your account was successfully unlocked. You are now signed in.' mailer: - admin: + locomotive: confirmation_instructions: 'Confirmation instructions' reset_password_instructions: 'Reset password instructions' unlock_instructions: 'Unlock Instructions' - admin: + locomotive: mailer: common: hello: Hello diff --git a/config/locales/devise.es.yml b/config/locales/devise.es.yml index b8f05b40..5b1a9880 100644 --- a/config/locales/devise.es.yml +++ b/config/locales/devise.es.yml @@ -7,7 +7,7 @@ es: devise: failure: - admin: + locomotive: unauthenticated: 'Debe crear una cuenta o acceder con una cuenta existente para continuar.' unconfirmed: 'Debe confirmar su cuenta para continuar.' locked: 'Su cuenta está bloqueada.' @@ -17,34 +17,34 @@ es: timeout: 'Su sesión ha expirado. Por favor inicie una nueva sesión para continuar.' inactive: 'Su cuenta no está activa.' sessions: - admin: + locomotive: signed_in: 'Sesión iniciada con éxito.' signed_out: 'Sesión finalizada con éxito.' passwords: - admin: + locomotive: send_instructions: 'Recibirá un email con instrucciones para resetear su clave en unos minutos.' updated: 'Su clave ha sido cambiada. Se ha iniciado una sesión.' confirmations: - admin: + locomotive: send_instructions: 'Recibirá un email con instrucciones para activar su clave en unos minutos.' confirmed: 'Su cuenta ha sido activada. Se ha iniciado una sesión.' registrations: - admin: + locomotive: signed_up: 'Creación de cuenta realizada con éxito.' updated: 'Se ha actualizado su cuenta con éxito.' destroyed: '¡Hasta pronto! Su cuenta ha sido eliminada. Esperamos verle de nuevo.' unlocks: - admin: + locomotive: send_instructions: 'Recibirá un email con instrucciones para desbloquear su cuenta en unos minutos.' unlocked: 'Su cuenta ha sido desbloqueada. Se ha iniciado una sesión.' mailer: - admin: + locomotive: confirmation_instructions: 'Instrucciones de activación' reset_password_instructions: 'Instrucciones de reseteo de clave' unlock_instructions: 'Instrucciones de desbloqueo' - admin: + locomotive: mailer: common: hello: Hola diff --git a/config/locales/devise.fr.yml b/config/locales/devise.fr.yml index 56bc40bf..47662ae6 100644 --- a/config/locales/devise.fr.yml +++ b/config/locales/devise.fr.yml @@ -7,7 +7,7 @@ fr: devise: failure: - admin: + locomotive: unauthenticated: "Vous devez vous connecter ou vous inscrire avant de poursuivre." unconfirmed: "Vous devez confirmer votre compte avant de poursuivre." locked: "Votre compte a été vérrouillé." @@ -16,33 +16,33 @@ fr: timeout: "Votre session a expiré, veuillez vous reconnecter pour poursuivre." inactive: "Votre compte n'a pas encore été activé." sessions: - admin: + locomotive: signed_in: "Connexion réussie." signed_out: "Déconnexion réussie." passwords: - admin: + locomotive: send_instructions: "Vous allez recevoir un email avec les instructions pour réinitialiser votre mot de passe dans quelques minutes." updated: "Votre mot de passe a été modifié avec succès. Vous êtes maintenant connecté." confirmations: - admin: + locomotive: send_instructions: "Vous allez recevoir un email avec les instruction pour confirmer votre compte dans quelques minutes." confirmed: "Votre compte a été confirmé avec succès." registrations: - admin: + locomotive: signed_up: "Vous vous êtes inscrit avec succès. Vous allez recevoir les instructions de confirmation par email." updated: "Vous avez mis à jour votre compte avec succès." destroyed: "Au revoir. Votre compte a été fermé avec succès. Nous espérons vous revoir bientôt." unlocks: - admin: + locomotive: send_instructions: "Vous allez recevoir un email avec les instructions pour déverrouiller votre compte dans quelques minutes." unlocked: "Votre compte a été déverrouillé avec succès. Vous êtes maintenant connecté." mailer: - admin: + locomotive: confirmation_instructions: "Instructions pour la confirmation" reset_password_instructions: "Instructions pour la réinitialisation du mot de passe" unlock_instructions: "Instructions pour le déverrouillage" - admin: + locomotive: mailer: common: hello: Bienvenu(e) diff --git a/config/locales/devise.it.yml b/config/locales/devise.it.yml index 3a15ba0e..d943d1f8 100644 --- a/config/locales/devise.it.yml +++ b/config/locales/devise.it.yml @@ -7,7 +7,7 @@ it: devise: failure: - admin: + locomotive: unauthenticated: "E' necessario accedere o registrati prima di continuare." unconfirmed: "E' necessario confermare l'account prima di continuare." locked: 'Il tuo account è bloccato.' @@ -17,34 +17,34 @@ it: timeout: 'La tua sessione è scaduta, si prega di accedere nuovamente per continuare.' inactive: 'Il tuo account non è stato ancora attivato.' sessions: - admin: + locomotive: signed_in: 'Login eseguito con successo.' signed_out: 'Logout eseguito con successo.' passwords: - admin: + locomotive: send_instructions: 'Entro qualche minuti riceverai una email con le istruzioni su come reimpostare la password.' updated: 'La tua password è stata cambiata con successo. Ora sei collegato.' confirmations: - admin: + locomotive: send_instructions: 'Entro qualche minuti riceverai un messaggio email con le istruzioni per confermare il tuo account.' confirmed: 'Il tuo account è stato confermato. Ora sei collegato.' registrations: - admin: + locomotive: signed_up: 'Registrazione eseguita correttamente.' updated: 'Il tuo account è stato aggiornato.' destroyed: "Arrivederci! L'account è stato eliminato. Speriamo di rivederci presto." unlocks: - admin: + locomotive: send_instructions: 'Entro qualche minuti riceverai un messaggio email con le istruzioni per sbloccare il tuo account.' unlocked: 'Il tuo account è stato correttamente sbloccato. Ora sei collegato.' mailer: - admin: + locomotive: confirmation_instructions: 'Istruzioni per la conferma' reset_password_instructions: 'Istruzioni per reimpostare la password' unlock_instructions: "Istruzioni per lo sblocco dell'account" - admin: + locomotive: mailer: common: hello: Ciao diff --git a/config/locales/devise.nl.yml b/config/locales/devise.nl.yml index 4a205882..b01f6479 100644 --- a/config/locales/devise.nl.yml +++ b/config/locales/devise.nl.yml @@ -7,7 +7,7 @@ en: devise: failure: - admin: + locomotive: unauthenticated: 'You need to sign in or sign up before continuing.' unconfirmed: 'You have to confirm your account before continuing.' locked: 'Your account is locked.' @@ -17,34 +17,34 @@ en: timeout: 'Your session expired, please sign in again to continue.' inactive: 'Your account was not activated yet.' sessions: - admin: + locomotive: signed_in: 'Signed in successfully.' signed_out: 'Signed out successfully.' passwords: - admin: + locomotive: send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.' updated: 'Your password was changed successfully. You are now signed in.' confirmations: - admin: + locomotive: send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.' confirmed: 'Your account was successfully confirmed. You are now signed in.' registrations: - admin: + locomotive: signed_up: 'You have signed up successfully.' updated: 'You updated your account successfully.' destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.' unlocks: - admin: + locomotive: send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.' unlocked: 'Your account was successfully unlocked. You are now signed in.' mailer: - admin: + locomotive: confirmation_instructions: 'Confirmation instructions' reset_password_instructions: 'Reset password instructions' unlock_instructions: 'Unlock Instructions' - admin: + locomotive: mailer: common: hello: Hello diff --git a/config/locales/devise.no.yml b/config/locales/devise.no.yml index c1d56763..b06f795d 100644 --- a/config/locales/devise.no.yml +++ b/config/locales/devise.no.yml @@ -7,7 +7,7 @@ devise: failure: - admin: + locomotive: unauthenticated: 'Du må logge inn eller registrere deg før du kan fortsette.' unconfirmed: 'Kontoen må aktiveres før du kan fortsette.' locked: 'Brukerkontoen er sperret.' @@ -17,34 +17,34 @@ timeout: 'Innloggingen har utløpt. Logg inn på nytt for å fortsette.' inactive: 'Kontoen din er ikke aktivert ennå.' sessions: - admin: + locomotive: signed_in: 'Du er nå logget inn.' signed_out: 'Du har blitt logget ut.' passwords: - admin: + locomotive: send_instructions: 'Du vil motta en epost med instruksjoner for hvordan du kan tilbakestille passordet i løpet av kort tid.' updated: 'Passordendringen var vellykket. Du er nå logget inn.' confirmations: - admin: + locomotive: send_instructions: 'Du vil motta en epost med instrusksjoner for hvordan brukerkontoen aktiveres i løpet av kort tid.' confirmed: 'Aktiveringen av brukerkontoen var vellykket. Du er nå logget inn.' registrations: - admin: + locomotive: signed_up: 'Registreringen var vellykket.' updated: 'Oppdateringen av kontoen var vellykket' destroyed: 'Kontoen din har blitt kansellert. Vi håper å se deg igjen en annen gang.' unlocks: - admin: + locomotive: send_instructions: 'Du vil motta en epost med instruksjoner for hvordan du kan åpne kontoen i løpet av kort tid.' unlocked: 'Kontoen har blitt åpnet og du er nå logget inn.' mailer: - admin: + locomotive: confirmation_instructions: 'Bekreftelsesinstrukser' reset_password_instructions: 'Instrukser for tilbakestilling av passord' unlock_instructions: 'Instrukser for åpning' - admin: + locomotive: mailer: common: hello: Hallo diff --git a/config/locales/devise.pt-BR.yml b/config/locales/devise.pt-BR.yml index 6cff714d..02acd777 100644 --- a/config/locales/devise.pt-BR.yml +++ b/config/locales/devise.pt-BR.yml @@ -7,7 +7,7 @@ pt-BR: devise: failure: - admin: + locomotive: unauthenticated: 'Você precisa se cadasstrar ou fazer o login antes de continuar.' unconfirmed: 'Você deve confirmar sua conta antes de continuar.' locked: 'Sua conta está bloquada.' @@ -16,34 +16,34 @@ pt-BR: timeout: 'Sua sessão expirou. Por favor, faça o login novamente para continuar.' inactive: 'Sua conta não foi ativada ainda.' sessions: - admin: + locomotive: signed_in: 'Login feito com sucesso.' signed_out: 'Logout feito com sucesso.' passwords: - admin: + locomotive: send_instructions: 'Você receberá um email com as instruções sobre como alterar sua senha em poucos minutos.' updated: 'Sua senha foi alterada com sucesso. Você está logado.' confirmations: - admin: + locomotive: send_instructions: 'Você receberá um email com as instruções sobre como confirmar sua conta em poucos minutos.' confirmed: 'Sua conta foi confirmada com sucesso. Você está logado.' registrations: - admin: + locomotive: signed_up: 'Você logou com sucesso.' updated: 'Atualização da conta feita com sucesso.' destroyed: 'Sua conta foi cancelada com sucesso. Logo logo esperamos te ver por aqui. Tchau!' unlocks: - admin: + locomotive: send_instructions: 'Você receberá um email com as intruções de como desbloquear sua conta em poucos minutos.' unlocked: 'Sua conta foi desbloqueada com sucesso. Você está logado.' mailer: - admin: + locomotive: confirmation_instructions: 'Instruções de confirmação' reset_password_instructions: 'Instruções para resetar a senha.' unlock_instructions: 'Instruções de desbloqueio' - admin: + locomotive: mailer: common: hello: Olá diff --git a/config/locales/devise.ru.yml b/config/locales/devise.ru.yml index 8647e5d6..cfe28b0a 100644 --- a/config/locales/devise.ru.yml +++ b/config/locales/devise.ru.yml @@ -7,7 +7,7 @@ ru: devise: failure: - admin: + locomotive: unauthenticated: 'Вам необходимо войти или зарегистрироваться перед тем, как продолжить.' unconfirmed: 'Вы должны подтвердить аккаунт перед продолжением.' locked: 'Ваш аккаунт заблокирован.' @@ -17,34 +17,34 @@ ru: timeout: 'Срок действия вашей сессии истек, пожалуйста залогиньтесь для продолжения.' inactive: 'Ваш аккаунт еще не был активирован.' sessions: - admin: + locomotive: signed_in: 'Вход выполнен успешно.' signed_out: 'Выход выполнен успешно.' passwords: - admin: + locomotive: send_instructions: 'Вы получите письмо с инструкциями о том, как сбросить ваш пароль, через несколько минут.' updated: 'Ваш пароль был успешно изменен. Вы вошли в систему.' confirmations: - admin: + locomotive: send_instructions: 'Вы получите письмо с инструкциями о том, как подтвердить ваш аккаунт, через несколько минут.' confirmed: 'Ваша учетная запись была успешно подтверждена. Вы вошли в систему.' registrations: - admin: + locomotive: signed_up: 'Вы успешно зарегистрировались.' updated: 'Вы успешно обновили ваш аккаунт.' destroyed: 'До свидания! Ваш аккаунт был успешно отменен. Мы надеемся скоро увидеть вас снова.' unlocks: - admin: + locomotive: send_instructions: 'Вам будет отправлено письмо с инструкциями о том, как разблокировать ваш аккаунт, в течение нескольких минут.' unlocked: 'Ваша учетная запись была успешно разблокирована. Вы вошли в систему.' mailer: - admin: + locomotive: confirmation_instructions: 'Инструкции подтверждения' reset_password_instructions: 'Инструкции по сбросу пароля' unlock_instructions: 'Инструкции по разблокированию' - admin: + locomotive: mailer: common: hello: Здравствуйте diff --git a/config/locales/flash.de.yml b/config/locales/flash.de.yml index 543650d0..379e8595 100644 --- a/config/locales/flash.de.yml +++ b/config/locales/flash.de.yml @@ -1,6 +1,6 @@ de: flash: - admin: + locomotive: pages: create: notice: "Seite wurde erfolgreich erstellt." diff --git a/config/locales/flash.en.yml b/config/locales/flash.en.yml index 8772b9a2..6592e87b 100644 --- a/config/locales/flash.en.yml +++ b/config/locales/flash.en.yml @@ -1,6 +1,6 @@ en: flash: - admin: + locomotive: pages: create: notice: "Page was successfully created." diff --git a/config/locales/flash.es.yml b/config/locales/flash.es.yml index 926a251a..95e9f923 100644 --- a/config/locales/flash.es.yml +++ b/config/locales/flash.es.yml @@ -1,6 +1,6 @@ es: flash: - admin: + locomotive: pages: create: notice: "Página creada con éxito." diff --git a/config/locales/flash.fr.yml b/config/locales/flash.fr.yml index 8addfb2b..84d8b509 100644 --- a/config/locales/flash.fr.yml +++ b/config/locales/flash.fr.yml @@ -1,6 +1,6 @@ fr: flash: - admin: + locomotive: pages: create: notice: "La page a été créée avec succès." diff --git a/config/locales/flash.it.yml b/config/locales/flash.it.yml index a1ea1841..7688663d 100644 --- a/config/locales/flash.it.yml +++ b/config/locales/flash.it.yml @@ -1,6 +1,6 @@ it: flash: - admin: + locomotive: pages: create: notice: "La pagina è stata creata con successo." diff --git a/config/locales/flash.nl.yml b/config/locales/flash.nl.yml index 6296aacb..f0ab1290 100644 --- a/config/locales/flash.nl.yml +++ b/config/locales/flash.nl.yml @@ -1,6 +1,6 @@ nl: flash: - admin: + locomotive: pages: create: notice: "Pagina is gemaakt." diff --git a/config/locales/flash.no.yml b/config/locales/flash.no.yml index 34997825..aae6a7a7 100644 --- a/config/locales/flash.no.yml +++ b/config/locales/flash.no.yml @@ -1,6 +1,6 @@ "no": flash: - admin: + locomotive: pages: create: notice: "Siden har blitt opprettet." diff --git a/config/locales/flash.pt-BR.yml b/config/locales/flash.pt-BR.yml index e693b8ee..b092135c 100644 --- a/config/locales/flash.pt-BR.yml +++ b/config/locales/flash.pt-BR.yml @@ -1,6 +1,6 @@ pt-BR: flash: - admin: + locomotive: pages: create: notice: "Página criada com sucesso." diff --git a/config/locales/flash.ru.yml b/config/locales/flash.ru.yml index ae1c1a3a..59ed641c 100644 --- a/config/locales/flash.ru.yml +++ b/config/locales/flash.ru.yml @@ -1,6 +1,6 @@ ru: flash: - admin: + locomotive: pages: create: notice: "Страница успешно создана." diff --git a/config/mongoid.yml b/config/mongoid.yml deleted file mode 100644 index d679479f..00000000 --- a/config/mongoid.yml +++ /dev/null @@ -1,34 +0,0 @@ -defaults: &defaults - host: localhost - port: 27017 - # slaves: - # - host: slave1.local - # port: 27018 - # - host: slave2.local - # port: 27019 - -development: - <<: *defaults - database: locomotive_rails_3_1_dev - -test: - <<: *defaults - database: locomotive_rails_3_1_test - -# set these environment variables on your prod server -production: - # <<: *defaults - # database: locomotive_prod - - # other settings for production - # host: <%= ENV['MONGOID_HOST'] %> - # port: <%= ENV['MONGOID_PORT'] %> - # username: <%= ENV['MONGOID_USERNAME'] %> - # password: <%= ENV['MONGOID_PASSWORD'] %> - # database: <%= ENV['MONGOID_DATABASE'] %> - - # heroku - # uri: <%= ENV['MONGOHQ_URL'] %> - - # bushido (mongohq_url will also work) - uri: <%= ENV['MONGODB_URL'] %> diff --git a/config/routes.rb b/config/routes.rb index 02caffad..a18cc503 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,70 +1,68 @@ # Locomotive::Application.routes.draw do |map| +Locomotive::Engine.routes.draw do + + # # admin authentication + # devise_for :admin, :class_name => 'Account', :controllers => { :sessions => 'admin/sessions', :passwords => 'admin/passwords' } + # + # as :admin do + # get '/admin' => 'admin/sessions#new' + # end + + root :to => 'sessions#new' + + resources :pages do + put :sort, :on => :member + get :get_path, :on => :collection + end + + resources :snippets + + resources :sites + + resource :current_site, :controller => 'current_site' + + resources :accounts + + resource :my_account, :controller => 'my_account' + + resources :memberships + + resources :theme_assets do + get :all, :action => 'index', :on => :collection, :defaults => { :all => true } + end + + resources :assets + + resources :content_types + + resources :contents, :path => 'content_types/:slug/contents' do + put :sort, :on => :collection + end + + resources :api_contents, :path => 'api/:slug/contents', :controller => 'api_contents', :only => [:create] + + resources :custom_fields, :path => 'custom/:parent/:slug/fields' + + resources :cross_domain_sessions, :only => [:new, :create] + + resource :import, :only => [:new, :show, :create], :controller => 'import' + + resource :export, :only => [:new], :controller => 'export' + + # installation guide + match '/installation' => 'installation#show', :defaults => { :step => 1 }, :as => :installation + match '/installation/:step' => 'installation#show', :as => :installation_step +end + Rails.application.routes.draw do - - # admin authentication - devise_for :admin, :class_name => 'Account', :controllers => { :sessions => 'admin/sessions', :passwords => 'admin/passwords' } - - as :admin do - get '/admin' => 'admin/sessions#new' - end - - # admin interface for each website - namespace 'admin' do - root :to => 'sessions#new' - - resources :pages do - put :sort, :on => :member - get :get_path, :on => :collection - end - - resources :snippets - - resources :sites - - resource :current_site, :controller => 'current_site' - - resources :accounts - - resource :my_account, :controller => 'my_account' - - resources :memberships - - resources :theme_assets do - get :all, :action => 'index', :on => :collection, :defaults => { :all => true } - end - - resources :assets - - resources :content_types - - resources :contents, :path => 'content_types/:slug/contents' do - put :sort, :on => :collection - end - - resources :api_contents, :path => 'api/:slug/contents', :controller => 'api_contents', :only => [:create] - - resources :custom_fields, :path => 'custom/:parent/:slug/fields' - - resources :cross_domain_sessions, :only => [:new, :create] - - resource :import, :only => [:new, :show, :create], :controller => 'import' - - resource :export, :only => [:new], :controller => 'export' - - # installation guide - match '/installation' => 'installation#show', :defaults => { :step => 1 }, :as => :installation - match '/installation/:step' => 'installation#show', :as => :installation_step - - end - # sitemap - match '/sitemap.xml' => 'admin/sitemaps#show', :format => 'xml' + match '/sitemap.xml' => 'locomotive/sitemaps#show', :format => 'xml' # robots.txt - match '/robots.txt' => 'admin/robots#show', :format => 'txt' + match '/robots.txt' => 'locomotive/robots#show', :format => 'txt' # magic urls - match '/' => 'admin/rendering#show' - match '*path/edit' => 'admin/rendering#edit' - match '*path' => 'admin/rendering#show' -end + match '/' => 'locomotive/rendering#show' + match '*path/edit' => 'locomotive/rendering#edit' + match '*path' => 'locomotive/rendering#show' +end \ No newline at end of file diff --git a/lib/locomotive.rb b/lib/locomotive.rb index 40b741bb..a97b37b5 100644 --- a/lib/locomotive.rb +++ b/lib/locomotive.rb @@ -1,5 +1,4 @@ -require 'mimetype_fu' -require 'devise' +require 'locomotive/engine' require 'locomotive/version' require 'locomotive/core_ext' @@ -72,11 +71,11 @@ module Locomotive self.add_middlewares # Load all the dynamic classes (custom fields) - begin - ContentType.all.collect(&:fetch_content_klass) - rescue ::Mongoid::Errors::InvalidDatabase => e - # let assume it's because of the first install (meaning no config.yml file) - end + # begin + # ContentType.all.collect(&:fetch_content_klass) + # rescue ::Mongoid::Errors::InvalidDatabase => e + # # let assume it's because of the first install (meaning no config.yml file) + # end end def self.add_middlewares diff --git a/lib/locomotive/engine.rb b/lib/locomotive/engine.rb index 619cc852..39054d30 100644 --- a/lib/locomotive/engine.rb +++ b/lib/locomotive/engine.rb @@ -4,6 +4,7 @@ require 'rails' require 'json/pure' require 'devise' require 'mongoid' +require 'mongoid/railtie' require 'mongoid_acts_as_tree' require 'will_paginate' require 'haml' @@ -31,7 +32,19 @@ module Locomotive config.autoload_once_paths += %W( #{config.root}/app/controllers #{config.root}/app/models #{config.root}/app/helpers #{config.root}/app/uploaders) - initializer "locomotive.cells" do |app| + # initializer 'locomotive.load_controllers_and_models' do |app| + # puts "[locomotive/initializer] locomotive.load_controllers_and_models" + # end + # + # config.before_initialize do |app| + # puts "[locomotive/before_initialize] NOTHING IS INITIALIZED !!!!!" + # end + # + # config.before_configuration do |app| + # puts "[locomotive/before_configuration] NOTHING IS INITIALIZED !!!!!" + # end + + initializer 'locomotive.cells' do |app| Cell::Base.prepend_view_path("#{config.root}/app/cells") end diff --git a/lib/locomotive/httparty/patches.rb b/lib/locomotive/httparty/patches.rb index 8be6c824..f5ee4b71 100644 --- a/lib/locomotive/httparty/patches.rb +++ b/lib/locomotive/httparty/patches.rb @@ -1,18 +1,18 @@ -require 'crack/json' - -module Crack - class JSON - - def self.parse_with_tumblr(json) - cleaned_json = json.gsub(/^var\s+.+\s+=\s+/, '').gsub(/;$/, '') - parse_without_tumblr(cleaned_json) - rescue ArgumentError => e - raise ParseError, "Invalid JSON string #{e.inspect}" - end - - class << self - alias_method_chain :parse, :tumblr - end - - end -end +# require 'crack/json' +# +# module Crack +# class JSON +# +# def self.parse_with_tumblr(json) +# cleaned_json = json.gsub(/^var\s+.+\s+=\s+/, '').gsub(/;$/, '') +# parse_without_tumblr(cleaned_json) +# rescue ArgumentError => e +# raise ParseError, "Invalid JSON string #{e.inspect}" +# end +# +# class << self +# alias_method_chain :parse, :tumblr +# end +# +# end +# end diff --git a/lib/locomotive/liquid/drops/contents.rb b/lib/locomotive/liquid/drops/contents.rb index 691e5c9f..bfe8ad7a 100644 --- a/lib/locomotive/liquid/drops/contents.rb +++ b/lib/locomotive/liquid/drops/contents.rb @@ -48,7 +48,7 @@ module Locomotive end def api - { 'create' => @context.registers[:controller].send('admin_api_contents_url', @content_type.slug) } + { 'create' => @context.registers[:controller].send('locomotive_api_contents_url', @content_type.slug) } end def before_method(meth) diff --git a/lib/locomotive/liquid/tags/inline_editor.rb b/lib/locomotive/liquid/tags/inline_editor.rb index f9149649..159ce289 100644 --- a/lib/locomotive/liquid/tags/inline_editor.rb +++ b/lib/locomotive/liquid/tags/inline_editor.rb @@ -4,18 +4,18 @@ module Liquid class InlineEditor < ::Liquid::Tag def render(context) - if context.registers[:current_admin] + if context.registers[:current_account] output = %{ - + - + } if context.registers[:inline_editor] controller = context.registers[:controller] output << %{ - + diff --git a/lib/locomotive/render.rb b/lib/locomotive/render.rb index d17d2d20..1bf29b5d 100644 --- a/lib/locomotive/render.rb +++ b/lib/locomotive/render.rb @@ -41,13 +41,13 @@ module Locomotive end if page = current_site.pages.any_in(:fullpath => [*path]).first - if not page.published? and current_admin.nil? + if not page.published? and current_account.nil? page = nil else if page.templatized? @content_instance = page.content_type.contents.where(:_slug => File.basename(path.first)).first - if @content_instance.nil? || (!@content_instance.visible? && current_admin.nil?) # content instance not found or not visible + if @content_instance.nil? || (!@content_instance.visible? && current_account.nil?) # content instance not found or not visible page = nil end end @@ -84,7 +84,7 @@ module Locomotive :site => current_site, :page => @page, :inline_editor => self.editing_page?, - :current_admin => current_admin + :current_account => current_account } ::Liquid::Context.new({}, assigns, registers) diff --git a/lib/locomotive/routing/site_dispatcher.rb b/lib/locomotive/routing/site_dispatcher.rb index 7405be1d..65c0d8ca 100644 --- a/lib/locomotive/routing/site_dispatcher.rb +++ b/lib/locomotive/routing/site_dispatcher.rb @@ -33,7 +33,7 @@ module Locomotive def require_site return true if current_site - redirect_to admin_installation_url and return false if Account.count == 0 || Site.count == 0 + redirect_to locomotive_installation_url and return false if Account.count == 0 || Site.count == 0 render_no_site_error and return false end @@ -43,11 +43,11 @@ module Locomotive end def validate_site_membership - return true if current_site.present? && current_site.accounts.include?(current_admin) + return true if current_site.present? && current_site.accounts.include?(current_account) - sign_out(current_admin) - flash[:alert] = I18n.t(:no_membership, :scope => [:devise, :failure, :admin]) - redirect_to new_admin_session_url and return false + sign_out(current_account) + flash[:alert] = I18n.t(:no_membership, :scope => [:devise, :failure, :locomotive]) + redirect_to new_locomotive_session_url and return false end end diff --git a/lib/tasks/bushido.rake b/lib/tasks/bushido.rake deleted file mode 100644 index 6897d464..00000000 --- a/lib/tasks/bushido.rake +++ /dev/null @@ -1,87 +0,0 @@ -require 'bushido' -require 'jammit' -require 'net/http' - -namespace :bushido do - desc "Prepare an app to run on the Bushido hosting platform, only called during the initial installation. Called just before booting the app." - task :install => :environment do - - # re-built assets - Jammit.package! - - if ENV['BUSHIDO_USER_EMAIL'] && ENV['BUSHIDO_USER_ID'] - # already logged in in Bushido - account = Account.create!({ - :email => ENV['BUSHIDO_USER_EMAIL'], - :name => ENV['BUSHIDO_USER_NAME'] || ENV['BUSHIDO_USER_EMAIL'].split('@').first, - :bushido_user_id => ENV['BUSHIDO_USER_ID'], - :password => ActiveSupport::SecureRandom.base64(6) - }) - else - # create an anonymous account right away - account = Account.create!({ - :email => "#{ENV['BUSHIDO_APP']}@#{ENV['BUSHIDO_HOST']}", - :name => ENV['BUSHIDO_APP'], - :password => ActiveSupport::SecureRandom.base64(6) - }) - end - - # create the site - site = Site.create_first_one(:name => ENV['LOCOMOTIVE_SITE_NAME'] || ENV['BUSHIDO_APP']) - - # fetch the site template - template_url = ENV['SITE_TEMPLATE_URL'] || Locomotive::Import::DEFAULT_SITE_TEMPLATE - template_url = "http://#{template_url}" unless template_url =~ /^https?:\/\// - - template_local_path = "#{Rails.root}/permanent/site_template.zip" - - uri = URI.parse(template_url) - http = Net::HTTP.new(uri.host, uri.port) - - if template_url.starts_with?('https') # ssl request ? - http.use_ssl = true - http.verify_mode = OpenSSL::SSL::VERIFY_NONE - end - - case http.request(Net::HTTP::Get.new(uri.request_uri)) - when Net::HTTPSuccess, Net::HTTPFound - `curl -L -s -o #{template_local_path} #{template_url}` - - tmp, Locomotive.config.delayed_job = Locomotive.config.delayed_job, false # disable DJ during this import - - Locomotive::Import::Job.run!(File.open(template_local_path), site, { :samples => true }) - - Locomotive.config.delayed_job = tmp # restore DJ flag - else - # do nothing - end - end - - desc "Perform custom actions triggered by the Bushido hosting platform." - task :event => :environment do - event = ::Bushido::Event.last - - puts "processing...#{event.inspect}" - - case event.category.to_s - when 'app' - case event.name.to_s - when 'claimed' - # an user has just claimed his application - account = Account.order_by(:created_at).first - - account.email = event.data['bushido_user_email'] - account.bushido_user_id = event.data['bushido_user_id'] - - account.save! - end - end - end - - desc "Prepare an app to run on the Bushido hosting platform, called on every update. Called just before booting the app." - task :update do - # re-built assets - Jammit.package! - end -end - diff --git a/lib/tasks/locomotive.rake b/lib/tasks/locomotive.rake index a36f5a70..2df1f1f1 100644 --- a/lib/tasks/locomotive.rake +++ b/lib/tasks/locomotive.rake @@ -14,7 +14,7 @@ namespace :locomotive do desc 'Rebuild the serialized template of all the site pages' task :rebuild_serialized_page_templates => :environment do - Site.all.each do |site| + Locomotive::Site.all.each do |site| pages = site.pages.to_a while !pages.empty? do page = pages.pop @@ -37,7 +37,7 @@ namespace :locomotive do raise "URL is missing or it is not a valid http url." end - site = Site.find(site_name_or_id) || Site.where(:name => site_name_or_id).first || Site.first + site = Locomotive::Site.find(site_name_or_id) || Locomotive::Site.where(:name => site_name_or_id).first || Locomotive::Site.first if site.nil? raise "No site found. Please give a correct value (name or id) for the SITE env variable." @@ -53,184 +53,24 @@ namespace :locomotive do password = ask('Password: ') { |q| q.echo = '*' } password_confirm = ask('Confirm password: ') { |q| q.echo = '*' } - account = Account.create :email => email, :password => password, :password_confirmation => password_confirm, :name => name + account = Locomotive::Account.create :email => email, :password => password, :password_confirmation => password_confirm, :name => name # TODO: this should be changed to work for multi-sites (see desc) - site = Site.first + site = Locomotive::Site.first site.memberships.build :account => account, :role => 'admin' site.save! end namespace :upgrade do - desc 'Set roles to the existing users' - task :set_roles => :environment do - Site.all.each do |site| - site.memberships.each do |membership| - if membership.attributes['admin'] == true - puts "...[#{site.name}] #{membership.account.name} has now the admin role" - membership.role = 'admin' - else - puts "...[#{site.name}] #{membership.account.name} has now the author role" - membership.role = 'author' - end - end - site.save - end - end - desc "Index page is sometimes after the 404 error page. Fix this" task :place_index_before_404 => :environment do - Site.all.each do |site| + Locomotive::Site.all.each do |site| site.pages.root.first.update_attribute :position, 0 site.pages.not_found.first.update_attribute :position, 1 end end - desc 'Remove asset collections and convert them into content types' - task :remove_asset_collections => :environment do - puts "Processing #{AssetCollection.count} asset collection(s)..." - - Asset.destroy_all - - AssetCollection.all.each do |collection| - site = Site.find(collection.attributes['site_id']) - - if collection.internal? - # internal collection => create simple assets without associated to a collection - - collection.assets.each do |tmp_asset| - # puts "tmp asset = #{tmp_asset.inspect} / #{tmp_asset.source.url.inspect}" TODO - - sanitized_attributes = tmp_asset.attributes.dup - sanitized_attributes[:_id] = tmp_asset._id - - asset = site.assets.build(sanitized_attributes) - - asset.save(:validate => false) - - # puts "asset = #{asset.inspect} / #{asset.source.url.inspect}" TODO - end - else - collection.fetch_asset_klass.class_eval { def self.model_name; 'Asset'; end } - - # create content_types reflection of an asset collection - ContentType.where(:slug => collection.slug).all.collect(&:destroy) # TODO - - content_type = site.content_types.build({ - :name => collection.name, - :slug => collection.slug, - :order_by => '_position_in_list' - }) - - content_type._id = collection._id - - # extra custom fields - collection.asset_custom_fields.each_with_index do |field, i| - content_type.content_custom_fields.build(field.attributes.merge(:position => i + 3)) - end - - # add default custom fields - content_type.content_custom_fields.build(:label => 'Name', :_alias => 'name', :kind => 'string', :required => true, :position => 1) - content_type.content_custom_fields.build(:label => 'Source', :_alias => 'source', :kind => 'file', :required => true, :position => 2) - - content_type.save! - - content_type = ContentType.find(content_type._id) # hard reload - - # set the highlighted field name - field = content_type.content_custom_fields.detect { |f| f._alias == 'name' } - content_type.highlighted_field_name = field._name - content_type.save - - # insert data - collection.ordered_assets.each do |asset| - attributes = (if asset.custom_fields.blank? - { :created_at => asset.created_at, :updated_at => asset.updated_at } - else - {}.tap do |h| - asset.custom_fields.each do |field| - case field.kind - when 'file' then h["#{field._name}"] = asset.send("#{field._name}".to_sym) - else - h[field._alias] = asset.send(field._name.to_sym) - end - end - end - end) - - attributes.merge!(:name => asset.name, :_position_in_list => asset.position) - - content = content_type.contents.build(attributes) - - content._id = asset._id - - content.source = asset.source.file - - content.save(:validate => false) - end - end - - puts "...the collection named '#{collection.slug}' for the '#{site.name}' site has been migrated with success !" - end - end - end -end - - -class TmpAssetUploader < CarrierWave::Uploader::Base - include CarrierWave::RMagick - include Locomotive::CarrierWave::Uploader::Asset - version :thumb, :if => :image? do - process :resize_to_fill => [50, 50] - process :convert => 'png' - end - version :medium, :if => :image? do - process :resize_to_fill => [80, 80] - process :convert => 'png' - end - version :preview, :if => :image? do - process :resize_to_fit => [880, 1100] - process :convert => 'png' - end - def store_dir - self.build_store_dir('sites', model.collection.site_id, 'assets', model.id) - end -end - -# Classes only used during the upgrade mechanism. Will be removed in a few weeks -class AssetCollection - include Locomotive::Mongoid::Document - field :name - field :slug - field :internal, :type => Boolean, :default => false - referenced_in :site - embeds_many :assets, :class_name => 'TmpAsset', :validate => false - custom_fields_for :assets - after_destroy :remove_uploaded_files - scope :internal, :where => { :internal => true } - scope :not_internal, :where => { :internal => false } - def ordered_assets - self.assets.sort { |a, b| (a.position || 0) <=> (b.position || 0) } - end - def self.find_or_create_internal(site) - site.asset_collections.internal.first || site.asset_collections.create(:name => 'system', :slug => 'system', :internal => true) - end -end - -class TmpAsset - include Mongoid::Document - include Mongoid::Timestamps - include CustomFields::ProxyClassEnabler - field :name, :type => String - field :content_type, :type => String - field :width, :type => Integer - field :height, :type => Integer - field :size, :type => Integer - field :position, :type => Integer, :default => 0 - mount_uploader :source, TmpAssetUploader - embedded_in :collection, :class_name => 'AssetCollection', :inverse_of => :assets - def site_id; self.collection.site_id; end -end +end \ No newline at end of file diff --git a/script/rails b/script/rails old mode 100755 new mode 100644 index ec22bf97..43098569 --- a/script/rails +++ b/script/rails @@ -1,10 +1,6 @@ #!/usr/bin/env ruby +#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. -ENV_PATH = File.expand_path('../../config/environment', __FILE__) -BOOT_PATH = File.expand_path('../../config/boot', __FILE__) -APP_PATH = File.expand_path('../../config/application', __FILE__) -ROOT_PATH = File.expand_path('../..', __FILE__) - -require BOOT_PATH -require 'rails/commands' +ENGINE_PATH = File.expand_path('../..', __FILE__) +load File.expand_path('../../spec/dummy/script/rails', __FILE__) diff --git a/spec/cells/admin/global_actions_spec.rb b/spec/cells/admin/global_actions_spec.rb index c84fceb2..1064d8bf 100644 --- a/spec/cells/admin/global_actions_spec.rb +++ b/spec/cells/admin/global_actions_spec.rb @@ -4,7 +4,7 @@ describe Admin::GlobalActionsCell do render_views - let(:menu) { render_cell('admin/global_actions', :show, :current_admin => FactoryGirl.build('admin user'), :current_site_url => 'http://www.yahoo.fr') } + let(:menu) { render_cell('admin/global_actions', :show, :current_account => FactoryGirl.build('admin user'), :current_site_url => 'http://www.yahoo.fr') } describe 'show menu' do diff --git a/spec/dummy/Rakefile b/spec/dummy/Rakefile new file mode 100644 index 00000000..36458522 --- /dev/null +++ b/spec/dummy/Rakefile @@ -0,0 +1,7 @@ +#!/usr/bin/env rake +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require File.expand_path('../config/application', __FILE__) + +Dummy::Application.load_tasks diff --git a/spec/dummy/app/assets/javascripts/application.js b/spec/dummy/app/assets/javascripts/application.js new file mode 100644 index 00000000..37c7bfcd --- /dev/null +++ b/spec/dummy/app/assets/javascripts/application.js @@ -0,0 +1,9 @@ +// This is a manifest file that'll be compiled into including all the files listed below. +// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically +// be included in the compiled file accessible from http://example.com/assets/application.js +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// the compiled file. +// +//= require jquery +//= require jquery_ujs +//= require_tree . diff --git a/spec/dummy/app/assets/stylesheets/application.css b/spec/dummy/app/assets/stylesheets/application.css new file mode 100644 index 00000000..fc25b572 --- /dev/null +++ b/spec/dummy/app/assets/stylesheets/application.css @@ -0,0 +1,7 @@ +/* + * This is a manifest file that'll automatically include all the stylesheets available in this directory + * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at + * the top of the compiled file, but it's generally better to create a new file per style scope. + *= require_self + *= require_tree . +*/ \ No newline at end of file diff --git a/spec/dummy/app/controllers/application_controller.rb b/spec/dummy/app/controllers/application_controller.rb new file mode 100644 index 00000000..e8065d95 --- /dev/null +++ b/spec/dummy/app/controllers/application_controller.rb @@ -0,0 +1,3 @@ +class ApplicationController < ActionController::Base + protect_from_forgery +end diff --git a/spec/dummy/app/helpers/application_helper.rb b/spec/dummy/app/helpers/application_helper.rb new file mode 100644 index 00000000..de6be794 --- /dev/null +++ b/spec/dummy/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/spec/dummy/app/mailers/.gitkeep b/spec/dummy/app/mailers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/spec/dummy/app/models/.gitkeep b/spec/dummy/app/models/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/spec/dummy/app/views/layouts/application.html.erb b/spec/dummy/app/views/layouts/application.html.erb new file mode 100644 index 00000000..9a8a761b --- /dev/null +++ b/spec/dummy/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + Dummy + <%= stylesheet_link_tag "application" %> + <%= javascript_include_tag "application" %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/config.ru b/spec/dummy/config.ru similarity index 82% rename from config.ru rename to spec/dummy/config.ru index 6db9de4d..1989ed8d 100644 --- a/config.ru +++ b/spec/dummy/config.ru @@ -1,4 +1,4 @@ # This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) -run Locomotive::Application +run Dummy::Application diff --git a/config/application.rb b/spec/dummy/config/application.rb similarity index 56% rename from config/application.rb rename to spec/dummy/config/application.rb index 793d275b..d8f8836b 100644 --- a/config/application.rb +++ b/spec/dummy/config/application.rb @@ -1,28 +1,26 @@ require File.expand_path('../boot', __FILE__) -require "action_controller/railtie" -require "action_mailer/railtie" -require "active_resource/railtie" -require "mongoid/railtie" +require 'action_controller/railtie' +require 'action_mailer/railtie' +require 'active_resource/railtie' -# Auto-require default libraries and those for the current Rails environment. -Bundler.require :default, Rails.env +Bundler.require +require "locomotive" -module Locomotive +module Dummy class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. - # Add additional load paths for your own custom dirs - # config.load_paths += %W( #{config.root}/extras ) - config.autoload_paths += %W( #{config.root}/app/models/extensions #{config.root}/app/models/extensions/site #{config.root}/app/models/extensions/page #{config.root}/app/models/extensions/asset #{config.root}/app/cells/admin) + # Custom directories with classes and modules you want to be autoloadable. + # config.autoload_paths += %W(#{config.root}/extras) # Only load the plugins named here, in the order given (default is alphabetical). - # :all can be used as a placeholder for all plugins not explicitly named + # :all can be used as a placeholder for all plugins not explicitly named. # config.plugins = [ :exception_notification, :ssl_requirement, :all ] - # Activate observers that should always be running + # Activate observers that should always be running. # config.active_record.observers = :cacher, :garbage_collector, :forum_observer # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. @@ -30,23 +28,20 @@ module Locomotive # config.time_zone = 'Central Time (US & Canada)' # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')] + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de - # Configure generators values. Many other options are available, be sure to check the documentation. - # config.generators do |g| - # g.orm :active_record - # g.template_engine :erb - # g.test_framework :test_unit, :fixture => true - # end - # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" # Configure sensitive parameters which will be filtered from the log file. - config.filter_parameters << :password + config.filter_parameters += [:password] # Enable the asset pipeline config.assets.enabled = true + + # Version of your assets, change this if you want to expire all your assets + config.assets.version = '1.0' end -end \ No newline at end of file +end + diff --git a/spec/dummy/config/boot.rb b/spec/dummy/config/boot.rb new file mode 100644 index 00000000..eba06813 --- /dev/null +++ b/spec/dummy/config/boot.rb @@ -0,0 +1,10 @@ +require 'rubygems' +gemfile = File.expand_path('../../../../Gemfile', __FILE__) + +if File.exist?(gemfile) + ENV['BUNDLE_GEMFILE'] = gemfile + require 'bundler' + Bundler.setup +end + +$:.unshift File.expand_path('../../../../lib', __FILE__) \ No newline at end of file diff --git a/config/environment.rb b/spec/dummy/config/environment.rb similarity index 76% rename from config/environment.rb rename to spec/dummy/config/environment.rb index 7e80d57d..3da5eb91 100644 --- a/config/environment.rb +++ b/spec/dummy/config/environment.rb @@ -2,4 +2,4 @@ require File.expand_path('../application', __FILE__) # Initialize the rails application -Locomotive::Application.initialize! +Dummy::Application.initialize! diff --git a/config/environments/development.rb b/spec/dummy/config/environments/development.rb similarity index 57% rename from config/environments/development.rb rename to spec/dummy/config/environments/development.rb index 02694487..863a8014 100644 --- a/config/environments/development.rb +++ b/spec/dummy/config/environments/development.rb @@ -1,9 +1,9 @@ -Locomotive::Application.configure do - # Settings specified here will take precedence over those in config/environment.rb +Dummy::Application.configure do + # Settings specified here will take precedence over those in config/application.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development - # since you don't have to restart the webserver when you make code changes. + # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Log error messages when you accidentally call methods on nil. @@ -16,9 +16,17 @@ Locomotive::Application.configure do # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false + # Print deprecation notices to the Rails logger config.active_support.deprecation = :log - # config.action_mailer.default_url_options = { :host => 'localhost:3000' } + # Only use best-standards-support built into browsers + config.action_dispatch.best_standards_support = :builtin + + # Do not compress assets + config.assets.compress = false + + # Expands the lines which load the assets + config.assets.debug = true # MockSmtp settings config.action_mailer.delivery_method = :smtp @@ -27,15 +35,4 @@ Locomotive::Application.configure do :port => 1025, :domain => "example.com" } - - # set up the bushido stub (uncomment it) - # config.bushido_stub_env = false - # config.bushido_stub_env = { - # 'APP_TLD' => 'bushi.do', - # 'BUSHIDO_APP' => 'san_francisco', - # 'BUSHIDO_HOST' => 'bushi.do', - # 'LOCOMOTIVE_SITE_NAME' => 'Locomotive TEST', - # 'BUSHIDO_CLAIMED' => 'true', - # 'BUSHIDO_METRICS_TOKEN' => 'foobar' - # } end diff --git a/config/environments/production.rb b/spec/dummy/config/environments/production.rb similarity index 56% rename from config/environments/production.rb rename to spec/dummy/config/environments/production.rb index 3ec49201..ca2c5888 100644 --- a/config/environments/production.rb +++ b/spec/dummy/config/environments/production.rb @@ -1,7 +1,6 @@ -Locomotive::Application.configure do - # Settings specified here will take precedence over those in config/environment.rb +Dummy::Application.configure do + # Settings specified here will take precedence over those in config/application.rb - # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true @@ -9,14 +8,27 @@ Locomotive::Application.configure do config.consider_all_requests_local = false config.action_controller.perform_caching = true + # Disable Rails's static asset server (Apache or nginx will already do this) + config.serve_static_assets = false + + # Compress JavaScripts and CSS + config.assets.compress = true + + # Don't fallback to assets pipeline if a precompiled asset is missed + config.assets.compile = false + + # Generate digests for assets URLs + config.assets.digest = true + + # Defaults to Rails.root.join("public/assets") + # config.assets.manifest = YOUR_PATH + # Specifies the header that your server uses for sending files - config.action_dispatch.x_sendfile_header = "X-Sendfile" + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx - # For nginx: - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' - - # If you have no front-end server that supports something like X-Sendfile, - # just comment this out and Rails will serve the files + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true # See everything in the log (default is :info) # config.log_level = :debug @@ -27,13 +39,12 @@ Locomotive::Application.configure do # Use a different cache store in production # config.cache_store = :mem_cache_store - # Disable Rails's static asset server - # In production, Apache or nginx will already do this - config.serve_static_assets = false - - # Enable serving of images, stylesheets, and javascripts from an asset server + # Enable serving of images, stylesheets, and JavaScripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" + # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) + # config.assets.precompile += %w( search.js ) + # Disable delivery errors, bad email addresses will be ignored # config.action_mailer.raise_delivery_errors = false @@ -44,9 +55,6 @@ Locomotive::Application.configure do # the I18n.default_locale when a translation can not be found) config.i18n.fallbacks = true + # Send deprecation notices to registered listeners config.active_support.deprecation = :notify - - # Compress both stylesheets and JavaScripts - config.assets.js_compressor = :uglifier - config.assets.css_compressor = :scss -end \ No newline at end of file +end diff --git a/config/environments/test.rb b/spec/dummy/config/environments/test.rb similarity index 86% rename from config/environments/test.rb rename to spec/dummy/config/environments/test.rb index d6b13604..6810c914 100644 --- a/config/environments/test.rb +++ b/spec/dummy/config/environments/test.rb @@ -1,5 +1,5 @@ -Locomotive::Application.configure do - # Settings specified here will take precedence over those in config/environment.rb +Dummy::Application.configure do + # Settings specified here will take precedence over those in config/application.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that @@ -7,7 +7,11 @@ Locomotive::Application.configure do # and recreated between test runs. Don't rely on the data there! config.cache_classes = true - # Log error messages when you accidentally call methods on nil. + # Configure static asset server for tests with Cache-Control for performance + config.serve_static_assets = true + config.static_cache_control = "public, max-age=3600" + + # Log error messages when you accidentally call methods on nil config.whiny_nils = true # Show full error reports and disable caching @@ -32,4 +36,4 @@ Locomotive::Application.configure do # Print deprecation notices to the stderr config.active_support.deprecation = :stderr -end \ No newline at end of file +end diff --git a/spec/dummy/config/initializers/carrierwave.rb b/spec/dummy/config/initializers/carrierwave.rb new file mode 100644 index 00000000..2f338725 --- /dev/null +++ b/spec/dummy/config/initializers/carrierwave.rb @@ -0,0 +1,8 @@ +CarrierWave.configure do |config| + + config.cache_dir = File.join(Rails.root, 'tmp', 'uploads') + + config.storage = :file + config.root = File.join(Rails.root, 'public') + +end diff --git a/spec/dummy/config/initializers/devise.rb b/spec/dummy/config/initializers/devise.rb new file mode 100644 index 00000000..0a2f55cc --- /dev/null +++ b/spec/dummy/config/initializers/devise.rb @@ -0,0 +1,194 @@ +# Use this hook to configure devise mailer, warden hooks and so forth. The first +# four configuration values can also be set straight in your models. +Devise.setup do |config| + # ==> Mailer Configuration + # Configure the e-mail address which will be shown in DeviseMailer. + config.mailer_sender = 'sender@dummyapp.org' + + # Configure the class responsible to send e-mails. + # config.mailer = "Devise::Mailer" + + # ==> ORM configuration + # Load and configure the ORM. Supports :active_record (default) and + # :mongoid (bson_ext recommended) by default. Other ORMs may be + # available as additional gems. + require 'devise/orm/mongoid' + + # ==> Configuration for any authentication mechanism + # Configure which keys are used when authenticating a user. The default is + # just :email. You can configure it to use [:username, :subdomain], so for + # authenticating a user, both parameters are required. Remember that those + # parameters are used only when authenticating and not when retrieving from + # session. If you need permissions, you should implement that in a before filter. + # You can also supply a hash where the value is a boolean determining whether + # or not authentication should be aborted when the value is not present. + # config.authentication_keys = [ :email ] + + # Configure parameters from the request object used for authentication. Each entry + # given should be a request method and it will automatically be passed to the + # find_for_authentication method and considered in your model lookup. For instance, + # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. + # The same considerations mentioned for authentication_keys also apply to request_keys. + # config.request_keys = [] + + # Configure which authentication keys should be case-insensitive. + # These keys will be downcased upon creating or modifying a user and when used + # to authenticate or find a user. Default is :email. + config.case_insensitive_keys = [ :email ] + + # Tell if authentication through request.params is enabled. True by default. + # config.params_authenticatable = true + + # Tell if authentication through HTTP Basic Auth is enabled. False by default. + # config.http_authenticatable = false + + # If http headers should be returned for AJAX requests. True by default. + # config.http_authenticatable_on_xhr = true + + # The realm used in Http Basic Authentication. "Application" by default. + # config.http_authentication_realm = "Application" + + # ==> Configuration for :database_authenticatable + # For bcrypt, this is the cost for hashing the password and defaults to 10. If + # using other encryptors, it sets how many times you want the password re-encrypted. + config.stretches = 10 + + # Setup a pepper to generate the encrypted password. + # config.pepper = "de368d6a1517489510a2ae145328ff1c238f03b02da8f57032936a353835e2ca20561decfb5f7bfafad095fa73cee55b101ed11a0d0f913429d3d9bd114d810e" + + # ==> Configuration for :confirmable + # The time you want to give your user to confirm his account. During this time + # he will be able to access your application without confirming. Default is 0.days + # When confirm_within is zero, the user won't be able to sign in without confirming. + # You can use this to let your user access some features of your application + # without confirming the account, but blocking it after a certain period + # (ie 2 days). + # config.confirm_within = 2.days + + # Defines which key will be used when confirming an account + # config.confirmation_keys = [ :email ] + + # ==> Configuration for :rememberable + # The time the user will be remembered without asking for credentials again. + config.remember_for = 2.weeks + + # If true, a valid remember token can be re-used between multiple browsers. + # config.remember_across_browsers = true + + # If true, extends the user's remember period when remembered via cookie. + # config.extend_remember_period = false + + # If true, uses the password salt as remember token. This should be turned + # to false if you are not using database authenticatable. + config.use_salt_as_remember_token = true + + # Options to be passed to the created cookie. For instance, you can set + # :secure => true in order to force SSL only cookies. + # config.cookie_options = {} + + # ==> Configuration for :validatable + # Range for password length. Default is 6..128. + # config.password_length = 6..128 + + # Regex to use to validate the email address + # config.email_regexp = /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i + + # ==> Configuration for :timeoutable + # The time you want to timeout the user session without activity. After this + # time the user will be asked for credentials again. Default is 30 minutes. + # config.timeout_in = 30.minutes + + # ==> Configuration for :lockable + # Defines which strategy will be used to lock an account. + # :failed_attempts = Locks an account after a number of failed attempts to sign in. + # :none = No lock strategy. You should handle locking by yourself. + # config.lock_strategy = :failed_attempts + + # Defines which key will be used when locking and unlocking an account + # config.unlock_keys = [ :email ] + + # Defines which strategy will be used to unlock an account. + # :email = Sends an unlock link to the user email + # :time = Re-enables login after a certain amount of time (see :unlock_in below) + # :both = Enables both strategies + # :none = No unlock strategy. You should handle unlocking by yourself. + # config.unlock_strategy = :both + + # Number of authentication tries before locking an account if lock_strategy + # is failed attempts. + # config.maximum_attempts = 20 + + # Time interval to unlock the account if :time is enabled as unlock_strategy. + # config.unlock_in = 1.hour + + # ==> Configuration for :recoverable + # + # Defines which key will be used when recovering the password for an account + # config.reset_password_keys = [ :email ] + + # Time interval you can reset your password with a reset password key. + # Don't put a too small interval or your users won't have the time to + # change their passwords. + config.reset_password_within = 2.hours + + # ==> Configuration for :encryptable + # Allow you to use another encryption algorithm besides bcrypt (default). You can use + # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, + # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) + # and :restful_authentication_sha1 (then you should set stretches to 10, and copy + # REST_AUTH_SITE_KEY to pepper) + # config.encryptor = :sha1 + + # ==> Configuration for :token_authenticatable + # Defines name of the authentication token params key + # config.token_authentication_key = :auth_token + + # If true, authentication through token does not store user in session and needs + # to be supplied on each request. Useful if you are using the token as API token. + # config.stateless_token = false + + # ==> Scopes configuration + # Turn scoped views on. Before rendering "sessions/new", it will first check for + # "users/sessions/new". It's turned off by default because it's slower if you + # are using only default views. + config.scoped_views = true + + # Configure the default scope given to Warden. By default it's the first + # devise role declared in your routes (usually :user). + config.default_scope = :account + + # Configure sign_out behavior. + # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope). + # The default is true, which means any logout action will sign out all active scopes. + # config.sign_out_all_scopes = true + + # ==> Navigation configuration + # Lists the formats that should be treated as navigational. Formats like + # :html, should redirect to the sign in page when the user does not have + # access, but formats like :xml or :json, should return 401. + # + # If you have any extra navigational formats, like :iphone or :mobile, you + # should add them to the navigational formats lists. + # + # The :"*/*" and "*/*" formats below is required to match Internet + # Explorer requests. + # config.navigational_formats = [:"*/*", "*/*", :html] + + # The default HTTP method used to sign out a resource. Default is :get. + # config.sign_out_via = :get + + # ==> OmniAuth + # Add a new OmniAuth provider. Check the wiki for more information on setting + # up on your models and hooks. + # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo' + + # ==> Warden configuration + # If you want to use other strategies, that are not supported by Devise, or + # change the failure app, you can configure them inside the config.warden block. + # + # config.warden do |manager| + # manager.failure_app = AnotherApp + # manager.intercept_401 = false + # manager.default_strategies(:scope => :user).unshift :some_external_strategy + # end +end diff --git a/spec/dummy/config/initializers/dragonfly.rb b/spec/dummy/config/initializers/dragonfly.rb new file mode 100644 index 00000000..ad373072 --- /dev/null +++ b/spec/dummy/config/initializers/dragonfly.rb @@ -0,0 +1,22 @@ +require 'dragonfly' + +## initialize Dragonfly ## + +app = Dragonfly[:images] +app.configure_with(:rails) +app.configure_with(:imagemagick) + +## configure it ## + +Dragonfly[:images].configure do |c| + # Convert absolute location needs to be specified + # to avoid issues with Phusion Passenger not using $PATH + convert = `which convert`.strip.presence || "/usr/local/bin/convert" + c.convert_command = convert + c.identify_command = convert + + c.allow_fetch_url = true + c.allow_fetch_file = true + + c.url_format = '/images/dynamic/:job/:basename.:format' +end \ No newline at end of file diff --git a/spec/dummy/config/initializers/formtastic.rb b/spec/dummy/config/initializers/formtastic.rb new file mode 100644 index 00000000..985d11ae --- /dev/null +++ b/spec/dummy/config/initializers/formtastic.rb @@ -0,0 +1,5 @@ +require 'formtastic' +require 'locomotive/misc_form_builder' +Formtastic::SemanticFormHelper.builder = Locomotive::MiscFormBuilder +Formtastic::SemanticFormBuilder.i18n_lookups_by_default = true + diff --git a/spec/dummy/config/initializers/haml.rb b/spec/dummy/config/initializers/haml.rb new file mode 100644 index 00000000..df0b4de4 --- /dev/null +++ b/spec/dummy/config/initializers/haml.rb @@ -0,0 +1 @@ +Haml::Template.options[:ugly] = true # improve performance in dev \ No newline at end of file diff --git a/spec/dummy/config/initializers/locomotive.rb b/spec/dummy/config/initializers/locomotive.rb new file mode 100644 index 00000000..993f4086 --- /dev/null +++ b/spec/dummy/config/initializers/locomotive.rb @@ -0,0 +1,80 @@ +Locomotive.configure do |config| + + # A single locomotive instance can serve one single site or many. + # If you want to run many different websites, you will have to specify + # your own domain name (ex: locomotivehosting.com). + # + # Ex: + # config.multi_sites do |multi_sites| + # # each new website you add will have a default entry based on a subdomain + # # and the multi_site_domain value (ex: website_1.locomotivehosting.com). + # multi_sites.domain = 'example.com' #'myhostingplatform.com' + # + # # define the reserved subdomains + # # Ex: + # multi_sites.reserved_subdomains = %w(www admin email blog webmail mail support help site sites) + # end + config.multi_sites = false + + # configure the hosting target for the production environment. Locomotive can be installed in: + # - your own server + # - Heroku (you need to create an account in this case) + # - Bushi.do (see the bushi.do website for more explanations) + # + # the possible options are: server, heroku, bushido or auto (default) + # if you select 'auto', Locomotive will look after specific ENV variables to check + # the matching platform (Heroku and Bushido set their own ENV variables). + # + config.hosting = :server + + # In case you host Locomotive in Heroku, the engine uses the heroku api to add / remove domains. + # there are 2 ways of passing heroku credentials to Locomotive + # - from ENV variables: HEROKU_LOGIN & HEROKU_PASSWORD + # - from this file, see the example below and uncomment it if needed + # config.heroku = { + # :login => '', + # :password => '' + # } + + # Locomotive uses the DelayedJob gem for the site import module. + # In case you want to deploy to Heroku, you will have to pay for an extra dyno. + # If you do not mind about importing theme without DelayedJob, disable it. + # + # Warning: this option is not used if you deploy on bushi.do and we set automatically the value to true. + config.delayed_job = false + + # configure how many items we display in sub menu in the "Contents" section. + # config.lastest_items_nb = 5 + + # default locale (for now, only en, de, fr, pt-BR and it are supported) + config.default_locale = :en + + # tell if logs are enabled. Useful for debug purpose. + config.enable_logs = true + + # Configure the e-mail address which will be shown in the DeviseMailer, NotificationMailer, ...etc + # if you do not put the domain name in the email, Locomotive will take the default domain name depending + # on your deployment target (server, Heroku, Bushido, ...etc) + # + # Ex: + # config.mailer_sender = 'support' + # # => 'support@heroku.com' (Heroku), 'support@bushi.do' (Bushido), 'support@example.com' (Dev) or 'support@' (Multi-sites) + config.mailer_sender = 'support' + + # allow apps using the engine to add their own Liquid drops, variables and similar available + # in Liquid templates, extending the assigns used while rendering. + # follow the Dependency Injection pattern + # config.context_assign_extensions = {} + + # Rack-cache settings, mainly used for the inline resizing image module. Default options: + # config.rack_cache = { + # :verbose => true, + # :metastore => URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/meta"), # URI encoded in case of spaces + # :entitystore => URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/body") + # } + # If you do want to disable it for good, just use the following syntax + # config.rack_cache = false + # + # Note: by default, rack/cache is disabled in the Heroku platform + +end diff --git a/spec/dummy/config/initializers/secret_token.rb b/spec/dummy/config/initializers/secret_token.rb new file mode 100644 index 00000000..c76ee249 --- /dev/null +++ b/spec/dummy/config/initializers/secret_token.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +Dummy::Application.config.secret_token = '2dedaee4c6eee3735e5295881d870bd4aaa3dbae40d8662db7accc5abd68bf3159c35f38d661f96e016db3a2644012a058da4e14bd19b752b4fd31f7b742ecbe' diff --git a/spec/dummy/config/initializers/session_store.rb b/spec/dummy/config/initializers/session_store.rb new file mode 100644 index 00000000..952473ff --- /dev/null +++ b/spec/dummy/config/initializers/session_store.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +Dummy::Application.config.session_store :cookie_store, key: '_dummy_session' + +# Use the database for sessions instead of the cookie-based default, +# which shouldn't be used to store highly confidential information +# (create the session table with "rails generate session_migration") +# Dummy::Application.config.session_store :active_record_store diff --git a/spec/dummy/config/initializers/wrap_parameters.rb b/spec/dummy/config/initializers/wrap_parameters.rb new file mode 100644 index 00000000..999df201 --- /dev/null +++ b/spec/dummy/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# Disable root element in JSON by default. +ActiveSupport.on_load(:active_record) do + self.include_root_in_json = false +end diff --git a/spec/dummy/config/locales/en.yml b/spec/dummy/config/locales/en.yml new file mode 100644 index 00000000..179c14ca --- /dev/null +++ b/spec/dummy/config/locales/en.yml @@ -0,0 +1,5 @@ +# Sample localization file for English. Add more files in this directory for other locales. +# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. + +en: + hello: "Hello world" diff --git a/spec/dummy/config/mongoid.yml b/spec/dummy/config/mongoid.yml new file mode 100644 index 00000000..17611c5e --- /dev/null +++ b/spec/dummy/config/mongoid.yml @@ -0,0 +1,20 @@ +defaults: &defaults + host: localhost + port: 27017 + # slaves: + # - host: slave1.local + # port: 27018 + # - host: slave2.local + # port: 27019 + +development: + <<: *defaults + database: locomotive_engine_dev + +test: + <<: *defaults + database: locomotive_engine_test + +production: + <<: *defaults + database: locomotive_engine_production diff --git a/spec/dummy/config/routes.rb b/spec/dummy/config/routes.rb new file mode 100644 index 00000000..e66c4212 --- /dev/null +++ b/spec/dummy/config/routes.rb @@ -0,0 +1,8 @@ +Rails.application.routes.draw do + + # locomotive authentication + devise_for :account, :class_name => 'Locomotive::Account', :controllers => { :sessions => 'locomotive/sessions', :passwords => 'locomotive/passwords' } + + mount Locomotive::Engine => '/locomotive' + +end diff --git a/spec/dummy/lib/assets/.gitkeep b/spec/dummy/lib/assets/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/spec/dummy/log/.gitkeep b/spec/dummy/log/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/spec/dummy/log/development.log b/spec/dummy/log/development.log new file mode 100644 index 00000000..648355da --- /dev/null +++ b/spec/dummy/log/development.log @@ -0,0 +1,271 @@ +MongoDB logging. Please note that logging negatively impacts performance and should be disabled for high-performance production apps. +MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1) +MongoDB logging. Please note that logging negatively impacts performance and should be disabled for high-performance production apps. +MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1) +MongoDB logging. Please note that logging negatively impacts performance and should be disabled for high-performance production apps. +MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1) +MongoDB logging. Please note that logging negatively impacts performance and should be disabled for high-performance production apps. +MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1) +MongoDB logging. Please note that logging negatively impacts performance and should be disabled for high-performance production apps. +MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1) +MongoDB logging. Please note that logging negatively impacts performance and should be disabled for high-performance production apps. +MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1) +MongoDB logging. Please note that logging negatively impacts performance and should be disabled for high-performance production apps. +MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1) +MongoDB logging. Please note that logging negatively impacts performance and should be disabled for high-performance production apps. +MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1) +MongoDB logging. Please note that logging negatively impacts performance and should be disabled for high-performance production apps. +MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1) +DEPRECATION WARNING: class_inheritable_attribute is deprecated, please use class_attribute method instead. Notice their behavior are slightly different, so refer to class_attribute documentation first. (called from acts_as_tree at /Users/didier/Desktop/NoCoffee/LocomotiveCMS/gems/acts_as_tree/lib/mongoid_acts_as_tree.rb:21) +MONGODB locomotive_engine_dev['system.namespaces'].find({}) +MONGODB locomotive_engine_dev['$cmd'].find({:create=>"locomotive_pages"}).limit(-1) +MONGODB locomotive_engine_dev['locomotive_pages'].find({}).limit(-1).sort([[:_id, :asc]]) +MONGODB locomotive_engine_dev['locomotive_pages'].find({}).limit(-1).sort([[:_id, :asc]]) +MONGODB locomotive_engine_dev['locomotive_pages'].find({}).limit(-1).sort([[:_id, :asc]]) +MongoDB logging. Please note that logging negatively impacts performance and should be disabled for high-performance production apps. +MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1) + + +Started GET "/" for 127.0.0.1 at 2011-10-30 19:28:31 +0100 + Processing by Locomotive::RenderingController#show as HTML +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['system.namespaces'].find({}) +MONGODB locomotive_engine_dev['$cmd'].find({:create=>"locomotive_sites"}).limit(-1) +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +MONGODB locomotive_engine_dev['system.namespaces'].find({}) +MONGODB locomotive_engine_dev['$cmd'].find({:create=>"locomotive_accounts"}).limit(-1) +MONGODB locomotive_engine_dev['$cmd'].find({"count"=>"locomotive_accounts", "query"=>{}, "fields"=>nil}).limit(-1) +Completed 500 Internal Server Error in 89ms + +NameError (undefined local variable or method `locomotive_installation_url' for #): + + +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.3ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.8ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (5.3ms) + + +Started GET "/" for 127.0.0.1 at 2011-10-30 19:29:29 +0100 + Processing by Locomotive::RenderingController#show as HTML +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +MONGODB locomotive_engine_dev['$cmd'].find({"count"=>"locomotive_accounts", "query"=>{}, "fields"=>nil}).limit(-1) +Completed 500 Internal Server Error in 96ms + +NameError (undefined local variable or method `locomotive_installation_url' for #): + + +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.3ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.7ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (4.1ms) + + +Started GET "/projects/feed" for 127.0.0.1 at 2011-10-30 19:30:36 +0100 + Processing by Locomotive::RenderingController#show as */* + Parameters: {"path"=>"projects/feed"} +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +MONGODB locomotive_engine_dev['$cmd'].find({"count"=>"locomotive_accounts", "query"=>{}, "fields"=>nil}).limit(-1) +Completed 500 Internal Server Error in 32ms + +NameError (undefined local variable or method `locomotive_installation_url' for #): + + +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.4ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.0ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (17.0ms) + + +Started GET "/projects/feed" for 127.0.0.1 at 2011-10-30 20:00:38 +0100 + Processing by Locomotive::RenderingController#show as */* + Parameters: {"path"=>"projects/feed"} +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +MONGODB locomotive_engine_dev['$cmd'].find({"count"=>"locomotive_accounts", "query"=>{}, "fields"=>nil}).limit(-1) +Completed 500 Internal Server Error in 96ms + +NameError (undefined local variable or method `locomotive_installation_url' for #): + + +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.3ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.9ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (4.8ms) + + +Started GET "/projects/feed" for 127.0.0.1 at 2011-10-30 20:30:40 +0100 + Processing by Locomotive::RenderingController#show as */* + Parameters: {"path"=>"projects/feed"} +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +MONGODB locomotive_engine_dev['$cmd'].find({"count"=>"locomotive_accounts", "query"=>{}, "fields"=>nil}).limit(-1) +Completed 500 Internal Server Error in 54ms + +NameError (undefined local variable or method `locomotive_installation_url' for #): + + +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.5ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.9ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (5.0ms) + + +Started GET "/" for 127.0.0.1 at 2011-10-30 20:49:04 +0100 + Processing by Locomotive::RenderingController#show as HTML +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +MONGODB locomotive_engine_dev['$cmd'].find({"count"=>"locomotive_accounts", "query"=>{}, "fields"=>nil}).limit(-1) +Completed 500 Internal Server Error in 98ms + +NameError (undefined local variable or method `locomotive_installation_url' for #): + + +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.3ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.8ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (3.9ms) +MongoDB logging. Please note that logging negatively impacts performance and should be disabled for high-performance production apps. +MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1) + + +Started GET "/projects/feed" for 127.0.0.1 at 2011-10-30 21:00:42 +0100 + Processing by Locomotive::RenderingController#show as */* + Parameters: {"path"=>"projects/feed"} +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +MONGODB locomotive_engine_dev['$cmd'].find({"count"=>"locomotive_accounts", "query"=>{}, "fields"=>nil}).limit(-1) +Completed 500 Internal Server Error in 33ms + +NameError (undefined local variable or method `locomotive_installation_url' for #): + + +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.8ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.8ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (8.1ms) +MongoDB logging. Please note that logging negatively impacts performance and should be disabled for high-performance production apps. +MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1) +MongoDB logging. Please note that logging negatively impacts performance and should be disabled for high-performance production apps. +MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1) +MongoDB logging. Please note that logging negatively impacts performance and should be disabled for high-performance production apps. +MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1) + + +Started GET "/projects/feed" for 127.0.0.1 at 2011-10-30 21:30:43 +0100 + Processing by Locomotive::RenderingController#show as */* + Parameters: {"path"=>"projects/feed"} +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['system.namespaces'].find({}) +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +MONGODB locomotive_engine_dev['system.namespaces'].find({}) +MONGODB locomotive_engine_dev['$cmd'].find({"count"=>"locomotive_accounts", "query"=>{}, "fields"=>nil}).limit(-1) +Completed 500 Internal Server Error in 148ms + +NameError (undefined local variable or method `locomotive_installation_url' for #): + + +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.4ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.8ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (5.1ms) + + +Started GET "/projects/feed" for 127.0.0.1 at 2011-10-30 22:00:45 +0100 + Processing by Locomotive::RenderingController#show as */* + Parameters: {"path"=>"projects/feed"} +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +MONGODB locomotive_engine_dev['$cmd'].find({"count"=>"locomotive_accounts", "query"=>{}, "fields"=>nil}).limit(-1) +Completed 500 Internal Server Error in 31ms + +NameError (undefined local variable or method `locomotive_installation_url' for #): + + +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.2ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (65.9ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (69.0ms) + + +Started GET "/projects/feed" for 127.0.0.1 at 2011-10-30 22:30:47 +0100 + Processing by Locomotive::RenderingController#show as */* + Parameters: {"path"=>"projects/feed"} +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +MONGODB locomotive_engine_dev['$cmd'].find({"count"=>"locomotive_accounts", "query"=>{}, "fields"=>nil}).limit(-1) +Completed 500 Internal Server Error in 30ms + +NameError (undefined local variable or method `locomotive_installation_url' for #): + + +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.3ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.9ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (4.2ms) + + +Started GET "/projects/feed" for 127.0.0.1 at 2011-10-30 23:00:48 +0100 + Processing by Locomotive::RenderingController#show as */* + Parameters: {"path"=>"projects/feed"} +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +MONGODB locomotive_engine_dev['$cmd'].find({"count"=>"locomotive_accounts", "query"=>{}, "fields"=>nil}).limit(-1) +Completed 500 Internal Server Error in 35ms + +NameError (undefined local variable or method `locomotive_installation_url' for #): + + +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.3ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.0ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (69.0ms) + + +Started GET "/projects/feed" for 127.0.0.1 at 2011-10-30 23:30:50 +0100 + Processing by Locomotive::RenderingController#show as */* + Parameters: {"path"=>"projects/feed"} +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +MONGODB locomotive_engine_dev['$cmd'].find({"count"=>"locomotive_accounts", "query"=>{}, "fields"=>nil}).limit(-1) +Completed 500 Internal Server Error in 38ms + +NameError (undefined local variable or method `locomotive_installation_url' for #): + + +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.4ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.9ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (4.6ms) + + +Started GET "/projects/feed" for 127.0.0.1 at 2011-10-31 00:00:52 +0100 + Processing by Locomotive::RenderingController#show as */* + Parameters: {"path"=>"projects/feed"} +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +[LocomotiveCMS] [fetch site] host = localhost / localhost:8080 +MONGODB locomotive_engine_dev['locomotive_sites'].find({}).limit(-1).sort([[:_id, :asc]]) +MONGODB locomotive_engine_dev['$cmd'].find({"count"=>"locomotive_accounts", "query"=>{}, "fields"=>nil}).limit(-1) +Completed 500 Internal Server Error in 96ms + +NameError (undefined local variable or method `locomotive_installation_url' for #): + + +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.3ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.8ms) +Rendered /Users/didier/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (4.2ms) diff --git a/spec/dummy/public/404.html b/spec/dummy/public/404.html new file mode 100644 index 00000000..9a48320a --- /dev/null +++ b/spec/dummy/public/404.html @@ -0,0 +1,26 @@ + + + + The page you were looking for doesn't exist (404) + + + + + +
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+ + diff --git a/spec/dummy/public/422.html b/spec/dummy/public/422.html new file mode 100644 index 00000000..83660ab1 --- /dev/null +++ b/spec/dummy/public/422.html @@ -0,0 +1,26 @@ + + + + The change you wanted was rejected (422) + + + + + +
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+ + diff --git a/spec/dummy/public/500.html b/spec/dummy/public/500.html new file mode 100644 index 00000000..b80307fc --- /dev/null +++ b/spec/dummy/public/500.html @@ -0,0 +1,26 @@ + + + + We're sorry, but something went wrong (500) + + + + + +
+

We're sorry, but something went wrong.

+

We've been notified about this issue and we'll take a look at it shortly.

+
+ + diff --git a/spec/dummy/public/favicon.ico b/spec/dummy/public/favicon.ico new file mode 100644 index 00000000..e69de29b diff --git a/spec/dummy/script/rails b/spec/dummy/script/rails new file mode 100755 index 00000000..f8da2cff --- /dev/null +++ b/spec/dummy/script/rails @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby +# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. + +APP_PATH = File.expand_path('../../config/application', __FILE__) +require File.expand_path('../../config/boot', __FILE__) +require 'rails/commands' diff --git a/spec/lib/locomotive/render_spec.rb b/spec/lib/locomotive/render_spec.rb index 49f9363e..c524269b 100644 --- a/spec/lib/locomotive/render_spec.rb +++ b/spec/lib/locomotive/render_spec.rb @@ -161,7 +161,7 @@ describe 'Locomotive rendering system' do before(:each) do @page.published = false - @controller.current_admin = nil + @controller.current_account = nil end it 'should return the 404 page if the page has not been published yet' do @@ -173,7 +173,7 @@ describe 'Locomotive rendering system' do end it 'should not return the 404 page if the page has not been published yet and admin is logged in' do - @controller.current_admin = true + @controller.current_account = true @controller.request.fullpath = '/contact' @controller.current_site.pages.expects(:any_in).with({ :fullpath => %w{contact content_type_template} }).returns([@page]) @controller.send(:locomotive_page).should == @page diff --git a/spec/lib/locomotive/routing/site_dispatcher_spec.rb b/spec/lib/locomotive/routing/site_dispatcher_spec.rb index 6b4a4c6f..198755cf 100644 --- a/spec/lib/locomotive/routing/site_dispatcher_spec.rb +++ b/spec/lib/locomotive/routing/site_dispatcher_spec.rb @@ -84,7 +84,7 @@ describe Locomotive::Routing::SiteDispatcher do @controller.instance_variable_set('@_response', ActionDispatch::Response.new) @controller.expects(:current_site).returns(false) - @controller.stubs(:admin_installation_url).returns('/admin/install/url/') + @controller.stubs(:locomotive_installation_url).returns('/admin/install/url/') @controller.stubs(:redirect_to).with('/admin/install/url/') end @@ -107,7 +107,7 @@ describe Locomotive::Routing::SiteDispatcher do @controller.instance_variable_set('@_response', ActionDispatch::Response.new) @controller.expects(:current_site).returns(false) - @controller.stubs(:admin_installation_url).returns('/admin/install/url/') + @controller.stubs(:locomotive_installation_url).returns('/admin/install/url/') @controller.stubs(:redirect_to).with('/admin/install/url/') end @@ -163,9 +163,9 @@ describe Locomotive::Routing::SiteDispatcher do @controller.instance_variable_set('@_response', ActionDispatch::Response.new) @controller.stubs(:request).returns(@request) - @controller.stubs(:current_admin).returns(@account) + @controller.stubs(:current_account).returns(@account) @controller.stubs(:sign_out).with(@account) - @controller.stubs(:new_admin_session_url).returns('/new/admin/session') + @controller.stubs(:new_locomotive_session_url).returns('/new/admin/session') end context 'when a site is present' do diff --git a/spec/support/controller.rb b/spec/support/controller.rb index 7e87fa76..e29e1b76 100644 --- a/spec/support/controller.rb +++ b/spec/support/controller.rb @@ -3,7 +3,7 @@ module Locomotive include Locomotive::Render - attr_accessor :output, :status, :current_site, :current_admin + attr_accessor :output, :status, :current_site, :current_account def render(options = {}) self.output = options[:text]