xhive 1.3.0.pre → 1.4.0.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -39,10 +39,10 @@ rake xhive:install:migrations
39
39
  rake db:migrate
40
40
  ```
41
41
 
42
- Include the xhive javascript in your head tag.
42
+ Include the xhive javascript loader in your head tag.
43
43
 
44
44
  ```erb
45
- <%= javascript_include_tag "xhive/application" %>
45
+ <%= javascript_include_tag "xhive/loader" %>
46
46
  ```
47
47
 
48
48
  Include the custom stylesheets in your head tag.
@@ -332,6 +332,20 @@ Then you can add your stylesheet into your email page using the corresponding ta
332
332
 
333
333
  This will create a `<style>` tag inside your email page and inject all the style rules.
334
334
 
335
+ ### Inline pages for your emails
336
+
337
+ If you add the inline widget to your cell routes you can use inline pages within your email pages:
338
+
339
+ ```ruby
340
+ Xhive::Router::Cells.draw do |router|
341
+ router.mount 'page/:id', :to => 'xhive/page#inline', :inline => true, :as => :inline_page
342
+ end
343
+ ```
344
+
345
+ Then you can add your inline page into your email page using the corresponding tag:
346
+
347
+ `{% inline_page id:email_header %}`
348
+
335
349
  TODO
336
350
  ====
337
351
 
@@ -19,5 +19,9 @@ module Xhive
19
19
  def present_content(opts={})
20
20
  presenter.render_content(opts)
21
21
  end
22
+
23
+ def present_title(opts={})
24
+ presenter.render_title(opts)
25
+ end
22
26
  end
23
27
  end
@@ -5,6 +5,12 @@ module Xhive
5
5
 
6
6
  liquid_methods :name, :title, :content, :meta_keywords, :meta_description
7
7
 
8
+ # Public: renders the page content.
9
+ #
10
+ # options - The Hash containing the values to use inside the template.
11
+ #
12
+ # Returns: the rendered page content.
13
+ #
8
14
  def render_content(options={})
9
15
  liquified = LiquidWrapper.liquify_objects(options)
10
16
  layout = ::Liquid::Template.parse("{{content}}").render({"content" => page.content})
@@ -20,5 +26,22 @@ module Xhive
20
26
  ensure
21
27
  return result
22
28
  end
29
+
30
+ # Public: renders the page title.
31
+ #
32
+ # options - The Hash containing the values to use inside the template.
33
+ #
34
+ # Returns: the rendered page title.
35
+ #
36
+ def render_title(options={})
37
+ liquified = LiquidWrapper.liquify_objects(options)
38
+ result = ::Liquid::Template.parse(title).render(liquified.stringify_keys)
39
+ rescue => e
40
+ logger.error "#{e.class.name}: #{e.message}"
41
+ logger.error e.backtrace.join("/n")
42
+ result = ''
43
+ ensure
44
+ return result
45
+ end
23
46
  end
24
47
  end
data/lib/xhive/mailer.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Xhive
2
2
  class Mailer
3
- attr :site, :resource, :action, :key, :mailer, :content
3
+ attr :site, :resource, :action, :key, :mailer, :content, :page
4
4
 
5
5
  def initialize(site, mailer, key = nil)
6
6
  @site = site
@@ -8,6 +8,7 @@ module Xhive
8
8
  @mailer = mailer
9
9
  @action = mailer.action_name
10
10
  @key = key
11
+ @page = Xhive::Mapper.page_for(@site, @resource, @action, @key)
11
12
  end
12
13
 
13
14
  # Public: sends the email to the specified recipients.
@@ -17,13 +18,13 @@ module Xhive
17
18
  # :from
18
19
  # :to
19
20
  # :reply_to
20
- # :subject
21
+ # :subject (uses page title if mapper is found)
21
22
  #
22
23
  # block - The block for customizing the email sending.
23
24
  #
24
25
  def send(opts = {}, &block)
25
26
  unless block_given?
26
- mailer.send(:mail, opts) do |format|
27
+ mailer.send(:mail, opts.merge(:subject => subject || opts[:subject])) do |format|
27
28
  format.html { mailer.render :text => content }
28
29
  end
29
30
  else
@@ -37,10 +38,17 @@ module Xhive
37
38
  #
38
39
  def content
39
40
  return @content if @content.present?
40
- page = Xhive::Mapper.page_for(site, resource, action, key)
41
41
  @content = page.present? ? page.present_content(mailer_instance_variables(mailer)) : mailer.render
42
42
  end
43
43
 
44
+ # Public: returns the email subject.
45
+ #
46
+ # Returns: the rendered template or the mapped page content body.
47
+ #
48
+ def subject
49
+ @subject = page.present? ? page.present_title(mailer_instance_variables(mailer)) : nil
50
+ end
51
+
44
52
  private
45
53
 
46
54
  # Private: extracts the instance variables from the mailer object.
data/lib/xhive/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Xhive
2
- VERSION = "1.3.0.pre"
2
+ VERSION = "1.4.0.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.3.0.pre
4
+ version: 1.4.0.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-15 00:00:00.000000000 Z
12
+ date: 2012-11-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -298,7 +298,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
298
298
  version: '0'
299
299
  segments:
300
300
  - 0
301
- hash: 392995254434772394
301
+ hash: 679411744217455480
302
302
  required_rubygems_version: !ruby/object:Gem::Requirement
303
303
  none: false
304
304
  requirements: