lib/landable/configuration.rb in landable-1.7.1.rc1 vs lib/landable/configuration.rb in landable-1.8.0
- old
+ new
@@ -1,10 +1,16 @@
module Landable
class Configuration
- attr_writer :api_namespace, :public_namespace, :categories, :traffic_enabled
- attr_writer :sitemap_exclude_categories, :sitemap_protocol, :sitemap_host
- attr_writer :sitemap_additional_paths, :reserved_paths, :partials_to_templates, :database_schema_prefix
+ attr_accessor :api_url, :public_url
+ attr_writer :api_namespace, :public_namespace
+ attr_writer :api_host, :public_host
+ attr_writer :categories
+ attr_writer :screenshots_enabled
+ attr_writer :traffic_enabled
+ attr_writer :sitemap_exclude_categories, :sitemap_protocol, :sitemap_host, :sitemap_additional_paths
+ attr_writer :reserved_paths, :partials_to_templates, :database_schema_prefix
+ attr_writer :publicist_url
def authenticators
@authenticators || raise("No Landable authenticator configured.")
end
@@ -12,17 +18,40 @@
@authenticators = Array(authenticators)
end
alias :authenticator= :authenticators=
+ def publicist_url
+ @publicist_url ||= 'publicist.dev'
+ end
+
+ def api_uri
+ if api_url.present?
+ @api_uri ||= URI(api_url)
+ end
+ end
+
+ def api_host
+ @api_host ||= api_uri.try(:host)
+ end
+
def api_namespace
- @api_namespace ||= '/api/landable'
+ @api_namespace ||= (api_uri.try(:path).presence || '/api/landable')
end
+ def public_uri
+ if public_url.present?
+ @public_uri ||= URI(public_url)
+ end
+ end
+
+ def public_host
+ @public_host ||= public_uri.try(:host)
+ end
+
def public_namespace
- raise NotImplementedError
- @public_namespace ||= '/'
+ @public_namespace ||= (public_uri.try(:path).presence || '')
end
def database_schema_prefix
@database_schema_prefix ||= ''
end
@@ -63,9 +92,13 @@
@sitemap_protocol ||= "http"
end
def sitemap_host
@sitemap_host
+ end
+
+ def screenshots_enabled
+ @screenshots_enabled ||= false
end
def traffic_enabled
@traffic_enabled ||= false
end