rabbit 1.0.9 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. data/GPL +19 -20
  2. data/Rakefile +25 -10
  3. data/bin/rabbit +20 -844
  4. data/bin/rabbit-command +25 -36
  5. data/bin/rabbit-slide +22 -0
  6. data/bin/rabbit-theme +22 -0
  7. data/bin/rabbit-theme-manager +30 -30
  8. data/data/account.kou.gpg +0 -0
  9. data/data/locale/en/LC_MESSAGES/rabbit.mo +0 -0
  10. data/data/locale/fr/LC_MESSAGES/rabbit.mo +0 -0
  11. data/data/locale/ja/LC_MESSAGES/rabbit.mo +0 -0
  12. data/doc/_config.yml +8 -0
  13. data/doc/_includes/en.menu.html +8 -0
  14. data/doc/_includes/ja.menu.html +8 -0
  15. data/doc/_layouts/en.html +19 -16
  16. data/doc/_layouts/ja.html +19 -16
  17. data/doc/_plugins/converters/rd.rb +1 -1
  18. data/doc/_plugins/support_symlink.rb +11 -0
  19. data/doc/en/development.rd +2 -2
  20. data/doc/en/how-to-make/index.rd +5 -5
  21. data/doc/en/how-to-make/rd.rd +1 -1
  22. data/doc/en/index.rd +6 -12
  23. data/doc/en/sample/index.rd +3 -3
  24. data/doc/en/slides.rd +2 -0
  25. data/doc/en/usage.rd +14 -356
  26. data/doc/en/usage/rabbit.rd +360 -0
  27. data/doc/en/users.rd +3 -1
  28. data/doc/images/screenshots/en/blue-circle-raw.png +0 -0
  29. data/doc/images/screenshots/en/blue-circle.png +0 -0
  30. data/doc/images/screenshots/en/clear-blue-raw.png +0 -0
  31. data/doc/images/screenshots/en/clear-blue.png +0 -0
  32. data/doc/images/screenshots/en/cozmixng-raw.png +0 -0
  33. data/doc/images/screenshots/en/cozmixng.png +0 -0
  34. data/doc/images/screenshots/en/dark-gradation-raw.png +0 -0
  35. data/doc/images/screenshots/en/dark-gradation.png +0 -0
  36. data/doc/images/screenshots/en/day-white.png +0 -0
  37. data/doc/images/screenshots/en/debian-raw.png +0 -0
  38. data/doc/images/screenshots/en/debian.png +0 -0
  39. data/doc/images/screenshots/en/green-circle-raw.png +0 -0
  40. data/doc/images/screenshots/en/green-circle.png +0 -0
  41. data/doc/images/screenshots/en/night-black.png +0 -0
  42. data/doc/images/screenshots/en/rabbit-raw.png +0 -0
  43. data/doc/images/screenshots/en/rabbit.png +0 -0
  44. data/doc/images/screenshots/en/ranguba-raw.png +0 -0
  45. data/doc/images/screenshots/en/ranguba.png +0 -0
  46. data/doc/images/screenshots/en/red-frame-raw.png +0 -0
  47. data/doc/images/screenshots/en/red-frame.png +0 -0
  48. data/doc/images/screenshots/en/ruby-gnome2-raw.png +0 -0
  49. data/doc/images/screenshots/en/ruby-gnome2.png +0 -0
  50. data/doc/images/screenshots/en/rubykaigi2011-raw.png +0 -0
  51. data/doc/images/screenshots/en/rubykaigi2011.png +0 -0
  52. data/doc/images/screenshots/ja/blue-circle-raw.png +0 -0
  53. data/doc/images/screenshots/ja/blue-circle.png +0 -0
  54. data/doc/images/screenshots/ja/clear-blue-raw.png +0 -0
  55. data/doc/images/screenshots/ja/clear-blue.png +0 -0
  56. data/doc/images/screenshots/ja/cozmixng-raw.png +0 -0
  57. data/doc/images/screenshots/ja/cozmixng.png +0 -0
  58. data/doc/images/screenshots/ja/dark-gradation-raw.png +0 -0
  59. data/doc/images/screenshots/ja/dark-gradation.png +0 -0
  60. data/doc/images/screenshots/ja/day-white.png +0 -0
  61. data/doc/images/screenshots/ja/debian-raw.png +0 -0
  62. data/doc/images/screenshots/ja/debian.png +0 -0
  63. data/doc/images/screenshots/ja/green-circle-raw.png +0 -0
  64. data/doc/images/screenshots/ja/green-circle.png +0 -0
  65. data/doc/images/screenshots/ja/night-black.png +0 -0
  66. data/doc/images/screenshots/ja/rabbit-raw.png +0 -0
  67. data/doc/images/screenshots/ja/rabbit.png +0 -0
  68. data/doc/images/screenshots/ja/ranguba-raw.png +0 -0
  69. data/doc/images/screenshots/ja/ranguba.png +0 -0
  70. data/doc/images/screenshots/ja/red-frame-raw.png +0 -0
  71. data/doc/images/screenshots/ja/red-frame.png +0 -0
  72. data/doc/images/screenshots/ja/ruby-gnome2-raw.png +0 -0
  73. data/doc/images/screenshots/ja/ruby-gnome2.png +0 -0
  74. data/doc/images/screenshots/ja/rubykaigi2011-raw.png +0 -0
  75. data/doc/images/screenshots/ja/rubykaigi2011.png +0 -0
  76. data/doc/index.html.en +1 -1
  77. data/doc/index.html.ja +1 -1
  78. data/doc/ja/about.rd +3 -3
  79. data/doc/ja/development.rd +2 -2
  80. data/doc/ja/how-to-make/index.rd +5 -5
  81. data/doc/ja/index.rd +10 -16
  82. data/doc/ja/install/macports.rd +1 -1
  83. data/doc/ja/news.rd +4 -4
  84. data/doc/ja/sample/index.rd +3 -3
  85. data/doc/ja/usage.rd +13 -358
  86. data/doc/ja/usage/rabbit.rd +362 -0
  87. data/doc/ja/users.rd +1 -1
  88. data/lib/rabbit/action.rb +2 -2
  89. data/lib/rabbit/author-configuration.rb +73 -0
  90. data/lib/rabbit/canvas.rb +0 -14
  91. data/lib/rabbit/command/rabbit-slide.rb +571 -0
  92. data/lib/rabbit/command/rabbit-theme.rb +381 -0
  93. data/lib/rabbit/command/rabbit.rb +898 -0
  94. data/lib/rabbit/config.rb +40 -0
  95. data/lib/rabbit/console.rb +124 -55
  96. data/lib/rabbit/gem-finder.rb +61 -0
  97. data/lib/rabbit/gettext.rb +6 -79
  98. data/lib/rabbit/html/generator.rb +1 -0
  99. data/lib/rabbit/image.rb +1 -1
  100. data/lib/rabbit/logger.rb +12 -2
  101. data/lib/rabbit/logger/base.rb +33 -32
  102. data/lib/rabbit/logger/stderr.rb +1 -1
  103. data/lib/rabbit/menu.rb +1 -1
  104. data/lib/rabbit/parser.rb +2 -0
  105. data/lib/rabbit/parser/ext/image.rb +14 -20
  106. data/lib/rabbit/path-manipulatable.rb +40 -0
  107. data/lib/rabbit/rabbit.rb +18 -8
  108. data/lib/rabbit/renderer/base.rb +3 -4
  109. data/lib/rabbit/renderer/color.rb +0 -1
  110. data/lib/rabbit/slideshare.rb +116 -0
  111. data/lib/rabbit/source/base.rb +1 -1
  112. data/lib/rabbit/stock.rb +1 -1
  113. data/lib/rabbit/task.rb +18 -0
  114. data/lib/rabbit/task/slide.rb +162 -0
  115. data/lib/rabbit/task/theme.rb +122 -0
  116. data/lib/rabbit/theme-browser/tree.rb +1 -1
  117. data/lib/rabbit/theme/applier.rb +9 -0
  118. data/lib/rabbit/theme/background-image-toolkit/background-image-toolkit.rb +1 -2
  119. data/lib/rabbit/theme/blue-bar/blue-bar.rb +0 -11
  120. data/lib/rabbit/theme/clear-blue/clear-blue.rb +0 -11
  121. data/lib/rabbit/theme/cozmixng/cozmixng.rb +0 -11
  122. data/lib/rabbit/theme/day-white/day-white.rb +0 -6
  123. data/lib/rabbit/theme/default/default.rb +7 -1
  124. data/lib/rabbit/theme/enishi-green/property.rb +2 -2
  125. data/lib/rabbit/theme/entry.rb +85 -27
  126. data/lib/rabbit/theme/image-slide-number/image-slide-number.rb +4 -1
  127. data/lib/rabbit/theme/lightning-monochrome/lightning-monochrome.rb +0 -1
  128. data/lib/rabbit/theme/lightning-simple/lightning-simple.rb +0 -1
  129. data/lib/rabbit/theme/nari/nari.rb +6 -16
  130. data/lib/rabbit/theme/nari/property.rb +3 -0
  131. data/lib/rabbit/theme/night-black/night-black.rb +0 -6
  132. data/lib/rabbit/theme/pdf/pdf.rb +0 -4
  133. data/lib/rabbit/theme/rabbit/rabbit.rb +0 -6
  134. data/lib/rabbit/theme/ranguba/ranguba.rb +0 -12
  135. data/lib/rabbit/theme/ruby-gnome2/ruby-gnome2.rb +7 -4
  136. data/lib/rabbit/theme/rubykaigi2011/rubykaigi2011.rb +2 -9
  137. data/lib/rabbit/theme/searcher.rb +38 -16
  138. data/lib/rabbit/theme/syntax-highlighting/property.rb +2 -2
  139. data/lib/rabbit/version.rb +19 -0
  140. data/po/en/rabbit.po +1605 -1425
  141. data/po/fr/rabbit.po +1756 -1684
  142. data/po/ja/rabbit.po +2198 -2097
  143. data/po/rabbit.pot +1556 -1419
  144. metadata +34 -100
  145. data/bin/rabbirack +0 -99
  146. data/bin/rabbiter +0 -108
  147. data/bin/rabrick +0 -95
  148. data/bin/rabwii +0 -77
  149. data/lib/rabbit/default-config.rb +0 -24
  150. data/lib/rabbit/div/comment-i.erb +0 -7
  151. data/lib/rabbit/div/comment.erb +0 -45
  152. data/lib/rabbit/div/css.erb +0 -1
  153. data/lib/rabbit/div/js.erb +0 -1
  154. data/lib/rabbit/div/log.erb +0 -5
  155. data/lib/rabbit/div/main-i.erb +0 -24
  156. data/lib/rabbit/div/main.css +0 -40
  157. data/lib/rabbit/div/main.erb +0 -33
  158. data/lib/rabbit/div/navi-i.erb +0 -6
  159. data/lib/rabbit/div/navi.erb +0 -6
  160. data/lib/rabbit/div/prototype.js +0 -4320
  161. data/lib/rabbit/div/slide-i.erb +0 -2
  162. data/lib/rabbit/div/slide.erb +0 -5
  163. data/lib/rabbit/div/tofu.rb +0 -309
  164. data/lib/rabbit/middleware/config.ru +0 -42
  165. data/lib/rabbit/middleware/controller.rb +0 -63
  166. data/lib/rabbit/middleware/public/stylesheets/rabbirack.css +0 -12
  167. data/lib/rabbit/middleware/views/index.haml +0 -13
  168. data/lib/rabbit/middleware/views/layout.haml +0 -8
  169. data/lib/rabbit/post-setup.rb +0 -8
  170. data/lib/rabbit/pre-clean.rb +0 -2
  171. data/lib/rabbit/pre-distclean.rb +0 -2
  172. data/lib/rabbit/theme/twitter-comment/property.rb +0 -4
  173. data/lib/rabbit/theme/twitter-comment/twitter-comment.rb +0 -15
  174. data/lib/rabbit/twitter.rb +0 -239
  175. data/sample/theme-bench-en.hiki +0 -100
  176. data/sample/theme-bench-en.rab +0 -127
  177. data/sample/theme-bench.hiki +0 -101
  178. data/sample/theme-bench.rab +0 -128
  179. data/setup.rb +0 -1585
  180. data/update-mo.rb +0 -20
  181. data/update-po.rb +0 -57
data/lib/rabbit/canvas.rb CHANGED
@@ -10,7 +10,6 @@ require "rabbit/theme/manager"
10
10
  require "rabbit/front"
11
11
  require "rabbit/action"
12
12
  require "rabbit/html/generator"
13
- require "rabbit/twitter"
14
13
 
15
14
  module Rabbit
16
15
  class Canvas
@@ -150,7 +149,6 @@ module Rabbit
150
149
  @limit_time = nil
151
150
  @use_gl = false
152
151
  @font_resolution_ratio = 1
153
- @twitter = nil
154
152
  @max_n_comments = 100
155
153
  @allotted_time = nil
156
154
  @comment_theme = nil
@@ -176,7 +174,6 @@ module Rabbit
176
174
  end
177
175
 
178
176
  def quit
179
- clear_twitter
180
177
  @quitted = true
181
178
  @frame.quit
182
179
  end
@@ -643,10 +640,6 @@ module Rabbit
643
640
  INTERNAL_DPI * @font_resolution_ratio
644
641
  end
645
642
 
646
- def twitter
647
- @twitter ||= Twitter.new(@logger)
648
- end
649
-
650
643
  private
651
644
  def _apply_theme(name, id, &block)
652
645
  @theme_name = name if name
@@ -697,7 +690,6 @@ module Rabbit
697
690
  end
698
691
 
699
692
  def clear
700
- clear_twitter
701
693
  clear_comments
702
694
  reset_timer
703
695
  stop_auto_redraw_timer
@@ -706,12 +698,6 @@ module Rabbit
706
698
  modified
707
699
  end
708
700
 
709
- def clear_twitter
710
- return if @twitter.nil?
711
- @twitter.close
712
- @twitter = nil
713
- end
714
-
715
701
  def clear_comments
716
702
  @comments = []
717
703
  @on_comment_callbacks = []
@@ -0,0 +1,571 @@
1
+ # Copyright (C) 2012 Kouhei Sutou <kou@cozmixng.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 2 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 along
14
+ # with this program; if not, write to the Free Software Foundation, Inc.,
15
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
+
17
+ require "yaml"
18
+
19
+ require "rabbit/console"
20
+ require "rabbit/author-configuration"
21
+ require "rabbit/path-manipulatable"
22
+
23
+ module Rabbit
24
+ module Command
25
+ class RabbitSlide
26
+ include GetText
27
+ include PathManipulatable
28
+
29
+ class << self
30
+ def run(*arguments)
31
+ new.run(arguments)
32
+ end
33
+ end
34
+
35
+ def initialize
36
+ @config_yaml_path = "config.yaml"
37
+ @id = nil
38
+ @base_name = nil
39
+ @title = nil
40
+ @tags = []
41
+ @allotted_time = nil
42
+ @presentation_date = nil
43
+ @author_conf = nil
44
+ @logger = nil
45
+ end
46
+
47
+ def run(arguments)
48
+ @options, @logger = parse_command_line_arguments(arguments)
49
+
50
+ validate
51
+ unless @validation_errors.empty?
52
+ messages = (@validation_errors + [_("See --help for example")])
53
+ @logger.error(messages.join("\n"))
54
+ return false
55
+ end
56
+
57
+ generate
58
+ @author_conf.save
59
+ true
60
+ end
61
+
62
+ private
63
+ def parse_command_line_arguments(arguments)
64
+ Rabbit::Console.parse!(ARGV) do |parser, options|
65
+ @logger = options.default_logger
66
+ @author_conf = AuthorConfiguration.new(@logger)
67
+ @author_conf.load
68
+
69
+ format = _("Usage: %s new [options]\n" \
70
+ " e.g.: %s new \\\n" \
71
+ " --id rubykaigi2012 \\\n" \
72
+ " --base-name rabbit-introduction \\\n" \
73
+ " --markup-language rd \\\n" \
74
+ " --name \"Kouhei Sutou\" \\\n" \
75
+ " --email kou@cozmixng.org \\\n" \
76
+ " --rubygems-user kou \\\n" \
77
+ " --slideshare-user kou \\\n" \
78
+ " --speaker-deck-user kou")
79
+
80
+ program = File.basename($0, ".*")
81
+ parser.banner = format % [program, program]
82
+
83
+ parser.separator("")
84
+
85
+ parser.separator(_("Slide information"))
86
+
87
+ parser.on("--id=ID",
88
+ _("Slide ID"),
89
+ _("(e.g.: %s)") % "--id=rubykaigi2012",
90
+ _("(must)")) do |id|
91
+ @id = id
92
+ end
93
+
94
+ messages = [
95
+ _("Base name for the slide source file and generated PDF file"),
96
+ _("(e.g.: %s)") % "--base-name=rabbit-introduction",
97
+ _("(must)"),
98
+ ]
99
+ parser.on("--base-name=NAME",
100
+ *messages) do |base_name|
101
+ @base_name = base_name
102
+ end
103
+
104
+ available_markup_languages = [:rd, :hiki, :markdown]
105
+ label = "[" + available_markup_languages.join(", ") + "]"
106
+ messages = [
107
+ _("Markup language for the new slide"),
108
+ _("(e.g.: %s)") % "--markup-language=rd",
109
+ _("(available markup languages: %s)") % label,
110
+ ]
111
+ if @author_conf.markup_language
112
+ messages << _("(default: %s)") % @author_conf.markup_language
113
+ end
114
+ messages << _("(optional)")
115
+ parser.on("--markup-language=LANGUAGE", available_markup_languages,
116
+ *messages) do |language|
117
+ @author_conf.markup_language = language
118
+ end
119
+
120
+ parser.on("--title=TITLE",
121
+ _("Title of the new slide"),
122
+ _("(e.g.: %s)") % _("--title=\"Rabbit Introduction\""),
123
+ _("(optional)")) do |title|
124
+ @title = title
125
+ end
126
+
127
+ parser.on("--tags=TAG,TAG,...",
128
+ Array,
129
+ _("Tags of the new slide"),
130
+ _("(e.g.: %s)") % "--tags=rabbit,presentation,ruby",
131
+ _("(optional)")) do |tags|
132
+ @tags.concat(tags)
133
+ end
134
+
135
+ parser.on("--allotted-time=TIME",
136
+ _("Allotted time in presentaion"),
137
+ _("(e.g.: %s)") % "--allotted-time=5m",
138
+ _("(optional)")) do |allotted_time|
139
+ @allotted_time = allotted_time
140
+ end
141
+
142
+ parser.on("--presentation-date=DATE",
143
+ _("Presentation date with the new slide"),
144
+ _("(e.g.: %s)") % "--presentation-date=2012/06/29",
145
+ _("(optional)")) do |date|
146
+ @presentation_date = date
147
+ end
148
+
149
+ parser.separator(_("Your information"))
150
+
151
+ messages = [
152
+ _("Author name of the new slide"),
153
+ _("(e.g.: %s)") % "--name=\"Kouhei Sutou\"",
154
+ ]
155
+ if @author_conf.name
156
+ messages << _("(default: %s)") % @author_conf.name
157
+ end
158
+ messages << _("(optional)")
159
+ parser.on("--name=NAME",
160
+ *messages) do |name|
161
+ @author_conf.name = name
162
+ end
163
+
164
+ messages = [
165
+ _("Author e-mail of the new slide"),
166
+ _("(e.g.: %s)") % "--email=kou@cozmixng.org",
167
+ ]
168
+ if @author_conf.email
169
+ messages << _("(default: %s)") % @author_conf.email
170
+ end
171
+ messages << _("(optional)")
172
+ parser.on("--email=EMAIL",
173
+ *messages) do |email|
174
+ @author_conf.email = email
175
+ end
176
+
177
+ messages = [
178
+ _("Account for %s") % "RubyGems.org",
179
+ _("It is used to publish your slide to %s") % "RubyGems.org",
180
+ _("(e.g.: %s)") % "--rubygems-user=kou",
181
+ ]
182
+ if @author_conf.rubygems_user
183
+ messages << _("(default: %s)") % @author_conf.rubygems_user
184
+ end
185
+ messages << _("(optional)")
186
+ parser.on("--rubygems-user=USER",
187
+ *messages) do |user|
188
+ @author_conf.rubygems_user = user
189
+ end
190
+
191
+ messages = [
192
+ _("Account for %s") % "SlideShare",
193
+ _("It is used to publish your slide to %s") % "SlideShare",
194
+ _("(e.g.: %s)") % "--slideshare-user=kou",
195
+ ]
196
+ if @author_conf.slideshare_user
197
+ messages << _("(default: %s)") % @author_conf.slideshare_user
198
+ end
199
+ messages << _("(optional)")
200
+ parser.on("--slideshare-user=USER",
201
+ *messages) do |user|
202
+ @author_conf.slideshare_user = user
203
+ end
204
+
205
+ messages = [
206
+ _("Account for %s") % "Speaker Deck",
207
+ _("It is used to publish your slide to %s") % "Speaker Deck",
208
+ _("(e.g.: %s)") % "--speaker-deck-user=kou",
209
+ ]
210
+ if @author_conf.speaker_deck_user
211
+ messages << _("(default: %s)") % @author_conf.speaker_deck_user
212
+ end
213
+ messages << _("(optional)")
214
+ parser.on("--speaker-deck-user=USER",
215
+ *messages) do |user|
216
+ @author_conf.speaker_deck_user = user
217
+ end
218
+ end
219
+ end
220
+
221
+ def validate
222
+ @validation_errors = []
223
+ validate_command
224
+ validate_id
225
+ validate_base_name
226
+ end
227
+
228
+ def validate_command
229
+ if @options.rest.empty?
230
+ @options.rest << "new"
231
+ end
232
+ if @options.rest.size != 1
233
+ message = _("too many commands: %s") % @options.rest.inspect
234
+ @validation_errors << message
235
+ end
236
+ @command = @options.rest[0]
237
+ if @command != "new"
238
+ format = _("invalid command: <%s>: available commands: %s")
239
+ message = format % [@command, "[new]"]
240
+ @validation_errors << message
241
+ end
242
+ end
243
+
244
+ def validate_id
245
+ if @id.nil?
246
+ @validation_errors << (_("%s is missing") % "--id")
247
+ end
248
+ end
249
+
250
+ def validate_base_name
251
+ if @base_name.nil?
252
+ @validation_errors << (_("%s is missing") % "--base-name")
253
+ end
254
+ end
255
+
256
+ def generate
257
+ generate_directory
258
+ generate_dot_rabbit
259
+ generate_config_yaml
260
+ generate_readme
261
+ generate_rakefile
262
+ generate_slide
263
+ end
264
+
265
+ def generate_directory
266
+ create_directory(@id)
267
+ end
268
+
269
+ def generate_dot_rabbit
270
+ create_file(".rabbit") do |dot_rabbit|
271
+ options = []
272
+ if @author_conf.markup_language.nil? and @allotted_time
273
+ options << "--allotted-time #{@allotted_time}"
274
+ end
275
+ options << slide_path
276
+ dot_rabbit.puts(options.join("\n"))
277
+ end
278
+ end
279
+
280
+ def generate_config_yaml
281
+ create_file(@config_yaml_path) do |config_yaml|
282
+ config = {
283
+ "id" => @id,
284
+ "tags" => @tags,
285
+ "base_name" => @base_name,
286
+ "name" => @author_conf.name,
287
+ "presentation_date" => @presentation_date,
288
+ "email" => @author_conf.email,
289
+ "rubygems_user" => @author_conf.rubygems_user,
290
+ "slideshare_user" => @author_conf.slideshare_user,
291
+ "speaker_deck_user" => @author_conf.speaker_deck_user,
292
+ }
293
+ config_yaml.puts(config.to_yaml)
294
+ end
295
+ end
296
+
297
+ def generate_readme
298
+ create_file("README.#{readme_extension}") do |readme|
299
+ readme.puts(readme_content)
300
+ end
301
+ end
302
+
303
+ def readme_content
304
+ markup_language = @author_conf.markup_language || :rd
305
+ syntax = markup_syntax(markup_language)
306
+
307
+ content = ""
308
+ content << (syntax[:heading1] % {:title => _("TODO: SLIDE TITLE")})
309
+ content << "\n\n"
310
+ content << _("TODO: SLIDE DESCRIPTION")
311
+ content << "\n\n"
312
+
313
+ content << (syntax[:heading2] % {:title => _("For author")})
314
+ content << "\n\n"
315
+ content << (syntax[:heading3] % {:title => _("Show")})
316
+ content << "\n\n"
317
+ content << (syntax[:preformatted_line] % {:content => "rake"})
318
+ content << "\n\n"
319
+ content << (syntax[:heading3] % {:title => _("Publish")})
320
+ content << "\n\n"
321
+ content << (syntax[:preformatted_line] % {:content => "rake publish"})
322
+ content << "\n\n"
323
+
324
+ content << (syntax[:heading2] % {:title => _("For viewers")})
325
+ content << "\n\n"
326
+ content << (syntax[:heading3] % {:title => _("Install")})
327
+ content << "\n\n"
328
+ install_command = "gem install #{gem_name}"
329
+ content << (syntax[:preformatted_line] % {:content => install_command})
330
+ content << "\n\n"
331
+ content << (syntax[:heading3] % {:title => _("Show")})
332
+ content << "\n\n"
333
+ show_command = "rabbit #{gem_name}.gem"
334
+ content << (syntax[:preformatted_line] % {:content => show_command})
335
+ content << "\n\n"
336
+ end
337
+
338
+ def generate_rakefile
339
+ create_file("Rakefile") do |rakefile|
340
+ rakefile.puts(<<-EOR)
341
+ require "time"
342
+ require "yaml"
343
+ require "rabbit/task/slide"
344
+
345
+ config = YAML.load(File.read("#{@config_yaml_path}"))
346
+
347
+ slide_id = config["id"]
348
+ tags = config["tags"]
349
+ base_name = config["base_name"]
350
+ pdf_base_path = "\#{base_name}.pdf"
351
+
352
+ version = nil
353
+ presentation_date = config["presentation_date"]
354
+ parsed_presentation_date = nil
355
+ if presentation_date
356
+ begin
357
+ parsed_presentation_date = Time.parse(presentation_date)
358
+ rescue ArgumentError
359
+ end
360
+ if parsed_presentation_date
361
+ version = parsed_presentation_date.strftime("%Y.%m.%d")
362
+ end
363
+ end
364
+ version ||= "1.0.0"
365
+
366
+ name = config["name"]
367
+ email = config["email"]
368
+ rubygems_user = config["rubygems_user"]
369
+ slideshare_user = config["slideshare_user"]
370
+ speaker_deck_user = config["speaker_deck_user"]
371
+
372
+ readme = File.read(Dir.glob("README*")[0])
373
+
374
+ readme_blocks = readme.split(/(?:\\r?\\n){2,}/)
375
+ summary = (readme_blocks[0] || "TODO").gsub(/\\A(?:[=*!]+|h\\d\\.)\s*/, "")
376
+ description = readme_blocks[1] || "TODO"
377
+
378
+ specification = Gem::Specification.new do |spec|
379
+ prefix = "#{gem_name_prefix}"
380
+ spec.name = "\#{prefix}-\#{rubygems_user}-\#{slide_id}"
381
+ spec.version = version
382
+ spec.homepage = "http://slide.rabbit-shockers.org/\#{rubygems_user}/\#{slide_id}/"
383
+ spec.authors = [name]
384
+ spec.email = [email]
385
+ spec.summary = summary
386
+ spec.description = description
387
+ spec.licenses = [] # ["CC BY-SA 3.0"]
388
+
389
+ spec.files = [".rabbit", "#{@config_yaml_path}", "Rakefile"]
390
+ spec.files += Dir.glob("{COPYING,GPL,README*}")
391
+ spec.files += Dir.glob("rabbit/**/*.*")
392
+ spec.files += Dir.glob("**/*.{svg,png,jpg,jpeg,gif,eps,pdf}")
393
+ spec.files += Dir.glob("*.{rd,rab,hiki,md,pdf}")
394
+ spec.files -= Dir.glob("{pkg,pdf}/**/*.*")
395
+
396
+ spec.add_runtime_dependency("rabbit")
397
+ end
398
+
399
+ Rabbit::Task::Slide.new(specification) do |task|
400
+ task.rubygems_user = rubygems_user
401
+ task.slideshare_user = slideshare_user
402
+ task.speaker_deck_user = speaker_deck_user
403
+ task.pdf_base_path = pdf_base_path
404
+ task.tags = tags
405
+ task.presentation_date = parsed_presentation_date
406
+ end
407
+ EOR
408
+ end
409
+ end
410
+
411
+ def generate_slide
412
+ source = slide_source
413
+ return if source.nil?
414
+ create_file(slide_path) do |slide|
415
+ slide.puts(source)
416
+ end
417
+ end
418
+
419
+ def slide_path
420
+ "#{@base_name}.#{slide_source_extension}"
421
+ end
422
+
423
+ def slide_source_extension
424
+ case @author_conf.markup_language
425
+ when :rd
426
+ "rab"
427
+ when :hiki
428
+ "hiki"
429
+ when :markdown
430
+ "md"
431
+ else
432
+ "pdf"
433
+ end
434
+ end
435
+
436
+ def readme_extension
437
+ case @author_conf.markup_language
438
+ when :rd
439
+ "rd"
440
+ when :hiki
441
+ "hiki"
442
+ when :markdown
443
+ "md"
444
+ else
445
+ "rd"
446
+ end
447
+ end
448
+
449
+ def slide_source
450
+ syntax = slide_source_syntax
451
+ return nil if syntax.nil?
452
+
453
+ source = ""
454
+ slide_source_title(source, syntax, _("TITLE"))
455
+ slide_source_metadata(source, syntax)
456
+ slide_source_title(source, syntax, _("FIRST SLIDE"))
457
+ slide_source_items(source, syntax)
458
+ slide_source_title(source, syntax, _("SECOND SLIDE"))
459
+ slide_source_image(source, syntax)
460
+ end
461
+
462
+ def slide_source_title(source, syntax, title)
463
+ source << (syntax[:heading1] % {:title => _("TITLE")})
464
+ source << "\n\n"
465
+ end
466
+
467
+ def slide_source_metadata(source, syntax)
468
+ slide_metadata = [
469
+ ["subtitle", nil, _("SUBTITLE")],
470
+ ["author", @author_conf.name, _("AUTHOR")],
471
+ ["institution", nil, _("INSTITUTION")],
472
+ ["content-source", nil, _("EVENT NAME")],
473
+ ["date", @presentation_date, Time.now.strftime("%Y/%m/%d")],
474
+ ["allotted-time", @allotted_time, "5m"],
475
+ ["theme", nil, "default"],
476
+ ]
477
+ slide_metadata.each do |key, value, default_value|
478
+ data = {:item => key, :description => value || default_value}
479
+ item = syntax[:definition_list_item] % data
480
+ item << "\n"
481
+ if value
482
+ source << item
483
+ else
484
+ item.each_line do |line|
485
+ source << (syntax[:comment] % {:content => line})
486
+ end
487
+ end
488
+ end
489
+ source << "\n\n"
490
+ end
491
+
492
+ def slide_source_items(source, syntax)
493
+ 1.upto(3) do |i|
494
+ source << syntax[:unorderd_list_item] % {:item => _("ITEM %d") % i}
495
+ source << "\n"
496
+ end
497
+ source << "\n"
498
+ end
499
+
500
+ def slide_source_image(source, syntax)
501
+ lavie = "https://raw.github.com/shockers/rabbit/master/sample/lavie.png"
502
+ data = {
503
+ :src => lavie,
504
+ :relative_height => 100,
505
+ }
506
+ source << syntax[:image] % data
507
+ source << "\n"
508
+ end
509
+
510
+ def slide_source_syntax
511
+ markup_syntax(@author_conf.markup_language)
512
+ end
513
+
514
+ def markup_syntax(markup_language)
515
+ case markup_language
516
+ when :rd
517
+ {
518
+ :heading1 => "= %{title}",
519
+ :heading2 => "== %{title}",
520
+ :heading3 => "=== %{title}",
521
+ :definition_list_item => ": %{item}\n %{description}",
522
+ :unorderd_list_item => " * %{item}",
523
+ :image =>
524
+ " # image\n" +
525
+ " # src = %{src}\n" +
526
+ " # relative_height = %{relative_height}",
527
+ :preformatted_line => " %{content}",
528
+ :comment => "# %{content}",
529
+ }
530
+ when :hiki
531
+ {
532
+ :heading1 => "! %{title}",
533
+ :heading2 => "!! %{title}",
534
+ :heading3 => "!!! %{title}",
535
+ :definition_list_item => ":%{item}:%{description}",
536
+ :unorderd_list_item => "* %{item}",
537
+ :image =>
538
+ "{{image(\"%{src}\",\n" +
539
+ " {\n" +
540
+ " :relative_height => %{relative_height},\n" +
541
+ " })}}",
542
+ :preformatted_line => " %{content}",
543
+ :comment => "// %{content}",
544
+ }
545
+ when :markdown
546
+ {
547
+ :heading1 => "# %{title}",
548
+ :heading2 => "## %{title}",
549
+ :heading3 => "### %{title}",
550
+ :definition_list_item => "%{item}\n %{description}",
551
+ :unorderd_list_item => "* %{item}",
552
+ :image =>
553
+ "![](%{src}){:relative_height='%{relative_height}'}",
554
+ :preformatted_line => " %{content}",
555
+ :comment => "",
556
+ }
557
+ else
558
+ nil
559
+ end
560
+ end
561
+
562
+ def gem_name
563
+ "#{gem_name_prefix}-#{@author_conf.rubygems_user}-#{@id}"
564
+ end
565
+
566
+ def gem_name_prefix
567
+ "rabbit-slide"
568
+ end
569
+ end
570
+ end
571
+ end