render_anywhere 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
data/lib/render_anywhere.rb
CHANGED
@@ -1,46 +1,48 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
1
|
+
module RenderAnywhere
|
2
|
+
class RenderingController < AbstractController::Base
|
3
|
+
# Include all the concerns we need to make this work
|
4
|
+
include AbstractController::Logger
|
5
|
+
include AbstractController::Rendering
|
6
|
+
include AbstractController::Layouts
|
7
|
+
include AbstractController::Helpers
|
8
|
+
include AbstractController::Translation
|
9
|
+
include AbstractController::AssetPaths
|
10
|
+
include Rails.application.routes.url_helpers
|
11
|
+
|
12
|
+
# this is you normal rails application helper
|
13
|
+
helper ApplicationHelper
|
14
|
+
|
15
|
+
# Define additional helpers, this one is for csrf_meta_tag
|
16
|
+
helper_method :protect_against_forgery?
|
17
|
+
|
18
|
+
# override the layout in your subclass if needed.
|
19
|
+
layout 'application'
|
20
|
+
|
21
|
+
# configure the different paths correctly
|
22
|
+
def initialize(*args)
|
23
|
+
super()
|
24
|
+
lookup_context.view_paths = Rails.root.join('app', 'views')
|
25
|
+
config.javascripts_dir = Rails.root.join('public', 'javascripts')
|
26
|
+
config.stylesheets_dir = Rails.root.join('public', 'stylesheets')
|
27
|
+
config.assets_dir = Rails.root.join('public')
|
28
|
+
end
|
29
|
+
|
30
|
+
# we are not in a browser, no need for this
|
31
|
+
def protect_against_forgery?
|
32
|
+
false
|
33
|
+
end
|
34
|
+
|
35
|
+
# so that your flash calls still work
|
36
|
+
def flash
|
37
|
+
{}
|
38
|
+
end
|
39
|
+
|
40
|
+
# same asset host as the controllers
|
41
|
+
self.asset_host = ActionController::Base.asset_host
|
42
|
+
|
43
|
+
# and nil request to differentiate between live and offline
|
44
|
+
def request
|
45
|
+
nil
|
46
|
+
end
|
27
47
|
end
|
28
|
-
|
29
|
-
# we are not in a browser, no need for this
|
30
|
-
def protect_against_forgery?
|
31
|
-
false
|
32
|
-
end
|
33
|
-
|
34
|
-
# so that your flash calls still work
|
35
|
-
def flash
|
36
|
-
{}
|
37
|
-
end
|
38
|
-
|
39
|
-
# same asset host as the controllers
|
40
|
-
self.asset_host = ActionController::Base.asset_host
|
41
|
-
|
42
|
-
# and nil request to differentiate between live and offline
|
43
|
-
def request
|
44
|
-
nil
|
45
|
-
end
|
46
|
-
end
|
48
|
+
end
|