Module: Locomotive

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

Constant Summary

VERSION =
'2.1.0'

Class Attribute Summary (collapse)

Class Method Summary (collapse)

Class Attribute Details

+ (Object) config

Returns the value of attribute config



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

def config
  @config
end

Class Method Details

+ (Object) add_middlewares



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/locomotive.rb', line 81

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.insert_after 'Dragonfly::Middleware', '::Locomotive::Middlewares::Fonts', path: %r{^/fonts}

  self.app_middleware.use '::Locomotive::Middlewares::SeoTrailingSlash'

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

+ (Object) after_configure



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

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

  # 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

+ (Object) configure {|self.config| ... }

Yields:



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

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

  yield(self.config)

  after_configure
end

+ (Object) configure_multi_sites



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

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

+ (Object) define_subdomain_and_domains_options



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

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

+ (Object) enable_hosting



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

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

+ (Object) log(*args)



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

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

+ (Object) mounted_on



136
137
138
# File 'lib/locomotive.rb', line 136

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

+ (Boolean) rack_cache?

rack_cache: needed by default

Returns:



132
133
134
# File 'lib/locomotive.rb', line 132

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