Module: Locomotive

Extended by:
ActiveSupport::Autoload
Defined in:
lib/locomotive/version.rb,
lib/locomotive.rb,
lib/locomotive/cancan.rb,
lib/locomotive/engine.rb,
lib/locomotive/logger.rb,
lib/locomotive/render.rb,
lib/locomotive/regexps.rb,
lib/locomotive/markdown.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/base.rb,
lib/locomotive/liquid/drops/page.rb,
lib/locomotive/liquid/drops/site.rb,
lib/locomotive/middlewares/cache.rb,
lib/locomotive/mongoid/presenter.rb,
app/inputs/locomotive/empty_input.rb,
app/models/locomotive/theme_asset.rb,
lib/locomotive/liquid/tags/hybrid.rb,
app/cells/locomotive/partials_cell.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/link_to.rb,
lib/locomotive/liquid/tags/path_to.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/api_key_input.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,
app/models/locomotive/editable_text.rb,
lib/locomotive/liquid/tags/paginate.rb,
app/mailers/locomotive/devise_mailer.rb,
app/mailers/locomotive/notifications.rb,
lib/locomotive/action_controller/ssl.rb,
lib/locomotive/liquid/drops/uploader.rb,
lib/locomotive/liquid/filters/resize.rb,
lib/locomotive/middlewares/permalink.rb,
app/inputs/locomotive/subdomain_input.rb,
lib/locomotive/liquid/tags/fetch_page.rb,
lib/locomotive/liquid/tags/javascript.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/liquid/tags/path_helper.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/liquid/tags/editable/text.rb,
lib/locomotive/middlewares/inline_editor.rb,
app/models/locomotive/editable_short_text.rb,
lib/locomotive/action_controller/timezone.rb,
lib/locomotive/liquid/drops/content_entry.rb,
lib/locomotive/liquid/drops/content_types.rb,
lib/locomotive/liquid/drops/session_proxy.rb,
lib/locomotive/liquid/tags/session_assign.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,
app/models/locomotive/extensions/shared/slug.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/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/models/locomotive/extensions/site/timezone.rb,
app/presenters/locomotive/membership_presenter.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,
app/presenters/locomotive/editable_text_presenter.rb,
app/presenters/locomotive/editable_text_presenter.rb,
app/presenters/locomotive/editable_text_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_entry/csv.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/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/controllers/locomotive/api/content_assets_controller.rb,
app/models/locomotive/extensions/content_entry/localized.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, Markdown, Middlewares, Misc, Mongoid, PagesHelper, Presentable, Public, Regexps, Render, Routing, SitesHelper, SnippetsHelper, ThemeAssetsHelper, TranslationsHelper Classes: Ability, Account, AccountPresenter, AccountsController, ApiKeyInput, 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, EditableText, EditableTextPresenter, EmptyInput, Engine, FileInput, GlobalActionsCell, InstallGenerator, InstallationController, LocaleInput, LocalesInput, MainMenuCell, Membership, MembershipPresenter, MembershipsController, MenuCell, MyAccountController, Notifications, Page, PagePresenter, PagesController, PartialsCell, PasswordsController, RteInput, SessionsController, SettingsMenuCell, Site, SitePresenter, SitesController, SmallCodeInput, Snippet, SnippetPresenter, SnippetsController, SubMenuCell, SubdomainInput, ThemeAsset, ThemeAssetPresenter, ThemeAssetUploader, ThemeAssetsController, ToggleInput, Translation, TranslationPresenter, TranslationsController

Constant Summary collapse

VERSION =
'2.4.1'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject

Returns the value of attribute config.



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

def config
  @config
end

Class Method Details

.add_middlewaresObject



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

def self.add_middlewares
  self.app_middleware.insert 0, '::Locomotive::Middlewares::Permalink'

  self.app_middleware.insert 1, '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.use '::Locomotive::Middlewares::SeoTrailingSlash'

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

.after_configureObject



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

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

  # 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

  # Check for outdated Dragonfly config
  conf = Dragonfly.app.configuration
  if conf[:identify_command] == conf[:convert_command]
    Locomotive.log :warn, "WARNING: Old Dragonfly config detected, image uploads might be broken. Use 'rails g locomotive:install' to get the latest configuration files."
  end
end

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

Yields:



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

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

  yield(self.config)


  after_configure
end

.configure_multi_sitesObject



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

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



108
109
110
111
112
113
114
# File 'lib/locomotive.rb', line 108

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



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

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



116
117
118
119
120
121
# File 'lib/locomotive.rb', line 116

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



128
129
130
# File 'lib/locomotive.rb', line 128

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

.rack_cache?Boolean

rack_cache: needed by default

Returns:



124
125
126
# File 'lib/locomotive.rb', line 124

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