-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
398 lines (246 loc) · 13.6 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
<meta charset="utf-8">
<title>用octopress来写博客并发布到Github上 - Wongyouth's Blog</title>
<meta name="author" content="Wongyouth">
<meta name="description" content="用过不少博客,MSN spaces,blogger.com,myspace, wordpress,搜狐,总是觉得少了点自由发挥的空间。直到现有有了octopress,就像我这个博客一样,这才是咱程序猿该有的! 安装
配置
发布
写第一个博文 安装 Install octopress1
2
3
4 …">
<!-- http://t.co/dKP3o1e -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="canonical" href="http://wongyouth.github.com/blog/2012/04/21/install-octopress-to-write-blogs-and-deploy-on-github-dot-com/">
<link href="/favicon.png" rel="icon">
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
<script src="/javascripts/modernizr-2.0.js"></script>
<script src="/javascripts/ender.js"></script>
<script src="/javascripts/octopress.js" type="text/javascript"></script>
<link href="/atom.xml" rel="alternate" title="Wongyouth's Blog" type="application/atom+xml">
<!--Fonts from Google"s Web font directory at http://google.com/webfonts -->
<link href="http://fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">
<script src="/javascripts/jiathis.js" type="text/javascript"></script>
<meta property="wb:webmaster" content="7f133defa7956d35" />
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-30466888-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body >
<header role="banner"><hgroup>
<h1><a href="/">Wongyouth's Blog</a></h1>
<h2>Do things the stupid way.</h2>
</hgroup>
</header>
<nav role="navigation"><ul class="subscription" data-subscription="rss">
<li><a href="/atom.xml" rel="subscribe-rss" title="subscribe via RSS">RSS</a></li>
</ul>
<form action="http://google.com/search" method="get">
<fieldset role="search">
<input type="hidden" name="q" value="site:wongyouth.github.com" />
<input class="search" type="text" name="q" results="0" placeholder="Search"/>
</fieldset>
</form>
<ul class="main-navigation">
<li><a href="/">Blog</a></li>
<li><a href="/blog/archives">Archives</a></li>
</ul>
</nav>
<div id="main">
<div id="content">
<div>
<article class="hentry" role="article">
<header>
<h1 class="entry-title">用octopress来写博客并发布到Github上</h1>
<p class="meta">
<time datetime="2012-04-21T20:54:00+08:00" pubdate data-updated="true">2012-04-21</time>
| <a href="#disqus_thread">Comments</a>
</p>
</header>
<div class="entry-content"><p>用过不少博客,MSN spaces,blogger.com,myspace, wordpress,搜狐,总是觉得少了点自由发挥的空间。直到现有有了<a href="http://octopress.org/">octopress</a>,就像我这个博客一样,这才是咱程序猿该有的!</p>
<!-- more -->
<ol>
<li>安装</li>
<li>配置</li>
<li>发布</li>
<li>写第一个博文</li>
</ol>
<h2>安装</h2>
<figure class='code'><figcaption><span>Install octopress</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>git clone git://github.com/imathis/octopress.git octopress
</span><span class='line'><span class="nb">cd </span>octopress
</span><span class='line'>bundler install
</span><span class='line'>rake install
</span></code></pre></td></tr></table></div></figure>
<h2>配置</h2>
<p>你要先有个github.com的帐号,如果没有赶快注册吧。
注册好后新建一个软件仓库 <a href="https://github.com/new">https://github.com/new</a> ,注意仓库名称要以下这种格式哦<code>yourname.github.com</code>,这样代码发布后自动这个url就可以访问了。</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>rake setup_github_pages
</span></code></pre></td></tr></table></div></figure>
<p>这个命令主要做以下的操作</p>
<ol>
<li>问你github上的url。 我的是 git@github.com:wongyouth/wongyouth.github.com.git</li>
<li>将原始的<code>imathis/octopress</code>远端仓库<code>origin</code>名称改为<code>octopress</code></li>
<li>把你输入的url作为远端仓库名<code>origin</code></li>
<li>把当前目录从分支<code>master</code>切换到<code>source</code></li>
<li>把当前目录与<code>origin</code>的仓库关联,能默认push到github中</li>
<li>配置<code>_deploy</code>目录作为github仓库的<code>master</code>分支</li>
</ol>
<p>要做的就是把原始的blog代码放在<code>source</code>分支中,当要发布时会自动生成发布代码到<code>_deploy</code>目录下以<code>master</code>分支更新到github上。github会以<code>master</code>中的代码作为blog的原始代码。</p>
<h2>发布</h2>
<figure class='code'><figcaption><span>Deploy blog</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>rake generate
</span><span class='line'>rake deploy
</span></code></pre></td></tr></table></div></figure>
<p>当你发布之后,你就可以到 <a href="http://yourname.github.com">http://yourname.github.com</a> 上看到你的博客了,是不是很酷呢。</p>
<h2>写第一个博文</h2>
<figure class='code'><figcaption><span>Create first post</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>rake new_post<span class="o">[</span><span class="s1">'first post'</span><span class="o">]</span>
</span></code></pre></td></tr></table></div></figure>
<p>引号里面是博文的标题,这个命令会在<code>source/_posts</code>下面生成一个markdown为后缀的文件,我们要做的就是编辑这个文件的内容,然后</p>
<figure class='code'><figcaption><span>Start a local server for preview</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>rake preview
</span></code></pre></td></tr></table></div></figure>
<p>会在本地启动sinatra服务,用浏览器打开 <a href="http://localhost:4000">http://localhost:4000</a> 就可以看到效果了。如果都没有问题就可以发布了。</p>
<p>有时候写了一半的博文想要先留为草稿放到服务器但是不发布这样情况。
我们可以在单独的这篇博文开头的yaml里面追加设置</p>
<pre><code>published: false
</code></pre>
<p>这样deploy的时候就不会发布了。</p>
<h2>其他</h2>
<p>你可以仔细查看以下三个文件,如果觉得有必要就按照自己的配置修改。</p>
<ol>
<li>_config.yml</li>
<li>config.rb</li>
<li>config.ru</li>
</ol>
<p>_config.yml中有关联其他一些社区的配置,比如github.com帐号,facebook帐号等。我认为比较有用的是<a href="http://disqus.com/">disqus</a>的评论帐号。到disqus注册一下,然后设置好<code>disqus_short_name</code>这样你的博客就有了评论功能了,而不是你一个人在唱独角戏了。</p>
<h2>在其他电脑里面同步时的操作</h2>
<pre><code>git clone git@github.com:wongyouth/wongyouth.github.com.git
cd wongyouth.github.com
git checkout source
git clone git@github.com:wongyouth/wongyouth.github.com.git _deploy
</code></pre>
<p><code>_deploy</code>目录是用来与远程代码库同步的目录,所以我们要把它checkout出来预先做好关联</p>
<p>make a new post and something else …</p>
<pre><code>rake generate
rake deploy
</code></pre>
</div>
<footer>
<p class="meta">
<span class="byline author vcard">Posted by <span class="fn">Wongyouth</span></span>
<time datetime="2012-04-21T20:54:00+08:00" pubdate data-updated="true">2012-04-21</time>
<span class="categories">
<a class='category' href='/blog/categories/github/'>github</a>, <a class='category' href='/blog/categories/octopress/'>octopress</a>
</span>
</p>
<div class="sharing">
</div>
<p class="meta">
<a class="basic-alignment left" href="/blog/2012/04/21/install-ruby-environment-on-ubuntu/" title="Previous Post: Ubuntu下安装ruby开发环境">« Ubuntu下安装ruby开发环境</a>
<a class="basic-alignment right" href="/blog/2012/04/26/git-tagging/" title="Next Post: Git标签常用操作">Git标签常用操作 »</a>
</p>
</footer>
</article>
<section>
<h1>Comments</h1>
<div id="disqus_thread" aria-live="polite"><noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
</section>
</div>
<aside class="sidebar">
<section>
<h1>Recent Posts</h1>
<ul id="recent_posts">
<li class="post">
<a href="/blog/2012/11/05/make-a-git-repo-mirror-for-redmine/">redmine用Git repo镜像脚本</a>
</li>
<li class="post">
<a href="/blog/2012/10/25/return-to-old-revision-on-git-repo/">Git中如何退回到旧版本</a>
</li>
<li class="post">
<a href="/blog/2012/07/05/rails-development-oriented-vimfiles/">rails开发用 vimfiles 配置</a>
</li>
<li class="post">
<a href="/blog/2012/06/30/use-mongoid-with-rails/">在rails中使用mongoid</a>
</li>
<li class="post">
<a href="/blog/2012/06/25/use-postgresql-with-rails/">Ubuntu环境下在Rails项目中使用postgresql时的初始配置</a>
</li>
</ul>
</section>
<section>
<h1>分类</h1>
<ul id="category-list"><li><a href='/blog/categories/git'>git (4)</a></li><li><a href='/blog/categories/github'>github (1)</a></li><li><a href='/blog/categories/mongodb'>mongodb (1)</a></li><li><a href='/blog/categories/octopress'>octopress (1)</a></li><li><a href='/blog/categories/postgresql'>postgresql (1)</a></li><li><a href='/blog/categories/rails'>rails (3)</a></li><li><a href='/blog/categories/redmine'>redmine (1)</a></li><li><a href='/blog/categories/ruby'>ruby (2)</a></li><li><a href='/blog/categories/ubuntu'>ubuntu (3)</a></li><li><a href='/blog/categories/vim'>vim (1)</a></li></ul>
</section>
<section>
<h1>近期评论</h1>
<script type="text/javascript" src="http://wongyouth.disqus.com/recent_comments_widget.js?num_items=5&hide_avatars=0&avatar_size=32&excerpt_length=200"></script>
</section>
<section>
<h1>GitHub Repos</h1>
<ul id="gh_repos">
<li class="loading">Status updating...</li>
</ul>
<a href="https://github.com/wongyouth">@wongyouth</a> on GitHub
<script type="text/javascript">
$.domReady(function(){
if (!window.jXHR){
var jxhr = document.createElement('script');
jxhr.type = 'text/javascript';
jxhr.src = '/javascripts/libs/jXHR.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(jxhr, s);
}
github.showRepos({
user: 'wongyouth',
count: 0,
skip_forks: true,
target: '#gh_repos'
});
});
</script>
<script src="/javascripts/github.js" type="text/javascript"> </script>
</section>
</aside>
</div>
</div>
<footer role="contentinfo"><p>
Copyright © 2012 - Wongyouth -
<span class="credit">Powered by <a href="http://octopress.org">Octopress</a></span>
</p>
</footer>
<script type="text/javascript">
var disqus_shortname = 'wongyouth';
// var disqus_developer = 1;
var disqus_identifier = 'http://wongyouth.github.com/blog/2012/04/21/install-octopress-to-write-blogs-and-deploy-on-github-dot-com/';
var disqus_url = 'http://wongyouth.github.com/blog/2012/04/21/install-octopress-to-write-blogs-and-deploy-on-github-dot-com/';
var disqus_script = 'embed.js';
(function () {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/' + disqus_script;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
}());
</script>
</body>
</html>