write_down 0.0.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +9 -21
- data/.travis.yml +4 -0
- data/Gemfile +1 -1
- data/LICENSE.txt +17 -18
- data/README.md +20 -8
- data/Rakefile +9 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/exe/write_down +3 -0
- data/lib/write_down/converter/base.rb +18 -0
- data/lib/write_down/converter/markdown.rb +18 -0
- data/lib/write_down/converter/org.rb +18 -0
- data/lib/write_down/erb/container.erb +19 -0
- data/lib/write_down/erb/essay.erb +5 -0
- data/lib/write_down/erb/layout.erb +64 -0
- data/lib/write_down/erb/page.erb +4 -0
- data/lib/write_down/erb/post.erb +5 -0
- data/lib/write_down/erb/slide.erb +79 -0
- data/lib/write_down/model/asset.rb +36 -0
- data/lib/write_down/model/base.rb +63 -0
- data/lib/write_down/model/container.rb +35 -0
- data/lib/write_down/model/essay.rb +35 -0
- data/lib/write_down/model/layout.rb +75 -0
- data/lib/write_down/model/page.rb +47 -0
- data/lib/write_down/model/post.rb +47 -0
- data/lib/write_down/model/slide.rb +27 -0
- data/lib/write_down/utils/qiniu_sync.rb +23 -0
- data/lib/write_down/version.rb +1 -1
- data/lib/write_down.rb +13 -33
- data/write_down.gemspec +23 -12
- metadata +54 -91
- data/bin/write_down +0 -43
- data/lib/write_down/article.rb +0 -64
- data/lib/write_down/configuration.rb +0 -6
- data/lib/write_down/converter.rb +0 -8
- data/lib/write_down/page.rb +0 -6
- data/lib/write_down/series.rb +0 -10
- data/lib/write_down/site.rb +0 -10
- data/lib/write_down/template.rb +0 -20
- data/template/emacs/404.html +0 -157
- data/template/emacs/CHANGELOG.md +0 -133
- data/template/emacs/CONTRIBUTING.md +0 -154
- data/template/emacs/LICENSE.md +0 -19
- data/template/emacs/README.md +0 -1
- data/template/emacs/apple-touch-icon-precomposed.png +0 -0
- data/template/emacs/crossdomain.xml +0 -15
- data/template/emacs/css/custom.css +0 -18
- data/template/emacs/css/main.css +0 -304
- data/template/emacs/css/normalize.css +0 -527
- data/template/emacs/favicon.ico +0 -0
- data/template/emacs/humans.txt +0 -15
- data/template/emacs/img/.gitignore +0 -0
- data/template/emacs/index.html +0 -62
- data/template/emacs/js/main.js +0 -1
- data/template/emacs/js/plugins.js +0 -24
- data/template/emacs/js/vendor/jquery-1.10.2.min.js +0 -6
- data/template/emacs/js/vendor/modernizr-2.6.2.min.js +0 -4
- data/template/emacs/post.html +0 -80
- data/template/emacs/robots.txt +0 -3
- data/template/simple/404.html +0 -157
- data/template/simple/CNAME +0 -1
- data/template/simple/README.md +0 -1
- data/template/simple/_disqus.mustache +0 -19
- data/template/simple/_footer.mustache +0 -28
- data/template/simple/_header.mustache +0 -38
- data/template/simple/apple-touch-icon-precomposed.png +0 -0
- data/template/simple/crossdomain.xml +0 -15
- data/template/simple/css/layout.css +0 -72
- data/template/simple/css/main.css +0 -304
- data/template/simple/css/normalize.css +0 -527
- data/template/simple/favicon.ico +0 -0
- data/template/simple/humans.txt +0 -15
- data/template/simple/img/.gitignore +0 -0
- data/template/simple/index.html +0 -12
- data/template/simple/js/main.js +0 -1
- data/template/simple/js/plugins.js +0 -24
- data/template/simple/js/vendor/jquery-1.10.2.min.js +0 -6
- data/template/simple/js/vendor/modernizr-2.6.2.min.js +0 -4
- data/template/simple/post.html +0 -9
- data/template/simple/robots.txt +0 -3
- data/theme/ghost/assets/css/screen.css +0 -911
- data/theme/ghost/index.html +0 -75
- data/theme/ghost/post.html +0 -112
- data/theme/html5-boilerplate/.gitattributes +0 -1
- data/theme/html5-boilerplate/.gitignore +0 -2
- data/theme/html5-boilerplate/.htaccess +0 -551
- data/theme/html5-boilerplate/404.html +0 -157
- data/theme/html5-boilerplate/CHANGELOG.md +0 -133
- data/theme/html5-boilerplate/CONTRIBUTING.md +0 -154
- data/theme/html5-boilerplate/LICENSE.md +0 -19
- data/theme/html5-boilerplate/README.md +0 -61
- data/theme/html5-boilerplate/apple-touch-icon-precomposed.png +0 -0
- data/theme/html5-boilerplate/crossdomain.xml +0 -15
- data/theme/html5-boilerplate/css/main.css +0 -297
- data/theme/html5-boilerplate/css/normalize.css +0 -527
- data/theme/html5-boilerplate/favicon.ico +0 -0
- data/theme/html5-boilerplate/humans.txt +0 -15
- data/theme/html5-boilerplate/img/.gitignore +0 -0
- data/theme/html5-boilerplate/index.html +0 -91
- data/theme/html5-boilerplate/js/main.js +0 -1
- data/theme/html5-boilerplate/js/plugins.js +0 -24
- data/theme/html5-boilerplate/js/vendor/jquery-1.10.2.min.js +0 -6
- data/theme/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js +0 -4
- data/theme/html5-boilerplate/post.html +0 -70
- data/theme/html5-boilerplate/robots.txt +0 -3
@@ -0,0 +1,75 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'erb'
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
# 布局, 是最大的 wrapper
|
6
|
+
# home_page 什么的都是它的内嵌
|
7
|
+
module WriteDown
|
8
|
+
module Model
|
9
|
+
class Layout
|
10
|
+
|
11
|
+
# @param page 被塞入的页面
|
12
|
+
# @param target_file 被写入的目标文件
|
13
|
+
def initialize(page, target_file, option = {})
|
14
|
+
@page = page
|
15
|
+
@target_file = target_file
|
16
|
+
@option = option
|
17
|
+
end
|
18
|
+
|
19
|
+
# 实际写入硬盘的是这个地方
|
20
|
+
def render
|
21
|
+
output = Pathname.new(@target_file)
|
22
|
+
output.dirname.mkpath
|
23
|
+
final_content = render_all_content(@page)
|
24
|
+
output.write(final_content)
|
25
|
+
end
|
26
|
+
|
27
|
+
# page 相当于一个接口, 需要实现 render 方法
|
28
|
+
# @see http://stackoverflow.com/questions/2460839/yield-in-erb-without-rails
|
29
|
+
def render_all_content(page)
|
30
|
+
page_html = page.render # 先渲染 page, 这里使用了代理模式把职责分配给当前的 page
|
31
|
+
render_layout { page_html } # 再渲染 layout
|
32
|
+
end
|
33
|
+
|
34
|
+
# 可以调用到 erb 中的 yield
|
35
|
+
def render_layout
|
36
|
+
layout_path = @option['layout'] || File.expand_path('../../erb/layout.erb', __FILE__)
|
37
|
+
ERB.new(File.read(layout_path)).result(binding)
|
38
|
+
end
|
39
|
+
|
40
|
+
# css 的版本号
|
41
|
+
def assets_version
|
42
|
+
"" #"?v=1"
|
43
|
+
end
|
44
|
+
|
45
|
+
# ===================== 一些 config 的 meta data ==============================
|
46
|
+
|
47
|
+
# 网站 title
|
48
|
+
def title
|
49
|
+
'编程青年'
|
50
|
+
end
|
51
|
+
|
52
|
+
# 副标题
|
53
|
+
def tagline
|
54
|
+
'没有银弹'
|
55
|
+
end
|
56
|
+
|
57
|
+
# 菜单
|
58
|
+
def menus
|
59
|
+
{
|
60
|
+
"home": '/',
|
61
|
+
"about": '/about/',
|
62
|
+
"essays": '/essays/',
|
63
|
+
"reading": '/reading/',
|
64
|
+
"github": 'https://github.com/teddy-ma/'
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
# 友情链接集合
|
69
|
+
def friend_links
|
70
|
+
{ "苏州八零年代": 'http://niandai80.com/' }
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'pathname'
|
3
|
+
require 'date'
|
4
|
+
require 'json'
|
5
|
+
require 'time'
|
6
|
+
|
7
|
+
module WriteDown
|
8
|
+
module Model
|
9
|
+
# 代表单个页面
|
10
|
+
class Page < Base
|
11
|
+
|
12
|
+
def render
|
13
|
+
template_file = File.expand_path('../../erb/page.erb', __FILE__)
|
14
|
+
template = File.read(template_file)
|
15
|
+
html_string = ERB.new(template).result(binding)
|
16
|
+
end
|
17
|
+
|
18
|
+
def build
|
19
|
+
Layout.new(self, @target_file).render
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
# 概览
|
24
|
+
def summary
|
25
|
+
@meta['summary']
|
26
|
+
end
|
27
|
+
|
28
|
+
# 标题
|
29
|
+
def title
|
30
|
+
@meta['title']
|
31
|
+
end
|
32
|
+
|
33
|
+
# 生成的链接
|
34
|
+
def url
|
35
|
+
if @draft
|
36
|
+
"posts/drafts/#{@base_name}/index.html"
|
37
|
+
else
|
38
|
+
"posts/#{@base_name}/index.html"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def link_to
|
43
|
+
"posts/#{@base_name}/"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'pathname'
|
3
|
+
require 'date'
|
4
|
+
require 'json'
|
5
|
+
require 'time'
|
6
|
+
|
7
|
+
module WriteDown
|
8
|
+
module Model
|
9
|
+
# 代表博文
|
10
|
+
class Post < Base
|
11
|
+
|
12
|
+
def render
|
13
|
+
template_file = File.expand_path('../../erb/post.erb', __FILE__)
|
14
|
+
template = File.read(template_file)
|
15
|
+
html_string = ERB.new(template).result(binding)
|
16
|
+
end
|
17
|
+
|
18
|
+
def build
|
19
|
+
Layout.new(self, @target_file).render
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
# 概览
|
24
|
+
def summary
|
25
|
+
@meta['summary']
|
26
|
+
end
|
27
|
+
|
28
|
+
# 标题
|
29
|
+
def title
|
30
|
+
@meta['title']
|
31
|
+
end
|
32
|
+
|
33
|
+
# 生成的链接
|
34
|
+
def url
|
35
|
+
if @draft
|
36
|
+
"posts/drafts/#{@base_name}/index.html"
|
37
|
+
else
|
38
|
+
"posts/#{@base_name}/index.html"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def link_to
|
43
|
+
"posts/#{@base_name}/"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'pandoc-ruby'
|
2
|
+
|
3
|
+
|
4
|
+
module WriteDown
|
5
|
+
module Model
|
6
|
+
class Slide < Base
|
7
|
+
|
8
|
+
def render
|
9
|
+
template = File.expand_path('../erb/slide.erb', __FILE__)
|
10
|
+
html_string = ERB.new(File.read(template)).result(binding)
|
11
|
+
end
|
12
|
+
|
13
|
+
def body
|
14
|
+
PandocRuby.convert(@content, { f: :org, to: :html5}, 'no-highlight')
|
15
|
+
end
|
16
|
+
|
17
|
+
def build
|
18
|
+
output = Pathname.new(@target_file)
|
19
|
+
output.dirname.mkpath
|
20
|
+
final_content = render
|
21
|
+
output.write(final_content)
|
22
|
+
self
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'qiniu'
|
2
|
+
|
3
|
+
class QiniuSync
|
4
|
+
|
5
|
+
def initialize(access_key, secret_key)
|
6
|
+
Qiniu.establish_connection! :access_key => access_key,
|
7
|
+
:secret_key => secret_key
|
8
|
+
|
9
|
+
@put_policy = Qiniu::Auth::PutPolicy.new(
|
10
|
+
bucket = "javaer"
|
11
|
+
)
|
12
|
+
|
13
|
+
# uptoken = Qiniu::Auth.generate_uptoken(put_policy)
|
14
|
+
end
|
15
|
+
|
16
|
+
def sync(local_file)
|
17
|
+
code, result, response_headers = Qiniu::Storage.upload_with_put_policy(
|
18
|
+
@put_policy,
|
19
|
+
local_file,
|
20
|
+
local_file.split("/")[2..-1].join("/").gsub!("assets/","assets/#{$assets_version}/")
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
data/lib/write_down/version.rb
CHANGED
data/lib/write_down.rb
CHANGED
@@ -1,37 +1,17 @@
|
|
1
1
|
require "write_down/version"
|
2
|
-
require "
|
3
|
-
require "
|
4
|
-
require "
|
5
|
-
require "write_down/
|
6
|
-
require "write_down/
|
7
|
-
require "write_down/
|
8
|
-
require "write_down/
|
9
|
-
require "write_down/
|
10
|
-
require "write_down/
|
2
|
+
require "write_down/model/asset.rb"
|
3
|
+
require "write_down/model/base.rb"
|
4
|
+
require "write_down/model/essay.rb"
|
5
|
+
require "write_down/model/layout.rb"
|
6
|
+
require "write_down/model/post.rb"
|
7
|
+
require "write_down/model/slide.rb"
|
8
|
+
require "write_down/model/container.rb"
|
9
|
+
require "write_down/model/page.rb"
|
10
|
+
require "write_down/converter/base.rb"
|
11
|
+
require "write_down/converter/markdown.rb"
|
12
|
+
require "write_down/converter/org.rb"
|
13
|
+
require "write_down/utils/qiniu_sync.rb"
|
11
14
|
|
12
15
|
module WriteDown
|
13
|
-
|
14
|
-
$site = Site.new
|
15
|
-
|
16
|
-
#just a demo
|
17
|
-
def self.hello
|
18
|
-
"hello! I am write down! Enjoy!"
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.build options
|
22
|
-
puts "generating by theme #{options[:theme]} ........"
|
23
|
-
#复制 html 模板到目标目录
|
24
|
-
FileUtils.cp_r File.expand_path("../template/#{options[:theme]}", File.dirname(__FILE__)) + '/.', options[:dist]
|
25
|
-
articles = Article.build options[:source]
|
26
|
-
Template.render options[:dist], articles
|
27
|
-
end
|
28
|
-
|
29
|
-
#定义一套步骤
|
30
|
-
def process
|
31
|
-
# 检查
|
32
|
-
# 初始化结构
|
33
|
-
# 渲染+填充
|
34
|
-
# 结束
|
35
|
-
end
|
36
|
-
|
16
|
+
# Your code goes here...
|
37
17
|
end
|
data/write_down.gemspec
CHANGED
@@ -6,21 +6,32 @@ require 'write_down/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "write_down"
|
8
8
|
spec.version = WriteDown::VERSION
|
9
|
-
spec.authors = ["
|
10
|
-
spec.email = ["
|
11
|
-
|
12
|
-
spec.summary = %q{
|
13
|
-
spec.
|
9
|
+
spec.authors = ["马陆骋"]
|
10
|
+
spec.email = ["malucheng@boohee.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Static Site render helper}
|
13
|
+
spec.description = %q{Static Site render helper}
|
14
|
+
spec.homepage = "http://javaer.me"
|
14
15
|
spec.license = "MIT"
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
28
|
spec.require_paths = ["lib"]
|
20
29
|
|
21
|
-
spec.add_development_dependency "bundler"
|
30
|
+
spec.add_development_dependency "bundler"
|
22
31
|
spec.add_development_dependency "rake"
|
23
|
-
spec.
|
24
|
-
|
25
|
-
spec.
|
32
|
+
spec.add_development_dependency "minitest"
|
33
|
+
|
34
|
+
spec.add_dependency "pandoc-ruby"
|
35
|
+
spec.add_dependency "front_matter_parser"
|
36
|
+
spec.add_dependency "qiniu"
|
26
37
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: write_down
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- "马陆骋"
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +39,21 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pandoc-ruby
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - ">="
|
@@ -53,7 +67,7 @@ dependencies:
|
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
70
|
+
name: front_matter_parser
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ">="
|
@@ -67,7 +81,7 @@ dependencies:
|
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
84
|
+
name: qiniu
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - ">="
|
@@ -80,100 +94,49 @@ dependencies:
|
|
80
94
|
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
|
-
description:
|
97
|
+
description: Static Site render helper
|
84
98
|
email:
|
85
|
-
-
|
99
|
+
- malucheng@boohee.com
|
86
100
|
executables:
|
87
101
|
- write_down
|
88
102
|
extensions: []
|
89
103
|
extra_rdoc_files: []
|
90
104
|
files:
|
91
105
|
- ".gitignore"
|
106
|
+
- ".travis.yml"
|
92
107
|
- Gemfile
|
93
108
|
- LICENSE.txt
|
94
109
|
- README.md
|
95
110
|
- Rakefile
|
96
|
-
- bin/
|
111
|
+
- bin/console
|
112
|
+
- bin/setup
|
113
|
+
- exe/write_down
|
97
114
|
- lib/write_down.rb
|
98
|
-
- lib/write_down/
|
99
|
-
- lib/write_down/
|
100
|
-
- lib/write_down/converter.rb
|
101
|
-
- lib/write_down/
|
102
|
-
- lib/write_down/
|
103
|
-
- lib/write_down/
|
104
|
-
- lib/write_down/
|
115
|
+
- lib/write_down/converter/base.rb
|
116
|
+
- lib/write_down/converter/markdown.rb
|
117
|
+
- lib/write_down/converter/org.rb
|
118
|
+
- lib/write_down/erb/container.erb
|
119
|
+
- lib/write_down/erb/essay.erb
|
120
|
+
- lib/write_down/erb/layout.erb
|
121
|
+
- lib/write_down/erb/page.erb
|
122
|
+
- lib/write_down/erb/post.erb
|
123
|
+
- lib/write_down/erb/slide.erb
|
124
|
+
- lib/write_down/model/asset.rb
|
125
|
+
- lib/write_down/model/base.rb
|
126
|
+
- lib/write_down/model/container.rb
|
127
|
+
- lib/write_down/model/essay.rb
|
128
|
+
- lib/write_down/model/layout.rb
|
129
|
+
- lib/write_down/model/page.rb
|
130
|
+
- lib/write_down/model/post.rb
|
131
|
+
- lib/write_down/model/slide.rb
|
132
|
+
- lib/write_down/utils/qiniu_sync.rb
|
105
133
|
- lib/write_down/version.rb
|
106
|
-
- template/emacs/404.html
|
107
|
-
- template/emacs/CHANGELOG.md
|
108
|
-
- template/emacs/CONTRIBUTING.md
|
109
|
-
- template/emacs/LICENSE.md
|
110
|
-
- template/emacs/README.md
|
111
|
-
- template/emacs/apple-touch-icon-precomposed.png
|
112
|
-
- template/emacs/crossdomain.xml
|
113
|
-
- template/emacs/css/custom.css
|
114
|
-
- template/emacs/css/main.css
|
115
|
-
- template/emacs/css/normalize.css
|
116
|
-
- template/emacs/favicon.ico
|
117
|
-
- template/emacs/humans.txt
|
118
|
-
- template/emacs/img/.gitignore
|
119
|
-
- template/emacs/index.html
|
120
|
-
- template/emacs/js/main.js
|
121
|
-
- template/emacs/js/plugins.js
|
122
|
-
- template/emacs/js/vendor/jquery-1.10.2.min.js
|
123
|
-
- template/emacs/js/vendor/modernizr-2.6.2.min.js
|
124
|
-
- template/emacs/post.html
|
125
|
-
- template/emacs/robots.txt
|
126
|
-
- template/simple/404.html
|
127
|
-
- template/simple/CNAME
|
128
|
-
- template/simple/README.md
|
129
|
-
- template/simple/_disqus.mustache
|
130
|
-
- template/simple/_footer.mustache
|
131
|
-
- template/simple/_header.mustache
|
132
|
-
- template/simple/apple-touch-icon-precomposed.png
|
133
|
-
- template/simple/crossdomain.xml
|
134
|
-
- template/simple/css/layout.css
|
135
|
-
- template/simple/css/main.css
|
136
|
-
- template/simple/css/normalize.css
|
137
|
-
- template/simple/favicon.ico
|
138
|
-
- template/simple/humans.txt
|
139
|
-
- template/simple/img/.gitignore
|
140
|
-
- template/simple/index.html
|
141
|
-
- template/simple/js/main.js
|
142
|
-
- template/simple/js/plugins.js
|
143
|
-
- template/simple/js/vendor/jquery-1.10.2.min.js
|
144
|
-
- template/simple/js/vendor/modernizr-2.6.2.min.js
|
145
|
-
- template/simple/post.html
|
146
|
-
- template/simple/robots.txt
|
147
|
-
- theme/ghost/assets/css/screen.css
|
148
|
-
- theme/ghost/index.html
|
149
|
-
- theme/ghost/post.html
|
150
|
-
- theme/html5-boilerplate/.gitattributes
|
151
|
-
- theme/html5-boilerplate/.gitignore
|
152
|
-
- theme/html5-boilerplate/.htaccess
|
153
|
-
- theme/html5-boilerplate/404.html
|
154
|
-
- theme/html5-boilerplate/CHANGELOG.md
|
155
|
-
- theme/html5-boilerplate/CONTRIBUTING.md
|
156
|
-
- theme/html5-boilerplate/LICENSE.md
|
157
|
-
- theme/html5-boilerplate/README.md
|
158
|
-
- theme/html5-boilerplate/apple-touch-icon-precomposed.png
|
159
|
-
- theme/html5-boilerplate/crossdomain.xml
|
160
|
-
- theme/html5-boilerplate/css/main.css
|
161
|
-
- theme/html5-boilerplate/css/normalize.css
|
162
|
-
- theme/html5-boilerplate/favicon.ico
|
163
|
-
- theme/html5-boilerplate/humans.txt
|
164
|
-
- theme/html5-boilerplate/img/.gitignore
|
165
|
-
- theme/html5-boilerplate/index.html
|
166
|
-
- theme/html5-boilerplate/js/main.js
|
167
|
-
- theme/html5-boilerplate/js/plugins.js
|
168
|
-
- theme/html5-boilerplate/js/vendor/jquery-1.10.2.min.js
|
169
|
-
- theme/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js
|
170
|
-
- theme/html5-boilerplate/post.html
|
171
|
-
- theme/html5-boilerplate/robots.txt
|
172
134
|
- write_down.gemspec
|
173
|
-
homepage:
|
135
|
+
homepage: http://javaer.me
|
174
136
|
licenses:
|
175
137
|
- MIT
|
176
|
-
metadata:
|
138
|
+
metadata:
|
139
|
+
allowed_push_host: https://rubygems.org
|
177
140
|
post_install_message:
|
178
141
|
rdoc_options: []
|
179
142
|
require_paths:
|
@@ -190,8 +153,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
153
|
version: '0'
|
191
154
|
requirements: []
|
192
155
|
rubyforge_project:
|
193
|
-
rubygems_version: 2.
|
156
|
+
rubygems_version: 2.4.5.1
|
194
157
|
signing_key:
|
195
158
|
specification_version: 4
|
196
|
-
summary:
|
159
|
+
summary: Static Site render helper
|
197
160
|
test_files: []
|
data/bin/write_down
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'optparse'
|
3
|
-
require "write_down"
|
4
|
-
|
5
|
-
options = {}
|
6
|
-
|
7
|
-
optparse = OptionParser.new do|opts|
|
8
|
-
|
9
|
-
# opts.banner= <<-BANNER "Usage: write_down -t the_theme_name -s the_posts_source -d the_generated_dist"
|
10
|
-
opts.banner= <<-BANNER
|
11
|
-
yet another static blog generator
|
12
|
-
|
13
|
-
Usage: write_down -t the_theme_name -s the_posts_source -d the_generated_dist
|
14
|
-
|
15
|
-
BANNER
|
16
|
-
|
17
|
-
# Define the options, and what they do
|
18
|
-
options[:theme] = 'simple'
|
19
|
-
opts.on("-t theme", "the theme name") do |theme|
|
20
|
-
options[:theme] = theme
|
21
|
-
end
|
22
|
-
|
23
|
-
# Create a flag
|
24
|
-
opts.on("-s source", "the posts source") do |source|
|
25
|
-
options[:source] = source
|
26
|
-
end
|
27
|
-
|
28
|
-
opts.on("-d dist", "the generated dist") do |dist|
|
29
|
-
options[:dist] = dist
|
30
|
-
end
|
31
|
-
|
32
|
-
# # This displays the help screen, all programs are
|
33
|
-
# # assumed to have this option.
|
34
|
-
opts.on( '-h', '--help', 'Display this screen' ) do
|
35
|
-
puts opts
|
36
|
-
exit
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
optparse.parse!
|
41
|
-
# puts options.inspect
|
42
|
-
|
43
|
-
WriteDown.build options
|
data/lib/write_down/article.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
module WriteDown
|
2
|
-
class Article
|
3
|
-
attr_accessor :title, :content, :link, :created_at, :updated_at, :file_name, :series
|
4
|
-
# link 可以是 uri, 或者其他 ID, 总之是一个资源的唯一定位符
|
5
|
-
|
6
|
-
|
7
|
-
#返回 article 对象的集合
|
8
|
-
def self.build source_folder
|
9
|
-
articles = Array.new
|
10
|
-
|
11
|
-
Dir.foreach(source_folder) do |file|
|
12
|
-
unless file.to_s.start_with?"." #排除.开头的文件
|
13
|
-
begin
|
14
|
-
file_path = "#{source_folder}/#{file}"
|
15
|
-
f = File.new(file_path,"r")
|
16
|
-
if File.directory?(f) #是目录
|
17
|
-
series = Series.new
|
18
|
-
series.name = File.basename(file_path) #系列的名字就是文件夹的名字
|
19
|
-
|
20
|
-
Dir.foreach(f) do |sub_f|
|
21
|
-
unless sub_f.to_s.start_with?"." #排除.开头的文件
|
22
|
-
file_path = "#{f.path}/#{sub_f}"
|
23
|
-
article = Article.new
|
24
|
-
article.build_from_file file_path
|
25
|
-
articles << article #所有的文章集合
|
26
|
-
series.articles << article #某个系列的文章集合
|
27
|
-
end
|
28
|
-
end
|
29
|
-
$site.series << series
|
30
|
-
else #最外层的文章
|
31
|
-
article = Article.new
|
32
|
-
article.build_from_file f
|
33
|
-
articles << article
|
34
|
-
end
|
35
|
-
rescue => err
|
36
|
-
puts "build from source folder error: #{err}"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
articles
|
42
|
-
end
|
43
|
-
|
44
|
-
def build_from_file file_path
|
45
|
-
basename = File.basename(file_path)
|
46
|
-
file = File.new(file_path)
|
47
|
-
file_content = file.read #读取所有内容
|
48
|
-
html_content = Converter.convert_markdown file_content #转成 html 了
|
49
|
-
puts self
|
50
|
-
self.content = html_content
|
51
|
-
self.file_name = basename #文件名
|
52
|
-
self.link = basename.chomp(File.extname(file_path)) + ".html" #链接形式以后要改
|
53
|
-
self.title = self.get_title #读取合适的 title
|
54
|
-
self.created_at = file.ctime
|
55
|
-
self.updated_at = file.mtime
|
56
|
-
file.close
|
57
|
-
end
|
58
|
-
|
59
|
-
def get_title
|
60
|
-
doc = Nokogiri::HTML(self.content)
|
61
|
-
doc.css('h1').first.content ||= self.file_name
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
data/lib/write_down/converter.rb
DELETED
data/lib/write_down/page.rb
DELETED