xhive 1.0.7.pre → 1.0.8.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -1
- data/app/assets/images/xhive/default.png +0 -0
- data/app/controllers/xhive/images_controller.rb +11 -0
- data/app/helpers/xhive/application_helper.rb +2 -2
- data/app/models/xhive/image.rb +19 -0
- data/app/models/xhive/mapper.rb +4 -2
- data/app/models/xhive/site.rb +1 -0
- data/app/uploaders/xhive/image_uploader.rb +35 -0
- data/config/routes.rb +1 -0
- data/db/migrate/20121031192552_add_key_to_xhive_mappers.rb +6 -0
- data/db/migrate/20121101124925_create_xhive_images.rb +12 -0
- data/lib/xhive/version.rb +1 -1
- metadata +57 -3
data/README.md
CHANGED
@@ -204,14 +204,27 @@ Create a new mapper record for the posts resources
|
|
204
204
|
mapper = Xhive::Mapper.create(:resource => 'posts', :action => 'index', :page => posts_page)
|
205
205
|
```
|
206
206
|
|
207
|
+
Create a new mapper record for some specific post
|
208
|
+
|
209
|
+
```
|
210
|
+
mapper = Xhive::Mapper.create(:resource => 'posts', :action => 'show', :key => '1', :page => posts_page)
|
211
|
+
```
|
212
|
+
|
207
213
|
From your posts controller, render the posts page
|
208
214
|
|
209
215
|
```
|
210
216
|
class PostsController < ApplicationController
|
217
|
+
# This will render the page associated with the index action
|
211
218
|
def index
|
212
219
|
@posts = Post.limit(10)
|
213
220
|
render_page_with :posts => @posts
|
214
221
|
end
|
222
|
+
|
223
|
+
# This will render the page associated with the specific post
|
224
|
+
def show
|
225
|
+
@post = Post.find(params[:id])
|
226
|
+
render_page_with @post.id, :post => @post
|
227
|
+
end
|
215
228
|
end
|
216
229
|
```
|
217
230
|
|
@@ -220,7 +233,6 @@ Using this feature you can let the designers implement the HTML/CSS to display t
|
|
220
233
|
TODO
|
221
234
|
====
|
222
235
|
|
223
|
-
* Implement the Image model
|
224
236
|
* Remove as many dependencies as possible
|
225
237
|
* Improve test coverage
|
226
238
|
|
Binary file
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require_dependency "xhive/application_controller"
|
2
|
+
|
3
|
+
module Xhive
|
4
|
+
class ImagesController < ApplicationController
|
5
|
+
def show
|
6
|
+
@image = current_site.images.where(:image => "#{params[:id]}.#{params[:format]}").first
|
7
|
+
fail ActiveRecord::RecordNotFound unless @image.present?
|
8
|
+
redirect_to @image.image_url, :status => 301
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -8,8 +8,8 @@ module Xhive
|
|
8
8
|
"<link href='#{xhive.stylesheets_path}' media='all' rel='stylesheet' type='text/css'/>".html_safe
|
9
9
|
end
|
10
10
|
|
11
|
-
def render_page_with(options={})
|
12
|
-
page = current_site.mappers.page_for(controller_path, action_name)
|
11
|
+
def render_page_with(key = nil, options={})
|
12
|
+
page = current_site.mappers.page_for(controller_path, action_name, key)
|
13
13
|
render :inline => page.presenter.render_content(options), :layout => true
|
14
14
|
rescue
|
15
15
|
render
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'carrierwave'
|
2
|
+
require 'carrierwave/orm/activerecord'
|
3
|
+
|
4
|
+
module Xhive
|
5
|
+
class Image < ActiveRecord::Base
|
6
|
+
belongs_to :site
|
7
|
+
|
8
|
+
attr_accessible :image, :site_id, :title
|
9
|
+
|
10
|
+
validates :image, :presence => true
|
11
|
+
validates :site, :presence => true
|
12
|
+
|
13
|
+
mount_uploader :image, ImageUploader
|
14
|
+
|
15
|
+
def basename
|
16
|
+
File.basename(image.to_s)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/app/models/xhive/mapper.rb
CHANGED
@@ -10,8 +10,10 @@ module Xhive
|
|
10
10
|
validates :site, :presence => true
|
11
11
|
validates :page, :presence => true
|
12
12
|
|
13
|
-
def self.page_for(resource, action)
|
14
|
-
|
13
|
+
def self.page_for(resource, action, key = nil)
|
14
|
+
mapper = where(:resource => resource).where(:action => action)
|
15
|
+
mapper = mapper.where(:key => key) if key.present?
|
16
|
+
page = mapper.first.try(:page)
|
15
17
|
fail ActiveRecord::RecordNotFound unless page.present?
|
16
18
|
page
|
17
19
|
end
|
data/app/models/xhive/site.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'carrierwave'
|
2
|
+
|
3
|
+
module Xhive
|
4
|
+
class ImageUploader < ::CarrierWave::Uploader::Base
|
5
|
+
include ::CarrierWave::MiniMagick
|
6
|
+
|
7
|
+
include ::Sprockets::Helpers::RailsHelper
|
8
|
+
include ::Sprockets::Helpers::IsolatedHelper
|
9
|
+
|
10
|
+
def store_dir
|
11
|
+
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def default_url
|
15
|
+
asset_path "fallback/" + [version_name, "default.png"].compact.join('_')
|
16
|
+
end
|
17
|
+
|
18
|
+
def url
|
19
|
+
super.gsub('+', '%2B')
|
20
|
+
end
|
21
|
+
|
22
|
+
version :thumb do
|
23
|
+
process :resize_to_limit => [144, 94]
|
24
|
+
end
|
25
|
+
|
26
|
+
def extension_white_list
|
27
|
+
%w(jpg jpeg gif png)
|
28
|
+
end
|
29
|
+
|
30
|
+
# For heroku read-only filesystem
|
31
|
+
def cache_dir
|
32
|
+
"#{Rails.root}/tmp/uploads"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/config/routes.rb
CHANGED
@@ -6,6 +6,7 @@ Xhive::Engine.routes.draw do
|
|
6
6
|
get 'stylesheets/custom.css', :to => 'stylesheets#index', :as => :stylesheets, :format => :css
|
7
7
|
|
8
8
|
resources :stylesheets, :only => :show, :format => :css
|
9
|
+
resources :images, :only => :show
|
9
10
|
|
10
11
|
get 'widgets/*widget', :to => 'widgets#show'
|
11
12
|
|
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.8.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-
|
12
|
+
date: 2012-11-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -107,6 +107,38 @@ dependencies:
|
|
107
107
|
- - ~>
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: 3.2.3
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: carrierwave
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: mini_magick
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
110
142
|
- !ruby/object:Gem::Dependency
|
111
143
|
name: sqlite3
|
112
144
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,6 +187,22 @@ dependencies:
|
|
155
187
|
- - ! '>='
|
156
188
|
- !ruby/object:Gem::Version
|
157
189
|
version: '0'
|
190
|
+
- !ruby/object:Gem::Dependency
|
191
|
+
name: mocha
|
192
|
+
requirement: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
194
|
+
requirements:
|
195
|
+
- - ! '>='
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
198
|
+
type: :development
|
199
|
+
prerelease: false
|
200
|
+
version_requirements: !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
202
|
+
requirements:
|
203
|
+
- - ! '>='
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: '0'
|
158
206
|
description: Simple Rails AJAX CMS
|
159
207
|
email:
|
160
208
|
- marcelo@frozeek.com
|
@@ -162,17 +210,20 @@ executables: []
|
|
162
210
|
extensions: []
|
163
211
|
extra_rdoc_files: []
|
164
212
|
files:
|
213
|
+
- app/assets/images/xhive/default.png
|
165
214
|
- app/assets/javascripts/xhive/application.js
|
166
215
|
- app/assets/javascripts/xhive/loader.js.coffee
|
167
216
|
- app/assets/javascripts/xhive/pages.js
|
168
217
|
- app/assets/stylesheets/xhive/application.css
|
169
218
|
- app/assets/stylesheets/xhive/pages.css
|
170
219
|
- app/controllers/xhive/application_controller.rb
|
220
|
+
- app/controllers/xhive/images_controller.rb
|
171
221
|
- app/controllers/xhive/pages_controller.rb
|
172
222
|
- app/controllers/xhive/stylesheets_controller.rb
|
173
223
|
- app/controllers/xhive/widgets_controller.rb
|
174
224
|
- app/helpers/xhive/application_helper.rb
|
175
225
|
- app/models/xhive/anonymous_user.rb
|
226
|
+
- app/models/xhive/image.rb
|
176
227
|
- app/models/xhive/mapper.rb
|
177
228
|
- app/models/xhive/page.rb
|
178
229
|
- app/models/xhive/site.rb
|
@@ -181,6 +232,7 @@ files:
|
|
181
232
|
- app/presenters/xhive/page_presenter.rb
|
182
233
|
- app/presenters/xhive/stylesheet_presenter.rb
|
183
234
|
- app/presenters/xhive/user_presenter.rb
|
235
|
+
- app/uploaders/xhive/image_uploader.rb
|
184
236
|
- app/views/layouts/xhive/application.html.erb
|
185
237
|
- app/views/xhive/pages/show.html.erb
|
186
238
|
- config/routes.rb
|
@@ -191,6 +243,8 @@ files:
|
|
191
243
|
- db/migrate/20121016224054_create_xhive_stylesheets.rb
|
192
244
|
- db/migrate/20121016224326_add_slug_index_to_pages.rb
|
193
245
|
- db/migrate/20121019185702_create_xhive_mappers.rb
|
246
|
+
- db/migrate/20121031192552_add_key_to_xhive_mappers.rb
|
247
|
+
- db/migrate/20121101124925_create_xhive_images.rb
|
194
248
|
- lib/tasks/xhive_tasks.rake
|
195
249
|
- lib/xhive/base_tag.rb
|
196
250
|
- lib/xhive/controller.rb
|
@@ -223,7 +277,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
223
277
|
version: '0'
|
224
278
|
segments:
|
225
279
|
- 0
|
226
|
-
hash:
|
280
|
+
hash: -363105832108409294
|
227
281
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
282
|
none: false
|
229
283
|
requirements:
|