xhive 1.5.0.pre → 1.5.1.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,7 +43,7 @@ module Xhive
43
43
 
44
44
  mapper = find_exact_map(site, resource, action, key, policy)
45
45
  mapper = new(:site_id => site.id, :resource => resource,
46
- :action => action, :policy => policy,
46
+ :action => action, :policy => policy.present? ? policy : nil,
47
47
  :key => key.present? ? key : nil) unless mapper.present?
48
48
  mapper.page = page
49
49
  mapper.save
@@ -16,6 +16,10 @@ module Xhive
16
16
  @object.id
17
17
  end
18
18
 
19
+ def safe_user
20
+ controller.try(:safe_user).try(:presenter)
21
+ end
22
+
19
23
  private
20
24
 
21
25
  def controller
@@ -12,19 +12,12 @@ module Xhive
12
12
  # Returns: the rendered page content.
13
13
  #
14
14
  def render_content(options={})
15
- liquified = LiquidWrapper.liquify_objects(options)
16
15
  layout = ::Liquid::Template.parse("{{content}}").render({"content" => page.content})
17
- text = ::Liquid::Template.parse(layout).render(
18
- {'page' => self, 'user' => controller.try(:safe_user).try(:presenter)}.merge(liquified.stringify_keys),
19
- :registers => {:controller => controller}
20
- )
21
- result = text.html_safe
16
+ result = ::Liquid::Template.parse(layout).render(optional_data(options), :registers => {:controller => controller}).html_safe
22
17
  rescue => e
23
- logger.error "#{e.class.name}: #{e.message}"
24
- logger.error e.backtrace.join("/n")
25
- result = ''
18
+ log_error(e)
26
19
  ensure
27
- return result
20
+ return result.to_s
28
21
  end
29
22
 
30
23
  # Public: renders the page title.
@@ -34,14 +27,25 @@ module Xhive
34
27
  # Returns: the rendered page title.
35
28
  #
36
29
  def render_title(options={})
37
- liquified = LiquidWrapper.liquify_objects(options)
38
- result = ::Liquid::Template.parse(title).render(liquified.stringify_keys)
30
+ result = ::Liquid::Template.parse(title).render(optional_data(options))
39
31
  rescue => e
32
+ log_error(e)
33
+ ensure
34
+ return result.to_s
35
+ end
36
+
37
+ private
38
+
39
+ def optional_data(options)
40
+ # wrap the options data to use it from liquid
41
+ liquified = LiquidWrapper.liquify_objects(options)
42
+ # build the optional data hash
43
+ {'page' => self, 'user' => safe_user}.merge(liquified.stringify_keys)
44
+ end
45
+
46
+ def log_error(e)
40
47
  logger.error "#{e.class.name}: #{e.message}"
41
48
  logger.error e.backtrace.join("/n")
42
- result = ''
43
- ensure
44
- return result
45
49
  end
46
50
  end
47
51
  end
data/lib/xhive/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Xhive
2
- VERSION = "1.5.0.pre"
2
+ VERSION = "1.5.1.pre"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xhive
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0.pre
4
+ version: 1.5.1.pre
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-28 00:00:00.000000000 Z
12
+ date: 2012-11-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -283,7 +283,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
283
283
  version: '0'
284
284
  segments:
285
285
  - 0
286
- hash: -2539444549338109190
286
+ hash: 987173346002263411
287
287
  required_rubygems_version: !ruby/object:Gem::Requirement
288
288
  none: false
289
289
  requirements: