Module: Locomotive

Extended by:
ActiveSupport::Autoload
Defined in:
lib/locomotive/liquid/drops/base.rb,
lib/locomotive.rb,
lib/locomotive/engine.rb,
lib/locomotive/logger.rb,
lib/locomotive/render.rb,
lib/locomotive/regexps.rb,
lib/locomotive/dragonfly.rb,
app/models/locomotive/page.rb,
app/models/locomotive/site.rb,
lib/locomotive/presentable.rb,
lib/locomotive/configuration.rb,
lib/locomotive/liquid/errors.rb,
app/models/locomotive/ability.rb,
app/models/locomotive/account.rb,
app/models/locomotive/snippet.rb,
lib/locomotive/mongoid/liquid.rb,
app/cells/locomotive/menu_cell.rb,
lib/locomotive/liquid/tags/nav.rb,
lib/locomotive/liquid/tags/seo.rb,
app/inputs/locomotive/rte_input.rb,
lib/locomotive/liquid/tags/csrf.rb,
lib/locomotive/mongoid/document.rb,
app/inputs/locomotive/code_input.rb,
app/inputs/locomotive/file_input.rb,
app/models/locomotive/membership.rb,
lib/locomotive/carrierwave/asset.rb,
lib/locomotive/liquid/drops/page.rb,
lib/locomotive/liquid/drops/site.rb,
lib/locomotive/middlewares/cache.rb,
lib/locomotive/middlewares/fonts.rb,
lib/locomotive/mongoid/presenter.rb,
app/inputs/locomotive/empty_input.rb,
app/models/locomotive/theme_asset.rb,
app/cells/locomotive/sub_menu_cell.rb,
app/helpers/locomotive/base_helper.rb,
app/inputs/locomotive/locale_input.rb,
app/inputs/locomotive/toggle_input.rb,
app/models/locomotive/content_type.rb,
lib/locomotive/httparty/webservice.rb,
lib/locomotive/liquid/filters/base.rb,
lib/locomotive/liquid/filters/date.rb,
lib/locomotive/liquid/filters/html.rb,
lib/locomotive/liquid/filters/misc.rb,
lib/locomotive/liquid/filters/text.rb,
lib/locomotive/liquid/tags/consume.rb,
lib/locomotive/liquid/tags/extends.rb,
lib/locomotive/liquid/tags/snippet.rb,
app/cells/locomotive/main_menu_cell.rb,
app/helpers/locomotive/pages_helper.rb,
app/helpers/locomotive/sites_helper.rb,
app/inputs/locomotive/locales_input.rb,
app/models/locomotive/content_asset.rb,
app/models/locomotive/content_entry.rb,
app/models/locomotive/editable_file.rb,
lib/locomotive/liquid/tags/paginate.rb,
app/mailers/locomotive/devise_mailer.rb,
app/mailers/locomotive/notifications.rb,
lib/locomotive/liquid/drops/uploader.rb,
lib/locomotive/liquid/filters/resize.rb,
app/inputs/locomotive/subdomain_input.rb,
lib/locomotive/liquid/tags/with_scope.rb,
lib/locomotive/misc/api_documentation.rb,
app/helpers/locomotive/accounts_helper.rb,
app/helpers/locomotive/snippets_helper.rb,
app/inputs/locomotive/small_code_input.rb,
app/models/locomotive/editable_control.rb,
app/models/locomotive/editable_element.rb,
lib/locomotive/routing/site_dispatcher.rb,
app/cells/locomotive/settings_menu_cell.rb,
lib/locomotive/liquid/filters/translate.rb,
app/cells/locomotive/global_actions_cell.rb,
app/models/locomotive/editable_long_text.rb,
app/presenters/locomotive/page_presenter.rb,
app/presenters/locomotive/site_presenter.rb,
lib/locomotive/liquid/drops/current_user.rb,
lib/locomotive/liquid/tags/editable/base.rb,
lib/locomotive/liquid/tags/editable/file.rb,
lib/locomotive/middlewares/inline_editor.rb,
app/models/locomotive/editable_short_text.rb,
lib/locomotive/liquid/drops/content_entry.rb,
lib/locomotive/liquid/drops/content_types.rb,
lib/locomotive/routing/default_constraint.rb,
app/controllers/locomotive/base_controller.rb,
app/helpers/locomotive/installation_helper.rb,
app/helpers/locomotive/theme_assets_helper.rb,
app/helpers/locomotive/translations_helper.rb,
app/models/locomotive/extensions/page/tree.rb,
lib/locomotive/action_controller/responder.rb,
lib/locomotive/liquid/tags/inherited_block.rb,
lib/locomotive/liquid/tags/locale_switcher.rb,
app/controllers/locomotive/pages_controller.rb,
app/controllers/locomotive/sites_controller.rb,
app/helpers/locomotive/content_types_helper.rb,
app/helpers/locomotive/custom_fields_helper.rb,
app/models/locomotive/extensions/page/parse.rb,
app/models/locomotive/extensions/shared/seo.rb,
app/presenters/locomotive/account_presenter.rb,
app/presenters/locomotive/snippet_presenter.rb,
lib/locomotive/liquid/tags/editable/control.rb,
app/models/locomotive/extensions/asset/types.rb,
app/models/locomotive/extensions/page/listed.rb,
app/models/locomotive/extensions/page/render.rb,
lib/locomotive/action_controller/url_helpers.rb,
lib/locomotive/liquid/drops/proxy_collection.rb,
app/helpers/locomotive/content_entries_helper.rb,
app/models/locomotive/extensions/site/locales.rb,
app/uploaders/locomotive/theme_asset_uploader.rb,
lib/locomotive/liquid/tags/editable/long_text.rb,
lib/locomotive/middlewares/seo_trailing_slash.rb,
app/controllers/locomotive/accounts_controller.rb,
app/controllers/locomotive/api/base_controller.rb,
app/controllers/locomotive/sessions_controller.rb,
app/controllers/locomotive/snippets_controller.rb,
app/models/locomotive/extensions/page/redirect.rb,
app/presenters/locomotive/membership_presenter.rb,
lib/locomotive/liquid/tags/editable/short_text.rb,
app/cells/locomotive/content_locale_picker_cell.rb,
app/controllers/locomotive/api/pages_controller.rb,
app/controllers/locomotive/api/sites_controller.rb,
app/controllers/locomotive/passwords_controller.rb,
app/models/locomotive/extensions/asset/vignette.rb,
app/presenters/locomotive/theme_asset_presenter.rb,
app/presenters/locomotive/translation_presenter.rb,
app/uploaders/locomotive/content_asset_uploader.rb,
app/uploaders/locomotive/editable_file_uploader.rb,
lib/locomotive/action_controller/locale_helpers.rb,
app/controllers/locomotive/api/tokens_controller.rb,
app/controllers/locomotive/my_account_controller.rb,
app/presenters/locomotive/content_type_presenter.rb,
lib/locomotive/action_controller/section_helpers.rb,
app/controllers/locomotive/memberships_controller.rb,
app/controllers/locomotive/public/base_controller.rb,
app/models/locomotive/extensions/page/templatized.rb,
app/presenters/locomotive/content_asset_presenter.rb,
app/presenters/locomotive/content_entry_presenter.rb,
app/presenters/locomotive/content_field_presenter.rb,
app/presenters/locomotive/editable_file_presenter.rb,
lib/locomotive/action_controller/public_responder.rb,
app/controllers/locomotive/api/accounts_controller.rb,
app/controllers/locomotive/api/snippets_controller.rb,
app/controllers/locomotive/current_site_controller.rb,
app/controllers/locomotive/installation_controller.rb,
app/controllers/locomotive/public/pages_controller.rb,
app/controllers/locomotive/theme_assets_controller.rb,
app/controllers/locomotive/translations_controller.rb,
app/models/locomotive/extensions/content_type/sync.rb,
app/controllers/locomotive/content_types_controller.rb,
app/controllers/locomotive/public/robots_controller.rb,
lib/generators/locomotive/install/install_generator.rb,
app/controllers/locomotive/api/my_account_controller.rb,
app/controllers/locomotive/content_assets_controller.rb,
app/presenters/locomotive/editable_control_presenter.rb,
app/presenters/locomotive/editable_element_presenter.rb,
app/controllers/locomotive/api/memberships_controller.rb,
app/controllers/locomotive/content_entries_controller.rb,
app/controllers/locomotive/public/sitemaps_controller.rb,
app/controllers/locomotive/api/current_site_controller.rb,
app/controllers/locomotive/api/theme_assets_controller.rb,
app/controllers/locomotive/api/translations_controller.rb,
app/presenters/locomotive/editable_long_text_presenter.rb,
app/controllers/locomotive/api/content_types_controller.rb,
app/controllers/locomotive/api/documentation_controller.rb,
app/models/locomotive/extensions/page/editable_elements.rb,
app/models/locomotive/extensions/site/subdomain_domains.rb,
app/presenters/locomotive/editable_short_text_presenter.rb,
app/controllers/locomotive/api/content_assets_controller.rb,
app/models/locomotive/extensions/site/first_installation.rb,
app/controllers/locomotive/api/content_entries_controller.rb,
app/models/locomotive/extensions/content_type/item_template.rb,
app/controllers/locomotive/public/content_entries_controller.rb,
app/models/locomotive/extensions/content_type/default_values.rb

Overview

Liquify taken from Mephisto sources (mephistoblog.com/)

Defined Under Namespace

Modules: AccountsHelper, ActionController, Api, BaseHelper, CarrierWave, ContentEntriesHelper, ContentTypesHelper, CustomFieldsHelper, Dragonfly, Extensions, Httparty, InstallationHelper, Liquid, Logger, Middlewares, Misc, Mongoid, PagesHelper, Presentable, Public, Regexps, Render, Routing, SitesHelper, SnippetsHelper, ThemeAssetsHelper, TranslationsHelper Classes: Ability, Account, AccountPresenter, AccountsController, BaseController, BasePresenter, CodeInput, Configuration, ConfigurationHash, ContentAsset, ContentAssetPresenter, ContentAssetUploader, ContentAssetsController, ContentEntriesController, ContentEntry, ContentEntryPresenter, ContentFieldPresenter, ContentLocalePickerCell, ContentType, ContentTypePresenter, ContentTypesController, CurrentSiteController, DeviseMailer, EditableControl, EditableControlPresenter, EditableElement, EditableElementPresenter, EditableFile, EditableFilePresenter, EditableFileUploader, EditableLongText, EditableLongTextPresenter, EditableShortText, EditableShortTextPresenter, EmptyInput, Engine, FileInput, GlobalActionsCell, InstallGenerator, InstallationController, LocaleInput, LocalesInput, MainMenuCell, Membership, MembershipPresenter, MembershipsController, MenuCell, MyAccountController, Notifications, Page, PagePresenter, PagesController, PasswordsController, RteInput, SessionsController, SettingsMenuCell, Site, SitePresenter, SitesController, SmallCodeInput, Snippet, SnippetPresenter, SnippetsController, SubMenuCell, SubdomainInput, ThemeAsset, ThemeAssetPresenter, ThemeAssetUploader, ThemeAssetsController, ToggleInput, Translation, TranslationPresenter, TranslationsController

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject

Returns the value of attribute config.



28
29
30
# File 'lib/locomotive.rb', line 28

def config
  @config
end

Class Method Details

.add_middlewaresObject



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/locomotive.rb', line 74

def self.add_middlewares
  self.app_middleware.insert 0, 'Dragonfly::Middleware', :images

  if self.rack_cache?
    self.app_middleware.insert_before 'Dragonfly::Middleware', '::Locomotive::Middlewares::Cache', self.config.rack_cache
  end

  self.app_middleware.insert_before Rack::Lock, '::Locomotive::Middlewares::Fonts', :path => %r{^/fonts}
  self.app_middleware.use '::Locomotive::Middlewares::SeoTrailingSlash'

  self.app_middleware.use '::Locomotive::Middlewares::InlineEditor'
end

.after_configureObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/locomotive.rb', line 44

def self.after_configure
  self.define_subdomain_and_domains_options

  # multi sites support
  self.configure_multi_sites

  # Devise
  mail_address = self.config.mailer_sender
  # ::Devise.mailer_sender = mail_address =~ /.+@.+/ ? mail_address : "#{mail_address}@#{Locomotive.config.domain}"

  # cookies stored in mongodb (mongoid_store)
  Rails.application.config.session_store :mongoid_store, {
    :key    => self.config.cookie_key,
    :domain => :all
  }

  # add middlewares (dragonfly, font, seo, ...etc)
  self.add_middlewares

  # Load all the dynamic classes (custom fields)
  begin
    ContentType.all.collect { |content_type| content_type.klass_with_custom_fields(:entries) }
  rescue ::Mongoid::Errors::InvalidDatabase => e
    # let assume it's because of the first install (meaning no config.yml file)
  end

  # enable the hosting solution if both we are not in test or dev and that the config.hosting option has been filled up
  self.enable_hosting
end

.configure {|self.config| ... } ⇒ Object

Yields:



36
37
38
39
40
41
42
# File 'lib/locomotive.rb', line 36

def self.configure
  self.config ||= Configuration.new

  yield(self.config)

  after_configure
end

.configure_multi_sitesObject



87
88
89
90
91
92
93
94
95
# File 'lib/locomotive.rb', line 87

def self.configure_multi_sites
  if self.config.multi_sites?
    domain_name = self.config.multi_sites.domain

    raise '[Error] Locomotive needs a domain name when used as a multi sites platform' if domain_name.blank?

    self.config.domain = domain_name
  end
end

.define_subdomain_and_domains_optionsObject



106
107
108
109
110
111
112
# File 'lib/locomotive.rb', line 106

def self.define_subdomain_and_domains_options
  if self.config.multi_sites?
    self.config.manage_subdomain = self.config.manage_domains = true
  else
    self.config.manage_domains = self.config.manage_subdomain = false
  end
end

.enable_hostingObject



97
98
99
100
101
102
103
104
# File 'lib/locomotive.rb', line 97

def self.enable_hosting
  return if Rails.env.test? || Rails.env.development? || self.config.hosting.blank?

  target = self.config.hosting[:target]
  method = :"enable_#{target}"

  self.send(method) if self.respond_to?(method)
end

.log(*args) ⇒ Object



114
115
116
117
118
119
# File 'lib/locomotive.rb', line 114

def self.log(*args)
  level   = args.size == 1 ? 'info' : args.first
  message = args.size == 1 ? args.first : args.last

  ::Locomotive::Logger.send(level.to_sym, message)
end

.mounted_onObject



126
127
128
# File 'lib/locomotive.rb', line 126

def self.mounted_on
  Rails.application.routes.named_routes[:locomotive].path.spec.to_s
end

.rack_cache?Boolean

rack_cache: needed by default

Returns:



122
123
124
# File 'lib/locomotive.rb', line 122

def self.rack_cache?
  self.config.rack_cache != false
end