publican_creators 1.2.0 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,58 +1,58 @@
1
- # Copyright (C) 2013-2017 Sascha Manns <Sascha.Manns@mailbox.org>
2
- #
3
- # This program is free software: you can redistribute it and/or modify
4
- # it under the terms of the GNU General Public License as published by
5
- # the Free Software Foundation, either version 3 of the License, or
6
- # (at your option) any later version.
7
- #
8
- # This program is distributed in the hope that it will be useful,
9
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- # GNU General Public License for more details.
12
- #
13
- # You should have received a copy of the GNU General Public License
14
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
-
16
- # Dependencies
17
-
18
- require 'fileutils'
19
- require 'rainbow/ext/string'
20
-
21
- # Module for different checks
22
- module Checker
23
- # Checks if the targetdirectory are present. If not, it creates one. It
24
- # returns a success or fail.
25
- # @param [String] todos contains the target directory
26
- # @return [String] true or false
27
- def self.check_dir(todos)
28
- # @note Checking if dir exists
29
- # TODO: Try to fix this in future
30
- # rubocop:disable Style/GuardClause
31
- if Dir.exist?(todos)
32
- puts 'Found directory. Im using it.'
33
- else
34
- puts 'No directory found. Im creating it.'
35
- # @note Creates the new directory
36
- FileUtils.mkdir_p(todos)
37
- if Dir.exist?(todos)
38
- puts 'Created new directory...'
39
- else
40
- raise('Cant create directory')
41
- end
42
- end
43
- end
44
-
45
- # This method will be launched from the init_docu_* methods. It returns a
46
- # success, otherwise it raises with a error.
47
- # @param [String] title comes from the get method. This @param represents the
48
- # name or title of your work. It is used in all important code places.
49
- # @return [String] true or false
50
- def self.check_result(title)
51
- # @note checking if new documentation directory exists
52
- if Dir.exist?(title)
53
- puts 'Creating documentation was a success...'
54
- else
55
- raise('Cant create documentation. Please try it manual with publican...')
56
- end
57
- end
58
- end
1
+ # Copyright (C) 2013-2018 Sascha Manns <Sascha.Manns@outlook.de>
2
+ #
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ # Dependencies
17
+
18
+ require 'fileutils'
19
+ require 'rainbow/ext/string'
20
+
21
+ # Module for different checks
22
+ module Checker
23
+ # Checks if the targetdirectory are present. If not, it creates one. It
24
+ # returns a success or fail.
25
+ # @param [String] todos contains the target directory
26
+ # @return [String] true or false
27
+ def self.check_dir(todos)
28
+ # @note Checking if dir exists
29
+ # TODO: Try to fix this in future
30
+ # rubocop:disable Style/GuardClause
31
+ if Dir.exist?(todos)
32
+ puts 'Found directory. Im using it.'
33
+ else
34
+ puts 'No directory found. Im creating it.'
35
+ # @note Creates the new directory
36
+ FileUtils.mkdir_p(todos)
37
+ if Dir.exist?(todos)
38
+ puts 'Created new directory...'
39
+ else
40
+ raise('Cant create directory')
41
+ end
42
+ end
43
+ end
44
+
45
+ # This method will be launched from the init_docu_* methods. It returns a
46
+ # success, otherwise it raises with a error.
47
+ # @param [String] title comes from the get method. This @param represents the
48
+ # name or title of your work. It is used in all important code places.
49
+ # @return [String] true or false
50
+ def self.check_result(title)
51
+ # @note checking if new documentation directory exists
52
+ if Dir.exist?(title)
53
+ puts 'Creating documentation was a success...'
54
+ else
55
+ raise('Cant create documentation. Please try it manual with publican...')
56
+ end
57
+ end
58
+ end
@@ -1,131 +1,131 @@
1
- # Copyright (C) 2013-2017 Sascha Manns <Sascha.Manns@mailbox.org>
2
- #
3
- # This program is free software: you can redistribute it and/or modify
4
- # it under the terms of the GNU General Public License as published by
5
- # the Free Software Foundation, either version 3 of the License, or
6
- # (at your option) any later version.
7
- #
8
- # This program is distributed in the hope that it will be useful,
9
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- # GNU General Public License for more details.
12
- #
13
- # You should have received a copy of the GNU General Public License
14
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
-
16
- # Dependencies
17
- require 'nokogiri'
18
- require_relative 'checker'
19
-
20
- # Class for creating stuff
21
- class PublicanCreatorsCreate
22
- # Method for creating initial documentation for work. It asks for title, type,
23
- # language, brand and db5 variable, creates a launch-string from them and
24
- # launches publican.
25
- # @param [String] title comes from the get method. This @param represents the
26
- # name or title of your work. It is used in all important code
27
- # places.
28
- # @param [String] type represents the Document-Type like Article or Book.
29
- # @param [String] language is just the ISO Code of your target language like:
30
- # de-DE, en-GB or such things.
31
- # @param [String] brand can be a special customized brand for your company to
32
- # fit the styleguide.
33
- # @param [String] db5 just sets your preferences. If you like to have DocBook
34
- # 5.x as default you can set it there.
35
- # @return [String] true or false
36
- # @note That method returns just a success or a fail. After the main part of
37
- # the method it starts another method "PublicanCreatorsChange.check_result".
38
- # This method checks if the directory with the content of the parameter title
39
- # is available.
40
- def self.init_docu_work(title, type, language, brand, db5)
41
- puts 'Creating initial documentation ...'
42
- # Set standard string
43
- string = "--lang #{language} --name #{title}"
44
- # Add Article if type is Article
45
- string << ' --type Article' if type == 'Article'
46
- # Set business brand if given
47
- string << " --brand #{brand}" if brand != ''
48
- # @note Check if DocBook 5 wished as default, if yes it adds the parameter
49
- # dtdver 5.0 to string
50
- string << ' --dtdver 5.0' if db5 == 'true'
51
- create_docu(string, title)
52
- end
53
-
54
- # Method for creating initial documentation for private. It asks for title,
55
- # type, language, homework, brand_homework, brand_private
56
- # and db5 variable, creates a launch-string from them and launches publican.
57
- # @param [String] title comes from the get method. This parameter represents
58
- # the name or title of your work. It is used in all
59
- # important code places.
60
- # @param [String] type represents the Document-Type like Article or Book.
61
- # @param [String] homework can be true or false
62
- # @param [String] brand_private is used in all methods with a "private" in the
63
- # name. If this brand is set it will be used instead of
64
- # the original publican brand.
65
- # @param [String] language is just the ISO Code of your target language like:
66
- # de-DE, en-GB or such things.
67
- # @param [String] brand_homework can be a special customized brand for
68
- # distance learning schools.
69
- # @param [String] db5 just sets your preferences. If you like to have DocBook
70
- # 5.x as default you can set it there.
71
- # @return [String] true or false
72
- # @note That method returns just a success or a fail. After the main part of
73
- # the method it starts another method "PublicanCreatorsChange.check_result".
74
- # This method checks if the directory with the content of the parameter title
75
- # is available.
76
- def self.init_docu_private(title, type, homework, language, brand_homework, brand_private, db5)
77
- puts 'Creating initial documentation ...'
78
-
79
- if type == 'Article'
80
- string = private_article(language, title, brand_private,
81
- brand_homework, homework)
82
- else
83
- # @note Initial creation of documentation with publican
84
- string = "--lang #{language} --name #{title}"
85
- string << " --brand #{brand_private}" if brand_private != ''
86
- end
87
- # @note Check if DocBook 5 wished as default, if yes it adds the parameter
88
- # dtdver 5.0 to string
89
- string << ' --dtdver 5.0' if db5 == 'true'
90
- create_docu(string, title)
91
- end
92
-
93
- # Method for preparing the string for private articles
94
- # @param [String] language is just the ISO Code of your target language like:
95
- # de-DE, en-GB or such things.
96
- # @param [String] title comes from the get method. This parameter represents
97
- # the name or title of your work. It is used in all
98
- # important code places.
99
- # @param [String] brand_private is used in all methods with a "private" in the
100
- # name. If this brand is set it will be used instead of
101
- # the original publican brand.
102
- # @param [String] brand_homework can be a special customized brand for
103
- # distance learning schools.
104
- # @param [String] homework true if homework set
105
- def self.private_article(language, title, brand_private, brand_homework, homework)
106
- # @note Initial creation of documentation with publican
107
- string = "--type Article --lang #{language} --name #{title}"
108
- # Use brand_private if brand_private is set
109
- if brand_private != '' && homework == 'FALSE'
110
- string << " --brand #{brand_private}"
111
- end
112
- # Use brand_homework if its set
113
- if brand_homework != '' && homework == 'TRUE'
114
- string << " --brand #{brand_homework}"
115
- end
116
- return string
117
- end
118
-
119
- # This method uses the input of init_docu methods to create the documentation
120
- # @param [String] string This input comes from init_docu
121
- # @param [String] title comes from the get method. This param represents the
122
- # name or title of your work. It is used in all important
123
- # code places.
124
- # @return [String] true or false
125
- def self.create_docu(string, title)
126
- system("publican create #{string}")
127
- # @param [String] title comes from the get method. This param represents
128
- # the name or title of your work. It is used in all important code places.
129
- Checker.check_result(title)
130
- end
131
- end
1
+ # Copyright (C) 2013-2018 Sascha Manns <Sascha.Manns@outlook.de>
2
+ #
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ # Dependencies
17
+ require 'nokogiri'
18
+ require_relative 'checker'
19
+
20
+ # Class for creating stuff
21
+ class PublicanCreatorsCreate
22
+ # Method for creating initial documentation for work. It asks for title, type,
23
+ # language, brand and db5 variable, creates a launch-string from them and
24
+ # launches publican.
25
+ # @param [String] title comes from the get method. This @param represents the
26
+ # name or title of your work. It is used in all important code
27
+ # places.
28
+ # @param [String] type represents the Document-Type like Article or Book.
29
+ # @param [String] language is just the ISO Code of your target language like:
30
+ # de-DE, en-GB or such things.
31
+ # @param [String] brand can be a special customized brand for your company to
32
+ # fit the styleguide.
33
+ # @param [String] db5 just sets your preferences. If you like to have DocBook
34
+ # 5.x as default you can set it there.
35
+ # @return [String] true or false
36
+ # @note That method returns just a success or a fail. After the main part of
37
+ # the method it starts another method "PublicanCreatorsChange.check_result".
38
+ # This method checks if the directory with the content of the parameter title
39
+ # is available.
40
+ def self.init_docu_work(title, type, language, brand, db5)
41
+ puts 'Creating initial documentation ...'
42
+ # Set standard string
43
+ string = "--lang #{language} --name #{title}"
44
+ # Add Article if type is Article
45
+ string << ' --type Article' if type == 'Article'
46
+ # Set business brand if given
47
+ string << " --brand #{brand}" if brand != ''
48
+ # @note Check if DocBook 5 wished as default, if yes it adds the parameter
49
+ # dtdver 5.0 to string
50
+ string << ' --dtdver 5.0' if db5 == 'true'
51
+ create_docu(string, title)
52
+ end
53
+
54
+ # Method for creating initial documentation for private. It asks for title,
55
+ # type, language, homework, brand_homework, brand_private
56
+ # and db5 variable, creates a launch-string from them and launches publican.
57
+ # @param [String] title comes from the get method. This parameter represents
58
+ # the name or title of your work. It is used in all
59
+ # important code places.
60
+ # @param [String] type represents the Document-Type like Article or Book.
61
+ # @param [String] homework can be true or false
62
+ # @param [String] brand_private is used in all methods with a "private" in the
63
+ # name. If this brand is set it will be used instead of
64
+ # the original publican brand.
65
+ # @param [String] language is just the ISO Code of your target language like:
66
+ # de-DE, en-GB or such things.
67
+ # @param [String] brand_homework can be a special customized brand for
68
+ # distance learning schools.
69
+ # @param [String] db5 just sets your preferences. If you like to have DocBook
70
+ # 5.x as default you can set it there.
71
+ # @return [String] true or false
72
+ # @note That method returns just a success or a fail. After the main part of
73
+ # the method it starts another method "PublicanCreatorsChange.check_result".
74
+ # This method checks if the directory with the content of the parameter title
75
+ # is available.
76
+ def self.init_docu_private(title, type, homework, language, brand_homework, brand_private, db5)
77
+ puts 'Creating initial documentation ...'
78
+
79
+ if type == 'Article'
80
+ string = private_article(language, title, brand_private,
81
+ brand_homework, homework)
82
+ else
83
+ # @note Initial creation of documentation with publican
84
+ string = "--lang #{language} --name #{title}"
85
+ string << " --brand #{brand_private}" if brand_private != ''
86
+ end
87
+ # @note Check if DocBook 5 wished as default, if yes it adds the parameter
88
+ # dtdver 5.0 to string
89
+ string << ' --dtdver 5.0' if db5 == 'true'
90
+ create_docu(string, title)
91
+ end
92
+
93
+ # Method for preparing the string for private articles
94
+ # @param [String] language is just the ISO Code of your target language like:
95
+ # de-DE, en-GB or such things.
96
+ # @param [String] title comes from the get method. This parameter represents
97
+ # the name or title of your work. It is used in all
98
+ # important code places.
99
+ # @param [String] brand_private is used in all methods with a "private" in the
100
+ # name. If this brand is set it will be used instead of
101
+ # the original publican brand.
102
+ # @param [String] brand_homework can be a special customized brand for
103
+ # distance learning schools.
104
+ # @param [String] homework true if homework set
105
+ def self.private_article(language, title, brand_private, brand_homework, homework)
106
+ # @note Initial creation of documentation with publican
107
+ string = "--type Article --lang #{language} --name #{title}"
108
+ # Use brand_private if brand_private is set
109
+ if brand_private != '' && homework == 'FALSE'
110
+ string << " --brand #{brand_private}"
111
+ end
112
+ # Use brand_homework if its set
113
+ if brand_homework != '' && homework == 'TRUE'
114
+ string << " --brand #{brand_homework}"
115
+ end
116
+ return string
117
+ end
118
+
119
+ # This method uses the input of init_docu methods to create the documentation
120
+ # @param [String] string This input comes from init_docu
121
+ # @param [String] title comes from the get method. This param represents the
122
+ # name or title of your work. It is used in all important
123
+ # code places.
124
+ # @return [String] true or false
125
+ def self.create_docu(string, title)
126
+ system("publican create #{string}")
127
+ # @param [String] title comes from the get method. This param represents
128
+ # the name or title of your work. It is used in all important code places.
129
+ Checker.check_result(title)
130
+ end
131
+ end
@@ -1,236 +1,236 @@
1
- # Copyright (C) 2013-2017 Sascha Manns <Sascha.Manns@mailbox.org>
2
- #
3
- # This program is free software: you can redistribute it and/or modify
4
- # it under the terms of the GNU General Public License as published by
5
- # the Free Software Foundation, either version 3 of the License, or
6
- # (at your option) any later version.
7
- #
8
- # This program is distributed in the hope that it will be useful,
9
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- # GNU General Public License for more details.
12
- #
13
- # You should have received a copy of the GNU General Public License
14
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
-
16
- # Dependencies
17
-
18
- require_relative 'change'
19
- require 'fileutils'
20
- require 'rainbow/ext/string'
21
- # Module for running exports to a file
22
- module PublicanCreatorsExport
23
- # Exports a predefined Shellscript to the target directory.
24
- # It returns a sucess or fail.
25
- # Description:
26
- # @param [String] title comes from the get method. This parameter represents
27
- # the name or title of your work. It is used in all important
28
- # code places.
29
- # @param [String] builds is the path to your buildscript
30
- # @param [String] language is just the ISO Code of your target language
31
- # like: en-GB or such things.
32
- # @param [String] xfc_brand_dir if present the path to your branded xfc
33
- # stylesheets (config file)
34
- # @param [String] pdfview your prefered PDF-Viewer (config file)
35
- # @return [String] true or false
36
- def self.export_buildscript(title, builds, language, xfc_brand_dir, pdfview)
37
- puts 'Export the buildscript into new directory...'
38
- FileUtils.touch builds.to_s
39
- # rubocop:disable Layout/IndentHeredoc
40
- File.write builds.to_s, <<BUILDSCRIPT
41
- # -*- ruby -*-
42
- # encoding: utf-8
43
- require 'fileutils'
44
-
45
- task :default do
46
- puts 'usage: rake [export_docx] [export_odt] [export_rtf] [export_wml] [export_pdf] [export_html] [export_man] [export_txt] [export_txt] [export_epub]'
47
- puts
48
- puts 'Options:'
49
- puts 'export_docx : Export DocBook source to DOCX'
50
- puts ' Example: rake export_docx'
51
- puts 'export_odt : Export DocBook source to ODT'
52
- puts ' Example: rake export_odt'
53
- puts 'export_rtf : Export DocBook source to RTF'
54
- puts ' Example: rake export_rtf'
55
- puts 'export_wml: Export DocBook source to WML'
56
- puts ' Example: rake export_wml'
57
- puts 'export_pdf: Export Docbook source to PDF'
58
- puts ' Example: rake export_pdf'
59
- puts 'export_html: Export DocBook source to HTML'
60
- puts ' Example: rake export_html'
61
- puts 'export_man: Export DocBook source to MAN'
62
- puts ' Example: rake export_man'
63
- puts 'export_txt: Export DocBook source to TXT'
64
- puts ' Example: rake export_txt'
65
- puts 'export_epub: Export DocBook source to EPUB'
66
- puts ' Example: rake export_epub'
67
- puts 'export_eclipse: Export DocBook source to Eclipse Help'
68
- puts ' Example: rake export_eclipse'
69
- end
70
-
71
- require 'dir'
72
- require 'fileutils'
73
- desc 'Checks if temp dir is available. Otherwise it creates it'
74
- task :checker do
75
- todos = "../tmp/#{language}/docx"
76
- if Dir.exist?(todos)
77
- puts 'Found directory. Im using it.'
78
- else
79
- puts 'No directory found. Im creating it.'
80
- FileUtils.mkdir_p(todos)
81
- end
82
- todos = "../tmp/#{language}/odt"
83
- if Dir.exist?(todos)
84
- puts 'Found directory. Im using it.'
85
- else
86
- puts 'No directory found. Im creating it.'
87
- FileUtils.mkdir_p(todos)
88
- end
89
- todos = "../tmp/#{language}/rtf"
90
- if Dir.exist?(todos)
91
- puts 'Found directory. Im using it.'
92
- else
93
- puts 'No directory found. Im creating it.'
94
- FileUtils.mkdir_p(todos)
95
- end
96
- todos = "../tmp/#{language}/wml"
97
- if Dir.exist?(todos)
98
- puts 'Found directory. Im using it.'
99
- else
100
- puts 'No directory found. Im creating it.'
101
- FileUtils.mkdir_p(todos)
102
- end
103
- end
104
-
105
- desc 'Convert to DOCX'
106
- task :export_docx => [:checker] do
107
- puts 'Resolving all XML-Entities and XI-Includes'
108
- system("xmllint --noent --dropdtd --xinclude #{title}.xml -o #{title}-resolved.xml")
109
- puts 'Formatting XML to XSL-FO'
110
- system("saxon-xslt -o #{title}.fo #{title}-resolved.xml #{xfc_brand_dir}")
111
- puts 'Removing temporary resolved file'
112
- FileUtils.rm('#{title}-resolved.xml')
113
- puts 'Transforming to DOCX'
114
- system("fo2docx #{title}.fo > ../tmp/#{language}/docx/#{title}.docx")
115
- puts 'Launching LibreOffice Writer for Preview'
116
- system("lowriter ../tmp/#{language}/docx/#{title}.docx &")
117
- end
118
-
119
- desc 'Convert to ODT'
120
- task :export_odt => [:checker] do
121
- puts 'Resolving all XML-Entities and XI-Includes'
122
- system("xmllint --noent --dropdtd --xinclude #{title}.xml -o #{title}-resolved.xml")
123
- puts 'Formatting XML to XSL-FO'
124
- system("saxon-xslt -o #{title}.fo #{title}-resolved.xml #{xfc_brand_dir}")
125
- puts 'Removing temporary resolved file'
126
- FileUtils.rm('#{title}-resolved.xml')
127
- puts 'Transforming to ODT'
128
- system("fo2odt #{title}.fo > ../tmp/#{language}/odt/#{title}.odt")
129
- puts 'Launching LibreOffice Writer for Preview'
130
- system("lowriter ../tmp/#{language}/odt/#{title}.odt &")
131
- end
132
-
133
- desc 'Convert to RTF'
134
- task :export_rtf => [:checker] do
135
- puts 'Resolving all XML-Entities and XI-Includes'
136
- system("xmllint --noent --dropdtd --xinclude #{title}.xml -o #{title}-resolved.xml")
137
- puts 'Formatting XML to XSL-FO'
138
- system("saxon-xslt -o #{title}.fo #{title}-resolved.xml #{xfc_brand_dir}")
139
- puts 'Removing temporary resolved file'
140
- FileUtils.rm('#{title}-resolved.xml')
141
- puts 'Transforming to RTF'
142
- system("fo2rtf #{title}.fo > ../tmp/#{language}/rtf/#{title}.rtf")
143
- puts 'Launching LibreOffice Writer for Preview'
144
- system("lowriter ../tmp/#{language}/rtf/#{title}.rtf &")
145
- end
146
-
147
- desc 'Convert to WML'
148
- task :export_wml => [:checker] do
149
- puts 'Resolving all XML-Entities and XI-Includes'
150
- system("xmllint --noent --dropdtd --xinclude #{title}.xml -o #{title}-resolved.xml")
151
- puts 'Formatting XML to XSL-FO'
152
- system("saxon-xslt -o #{title}.fo #{title}-resolved.xml #{xfc_brand_dir}")
153
- puts 'Removing temporary resolved file'
154
- FileUtils.rm('#{title}-resolved.xml')
155
- puts 'Transforming to WML'
156
- system("fo2wml #{title}.fo > ../tmp/#{language}/wml/#{title}.wml")
157
- end
158
-
159
- desc 'Convert to PDF'
160
- task :export_pdf do
161
- FileUtils.cd('..')
162
- puts 'Cleaning up temp directory'
163
- system('publican clean')
164
- puts 'Formatting to PDF'
165
- system('publican build --langs=#{language} --formats=pdf --allow_network')
166
- puts 'Launching PDF-Viewer'
167
- system('#{pdfview} tmp/#{language}/pdf/*.pdf &')
168
- end
169
-
170
- desc 'Convert to HTML'
171
- task :export_html do
172
- FileUtils.cd('..')
173
- puts 'Cleaning up temp directory'
174
- system('publican clean')
175
- puts 'Formatting to PDF'
176
- system('publican build --langs=#{language} --formats=html --allow_network')
177
- puts 'Launching Browser'
178
- system('firefox tmp/#{language}/html/index.html &')
179
- end
180
-
181
- desc 'Convert to MAN'
182
- task :export_man do
183
- FileUtils.cd('..')
184
- puts 'Cleaning up temp directory'
185
- system('publican clean')
186
- puts 'Formatting to MAN'
187
- system('publican build --langs=#{language} --formats=man --allow_network')
188
- end
189
-
190
- desc 'Convert to TXT'
191
- task :export_txt do
192
- FileUtils.cd('..')
193
- puts 'Cleaning up temp directory'
194
- system('publican clean')
195
- puts 'Formatting to TXT'
196
- system('publican build --langs=#{language} --formats=txt --allow_network')
197
- puts 'Launching Texteditor'
198
- system('gedit tmp/#{language}/txt/*.txt &')
199
- end
200
-
201
- desc 'Convert to EPUB'
202
- task :export_epub do
203
- FileUtils.cd('..')
204
- puts 'Cleaning up temp directory'
205
- system('publican clean')
206
- puts 'Formatting to EPUB'
207
- system('publican build --langs=#{language} --formats=epub --allow_network')
208
- if File.exist?('/usr/bin/ebook-viewer')
209
- puts 'Launching EPUB-Viewer'
210
- system('ebook-viewer /tmp/#{language}/*.epub &')
211
- else
212
- puts 'You have to install calibre for using ebook-viewer for preview'
213
- end
214
- end
215
-
216
- desc 'Convert to ECLIPSE'
217
- task :export_eclipse do
218
- FileUtils.cd('..')
219
- puts 'Cleaning up temp directory'
220
- system('publican clean')
221
- puts 'Formatting to ECLIPSE'
222
- system('publican build --langs=#{language} --formats=eclipse --allow_network')
223
- end
224
-
225
- desc 'Run convert to most used formats'
226
- task :export_most => [:export_docx, :export_odt, :export_rtf, :export_html, :export_pdf] do
227
- puts 'Successful exported to DOCX, ODT, RTF, HTML and PDF'
228
- end
229
-
230
- desc 'Run convert to all formats'
231
- task :export_all => [:export_most, :export_wml, :export_man, :export_txt, :export_epub, :export_eclipse] do
232
- puts 'Successfull exported to all formats'
233
- end
234
- BUILDSCRIPT
235
- end
236
- end
1
+ # Copyright (C) 2013-2018 Sascha Manns <Sascha.Manns@outlook.de>
2
+ #
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ # Dependencies
17
+
18
+ require_relative 'change'
19
+ require 'fileutils'
20
+ require 'rainbow/ext/string'
21
+ # Module for running exports to a file
22
+ module PublicanCreatorsExport
23
+ # Exports a predefined Shellscript to the target directory.
24
+ # It returns a sucess or fail.
25
+ # Description:
26
+ # @param [String] title comes from the get method. This parameter represents
27
+ # the name or title of your work. It is used in all important
28
+ # code places.
29
+ # @param [String] builds is the path to your buildscript
30
+ # @param [String] language is just the ISO Code of your target language
31
+ # like: en-GB or such things.
32
+ # @param [String] xfc_brand_dir if present the path to your branded xfc
33
+ # stylesheets (config file)
34
+ # @param [String] pdfview your prefered PDF-Viewer (config file)
35
+ # @return [String] true or false
36
+ def self.export_buildscript(title, builds, language, xfc_brand_dir, pdfview)
37
+ puts 'Export the buildscript into new directory...'
38
+ FileUtils.touch builds.to_s
39
+ # rubocop:disable Layout/IndentHeredoc
40
+ File.write builds.to_s, <<BUILDSCRIPT
41
+ # -*- ruby -*-
42
+ # encoding: utf-8
43
+ require 'fileutils'
44
+
45
+ task :default do
46
+ puts 'usage: rake [export_docx] [export_odt] [export_rtf] [export_wml] [export_pdf] [export_html] [export_man] [export_txt] [export_txt] [export_epub]'
47
+ puts
48
+ puts 'Options:'
49
+ puts 'export_docx : Export DocBook source to DOCX'
50
+ puts ' Example: rake export_docx'
51
+ puts 'export_odt : Export DocBook source to ODT'
52
+ puts ' Example: rake export_odt'
53
+ puts 'export_rtf : Export DocBook source to RTF'
54
+ puts ' Example: rake export_rtf'
55
+ puts 'export_wml: Export DocBook source to WML'
56
+ puts ' Example: rake export_wml'
57
+ puts 'export_pdf: Export Docbook source to PDF'
58
+ puts ' Example: rake export_pdf'
59
+ puts 'export_html: Export DocBook source to HTML'
60
+ puts ' Example: rake export_html'
61
+ puts 'export_man: Export DocBook source to MAN'
62
+ puts ' Example: rake export_man'
63
+ puts 'export_txt: Export DocBook source to TXT'
64
+ puts ' Example: rake export_txt'
65
+ puts 'export_epub: Export DocBook source to EPUB'
66
+ puts ' Example: rake export_epub'
67
+ puts 'export_eclipse: Export DocBook source to Eclipse Help'
68
+ puts ' Example: rake export_eclipse'
69
+ end
70
+
71
+ require 'dir'
72
+ require 'fileutils'
73
+ desc 'Checks if temp dir is available. Otherwise it creates it'
74
+ task :checker do
75
+ todos = "../tmp/#{language}/docx"
76
+ if Dir.exist?(todos)
77
+ puts 'Found directory. Im using it.'
78
+ else
79
+ puts 'No directory found. Im creating it.'
80
+ FileUtils.mkdir_p(todos)
81
+ end
82
+ todos = "../tmp/#{language}/odt"
83
+ if Dir.exist?(todos)
84
+ puts 'Found directory. Im using it.'
85
+ else
86
+ puts 'No directory found. Im creating it.'
87
+ FileUtils.mkdir_p(todos)
88
+ end
89
+ todos = "../tmp/#{language}/rtf"
90
+ if Dir.exist?(todos)
91
+ puts 'Found directory. Im using it.'
92
+ else
93
+ puts 'No directory found. Im creating it.'
94
+ FileUtils.mkdir_p(todos)
95
+ end
96
+ todos = "../tmp/#{language}/wml"
97
+ if Dir.exist?(todos)
98
+ puts 'Found directory. Im using it.'
99
+ else
100
+ puts 'No directory found. Im creating it.'
101
+ FileUtils.mkdir_p(todos)
102
+ end
103
+ end
104
+
105
+ desc 'Convert to DOCX'
106
+ task :export_docx => [:checker] do
107
+ puts 'Resolving all XML-Entities and XI-Includes'
108
+ system("xmllint --noent --dropdtd --xinclude #{title}.xml -o #{title}-resolved.xml")
109
+ puts 'Formatting XML to XSL-FO'
110
+ system("saxon-xslt -o #{title}.fo #{title}-resolved.xml #{xfc_brand_dir}")
111
+ puts 'Removing temporary resolved file'
112
+ FileUtils.rm('#{title}-resolved.xml')
113
+ puts 'Transforming to DOCX'
114
+ system("fo2docx #{title}.fo > ../tmp/#{language}/docx/#{title}.docx")
115
+ puts 'Launching LibreOffice Writer for Preview'
116
+ system("lowriter ../tmp/#{language}/docx/#{title}.docx &")
117
+ end
118
+
119
+ desc 'Convert to ODT'
120
+ task :export_odt => [:checker] do
121
+ puts 'Resolving all XML-Entities and XI-Includes'
122
+ system("xmllint --noent --dropdtd --xinclude #{title}.xml -o #{title}-resolved.xml")
123
+ puts 'Formatting XML to XSL-FO'
124
+ system("saxon-xslt -o #{title}.fo #{title}-resolved.xml #{xfc_brand_dir}")
125
+ puts 'Removing temporary resolved file'
126
+ FileUtils.rm('#{title}-resolved.xml')
127
+ puts 'Transforming to ODT'
128
+ system("fo2odt #{title}.fo > ../tmp/#{language}/odt/#{title}.odt")
129
+ puts 'Launching LibreOffice Writer for Preview'
130
+ system("lowriter ../tmp/#{language}/odt/#{title}.odt &")
131
+ end
132
+
133
+ desc 'Convert to RTF'
134
+ task :export_rtf => [:checker] do
135
+ puts 'Resolving all XML-Entities and XI-Includes'
136
+ system("xmllint --noent --dropdtd --xinclude #{title}.xml -o #{title}-resolved.xml")
137
+ puts 'Formatting XML to XSL-FO'
138
+ system("saxon-xslt -o #{title}.fo #{title}-resolved.xml #{xfc_brand_dir}")
139
+ puts 'Removing temporary resolved file'
140
+ FileUtils.rm('#{title}-resolved.xml')
141
+ puts 'Transforming to RTF'
142
+ system("fo2rtf #{title}.fo > ../tmp/#{language}/rtf/#{title}.rtf")
143
+ puts 'Launching LibreOffice Writer for Preview'
144
+ system("lowriter ../tmp/#{language}/rtf/#{title}.rtf &")
145
+ end
146
+
147
+ desc 'Convert to WML'
148
+ task :export_wml => [:checker] do
149
+ puts 'Resolving all XML-Entities and XI-Includes'
150
+ system("xmllint --noent --dropdtd --xinclude #{title}.xml -o #{title}-resolved.xml")
151
+ puts 'Formatting XML to XSL-FO'
152
+ system("saxon-xslt -o #{title}.fo #{title}-resolved.xml #{xfc_brand_dir}")
153
+ puts 'Removing temporary resolved file'
154
+ FileUtils.rm('#{title}-resolved.xml')
155
+ puts 'Transforming to WML'
156
+ system("fo2wml #{title}.fo > ../tmp/#{language}/wml/#{title}.wml")
157
+ end
158
+
159
+ desc 'Convert to PDF'
160
+ task :export_pdf do
161
+ FileUtils.cd('..')
162
+ puts 'Cleaning up temp directory'
163
+ system('publican clean')
164
+ puts 'Formatting to PDF'
165
+ system('publican build --langs=#{language} --formats=pdf --allow_network')
166
+ puts 'Launching PDF-Viewer'
167
+ system('#{pdfview} tmp/#{language}/pdf/*.pdf &')
168
+ end
169
+
170
+ desc 'Convert to HTML'
171
+ task :export_html do
172
+ FileUtils.cd('..')
173
+ puts 'Cleaning up temp directory'
174
+ system('publican clean')
175
+ puts 'Formatting to PDF'
176
+ system('publican build --langs=#{language} --formats=html --allow_network')
177
+ puts 'Launching Browser'
178
+ system('firefox tmp/#{language}/html/index.html &')
179
+ end
180
+
181
+ desc 'Convert to MAN'
182
+ task :export_man do
183
+ FileUtils.cd('..')
184
+ puts 'Cleaning up temp directory'
185
+ system('publican clean')
186
+ puts 'Formatting to MAN'
187
+ system('publican build --langs=#{language} --formats=man --allow_network')
188
+ end
189
+
190
+ desc 'Convert to TXT'
191
+ task :export_txt do
192
+ FileUtils.cd('..')
193
+ puts 'Cleaning up temp directory'
194
+ system('publican clean')
195
+ puts 'Formatting to TXT'
196
+ system('publican build --langs=#{language} --formats=txt --allow_network')
197
+ puts 'Launching Texteditor'
198
+ system('gedit tmp/#{language}/txt/*.txt &')
199
+ end
200
+
201
+ desc 'Convert to EPUB'
202
+ task :export_epub do
203
+ FileUtils.cd('..')
204
+ puts 'Cleaning up temp directory'
205
+ system('publican clean')
206
+ puts 'Formatting to EPUB'
207
+ system('publican build --langs=#{language} --formats=epub --allow_network')
208
+ if File.exist?('/usr/bin/ebook-viewer')
209
+ puts 'Launching EPUB-Viewer'
210
+ system('ebook-viewer /tmp/#{language}/*.epub &')
211
+ else
212
+ puts 'You have to install calibre for using ebook-viewer for preview'
213
+ end
214
+ end
215
+
216
+ desc 'Convert to ECLIPSE'
217
+ task :export_eclipse do
218
+ FileUtils.cd('..')
219
+ puts 'Cleaning up temp directory'
220
+ system('publican clean')
221
+ puts 'Formatting to ECLIPSE'
222
+ system('publican build --langs=#{language} --formats=eclipse --allow_network')
223
+ end
224
+
225
+ desc 'Run convert to most used formats'
226
+ task :export_most => [:export_docx, :export_odt, :export_rtf, :export_html, :export_pdf] do
227
+ puts 'Successful exported to DOCX, ODT, RTF, HTML and PDF'
228
+ end
229
+
230
+ desc 'Run convert to all formats'
231
+ task :export_all => [:export_most, :export_wml, :export_man, :export_txt, :export_epub, :export_eclipse] do
232
+ puts 'Successfull exported to all formats'
233
+ end
234
+ BUILDSCRIPT
235
+ end
236
+ end