Created
April 15, 2014 04:30
-
-
Save leeight/10702261 to your computer and use it in GitHub Desktop.
app/ecom/fe/trunk/vs-mid-edu/course
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/course/.gitignore b/course/.gitignore | |
new file mode 100644 | |
index 0000000..edc986c | |
--- /dev/null | |
+++ b/course/.gitignore | |
@@ -0,0 +1,2 @@ | |
+output | |
+templates_c | |
diff --git a/course/dep/log/0.0.1/package.json b/course/dep/log/0.0.1/package.json | |
new file mode 100644 | |
index 0000000..bb270ba | |
--- /dev/null | |
+++ b/course/dep/log/0.0.1/package.json | |
@@ -0,0 +1,5 @@ | |
+{ | |
+ "name": "log", | |
+ "version": "0.0.1", | |
+ "contributors": [] | |
+} | |
diff --git a/course/dep/log/0.0.1/src/log.js b/course/dep/log/0.0.1/src/log.js | |
new file mode 100644 | |
index 0000000..67d7344 | |
--- /dev/null | |
+++ b/course/dep/log/0.0.1/src/log.js | |
@@ -0,0 +1,254 @@ | |
+/** | |
+ * Copyright 2013 Baidu Inc. All rights reserved. | |
+ * @file 知心中间页日志统计模块(无define版) | |
+ * @see 点击统计规范(新版/xpath) | |
+ * @see <a href="http://fe.baidu.com/doc/aladdin/#standard/aladdin_click.text">点击统计规范(新版/xpath)</a> | |
+ * @author chris([email protected]) | |
+ */ | |
+ | |
+// add define by [email protected] | |
+define(function (require) { | |
+ return (function () { | |
+ var T = baidu; | |
+ var DOM = T.dom; | |
+ var TO = T.object; | |
+ var parseJson = T.json.parse; | |
+ | |
+ /** | |
+ * 发送日志请求 | |
+ * | |
+ * @inner | |
+ * @type {string} url 日志完事地址 | |
+ */ | |
+ var send = (function () { | |
+ var list = []; | |
+ return function (url) { | |
+ var index = list.push(new Image) - 1; | |
+ | |
+ list[index].onload = list[index].onerror = function () { | |
+ list[index] = list[index].onload = list[index].onerror = null; | |
+ delete list[index]; | |
+ }; | |
+ | |
+ list[index].src = url; | |
+ }; | |
+ })(); | |
+ | |
+ /** | |
+ * 填充数据 | |
+ * 根据当前点击对象,解释对象所处XPath及url | |
+ * @inner | |
+ * @param {Object} data待发送的数据对象 | |
+ * @param {HTMLElement} from 当前点击对象 | |
+ * @param {HTMLElement} to 统计日志最上层容器 | |
+ * @return {Object} 合并所有HTML自定义属性和相关配置项后的数据对象 | |
+ */ | |
+ var fill = function (data, from, to) { | |
+ var type = 'other'; | |
+ var tag = from.tagName.toLowerCase(); | |
+ var path = [tag]; | |
+ var i = 1; | |
+ var url; | |
+ var nolog = 0; | |
+ | |
+ var walk = function (el) { | |
+ if ( el.getAttribute('data-nolog') === '1' ) { | |
+ nolog = 1; | |
+ return true; | |
+ } | |
+ var clickData = el.getAttribute('data-click'); | |
+ if ( clickData ) { | |
+ data = T.extend(parseJson(clickData), data); | |
+ } | |
+ | |
+ if ( el !== to ) { | |
+ path[i ++] = el.tagName; | |
+ | |
+ if ( el.href ) { | |
+ url = el.href; | |
+ type = 'link'; | |
+ } | |
+ } | |
+ else { | |
+ return true; | |
+ } | |
+ }; | |
+ | |
+ if ( from === to ) { | |
+ walk(from); | |
+ } | |
+ else { | |
+ DOM.getAncestorBy(from, walk); | |
+ } | |
+ | |
+ if ( nolog ) { | |
+ return !nolog; | |
+ } | |
+ | |
+ path.reverse(); | |
+ | |
+ if ( /^a|img|input|button$/.test(tag) ) { | |
+ type = {a: 'link', button: 'btn'}[tag] || tag; | |
+ | |
+ // 取type的前3位作判断,默认非输入框的点击都作为 btn 类型上报 | |
+ if ( from.type && /^(rad|che|but|sub|res|ima)/.test(from.type) ){ | |
+ type = 'btn'; | |
+ } | |
+ | |
+ url = from.href || from.src || url; | |
+ if ( url ) { | |
+ data.url = url; | |
+ } | |
+ } else { | |
+ T.each('title,link,img,btn,others'.split(','), function (key) { | |
+ if ( DOM.hasClass(from, options[key]) ) { | |
+ type = key; | |
+ } | |
+ }); | |
+ } | |
+ | |
+ data.rsv_xpath = path.join('-').toLowerCase() + '(' + type + ')'; | |
+ return data; | |
+ }; | |
+ | |
+ /** | |
+ * 配置项 | |
+ * | |
+ * @type {Object} | |
+ * @type {string} options.action 日志统计服务接口地址 | |
+ * @type {string} options.main 日志统计顶层容器className | |
+ * @type {string} options.title xpath中title类型的className | |
+ * @type {string} options.link xpath中link类型的className | |
+ * @type {string} options.img xpath中img类型的className | |
+ * @type {string} options.btn xpath中btn类型的className | |
+ * @type {string} options.others xpath中others类型的className | |
+ * @type {Object} options.data 统计公共数据部分 | |
+ */ | |
+ var options = /** @lends log.options */ { | |
+ | |
+ // 日志统计服务接口地址 | |
+ action: 'http://sclick.baidu.com/w.gif?', | |
+ | |
+ // 日志统计顶层容器className | |
+ main: 'result-op', | |
+ | |
+ // xpath中title类型的className | |
+ title: 'OP_LOG_TITLE', | |
+ | |
+ // xpath中link类型的className | |
+ link: 'OP_LOG_LINK', | |
+ | |
+ // xpath中img类型的className | |
+ img: 'OP_LOG_IMG', | |
+ | |
+ // xpath中btn类型的className | |
+ btn: 'OP_LOG_BTN', | |
+ | |
+ // xpath中others类型的className | |
+ others: 'OP_LOG_OTHERS', | |
+ | |
+ // 统计公共数据部分 | |
+ data: {} | |
+ }; | |
+ | |
+ /** | |
+ * 页面点击监听 | |
+ * | |
+ * @inner | |
+ * @param {DOMEvent} e DOM事件对象 | |
+ */ | |
+ var onClick = function (e) { | |
+ var target = T.event.getTarget(e); | |
+ var klass = options.main; | |
+ var main = DOM.hasClass(target, klass) | |
+ ? target | |
+ : DOM.getAncestorByClass(target, klass); | |
+ var nolog = target.getAttribute('data-nolog') === '1'; | |
+ | |
+ if ( nolog || !main ) { | |
+ return; | |
+ } | |
+ | |
+ var data = target.getAttribute('data-click'); | |
+ | |
+ if ( data ) { | |
+ data = parseJson(data); | |
+ } | |
+ | |
+ data = fill(data || {}, target, main); | |
+ | |
+ // 某个上级节点配置了 data-nolog 之后 | |
+ if ( !data ) { | |
+ return; | |
+ } | |
+ | |
+ if ( options.data ) { | |
+ data = T.extend(T.extend({}, options.data), data); | |
+ } | |
+ | |
+ data.t = (+new Date).toString(36); | |
+ | |
+ send(options.action + T.url.jsonToQuery(data)); | |
+ }; | |
+ | |
+ // 对外暴露的send | |
+ function outerSender(data) { | |
+ if ( !data ) { | |
+ return; | |
+ } | |
+ | |
+ if ( options.data ) { | |
+ data = T.extend(T.extend({}, options.data), data); | |
+ } | |
+ | |
+ data.t = (+new Date).toString(36); | |
+ | |
+ send(options.action + T.url.jsonToQuery(data)); | |
+ }; | |
+ | |
+ /** | |
+ * 日志模块对象 | |
+ * | |
+ * @type {Object} | |
+ */ | |
+ var log = { | |
+ | |
+ _send: outerSender, | |
+ | |
+ /** | |
+ * 配置项 | |
+ * | |
+ * @param {Object} ops 可配置项 | |
+ * @type {string} ops.action 日志统计服务接口地址 | |
+ * @type {string} ops.main 日志统计顶层容器className | |
+ * @type {string} ops.title xpath中title类型的className | |
+ * @type {string} ops.link xpath中link类型的className | |
+ * @type {string} ops.img xpath中img类型的className | |
+ * @type {string} ops.btn xpath中btn类型的className | |
+ * @type {string} ops.others xpath中others类型的className | |
+ * @type {Object} ops.data 统计公共数据部分 | |
+ */ | |
+ config: function (ops) { | |
+ T.extend(options, ops); | |
+ }, | |
+ | |
+ /** | |
+ * 开始监听页面点击日志 | |
+ * | |
+ */ | |
+ start: function () { | |
+ T.on(document, 'click', onClick); | |
+ }, | |
+ | |
+ /** | |
+ * 停止监听页面点击日志 | |
+ * | |
+ */ | |
+ stop: function () { | |
+ T.un(document, 'click', onClick); | |
+ } | |
+ }; | |
+ | |
+ return log; | |
+})(); | |
+}); | |
\ No newline at end of file | |
diff --git a/course/dep/log/log.js b/course/dep/log/log.js | |
deleted file mode 100644 | |
index 67d7344..0000000 | |
--- a/course/dep/log/log.js | |
+++ /dev/null | |
@@ -1,254 +0,0 @@ | |
-/** | |
- * Copyright 2013 Baidu Inc. All rights reserved. | |
- * @file 知心中间页日志统计模块(无define版) | |
- * @see 点击统计规范(新版/xpath) | |
- * @see <a href="http://fe.baidu.com/doc/aladdin/#standard/aladdin_click.text">点击统计规范(新版/xpath)</a> | |
- * @author chris([email protected]) | |
- */ | |
- | |
-// add define by [email protected] | |
-define(function (require) { | |
- return (function () { | |
- var T = baidu; | |
- var DOM = T.dom; | |
- var TO = T.object; | |
- var parseJson = T.json.parse; | |
- | |
- /** | |
- * 发送日志请求 | |
- * | |
- * @inner | |
- * @type {string} url 日志完事地址 | |
- */ | |
- var send = (function () { | |
- var list = []; | |
- return function (url) { | |
- var index = list.push(new Image) - 1; | |
- | |
- list[index].onload = list[index].onerror = function () { | |
- list[index] = list[index].onload = list[index].onerror = null; | |
- delete list[index]; | |
- }; | |
- | |
- list[index].src = url; | |
- }; | |
- })(); | |
- | |
- /** | |
- * 填充数据 | |
- * 根据当前点击对象,解释对象所处XPath及url | |
- * @inner | |
- * @param {Object} data待发送的数据对象 | |
- * @param {HTMLElement} from 当前点击对象 | |
- * @param {HTMLElement} to 统计日志最上层容器 | |
- * @return {Object} 合并所有HTML自定义属性和相关配置项后的数据对象 | |
- */ | |
- var fill = function (data, from, to) { | |
- var type = 'other'; | |
- var tag = from.tagName.toLowerCase(); | |
- var path = [tag]; | |
- var i = 1; | |
- var url; | |
- var nolog = 0; | |
- | |
- var walk = function (el) { | |
- if ( el.getAttribute('data-nolog') === '1' ) { | |
- nolog = 1; | |
- return true; | |
- } | |
- var clickData = el.getAttribute('data-click'); | |
- if ( clickData ) { | |
- data = T.extend(parseJson(clickData), data); | |
- } | |
- | |
- if ( el !== to ) { | |
- path[i ++] = el.tagName; | |
- | |
- if ( el.href ) { | |
- url = el.href; | |
- type = 'link'; | |
- } | |
- } | |
- else { | |
- return true; | |
- } | |
- }; | |
- | |
- if ( from === to ) { | |
- walk(from); | |
- } | |
- else { | |
- DOM.getAncestorBy(from, walk); | |
- } | |
- | |
- if ( nolog ) { | |
- return !nolog; | |
- } | |
- | |
- path.reverse(); | |
- | |
- if ( /^a|img|input|button$/.test(tag) ) { | |
- type = {a: 'link', button: 'btn'}[tag] || tag; | |
- | |
- // 取type的前3位作判断,默认非输入框的点击都作为 btn 类型上报 | |
- if ( from.type && /^(rad|che|but|sub|res|ima)/.test(from.type) ){ | |
- type = 'btn'; | |
- } | |
- | |
- url = from.href || from.src || url; | |
- if ( url ) { | |
- data.url = url; | |
- } | |
- } else { | |
- T.each('title,link,img,btn,others'.split(','), function (key) { | |
- if ( DOM.hasClass(from, options[key]) ) { | |
- type = key; | |
- } | |
- }); | |
- } | |
- | |
- data.rsv_xpath = path.join('-').toLowerCase() + '(' + type + ')'; | |
- return data; | |
- }; | |
- | |
- /** | |
- * 配置项 | |
- * | |
- * @type {Object} | |
- * @type {string} options.action 日志统计服务接口地址 | |
- * @type {string} options.main 日志统计顶层容器className | |
- * @type {string} options.title xpath中title类型的className | |
- * @type {string} options.link xpath中link类型的className | |
- * @type {string} options.img xpath中img类型的className | |
- * @type {string} options.btn xpath中btn类型的className | |
- * @type {string} options.others xpath中others类型的className | |
- * @type {Object} options.data 统计公共数据部分 | |
- */ | |
- var options = /** @lends log.options */ { | |
- | |
- // 日志统计服务接口地址 | |
- action: 'http://sclick.baidu.com/w.gif?', | |
- | |
- // 日志统计顶层容器className | |
- main: 'result-op', | |
- | |
- // xpath中title类型的className | |
- title: 'OP_LOG_TITLE', | |
- | |
- // xpath中link类型的className | |
- link: 'OP_LOG_LINK', | |
- | |
- // xpath中img类型的className | |
- img: 'OP_LOG_IMG', | |
- | |
- // xpath中btn类型的className | |
- btn: 'OP_LOG_BTN', | |
- | |
- // xpath中others类型的className | |
- others: 'OP_LOG_OTHERS', | |
- | |
- // 统计公共数据部分 | |
- data: {} | |
- }; | |
- | |
- /** | |
- * 页面点击监听 | |
- * | |
- * @inner | |
- * @param {DOMEvent} e DOM事件对象 | |
- */ | |
- var onClick = function (e) { | |
- var target = T.event.getTarget(e); | |
- var klass = options.main; | |
- var main = DOM.hasClass(target, klass) | |
- ? target | |
- : DOM.getAncestorByClass(target, klass); | |
- var nolog = target.getAttribute('data-nolog') === '1'; | |
- | |
- if ( nolog || !main ) { | |
- return; | |
- } | |
- | |
- var data = target.getAttribute('data-click'); | |
- | |
- if ( data ) { | |
- data = parseJson(data); | |
- } | |
- | |
- data = fill(data || {}, target, main); | |
- | |
- // 某个上级节点配置了 data-nolog 之后 | |
- if ( !data ) { | |
- return; | |
- } | |
- | |
- if ( options.data ) { | |
- data = T.extend(T.extend({}, options.data), data); | |
- } | |
- | |
- data.t = (+new Date).toString(36); | |
- | |
- send(options.action + T.url.jsonToQuery(data)); | |
- }; | |
- | |
- // 对外暴露的send | |
- function outerSender(data) { | |
- if ( !data ) { | |
- return; | |
- } | |
- | |
- if ( options.data ) { | |
- data = T.extend(T.extend({}, options.data), data); | |
- } | |
- | |
- data.t = (+new Date).toString(36); | |
- | |
- send(options.action + T.url.jsonToQuery(data)); | |
- }; | |
- | |
- /** | |
- * 日志模块对象 | |
- * | |
- * @type {Object} | |
- */ | |
- var log = { | |
- | |
- _send: outerSender, | |
- | |
- /** | |
- * 配置项 | |
- * | |
- * @param {Object} ops 可配置项 | |
- * @type {string} ops.action 日志统计服务接口地址 | |
- * @type {string} ops.main 日志统计顶层容器className | |
- * @type {string} ops.title xpath中title类型的className | |
- * @type {string} ops.link xpath中link类型的className | |
- * @type {string} ops.img xpath中img类型的className | |
- * @type {string} ops.btn xpath中btn类型的className | |
- * @type {string} ops.others xpath中others类型的className | |
- * @type {Object} ops.data 统计公共数据部分 | |
- */ | |
- config: function (ops) { | |
- T.extend(options, ops); | |
- }, | |
- | |
- /** | |
- * 开始监听页面点击日志 | |
- * | |
- */ | |
- start: function () { | |
- T.on(document, 'click', onClick); | |
- }, | |
- | |
- /** | |
- * 停止监听页面点击日志 | |
- * | |
- */ | |
- stop: function () { | |
- T.un(document, 'click', onClick); | |
- } | |
- }; | |
- | |
- return log; | |
-})(); | |
-}); | |
\ No newline at end of file | |
diff --git a/course/edp-build-config.js b/course/edp-build-config.js | |
index 5ff3f03..6317a13 100644 | |
--- a/course/edp-build-config.js | |
+++ b/course/edp-build-config.js | |
@@ -9,41 +9,39 @@ var pageEntries = 'html,htm,phtml,tpl,vm'; | |
exports.getProcessors = function () { | |
return [ | |
new LessCompiler( { | |
- entryExtnames: pageEntries | |
- } ), | |
- new CssCompressor(), | |
- new ModuleCompiler( { | |
- 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' } | |
+ files: [ | |
+ 'src/common/css/main.less' | |
], | |
- from: 'src', | |
- to: 'asset' | |
- } ) | |
+ pageFiles: [ | |
+ 'templates/index.tpl' | |
+ ] | |
+ } ), | |
+ new CssCompressor({ | |
+ files: [ | |
+ 'src/common/css/main.less', | |
+ '*.css' | |
+ ] | |
+ }), | |
+ new ModuleCompiler(), | |
+ // new JsCompressor(), | |
+ new PathMapper() | |
]; | |
}; | |
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', | |
+ 'module.conf', | |
+ 'dep/packages.manifest', | |
+ 'dep/*/*/test', | |
+ 'dep/*/*/doc', | |
+ 'dep/*/*/demo', | |
+ 'dep/*/*/tool', | |
+ 'dep/*/*/*.md', | |
+ 'dep/*/*/package.json', | |
+ 'edp-*', | |
+ '.edpproj', | |
'.svn', | |
'.git', | |
'.gitignore', | |
@@ -57,9 +55,9 @@ exports.exclude = [ | |
'*.swp', | |
'*.bat', | |
'*.php', | |
- '/templates_c', | |
- '/build', | |
- '/src/common/css/img/source' | |
+ 'templates_c', | |
+ 'build', | |
+ 'src/common/css/img/source' | |
]; | |
exports.injectProcessor = function ( processors ) { | |
diff --git a/course/edp-webserver-config.js b/course/edp-webserver-config.js | |
index 479b1e3..4266faa 100644 | |
--- a/course/edp-webserver-config.js | |
+++ b/course/edp-webserver-config.js | |
@@ -36,6 +36,12 @@ exports.getLocations = function () { | |
less() | |
] | |
}, | |
+ { | |
+ location: /\.php$/, | |
+ handler: [ | |
+ php('php-cgi') | |
+ ] | |
+ }, | |
{ | |
location: /^.*$/, | |
handler: [ | |
diff --git a/course/edu_course.php b/course/edu_course.php | |
index ea7ec7b..37c6db6 100644 | |
--- a/course/edu_course.php | |
+++ b/course/edu_course.php | |
@@ -30,7 +30,7 @@ $smarty->assign("course_org_introduction", "新东方教育科技集团,20年 | |
// $smarty->assign("course_img", ""); | |
-$couse_host = "http://127.0.0.1:8848/course"; | |
+$couse_host = "http://127.0.0.1:8848"; | |
$smarty->assign("course_host", $couse_host); | |
// $smarty->assign("course_directly_map", 1); | |
@@ -243,4 +243,4 @@ $smarty -> assign('bd_stat_signature', '1128e9e0f1fc927bb885835e0e7a6e48'); | |
// 是否是被嵌套在商桥页面iframe | |
$smarty -> assign('is_frm', 1); | |
-$smarty->display('index.tpl'); | |
\ No newline at end of file | |
+$smarty->display('index.tpl'); | |
diff --git a/course/module.conf b/course/module.conf | |
index 1fbcf09..42d8db4 100644 | |
--- a/course/module.conf | |
+++ b/course/module.conf | |
@@ -4,13 +4,11 @@ | |
"packages": [ | |
{ | |
"name": "log", | |
- "location": "dep/log", | |
+ "location": "../dep/log/0.0.1/src", | |
"main": "log" | |
} | |
], | |
"combine": { | |
- "main": { | |
- "include": [ "common/course" ] | |
- } | |
+ "main": true | |
} | |
-} | |
\ No newline at end of file | |
+} | |
diff --git a/course/src/main.js b/course/src/main.js | |
index f3ad099..c7aa1bf 100644 | |
--- a/course/src/main.js | |
+++ b/course/src/main.js | |
@@ -3,7 +3,6 @@ | |
* @author wuhuiyao | |
*/ | |
define(function (require) { | |
- require('log'); | |
require('./common/control'); | |
- require(['./common/course']); | |
-}); | |
\ No newline at end of file | |
+ require('./common/course'); | |
+}); | |
diff --git a/course/templates/index.tpl b/course/templates/index.tpl | |
index f52bb6a..dd4291d 100644 | |
--- a/course/templates/index.tpl | |
+++ b/course/templates/index.tpl | |
@@ -399,7 +399,7 @@ | |
'packages': [ | |
{ | |
'name': 'log', | |
- 'location': '../dep/log', | |
+ 'location': '../dep/log/0.0.1/src', | |
'main': 'log' | |
} | |
] | |
@@ -419,4 +419,4 @@ | |
require([ 'main' ]); | |
</script> | |
</body> | |
-</html> | |
\ No newline at end of file | |
+</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment