Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/tryToUseWebpack'
Browse files Browse the repository at this point in the history
  • Loading branch information
bh-lay committed Aug 30, 2017
2 parents 59c4d38 + be65cb3 commit 2203de0
Show file tree
Hide file tree
Showing 49 changed files with 7,412 additions and 3,074 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ results
.project
.idea/
npm-debug.log
sys/node_modules/
node_modules
web/topic/

24 changes: 24 additions & 0 deletions frontEnd/admin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "multi-page",
"version": "1.0.0",
"description": "blog's administrator project",
"main": "app.js",
"scripts": {
"dev": "fis3 release -wd ../../static/",
"production": "fis3 release production -d ../../static/"
},
"repository": {
"type": "git",
"url": "git+https://github.com/bh-lay/blog.git"
},
"keywords": [
"bh-lay",
"blog"
],
"author": "剧中人[bh-lay.com]",
"license": "ISC",
"bugs": {
"url": "https://github.com/bh-lay/blog/issues"
},
"homepage": "https://github.com/bh-lay/blog#readme"
}
20 changes: 4 additions & 16 deletions frontEnd/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ function help(){
echo "Usage sh $0 [project] [media]";
echo " project 项目目录名,all为编译全部";
echo " media fis3 中配置的 media(可选)\n";
echo "notice 非编译全部项目[all],且未指定 media 时,默认开启 watch\n";
}

# 画横线
Expand All @@ -17,10 +16,10 @@ function deploy(){
if [ ${1:0:1} == '_' ]; then
echo "skip ["$1"], ["$1"] is not a project !\n";
else
echo ' frontEnd/'$1 ' --> '$deployTo;
echo ' fis3 release '$deployMedia' '$watch' -d '$deployTo' --file fis-conf.js'
echo ' cd frontEnd/'$1;
echo ' npm run '$deployMedia
cd $root'/'$1
fis3 release $deployMedia $watch -d $deployTo --file fis-conf.js
npm run $deployMedia
fi
}

Expand All @@ -31,16 +30,6 @@ root=`pwd`;
# 发布media,fis3的参数
deployMedia=${2:-''};

# 发布目录
deployTo='../../static/';

# 是否开启持续观测模式
watch='';
# 没有media配置时才用watch
if [ ${#deployMedia} == 0 ]; then
watch='-w';
fi



echo '\n[BDS] bh-lay deploy system'
Expand All @@ -61,8 +50,7 @@ elif [ $1 == 'all' ]; then
# all 编译所有项目

echo "deploy all project start ";
# 取消 watch
watch='';

# 遍历编译所有项目
for x in `ls -l | grep '^d' | awk '{print $9}'`
do
Expand Down
24 changes: 24 additions & 0 deletions frontEnd/multi-page/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "multi-page",
"version": "1.0.0",
"description": "blog's multi page project",
"main": "null",
"scripts": {
"dev": "fis3 release -wd ../../static/",
"production": "fis3 release production -d ../../static/"
},
"repository": {
"type": "git",
"url": "git+https://github.com/bh-lay/blog.git"
},
"keywords": [
"bh-lay",
"blog"
],
"author": "剧中人[bh-lay.com]",
"license": "ISC",
"bugs": {
"url": "https://github.com/bh-lay/blog/issues"
},
"homepage": "https://github.com/bh-lay/blog#readme"
}
206 changes: 102 additions & 104 deletions frontEnd/single-page/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,124 +3,122 @@
* Copyright (c) 2012-2018
**/

window.L = window.L || {};
// window.L = window.L || {};

require([
'js/user',
'js/navigation',
'js/Base',
'js/routerHandle',
'js/imageHosting',
'js/funny',
import './css/main.less';

'js/dialog'
], function (user,navigation,utils,routerHandle,imageHosting,funny){
import user from './js/user.js'
import navigation from './js/navigation.js'
import utils from "./js/Base.js";
import imageHosting from "./js/imageHosting.js";
import funny from "./js/funny.js";
import UI from "./js/dialog.js";
import routerHandle from "./js/routerHandle.js";

/**
* 判断是否支持css属性
* 兼容css3
*/
var supports = (function() {
var styles = document.createElement('div').style,
vendors = 'Webkit Khtml Ms O Moz'.split(/\s/);
/**
* 判断是否支持css属性
* 兼容css3
*/
let supports = (function() {
let styles = document.createElement('div').style;
let vendors = 'Webkit Khtml Ms O Moz'.split(/\s/);

return function(prop) {
if ( prop in styles ){
return prop;
}else{
prop = prop.replace(/^[a-z]/, function(val) {
return val.toUpperCase();
});
for(var i=0,total=vendors.length;i<total;i++){
if ( vendors[i] + prop in styles ) {
return ('-' + vendors[i] + '-' + prop).toLowerCase();
}
return function(prop) {
if ( prop in styles ){
return prop;
}else{
prop = prop.replace(/^[a-z]/, function(val) {
return val.toUpperCase();
});
for(var i=0,total=vendors.length;i<total;i++){
if ( vendors[i] + prop in styles ) {
return ('-' + vendors[i] + '-' + prop).toLowerCase();
}
}
};
})();
//是否支持 canvas
var supports_canvas = !!document.createElement('canvas').getContext ? true : false,
//是否为windows系统
isWindows = /windows|win32/.test(navigator.userAgent.toLowerCase()),
//是否支持 history API
isHistorySupported = window.history && window.history.pushState,
//是否为高级浏览器
isAdvancedBrowser = (supports('transform') && isHistorySupported && supports_canvas) ? true : false;

//屌丝就用屌丝版
if (!isAdvancedBrowser) {
document.cookie = 'ui_version=html;path=/;';
window.location.reload();
}
//为windows系统定制body滚动条样式(仅webkit有效)
if(isWindows){
utils.addClass(utils.query('body'),'define-scrollbar');
}

L.user = user;
//占用全局方法
L.gravatar_error_fn = function(elem){
if(elem.src.indexOf('www.gravatar.com') > -1){
//若gravatar官网请求失败,使用多说镜像
elem.src = elem.src.replace('www.gravatar.com','gravatar.duoshuo.com');
}else if(elem.src.indexOf('gravatar.duoshuo.com') > -1){
//若多说镜像失败,使用默认头像
elem.src = __uri('/images/default.jpg');
}
//其余情况均不处理(已是默认头像)
};
})();
//是否支持 canvas
let supports_canvas = !!document.createElement('canvas').getContext;
//是否为windows系统
let isWindows = /windows|win32/.test(navigator.userAgent.toLowerCase());
//是否支持 history API
let isHistorySupported = window.history && window.history.pushState;
//是否为高级浏览器
let isAdvancedBrowser = !!(supports('transform') && isHistorySupported && supports_canvas);

//模块替换
L.tplModule = function(txt){
return (txt && txt.length) ? txt.replace(/\[\-(\w+)\-\]/g,function(a,key){
return utils.query('#module_' + key).innerHTML || '';
}) : '';
};
//屌丝就用屌丝版
if (!isAdvancedBrowser) {
document.cookie = 'ui_version=html;path=/;';
window.location.reload();
}
//为windows系统定制body滚动条样式(仅webkit有效)
if (isWindows) {
utils.addClass(utils.query('body'),'define-scrollbar');
}
window.L = {};
L.user = user;
//占用全局方法
L.gravatar_error_fn = function(elem){
if(elem.src.indexOf('www.gravatar.com') > -1){
//若gravatar官网请求失败,使用多说镜像
elem.src = elem.src.replace('www.gravatar.com','gravatar.duoshuo.com');
}else if(elem.src.indexOf('gravatar.duoshuo.com') > -1){
//若多说镜像失败,使用默认头像
elem.src = require("./images/default.jpg");
}
//其余情况均不处理(已是默认头像)
};

//动态插入emoji表情样式
var str = '<style type="text/css" data-module="emoji">';
(utils.query('#data_emoji').innerHTML || '').trim().split(/\s+/).forEach(function(item,index){
str += '.emoji.s_' + item + '{background-position: -' + (index * 25) + 'px 0;}';
});
str += '</style>';
utils.query('head').insertAdjacentHTML('beforeEnd', str);
//模块替换
L.tplModule = function(txt){
return (txt && txt.length) ? txt.replace(/\[\-(\w+)\-\]/g,function(a,key){
return utils.query('#module_' + key).innerHTML || '';
}) : '';
};

//配置弹出层
UI.config.zIndex(2000);
//动态插入emoji表情样式
var str = '<style type="text/css" data-module="emoji">';
(utils.query('#data_emoji').innerHTML || '').trim().split(/\s+/).forEach(function(item,index){
str += '.emoji.s_' + item + '{background-position: -' + (index * 25) + 'px 0;}';
});
str += '</style>';
utils.query('head').insertAdjacentHTML('beforeEnd', str);

//开始导航
navigation.init();
//加入一些好玩的东西
funny();
//开始掌控路由
routerHandle();
//渐隐加载遮罩
utils.addClass(utils.query('.app_mask'),'app_mask_out');
setTimeout(function () {
utils.remove(utils.query('.app_mask'));
}, 1000);
//配置弹出层
UI.config.zIndex(2000);

//开始导航
navigation.init();
//加入一些好玩的东西
funny();
//开始掌控路由
routerHandle();
//渐隐加载遮罩
utils.addClass(utils.query('.app_mask'),'app_mask_out');
setTimeout(function () {
utils.remove(utils.query('.app_mask'));
}, 1000);

/**
* 分享功能
* data-text data-url data-title data-img data-shareto
*/
utils.bind(utils.query('body'),'click','.sns-share a',function(){
var node_data = utils.parents(this,'.sns-share'),
url = node_data.getAttribute('data-url') || location.href,
text = encodeURIComponent(node_data.getAttribute('data-text')) || document.title,
title = encodeURIComponent(node_data.getAttribute('data-title')),
img = node_data.getAttribute('data-img'),
shareto = this.getAttribute('data-shareto');

img = img ? imageHosting(img) : '';
var share_url={
weibo: 'http://service.weibo.com/share/share.php?title='+text+'+&url='+url+'&source=bookmark&appkey=2861592023&searchPic=false&pic='+img,
qzone: 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?summary='+text+'&url='+url+'&title='+ title+'&pics='+img+'&desc='+text
};
share_url[shareto] && window.open(share_url[shareto]);
return false;
});
/**
* 分享功能
* data-text data-url data-title data-img data-shareto
*/
utils.bind(utils.query('body'),'click','.sns-share a', function () {
var node_data = utils.parents(this,'.sns-share'),
url = node_data.getAttribute('data-url') || location.href,
text = encodeURIComponent(node_data.getAttribute('data-text')) || document.title,
title = encodeURIComponent(node_data.getAttribute('data-title')),
img = node_data.getAttribute('data-img'),
shareto = this.getAttribute('data-shareto');

img = img ? imageHosting(img) : '';
var share_url={
weibo: 'http://service.weibo.com/share/share.php?title='+text+'+&url='+url+'&source=bookmark&appkey=2861592023&searchPic=false&pic='+img,
qzone: 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?summary='+text+'&url='+url+'&title='+ title+'&pics='+img+'&desc='+text
};
share_url[shareto] && window.open(share_url[shareto]);
return false;
});

56 changes: 28 additions & 28 deletions frontEnd/single-page/comments/face.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
define([
'js/Base',
'js/juicer'
],function(utils,juicer){
var face_config = 'smile grinning smiley blush relaxed wink heart_eyes kissing_heart kissing_heart kissing flushed grin pensive relieved cry scream angry mask tired_face sleeping hushed smirk 1 -1 two_men_holding_hands heart broken_heart gun';
var face_tpl = ['<div class="face_list">{@each list as it}',
'<a href="javascript:void(0)" title="${it}"><span class="emoji s_${it}"></span></a>',
'{@/each}</div>'].join('');

function face(param){
var html = '';
var config_arr = face_config.split(/\s/);
var html = juicer(face_tpl,{
list: config_arr
});
import utils from "../js/Base.js";
import juicer from "../js/juicer.js";
import UI from "../js/dialog.js";

var pop = UI.pop({
title: '贱萌的emoji表情',
top: param.top,
left: param.left,
width: 300,
html : html
});
utils.bind(pop.cntDom,'click','a',function(){
param.onSelect && param.onSelect(this.getAttribute('title'));
pop.close();
});
}
return face;
});
var face_config = 'smile grinning smiley blush relaxed wink heart_eyes kissing_heart kissing_heart kissing flushed grin pensive relieved cry scream angry mask tired_face sleeping hushed smirk 1 -1 two_men_holding_hands heart broken_heart gun';
var face_tpl = ['<div class="face_list">{@each list as it}',
'<a href="javascript:void(0)" title="${it}"><span class="emoji s_${it}"></span></a>',
'{@/each}</div>'].join('');

function face(param){
var html = '';
var config_arr = face_config.split(/\s/);
var html = juicer(face_tpl,{
list: config_arr
});

var pop = UI.pop({
title: '贱萌的emoji表情',
top: param.top,
left: param.left,
width: 300,
html : html
});
utils.bind(pop.cntDom,'click','a',function(){
param.onSelect && param.onSelect(this.getAttribute('title'));
pop.close();
});
}
export default face;
Loading

0 comments on commit 2203de0

Please sign in to comment.