Skip to content

Commit

Permalink
v1.0.0 beta
Browse files Browse the repository at this point in the history
  • Loading branch information
mamboer committed Nov 15, 2015
1 parent fc83a47 commit a0183d9
Show file tree
Hide file tree
Showing 82 changed files with 11,875 additions and 341 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,29 @@ $ npm install
Generate:

``` bash
$ hexo generate
$ hexo g
```

Run server:

``` bash
$ hexo server --watch
$ hexo s --watch
```

## Deployment

1. Generate and optimize assets

```bash
gulp
```

2. Deploy to the gh-pages branch

```bash
hexo deploy
```

## Contributors

- English - [mamboer]
Expand Down
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ author: 凹凸实验室(LV&天哥)
language: zh-cn
timezone: UTC
url: http://aotu.io/mac
root: /
root: /mac/
permalink: news/:year/:month/:day/:title/
archive_dir: news
code_dir: downloads/code
Expand Down
137 changes: 63 additions & 74 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
'use strict';

var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var cssnano = require('cssnano');
var gulp = require('gulp'),
$ = require('gulp-load-plugins')(),
cssnano = require('cssnano'),
yaml = require('js-yaml'),
fs = require('fs'),
cfg = yaml.safeLoad(fs.readFileSync('_config.yml'));

require('shelljs/global');

var htmlMinifierOptions = {
removeComments: true,
Expand All @@ -17,16 +22,20 @@ var htmlMinifierOptions = {

var dirs = {
public: 'public',
revSrc: 'public/build',
revDist: 'public/dist',
fonts: 'public/fonts',
screenshots: 'public/dist/screenshots'
imgs: 'public/img',
assetsDir:'public/assets'
};

gulp.task('useref', function(){
gulp.task('useref', ['hexo'], function(){

return gulp.src('public/**/*.html')
.pipe($.useref({searchPath:'public'}))
.pipe($.useref({
searchPath:'public',
transformPath: function(filePath) {
return filePath.replace(dirs.public + cfg.root, dirs.public + '/');
}
}))
.pipe($.if('*.css', $.postcss([
cssnano()
])))
Expand All @@ -36,87 +45,67 @@ gulp.task('useref', function(){
.pipe(gulp.dest('public'));
});

gulp.task('fonts', function(){

gulp.task('rev:media', function(){

return gulp.src([dirs.fonts + '/**/*'], {base: dirs.public})
return gulp.src([dirs.fonts + '/**/*', dirs.imgs + '/**/*'], {base: dirs.public})
.pipe($.rev())
.pipe(gulp.dest(dirs.revDist))
.pipe($.rev.manifest('rev-fonts.json'))
.pipe(gulp.dest(dirs.revDist));
.pipe(gulp.dest(dirs.assetsDir))
.pipe($.rev.manifest('rev-media.json'))
.pipe(gulp.dest(dirs.assetsDir));

});

gulp.task('rev:scripts', ['useref', 'rev:media'], function(){
var manifest = gulp.src(dirs.assetsDir + '/rev-media.json');

gulp.task('rev', ['useref', 'fonts'], function(){

var basePath = dirs.revSrc,
distPath = dirs.revDist;

return gulp.src([basePath+'/css/*.css', basePath + '/js/*.js'], {base: basePath})
return gulp.src([dirs.public + '/css/dist*.css', dirs.public + '/js/dist*.js'], {base: dirs.public})
.pipe($.rev())
.pipe(gulp.dest(distPath))
.pipe($.revReplace({
manifest: manifest
}))
.pipe(gulp.dest(dirs.assetsDir))
.pipe($.rev.manifest())
.pipe(gulp.dest(distPath));
.pipe(gulp.dest(dirs.assetsDir));

});

gulp.task("revreplace", ["rev"], function(){

return gulp.src([dirs.public + '/**/rev-manifest.json', "public/**/*.html", "public/dist/**/*.css"])
.pipe($.revCollector({
replaceReved:true,
dirReplacements: {
'build/':'dist/'
}
}))
.pipe($.ignore.exclude('./**/rev-*.json'))
.pipe(gulp.dest(dirs.public));
});
gulp.task('img:min', ['rev:media'], function(){

gulp.task('screenshot:rev', function(){
return gulp.src('public/themes/screenshots/*.png')
.pipe($.rev())
.pipe(gulp.dest(dirs.screenshots))
.pipe($.rev.manifest())
.pipe(gulp.dest(dirs.screenshots));
var pngquant = require('imagemin-pngquant');

return gulp.src(dirs.assetsDir + '/img/**/*', {base: dirs.assetsDir})
.pipe($.imagemin({
progressive: true,
svgoPlugins: [{removeViewBox:false}],
use:[pngquant()]
}))
.pipe(gulp.dest(dirs.assetsDir))
});

gulp.task('screenshot:resize', ['screenshot:rev'], function(){
var resizeOptions = {
width: 400,
height: 250,
crop: true
};

return gulp.src('public/dist/screenshots/*.png')
// Append "@2x" to the original images
.pipe($.rename({
suffix: '@2x'
}))
// Copy original images
.pipe(gulp.dest(dirs.screenshots))
// Resize images
.pipe($.imageResize(resizeOptions))
// Remove "@2x" in filename
.pipe($.rename(function(path){
path.basename = path.basename.replace('@2x', '');
return path;
}))
// Save resized images
.pipe(gulp.dest(dirs.screenshots));
gulp.task("rev:replace", ["rev:scripts"], function(){
var manifest = gulp.src([dirs.assetsDir + '/rev-*.json']);

return gulp.src([ dirs.public + "/**/*.html"])
.pipe($.revReplace({
manifest: manifest,
modifyReved:function(fileName){
if(fileName.indexOf('/dist') > -1){
//special files proccessed by gulp-useref
fileName = cfg.root + 'assets/' + fileName;
}else {
fileName = 'assets/' + fileName;
}
return fileName;
}
}))
.pipe(gulp.dest(dirs.public));
});

gulp.task('screenshot:revreplace', ['screenshot:rev'], function(){
return gulp.src([dirs.screenshots + '/rev-manifest.json', 'public/themes/index.html'])
.pipe($.revCollector({
replaceReved: true,
dirReplacements: {
'/themes/screenshots': '/dist/screenshots'
}
}))
.pipe(gulp.dest('public/themes'));
gulp.task('hexo', function(){

exec('hexo g');

});

gulp.task('screenshot', ['screenshot:rev', 'screenshot:resize', 'screenshot:revreplace']);
gulp.task('default', ['revreplace', 'screenshot']);
gulp.task('img', ['img:min']);
gulp.task('default', ['rev:replace', 'img']);
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"gulp-if": "^2.0.0",
"gulp-ignore": "^2.0.1",
"gulp-image-resize": "^0.7.1",
"gulp-imagemin": "^2.4.0",
"gulp-load-plugins": "^1.1.0",
"gulp-minify-css": "^1.2.1",
"gulp-minify-html": "^1.0.4",
Expand All @@ -38,7 +39,10 @@
"gulp-rev-collector": "^1.0.2",
"gulp-rev-replace": "^0.4.2",
"gulp-uglify": "^1.5.1",
"gulp-useref": "^3.0.0"
"gulp-useref": "^3.0.0",
"imagemin-pngquant": "^4.2.0",
"js-yaml": "^3.4.3",
"shelljs": "^0.5.3"
},
"optionalDependencies": {
"hexo-browsersync": "^0.1.0"
Expand Down
9 changes: 6 additions & 3 deletions scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ hexo.extend.helper.register('header_menu', function(className){
var isDefaultLang = lang === 'zh-cn';

_.each(menu, function(path, title){
if (!isDefaultLang && ~localizedPath.indexOf(title)) path = lang + path;
if (!isDefaultLang && ~localizedPath.indexOf(title)) path = lang + '/' + path;

result += '<li class="' + className + '-item">';
result += '<a href="' + self.url_for(path) + '" class="' + className + '-link">' + self.__('menu.' + title) + '</a>';
Expand All @@ -95,9 +95,12 @@ hexo.extend.helper.register('canonical_url', function(lang){

hexo.extend.helper.register('url_for_lang', function(path){
var lang = this.page.lang;
var url = this.url_for(path);
var isDefaultLang = lang === 'zh-cn';
var url = path;

if (!isDefaultLang && lang) url = lang + '/' + url;

if (lang !== 'zh-cn' && url[0] === '/') url = '/' + lang + url;
url = this.url_for(url);

return url;
});
Expand Down
4 changes: 2 additions & 2 deletions source/_data/menu.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
docs: /docs/
news: /news/
docs: docs/
news: news/
4 changes: 2 additions & 2 deletions source/_posts/2015-11-13-first-released.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
title: MAC全栈开发环境搭建指南 - 预览版
title: V1.0.0 Preview (预览版)
layout: post
---

`全栈MAC装机指南` 中文预览版发布。感谢各位开源贡献人员。
`MAC全栈开发环境搭建指南` 中文预览版发布。感谢各位开源贡献人员。

## 特性

Expand Down
15 changes: 15 additions & 0 deletions source/_posts/2015-11-15-beta-released.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
title: V1.0.0 Beta Released
layout: post
---

`MAC全栈开发环境搭建指南` 中英双语V1.0.0 Beta版本发布。感谢各位开源贡献人员。

## 特性

- 中文双语版本

英文为简版,6级刚刚及格抱歉了~
欢迎英文达人参与 `MAC全栈开发环境搭建指南` 的维护。

- 修复了配置站点根目录为网站子目录时切换语言404的bug。
- 去掉了retinajs的特性,现在srcset支持不错,没必要使用retinajs做响应式图片加载。
2 changes: 1 addition & 1 deletion source/docs/dev-common/vim.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ set autoread

看不清楚可以新窗口打开!

![Vim Cheatsheet](../img/vim.png)
![Vim Cheatsheet](../../img/vim.png)
2 changes: 1 addition & 1 deletion source/docs/dev-fd/sublime-text.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ SublimeText所有插件都依赖于`Package Control`,默认情况下`Package C

预览效果:

![material theme](../img/material-theme.png)
![material theme](../../img/material-theme.png)

## 推荐插件

Expand Down
2 changes: 1 addition & 1 deletion source/docs/dev-ios/crash-logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: 查看IOS应用崩溃时的日志

首先用iTunes的同步功能,将手机的各种信息同步至电脑:

![iTunes Sync](../img/crash-logs.jpg)
![iTunes Sync](../../img/crash-logs.jpg)

然后,崩溃日志可以在这里找到:

Expand Down
4 changes: 2 additions & 2 deletions source/en/docs/common.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ Your network DNS is located at `System Preferences > Network > Wi-Fi > Advanced

We recommend the default Mail Client distributed along with MAC OS.

### Office & Writing
### Office and Writing

1. [Office](http://soft.macx.cn/soft4350.htm)
2. [Evernote](https://www.evernote.com/)
3. [OneNote](https://onenote.com)
4. [Marxi.co](https://marxi.co/)

### Achive & Unachive
### Achive and Unachive

1. The Unachiver

Expand Down
2 changes: 1 addition & 1 deletion source/en/docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The document site was powered by [hexo](https://hexo.io), so install hexo locall
npm i -g hexo-cli
```

### How to contribute?
### How to contribute

1. Fork [o2team/mac].
2. Clone the forked repo and install the dependencies
Expand Down
2 changes: 1 addition & 1 deletion source/en/docs/dev-common/vim.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ sh ~/.vim_runtime/install_awesome_vimrc.sh

### Vim Cheatsheet

![Vim Cheatsheet](../../../docs/img/vim.png)
![Vim Cheatsheet](../../../img/vim.png)
2 changes: 1 addition & 1 deletion source/en/docs/dev-fd/sublime-text.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ We recommended the cool dark [Material Theme](https://github.com/equinusocio/mat

Preview:

![material theme](../img/material-theme.png)
![material theme](../../../img/material-theme.png)

## Recommened Plugins

Expand Down
2 changes: 1 addition & 1 deletion source/en/docs/dev-ios/crash-logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Crashing Logs

Firstly, backup the phone via iTunes

![iTunes Sync](../../../docs/img/crash-logs.jpg)
![iTunes Sync](../../../img/crash-logs.jpg)

Then,you can find the Crashing Logs at:

Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
2 changes: 2 additions & 0 deletions themes/navy/layout/layout.swig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html lang="{{ page.lang }}">
{{ partial('partial/head') }}
<body>
<div class="root">
<div id="container" class="container">
{{ partial('partial/header') }}
{{ body }}
Expand All @@ -10,5 +11,6 @@
<div id="mobile-nav-dimmer" class="mobile-nav-dimmer"></div>
{{ partial('partial/mobile_nav') }}
{{ partial('partial/after_footer') }}
</div>
</body>
</html>
Loading

0 comments on commit a0183d9

Please sign in to comment.