replace the metafields_label site attribute by something more powerful: metafields_ui + better error message if something goes wrong

did committed Mar 17, 2016
commit 0735f57354b06ba229a64bcccbfdaea702c0ec49
Showing 9 changed files with 35 additions and 20 deletions
Gemfile +1 -1
@@ @@ -12,7 +12,7 @@ gem 'rb-fsevent', '~> 0.9.1'
# Local development
# gem 'locomotivecms_coal', path: '../gems/coal', require: false
- # gem 'locomotivecms_steam', path: '../gems/steam', require: false
+ gem 'locomotivecms_steam', path: '../gems/steam', require: false
# gem 'locomotivecms_common', path: '../gems/common', require: false
group :development, :test do
generators/blank/config/site.yml.tt +5 -3
@@ @@ -27,9 +27,11 @@ seo_title: <%= @name %>
meta_keywords: "some meta keywords"
meta_description: "some meta description"
- # You can change the label of the metafields section in the Locomotive Engine left sidebar.
- # Default label is "Properties".
- # metafields_label: Store settings
+ # You can control the display of the "Properties" section in the back-office
+ # metafields_ui:
+ # label: Store settings # use a hash for localized versions
+ # icon: shopping-cart # FontAwesome icons without the leading "fa-" string.
+ # hint: "Lorem ipsum..."
# Each site can have its own set of custom properties organized in namespaces.
# First, define namespaces and their fields in the config/metafields_schema.yml file.
generators/bootstrap/config/site.yml.tt +5 -3
@@ @@ -27,9 +27,11 @@ seo_title: <%= @name %>
meta_keywords: "some meta keywords"
meta_description: "some meta description"
- # You can change the label of the metafields section in the Locomotive Engine left sidebar.
- # Default label is "Properties".
- # metafields_label: Store settings
+ # You can control the display of the "Properties" section in the back-office
+ # metafields_ui:
+ # label: Store settings # use a hash for localized versions
+ # icon: shopping-cart # FontAwesome icons without the leading "fa-" string.
+ # hint: "Lorem ipsum..."
# Each site can have its own set of custom properties organized in namespaces.
# First, define namespaces and their fields in the config/metafields_schema.yml file.
generators/foundation5/config/site.yml.tt +5 -3
@@ @@ -27,9 +27,11 @@ seo_title: <%= @name %>
meta_keywords: "some meta keywords"
meta_description: "some meta description"
- # You can change the label of the metafields section in the Locomotive Engine left sidebar.
- # Default label is "Properties".
- # metafields_label: Store settings
+ # You can control the display of the "Properties" section in the back-office
+ # metafields_ui:
+ # label: Store settings # use a hash for localized versions
+ # icon: shopping-cart # FontAwesome icons without the leading "fa-" string.
+ # hint: "Lorem ipsum..."
# Each site can have its own set of custom properties organized in namespaces.
# First, define namespaces and their fields in the config/metafields_schema.yml file.
locomotive/wagon/cli.rb b/lib/locomotive/wagon/cli.rb +6 -2
@@ @@ -399,9 +399,13 @@ module Locomotive
# @param [ Boolean ] verbose Print the full backtrace if true
#
def print_exception(exception, verbose)
- say exception.message, :red
if verbose
- say "\t" + exception.backtrace.join("\n\t")
+ say "\n# Error description:", :bold
+ say exception.message, :red
+ say "\n# Backtrace:", :bold
+ say "\n\t" + exception.backtrace.join("\n\t")
+ else
+ say "\n\nError(s) found. Please use the -v option to display the full exception", :red
end
end
locomotive/wagon/commands/pull_sub_commands/pull_site_command.rb b/lib/locomotive/wagon/commands/pull_sub_commands/pull_site_command.rb +1 -1
@@ @@ -3,7 +3,7 @@ module Locomotive::Wagon
class PullSiteCommand < PullBaseCommand
def _pull
- attributes = current_site.attributes.slice('name', 'locales', 'domains', 'timezone', 'seo_title', 'meta_keywords', 'meta_description', 'picture_thumbnail_url', 'metafields', 'metafields_schema')
+ attributes = current_site.attributes.slice('name', 'locales', 'domains', 'timezone', 'seo_title', 'meta_keywords', 'meta_description', 'picture_thumbnail_url', 'metafields', 'metafields_schema', 'metafields_ui')
locales.each_with_index do |locale, index|
if index == 0
locomotive/wagon/commands/push_sub_commands/push_base_command.rb b/lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb +3 -0
@@ @@ -35,6 +35,9 @@ module Locomotive::Wagon
instrument :persist_with_success
rescue SkipPersistingException => e
instrument :skip_persisting
+ rescue Locomotive::Coal::ServerSideError => e
+ instrument :persist_with_error, message: 'Locomotive Back-office error. Contact your administrator or check your application logs.'
+ raise e
rescue Exception => e
instrument :persist_with_error, message: e.message
raise e
locomotive/wagon/decorators/site_decorator.rb b/lib/locomotive/wagon/decorators/site_decorator.rb +4 -4
@@ @@ -12,8 +12,8 @@ module Locomotive
(__getobj__.domains || []) - ['localhost']
end
- def metafields_label
- self[:metafields_label]
+ def metafields_ui
+ self[:metafields_ui].try(:to_json)
end
def metafields_schema
@@ @@ -41,7 +41,7 @@ module Locomotive
end
def __attributes__
- %i(name handle robots_txt locales timezone seo_title meta_keywords meta_description picture metafields_schema metafields metafields_label)
+ %i(name handle robots_txt locales timezone seo_title meta_keywords meta_description picture metafields_schema metafields metafields_ui)
end
def edited?
@@ @@ -53,7 +53,7 @@ module Locomotive
class UpdateSiteDecorator < SiteDecorator
def __attributes__
- %i(picture locales metafields_schema metafields metafields_label)
+ %i(picture locales metafields_schema metafields metafields_ui)
end
end
locomotive/wagon/generators/site_metafields.rb b/lib/locomotive/wagon/generators/site_metafields.rb +5 -3
@@ @@ -21,9 +21,11 @@ module Locomotive
def add_instructions
append_to_file 'config/site.yml', <<-EOF
- # You can change the label of the metafields section in the Locomotive Engine left sidebar.
- # Default label is "Properties".
- # metafields_label: Store settings
+ # You can control the display of the "Properties" section in the back-office
+ # metafields_ui:
+ # label: Store settings # use a hash for localized versions
+ # icon: shopping-cart # FontAwesome icons without the leading "fa-" string.
+ # hint: "Lorem ipsum..."
# Each site can have its own set of custom properties organized in namespaces.
# First, define namespaces and their fields in the config/metafields_schema.yml file.