Last active
August 29, 2015 13:57
-
-
Save leeight/9910760 to your computer and use it in GitHub Desktop.
app/ecom/baike/trunk/web/src/main/webapp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/edp-build-config.js b/edp-build-config.js | |
index 0078580..9b345fb 100644 | |
--- a/edp-build-config.js | |
+++ b/edp-build-config.js | |
@@ -3,59 +3,70 @@ exports.input = __dirname; | |
var path = require( 'path' ); | |
exports.output = path.resolve( __dirname, 'output' ); | |
-var moduleEntries = 'html,htm,phtml,tpl,vm,js'; | |
-var pageEntries = 'html,htm,phtml,tpl,vm'; | |
- | |
exports.getProcessors = function () { | |
- return [ | |
- new LessCompiler( { | |
- exclude: [ | |
- '*.less', '*.js', '*.html' | |
- ], | |
- include: [ | |
- '/index.html', | |
- '/src/common/css/main.less' | |
- ], | |
- entryExtnames: pageEntries, | |
- compileOptions: { | |
- compress: false | |
- } | |
- } ), | |
- // new CssCompressor(), | |
- new ModuleCompiler( { | |
- exclude: [], | |
- configFile: 'module.conf', | |
- entryExtnames: moduleEntries | |
- } ), | |
- // new JsCompressor(), | |
- new PathMapper( { | |
- replacements: [ | |
- { type: 'html', tag: 'link', attribute: 'href', extnames: pageEntries }, | |
- { type: 'html', tag: 'img', attribute: 'src', extnames: pageEntries }, | |
- { type: 'html', tag: 'script', attribute: 'src', extnames: pageEntries }, | |
- { extnames: moduleEntries, replacer: 'module-config' }, | |
- { extnames: 'css,less', replacer: 'css' } | |
- ], | |
- from: 'src', | |
- to: 'asset' | |
- } ) | |
- ]; | |
+ var lessProcessor = new LessCompiler( { | |
+ files: [ | |
+ 'index.html', | |
+ 'src/common/css/main.less' | |
+ ] | |
+ }); | |
+ | |
+ var moduleProcessor = new ModuleCompiler( { | |
+ files: [ 'src/common/main.js' ] | |
+ }); | |
+ | |
+ var tplMergeProcessor = new TplMerge({ | |
+ files: [ | |
+ 'src/common/main.js' | |
+ ], | |
+ outputPluginId: 'jstpl', | |
+ outputType: 'js' | |
+ }); | |
+ | |
+ var pathMapperProcessor = new PathMapper(); | |
+ | |
+ var cssProcessor = new CssCompressor({ | |
+ files: [ 'src/common/css/*' ] | |
+ }); | |
+ var jsProcessor = new JsCompressor({ | |
+ files: [ 'src/common/main.js' ] | |
+ }); | |
+ var addCopyright = new AddCopyright(); | |
+ | |
+ var outputCleaner = new OutputCleaner(); | |
+ | |
+ return { | |
+ 'default': [ | |
+ lessProcessor, moduleProcessor, | |
+ tplMergeProcessor, pathMapperProcessor, | |
+ outputCleaner | |
+ ], | |
+ 'release': [ | |
+ lessProcessor, cssProcessor, | |
+ moduleProcessor, tplMergeProcessor, | |
+ jsProcessor, pathMapperProcessor, | |
+ addCopyright | |
+ ] | |
+ }; | |
}; | |
exports.exclude = [ | |
- '/tool', | |
- '/doc', | |
- '/test', | |
- '/module.conf', | |
- '/dep/packages.manifest', | |
- '/dep/*/*/test', | |
- '/dep/*/*/doc', | |
- '/dep/*/*/demo', | |
- '/dep/*/*/tool', | |
- '/dep/*/*/*.md', | |
- '/dep/*/*/package.json', | |
- '/edp-*', | |
- '/.edpproj', | |
+ 'tool', | |
+ 'doc', | |
+ 'test', | |
+ '~mock', | |
+ 'build.xml', | |
+ 'build.sh', | |
+ 'module.conf', | |
+ 'dep/packages.manifest', | |
+ 'dep/*/*/test', | |
+ 'dep/*/*/doc', | |
+ 'dep/*/*/demo', | |
+ 'dep/*/*/tool', | |
+ 'dep/*/*/*.md', | |
+ 'dep/*/*/package.json', | |
+ 'edp-*', | |
+ '.edpproj', | |
'.svn', | |
'.git', | |
'.gitignore', | |
diff --git a/edp-webserver-config.js b/edp-webserver-config.js | |
index a56081c..081bbfc 100644 | |
--- a/edp-webserver-config.js | |
+++ b/edp-webserver-config.js | |
@@ -31,12 +31,6 @@ function commonHandler (request) { | |
var mockModuleName = './mock/' + filePath; | |
if (fs.existsSync(mockModuleName + '.js')) { | |
- if ('req'.green) { | |
- console.log('req path: '.green + request.pathname); | |
- } | |
- else { | |
- console.log('req path: ' + request.pathname); | |
- } | |
delete require.cache[require.resolve(mockModuleName)]; | |
var mockDataHandler = require(mockModuleName); | |
return mockDataHandler; | |
@@ -48,13 +42,11 @@ function commonHandler (request) { | |
function common404 (context) { | |
context.status = 404; | |
- console.log('Not Mock Path: '.red + context.request.pathname.red); | |
context.start(); | |
} | |
function common500 (context, e) { | |
context.status = 500; | |
- console.log('\nError Happen: '.red + e.toString().red + '\n'); | |
context.start(); | |
} | |
@@ -142,12 +134,6 @@ exports.getLocations = function () { | |
}, | |
handler: [ | |
function (context) { | |
- if ('req'.green) { | |
- console.log('req path: '.green + context.request.pathname); | |
- } | |
- else { | |
- console.log('req path: ' + context.request.pathname); | |
- } | |
}, | |
proxy(remoteIp, remotePort) | |
] | |
@@ -174,7 +160,6 @@ exports.getLocations = function () { | |
var fileReg = new RegExp(/name="callback"\r\n\r\n([\w\.\[\]'"]+)\r\n[\s\S]+?filename="(.*?)\.([^\.]+?)"\r\nContent\-Type: [a-zA-z\/\.\-]+?\r\n\r\n([\s\S]+?)\-{6}/); | |
var result = fileReg.exec(reqBody); | |
var callback = (result && result[1]) || ''; | |
- console.log(callback); | |
var fileName = (result && result[2]) || ''; | |
var fileType = (result && result[3]) || ''; | |
var fileData = (result && result[4]) || ''; | |
@@ -276,6 +261,10 @@ exports.getLocations = function () { | |
]; | |
}; | |
+exports.logger = function( req, resp, next ) { | |
+ next(); | |
+} | |
+ | |
exports.injectResource = function ( res ) { | |
for ( var key in res ) { | |
global[ key ] = res[ key ]; | |
diff --git a/index.html b/index.html | |
index ce1f0c7..c932915 100644 | |
--- a/index.html | |
+++ b/index.html | |
@@ -34,11 +34,12 @@ | |
<!--[if IE 6]></div></div><![endif]--> | |
<script> | |
- | |
require.config({ | |
+ 'waitSeconds': 5, | |
'baseUrl': 'src', | |
'paths': { | |
'tpl': 'common/ecma/tpl', | |
+ 'jstpl': 'common/ecma/tpl', | |
'ecma': 'common/ecma' | |
}, | |
'packages': [ | |
diff --git a/module.conf b/module.conf | |
index 9ddc1a6..9813276 100644 | |
--- a/module.conf | |
+++ b/module.conf | |
@@ -1,57 +1,66 @@ | |
{ | |
"baseUrl": "src", | |
"paths": { | |
- "tpl": "src/common/ecma/tpl", | |
- "ecma": "src/common/ecma" | |
+ "tpl": "common/ecma/tpl", | |
+ "jstpl": "common/ecma/tpl", | |
+ "ecma": "common/ecma" | |
}, | |
"packages": [ | |
{ | |
"name": "ef", | |
- "location": "dep/ef/3.1.0-alpha.3/src", | |
+ "location": "../dep/ef/3.1.0-alpha.3/src", | |
"main": "main" | |
}, | |
{ | |
"name": "er", | |
- "location": "dep/er/3.1.0-alpha.6/src", | |
+ "location": "../dep/er/3.1.0-alpha.6/src", | |
"main": "main" | |
}, | |
{ | |
"name": "mini-event", | |
- "location": "dep/mini-event/1.0.0/src", | |
+ "location": "../dep/mini-event/1.0.0/src", | |
"main": "main" | |
}, | |
{ | |
"name": "etpl", | |
- "location": "dep/etpl/2.0.8/src", | |
+ "location": "../dep/etpl/2.0.8/src", | |
"main": "main" | |
}, | |
{ | |
"name": "esui", | |
- "location": "dep/esui/3.1.0-alpha.6/src", | |
+ "location": "../dep/esui/3.1.0-alpha.6/src", | |
"main": "main" | |
}, | |
{ | |
"name": "underscore", | |
- "location": "dep/underscore/1.4.4/src", | |
+ "location": "../dep/underscore/1.4.4/src", | |
"main": "underscore" | |
}, | |
{ | |
"name": "moment", | |
- "location": "dep/moment/2.0.0/src", | |
+ "location": "../dep/moment/2.0.0/src", | |
"main": "moment" | |
}, | |
{ | |
"name": "esf-ms", | |
- "location": "dep/esf-ms/1.0.2/src" | |
+ "location": "../dep/esf-ms/1.0.2/src" | |
}, | |
{ | |
"name": "est", | |
- "location": "dep/est/1.1.0/src" | |
+ "location": "../dep/est/1.1.0/src" | |
}, | |
{ | |
"name": "urijs", | |
- "location": "dep/urijs/1.12.0/src", | |
+ "location": "../dep/urijs/1.12.0/src", | |
"main": "URI" | |
} | |
- ] | |
+ ], | |
+ "combine": { | |
+ "common/main": { | |
+ "files": [ | |
+ "~ef", "~validation", "~esui", "~er", "~ui", "~urijs", "~underscore", | |
+ "~setting", "~ecma", "~etpl" | |
+ ] | |
+ } | |
+ } | |
} | |
diff --git a/src/common/ecma/tpl.js b/src/common/ecma/tpl.js | |
index 8a91d2f..a9effad 100755 | |
--- a/src/common/ecma/tpl.js | |
+++ b/src/common/ecma/tpl.js | |
@@ -7,7 +7,6 @@ | |
*/ | |
define( | |
function(require) { | |
- var ajax = require('er/ajax'); | |
var etpl = require('etpl'); | |
var template = etpl; | |
@@ -156,13 +155,19 @@ define( | |
require(dependencies, function () { load(text); }); | |
} | |
- var options = { | |
- method: 'GET', | |
- url: parentRequire.toUrl(resourceId), | |
- cache: true, | |
- dataType: 'text' | |
- }; | |
- ajax.request(options).then(addTemplate); | |
+ if ( /\.html$/.test( resourceId ) ) { | |
+ var options = { | |
+ method: 'GET', | |
+ url: parentRequire.toUrl(resourceId), | |
+ cache: true, | |
+ dataType: 'text' | |
+ }; | |
+ require( 'er/ajax' ).request(options).then(addTemplate); | |
+ } | |
+ else { | |
+ // js tpl | |
+ require( [resourceId], addTemplate ); | |
+ } | |
}, | |
/** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment