mkblog 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/mkblog +43 -8
- data/lib/mkblog_version.rb +1 -1
- data/templates/_layouts/{master.html → master.html.erb} +4 -4
- data/templates/_layouts/{post.html → post.html.erb} +1 -1
- data/templates/_posts/2012-03-16-setup-blog-in-5minutes.mkd.erb +8 -6
- data/templates/atom.xml.erb +8 -8
- data/templates/index.html.erb +3 -3
- metadata +9 -9
data/bin/mkblog
CHANGED
@@ -11,7 +11,7 @@ include FileUtils
|
|
11
11
|
|
12
12
|
def main()
|
13
13
|
options = {
|
14
|
-
|
14
|
+
"debug" => false
|
15
15
|
}
|
16
16
|
option_parser = OptionParser.new do |opts|
|
17
17
|
executable_name = File.basename($PROGRAM_NAME)
|
@@ -27,7 +27,7 @@ def main()
|
|
27
27
|
raise ArgumentError,"name should be [a-zA-Z0-9]"
|
28
28
|
end
|
29
29
|
options["command"] = "generate"
|
30
|
-
options["
|
30
|
+
options["account"] = name
|
31
31
|
end
|
32
32
|
opts.on("-s","--show","show how to continue") do
|
33
33
|
options["command"] = "show"
|
@@ -39,8 +39,8 @@ def main()
|
|
39
39
|
puts options.inspect if options["debug"]
|
40
40
|
|
41
41
|
case options["command"]
|
42
|
-
when "generate" then generate_project(options["
|
43
|
-
when "show" then showhelp()
|
42
|
+
when "generate" then generate_project(options["account"],options["debug"])
|
43
|
+
when "show" then showhelp()
|
44
44
|
else puts "--help for help"
|
45
45
|
end
|
46
46
|
end
|
@@ -50,9 +50,33 @@ def showhelp()
|
|
50
50
|
puts "2. create project in github.com and push this project"
|
51
51
|
puts "3. follow http://pages.github.com/"
|
52
52
|
end
|
53
|
+
|
54
|
+
def guess()
|
55
|
+
username = "Larry Cai"
|
56
|
+
email = "larry.caiyu@gmail.com"
|
57
|
+
|
58
|
+
# scan ~/.gitconfig
|
59
|
+
gitconfig = ".gitconfig"
|
60
|
+
gconf = File.join(Dir.home, gitconfig)
|
61
|
+
if File.exists?(gconf)
|
62
|
+
puts "..scan `#{gconf}`"
|
63
|
+
File.open(gconf).each do |record|
|
64
|
+
name,value = record.split("=")
|
65
|
+
name.gsub!(/\t*\s*/,'')
|
66
|
+
# puts "[#{name}]" + ":"
|
67
|
+
case name
|
68
|
+
when "name" then username = value.gsub(/\t*\s*\n*/,'')
|
69
|
+
when "email" then email = value.gsub(/ /,'')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
# puts username + ":" + email
|
74
|
+
return username,email
|
75
|
+
end
|
53
76
|
# http://stackoverflow.com/questions/5074327/most-appropriate-way-to-generate-directory-of-files-from-directory-of-template-f
|
54
|
-
def generate_project(
|
55
|
-
destination =
|
77
|
+
def generate_project(account,debug)
|
78
|
+
destination = account + ".github.com"
|
79
|
+
username,email = guess()
|
56
80
|
source = File.dirname(__FILE__)+"/../templates"
|
57
81
|
#puts "generate project \"#{destination}\" from source \"#{source}\""
|
58
82
|
FileUtils.rmtree(destination)
|
@@ -77,16 +101,27 @@ def generate_project(project)
|
|
77
101
|
#puts relative.dirname
|
78
102
|
#puts File.join(destination,relative.dirname,pathname.basename.sub(/\.erb$/, ''))
|
79
103
|
target = File.join(destination,relative.dirname,pathname.basename.sub(/\.erb$/, ''))
|
80
|
-
|
104
|
+
if debug == true
|
105
|
+
print " ", pathname.cleanpath, " => ", target,"\n"
|
106
|
+
end
|
81
107
|
File.open(target, 'w') do |file|
|
82
108
|
file.puts(ERB.new(File.read(path)).result(binding))
|
83
109
|
end
|
84
110
|
else
|
85
|
-
|
111
|
+
if debug == true
|
112
|
+
print " ", pathname.cleanpath, " => ", File.join(destination, relative.dirname),"\n"
|
113
|
+
end
|
86
114
|
FileUtils.cp(pathname, File.join(destination, relative.dirname))
|
87
115
|
end
|
88
116
|
end
|
89
117
|
end
|
118
|
+
puts
|
119
|
+
puts "The blog is now yours"
|
120
|
+
puts "=> name:" + username
|
121
|
+
puts "=> email:" + email
|
122
|
+
puts "=> github: http://github.com/" + account
|
123
|
+
puts "please run `cd " + account + ".github.com/" + " ; jekyll --server'"
|
124
|
+
puts "Then and open browser to http://localhost:4000 see the magic"
|
90
125
|
end
|
91
126
|
|
92
127
|
main
|
data/lib/mkblog_version.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<html>
|
5
5
|
<head>
|
6
6
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
7
|
-
<title
|
7
|
+
<title><%= username %> - {{ page.title }}</title>
|
8
8
|
<link rel="stylesheet" href="/stylesheets/master.css" type="text/css" media="screen" charset="utf-8"/>
|
9
9
|
<link rel="stylesheet" href="/stylesheets/syntax.css" type="text/css" media="screen" charset="utf-8"/>
|
10
10
|
<script src="/javascripts/jquery.js" type="text/javascript" charset="utf-8"></script>
|
@@ -14,13 +14,13 @@
|
|
14
14
|
<body>
|
15
15
|
<div id='wrapper'>
|
16
16
|
<div id='header'>
|
17
|
-
<h1><a href='/'
|
17
|
+
<h1><a href='/'><%= username %></a></h1>
|
18
18
|
|
19
19
|
<div id='menu'>
|
20
20
|
<ul>
|
21
21
|
<li><a href='/blog.html' id='blog_link' title='Blog'>Blog</a></li>
|
22
22
|
<li><a href='/about.html' id='about_link' title='About'>About</a></li>
|
23
|
-
<li><a href='http://github.com
|
23
|
+
<li><a href='http://github.com/<%= account %>' target='_blank' title='GitHub' rel='me' id='github_link'>GitHub</a></li>
|
24
24
|
<li><a href='http://cn.linkedin.com/in/larrycaiyu' title='LinkedIn' target='_blank' rel='me' id='linkedin_link'>LinkedIn</a></li>
|
25
25
|
<li><a href='http://weibo.com/larrycaiyu' title='Weibo' target='_blank' rel='me' id='weibo_link'>Weibo</a></li>
|
26
26
|
</ul>
|
@@ -32,7 +32,7 @@
|
|
32
32
|
</div>
|
33
33
|
</div>
|
34
34
|
<div id='footer'>
|
35
|
-
Copyright © 2011
|
35
|
+
Copyright © 2011 <%= username %>. Hosted by <a href='http://github.com/<%= account %>/<%= account %>.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>.
|
36
36
|
</div>
|
37
37
|
<script type="text/javascript">
|
38
38
|
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
|
@@ -21,7 +21,7 @@ layout: master
|
|
21
21
|
</div>
|
22
22
|
|
23
23
|
<script type="text/javascript" charset="utf-8">
|
24
|
-
var disqus_url = "http
|
24
|
+
var disqus_url = "http://<%= account %>.github.com/{{page.url}}";
|
25
25
|
</script>
|
26
26
|
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
|
27
27
|
<a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
|
@@ -4,26 +4,28 @@ title: 5分钟快速架设个人博客
|
|
4
4
|
---
|
5
5
|
|
6
6
|
#介绍#
|
7
|
-
现在很多人都有博客,为什么不自己来一个呢。最方便的是放在Github上,假设你有个Github账号`<%=
|
7
|
+
现在很多人都有博客,为什么不自己来一个呢。最方便的是放在Github上,假设你有个Github账号`<%= account %>`
|
8
8
|
|
9
9
|
gem install mkblog
|
10
|
-
mkblog --generate <%=
|
11
|
-
cd <%=
|
10
|
+
mkblog --generate <%= account %>
|
11
|
+
cd <%= account %>.github.com
|
12
12
|
jekyll --server
|
13
13
|
|
14
14
|
好了打开浏览器访问 <http://localhost:4000> 。
|
15
15
|
|
16
|
-
|
16
|
+
当然还没做好,你看到有些是Larry Cai的东西,试着改成你自己的吧,我会用模板自动化起来,现在还是手工吧。
|
17
17
|
|
18
18
|
about.title
|
19
19
|
blog.html
|
20
20
|
index.html
|
21
|
+
_layout/master.html
|
22
|
+
_layout/post.html
|
21
23
|
|
22
|
-
现在就可以把东西放到Github上了。在<http://github.com/<%=
|
24
|
+
现在就可以把东西放到Github上了。在<http://github.com/<%= account %>>建一个`<%= account %>.github.com`,然后上传。
|
23
25
|
|
24
26
|
再在你的项目中按照[github:pages](http://pages.github.com/)配好。
|
25
27
|
|
26
|
-
现在你就可以看到 <http://<%=
|
28
|
+
现在你就可以看到 <http://<%= account %>.github.com> 了,如果有自己的域名就可以转过来了。
|
27
29
|
|
28
30
|
忘了说怎么写博客了,把文件放在 `_posts`即可。
|
29
31
|
|
data/templates/atom.xml.erb
CHANGED
@@ -4,22 +4,22 @@ layout: nil
|
|
4
4
|
<?xml version="1.0" encoding="utf-8"?>
|
5
5
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
6
6
|
|
7
|
-
<title
|
8
|
-
<link href="http://<%=
|
9
|
-
<link href="http://<%=
|
7
|
+
<title><%= username %></title>
|
8
|
+
<link href="http://<%= account %>.github.com/atom.xml" rel="self"/>
|
9
|
+
<link href="http://<%= account %>.github.com"/>
|
10
10
|
<updated>{{ site.time | date_to_xmlschema }}</updated>
|
11
|
-
<id><%=
|
11
|
+
<id><%= account %>.github.com</id>
|
12
12
|
<author>
|
13
|
-
<name
|
14
|
-
<email
|
13
|
+
<name><%= username %></name>
|
14
|
+
<email><%= email %></email>
|
15
15
|
</author>
|
16
16
|
|
17
17
|
{% for post in site.posts %}
|
18
18
|
<entry>
|
19
19
|
<title>{{ post.title }}</title>
|
20
|
-
<link href="http://<%=
|
20
|
+
<link href="http://<%= account %>.github.com{{ post.url }}"/>
|
21
21
|
<updated>{{ post.date | date_to_xmlschema }}</updated>
|
22
|
-
<id>http://<%=
|
22
|
+
<id>http://<%= account %>.github.com{{ post.id }}</id>
|
23
23
|
<content type="html">{{ post.content | xml_escape }}</content>
|
24
24
|
</entry>
|
25
25
|
{% endfor %}
|
data/templates/index.html.erb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
layout: master
|
3
|
-
title:
|
3
|
+
title: <%= username %>
|
4
4
|
full_posts: 3
|
5
5
|
---
|
6
6
|
|
@@ -25,7 +25,7 @@ full_posts: 3
|
|
25
25
|
<div class="sidebar-item">
|
26
26
|
<dl>
|
27
27
|
<dt>邮件:</dt>
|
28
|
-
<dd
|
28
|
+
<dd><%= email %></dd>
|
29
29
|
|
30
30
|
<dt>微博:</dt>
|
31
31
|
<dd><a href="http://weibo.com/larrycaiyu">http://weibo.com/larrycaiyu</a></dd>
|
@@ -39,7 +39,7 @@ full_posts: 3
|
|
39
39
|
</div>
|
40
40
|
|
41
41
|
<script type="text/javascript" charset="utf-8">
|
42
|
-
$.githubUser('<%=
|
42
|
+
$.githubUser('<%= account %>', function(data) {
|
43
43
|
$('#github-projects').html('');
|
44
44
|
|
45
45
|
var repos = data.user.repositories;
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mkblog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-03-17 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aruba
|
16
|
-
requirement: &
|
16
|
+
requirement: &24945000 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.4.6
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *24945000
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: jekyll
|
27
|
-
requirement: &
|
27
|
+
requirement: &24944760 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *24944760
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rdiscount
|
38
|
-
requirement: &
|
38
|
+
requirement: &24944472 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *24944472
|
47
47
|
description: ! 'generate jekyll based blog '
|
48
48
|
email:
|
49
49
|
- larry.caiyu@gmail.com
|
@@ -82,8 +82,8 @@ files:
|
|
82
82
|
- templates/stylesheets/master.css
|
83
83
|
- templates/stylesheets/syntax.css
|
84
84
|
- templates/_config.yml
|
85
|
-
- templates/_layouts/master.html
|
86
|
-
- templates/_layouts/post.html
|
85
|
+
- templates/_layouts/master.html.erb
|
86
|
+
- templates/_layouts/post.html.erb
|
87
87
|
- templates/_posts/2012-03-16-setup-blog-in-5minutes.mkd.erb
|
88
88
|
- templates/_site/about.html
|
89
89
|
- templates/_site/atom.xml
|