write_down 0.0.5 → 0.2.0

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.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +9 -21
  3. data/.travis.yml +4 -0
  4. data/Gemfile +1 -1
  5. data/LICENSE.txt +17 -18
  6. data/README.md +20 -8
  7. data/Rakefile +9 -0
  8. data/bin/console +14 -0
  9. data/bin/setup +7 -0
  10. data/exe/write_down +3 -0
  11. data/lib/write_down/converter/base.rb +18 -0
  12. data/lib/write_down/converter/markdown.rb +18 -0
  13. data/lib/write_down/converter/org.rb +18 -0
  14. data/lib/write_down/erb/container.erb +19 -0
  15. data/lib/write_down/erb/essay.erb +5 -0
  16. data/lib/write_down/erb/layout.erb +64 -0
  17. data/lib/write_down/erb/page.erb +4 -0
  18. data/lib/write_down/erb/post.erb +5 -0
  19. data/lib/write_down/erb/slide.erb +79 -0
  20. data/lib/write_down/model/asset.rb +36 -0
  21. data/lib/write_down/model/base.rb +63 -0
  22. data/lib/write_down/model/container.rb +35 -0
  23. data/lib/write_down/model/essay.rb +35 -0
  24. data/lib/write_down/model/layout.rb +75 -0
  25. data/lib/write_down/model/page.rb +47 -0
  26. data/lib/write_down/model/post.rb +47 -0
  27. data/lib/write_down/model/slide.rb +27 -0
  28. data/lib/write_down/utils/qiniu_sync.rb +23 -0
  29. data/lib/write_down/version.rb +1 -1
  30. data/lib/write_down.rb +13 -33
  31. data/write_down.gemspec +23 -12
  32. metadata +54 -91
  33. data/bin/write_down +0 -43
  34. data/lib/write_down/article.rb +0 -64
  35. data/lib/write_down/configuration.rb +0 -6
  36. data/lib/write_down/converter.rb +0 -8
  37. data/lib/write_down/page.rb +0 -6
  38. data/lib/write_down/series.rb +0 -10
  39. data/lib/write_down/site.rb +0 -10
  40. data/lib/write_down/template.rb +0 -20
  41. data/template/emacs/404.html +0 -157
  42. data/template/emacs/CHANGELOG.md +0 -133
  43. data/template/emacs/CONTRIBUTING.md +0 -154
  44. data/template/emacs/LICENSE.md +0 -19
  45. data/template/emacs/README.md +0 -1
  46. data/template/emacs/apple-touch-icon-precomposed.png +0 -0
  47. data/template/emacs/crossdomain.xml +0 -15
  48. data/template/emacs/css/custom.css +0 -18
  49. data/template/emacs/css/main.css +0 -304
  50. data/template/emacs/css/normalize.css +0 -527
  51. data/template/emacs/favicon.ico +0 -0
  52. data/template/emacs/humans.txt +0 -15
  53. data/template/emacs/img/.gitignore +0 -0
  54. data/template/emacs/index.html +0 -62
  55. data/template/emacs/js/main.js +0 -1
  56. data/template/emacs/js/plugins.js +0 -24
  57. data/template/emacs/js/vendor/jquery-1.10.2.min.js +0 -6
  58. data/template/emacs/js/vendor/modernizr-2.6.2.min.js +0 -4
  59. data/template/emacs/post.html +0 -80
  60. data/template/emacs/robots.txt +0 -3
  61. data/template/simple/404.html +0 -157
  62. data/template/simple/CNAME +0 -1
  63. data/template/simple/README.md +0 -1
  64. data/template/simple/_disqus.mustache +0 -19
  65. data/template/simple/_footer.mustache +0 -28
  66. data/template/simple/_header.mustache +0 -38
  67. data/template/simple/apple-touch-icon-precomposed.png +0 -0
  68. data/template/simple/crossdomain.xml +0 -15
  69. data/template/simple/css/layout.css +0 -72
  70. data/template/simple/css/main.css +0 -304
  71. data/template/simple/css/normalize.css +0 -527
  72. data/template/simple/favicon.ico +0 -0
  73. data/template/simple/humans.txt +0 -15
  74. data/template/simple/img/.gitignore +0 -0
  75. data/template/simple/index.html +0 -12
  76. data/template/simple/js/main.js +0 -1
  77. data/template/simple/js/plugins.js +0 -24
  78. data/template/simple/js/vendor/jquery-1.10.2.min.js +0 -6
  79. data/template/simple/js/vendor/modernizr-2.6.2.min.js +0 -4
  80. data/template/simple/post.html +0 -9
  81. data/template/simple/robots.txt +0 -3
  82. data/theme/ghost/assets/css/screen.css +0 -911
  83. data/theme/ghost/index.html +0 -75
  84. data/theme/ghost/post.html +0 -112
  85. data/theme/html5-boilerplate/.gitattributes +0 -1
  86. data/theme/html5-boilerplate/.gitignore +0 -2
  87. data/theme/html5-boilerplate/.htaccess +0 -551
  88. data/theme/html5-boilerplate/404.html +0 -157
  89. data/theme/html5-boilerplate/CHANGELOG.md +0 -133
  90. data/theme/html5-boilerplate/CONTRIBUTING.md +0 -154
  91. data/theme/html5-boilerplate/LICENSE.md +0 -19
  92. data/theme/html5-boilerplate/README.md +0 -61
  93. data/theme/html5-boilerplate/apple-touch-icon-precomposed.png +0 -0
  94. data/theme/html5-boilerplate/crossdomain.xml +0 -15
  95. data/theme/html5-boilerplate/css/main.css +0 -297
  96. data/theme/html5-boilerplate/css/normalize.css +0 -527
  97. data/theme/html5-boilerplate/favicon.ico +0 -0
  98. data/theme/html5-boilerplate/humans.txt +0 -15
  99. data/theme/html5-boilerplate/img/.gitignore +0 -0
  100. data/theme/html5-boilerplate/index.html +0 -91
  101. data/theme/html5-boilerplate/js/main.js +0 -1
  102. data/theme/html5-boilerplate/js/plugins.js +0 -24
  103. data/theme/html5-boilerplate/js/vendor/jquery-1.10.2.min.js +0 -6
  104. data/theme/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js +0 -4
  105. data/theme/html5-boilerplate/post.html +0 -70
  106. 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
@@ -1,3 +1,3 @@
1
1
  module WriteDown
2
- VERSION = "0.0.5"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/write_down.rb CHANGED
@@ -1,37 +1,17 @@
1
1
  require "write_down/version"
2
- require "minidown"
3
- require "mustache"
4
- require "nokogiri"
5
- require "write_down/article"
6
- require "write_down/converter"
7
- require "write_down/template"
8
- require "write_down/series"
9
- require "write_down/site"
10
- require "write_down/page"
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 = ["Ma Lucheng"]
10
- spec.email = ["mlc880926@gmail.com"]
11
- spec.description = %q{yet another static blog generator}
12
- spec.summary = %q{yet another static blog generator}
13
- spec.homepage = ""
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
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
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", "~> 1.3"
30
+ spec.add_development_dependency "bundler"
22
31
  spec.add_development_dependency "rake"
23
- spec.add_runtime_dependency "minidown"
24
- spec.add_runtime_dependency "mustache"
25
- spec.add_runtime_dependency 'nokogiri'
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.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Ma Lucheng
7
+ - "马陆骋"
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2014-02-21 00:00:00.000000000 Z
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: '1.3'
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: '1.3'
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: minidown
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: mustache
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: nokogiri
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: yet another static blog generator
97
+ description: Static Site render helper
84
98
  email:
85
- - mlc880926@gmail.com
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/write_down
111
+ - bin/console
112
+ - bin/setup
113
+ - exe/write_down
97
114
  - lib/write_down.rb
98
- - lib/write_down/article.rb
99
- - lib/write_down/configuration.rb
100
- - lib/write_down/converter.rb
101
- - lib/write_down/page.rb
102
- - lib/write_down/series.rb
103
- - lib/write_down/site.rb
104
- - lib/write_down/template.rb
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.2.0.rc.1
156
+ rubygems_version: 2.4.5.1
194
157
  signing_key:
195
158
  specification_version: 4
196
- summary: yet another static blog generator
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
@@ -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
@@ -1,6 +0,0 @@
1
- module WriteDown
2
- class Configuration
3
- #常用固定值
4
- #其余hash
5
- end
6
- end
@@ -1,8 +0,0 @@
1
- module WriteDown
2
- class Converter
3
- #转换 markdown(引擎在这里更换)
4
- def self.convert_markdown markdown_content
5
- html = Minidown.render(markdown_content)
6
- end
7
- end
8
- end
@@ -1,6 +0,0 @@
1
- module WriteDown
2
- class Page
3
- attr_accessor :title, :keyword, :description
4
- #单一页面的变量, 可以包含比 article 更多的东西, 比如侧边栏之类的或者插件
5
- end
6
- end
@@ -1,10 +0,0 @@
1
- module WriteDown
2
- class Series
3
- attr_accessor :name, :articles
4
- #artcile 的集合
5
-
6
- def initialize
7
- self.articles = Array.new
8
- end
9
- end
10
- end