rabbit 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -1
  3. data/data/locale/ja/LC_MESSAGES/rabbit.mo +0 -0
  4. data/doc/_config.yml +2 -2
  5. data/doc/_layouts/skeleton.html +0 -7
  6. data/doc/en/install/homebrew.rd +8 -13
  7. data/doc/en/news.rd +67 -0
  8. data/doc/images/screenshots/en/blue-circle-raw.png +0 -0
  9. data/doc/images/screenshots/en/blue-circle.png +0 -0
  10. data/doc/images/screenshots/en/clear-blue-raw.png +0 -0
  11. data/doc/images/screenshots/en/clear-blue.png +0 -0
  12. data/doc/images/screenshots/en/cozmixng-raw.png +0 -0
  13. data/doc/images/screenshots/en/cozmixng.png +0 -0
  14. data/doc/images/screenshots/en/dark-gradation-raw.png +0 -0
  15. data/doc/images/screenshots/en/dark-gradation.png +0 -0
  16. data/doc/images/screenshots/en/day-white-raw.png +0 -0
  17. data/doc/images/screenshots/en/day-white.png +0 -0
  18. data/doc/images/screenshots/en/debian-raw.png +0 -0
  19. data/doc/images/screenshots/en/debian.png +0 -0
  20. data/doc/images/screenshots/en/green-circle-raw.png +0 -0
  21. data/doc/images/screenshots/en/green-circle.png +0 -0
  22. data/doc/images/screenshots/en/night-black-raw.png +0 -0
  23. data/doc/images/screenshots/en/night-black.png +0 -0
  24. data/doc/images/screenshots/en/rabbit-raw.png +0 -0
  25. data/doc/images/screenshots/en/rabbit.png +0 -0
  26. data/doc/images/screenshots/en/ranguba-raw.png +0 -0
  27. data/doc/images/screenshots/en/ranguba.png +0 -0
  28. data/doc/images/screenshots/en/red-frame-raw.png +0 -0
  29. data/doc/images/screenshots/en/red-frame.png +0 -0
  30. data/doc/images/screenshots/en/ruby-gnome2-raw.png +0 -0
  31. data/doc/images/screenshots/en/ruby-gnome2.png +0 -0
  32. data/doc/images/screenshots/en/rubykaigi2011-raw.png +0 -0
  33. data/doc/images/screenshots/en/rubykaigi2011.png +0 -0
  34. data/doc/images/screenshots/ja/blue-circle-raw.png +0 -0
  35. data/doc/images/screenshots/ja/blue-circle.png +0 -0
  36. data/doc/images/screenshots/ja/clear-blue-raw.png +0 -0
  37. data/doc/images/screenshots/ja/clear-blue.png +0 -0
  38. data/doc/images/screenshots/ja/cozmixng-raw.png +0 -0
  39. data/doc/images/screenshots/ja/cozmixng.png +0 -0
  40. data/doc/images/screenshots/ja/dark-gradation-raw.png +0 -0
  41. data/doc/images/screenshots/ja/dark-gradation.png +0 -0
  42. data/doc/images/screenshots/ja/day-white-raw.png +0 -0
  43. data/doc/images/screenshots/ja/day-white.png +0 -0
  44. data/doc/images/screenshots/ja/debian-raw.png +0 -0
  45. data/doc/images/screenshots/ja/debian.png +0 -0
  46. data/doc/images/screenshots/ja/green-circle-raw.png +0 -0
  47. data/doc/images/screenshots/ja/green-circle.png +0 -0
  48. data/doc/images/screenshots/ja/night-black-raw.png +0 -0
  49. data/doc/images/screenshots/ja/night-black.png +0 -0
  50. data/doc/images/screenshots/ja/rabbit-raw.png +0 -0
  51. data/doc/images/screenshots/ja/rabbit.png +0 -0
  52. data/doc/images/screenshots/ja/ranguba-raw.png +0 -0
  53. data/doc/images/screenshots/ja/ranguba.png +0 -0
  54. data/doc/images/screenshots/ja/red-frame-raw.png +0 -0
  55. data/doc/images/screenshots/ja/red-frame.png +0 -0
  56. data/doc/images/screenshots/ja/ruby-gnome2-raw.png +0 -0
  57. data/doc/images/screenshots/ja/ruby-gnome2.png +0 -0
  58. data/doc/images/screenshots/ja/rubykaigi2011-raw.png +0 -0
  59. data/doc/images/screenshots/ja/rubykaigi2011.png +0 -0
  60. data/doc/ja/install/homebrew.rd +8 -12
  61. data/doc/ja/news.rd +67 -0
  62. data/lib/rabbit/canvas.rb +7 -5
  63. data/lib/rabbit/element/base.rb +1 -5
  64. data/lib/rabbit/element/image.rb +70 -4
  65. data/lib/rabbit/error.rb +7 -1
  66. data/lib/rabbit/formatter.rb +1 -1
  67. data/lib/rabbit/gem-pusher.rb +2 -1
  68. data/lib/rabbit/image/base.rb +67 -3
  69. data/lib/rabbit/image/dia.rb +7 -15
  70. data/lib/rabbit/image/mermaid.rb +73 -0
  71. data/lib/rabbit/image/pdf.rb +21 -5
  72. data/lib/rabbit/image.rb +3 -2
  73. data/lib/rabbit/parser/base.rb +2 -1
  74. data/lib/rabbit/parser/ext/blockdiag.rb +16 -14
  75. data/lib/rabbit/parser/ext/image.rb +36 -9
  76. data/lib/rabbit/parser/markdown/converter.rb +36 -30
  77. data/lib/rabbit/parser/rd/ext/block-verbatim.rb +23 -33
  78. data/lib/rabbit/parser/rd/ext/image.rb +23 -4
  79. data/lib/rabbit/parser/rd/rd2rabbit-lib.rb +3 -1
  80. data/lib/rabbit/parser/rd.rb +1 -1
  81. data/lib/rabbit/parser/wiki/output.rb +9 -9
  82. data/lib/rabbit/parser.rb +2 -2
  83. data/lib/rabbit/properties.rb +14 -1
  84. data/lib/rabbit/renderer/display/drawing-area-base.rb +1 -1
  85. data/lib/rabbit/slide-configuration.rb +4 -0
  86. data/lib/rabbit/task/slide.rb +4 -31
  87. data/lib/rabbit/theme/background-image-toolkit/background-image-toolkit.rb +38 -0
  88. data/lib/rabbit/theme/clear-blue/clear-blue.rb +1 -1
  89. data/lib/rabbit/theme/image/image.rb +3 -0
  90. data/lib/rabbit/theme/image-slide-number/image-slide-number.rb +7 -2
  91. data/lib/rabbit/theme/image-timer/image-timer.rb +8 -3
  92. data/lib/rabbit/theme/pdf/pdf.rb +1 -1
  93. data/lib/rabbit/utils.rb +25 -2
  94. data/lib/rabbit/version.rb +2 -2
  95. data/po/en/rabbit.edit.po +50 -66
  96. data/po/en/rabbit.po +12 -24
  97. data/po/fr/rabbit.edit.po +50 -66
  98. data/po/fr/rabbit.po +12 -24
  99. data/po/ja/rabbit.edit.po +82 -94
  100. data/po/ja/rabbit.po +18 -30
  101. data/rabbit.gemspec +0 -1
  102. data/sample/rabbit-en.md +13 -0
  103. data/sample/rabbit-en.rd +10 -0
  104. data/sample/rabbit.md +21 -0
  105. data/sample/rabbit.rd +20 -0
  106. data/test/command/test-rabbit.rb +1 -0
  107. data/test/parser/test-markdown.rb +2 -2
  108. data/test/test-slide-configuration.rb +2 -1
  109. metadata +7 -26
  110. data/doc/css/jquery-ui/themes/ui-lightness.css +0 -573
  111. data/doc/javascripts/jquery-ui.js +0 -11544
  112. data/doc/javascripts/jquery.js +0 -7179
  113. data/lib/rabbit/slideshare.rb +0 -192
  114. data/test/test-slideshare.rb +0 -34
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ce2e5a227e5b700aab7ed9bf170bd44cdd322e2acf75fdfbd7e846d0a95f5f4
4
- data.tar.gz: 73e79afd0c49ecb664fb98594b589521a4bbaf74bcd1b91209335a22e90f5d74
3
+ metadata.gz: 3bc7a134517bbe5f63d57298ef2843ca3acddbe99a995b7f41ba179a94ef1a97
4
+ data.tar.gz: 30b19d488840c4db1056eb8108c4b0581ebdcf486da9386d22669cc04730758e
5
5
  SHA512:
6
- metadata.gz: 8a76046159d4c2dc9bb19703a59222f1c93d993f9c5928b41b57868b15377f2659629a15492058ede5e3dbeeb32592099dcadb39a8b686187fa45e47129f1107
7
- data.tar.gz: aee5a1944c8fe477b7a879fae1641fcbfa4f02ea050aab9f82415e1eb194a21a994e33512182a51a36c5a595fb992a335e176e7eddc555812bb090b43139affe
6
+ metadata.gz: 20e0421868ffce5e36d65b0260999808b898b16152e2d9e7be4db94633922c80d37b89ca4a24494f77aa0f508e2186208c7bd23abebb1ff06ff83a31117291b2
7
+ data.tar.gz: 42766ca67a7e70a5b5c31ffeafae3aaab515be534a1a97fe977da864d42781e6700562d643c47ec34af6ad991352c9ff2386ee52967ff7c8a63ce83bb377915f
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- ruby -*-
2
2
  #
3
- # Copyright (C) 2008-2014 Kouhei Sutou <kou@cozmixng.org>
3
+ # Copyright (C) 2008-2023 Kouhei Sutou <kou@cozmixng.org>
4
4
  #
5
5
  # This program is free software; you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
@@ -58,6 +58,7 @@ end
58
58
  GetText::Tools::Task.define do |task|
59
59
  task.spec = spec
60
60
  task.files -= Dir.glob("sample/**/*.*")
61
+ task.files -= Dir.glob("test/**/*.*")
61
62
  task.mo_base_directory = "data/locale"
62
63
  end
63
64
 
Binary file
data/doc/_config.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  markdown: kramdown
2
- version: 3.0.1
3
- release_date: 2021-09-25
2
+ version: 3.0.2
3
+ release_date: 2023-06-25
4
4
  rabbiter_version: 2.0.3
5
5
  rabbiter_release_date: 2016-08-21
6
6
  rabbirack_version: 2.0.0
@@ -7,8 +7,6 @@
7
7
  <link rel="shortcut icon" href="/favicon.ico"
8
8
  type="image/vnd.microsfot.icon">
9
9
  <link rel="icon" href="/favicon.png" type="image/png">
10
- <link rel="stylesheet" href="/css/jquery-ui/themes/ui-lightness.css"
11
- type="text/css">
12
10
  <link rel="stylesheet" href="/css/syntax.css" type="text/css">
13
11
  <link rel="stylesheet" href="/css/rabbit.css" type="text/css">
14
12
  <meta property="fb:page_id" content="rabbit.shocker">
@@ -17,11 +15,6 @@
17
15
  <meta property="og:image"
18
16
  content="http://rabbit-shocker.org/images/lavie.png">
19
17
  <meta property="og:site_name" content="Rabbit">
20
- <script type="text/javascript" src="/javascripts/jquery.js"></script>
21
- <script type="text/javascript" src="/javascripts/jquery-ui.js"></script>
22
- <!--[if lt IE 9]>
23
- <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
24
- <![endif]-->
25
18
  <script>
26
19
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
27
20
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
@@ -2,38 +2,33 @@
2
2
  layout: en
3
3
  title: Install with Homebrew
4
4
  ---
5
- == How to install Rabbit with Homebrew on Mac OS X
5
+ == How to install Rabbit with Homebrew on macOS
6
6
 
7
- This document describes how to install Rabbit with Homebrew and RubyGems on Mac OS X.
7
+ This document describes how to install Rabbit with Homebrew and RubyGems on macOS.
8
8
 
9
9
  === Requirements
10
10
 
11
- * An Intel CPU
12
- * OS X Leopard or higher
11
+ * A macOS machine
13
12
  * Xcode with X11 (XQuartz is required)
14
13
 
15
14
  === Install Homebrew
16
15
 
17
- $ ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)
18
-
19
- Then add /usr/local/bin to your PATH.
16
+ Follow the instruction on ((<URL:https://brew.sh>)).
20
17
 
21
18
  === Install softwares Rabbit needs
22
19
 
23
20
  $ brew install cairo
24
- $ brew link cairo
25
- $ brew link --overwrite pixman
26
21
  $ brew install pango
27
22
  $ brew install gtk+
28
- $ brew install poppler --with-glib
29
- $ brew install libsvg
23
+ $ brew install gobject-introspection
24
+ $ brew install poppler
30
25
 
31
26
  === Install Rabbit
32
27
 
33
28
  Exec gem install.
34
29
 
35
- $ sudo PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig gem install rabbit
36
- $ sudo gem install rabbiter # If you want to use Twitter related features
30
+ $ gem install rabbit
31
+ $ gem install rabbiter # If you want to use Twitter related features
37
32
 
38
33
  === Set environment variable
39
34
 
data/doc/en/news.rd CHANGED
@@ -4,6 +4,73 @@ title: News
4
4
  ---
5
5
  {% raw %}
6
6
 
7
+ == 3.0.2: 2023-06-25
8
+
9
+ Image drawing support release.
10
+
11
+ === Improvements
12
+
13
+ ==== rabbit
14
+
15
+ * image: Added support for drawing on image.
16
+
17
+ * image: Added support for (({align=right})).
18
+
19
+ * Added support for Mermaid.
20
+
21
+ * blockdiag: Added support for (({blockdiag3})) command.
22
+
23
+ ==== rabbit-slide
24
+
25
+ * config: Added (({source_code_uri})).
26
+ ((<GH-144|URL:https://github.com/rabbit-shocker/rabbit/issues/144>))
27
+ [Patch by Yusuke Nakamura]
28
+
29
+ * Dropped support for uploading to SlideShare. Because SlideShare
30
+ API dropped support for uploading a slideshow.
31
+
32
+ ==== Theme
33
+
34
+ * image-slide-number: Changed to render images back to the main
35
+ content. It prevents hiding the main content.
36
+
37
+ * image-timer: Changed to render images back to the main
38
+ content. It prevents hiding the main content.
39
+
40
+ * background-image-toolkit: Added support for caption.
41
+
42
+ * clear-blue: Changed to replace (({\n})) with a space character
43
+ instead of just removing it in footer.
44
+
45
+ * pdf: Changed to use (({./theme.rb})) instead of (({canvas.title}))
46
+ theme by default.
47
+
48
+ ==== Document
49
+
50
+ * macos Homebrew: Updated how to install document.
51
+ ((<GH-150|URL:https://github.com/rabbit-shocker/rabbit/issues/150>))
52
+ [Patch by Yusuke Nakamura]
53
+
54
+ === Fixes
55
+
56
+ ==== rabbit
57
+
58
+ * formatter HTML: Fixed a bug that weight configuration is missing.
59
+ ((<GH-146|URL:https://github.com/rabbit-shocker/rabbit/issues/146>))
60
+ [Patch by HASUMI Hitoshi]
61
+
62
+ ==== Theme
63
+
64
+ * image-timer: Fixed a bug that images aren't showed with PDF.
65
+
66
+ * image-slide-number: Fixed a bug that images aren't showed with PDF.
67
+
68
+ === Thanks
69
+
70
+ * Yusuke Nakamura
71
+
72
+ * HASUMI Hitoshi
73
+
7
74
  == 3.0.1: 2021-09-25
8
75
 
9
76
  Ruby 3.0 support release.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -2,37 +2,33 @@
2
2
  layout: ja
3
3
  title: Homebrewでインストール
4
4
  ---
5
- == Mac OS XでHomebrewを使ったインストール方法
5
+ == macOSでHomebrewを使ったインストール方法
6
6
 
7
- Mac OS X のパッケージ管理システムのひとつである Homebrew と RubyGems を利用して
7
+ macOS のパッケージ管理システムのひとつである Homebrew と RubyGems を利用して
8
8
  Rabbit をインストール、利用する手順について説明します。
9
9
 
10
10
  === 事前に準備するもの
11
11
 
12
- * Intel Mac
13
- * Mac OS X Leopard 以上
12
+ * macOS
14
13
  * Xcode と X11(XQuartzをインストール)
15
14
 
16
15
  === Homebrew のインストール
17
16
 
18
- $ ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)
17
+ ((<URL:https://brew.sh/>)) に記載の方法に従ってインストールしてください。
19
18
 
20
- 環境変数 PATH /usr/local/bin を追加します。
21
-
22
- ==== brew install と brew link の実行
19
+ ==== brew install の実行
23
20
 
24
21
  $ brew install cairo
25
- $ brew link cairo
26
- $ brew link --overwrite pixman
27
22
  $ brew install pango
28
23
  $ brew install gtk+
29
- $ brew install poppler --with-glib
24
+ $ brew install gobject-introspection
25
+ $ brew install poppler
30
26
 
31
27
  === Rabbit のインストール
32
28
 
33
29
  gem install を実行します。
34
30
 
35
- $ sudo PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig gem install rabbit
31
+ $ sudo gem install rabbit
36
32
  $ sudo gem install rabbiter # Twitter連携機能を使う場合
37
33
 
38
34
  === 環境変数の設定
data/doc/ja/news.rd CHANGED
@@ -5,6 +5,73 @@ apply_data: false
5
5
  ---
6
6
  {% raw %}
7
7
 
8
+ == 3.0.2: 2023-06-25
9
+
10
+ 画像への描画をサポートしたリリース。
11
+
12
+ === 改良
13
+
14
+ ==== rabbit
15
+
16
+ * image: 画像への描画をサポート。
17
+
18
+ * image: (({align=right}))をサポート。
19
+
20
+ * Mermaidをサポート。
21
+
22
+ * blockdiag: (({blockdiag3}))コマンドをサポート。
23
+
24
+ ==== rabbit-slide
25
+
26
+ * config: (({source_code_uri}))を追加。
27
+ ((<GH-144|URL:https://github.com/rabbit-shocker/rabbit/issues/144>))
28
+ [Yusuke Nakamuraさんがパッチ提供]
29
+
30
+ * SlideShareへのアップロード機能を削除。これはSlideShareのAPIからス
31
+ ライドアップロード機能が削除されたからです。
32
+
33
+ ==== テーマ
34
+
35
+ * image-slide-number: メインコンテンツの後ろに画像を描画するように変
36
+ 更。これによりメインコンテンツを隠すことがなくなります。
37
+
38
+ * image-timer: メインコンテンツの後ろに画像を描画するように変更。こ
39
+ れによりメインコンテンツを隠すことがなくなります。
40
+
41
+ * background-image-toolkit: キャプションをサポート。
42
+
43
+ * clear-blue: フッターの(({\n}))を削除するのではなく空白文字に置換す
44
+ るように変更。
45
+
46
+ * pdf: デフォルトで(({canvas.title}))テーマではなく(({./theme.rb}))
47
+ テーマを使うように変更。
48
+
49
+ ==== ドキュメント
50
+
51
+ * macos Homebrew: インストールドキュメントを更新。
52
+ ((<GH-150|URL:https://github.com/rabbit-shocker/rabbit/issues/150>))
53
+ [Yusuke Nakamuraさんがパッチ提供]
54
+
55
+ === 修正
56
+
57
+ ==== rabbit
58
+
59
+ * formatter HTML: 重みの設定が反映されない問題を修正。
60
+ ((<GH-146|URL:https://github.com/rabbit-shocker/rabbit/issues/146>))
61
+ [HASUMI Hitoshiさんがパッチ提供]
62
+
63
+ ==== テーマ
64
+
65
+ * image-timer: PDFで画像が表示されない問題を修正。
66
+
67
+ * image-slide-number: PDFで画像が表示されない問題を修正。
68
+
69
+ === 感謝
70
+
71
+ * Yusuke Nakamuraさん
72
+
73
+ * HASUMI Hitoshiさん
74
+
8
75
  == 3.0.1: 2021-09-25
9
76
 
10
77
  Ruby 3.0をサポートしたリリース。
data/lib/rabbit/canvas.rb CHANGED
@@ -83,6 +83,8 @@ module Rabbit
83
83
  def_delegators(:@renderer, :shear_context)
84
84
  def_delegators(:@renderer, :save_context, :restore_context)
85
85
  def_delegators(:@renderer, :draw_line, :draw_rectangle, :draw_arc)
86
+ def_delegators(:@renderer, :draw_lines)
87
+ def_delegators(:@renderer, :draw_polygon)
86
88
  def_delegators(:@renderer, :draw_circle, :draw_layout, :draw_pixbuf)
87
89
  def_delegators(:@renderer, :draw_arc_by_radius, :draw_circle_by_radius)
88
90
  def_delegators(:@renderer, :draw_slide, :draw_polygon, :draw_flag)
@@ -345,7 +347,7 @@ module Rabbit
345
347
  apply_theme(@theme_name, &block)
346
348
  end
347
349
 
348
- def parse(source=nil, callback=nil, &block)
350
+ def parse(source=nil, progress=nil, &block)
349
351
  id = Object.new.__id__
350
352
  @parse_request_queue.push(id)
351
353
  @source = source || @source
@@ -355,7 +357,7 @@ module Rabbit
355
357
  keep_index do
356
358
  @renderer.pre_parse
357
359
  clear
358
- Parser.parse(self, @source)
360
+ Parser.parse(self, @source, progress: progress)
359
361
  new_allotted_time = allotted_time
360
362
  reset_timer if new_allotted_time != current_allotted_time
361
363
  apply_timer
@@ -364,7 +366,7 @@ module Rabbit
364
366
  if @parse_request_queue.last != id
365
367
  raise ParseFinish
366
368
  end
367
- callback.call if callback
369
+ progress.call if progress
368
370
  end
369
371
  @renderer.post_parse
370
372
  index = current_index
@@ -382,9 +384,9 @@ module Rabbit
382
384
  end
383
385
  end
384
386
 
385
- def reload_source(callback=nil, &block)
387
+ def reload_source(progress=nil, &block)
386
388
  if need_reload_source?
387
- parse(nil, callback, &block)
389
+ parse(nil, progress, &block)
388
390
  end
389
391
  end
390
392
 
@@ -430,11 +430,7 @@ module Rabbit
430
430
 
431
431
  def make_prop_value(name, *values)
432
432
  formatter_name = to_class_name(name)
433
- begin
434
- unless Format.const_defined?(formatter_name)
435
- raise NameError
436
- end
437
- rescue NameError
433
+ unless Format.const_defined?(formatter_name)
438
434
  raise UnknownPropertyError.new(name)
439
435
  end
440
436
  Format.const_get(formatter_name).new(*values)
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2004-2020 Sutou Kouhei <kou@cozmixng.org>
1
+ # Copyright (C) 2004-2021 Sutou Kouhei <kou@cozmixng.org>
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or modify
4
4
  # it under the terms of the GNU General Public License as published by
@@ -29,21 +29,27 @@ module Rabbit
29
29
  alias image_draw draw
30
30
  alias draw element_draw
31
31
 
32
- def initialize(filename, props)
33
- super(filename, props)
32
+ def initialize(filename, props, canvas: nil)
33
+ super(filename, props, canvas: canvas)
34
34
  setup_draw_parameters
35
35
  resize(properties.get_size("width", @filename),
36
36
  properties.get_size("height", @filename))
37
37
  end
38
38
 
39
39
  def draw_element(canvas, x, y, w, h, simulation)
40
- draw_image(canvas, x, y, w, h, simulation)
40
+ result = draw_image(canvas, x, y, w, h, simulation)
41
+ draw_properties(canvas, x, y, w, h) unless simulation
42
+ result
41
43
  end
42
44
 
43
45
  def caption
44
46
  self["caption"]
45
47
  end
46
48
 
49
+ def caption_font_size
50
+ properties.get_float("caption-font-size")
51
+ end
52
+
47
53
  def text
48
54
  caption.to_s
49
55
  end
@@ -113,10 +119,12 @@ module Rabbit
113
119
  adjust_size(canvas, @x, @y, @w, @h)
114
120
  end
115
121
 
122
+ alias_method :width_without_padding, :width
116
123
  def width
117
124
  super + @padding_left + @padding_right
118
125
  end
119
126
 
127
+ alias_method :height_without_padding, :height
120
128
  def height
121
129
  super + @padding_top + @padding_bottom
122
130
  end
@@ -191,6 +199,64 @@ module Rabbit
191
199
  end
192
200
  resize(iw, ih)
193
201
  end
202
+
203
+ def draw_properties(canvas, base_x, base_y, base_w, base_h)
204
+ properties.draws.each do |type, *args|
205
+ case type
206
+ when "line"
207
+ if args.last.is_a?(Hash)
208
+ params = args.pop
209
+ else
210
+ params = nil
211
+ end
212
+ points = args.each_slice(2).collect do |x, y|
213
+ x = (x * width_without_padding) + base_x
214
+ y = (y * height_without_padding) + base_y
215
+ [x, y]
216
+ end
217
+ params = normalize_params(params)
218
+ color = params.delete(:color) || "black"
219
+ canvas.draw_lines(points, color, params)
220
+ when "rectangle"
221
+ filled, x, y, w, h, params = args
222
+ x = (x * width_without_padding) + base_x
223
+ y = (y * height_without_padding) + base_y
224
+ w = (w * width_without_padding)
225
+ h = (h * height_without_padding)
226
+ params = normalize_params(params)
227
+ color = params.delete(:color) || "black"
228
+ canvas.draw_rectangle(filled, x, y, w, h, color, params)
229
+ when "text"
230
+ text, x, y, params = args
231
+ params = normalize_params(params)
232
+ layout = canvas.make_layout(markup_text(text, params))
233
+ x = (x * width_without_padding) + base_x
234
+ y = (y * height_without_padding) + base_y
235
+ color = params.delete(:color) || "black"
236
+ canvas.draw_layout(layout, x, y, color, params)
237
+ end
238
+ end
239
+ end
240
+
241
+ def normalize_params(params)
242
+ return {} if params.nil?
243
+ normalized_params = {}
244
+ params.each do |key, value|
245
+ normalized_params[key.to_sym] = value
246
+ end
247
+ normalized_params
248
+ end
249
+
250
+ def markup_text(text, props)
251
+ props.each do |name, value|
252
+ formatter_name = Utils.to_class_name(name.to_s)
253
+ next unless Format.const_defined?(formatter_name)
254
+ formatter = Format.const_get(formatter_name).new(value)
255
+ next unless formatter.text_formatter?
256
+ text = formatter.format(text)
257
+ end
258
+ text
259
+ end
194
260
  end
195
261
  end
196
262
  end
data/lib/rabbit/error.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2004-2017 Kouhei Sutou <kou@cozmixng.org>
1
+ # Copyright (C) 2004-2022 Sutou Kouhei <kou@cozmixng.org>
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or modify
4
4
  # it under the terms of the GNU General Public License as published by
@@ -87,6 +87,12 @@ module Rabbit
87
87
  end
88
88
  end
89
89
 
90
+ class MermaidCanNotHandleError < ImageLoadWithExternalCommandError
91
+ def initialize(command, additional_info=nil)
92
+ super("Mermaid", command, additional_info)
93
+ end
94
+ end
95
+
90
96
  class UnknownPropertyError < Error
91
97
  attr_reader :name
92
98
  def initialize(name)
@@ -131,7 +131,7 @@ EOC
131
131
  end
132
132
  end
133
133
 
134
- class Weigth
134
+ class Weight
135
135
  private
136
136
  def css_name
137
137
  "font-weight"
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2016-2021 Sutou Kouhei <kou@cozmixng.org>
1
+ # Copyright (C) 2016-2023 Sutou Kouhei <kou@cozmixng.org>
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or modify
4
4
  # it under the terms of the GNU General Public License as published by
@@ -41,6 +41,7 @@ module Rabbit
41
41
  end
42
42
  unless credentials.key?(@user.to_sym)
43
43
  credentials[@user.to_sym] = retrieve_api_key
44
+ FileUtils.mkdir_p(File.dirname(credentials_path))
44
45
  File.open(credentials_path, "w") do |credentials_file|
45
46
  credentials_file.print(credentials.to_yaml)
46
47
  end