Class: Locomotive::EditorService
- Inherits:
-
Struct
- Object
- Struct
- Locomotive::EditorService
- Includes:
- Concerns::ActivityService
- Defined in:
- app/services/locomotive/editor_service.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#page ⇒ Object
Returns the value of attribute page.
-
#site ⇒ Object
Returns the value of attribute site.
Instance Method Summary collapse
-
#find_resources(type, query, scope = nil, max_results = 10) ⇒ Object
Used by the URL picker to retrieve either a page or a content entry.
-
#save(site_attributes, page_attributes) ⇒ Object
Save sections for both the current site (global versions) and the page.
Methods included from Concerns::ActivityService
#track_activity, #without_tracking_activity
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account
2 3 4 |
# File 'app/services/locomotive/editor_service.rb', line 2 def account @account end |
#locale ⇒ Object
Returns the value of attribute locale
2 3 4 |
# File 'app/services/locomotive/editor_service.rb', line 2 def locale @locale end |
#page ⇒ Object
Returns the value of attribute page
2 3 4 |
# File 'app/services/locomotive/editor_service.rb', line 2 def page @page end |
#site ⇒ Object
Returns the value of attribute site
2 3 4 |
# File 'app/services/locomotive/editor_service.rb', line 2 def site @site end |
Instance Method Details
#find_resources(type, query, scope = nil, max_results = 10) ⇒ Object
Used by the URL picker to retrieve either a page or a content entry.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/services/locomotive/editor_service.rb', line 7 def find_resources(type, query, scope = nil, max_results = 10) return [] if type.blank? || query.strip.blank? case type when 'page' find_pages(query, max_results) when 'content_entry' find_content_entries(scope, query, max_results) else Rails.logger.warn("[EditorService] Unknown type: #{type}") [] end end |
#save(site_attributes, page_attributes) ⇒ Object
Save sections for both the current site (global versions) and the page
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/locomotive/editor_service.rb', line 22 def save(site_attributes, page_attributes) site_attributes[:sections_content] = parse_sections_content(site_attributes[:sections_content]) site.update_attributes(site_attributes) page_attributes[:sections_content] = parse_sections_content(page_attributes[:sections_content]) page_attributes[:sections_dropzone_content] = parse_sections_dropzone_content(page_attributes[:sections_dropzone_content]) page.update_attributes(page_attributes) track_activity 'page_content.updated', parameters: { _id: page._id, title: page.title }, locale: locale end |