mkblog 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +13 -0
- data/README.rdoc +38 -0
- data/bin/mkblog +90 -0
- data/lib/mkblog_version.rb +3 -0
- data/templates/README.markdown +24 -0
- data/templates/Rakefile +46 -0
- data/templates/_config.yml +2 -0
- data/templates/_layouts/master.html +50 -0
- data/templates/_layouts/post.html +39 -0
- data/templates/_posts/2012-03-06-travis-ci-is-evolution.mkd +111 -0
- data/templates/_site/README.markdown +24 -0
- data/templates/_site/Rakefile +46 -0
- data/templates/_site/about.html +55 -0
- data/templates/_site/atom.xml +936 -0
- data/templates/_site/blog.html +581 -0
- data/templates/_site/drafts/outsource-your-blog.html +96 -0
- data/templates/_site/favicon.ico +0 -0
- data/templates/_site/images/about.gif +0 -0
- data/templates/_site/images/alm-overview.jpg +0 -0
- data/templates/_site/images/blog.gif +0 -0
- data/templates/_site/images/build-matrix.png +0 -0
- data/templates/_site/images/building-status-tag.png +0 -0
- data/templates/_site/images/gerrit-demo.jpg +0 -0
- data/templates/_site/images/github.gif +0 -0
- data/templates/_site/images/green_gradient.gif +0 -0
- data/templates/_site/images/header_bg.gif +0 -0
- data/templates/_site/images/header_gradient.gif +0 -0
- data/templates/_site/images/jenkins-jobs.jpg +0 -0
- data/templates/_site/images/jenkins-logo.jpg +0 -0
- data/templates/_site/images/linkedin.gif +0 -0
- data/templates/_site/images/subscribe-icon.gif +0 -0
- data/templates/_site/images/subscribe.png +0 -0
- data/templates/_site/images/title.gif +0 -0
- data/templates/_site/images/twitter.gif +0 -0
- data/templates/_site/images/weibo.gif +0 -0
- data/templates/_site/images/whiteboard.jpg +0 -0
- data/templates/_site/index.html +471 -0
- data/templates/_site/javascripts/jquery.github.js +3 -0
- data/templates/_site/javascripts/jquery.js +19 -0
- data/templates/_site/open-source.html +78 -0
- data/templates/_site/stylesheets/master.css +296 -0
- data/templates/_site/stylesheets/syntax.css +60 -0
- data/templates/about.textile +16 -0
- data/templates/atom.xml +27 -0
- data/templates/blog.html +29 -0
- data/templates/drafts/outsource-your-blog.textile +32 -0
- data/templates/favicon.ico +0 -0
- data/templates/images/about.gif +0 -0
- data/templates/images/blog.gif +0 -0
- data/templates/images/build-matrix.png +0 -0
- data/templates/images/building-status-tag.png +0 -0
- data/templates/images/github.gif +0 -0
- data/templates/images/green_gradient.gif +0 -0
- data/templates/images/header_bg.gif +0 -0
- data/templates/images/header_gradient.gif +0 -0
- data/templates/images/jenkins-jobs.jpg +0 -0
- data/templates/images/linkedin.gif +0 -0
- data/templates/images/subscribe-icon.gif +0 -0
- data/templates/images/subscribe.png +0 -0
- data/templates/images/title.gif +0 -0
- data/templates/images/twitter.gif +0 -0
- data/templates/images/weibo.gif +0 -0
- data/templates/index.html +62 -0
- data/templates/javascripts/jquery.github.js +3 -0
- data/templates/javascripts/jquery.js +19 -0
- data/templates/open-source.html +33 -0
- data/templates/stylesheets/master.css +296 -0
- data/templates/stylesheets/syntax.css +60 -0
- metadata +125 -0
@@ -0,0 +1,581 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
3
|
+
|
4
|
+
<html>
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
7
|
+
<title>Larry Cai - Blog</title>
|
8
|
+
<link rel="stylesheet" href="/stylesheets/master.css" type="text/css" media="screen" charset="utf-8"/>
|
9
|
+
<link rel="stylesheet" href="/stylesheets/syntax.css" type="text/css" media="screen" charset="utf-8"/>
|
10
|
+
<script src="/javascripts/jquery.js" type="text/javascript" charset="utf-8"></script>
|
11
|
+
<script src="/javascripts/jquery.github.js" type="text/javascript" charset="utf-8"></script>
|
12
|
+
<link rel='alternate' type='application/rss+xml' href='http://feeds2.feedburner.com/larrycai' />
|
13
|
+
</head>
|
14
|
+
<body>
|
15
|
+
<div id='wrapper'>
|
16
|
+
<div id='header'>
|
17
|
+
<h1><a href='/'>Larry Cai</a></h1>
|
18
|
+
|
19
|
+
<div id='menu'>
|
20
|
+
<ul>
|
21
|
+
<li><a href='/blog.html' id='blog_link' title='Blog'>Blog</a></li>
|
22
|
+
<li><a href='/about.html' id='about_link' title='About'>About</a></li>
|
23
|
+
<li><a href='http://github.com/larrycai' target='_blank' title='GitHub' rel='me' id='github_link'>GitHub</a></li>
|
24
|
+
<li><a href='http://cn.linkedin.com/in/larrycaiyu' title='LinkedIn' target='_blank' rel='me' id='linkedin_link'>LinkedIn</a></li>
|
25
|
+
<li><a href='http://weibo.com/larrycaiyu' title='Weibo' target='_blank' rel='me' id='weibo_link'>Weibo</a></li>
|
26
|
+
</ul>
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
<div id='content'>
|
30
|
+
<a href='http://feeds.feedburner.com/~u/14174549791849888941' class='float-right'><img src='/images/subscribe.png' alt='Subscribe to XML Feed'/></a>
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
<div class='post'>
|
35
|
+
<span class='date'>06 Mar 2012</span>
|
36
|
+
<h1><a href='/2012/03/06/travis-ci-is-evolution.html'>Travis CI会替代Jenkins吗?</a></h1>
|
37
|
+
<div class='body'><h1>介绍</h1>
|
38
|
+
|
39
|
+
<p>你可能用Github了。但是你是怎么自动构建你的开源项目的呢?你的Github项目有“构建状态”标签吗?</p>
|
40
|
+
|
41
|
+
<p><img src="http://larrycai.github.com/images/building-status-tag.png" alt="Github上的项目构建状态" /></p>
|
42
|
+
|
43
|
+
<p>如果你还不知道这个,你就有些落伍了,因为这是Travis CI带来的持续集成的革新,它可能会替代Jenkins现在的地位。</p>
|
44
|
+
|
45
|
+
<p>让我们一起来看看Travis-ci到底带来了什么,先从Jenkins说起。</p>
|
46
|
+
|
47
|
+
<p>在写这篇博客时,发现好友晓斌也写了一篇<a href="http://www.juvenxu.com/2012/03/06/travis-ci/">Travis CI,翩翩而至的CI云</a>,可以参考阅读。</p>
|
48
|
+
|
49
|
+
<h2>Jenkins介绍</h2>
|
50
|
+
|
51
|
+
<p>持续集成是敏捷软件开发的一个重要工具,开源工具<a href="http://jenkins-ci.org/">Jenkins</a>是实施持续集成首选,大概占据了半壁江山。</p>
|
52
|
+
|
53
|
+
<p><img src="http://larrycai.github.com//images/jenkins-jobs.jpg" alt="Jenkins界面" /></p>
|
54
|
+
|
55
|
+
<p>Jenkins以前叫Hudson,后来由于Oracle收购了Sun公司,Oracle与开源软件社区谈崩了。Hudson创始人Kohsuke Kawaguchi(简称 KK)一怒之下,和社区的人其他人重起炉灶,建立了Jenkins社区。详细可以看看InfoQ的文章<a href="http://www.infoq.com/cn/news/2011/01/hudson-jenkins2">Hudson社区提议将项目更名为Jenkins</a>。</p>
|
56
|
+
|
57
|
+
<h3>Jenkins功能</h3>
|
58
|
+
|
59
|
+
<p>它有很多极佳的特性:</p>
|
60
|
+
|
61
|
+
<ol>
|
62
|
+
<li>易于安装:一个命令就可启动,也方便部署到各种Web容器中(如tomcat)。</li>
|
63
|
+
<li>易于配置:所有的配置都在Web界面实现,权限控制得也不错。</li>
|
64
|
+
<li>插件支持:基本上所有的扩展都是有插件完成的,开发插件也很方便,由此产生了庞大的社区。</li>
|
65
|
+
<li>支持分布式构建:Jenkins能够让通过主从模式(master/slave)多台机器一起构建。</li>
|
66
|
+
</ol>
|
67
|
+
|
68
|
+
|
69
|
+
<h3>Jenkins在企业中常见步骤</h3>
|
70
|
+
|
71
|
+
<p>Jenkins服务器一般先架设在一台服务器上,有配置管理人员管理。</p>
|
72
|
+
|
73
|
+
<p>产品有构建需求后,配置管理人员就新建一个任务,配好源码仓库,设置构建时间,指定运行脚本来编译测试产品,并且设置报告输出。一切都可以在Web界面中运行。</p>
|
74
|
+
|
75
|
+
<h2>Jenkins的一些弊端</h2>
|
76
|
+
|
77
|
+
<p>Jenkins虽然非常好用,但还是有些弊端。</p>
|
78
|
+
|
79
|
+
<h3>多平台或依赖的包</h3>
|
80
|
+
|
81
|
+
<p>如果你的软件想在不同的操作系统软件构建并验证,这将是相当有难度和技巧性,一般主要是准备不同的操作系统的机器,然后使用主/从模式进行分布式构建。</p>
|
82
|
+
|
83
|
+
<p>在C++中你可以使用有关的交叉编译器,一个不错的解决方案。</p>
|
84
|
+
|
85
|
+
<p>但是再进一步如果你的第三方软件和不同的依赖比较多,那么这个环境的准备是非常困难的,因为这个组合将很大。</p>
|
86
|
+
|
87
|
+
<p>当然你可有使用虚拟机的技术vagrant/virtualbox,参见<a href="http://larrycai.github.com/2011/10/25/vagrant-jenkins-ci.html">使用vagrant+jenkins来管理虚拟机的技巧</a>。可以工作,不太优雅。因为它不是原生的,有点复杂。</p>
|
88
|
+
|
89
|
+
<h3>配置管理人员的工作</h3>
|
90
|
+
|
91
|
+
<p>一般来说Jenkins的构建任务,它是集中控制的。大多来说都是有专职的配置管理人员来管理,否者权限会混乱。</p>
|
92
|
+
|
93
|
+
<p>当有需求时,他们负责在CI服务器创建任务(记住:这些配置文件不是有版本控制的)。这个就涉及到了沟通成本,你有变化需求,很难及时满足。</p>
|
94
|
+
|
95
|
+
<p>由于服务器是有限的,它主要构建重要分支的内容。在你自己的私有分支上运行CI是比较奢侈的,而且环境不一样,也不推荐。</p>
|
96
|
+
|
97
|
+
<p>你可以想象如果在一个C/C++产品的公司,你要为一个Lisp的项目创建CI要花多久?</p>
|
98
|
+
|
99
|
+
<p>作为开发者,为什么不能随时构建你想要的东西呢?这就是Travis CI想做的。</p>
|
100
|
+
|
101
|
+
<h2>Travis CI 介绍</h2>
|
102
|
+
|
103
|
+
<p>Travis CI 这里就不介绍怎么使用了具体可以先看<a href="http://www.juvenxu.com/2012/03/06/travis-ci/">晓斌的博客</a>和<a href="http://saberma.me/other/2011/11/29/travis-ci-is-a-free-continuous-integration-test-server.html">免费的持续集成测试服务</a>,强烈建议你先试一下。</p>
|
104
|
+
|
105
|
+
<p>初看Travis CI象和Jenkins没啥区别,指定你Github中的项目,然后他帮你编译,而且它使用的也是Vagrant/Virtualbox技术。但实际上里面有很多好点子。</p>
|
106
|
+
|
107
|
+
<h2>Travis CI带来的变革</h2>
|
108
|
+
|
109
|
+
<h3>配置本地化和可读性</h3>
|
110
|
+
|
111
|
+
<p>不像以前,构建的任务是在Jenkins服务器上的,现在构建的配置文件直接就和源码放在一起,而且配置文件使用DSL写的,可读性更高。</p>
|
112
|
+
|
113
|
+
<pre><code>before_script:
|
114
|
+
- sudo apt-get install pandoc
|
115
|
+
- sudo apt-get install ttf-arphic-gbsn00lp ttf-arphic-ukai ttf-wqy-microhei ttf-wqy-zenhei
|
116
|
+
- sudo apt-get install texlive-xetex texlive-latex-recommended texlive-latex-extra
|
117
|
+
- gem install mkbok
|
118
|
+
|
119
|
+
rvm:
|
120
|
+
- 1.9.3
|
121
|
+
- 1.8.7
|
122
|
+
script: mkbok --lang zh --build pdf
|
123
|
+
|
124
|
+
after_script:
|
125
|
+
- which curl ; curl -v --upload-file sdcamp.zh.pdf http://blobs.ge.tt/3iBcNNC/sdcamp.zh.pdf?sig=-TY5O1GAx8xHwWiCqd8aySlQiroFAnHK2o4
|
126
|
+
</code></pre>
|
127
|
+
|
128
|
+
<p>作为用户,关心的是要哪些依赖包,然后怎么构建就行了,上面的配置每一行都没有浪费。</p>
|
129
|
+
|
130
|
+
<h3>多版本支持</h3>
|
131
|
+
|
132
|
+
<p>像上面的例子中,我要求在两个Ruby环境中运行,它就帮我做到了,我并不关心它是怎么切换的。</p>
|
133
|
+
|
134
|
+
<p><img src="http://larrycai.github.com/images/build-matrix.png" alt="多版本构建结果" /></p>
|
135
|
+
|
136
|
+
<h3>原生的云技术来分布式构建</h3>
|
137
|
+
|
138
|
+
<p>Travis CI使用的Ruby语言,一开始考虑的就是分布式构建,比Jenkins的插件式进了一步。</p>
|
139
|
+
|
140
|
+
<p>虽然Travis CI并不是直接用到了云机器,它的虚拟机部分只是Vagrant/Virtualbox,但是这一块是很容易迁移到其他的技术的。</p>
|
141
|
+
|
142
|
+
<h1>总结</h1>
|
143
|
+
|
144
|
+
<p>Jenkins有点可惜,改了名字以后,功能上面并没有突破。当然这就是开源竞争的好处,总有新的理念,新的工具产生。你不前进,别人就迎头赶上。</p>
|
145
|
+
|
146
|
+
<p>Travis CI现在只是支持Github的公开项目,但已经爆发出它的优点了。要不了多久,我相信就能运行在你公司内部了。</p>
|
147
|
+
|
148
|
+
<p>让我们一起期待这个革新吧!</p>
|
149
|
+
|
150
|
+
<h1>相关阅读</h1>
|
151
|
+
|
152
|
+
<ol>
|
153
|
+
<li>Juven Xu的“Travis CI,翩翩而至的CI云” <a href="http://www.juvenxu.com/2012/03/06/travis-ci/">http://www.juvenxu.com/2012/03/06/travis-ci/</a></li>
|
154
|
+
<li>免费的持续集成测试服务 <a href="http://saberma.me/other/2011/11/29/travis-ci-is-a-free-continuous-integration-test-server.html">http://saberma.me/other/2011/11/29/travis-ci-is-a-free-continuous-integration-test-server.html</a></li>
|
155
|
+
</ol>
|
156
|
+
|
157
|
+
</div>
|
158
|
+
<a href='/2012/03/06/travis-ci-is-evolution.html#disqus_thread'>View Comments</a>
|
159
|
+
</div>
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
<div class='post'>
|
164
|
+
<span class='date'>13 Jan 2012</span>
|
165
|
+
<h1><a href='/2012/01/13/ebook-chinese-fonts.html'>开源书和开源技术-PDF中蛋疼的中文字体</a></h1>
|
166
|
+
<div class='body'><h1>介绍</h1>
|
167
|
+
|
168
|
+
<p>上次我介绍了一个用<a href="http://www.ituring.com.cn/article/828">Markdown格式来写开源书和相关的开源技术</a>,还留了个在Linux下产生PDF所需要的中文字体这个大尾巴。这次我想借用我写<a href="http://weibo.com/2104936813/y0oXC350t">【跟我学企业敏捷开发】</a>的一点经验,给不太了解这一块知识的朋友一起探讨一下。</p>
|
169
|
+
|
170
|
+
<p>有些问题还是没有解决,希望有Latex的高手解答。</p>
|
171
|
+
|
172
|
+
<p>不管怎样,还是希望能借此机会推动国内电子书,特别是开源电子书的发展。</p>
|
173
|
+
|
174
|
+
<h1>Linux下的中文编码和字体</h1>
|
175
|
+
|
176
|
+
<p>首先,我用的是Linux环境并且选用的是<strong>UTF-8</strong>的编码,而不是GBK,否者在github上显示会有问题,不了解这方面的朋友自己找找资料吧,够讲个把小时的。</p>
|
177
|
+
|
178
|
+
<p>在产生PDF时,一般建议内嵌中文字体的,但是真正能用的中文字体实际很少,极大多数是有版权的:</p>
|
179
|
+
|
180
|
+
<ul>
|
181
|
+
<li><a href="http://www.arphic.com.tw/">文鼎</a>开放的四套字体(简报宋、细上海宋、简中楷、中楷),没有一点版权问题,是大部分的中文Linux的缺省安装。</li>
|
182
|
+
<li><a href="http://wenq.org/">文泉驿</a>的几套字体(微米黑、正黑、点阵宋体)是开放但是GPL性质的,所以不是随便可以商用的。</li>
|
183
|
+
<li>Adobe有两套开放字体(宋体、黑体)我认为是可以随便用的,忘了在哪里看到这个解释的了。</li>
|
184
|
+
</ul>
|
185
|
+
|
186
|
+
|
187
|
+
<p>可以看看<a href="http://wiki.ubuntu.org.cn/�%8D费中文字体">Ubuntu免费中文字体</a>的介绍有个认识。</p>
|
188
|
+
|
189
|
+
<h2>怎么选择对应字体</h2>
|
190
|
+
|
191
|
+
<p>一般缺省中文正文字体是宋体、细明体,对应英文Serif类的英文字体:Georgia、Times New Roman等。</p>
|
192
|
+
|
193
|
+
<p>标题和重要内容可以选楷体和黑体,对应英文Sans Serif类的英文字体:Arial、Tahoma、Verdana等</p>
|
194
|
+
|
195
|
+
<p>技术文章中常见的代码典型的等宽体用黑体,对应英文Monospace类的英文字体:Courier New等</p>
|
196
|
+
|
197
|
+
<p>所以对应的在<a href="https://github.com/larrycai/sdcamp/blob/master/latex/config.yml">我的中文Latex配置</a>中可选的是:</p>
|
198
|
+
|
199
|
+
<ul>
|
200
|
+
<li>font:文鼎的简报宋、细上海宋,文泉驿的点阵宋体,Adobe的宋体</li>
|
201
|
+
<li>bold: 文鼎的简中楷、中楷,文泉驿的微米黑、正黑,Adobe的黑体</li>
|
202
|
+
<li>mono: 文泉驿的微米黑、正黑,Adobe的黑体</li>
|
203
|
+
</ul>
|
204
|
+
|
205
|
+
|
206
|
+
<h2>如何安装字体</h2>
|
207
|
+
|
208
|
+
<p>我用的试验环境是Ubuntu 11.04 (Natty),大部分可以直接从Ubuntu源中下载了。</p>
|
209
|
+
|
210
|
+
<p>你可以用命令<code>fc-list :lang=zh-cn</code>查看安装好的中文字体,结果中前半部分就是字体名称(如<code>AR PL UMing CN</code>)。</p>
|
211
|
+
|
212
|
+
<pre><code>user@puppet1:~$ fc-list :lang=zh-cn | grep CN
|
213
|
+
AR PL UMing CN:style=Light
|
214
|
+
AR PL UKai CN:style=Book
|
215
|
+
</code></pre>
|
216
|
+
|
217
|
+
<p>文鼎开放的四套字体的Ubuntu包、字体名字和名称如下:</p>
|
218
|
+
|
219
|
+
<pre><code>ttf-arphic-gbsn00lp "AR PL SungtiL GB" 文鼎PL简报宋
|
220
|
+
ttf-arphic-gkai00mp "AR PL KaitiM GB" 文鼎PL简中楷
|
221
|
+
ttf-arphic-ukai "AR PL UKai" 文鼎PL中楷
|
222
|
+
ttf-arphic-uming "AR PL UMing" 文鼎PL细上海宋
|
223
|
+
</code></pre>
|
224
|
+
|
225
|
+
<p>文泉驿字体的Ubuntu包、字体名字和名称如下</p>
|
226
|
+
|
227
|
+
<pre><code>ttf-wqy-microhei "WenQuanYi Micro Hei" 文泉驿的微米黑
|
228
|
+
ttf-wqy-zenhei "WenQuanYi Zen Hei" 文泉驿的正黑
|
229
|
+
xfonts-wqy "WenQuanYi Bitmap Song" 文泉驿的点阵宋体
|
230
|
+
</code></pre>
|
231
|
+
|
232
|
+
<p>Adobe的中文字体有<a href="http://www.adobe.com/support/downloads/detail.jsp?ftpID=4421">官方下载</a></p>
|
233
|
+
|
234
|
+
<pre><code>$ tar -jzxf FontPack910_chs_i486-linux.tar.bz2
|
235
|
+
$ tar -xvf CHSKIT/LANGCHS.TAR
|
236
|
+
$ mkdir ~/.fonts
|
237
|
+
$ cp Adobe/Reader9/Resource/CIDFont/*.otf ~/.fonts
|
238
|
+
$ fc-cache -f -v
|
239
|
+
$ fc-list :lang=zh | grep Adobe
|
240
|
+
</code></pre>
|
241
|
+
|
242
|
+
<h2>蛋疼的问题</h2>
|
243
|
+
|
244
|
+
<p>只可惜现在正文在产生PDF时没有一种字体是有完美表现的。</p>
|
245
|
+
|
246
|
+
<ol>
|
247
|
+
<li>文鼎贡献的字体中台湾字形的细上海宋的句号在中间,出来的效果不伦不类的。</li>
|
248
|
+
<li>文鼎贡献的字体中大陆字形的简中楷和简报宋,标点符号的位置是对的,但是当碰到条目(Item)的时候条目的点没能显示出来。</li>
|
249
|
+
<li>Adobe的宋体,条目的时候显示一个田子框,很难看。</li>
|
250
|
+
<li>文泉驿的点阵宋体老是转化Latex时出错,搞不定。</li>
|
251
|
+
</ol>
|
252
|
+
|
253
|
+
|
254
|
+
<p>现在将就着用文鼎的细上海宋。</p>
|
255
|
+
|
256
|
+
<p>【更新】
|
257
|
+
2、3 条目的问题,我hack成其他字符(*)显示就没问题了(如下),不知道缺省的圆点显示不对。<a href="http://wiki.ctex.org/index.php/LaTeX/%E5%88%97%E8%A1%A8">http://wiki.ctex.org/index.php/LaTeX/%E5%88%97%E8%A1%A8</a>,现在就用文鼎的细上海宋了。</p>
|
258
|
+
|
259
|
+
<pre><code>\begin{itemize}\setlength{\itemsep}{1pt}\setlength{\parskip}{0pt}\setlength{\parsep}{0pt}
|
260
|
+
\item[*]
|
261
|
+
% 原来是
|
262
|
+
% \item
|
263
|
+
</code></pre>
|
264
|
+
|
265
|
+
<h1>其他</h1>
|
266
|
+
|
267
|
+
<p>本文也是我用git记录在<a href="https://github.com/larrycai/larrycai.github.com">github</a>上的,你可以看到每次的变化。</p>
|
268
|
+
|
269
|
+
<p>如果对此文有兴趣,帮忙顶一下,别忘了 <a href="http://weibo.com/larrycaiyu">@larrycaiyu</a>。</p>
|
270
|
+
|
271
|
+
<h1>参考</h1>
|
272
|
+
|
273
|
+
<ol>
|
274
|
+
<li>中文字体没有版权问题的解决方案?http://bbs.ctex.org/viewthread.php?tid=46106&extra=&page=1</li>
|
275
|
+
</ol>
|
276
|
+
|
277
|
+
</div>
|
278
|
+
<a href='/2012/01/13/ebook-chinese-fonts.html#disqus_thread'>View Comments</a>
|
279
|
+
</div>
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
<div class='post'>
|
284
|
+
<span class='date'>31 Dec 2011</span>
|
285
|
+
<h1><a href='/2011/12/31/ebook-by-markdown.html'>开源书和开源技术-Markdown篇</a></h1>
|
286
|
+
<div class='body'><h1>开源书和开源技术-Markdown篇</h1>
|
287
|
+
|
288
|
+
<h1>背景</h1>
|
289
|
+
|
290
|
+
<p>看到<a href="http://weibo.com/1404949082/xDeyDEaDq">霍泰稳关于infoq的架构师电子书问题的微博</a>和图灵社区的文章<a href="http://www.ituring.com.cn/article/details/764">为什么写作自由书籍?</a>,我就想通过一个用Markdown格式写的<a href="http://progit.org/">Pro Git</a>开源书 的例子来介绍其中用到的技术。希望能借此机会推动国内电子书,特别是开源电子书的发展。</p>
|
291
|
+
|
292
|
+
<p>【声明】我并没有写书的经历,这里只是对电子书出版技术的入门介绍而已。</p>
|
293
|
+
|
294
|
+
<h1>从Pro Git说起</h1>
|
295
|
+
|
296
|
+
<p>如果你了解Git,或者想了解Git。那么你就应该知道<a href="http://progit.org/">Pro Git</a>,它是Git的书中写得最好的一本(至少是之一),可是你是否知道它有网络中文版,而且能在iPad上极其漂亮得阅读。并且是免费的,不是盗版的免费!如果你想要最新的,你甚至可以自己生成它。哈哈,我就是这么干的。</p>
|
297
|
+
|
298
|
+
<p>这一切就归功于开源社区和它后面用到的技术。</p>
|
299
|
+
|
300
|
+
<h1>开源书</h1>
|
301
|
+
|
302
|
+
<p>这里我不用多讲,开源书就像其他的开源产品(如维基百科)一样,只要是开放的,社区就有人会贡献。<a href="http://progit.org/">Pro Git</a>的作者Scott很慷慨得把书的内容全部共享在<a href="http://github.com/progit/progit">github/progit</a>库中,使用得是<a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">CC BY-NC-SA 3.0</a>。</p>
|
303
|
+
|
304
|
+
<p>Scott只负责英文版,其他许许多多语言的翻译都是社区贡献的,中国翻译相当有质量,你可以在线读<a href="http://progit.org/book/zh/">Pro Git中文版</a>。</p>
|
305
|
+
|
306
|
+
<h1>开源技术生成电子书</h1>
|
307
|
+
|
308
|
+
<p>这本书不仅仅开源了内容,使用的技术也是开源的。让我们看看他是怎么做的。</p>
|
309
|
+
|
310
|
+
<h2>markdown原始文件</h2>
|
311
|
+
|
312
|
+
<p>首先书的内容是用markdown格式写的。markdown格式的普及要归功于<a href="github.com">Github</a>和<a href="http://stackoverflow.com/">StackOverflow</a>。因为它们越来越流行,它们支持markdown格式也越来越流行。这里要赞一个的是,国内的<a href="http://www.ituring.com.cn/">图灵社区</a>也支持markdown,用起来超级方便。</p>
|
313
|
+
|
314
|
+
<p>简单来说,markdown格式的文件看着像一般的文本文件,里面只是加了很少的格式标记,因此看文本文件也不影响理解,这种格式也有很多工具帮你去转化,而且很容自动化解决。并且这些技术大多数是开源或免费的。</p>
|
315
|
+
|
316
|
+
<p>你可以直接看一下【Pro Git】的<a href="https://raw.github.com/progit/progit/master/zh/01-introduction/01-chapter1.markdown">“第一章 介绍” 的markdown原始文件</a>,顺便看看github自动生成的简单<a href="https://github.com/progit/progit/blob/master/zh/01-introduction/01-chapter1.markdown">“第一章 介绍” 的html</a>。</p>
|
317
|
+
|
318
|
+
<h2>产生电子书</h2>
|
319
|
+
|
320
|
+
<h3>epub/mobi格式</h3>
|
321
|
+
|
322
|
+
<p>Ruby的<a href="https://github.com/rtomayko/rdiscount">rdiscount</a>帮你从markdown转成html格式,然后有<a href="calibre">Calibre</a>附带的命令<code>ebook-convert</code>生成最终的<code>.mobi</code> (Kindle) 和 <code>.epub</code> (iPad)。</p>
|
323
|
+
|
324
|
+
<h3>PDF格式</h3>
|
325
|
+
|
326
|
+
<p>为了能达到出版的质量,Latex是一个常用的格式,PDF也能很容易的产生出来,有关Latex,自己看看参考链接学习吧。</p>
|
327
|
+
|
328
|
+
<p><a href="http://johnmacfarlane.net/pandoc/">pandoc</a>能帮着从markdown转换出latex格式,然后<a href="http://www.tug.org/texlive/">TexLive</a>软件中的<code>xelatex</code>再转成PDF格式。</p>
|
329
|
+
|
330
|
+
<h2>试验环境</h2>
|
331
|
+
|
332
|
+
<p>你只需要一台Linux机器(虚拟机就可以了)和简单的Linux命令就可以试验了。有git和ruby的知识那就更方便了。</p>
|
333
|
+
|
334
|
+
<p>我用的试验环境是Ubuntu 11.04 (Natty)</p>
|
335
|
+
|
336
|
+
<h3>下载Pro Git开源书</h3>
|
337
|
+
|
338
|
+
<p>很简单,<code>git clone</code>一下就可以了,下载它的源文件包我觉得还是烦了点。</p>
|
339
|
+
|
340
|
+
<pre><code>$ git clone https://github.com/progit/progit.git
|
341
|
+
</code></pre>
|
342
|
+
|
343
|
+
<h3>epub/mobi格式</h3>
|
344
|
+
|
345
|
+
<p>做电子书相对简单一点,因为要求没有PDF的高,<a href="http://calibre-ebook.com/">calibre</a>就可以满足了。</p>
|
346
|
+
|
347
|
+
<p>如果装的Ubuntu是服务器版的(没有X-Windows),建议安装<a href="http://en.wikipedia.org/wiki/Xvfb">xvfb</a>无头(headless)X服务器,因为不知道什么原因有几个命令需要。XMing还不行,因为需要<code>X-Input</code></p>
|
348
|
+
|
349
|
+
<pre><code>$ sudo apt-get install ruby rubygems # ruby 1.8.7 is used
|
350
|
+
$ sudo apt-get install calibre # calibre 0.7.44 for ubuntu 11.04
|
351
|
+
$ gem install rdiscount ruby-debug
|
352
|
+
$ xvfb-run ./makeebooks zh # 缺省.mobi格式
|
353
|
+
$ export FORMAT=epub
|
354
|
+
$ xvfb-run ./makeebooks zh # .epub格式
|
355
|
+
</code></pre>
|
356
|
+
|
357
|
+
<h3>PDF格式</h3>
|
358
|
+
|
359
|
+
<p>生成PDF是一个比较复杂的东西,<a href="http://johnmacfarlane.net/pandoc/">pandoc</a>用Ubuntu库里的,TexLive建议下载最新的<a href="http://www.tug.org/texlive/">TexLive</a>包安装,并配置到搜索路径中。</p>
|
360
|
+
|
361
|
+
<pre><code>$ sudo apt-get install pandoc
|
362
|
+
$ # 安装texlive 2011
|
363
|
+
</code></pre>
|
364
|
+
|
365
|
+
<p>因为是中文PDF,需要把字体嵌入在文件中,因此需要安装字体文件(如果不是Ubuntu中文版)</p>
|
366
|
+
|
367
|
+
<pre><code>$ sudo apt-get install language-support-fonts-zh-hans
|
368
|
+
</code></pre>
|
369
|
+
|
370
|
+
<p>现在你就可以生成pdf文件了。</p>
|
371
|
+
|
372
|
+
<pre><code>$ ./makepdfs zh
|
373
|
+
</code></pre>
|
374
|
+
|
375
|
+
<h1>其他常用的格式</h1>
|
376
|
+
|
377
|
+
<p>计算机类图书对格式要求不是很多,图文、章节、源代码基本就够了,就算有些复杂公式,也可用图来显示。这也从理论上说明,它不需要复杂的格式。现在对这类技术书出版我的理解主要有几种:</p>
|
378
|
+
|
379
|
+
<ol>
|
380
|
+
<li>Microsoft的Word格式,虽然国内出版界如日中天,缺省就认它(对技术没追求,鄙视)。简单好学,但是不擅长自动化,是开源的死敌。</li>
|
381
|
+
<li>Latex格式(就是Donald E. Knuth(高德纳)发明的,这是很棒的东西,特别适合学术类的各种复杂的公式等,不过学习曲线很高,国内也只有几家学术期刊使用。</li>
|
382
|
+
<li>docbook格式是最有名的(从SGML演化过来?),Orielly和Pragmatic出版社缺省就用它,它能 很方便的转化出出版要的各种样式。如<a href="http://www.wakaleo.com/books/jenkins-the-definitive-guide">Jenkins - the definition guide</a>开源书就是采用docbook。但由于是XML格式,很多人不习惯,而且多人网上协作不是很方便。</li>
|
383
|
+
<li>通过蒋鑫的<a href="http://www.worldhello.net/gotgithub/">Got Github</a>开源书,我也了解reStructureText也是和markdown差不多纯文本(plain text)的,也是蛮流行的。</li>
|
384
|
+
</ol>
|
385
|
+
|
386
|
+
|
387
|
+
<p>如果有机会,我再介绍一下docbook和reStructureText的相关技术。</p>
|
388
|
+
|
389
|
+
<h1>其他</h1>
|
390
|
+
|
391
|
+
<p>本文也是我用git记录在<a href="https://github.com/larrycai/larrycai.github.com">github</a>上的,你可以看到每次的变化。</p>
|
392
|
+
|
393
|
+
<p>如果对此文有兴趣,帮忙顶一下,别忘了 <a href="http://weibo.com/larrycaiyu">@larrycaiyu</a>。</p>
|
394
|
+
|
395
|
+
<h1>Latex的参考</h1>
|
396
|
+
|
397
|
+
<ol>
|
398
|
+
<li>http://share.chinatex.org/</li>
|
399
|
+
<li>http://manual.calibre-ebook.com/conversion.html</li>
|
400
|
+
<li>http://calibre-ebook.com/download_linux</li>
|
401
|
+
<li>http://johnmacfarlane.net/pandoc/</li>
|
402
|
+
<li>http://latex.yo2.cn/articles/latex-introduction0.html</li>
|
403
|
+
<li>http://product.china-pub.com/54569</li>
|
404
|
+
</ol>
|
405
|
+
|
406
|
+
</div>
|
407
|
+
<a href='/2011/12/31/ebook-by-markdown.html#disqus_thread'>View Comments</a>
|
408
|
+
</div>
|
409
|
+
|
410
|
+
|
411
|
+
|
412
|
+
<div class='post'>
|
413
|
+
<span class='date'>16 Dec 2011</span>
|
414
|
+
<h1><a href='/2011/12/16/visualize-quality-4-cxx-legacycode.html'>企业C++大型系统遗留代码变迁的布道之旅</a></h1>
|
415
|
+
<div class='body'><h1>企业C++大型系统遗留代码变迁的布道之旅</h1>
|
416
|
+
|
417
|
+
<h1>前沿</h1>
|
418
|
+
|
419
|
+
<p>特别声明:本文专为<a href="http://www.ituring.com.cn/activity/details/696">图灵社区活动“唤醒你心中的布道师”</a>而写,欢迎大家积极参与!</p>
|
420
|
+
|
421
|
+
<p><a href="http://www.programmer.com.cn/9072/">程序员杂志第十二期</a>中讲到了企业开发的困境,其中有一点就是企业有很多的遗留代码,而且是C/C++的大型系统。怎么处理一直是推动软件开发中的头疼问题,为什么头疼呢?</p>
|
422
|
+
|
423
|
+
<ol>
|
424
|
+
<li>旧代码,又大,怎么下手,时间在哪里?</li>
|
425
|
+
<li>C/C++代码,和java比起来没有统一的单元测试工具,又难改造,怎么办?</li>
|
426
|
+
</ol>
|
427
|
+
|
428
|
+
|
429
|
+
<p>现在我们已经基本完成了这个转变,主要代码覆盖率在60%以上,很好得支持了敏捷开发(如持续集成)。</p>
|
430
|
+
|
431
|
+
<p>在看了<a href="http://www.ituring.com.cn/book/736">布道之道</a>一书后,把我们用的一些技巧和策略用实际例子和大家一起来探讨一下。</p>
|
432
|
+
|
433
|
+
<h1>背景介绍</h1>
|
434
|
+
|
435
|
+
<p>变革开始于2007年左右,那时,这是一个有几十万行代码的C++产品,始于上个世纪末,基于Corba,XML,组件(component)的技术,由于架构的关系,没有单元测试,只有集成测试。</p>
|
436
|
+
|
437
|
+
<p>功能持续增加,开发者交付压力大。质量开始有下降、维护成本有提高的苗头。</p>
|
438
|
+
|
439
|
+
<p>我们就想通过提高C++的代码测试覆盖率来解决这些问题;这就需要把单元测试从无到有,再到一个高度。</p>
|
440
|
+
|
441
|
+
<p>基础这么差,不得不需要布道!</p>
|
442
|
+
|
443
|
+
<h1>什么样的怀疑者</h1>
|
444
|
+
|
445
|
+
<p>在推动这个变革前,先看看有什么样的怀疑者会阻碍你。</p>
|
446
|
+
|
447
|
+
<p>在大公司里最多的还是孤陋寡闻型,时间紧迫型。</p>
|
448
|
+
|
449
|
+
<p><strong>孤陋寡闻型</strong>:主要是开发者,我又想叫他们埋头苦干型。因为他们干活踏踏实实,只是由于项目压力的关系,没有额外的时间去看看外面的新技术,习惯了按步就班。</p>
|
450
|
+
|
451
|
+
<p>他们早已经习惯了用集成测试来替代单元测试。猛然间听说要上单元测试,一下子就觉得不行。Java么还可以考虑考虑,C++的产品需要搞单元测试吗?而且这种复杂的架构,能搞成功吗?就算能成,代价也太大了,那么多旧的代码,不可能!</p>
|
452
|
+
|
453
|
+
<p><strong>时间紧迫型</strong>:主要就是项目管理者,他们最大的愿望是项目准时完成,质量达到要求,项目完成后,他们基本就会转战到另一个战场。</p>
|
454
|
+
|
455
|
+
<p>所以一听说想在项目里面加点东西,还不知道干嘛呢,就问多少时间?问为什么在这个项目做(潜台词就是别在我这儿捣乱)。等到一听说要做以前都不做的单元测试,头摇得就像拨浪鼓一样,死活都不肯。</p>
|
456
|
+
|
457
|
+
<h1>对症下药:采用合适的技术</h1>
|
458
|
+
|
459
|
+
<p>对上面两种人和我们要解决的问题,我们采用了好多种方法,下面介绍主要的两种:展示技术和适当妥协</p>
|
460
|
+
|
461
|
+
<p><strong>展示技术</strong>:你要告诉他们,你要推动的变革是可以做到的,这样来消除他们的疑惑。</p>
|
462
|
+
|
463
|
+
<p>这是对付孤陋寡闻型的最好办法,告诉他们这个能做到,也没有想象中的难。</p>
|
464
|
+
|
465
|
+
<p>我记得我花了两周的时间找了一个最典型的组件,采用了CppUnit这个单元测试框架,并应用了虚函数(java中的接口)的方式把对平台架构的依赖全部隔离掉,顺利地跑通了几个测试。并且我还准备了ppt,召集大家一起来探讨确认这是一个可以工作的方式。</p>
|
466
|
+
|
467
|
+
<p>就象书上说的,孤陋寡闻型的人看到了, 了解了以后,就很容易得接受你的建议了。</p>
|
468
|
+
|
469
|
+
<p><strong>适当妥协</strong>:就是要找到折中方案,让大家都能过的去。</p>
|
470
|
+
|
471
|
+
<p>这是对付时间紧迫型的一个好办法,要求不能太高,把一下子想做的东西放在一个地方。</p>
|
472
|
+
|
473
|
+
<p>我们决定用循序渐进的方式,提出一个中肯的方案:</p>
|
474
|
+
|
475
|
+
<ol>
|
476
|
+
<li>新代码必须要用单元测试,这个没话可说,因为从项目质量上这个是可以要求的。当然怎么做单元测试,由于是新的,会有人提供培训和帮助。</li>
|
477
|
+
<li>旧代码在改变时必须要用单元测试,因为改了代码,有测试保证这也是应该的。</li>
|
478
|
+
<li>在改动的组件中,每次要对旧代码增加一些测试。</li>
|
479
|
+
</ol>
|
480
|
+
|
481
|
+
|
482
|
+
<p>这样一来,每个项目中都会对单元测试有所贡献,长而久之,会积累到比较客观的数量,虽然慢了点,但还是往前进步的。</p>
|
483
|
+
|
484
|
+
<p>时间紧迫型当然不是吃素的,老觉得亏了点,就盯着第三点说:“项目没时间做这个额外的事情”,这个要靠策略了。</p>
|
485
|
+
|
486
|
+
<h1>辅以策略:贯彻实施</h1>
|
487
|
+
|
488
|
+
<p>两个最基本的策略:竭力支持者,说服管理层。</p>
|
489
|
+
|
490
|
+
<p><strong>竭力支持者</strong> 是最该采纳的,他们会鼓动周边的人和你一起服务,要善于团结他们,这要就扭成了一股绳。</p>
|
491
|
+
|
492
|
+
<p>对大多数有经验的开发者,大家都明白单元测试是保证质量的最好办法,技术上说服以后,他们很快就变成了<strong>竭力支持者</strong>,觉得不加单元测试就是一种罪过,项目中有谁忘了,<strong>竭力支持者</strong>也会及时提醒他们,不需要你们一直跟踪,减轻了很多压力。</p>
|
493
|
+
|
494
|
+
<p><strong>说服管理层</strong> 是一个最棒的方式,当然前提是你要能说服他们。</p>
|
495
|
+
|
496
|
+
<p>实际上管理层也知道没有单元测试这一弊端,只是苦于没有行之有效的方案而已。所以当你告诉他们技术上没有问题了,代价也不是很大,并且你又提供了切实可行的计划。管理层立马会通知大家把这个落实到各个项目中去(包括上面的第三条)。</p>
|
497
|
+
|
498
|
+
<p>拿到了这个尚方宝剑,没有谁会阻碍了,我们就可以把主要精力花在技术支持上,当然千万不能搞砸了。</p>
|
499
|
+
|
500
|
+
<h1>收获果实</h1>
|
501
|
+
|
502
|
+
<p>果然,经过了几年,到2010年单元测试已经达到了60%左右(对C++来说不错了),现在开发人员也习以为常了。</p>
|
503
|
+
|
504
|
+
<h1>结束语</h1>
|
505
|
+
|
506
|
+
<p><a href="http://www.ituring.com.cn/book/736">布道之道</a> 真是一本好书(翻译要记一功),它的好多种模式一看就明白。如果你是个有经验的人,你会发现你的很多技巧都在书上提到了,它会帮你进一步的提炼升华,使你下次做的更好。</p>
|
507
|
+
|
508
|
+
<p>布道会使你有一种成就感,让我们一起来把这个软件行业变得越来越好吧。</p>
|
509
|
+
|
510
|
+
<h1>其他</h1>
|
511
|
+
|
512
|
+
<p>本文也是我用git记录在<a href="https://github.com/larrycai/larrycai.github.com">github</a>上的,你可以看到每次的变化。</p>
|
513
|
+
|
514
|
+
<p>如果对此文有兴趣,帮忙顶一下,别忘了 <a href="http://weibo.com/larrycaiyu">@larrycaiyu</a> ,希望有机会有人能帮我推荐到QConf 2012中去分享,到时我们可以探讨得更多。</p>
|
515
|
+
|
516
|
+
<p>这儿再留一个关子,如何建立一个好的C++代码质量检测框架,并且最终和其他java代码质量清晰得显示在一起又是另外一个布道故事了,而且有一些就是因为没有看这本书而得到的一个反面教材。</p>
|
517
|
+
</div>
|
518
|
+
<a href='/2011/12/16/visualize-quality-4-cxx-legacycode.html#disqus_thread'>View Comments</a>
|
519
|
+
</div>
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
|
524
|
+
<h3>Older Posts</h3>
|
525
|
+
<table class='post-list'>
|
526
|
+
|
527
|
+
<tr>
|
528
|
+
<th><a href='/2011/12/10/clearcase-2-git.html'>企业版本控制的改革:从ClearCase到Git--我的布道之旅</a></th>
|
529
|
+
<td>10 Dec 2011</td>
|
530
|
+
<td><a href='/2011/12/10/clearcase-2-git.html#disqus_thread'>Comments</a></td>
|
531
|
+
</tr>
|
532
|
+
|
533
|
+
|
534
|
+
|
535
|
+
|
536
|
+
<tr>
|
537
|
+
<th><a href='/2011/11/04/veewee-create-vm.html'>用veewee创建vagrant的虚拟机</a></th>
|
538
|
+
<td>04 Nov 2011</td>
|
539
|
+
<td><a href='/2011/11/04/veewee-create-vm.html#disqus_thread'>Comments</a></td>
|
540
|
+
</tr>
|
541
|
+
|
542
|
+
|
543
|
+
|
544
|
+
|
545
|
+
<tr>
|
546
|
+
<th><a href='/2011/10/25/vagrant-jenkins-ci.html'>使用vagrant+jenkins来管理虚拟机的技巧</a></th>
|
547
|
+
<td>25 Oct 2011</td>
|
548
|
+
<td><a href='/2011/10/25/vagrant-jenkins-ci.html#disqus_thread'>Comments</a></td>
|
549
|
+
</tr>
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
|
554
|
+
<tr>
|
555
|
+
<th><a href='/2011/08/18/agile-tools.html'>敏捷和工具</a></th>
|
556
|
+
<td>18 Aug 2011</td>
|
557
|
+
<td><a href='/2011/08/18/agile-tools.html#disqus_thread'>Comments</a></td>
|
558
|
+
</tr>
|
559
|
+
|
560
|
+
|
561
|
+
</table>
|
562
|
+
<div class='clearfix'></div>
|
563
|
+
</div>
|
564
|
+
</div>
|
565
|
+
<div id='footer'>
|
566
|
+
Copyright © 2011 Larry Cai. Hosted by <a href='http://github.com/larrycai/larrycai.github.com/' target='_blank'>GitHub</a> and powered by <a href='http://github.com/mojombo/jekyll'>Jekyll</a>, and reuse the template from <a href='http://github.com/mbleigh/mbleigh.github.com/'>Michael Bleigh</a>.
|
567
|
+
</div>
|
568
|
+
<script type="text/javascript">
|
569
|
+
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
|
570
|
+
var disqus_shortname = 'larrycaiyu'; // required: replace example with your forum shortname
|
571
|
+
|
572
|
+
/* * * DON'T EDIT BELOW THIS LINE * * */
|
573
|
+
(function () {
|
574
|
+
var s = document.createElement('script'); s.async = true;
|
575
|
+
s.type = 'text/javascript';
|
576
|
+
s.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
|
577
|
+
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
|
578
|
+
}());
|
579
|
+
</script>
|
580
|
+
</body>
|
581
|
+
</html>
|