聊聊助我成长的团队

我想称赞一下我曾经处在一个很优秀的团队,无论从产品到设计到技术都有BAT出来的年轻活力。

跟我开会最多的产品经理

根据运营推广需求,产品经理作出新功能,新产品原型的计划,在里面我能学会到某个功能的不同展现方式和展现位置都是经过很长的经验累积的,会通过google统计记录所处点击量,不断做出调整。而且我们的产品经理具有前沿的敏锐性,在社区曾做出众测产品和秒杀活动的带来大流量的产品。而我主要是和产品经理谈论功能实现上的难易,最后会采用到teambition 项目管理工具进行排期。记得刚来公司技术部的每天都是晨会,通过便利贴实现to do list,后来也讨论了敏捷开发方式,最终使用teambition作为项目管理工具,都是一种成长。

追求细节和美感的设计师

设计师总有自己的独特的审美方式,经常尝试新的效果,我记得最深的是,最折腾我的还是追求字体和1px差距,经常会对我们说要做个有追求的前端。

一直伴随我成长的技术团队

我们技术团队每个星期都会开分享会或者code review,一直在成长。我分享过前端高性能和cdn缓存和前端安全方面的浅谈,这些应该是我比较擅长的。而且我们前端团队也会组织参加JSConf大会,更多的接触新知识。对于新技术,我们会提倡在后台尝试使用。
我们如果一个大项目结束,技术总监会开复盘大会,一般针对出现严重的问题进行指出和改善。

寄语

在前端的路上不断追寻新知识,希望自己能在一个新的环境拥抱未来。

Node.js+gulp.js构建前端自动化环境

本地环境下,静态网站的构建自动化

vim编辑器工作以来使用了两年多,早已熟悉每一个命令。工作之余,打算在本地制作一个线下网站环境。所以我想到了在本地构建关系,并通过gulp打包输出。

目录设计如下:
关系图

整个过程是:安装nodejs,全局安装gulp,项目安装gulp以及gulp插件,配置gulpfile.js,运行任务

全局安装gulp插件

$ npm install gulp -g

本地路径

创建模块,package.json 文件是必不可少的。我们可以使用 NPM 生成 package.json 文件,生成的文件包含了基本的结果.

$ npm init

本地安装gulp插件

$ npm install gulp gulp-less gulp-uglify imagemin-pngcrush
 gulp-imagemin gulp-html-extend —save-dev     //对less的输出,js的压缩,图片压缩,html的处理

全局安装gulp是为了执行gulp任务,本地安装gulp则是为了调用gulp插件功能

$ vim gulp.js

修改gulp.js文件

var gulp = require('gulp'),
less = require('gulp-less'),
uglify = require('gulp-uglify'),              
imagemin = require('gulp-imagemin'),//图片压缩
pngcrush = require('imagemin-pngcrush'),
htmlHelper = require('gulp-html-extend');    //主要处理公用部分layout

var dir = '../event/';   //定义目录


gulp.task('testLess', function() {
    gulp.src(dir+'web/*/*/*.less')
    .pipe(less())
    .pipe(gulp.dest(dir+'output'));
    console.log('done css');
})

gulp.task('minify-js', function() {
    gulp.src(dir+'web/*/*/*.js')
  //.pipe(uglify())   //开发环境下不压缩js
    .pipe(gulp.dest(dir+'output'));
})

gulp.task('img', function() {
      return gulp.src(dir+'web/*/images/*')
    .pipe(imagemin({
    progressive: true,
    svgoPlugins: [{removeViewBox: false}],
      use: [pngcrush()]
    }))
 .pipe(gulp.dest(dir+'output'));
});

gulp.task('testHtml', function() {
    gulp.src(dir+'web/*/*.html').pipe(htmlHelper({
    annotations:false,verbose:false
    })).pipe(gulp.dest(dir+'output'))
})


gulp.task('default', function() {
     gulp.run('testLess','minify-js','testHtml','img');
     gulp.watch(dir+'web/*/*/*.less',['testLess'])
     gulp.watch(dir+'web/*/*/*.js',['minify-js'])
     gulp.watch(dir+'web/*/*.html',['testHtml'])
     gulp.watch(dir+'web/*/images/*',['img'])
})

使用gulp命令运行打包程序

$ gulp

layout.html 使用了bootstrap框架

layout

页面引用(注意使用output路径,按需引入资源)

源码查看

通过hexo建立blog,并发布在github

注册github

创建仓库
settings -> Repositories

输入名称 EugeniaWu.github.io //注意格式,要与github用户相同

本地本地新建项目路径

1
$ mkdir myGitHub

按照命令初始化,

1
2
3
4
5
6
$ echo "# eugeniawu.github.io" >> README.md
$ git init
$ git add README.md
$ git commit -m "first commit"
$ git remote add origin git@github.com:EugeniaWu/eugeniawu.github.io.git
$ git push -u origin master

提示

Permanently added the RSA host key for IP address ‘192.30.253.112’ to the list of known hosts.
Permission denied (publickey).

1
$ sudo ssh-keygen -t rsa -C "xxx@xxx.com" //注册github邮箱

Enter passphrase (empty for no passphrase): //输入密码

Enter same passphrase again: //输入密码

1
$ pbcopy < ~/.ssh/id_rsa.pub //通过命令复制生成的ssh key

通过settings -> SSH and GPG keys

new SSH key

粘贴ssh key

再次提交

1
$ git push origin master

浏览器输入https://eugeniawu.github.io/ 即可打开web

使用hexo创建blog

Hexo 是一个简单地、轻量地、基于Node的一个静态博客框架,可以方便的生成静态网页托管在github和Heroku上.

在myGithub目录下,执行命令安装Hexo

1
$ sudo npm install -g hexo

初始化hexo

1
$ hexo init

1
2
3
$ hexo generate #生成静态页面至public目录
$ hexo server #开启预览访问端口(默认端口4000,'ctrl + c'关闭server)

配置发布github

1
$ vim _config.yml

//修改配置文件需要重新执行命令查看,下面是简写形式

1
hexo clean && hexo g && hexo s

增加评论功能

将最底部的deploy配置修改:

1
2
3
4
5
deploy:
type: git
#repo: https://github.com/EugeniaWu/eugeniawu.github.io.git
repo: https://[github账户名]:[密码]@github.com/EugeniaWu/eugeniawu.github.io.git
branch: master

然后执行命令

1
$ npm install hexo-deployer-git --save

通过命令,将静态网页提交到github

1
2
3
$ hexo clean
$ hexo generate
$ hexo deploy #部署到GitHub

浏览器输入https://eugeniawu.github.io/ 即可打开web

一些常用命令:

1
2
$ hexo new "postName" #新建文章
$ hexo new page "pageName" #新建页面

文章内容采用markdown格式。

注意:
[remote rejected] HEAD -> master (cannot lock ref ‘refs/heads/master’

解决
fetch 改变的是 remotes 里面相应分支的 commit id。
git fetch 并没更改本地仓库的代码,git pull会更改,拉下来并merge

1
$ git fetch

//使用duoshuo做评论
 注册多说帐号 http://duoshuo.com/

主题是landscape

1
$ vim themes/landscape/layout/_partial/article.ejs

找到下面代码

1
2
3
4
5
6
7
<% if (!index && post.comments && config.disqus_shortname){ %>
<section id="comments">
<div id="disqus_thread">
<noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
</section>
<% } %>

替换成

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<% if (!index && post.comments && config.duoshuo_shortname){ %>
<section id="comments">
<!-- 多说评论框 start -->
<div class="ds-thread" data-thread-key="<%= post.layout %>-<%= post.slug %>" data-title="<%= post.title %>" data-url="<%= page.permalink %>"></div>
<!-- 多说评论框 end -->
<!-- 多说公共JS代码 start (一个网页只需插入一次) -->
<script type="text/javascript">
var duoshuoQuery = {short_name:'<%= config.duoshuo_shortname %>'};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<!-- 多说公共JS代码 end -->
</section>
<% } %>

到根目录myGithub

1
$ vim _config.yml

在文件底部新增

duoshuo_shortname: eugeniawu //刚刚注册duoshuo的域名

注意
Port 4000 has been used. Try other port instead.

1
2
$ lsof -i:4000
$ kill -9 [PID] //PID填入值