Merge branch 'weixin_guange' of https://git.trustie.net/jacknudt/trustieforge into weixin_guange
commit
f3d74fcd55
@ -0,0 +1,20 @@
|
||||
#coding=utf-8
|
||||
#
|
||||
|
||||
module WechatsHelper
|
||||
def include_wechat_jsfile
|
||||
if Rails.env.production?
|
||||
javascript_include_tag '/javascripts/wechat/build/app.min.js'
|
||||
else
|
||||
wechat_path = File.join(Rails.root, "public", "javascripts", "wechat")
|
||||
srcs = Rails.application.config.wechat_srcs
|
||||
paths = []
|
||||
srcs.each do |src|
|
||||
Dir.glob(wechat_path+ "/#{src}" ) do |path|
|
||||
paths << path[File.join(Rails.root, "public").to_s.size, path.size]
|
||||
end
|
||||
end
|
||||
javascript_include_tag *paths
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -0,0 +1,31 @@
|
||||
#coding=utf-8
|
||||
#
|
||||
|
||||
def compress(srcs, outfile)
|
||||
wechat_path = File.join(Rails.root, "public", "javascripts", "wechat")
|
||||
out_buffer = ''
|
||||
|
||||
srcs.each do |src|
|
||||
Dir.glob("#{wechat_path}/#{src}").each do |path|
|
||||
puts "assets #{path}"
|
||||
out_buffer = out_buffer + "\n//#{File.basename(path)}\n" + Uglifier.compile(File.read(path))
|
||||
end
|
||||
end
|
||||
|
||||
File.open(File.join(wechat_path, "build/#{outfile}"), 'w+') {|f| f.write(out_buffer)}
|
||||
end
|
||||
|
||||
|
||||
namespace :wechat do
|
||||
desc "assets javascript file"
|
||||
task :assets => :environment do
|
||||
srcs = Rails.application.config.wechat_srcs
|
||||
compress(srcs, 'app.min.js')
|
||||
end
|
||||
|
||||
desc "minify angularjs"
|
||||
task :minify => :environment do
|
||||
srcs = ['../jquery-1.3.2.js','angular.js', 'angular-route.js', 'angular-sanitize.min.js']
|
||||
compress(srcs, 'angular.all.min.js')
|
||||
end
|
||||
end
|
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue