docwu 0.0.14 → 0.0.15
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/lib/docwu/config.rb +4 -0
- data/lib/docwu/folder.rb +1 -1
- data/lib/docwu/post.rb +1 -1
- data/lib/docwu/render.rb +7 -0
- data/lib/docwu/topic.rb +1 -1
- data/lib/docwu/version.rb +1 -1
- data/lib/docwu/worker.rb +26 -12
- data/lib/template_files/Gemfile +1 -1
- metadata +4 -4
data/lib/docwu/config.rb
CHANGED
data/lib/docwu/folder.rb
CHANGED
data/lib/docwu/post.rb
CHANGED
@@ -53,7 +53,7 @@ module Docwu
|
|
53
53
|
|
54
54
|
@path = "#{_filename_extless}.#{_extend_name}"
|
55
55
|
@url = "/#{@path}"
|
56
|
-
@dest = "#{self.worker.
|
56
|
+
@dest = "#{self.worker.tmp_deploy_path}/#{self.path}"
|
57
57
|
|
58
58
|
@file_name = ::Docwu::Utils.filename(_filename_extless)
|
59
59
|
|
data/lib/docwu/render.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'redcarpet'
|
3
3
|
require 'coderay'
|
4
4
|
require "nokogiri"
|
5
|
+
# require "pdfkit"
|
5
6
|
|
6
7
|
module Docwu
|
7
8
|
class Render
|
@@ -11,6 +12,12 @@ module Docwu
|
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
15
|
+
# 生成pdf
|
16
|
+
# https://github.com/pdfkit/PDFKit
|
17
|
+
# def generate_pdf options={}
|
18
|
+
# kit = ::PDFKit.new(::File.new(options[:dest]))
|
19
|
+
# end
|
20
|
+
|
14
21
|
#
|
15
22
|
# usage:
|
16
23
|
# ::Docwu::Render.generate(
|
data/lib/docwu/topic.rb
CHANGED
@@ -17,7 +17,7 @@ module Docwu
|
|
17
17
|
_filename_extless = ::Docwu::Utils.filename_extless(self.path)
|
18
18
|
|
19
19
|
@url = "/#{@path}"
|
20
|
-
@dest = "#{self.worker.
|
20
|
+
@dest = "#{self.worker.tmp_deploy_path}/#{self.path}"
|
21
21
|
|
22
22
|
@file_name = ::Docwu::Utils.filename(_filename_extless)
|
23
23
|
|
data/lib/docwu/version.rb
CHANGED
data/lib/docwu/worker.rb
CHANGED
@@ -3,10 +3,11 @@ require 'date'
|
|
3
3
|
module Docwu
|
4
4
|
class Worker
|
5
5
|
|
6
|
-
attr_reader :layouts, :data, :deploy_path, :folders, :topics
|
6
|
+
attr_reader :layouts, :data, :deploy_path, :folders, :topics, :tmp_path
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
@deploy_path = ::Docwu.config.deploy_path # 部署路径
|
10
|
+
@tmp_path = ::Docwu.config.tmp_path
|
10
11
|
|
11
12
|
@data = {
|
12
13
|
'worker' => {
|
@@ -69,24 +70,37 @@ module Docwu
|
|
69
70
|
# 输出:
|
70
71
|
# TODO: 先生成临时目录, 然后 -> deploy
|
71
72
|
def generate
|
72
|
-
|
73
|
-
|
74
|
-
|
73
|
+
begin
|
74
|
+
# 删除要输出的路径
|
75
|
+
FileUtils.mkdir_p(self.tmp_deploy_path)
|
75
76
|
|
76
|
-
|
77
|
+
::Docwu::Utils.cp_r("#{plain_path('/assets')}", "#{self.tmp_deploy_path}/assets")
|
77
78
|
|
78
|
-
|
79
|
-
|
79
|
+
# 复制静态文件里去
|
80
|
+
::Docwu::Utils.cp_r("#{plain_path('/static')}", "#{self.tmp_deploy_path}/static")
|
80
81
|
|
81
|
-
|
82
|
-
|
83
|
-
|
82
|
+
self.folders.each do |folder|
|
83
|
+
folder.generate
|
84
|
+
end
|
85
|
+
|
86
|
+
self.topics.each do |topic|
|
87
|
+
topic.generate
|
88
|
+
end
|
84
89
|
|
85
|
-
|
86
|
-
|
90
|
+
rescue Exception => exception
|
91
|
+
FileUtils.rm_rf(self.tmp_deploy_path)
|
92
|
+
raise "#{exception}"
|
93
|
+
else
|
94
|
+
FileUtils.rm_rf(self.deploy_path)
|
95
|
+
FileUtils.mv(self.tmp_deploy_path, self.deploy_path)
|
96
|
+
ensure
|
87
97
|
end
|
88
98
|
end
|
89
99
|
|
100
|
+
def tmp_deploy_path
|
101
|
+
@tmp_deploy_path ||= "#{self.tmp_path}/_deploy/#{Time.now.to_i}"
|
102
|
+
end
|
103
|
+
|
90
104
|
def plain_path(path)
|
91
105
|
"#{::Docwu.config.workspace}#{path}"
|
92
106
|
end
|
data/lib/template_files/Gemfile
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docwu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redcarpet
|
@@ -154,7 +154,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
154
|
version: '0'
|
155
155
|
segments:
|
156
156
|
- 0
|
157
|
-
hash:
|
157
|
+
hash: -2459986803963416847
|
158
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
159
|
none: false
|
160
160
|
requirements:
|
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
163
|
version: '0'
|
164
164
|
segments:
|
165
165
|
- 0
|
166
|
-
hash:
|
166
|
+
hash: -2459986803963416847
|
167
167
|
requirements: []
|
168
168
|
rubyforge_project:
|
169
169
|
rubygems_version: 1.8.25
|