xhive 1.0.3.pre → 1.0.4.pre

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,6 +3,9 @@ XHIVE
3
3
 
4
4
  xhive is a gem built for turning your Rails application into an AJAXified CMS.
5
5
 
6
+ [![Build Status](https://secure.travis-ci.org/frozeek/xhive.png)](http://travis-ci.org/frozeek/xhive)
7
+ [![Code Quality](https://codeclimate.com/badge.png)](https://codeclimate.com/github/frozeek/xhive)
8
+
6
9
  # How it works
7
10
 
8
11
  xhive converts your controller actions or [cells](https://github.com/apotonick/cells) into AJAX widgets.
@@ -36,6 +39,10 @@ rake xhive:install:migrations
36
39
  rake db:migrate
37
40
  ```
38
41
 
42
+ Include the xhive javascript in your head tag.
43
+
44
+ `<%= javascript_include_tag "xhive/application" %>`
45
+
39
46
  Include the custom stylesheets in your head tag.
40
47
 
41
48
  `<%= include_custom_stylesheets %>`
@@ -194,7 +201,7 @@ stylesheet = Xhive::Stylesheet.create(:name => 'Posts',
194
201
  Create a new mapper record for the posts resources
195
202
 
196
203
  ```
197
- mapper = Xhive::Mapper.create(:resource => 'Post', :action => 'index', :page => posts_page)
204
+ mapper = Xhive::Mapper.create(:resource => 'posts', :action => 'index', :page => posts_page)
198
205
  ```
199
206
 
200
207
  From your posts controller, render the posts page
@@ -202,8 +209,8 @@ From your posts controller, render the posts page
202
209
  ```
203
210
  class PostsController < ApplicationController
204
211
  def index
205
- @posts = Post.all.limit(10)
206
- render_page_for 'Post', 'index', :posts => @posts
212
+ @posts = Post.limit(10)
213
+ render_page_with :posts => @posts
207
214
  end
208
215
  end
209
216
  ```
@@ -4,13 +4,42 @@ module Xhive
4
4
  class WidgetsController < ApplicationController
5
5
  def show
6
6
  # Looks for a route matching the request path
7
- route = Xhive::Router::Route.find(request.path)
8
- # Gets the parameters from the request path and the query string
9
- parameters = route.params_from(request.path).merge(params).with_indifferent_access
10
- # Renders the corresponding cell#action
11
- render :text => render_cell(route.klass.underscore.to_sym, route.action.to_sym, parameters), :status => 200
7
+ route = extract_route
8
+ parameters = extract_parameters(route)
9
+ render :text => rendered_cell_content(route, parameters), :status => 200
12
10
  rescue => e
13
11
  render :text => 'Not found', :status => 404
14
12
  end
13
+
14
+ private
15
+
16
+ # Private: finds the requested route in the internal route map.
17
+ #
18
+ # Returns: a route object.
19
+ #
20
+ def extract_route
21
+ Xhive::Router::Route.find(request.path)
22
+ end
23
+
24
+ # Private: extracts the parameters from the request path and the query string.
25
+ #
26
+ # route - The Route object obtained from the request.
27
+ #
28
+ # Returns: a hash containing the request parameters.
29
+ #
30
+ def extract_parameters(route)
31
+ route.params_from(request.path).merge(params).with_indifferent_access
32
+ end
33
+
34
+ # Private: renders the corresponding cell#action.
35
+ #
36
+ # route - The Route object obtained from the request.
37
+ # parameters - The Hash containing the request parameters.
38
+ #
39
+ # Returns: the rendered content.
40
+ #
41
+ def rendered_cell_content(route, parameters)
42
+ render_cell(route.klass.underscore.to_sym, route.action.to_sym, parameters)
43
+ end
15
44
  end
16
45
  end
@@ -24,7 +24,7 @@ module Xhive
24
24
  url = url.gsub('(.:format)', '')
25
25
  url
26
26
  rescue
27
- fail Error, "#{controller}##{action}"
27
+ Rails.logger.error "#{Error.class.name}:#{controller}##{action}"
28
28
  end
29
29
 
30
30
  private
data/lib/xhive/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Xhive
2
- VERSION = "1.0.3.pre"
2
+ VERSION = "1.0.4.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.3.pre
4
+ version: 1.0.4.pre
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -223,7 +223,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
223
223
  version: '0'
224
224
  segments:
225
225
  - 0
226
- hash: -3877875978952443496
226
+ hash: 2240109890561741587
227
227
  required_rubygems_version: !ruby/object:Gem::Requirement
228
228
  none: false
229
229
  requirements: