xhive 1.0.1.pre → 1.0.3.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,12 +5,15 @@ module Xhive
5
5
  end
6
6
 
7
7
  def include_custom_stylesheets
8
- "<link href='#{stylesheets_path}' media='all' rel='stylesheet' type='text/css'/>".html_safe
8
+ # TODO: merge engine routes with Rails application routes
9
+ "<link href='/stylesheets/custom.css' media='all' rel='stylesheet' type='text/css'/>".html_safe
9
10
  end
10
11
 
11
- def render_page_for(resource, action, options={})
12
- page = current_site.mappers.page_for(resource, action)
13
- render :text => page.presenter.render_content(options)
12
+ def render_page_with(options={})
13
+ page = current_site.mappers.page_for(controller_name, action_name)
14
+ render :inline => page.presenter.render_content(options), :layout => true
15
+ rescue
16
+ render
14
17
  end
15
18
 
16
19
  def current_site
@@ -1,6 +1,6 @@
1
1
  module Xhive
2
2
  class Mapper < ActiveRecord::Base
3
- attr_accessible :action, :page, :site, :resource
3
+ attr_accessible :action, :page_id, :site_id, :resource
4
4
 
5
5
  belongs_to :site
6
6
  belongs_to :page
@@ -7,7 +7,7 @@ module Xhive
7
7
 
8
8
  include Xhive::Presentable
9
9
 
10
- attr_accessible :content, :meta_description, :meta_keywords, :name, :slug, :title, :site
10
+ attr_accessible :content, :meta_description, :meta_keywords, :name, :slug, :title, :site_id
11
11
 
12
12
  belongs_to :site
13
13
 
@@ -1,6 +1,6 @@
1
1
  module Xhive
2
2
  class Site < ActiveRecord::Base
3
- attr_accessible :domain, :name, :home_page
3
+ attr_accessible :domain, :name, :home_page_id
4
4
 
5
5
  has_many :pages
6
6
  has_many :mappers
@@ -8,7 +8,7 @@ module Xhive
8
8
 
9
9
  include Xhive::Presentable
10
10
 
11
- attr_accessible :content, :name, :slug, :site
11
+ attr_accessible :content, :name, :slug, :site_id
12
12
 
13
13
  belongs_to :site
14
14
 
data/lib/xhive/engine.rb CHANGED
@@ -11,13 +11,13 @@ module Xhive
11
11
 
12
12
  include Xhive::ApplicationHelper
13
13
 
14
- helper_method :initialize_widgets_loader
14
+ helper_method :initialize_widgets_loader, :include_custom_stylesheets
15
15
  end
16
16
  end
17
- initializer "xhive.load_all_controller_classes" do
17
+ initializer "xhive.load_all_controller_classes", :after=> :disable_dependency_loading do
18
18
  ActiveSupport.on_load(:action_controller) do
19
- Rails.application.reload_routes!
20
19
  Dir[Rails.root.join("app/controllers/**/*.rb")].each {|f| require f}
20
+ Xhive::Router::Cells.process_routes
21
21
  end
22
22
  end
23
23
  end
@@ -10,7 +10,7 @@ module Xhive
10
10
  # end
11
11
  #
12
12
  def self.draw
13
- Rails.application.reload_routes!
13
+ class_variable_set("@@routes", [])
14
14
  yield self
15
15
  end
16
16
 
@@ -21,15 +21,28 @@ module Xhive
21
21
  #
22
22
  # Example: mount 'my_widget', :to => 'my_cell#action'
23
23
  #
24
+ # It stores the route in internal storage for later processing
25
+ #
24
26
  def self.mount(route, options)
25
- cell, action = options[:to].split('#')
26
- widgets_base_route = Base.route_for('widgets', 'show').gsub(/\/\*\w*$/, '')
27
- widget_route = "#{widgets_base_route}/#{route}"
28
- tag_class_name = "#{cell}_#{action}".classify
27
+ @@routes << { :path => route, :options => options }
28
+ end
29
+
30
+ # Public: process the previously stored routes
31
+ #
32
+ def self.process_routes
33
+ @@routes.each do |route|
34
+ path = route[:path]
35
+ options = route[:options]
36
+
37
+ cell, action = options[:to].split('#')
38
+ widgets_base_route = Base.route_for('widgets', 'show').gsub(/\/\*\w*$/, '')
39
+ widget_route = "#{widgets_base_route}/#{path}"
40
+ tag_class_name = "#{cell}_#{action}".camelize
29
41
 
30
- Route.add(widget_route, cell.classify, action)
42
+ Route.add(widget_route, cell.camelize, action)
31
43
 
32
- Xhive::TagFactory.create_class(tag_class_name, widget_route)
44
+ Xhive::TagFactory.create_class(tag_class_name, widget_route)
45
+ end
33
46
  end
34
47
  end
35
48
  end
data/lib/xhive/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Xhive
2
- VERSION = "1.0.1.pre"
2
+ VERSION = "1.0.3.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.0.1.pre
4
+ version: 1.0.3.pre
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,64 +9,64 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-22 00:00:00.000000000 Z
12
+ date: 2012-10-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: cells
15
+ name: rails
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - '='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 3.8.5
21
+ version: '3.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - '='
27
+ - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 3.8.5
29
+ version: '3.2'
30
30
  - !ruby/object:Gem::Dependency
31
- name: friendly_id
31
+ name: jquery-rails
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ~>
35
+ - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: 4.0.1
37
+ version: '0'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ~>
43
+ - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: 4.0.1
45
+ version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
- name: liquid
47
+ name: cells
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ! '>='
51
+ - - '='
52
52
  - !ruby/object:Gem::Version
53
- version: '0'
53
+ version: 3.8.5
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ! '>='
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 3.8.5
62
62
  - !ruby/object:Gem::Dependency
63
- name: sass-rails
63
+ name: friendly_id
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: 3.2.3
69
+ version: 4.0.1
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,39 +74,39 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: 3.2.3
77
+ version: 4.0.1
78
78
  - !ruby/object:Gem::Dependency
79
- name: rails
79
+ name: liquid
80
80
  requirement: !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
83
- - - ~>
83
+ - - ! '>='
84
84
  - !ruby/object:Gem::Version
85
- version: '3.2'
86
- type: :development
85
+ version: '0'
86
+ type: :runtime
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
- - - ~>
91
+ - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
- version: '3.2'
93
+ version: '0'
94
94
  - !ruby/object:Gem::Dependency
95
- name: jquery-rails
95
+ name: sass-rails
96
96
  requirement: !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
99
- - - ! '>='
99
+ - - ~>
100
100
  - !ruby/object:Gem::Version
101
- version: '0'
102
- type: :development
101
+ version: 3.2.3
102
+ type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
- - - ! '>='
107
+ - - ~>
108
108
  - !ruby/object:Gem::Version
109
- version: '0'
109
+ version: 3.2.3
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: sqlite3
112
112
  requirement: !ruby/object:Gem::Requirement
@@ -223,7 +223,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
223
223
  version: '0'
224
224
  segments:
225
225
  - 0
226
- hash: -1032218936541057101
226
+ hash: -3877875978952443496
227
227
  required_rubygems_version: !ruby/object:Gem::Requirement
228
228
  none: false
229
229
  requirements: