Skip to content

Commit 9888cea

Browse files
committed
first version
1 parent 06f1c36 commit 9888cea

File tree

170 files changed

+35110
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+35110
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
node_modules

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 SUPER O2 MAN
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

100644100755
Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
1-
# 编码规范
1+
# Full-Stack Development Guide
22

3-
前端代码规范旨在确保每一行代码易读、易维护,从而形成团队统一编码风格,最终确保项目的专业化输出。
3+
Installation Guides For Full-Stack Developers Using MAC OS
4+
5+
## Getting started
6+
7+
Install dependencies:
8+
9+
``` bash
10+
$ git clone https://github.com/o2team/guide.git
11+
$ cd guide
12+
$ npm install
13+
```
14+
15+
Generate:
16+
17+
``` bash
18+
$ hexo g
19+
```
20+
21+
Run server:
22+
23+
``` bash
24+
$ hexo s --watch
25+
```
26+
27+
## Deployment
28+
29+
1. Generate and optimize assets
30+
31+
```bash
32+
gulp
33+
```
34+
35+
2. Deploy to the gh-pages branch
36+
37+
```bash
38+
hexo deploy
39+
```
40+
41+
## Contributors
42+
43+
- English - [mamboer]
44+
- 简体中文 - [天哥]
45+
46+
## License
47+
48+
[CC BY 4.0](http://creativecommons.org/licenses/by/4.0/)

_config.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
title: Aotu.io - 前端代码规范
2+
subtitle: "Front-End Coding Guidelines"
3+
description: "Best Coding Guidelines For Front-End Developer."
4+
author: 凹凸实验室
5+
language: zh-cn
6+
timezone: UTC
7+
url: http://aotu.io/guide
8+
root: /guide/
9+
permalink: news/:year/:month/:day/:title/
10+
archive_dir: news
11+
code_dir: downloads/code
12+
new_post_name: :year-:month-:day-:title.md # File name of new posts
13+
post_asset_folder: true
14+
highlight:
15+
enable: true
16+
line_number: false
17+
per_page: 0
18+
19+
theme: navy
20+
deploy:
21+
type: git
22+
repo: [email protected]:o2team/guide.git
23+
branch: gh-pages
24+
25+
disqus_shortname:
26+
google_analytics: UA-4910098-10
27+
baidu_analytics: bb4b770d7fdf4e05245cd1327199d813
28+
fb_admins: 100000247608790
29+
swiftype_key: nxhXzi1rDss_9_P_6zBa
30+
twitter: o2circle
31+
github: o2team/guide
32+
gh:
33+
user: o2team
34+
repo: guide

db.json

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

gulpfile.js

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
'use strict';
2+
3+
var gulp = require('gulp'),
4+
$ = require('gulp-load-plugins')(),
5+
cssnano = require('cssnano'),
6+
yaml = require('js-yaml'),
7+
fs = require('fs'),
8+
cfg = yaml.safeLoad(fs.readFileSync('_config.yml'));
9+
10+
require('shelljs/global');
11+
12+
var htmlMinifierOptions = {
13+
removeComments: true,
14+
collapseWhitespace: true,
15+
collapseBooleanAttributes: true,
16+
removeScriptTypeAttributes: true,
17+
removeStyleLinkTypeAttributes: true,
18+
removeOptionalTags: true,
19+
minifyJS: true,
20+
minifyCSS: true
21+
};
22+
23+
var dirs = {
24+
public: 'public',
25+
fonts: 'public/fonts',
26+
imgs: 'public/img',
27+
assetsDir:'public/assets'
28+
};
29+
30+
gulp.task('useref', ['hexo'], function(){
31+
32+
return gulp.src('public/**/*.html')
33+
.pipe($.useref({
34+
searchPath:'public',
35+
transformPath: function(filePath) {
36+
return filePath.replace(dirs.public + cfg.root, dirs.public + '/');
37+
}
38+
}))
39+
.pipe($.if('*.css', $.postcss([
40+
cssnano()
41+
])))
42+
.pipe($.if('*.css', $.minifyCss()))
43+
.pipe($.if('*.js', $.uglify()))
44+
.pipe($.if('*.html', $.htmlMinifier(htmlMinifierOptions)))
45+
.pipe(gulp.dest('public'));
46+
});
47+
48+
gulp.task('rev:media', function(){
49+
50+
return gulp.src([dirs.fonts + '/**/*', dirs.imgs + '/**/*'], {base: dirs.public})
51+
.pipe($.rev())
52+
.pipe(gulp.dest(dirs.assetsDir))
53+
.pipe($.rev.manifest('rev-media.json'))
54+
.pipe(gulp.dest(dirs.assetsDir));
55+
56+
});
57+
58+
gulp.task('rev:scripts', ['useref', 'rev:media'], function(){
59+
var manifest = gulp.src(dirs.assetsDir + '/rev-media.json');
60+
61+
return gulp.src([dirs.public + '/css/dist*.css', dirs.public + '/js/dist*.js'], {base: dirs.public})
62+
.pipe($.rev())
63+
.pipe($.revReplace({
64+
manifest: manifest
65+
}))
66+
.pipe(gulp.dest(dirs.assetsDir))
67+
.pipe($.rev.manifest())
68+
.pipe(gulp.dest(dirs.assetsDir));
69+
70+
});
71+
72+
gulp.task('img:min', ['rev:media'], function(){
73+
74+
var pngquant = require('imagemin-pngquant');
75+
76+
return gulp.src(dirs.assetsDir + '/img/**/*', {base: dirs.assetsDir})
77+
.pipe($.imagemin({
78+
progressive: true,
79+
svgoPlugins: [{removeViewBox:false}],
80+
use:[pngquant()]
81+
}))
82+
.pipe(gulp.dest(dirs.assetsDir))
83+
});
84+
85+
gulp.task("rev:replace", ["rev:scripts"], function(){
86+
var manifest = gulp.src([dirs.assetsDir + '/rev-*.json']);
87+
88+
return gulp.src([ dirs.public + "/**/*.html"])
89+
.pipe($.revReplace({
90+
manifest: manifest,
91+
modifyReved:function(fileName){
92+
if(fileName.indexOf('/dist') > -1){
93+
//special files proccessed by gulp-useref
94+
fileName = cfg.root + 'assets/' + fileName;
95+
}else {
96+
fileName = 'assets/' + fileName;
97+
}
98+
return fileName;
99+
}
100+
}))
101+
.pipe(gulp.dest(dirs.public));
102+
});
103+
104+
gulp.task('hexo', function(){
105+
106+
exec('hexo g');
107+
108+
});
109+
110+
gulp.task('img', ['img:min']);
111+
gulp.task('default', ['rev:replace', 'img']);

package.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "hexo-site",
3+
"version": "0.0.0",
4+
"private": true,
5+
"hexo": {
6+
"version": "3.1.1"
7+
},
8+
"scripts": {
9+
"build": "hexo generate && gulp"
10+
},
11+
"dependencies": {
12+
"cheerio": "^0.19.0",
13+
"hexo": "^3.1.1",
14+
"hexo-deployer-git": "0.0.4",
15+
"hexo-generator-archive": "^0.1.3",
16+
"hexo-generator-feed": "^1.0.3",
17+
"hexo-generator-sitemap": "^1.0.1",
18+
"hexo-renderer-jade": "^0.1.0",
19+
"hexo-renderer-marked": "^0.2.5",
20+
"hexo-renderer-stylus": "^0.3.0",
21+
"hexo-server": "^0.1.2",
22+
"lodash": "^3.10.1",
23+
"lunr": "^0.6.0"
24+
},
25+
"devDependencies": {
26+
"cssnano": "^3.3.1",
27+
"gulp": "^3.9.0",
28+
"gulp-favicons": "^2.1.3",
29+
"gulp-html-minifier": "^0.1.6",
30+
"gulp-if": "^2.0.0",
31+
"gulp-ignore": "^2.0.1",
32+
"gulp-image-resize": "^0.7.1",
33+
"gulp-imagemin": "^2.4.0",
34+
"gulp-load-plugins": "^1.1.0",
35+
"gulp-minify-css": "^1.2.1",
36+
"gulp-minify-html": "^1.0.4",
37+
"gulp-postcss": "^6.0.1",
38+
"gulp-rename": "^1.2.2",
39+
"gulp-rev": "^6.0.1",
40+
"gulp-rev-collector": "^1.0.2",
41+
"gulp-rev-replace": "^0.4.2",
42+
"gulp-uglify": "^1.5.1",
43+
"gulp-useref": "^3.0.0",
44+
"imagemin-pngquant": "^4.2.0",
45+
"js-yaml": "^3.4.3",
46+
"shelljs": "^0.5.3"
47+
},
48+
"optionalDependencies": {
49+
"hexo-browsersync": "^0.1.0"
50+
}
51+
}

scaffolds/page.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
title: {{ title }}
2+
---

scaffolds/post.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
title: {{ title }}
2+
---

scripts/helper.bstoc.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
'use strict';
2+
var cheerio;
3+
4+
function bsTOC(str, options) {
5+
options = options || {};
6+
7+
if (!cheerio) cheerio = require('cheerio');
8+
9+
var $ = cheerio.load(str);
10+
var headings = $('h1, h2, h3, h4, h5, h6');
11+
12+
if (!headings.length) return '';
13+
14+
var className = options.class || 'nav';
15+
var listNumber = options.hasOwnProperty('list_number') ? options.list_number : true;
16+
var result = '<ul class="' + className + ' toc-nav">';
17+
var lastNumber = [0, 0, 0, 0, 0, 0];
18+
var firstLevel = 0;
19+
var lastLevel = 0;
20+
var i = 0;
21+
22+
headings.each(function() {
23+
var level = +this.name[1];
24+
var id = $(this).attr('id');
25+
var text = $(this).text();
26+
27+
lastNumber[level - 1]++;
28+
29+
for (i = level; i <= 5; i++) {
30+
lastNumber[i] = 0;
31+
}
32+
33+
if (firstLevel) {
34+
for (i = level; i < lastLevel; i++) {
35+
result += '</li></ul>';
36+
}
37+
38+
if (level > lastLevel) {
39+
result += '<ul class="' + className + ' '+ className + '-child">';
40+
} else {
41+
result += '</li>';
42+
}
43+
} else {
44+
firstLevel = level;
45+
}
46+
47+
result += '<li class="' + className + '-item ' + className + '-level-' + level + '">';
48+
result += '<a class="' + className + '-link" href="#' + id + '">';
49+
50+
if (listNumber) {
51+
result += '<span class="' + className + '-number">';
52+
53+
for (i = firstLevel - 1; i < level; i++) {
54+
result += lastNumber[i] + '.';
55+
}
56+
57+
result += '</span> ';
58+
}
59+
60+
result += '<span class="' + className + '-text">' + text + '</span></a>';
61+
62+
lastLevel = level;
63+
});
64+
65+
for (i = firstLevel - 1; i < lastLevel; i++) {
66+
result += '</li></ul>';
67+
}
68+
69+
return result;
70+
};
71+
/**
72+
* boostrap scrollspy compatible toc
73+
*/
74+
hexo.extend.helper.register('bstoc', function(str, opts){
75+
return bsTOC(str, opts);
76+
});

0 commit comments

Comments
 (0)