mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2025-02-28 16:31:44 -05:00
Javascript modules can live in subdirectories
This commit is contained in:
parent
50f811984f
commit
2818312dcd
@ -9,11 +9,11 @@ require_js:
|
|||||||
# Dependiences are added first as globals
|
# Dependiences are added first as globals
|
||||||
lib:
|
lib:
|
||||||
- lib/modernizr.js
|
- lib/modernizr.js
|
||||||
- lib/**/*.*
|
- lib/**/*
|
||||||
|
|
||||||
# Modules are wrapped with CommonJS functions and must be
|
# Modules are wrapped with CommonJS functions and must be
|
||||||
# Example:
|
# Example:
|
||||||
# for file: assets/javascripts/modules/some-plugin/awesome.js
|
# for file: assets/javascripts/modules/some-plugin/awesome.js
|
||||||
# require like: var awesome = require('some-plugin/awesome')
|
# require like: var awesome = require('some-plugin/awesome')
|
||||||
modules:
|
modules:
|
||||||
- modules/
|
- modules
|
||||||
|
@ -24,7 +24,8 @@ module Octopress
|
|||||||
|
|
||||||
# Read js dependencies from require_js.yml configuration
|
# Read js dependencies from require_js.yml configuration
|
||||||
@lib = Octopress.configuration[:require_js][:lib].collect {|item| Dir.glob("#{@js_assets_path}/#{item}") }.flatten.uniq
|
@lib = Octopress.configuration[:require_js][:lib].collect {|item| Dir.glob("#{@js_assets_path}/#{item}") }.flatten.uniq
|
||||||
@modules = Octopress.configuration[:require_js][:modules].collect {|item| Dir.glob("#{@js_assets_path}/#{item}") }.flatten.uniq
|
@modules = Octopress.configuration[:require_js][:modules].collect {|item| "#{@js_assets_path}/#{item}" }.flatten.uniq
|
||||||
|
@module_files = @modules.collect {|item| Dir[item+'/**/*'] }.flatten.uniq
|
||||||
|
|
||||||
@template_path = File.expand_path("../../#{Octopress.configuration[:source]}", File.dirname(__FILE__))
|
@template_path = File.expand_path("../../#{Octopress.configuration[:source]}", File.dirname(__FILE__))
|
||||||
@build_path = "/javascripts/build"
|
@build_path = "/javascripts/build"
|
||||||
@ -32,7 +33,7 @@ module Octopress
|
|||||||
|
|
||||||
|
|
||||||
def get_fingerprint
|
def get_fingerprint
|
||||||
Digest::MD5.hexdigest(@modules.concat(@lib).uniq.map! do |path|
|
Digest::MD5.hexdigest(@module_files.concat(@lib).uniq.map! do |path|
|
||||||
"#{File.mtime(path).to_i}"
|
"#{File.mtime(path).to_i}"
|
||||||
end.join)
|
end.join)
|
||||||
end
|
end
|
||||||
@ -51,9 +52,7 @@ module Octopress
|
|||||||
if File.exists?(file) and File.open(file) {|f| f.readline} =~ /#{@fingerprint}/
|
if File.exists?(file) and File.open(file) {|f| f.readline} =~ /#{@fingerprint}/
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
modules = @modules.delete_if { |f| @lib.include? f }
|
js = Stitch::Package.new(:dependencies => @lib, :paths => @modules).compile
|
||||||
puts modules
|
|
||||||
js = Stitch::Package.new(:dependencies => @lib, :paths => modules).compile
|
|
||||||
js = "/* Octopress fingerprint: #{@fingerprint} */\n" + js
|
js = "/* Octopress fingerprint: #{@fingerprint} */\n" + js
|
||||||
js = Uglifier.new.compile js if Octopress.env == 'production'
|
js = Uglifier.new.compile js if Octopress.env == 'production'
|
||||||
write_path = "#{@template_path}/#{@build_path}"
|
write_path = "#{@template_path}/#{@build_path}"
|
||||||
@ -67,3 +66,4 @@ module Octopress
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user