Skip to content

Commit ebdf6d9

Browse files
committed
start build bookmark
1 parent 5b29f65 commit ebdf6d9

9 files changed

Lines changed: 384 additions & 28 deletions

File tree

‎cache.manifest‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CACHE MANIFEST
2-
# Build: 20160113035402
2+
# Build: 20160115032152
33

44
CACHE:
55
resources/fonts/Dressedless_Three.svg
@@ -9,7 +9,7 @@ resources/images/paypal.png
99
resources/images/twohardtings.jpg
1010
resources/images/wechatpay.jpg
1111
resources/images/zhifubao.png
12-
src/lib/libs.381945f7.js
12+
src/lib/libs.543e0ad0.js
1313

1414
NETWORK:
1515
*

‎gulpfile.js‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,26 @@ gulp.task('watch', function () {
3232
});
3333

3434
});
35+
//clear dist folder
36+
gulp.task('clean:dist', function (cb) {
37+
return gulp.src(['./src/lib/*.js'])
38+
.pipe($.clean({force: true}))
39+
});
40+
3541
gulp.task('dist:js', function (cb) {
3642
var dir = './static/app/src/lib/';
37-
return gulp.src([dir+'jquery.min.js',dir+'tether.min.js',dir+'bootstrap.min.js',dir+'prettify.js',dir+'ZeroClipboard.min.js'])
43+
gulp.src([dir+'jquery.min.js',dir+'tether.min.js',dir+'bootstrap.min.js',dir+'prettify.js',dir+'ZeroClipboard.min.js',dir+'lovefield.min.js'])
44+
.pipe($.cached('build-cache', {
45+
optimizeMemory: true
46+
}))
3847
.pipe($.concat('libs.js'))
3948
.pipe(cachebust.references())
4049
.pipe($.uglify())
4150
.pipe(cachebust.resources())
42-
.pipe(gulp.dest('./src/lib/'));
51+
.pipe(gulp.dest('./src/lib/'))
52+
.on('end', function () {
53+
cb();
54+
});
4355
});
4456
gulp.task('dist:html', function () {
4557
return gulp.src(['./static/app/*.html'])
@@ -103,8 +115,8 @@ gulp.task('prepare', function (cb) {
103115
runSequence('build_version', cb);
104116
});
105117
gulp.task('compile', function (cb) {
106-
runSequence(['prepare','manifest','dist:html'], cb);
118+
runSequence('prepare', 'dist:js', 'dist:html', 'manifest', cb);
107119
});
108120
gulp.task('default', function (cb) {
109-
runSequence('compile','dist:js', 'watch', 'serve', cb);
121+
runSequence('clean:dist', 'compile', 'watch', 'serve', cb);
110122
});

‎index.html‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎package.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"date-utils": "^1.2.16",
99
"gulp": "^3.9.0",
1010
"gulp-cachebust": "0.0.6",
11+
"gulp-cached": "^1.1.0",
12+
"gulp-clean": "^0.3.1",
1113
"gulp-concat": "^2.6.0",
1214
"gulp-file-include": "^0.13.7",
1315
"gulp-htmlmin": "^1.3.0",

‎src/lib/libs.381945f7.js‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

‎src/lib/libs.543e0ad0.js‎

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎static/app/index.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ <h5 class="variable-wrap" data-id="{id}" data-repo="{repo}" data-val="{val}"><sp
123123
</div>
124124
</div>
125125
</section>
126+
126127
<section class="container donate" hidden>
127128
<header class="title">
128129
<h6 class="lang en">Buy <a href="https://twitter.com/unbug" target="_blank">@unbug</a> a drink</h6>

‎static/app/src/App.js‎

Lines changed: 73 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ $(function () {
230230
//model
231231
//http://githut.info/
232232
var topProgramLan = [{"id":"22,106","language":"JavaScript, CoffeeScript"},{"id":"133,135","language":"CSS"},{"id":"3,39","language":"HTML"},{"id":137,"language":"Swift"},{"id":35,"language":"Objective-C"},{"id":23,"language":"Java"},{"id":19,"language":"Python"},{"id":24,"language":"PHP"},{"id":32,"language":"Ruby"},{"id":28,"language":"C"},{"id":16,"language":"C++"},{"id":6,"language":"C#"},{"id":55,"language":"Go"},{"id":51,"language":"Perl"},{"id":"104,109","language":"Clojure, ClojureScript"},{"id":40,"language":"Haskell"},{"id":54,"language":"Lua"},{"id":20,"language":"Matlab"},{"id":144,"language":"R"},{"id":47,"language":"Scala"},{"id":"69,78,146","language":"Shell"},{"id":29,"language":"Lisp"},{"id":42,"language":"ActionScript"}];
233-
var searchcode = new function(){
233+
var searchcodeModel = new function(){
234234
var persistLangsName = 'codelf_langs_selected';
235235
var langs = localStorage.get(persistLangsName),langQuery;
236236
var page = 0;
@@ -307,7 +307,7 @@ $(function () {
307307
}
308308
};
309309

310-
var youdaoTranslate = new function (){
310+
var youdaoTranslateModel = new function (){
311311
var lastVal;
312312
var translateRequestCallback;
313313
this.request = function(val,callback){
@@ -332,7 +332,7 @@ $(function () {
332332
}
333333
}
334334
};
335-
var DDMS = new function(){
335+
var DDMSModel = new function(){
336336
var persistKeyWordsName = 'codelf_ddms_keywords';
337337
var persistKeyWordsTimerName = persistKeyWordsName+'_timer';
338338
var cacheKeyWords = (localStorage.get(persistKeyWordsName) || '').split(',');
@@ -361,7 +361,59 @@ $(function () {
361361
}
362362
};
363363

364-
var beanHelpers = new function(){
364+
var bookmarkModel = new function (){
365+
this.repos = new function (){
366+
var _this = this;
367+
var page = 1;
368+
var mainData = [];
369+
function storeRepos(data){
370+
mainData = mainData.concat(data);
371+
}
372+
this.request = function(callback){
373+
$.ajax({
374+
type: 'GET',
375+
dataType: 'json',
376+
url: 'https://api.github.com/users/unbug/repos?per_page=100&page='+page,
377+
success: function(data){
378+
if(data && data.length){
379+
storeRepos(data);
380+
page++;
381+
_this.request(callback);
382+
}else{
383+
callback && callback(mainData);
384+
}
385+
}
386+
});
387+
}
388+
};
389+
390+
this.stars = new function (){
391+
var _this = this;
392+
var page = 1;
393+
var mainData = [];
394+
function storeRepos(data){
395+
mainData = mainData.concat(data);
396+
}
397+
this.request = function(callback){
398+
$.ajax({
399+
type: 'GET',
400+
dataType: 'json',
401+
url: 'https://api.github.com/users/unbug/starred?per_page=100&page='+page,
402+
success: function(data){
403+
if(data && data.length){
404+
storeRepos(data);
405+
page++;
406+
_this.request(callback);
407+
}else{
408+
callback && callback(mainData);
409+
}
410+
}
411+
});
412+
}
413+
};
414+
};
415+
416+
var beanHelpersModel = new function(){
365417
this.getRandomLabelType = function (){
366418
var types = ['default','primary','success','info','warning','warning','danger'];
367419
return randomList(types,1)[0];
@@ -472,7 +524,7 @@ $(function () {
472524

473525
function showSourceCode(){
474526
renderSourceCode();
475-
searchcode.requestSourceCode(this.dataset.id,renderSourceCode);
527+
searchcodeModel.requestSourceCode(this.dataset.id,renderSourceCode);
476528
this.dataset.val && renderRelatedProperty(this.dataset.val);
477529
els.sourceCodeModal.modal('show');
478530
}
@@ -487,12 +539,12 @@ $(function () {
487539
checked.each(function(){
488540
lang.push(this.value);
489541
});
490-
searchcode.setLang(lang.join(' '));
542+
searchcodeModel.setLang(lang.join(' '));
491543
renderSearchBtn('Search');
492544
}
493545
function onResetLang(){
494546
els.searchDropdownMenu.find('input').removeAttr('checked');
495-
searchcode.setLang();
547+
searchcodeModel.setLang();
496548
renderSearchBtn('Search');
497549
}
498550
function onSearch(val){
@@ -519,7 +571,7 @@ $(function () {
519571
});
520572
els.lastVal = tmpval.join(' ');
521573
if(tmpch.length){
522-
youdaoTranslate.request(tmpch.join(' '),function(tdata){
574+
youdaoTranslateModel.request(tmpch.join(' '),function(tdata){
523575
//basic translate
524576
if(tdata.basic && tdata.basic.explains){
525577
els.valHistory = tdata.basic.explains.join(' ');
@@ -563,21 +615,21 @@ $(function () {
563615
function saveKeyWordRegs(){
564616
els.valRegs = [];
565617
els.lastVal.replace(/\s+/ig,'+').split('+').forEach(function(key){
566-
key.length && els.valRegs.push(beanHelpers.getKeyWordReg(key));
618+
key.length && els.valRegs.push(beanHelpersModel.getKeyWordReg(key));
567619
});
568620
}
569621

570622
function doSearch(){
571623
if(els.lastVal && els.lastVal.length){
572-
searchcode.request(els.lastVal,renderSearchResult);
624+
searchcodeModel.request(els.lastVal,renderSearchResult);
573625
renderSearchResultHeader('loading');
574626
renderSearchBtn();
575627
}else{
576628
renderSearchResultHeader('error');
577629
renderSearchBtn('Search');
578630
}
579631

580-
els.isGithub && DDMS.postKeyWords(els.lastInputVal);
632+
els.isGithub && DDMSModel.postKeyWords(els.lastInputVal);
581633
renderAnalytics('q='+els.lastInputVal);
582634
}
583635

@@ -608,7 +660,7 @@ $(function () {
608660
}
609661

610662
function renderLangMunu(){
611-
var htm = [],storeLang = searchcode.getLang();
663+
var htm = [],storeLang = searchcodeModel.getLang();
612664
storeLang = storeLang?storeLang.split(' '):[];
613665
topProgramLan.forEach(function(key){
614666
htm.push(els.searchDropdownMenuTpl
@@ -651,7 +703,7 @@ $(function () {
651703
vals.push(el);
652704
//render variable labels
653705
labels.push(els.searchResultTpl
654-
.replace('{label_type}',beanHelpers.getRandomLabelType())
706+
.replace('{label_type}',beanHelpersModel.getRandomLabelType())
655707
.replace(/\{val\}/g,el)
656708
.replace('{id}',rkey.id)
657709
.replace('{repo}',rkey.repo)
@@ -750,7 +802,7 @@ $(function () {
750802
els.sourceCodeModalDropdownTpl.replace(/\{id\}/g,ids[i])
751803
.replace(/\{repo\}/g,repos[i])
752804
.replace(/\{lang\}/g,langs[i])
753-
.replace(/\{label_type\}/g,beanHelpers.getRandomLabelType())
805+
.replace(/\{label_type\}/g,beanHelpersModel.getRandomLabelType())
754806
);
755807
}
756808
}
@@ -779,6 +831,13 @@ $(function () {
779831
window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"slide":{"type":"slide","bdImg":"5","bdPos":"right","bdTop":els.body.height()/2-80}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
780832
}
781833

834+
bookmarkModel.repos.request(function(data){
835+
console.log('repos',data.length,data);
836+
});
837+
bookmarkModel.stars.request(function(data){
838+
console.log('stars',data.length,data);
839+
});
840+
782841
init();
783842
//end view and render
784843
});

0 commit comments

Comments
 (0)