59 lines
1.8 KiB
Ruby
59 lines
1.8 KiB
Ruby
require 'fileutils'
|
|
include FileUtils
|
|
#rm_rf Rails.root.join('public', 'assets')
|
|
#`rake assets:precompile`
|
|
android_root = '/Users/bterkuile/Documents/workspace/Qwaiter/assets'
|
|
root_url = "file:///Users/bterkuile/Documents/workspace/Qwaiter/assets"
|
|
root_url = 'file:///android_asset'
|
|
mkdir_p File.join(android_root, 'user')
|
|
rm_rf File.join(android_root, 'assets')
|
|
Dir.glob(File.join('public', 'assets', '**', '*.gz')).each{|f| rm_f f}
|
|
move Rails.root.join('public', 'assets'), File.join(android_root, 'assets') if File.directory?(Rails.root.join('public', 'assets'))
|
|
for css in Dir.glob(File.join(android_root, "**", "*.css"))
|
|
contents = File.read(css)
|
|
contents.gsub!(/url\("/, %|url("#{root_url}|)
|
|
contents.gsub!(/url\(\//, %|url(#{root_url}/|)
|
|
File.open(css, 'w'){|f| f.puts contents}
|
|
end
|
|
|
|
|
|
uc = UserController.new
|
|
class << uc
|
|
def authenticate_user!
|
|
end
|
|
|
|
def current_user
|
|
@current_user ||= User.first || User.new
|
|
@current_user.id ||= 'bogus_user'
|
|
@current_user
|
|
end
|
|
|
|
def request
|
|
ActionDispatch::Request.new({})
|
|
end
|
|
end
|
|
uc.instance_variable_set('@_request', uc.request)
|
|
for action in uc.action_methods
|
|
if File.exist?(Rails.root.join('app', 'views', 'user', "#{action}.html.slim"))
|
|
puts "action #{action} found"
|
|
result = uc.render_to_string(action: action.dup)
|
|
#result.sub! /<head>/, '<head><base href="file:///Users/bterkuile/Documents/workspace/Qwaiter/assets/" target="_self" />'
|
|
result.gsub! /(href|src)="([^#])/, %|\\1="#{root_url}\\2|
|
|
File.open(File.join(android_root, 'user', "#{action}.html"), 'w'){|f| f.puts result}
|
|
end
|
|
end
|
|
view = view = ActionView::Base.new(uc.view_paths)
|
|
class << view
|
|
include ApplicationHelper
|
|
include Rails.application.routes.url_helpers
|
|
def current_user
|
|
User.first || User.new
|
|
end
|
|
|
|
|
|
def protect_against_forgery?
|
|
false
|
|
end
|
|
end
|
|
# view.render()
|