xhive 1.0.3.pre → 1.0.4.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 +10 -3
- data/app/controllers/xhive/widgets_controller.rb +34 -5
- data/lib/xhive/router/base.rb +1 -1
- data/lib/xhive/version.rb +1 -1
- metadata +2 -2
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
|
+
[](http://travis-ci.org/frozeek/xhive)
|
|
7
|
+
[](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 => '
|
|
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.
|
|
206
|
-
|
|
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 =
|
|
8
|
-
|
|
9
|
-
|
|
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
|
data/lib/xhive/router/base.rb
CHANGED
data/lib/xhive/version.rb
CHANGED
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.
|
|
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:
|
|
226
|
+
hash: 2240109890561741587
|
|
227
227
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
228
|
none: false
|
|
229
229
|
requirements:
|