webby 0.9.3-x86-mswin32 → 0.9.4-x86-mswin32

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 (145) hide show
  1. data/History.txt +20 -0
  2. data/{README.txt → README.rdoc} +9 -9
  3. data/Rakefile +19 -6
  4. data/examples/blog/content/css/blueprint/ie.css +26 -0
  5. data/examples/blog/content/css/blueprint/plugins/buttons/icons/cross.png +0 -0
  6. data/examples/blog/content/css/blueprint/plugins/buttons/icons/key.png +0 -0
  7. data/examples/blog/content/css/blueprint/plugins/buttons/icons/tick.png +0 -0
  8. data/examples/{website/content/css/blueprint/plugins/buttons/Readme → blog/content/css/blueprint/plugins/buttons/readme.txt} +3 -2
  9. data/examples/{website/content/css/blueprint/plugins/buttons/buttons.css → blog/content/css/blueprint/plugins/buttons/screen.css} +1 -1
  10. data/examples/blog/content/css/blueprint/plugins/fancy-type/readme.txt +14 -0
  11. data/examples/{website/content/css/blueprint/plugins/fancy-type/fancy-type.css → blog/content/css/blueprint/plugins/fancy-type/screen.css} +2 -5
  12. data/examples/blog/content/css/blueprint/plugins/link-icons/icons/doc.png +0 -0
  13. data/examples/blog/content/css/blueprint/plugins/link-icons/icons/email.png +0 -0
  14. data/examples/blog/content/css/blueprint/plugins/link-icons/icons/external.png +0 -0
  15. data/examples/blog/content/css/blueprint/plugins/link-icons/icons/feed.png +0 -0
  16. data/examples/blog/content/css/blueprint/plugins/link-icons/icons/im.png +0 -0
  17. data/examples/blog/content/css/blueprint/plugins/link-icons/icons/pdf.png +0 -0
  18. data/examples/blog/content/css/blueprint/plugins/link-icons/icons/visited.png +0 -0
  19. data/examples/blog/content/css/blueprint/plugins/link-icons/icons/xls.png +0 -0
  20. data/examples/blog/content/css/blueprint/plugins/link-icons/readme.txt +18 -0
  21. data/examples/blog/content/css/blueprint/plugins/link-icons/screen.css +40 -0
  22. data/examples/blog/content/css/blueprint/plugins/rtl/readme.txt +10 -0
  23. data/examples/blog/content/css/blueprint/plugins/rtl/screen.css +109 -0
  24. data/examples/blog/content/css/blueprint/print.css +30 -0
  25. data/examples/blog/content/css/blueprint/screen.css +251 -0
  26. data/examples/blog/content/css/blueprint/src/forms.css +49 -0
  27. data/examples/blog/content/css/blueprint/src/grid.css +212 -0
  28. data/examples/{website/content/css/blueprint/lib → blog/content/css/blueprint/src}/grid.png +0 -0
  29. data/examples/blog/content/css/blueprint/src/ie.css +59 -0
  30. data/examples/blog/content/css/blueprint/src/print.css +85 -0
  31. data/examples/{website/content/css/blueprint/lib → blog/content/css/blueprint/src}/reset.css +14 -15
  32. data/examples/blog/content/css/blueprint/src/typography.css +105 -0
  33. data/examples/blog/content/css/coderay.css +111 -0
  34. data/examples/blog/content/css/site.css +67 -0
  35. data/examples/blog/layouts/default.txt +61 -0
  36. data/examples/blog/tasks/blog.rake +5 -1
  37. data/examples/presentation/Sitefile +2 -2
  38. data/examples/tumblog/tasks/tumblog.rake +5 -1
  39. data/examples/webby/Sitefile +2 -2
  40. data/examples/webby/content/communicate/index.txt +2 -2
  41. data/examples/webby/content/index.txt +1 -1
  42. data/examples/webby/content/release-notes/rel-0-9-3/index.txt +0 -2
  43. data/examples/webby/content/release-notes/rel-0-9-4/index.txt +33 -0
  44. data/examples/webby/content/sitemap.txt +2 -2
  45. data/examples/webby/content/user-manual/index.txt +3 -3
  46. data/examples/website/content/css/blueprint/ie.css +26 -0
  47. data/examples/website/content/css/blueprint/plugins/buttons/readme.txt +32 -0
  48. data/examples/website/content/css/blueprint/plugins/buttons/screen.css +97 -0
  49. data/examples/website/content/css/blueprint/plugins/fancy-type/readme.txt +14 -0
  50. data/examples/website/content/css/blueprint/plugins/fancy-type/screen.css +71 -0
  51. data/examples/website/content/css/blueprint/plugins/link-icons/icons/doc.png +0 -0
  52. data/examples/website/content/css/blueprint/plugins/link-icons/icons/email.png +0 -0
  53. data/examples/website/content/css/blueprint/plugins/link-icons/icons/external.png +0 -0
  54. data/examples/website/content/css/blueprint/plugins/link-icons/icons/feed.png +0 -0
  55. data/examples/website/content/css/blueprint/plugins/link-icons/icons/im.png +0 -0
  56. data/examples/website/content/css/blueprint/plugins/link-icons/icons/pdf.png +0 -0
  57. data/examples/website/content/css/blueprint/plugins/link-icons/icons/visited.png +0 -0
  58. data/examples/website/content/css/blueprint/plugins/link-icons/icons/xls.png +0 -0
  59. data/examples/website/content/css/blueprint/plugins/link-icons/readme.txt +18 -0
  60. data/examples/website/content/css/blueprint/plugins/link-icons/screen.css +40 -0
  61. data/examples/website/content/css/blueprint/plugins/rtl/readme.txt +10 -0
  62. data/examples/website/content/css/blueprint/plugins/rtl/screen.css +109 -0
  63. data/examples/website/content/css/blueprint/print.css +30 -68
  64. data/examples/website/content/css/blueprint/screen.css +251 -22
  65. data/examples/website/content/css/blueprint/src/forms.css +49 -0
  66. data/examples/website/content/css/blueprint/src/grid.css +212 -0
  67. data/examples/website/content/css/blueprint/src/grid.png +0 -0
  68. data/examples/website/content/css/blueprint/src/ie.css +59 -0
  69. data/examples/website/content/css/blueprint/src/print.css +85 -0
  70. data/examples/website/content/css/blueprint/src/reset.css +38 -0
  71. data/examples/website/content/css/blueprint/src/typography.css +105 -0
  72. data/examples/website/layouts/default.txt +5 -2
  73. data/lib/webby.rb +36 -102
  74. data/lib/webby/apps/generator.rb +2 -2
  75. data/lib/webby/apps/main.rb +36 -62
  76. data/lib/webby/auto_builder.rb +3 -3
  77. data/lib/webby/builder.rb +5 -13
  78. data/lib/webby/config.rb +172 -0
  79. data/lib/webby/filters.rb +2 -0
  80. data/lib/webby/filters/haml.rb +13 -0
  81. data/lib/webby/filters/maruku.rb +16 -0
  82. data/lib/webby/filters/outline.rb +1 -1
  83. data/lib/webby/filters/sass.rb +14 -0
  84. data/lib/webby/filters/slides.rb +2 -2
  85. data/lib/webby/filters/tidy.rb +5 -0
  86. data/lib/webby/helpers/coderay_helper.rb +27 -3
  87. data/lib/webby/helpers/graphviz_helper.rb +20 -3
  88. data/lib/webby/helpers/tex_img_helper.rb +25 -5
  89. data/lib/webby/helpers/ultraviolet_helper.rb +19 -5
  90. data/lib/webby/link_validator.rb +59 -51
  91. data/lib/webby/renderer.rb +9 -6
  92. data/lib/webby/resources.rb +2 -1
  93. data/lib/webby/resources/page.rb +4 -1
  94. data/lib/webby/tasks/create.rake +1 -1
  95. data/lib/webby/tasks/validate.rake +1 -1
  96. data/spec/data/html/anchor.html +11 -0
  97. data/spec/data/html/external.html +10 -0
  98. data/spec/data/html/invalid-relative.html +10 -0
  99. data/spec/data/html/relative-anchor.html +10 -0
  100. data/spec/data/html/relative-invalid-anchor.html +10 -0
  101. data/spec/data/html/relative.html +10 -0
  102. data/spec/data/site/tasks/tumblog.rake +5 -1
  103. data/spec/spec_helper.rb +8 -1
  104. data/spec/webby/apps/generator_spec.rb +36 -3
  105. data/spec/webby/apps/main_spec.rb +2 -1
  106. data/spec/webby/filters/basepath_spec.rb +2 -2
  107. data/spec/webby/filters/maruku_spec.rb +31 -0
  108. data/spec/webby/filters/textile_spec.rb +15 -4
  109. data/spec/webby/helpers/capture_helper_spec.rb +1 -1
  110. data/spec/webby/link_validator_spec.rb +154 -0
  111. data/spec/webby/resources/db_spec.rb +24 -24
  112. data/spec/webby/resources/layout_spec.rb +1 -1
  113. data/spec/webby/resources/page_spec.rb +8 -2
  114. data/spec/webby/resources/resource_spec.rb +1 -1
  115. data/spec/webby/resources_spec.rb +1 -1
  116. data/tasks/ann.rake +1 -2
  117. data/tasks/bones.rake +0 -1
  118. data/tasks/gem.rake +48 -34
  119. data/tasks/git.rake +0 -1
  120. data/tasks/mswin32.rake +38 -0
  121. data/tasks/notes.rake +0 -1
  122. data/tasks/post_load.rake +4 -9
  123. data/tasks/rdoc.rake +4 -4
  124. data/tasks/setup.rb +50 -26
  125. data/tasks/spec.rake +1 -2
  126. data/tasks/svn.rake +47 -0
  127. data/tasks/test.rake +40 -0
  128. data/tasks/website.rake +0 -1
  129. data/tasks/zentest.rake +36 -0
  130. metadata +104 -33
  131. data/Manifest.txt +0 -228
  132. data/examples/website/content/css/blueprint/License.txt +0 -21
  133. data/examples/website/content/css/blueprint/Readme.txt +0 -100
  134. data/examples/website/content/css/blueprint/compressed/print.css +0 -76
  135. data/examples/website/content/css/blueprint/compressed/screen.css +0 -696
  136. data/examples/website/content/css/blueprint/lib/forms.css +0 -45
  137. data/examples/website/content/css/blueprint/lib/grid.css +0 -193
  138. data/examples/website/content/css/blueprint/lib/ie.css +0 -30
  139. data/examples/website/content/css/blueprint/lib/typography.css +0 -116
  140. data/examples/website/content/css/blueprint/plugins/css-classes/Readme +0 -14
  141. data/examples/website/content/css/blueprint/plugins/css-classes/css-classes.css +0 -24
  142. data/examples/website/content/css/blueprint/plugins/fancy-type/Readme +0 -22
  143. data/examples/website/content/css/blueprint/plugins/fancy-type/fancy-type-compressed.css +0 -5
  144. data/lib/webby/stelan/spawner.rb +0 -339
  145. data/tasks/manifest.rake +0 -48
@@ -74,10 +74,8 @@ class Builder
74
74
  def new_page_info
75
75
  args = Webby.site.args
76
76
 
77
- if args.raw.empty?
78
- task_name = Rake.application.top_level_tasks.first
79
- raise "Usage: webby #{task_name} path"
80
- end
77
+ # TODO: maybe even get rid of this method altogether
78
+ raise "Usage: webby #{args.rake.first} 'path'" if args.raw.empty?
81
79
 
82
80
  [args.page, args.title, args.dir]
83
81
  end
@@ -131,7 +129,7 @@ class Builder
131
129
  FileUtils.mkdir output_dir
132
130
  end
133
131
 
134
- load_files if opts[:load_files]
132
+ ::Webby.load_files if opts[:load_files]
135
133
 
136
134
  Resources.pages.each do |page|
137
135
  unless page.dirty? or opts[:rebuild]
@@ -157,15 +155,9 @@ class Builder
157
155
  nil
158
156
  end
159
157
 
160
- # Scan the <code>layouts/</code> folder and the <code>content/</code>
161
- # folder and create a new Resource object for each file found there.
162
- #
163
158
  def load_files
164
- ::Find.find(layout_dir, content_dir) do |path|
165
- next unless test ?f, path
166
- next if path =~ ::Webby.exclude
167
- Resources.new path
168
- end
159
+ ::Webby.deprecated "load_files", "it is being replaced by the Webby#load() method"
160
+ ::Webby.load_files
169
161
  end
170
162
 
171
163
  %w(output_dir layout_dir content_dir).each do |key|
@@ -0,0 +1,172 @@
1
+ # These are the main configuration options for Webby. Options for specific
2
+ # filters and helpers are defined in those files. Even a few of the rake
3
+ # tasks in the "examples" folder have their own configuration options
4
+ # defined.
5
+ #
6
+ # The nice thing about Loquacious configurations is that all these options
7
+ # can be defined where they are used, but the descriptions can be viewed by
8
+ # the user in one handy page.
9
+
10
+ Loquacious.configuration_for(:webby) {
11
+
12
+ desc 'The generated website will be output to this directory.'
13
+ output_dir 'output'
14
+
15
+ desc <<-__
16
+ The directory containg the main site content - pages, partials, css
17
+ stylesheets, etc.
18
+ __
19
+ content_dir 'content'
20
+
21
+ desc 'The directory containing the layout files.'
22
+ layout_dir 'layouts'
23
+
24
+ desc <<-__
25
+ The directory where page templtes can be found. These templates are used
26
+ by the 'webby create' command to define the boiler-plate for new pages
27
+ (things like the meta-data or standard text).
28
+ __
29
+ template_dir 'templates'
30
+
31
+ desc <<-__
32
+ This is an array of regular expression patterns that will exclude files
33
+ from webby processing. The patterns will be joined using the regular
34
+ expression OR operator '|'.
35
+ __
36
+ exclude %w{tmp$ bak$ ~$ CVS \.svn}
37
+
38
+ desc <<-__
39
+ A set of default meta-data values that are added to every page rendered
40
+ by webby. Specific values in the page override the default values
41
+ defined here. For example, you could define a default set of filters
42
+ |
43
+ | SITE.page_defaults = {
44
+ | 'layout' => 'default',
45
+ | 'filter' => ['erb', 'textile']
46
+ | }
47
+ |
48
+ Now, every page will be run through the ERB filter and then the
49
+ Textile filter. Specific pages can override the set of filters or omit
50
+ them altogether as needed.
51
+ __
52
+ page_defaults({
53
+ 'layout' => 'default'
54
+ })
55
+
56
+ desc <<-__
57
+ Defines the default page attribute that will be used by the
58
+ 'link_to_page' method to find other pages in the site. If this value
59
+ is set to :title, then the title found in the page meta-data is
60
+ searched for a match. If this value is set to :filename, then the
61
+ filenames of pages are search for a match.
62
+
63
+ This value can be overridden on a case by case basis when the
64
+ 'link_to_page' method is called.
65
+ __
66
+ find_by :title
67
+
68
+ desc <<-__
69
+ Using the 'webby create' task, new pages can either be created as a
70
+ normal page or as an index page in it's own directory. The latter
71
+ option allows your pages to have "nice" URLs:
72
+ |
73
+ | foo/bar/my-new-post.html <-- 'page'
74
+ | foo/bar/my-new-post/ <-- 'directory'
75
+ |
76
+ The two options supported by the 'create_mode' are either 'page'
77
+ or 'directory'.
78
+ __
79
+ create_mode 'page'
80
+
81
+ desc <<-__
82
+ When the 'webby create' task is used to create a new page in your site,
83
+ webby will automatically open your favorite editor. Use this option to
84
+ define which editor webby will start. Set this option to nil if you do
85
+ not want webby to launch an editor when you create new pages.
86
+
87
+ The default is taken from the environment as either 'WEBBY_EDITOR' or
88
+ 'EDITOR', whichever is defined.
89
+ __
90
+ editor ENV['WEBBY_EDITOR'] || ENV['EDITOR']
91
+
92
+ desc <<-__
93
+ This flag determines whether or not the internal web server is launched
94
+ when the autobuild loop is running. The default is to launch the web
95
+ server. Set to false to disable.
96
+ __
97
+ use_web_server true
98
+
99
+ desc <<-__
100
+ Defines the port number the internal web server will use when the
101
+ autobuild loop is running.
102
+ __
103
+ web_port 4331
104
+
105
+ desc <<-__
106
+ The username that will be used when publishing a site to the remote host.
107
+ Login to the remote host will take the form 'user@host' where both 'user'
108
+ and 'host' are configuration options.
109
+
110
+ The default is taken from the environment as either 'USER' or
111
+ 'USERNAME', whichever is defined.
112
+ __
113
+ user ENV['USER'] || ENV['USERNAME']
114
+
115
+ desc <<-__
116
+ The hostname that will be used when publishing a site to the remote host.
117
+ Login to the remote host will take the form 'user@host' where both 'user'
118
+ and 'host' are configuration options.
119
+ __
120
+ host 'example.com'
121
+
122
+ desc <<-__
123
+ The destination directory on the remote host where the site will
124
+ be published.
125
+ __
126
+ remote_dir '/dev/null'
127
+
128
+ desc <<-__
129
+ Arguments that will be passed to the rysnc command when deploying the
130
+ site to the remote host. This array of arguments will be joined together
131
+ by spaces.
132
+ __
133
+ rsync_args %w(-av)
134
+
135
+ desc <<-__
136
+ The list of URIs that will automatically pass validation when the webby
137
+ validate task is run.
138
+ __
139
+ valid_uris []
140
+
141
+ desc <<-__
142
+ The base URL of the site. This value is used by the 'basepath' filter to
143
+ replace leading slashes in URIs with this base value. The URIs to replace
144
+ are identified by the 'xpaths' option.
145
+ __
146
+ base nil
147
+
148
+ desc <<-__
149
+ The basepath filter is used to replace leading slashes in URIs with the
150
+ text from the 'base' option. Only those URIs identified by the XPaths
151
+ defined here will be altered. You can add to or remove XPaths from this
152
+ list depending on your needs.
153
+ __
154
+ xpaths %w{
155
+ /html/head//base[@href]
156
+ /html/head//link[@href]
157
+ //script[@src]
158
+ /html/body[@background]
159
+ /html/body//a[@href]
160
+ /html/body//object[@data]
161
+ /html/body//img[@src]
162
+ /html/body//area[@href]
163
+ /html/body//form[@action]
164
+ /html/body//input[@src]
165
+ }
166
+ # other possible XPaths to include for base path substitution
167
+ # /html/body//object[@usemap]
168
+ # /html/body//img[@usemap]
169
+ # /html/body//input[@usemap]
170
+ }
171
+
172
+ # EOF
@@ -70,6 +70,8 @@ module Filters
70
70
  result = handler.call(*args)
71
71
  @processed += 1
72
72
  result
73
+ rescue StandardError => err
74
+ raise ::Webby::Error, "#{filter} filter error: #{err.message.inspect}"
73
75
  end
74
76
 
75
77
  end # class Cursor
@@ -2,8 +2,21 @@
2
2
  # Render text via the Haml library
3
3
  if try_require('haml', 'haml')
4
4
 
5
+ Loquacious.configuration_for(:webby) {
6
+ desc <<-__
7
+ A hash of options that will be passed to the Haml::Engine when procesing
8
+ content through the 'haml' filter. See the Haml rdoc documentation for
9
+ the list of available options.
10
+
11
+ Note: webby will set the :filename to the current page being rendered.
12
+ __
13
+ haml_options Hash.new
14
+ }
15
+
5
16
  Webby::Filters.register :haml do |input, cursor|
6
17
  opts = ::Webby.site.haml_options.merge(cursor.page.haml_options || {})
18
+ opts = opts.symbolize_keys
19
+ opts.merge!(:filename => cursor.page.destination)
7
20
  b = cursor.renderer.get_binding
8
21
  Haml::Engine.new(input, opts).to_html(b)
9
22
  end
@@ -0,0 +1,16 @@
1
+
2
+ # Render text via markdown using the Maruku library.
3
+ if try_require('maruku', 'maruku')
4
+
5
+ Webby::Filters.register :maruku do |input|
6
+ Maruku.new(input).to_html
7
+ end
8
+
9
+ # Otherwise raise an error if the user tries to use maruku
10
+ else
11
+ Webby::Filters.register :maruku do |input|
12
+ raise Webby::Error, "'maruku' must be installed to use the maruku filter"
13
+ end
14
+ end
15
+
16
+ # EOF
@@ -175,7 +175,7 @@ class Outline
175
175
 
176
176
  lbl = label
177
177
  if numbering?
178
- elem.children.first.before {tag!(:span, lbl, :class => 'heading-num')}
178
+ elem.children.first.before %Q{<span class="heading-num">#{lbl}</span>}
179
179
  end
180
180
  elem['id'] = "h#{lbl.tr('.','_')}" if elem['id'].nil?
181
181
 
@@ -2,8 +2,22 @@
2
2
  # Render text via the Sass library (part of Haml)
3
3
  if try_require('sass', 'haml')
4
4
 
5
+ Loquacious.configuration_for(:webby) {
6
+ desc <<-__
7
+ A hash of options that will be passed to the Sass::Engine when procesing
8
+ content through the 'sass' filter. See the Sass rdoc documentation for
9
+ the list of available options (par of the haml gem).
10
+
11
+ Note: webby will set the :filename to the current page being rendered.
12
+ __
13
+ sass_options Hash.new
14
+ }
15
+
5
16
  Webby::Filters.register :sass do |input, cursor|
6
17
  opts = ::Webby.site.sass_options.merge(cursor.page.sass_options || {})
18
+ opts = opts.symbolize_keys
19
+ opts.merge!(:filename => cursor.page.destination)
20
+ opts[:style] = opts[:style].to_sym if opts.include? :style
7
21
  Sass::Engine.new(input, opts).render
8
22
  end
9
23
 
@@ -35,9 +35,9 @@ class Slides
35
35
  def filter
36
36
  result = []
37
37
 
38
- @str.split(%r/\<h1\>/i).each do |slide|
38
+ @str.split(%r/\<h1/i).each do |slide|
39
39
  next if slide.strip.empty?
40
- result << START_SLIDE << '<h1>' << slide << END_SLIDE
40
+ result << START_SLIDE << '<h1' << slide << END_SLIDE
41
41
  end
42
42
 
43
43
  result.join
@@ -1,6 +1,11 @@
1
1
  require 'fileutils'
2
2
  require 'tempfile'
3
3
 
4
+ Loquacious.configuration_for(:webby) {
5
+ desc "Options passed to the 'tidy' program when the tidy filter is used"
6
+ tidy_options '-indent -wrap 80'
7
+ }
8
+
4
9
  module Webby
5
10
  module Filters
6
11
 
@@ -1,6 +1,30 @@
1
1
  if try_require 'coderay'
2
2
  require 'enumerator'
3
3
 
4
+ Loquacious.configuration_for(:webby) {
5
+ desc <<-__
6
+ Options for CodeRay syntax highlighting. See the CodeRay home page
7
+ (http://coderay.rubychan.de/) for more information about the available
8
+ options.
9
+ __
10
+ coderay {
11
+ desc 'The language being highlighted (given as a symbol).'
12
+ lang :ruby
13
+
14
+ desc 'Include line numbers in :table, :inline, :list or nil (no line numbers).'
15
+ line_numbers nil
16
+
17
+ desc 'Where to start line number counting.'
18
+ line_number_start 1
19
+
20
+ desc 'Make every N-th number appear bold.'
21
+ bold_every 10
22
+
23
+ desc 'Tabs will be converted into this number of space characters.'
24
+ tab_width 8
25
+ }
26
+ }
27
+
4
28
  module Webby::Helpers
5
29
  module CodeRayHelper
6
30
 
@@ -35,7 +59,7 @@ module CodeRayHelper
35
59
  return if text.empty?
36
60
 
37
61
  defaults = ::Webby.site.coderay
38
- lang = opts.getopt(:lang, defaults[:lang]).to_sym
62
+ lang = opts.getopt(:lang, defaults.lang).to_sym
39
63
 
40
64
  cr_opts = {}
41
65
  %w(line_numbers to_sym
@@ -49,9 +73,9 @@ module CodeRayHelper
49
73
  end
50
74
 
51
75
  #cr.swap(CodeRay.scan(text, lang).html(opts).div)
52
- out = '<div class="CodeRay"><pre>'
76
+ out = %Q{<div class="CodeRay">\n<pre>}
53
77
  out << ::CodeRay.scan(text, lang).html(cr_opts)
54
- out << '</pre></div>'
78
+ out << %Q{</pre>\n</div>}
55
79
 
56
80
  # put some guards around the output (specifically for textile)
57
81
  out = _guard(out)
@@ -1,6 +1,23 @@
1
1
  require 'fileutils'
2
2
  require 'tempfile'
3
3
 
4
+ Loquacious.configuration_for(:webby) {
5
+ desc 'Options for graphviz processing.'
6
+ graphviz {
7
+ desc 'The path in the output folder where images are stored.'
8
+ path nil
9
+
10
+ desc <<-__
11
+ The graphviz command used to render the images.
12
+ (dot, neato, twopi, circo, fdp)
13
+ __
14
+ cmd 'dot'
15
+
16
+ desc 'The type of output image to generate (png, jpg, gif).'
17
+ type 'png'
18
+ }
19
+ }
20
+
4
21
  module Webby::Helpers
5
22
  module GraphvizHelper
6
23
 
@@ -71,9 +88,9 @@ module GraphvizHelper
71
88
  err.close
72
89
 
73
90
  defaults = ::Webby.site.graphviz
74
- path = opts.getopt(:path, defaults[:path])
75
- cmd = opts.getopt(:cmd, defaults[:cmd])
76
- type = opts.getopt(:type, defaults[:type])
91
+ path = opts.getopt(:path, defaults.path)
92
+ cmd = opts.getopt(:cmd, defaults.cmd)
93
+ type = opts.getopt(:type, defaults.type)
77
94
 
78
95
  # pull the name of the graph|digraph out of the DOT script
79
96
  name = text.match(%r/\A\s*(?:strict\s+)?(?:di)?graph\s+([A-Za-z_][A-Za-z0-9_]*)\s+\{/o)[1]
@@ -1,6 +1,26 @@
1
1
  require Webby.libpath(*%w[webby stelan mktemp])
2
2
  require 'fileutils'
3
3
 
4
+ Loquacious.configuration_for(:webby) {
5
+ desc "Options for processing TeX math formula into images."
6
+ tex2img {
7
+ desc 'Where generated images will be stored.'
8
+ path nil
9
+
10
+ desc 'The type of image to generate (png, jpeg, gif).'
11
+ type 'png'
12
+
13
+ desc 'The background color of the image (color name, TeX color spec, or #aabbcc)'
14
+ bg 'white'
15
+
16
+ desc 'The foreground color of the image (color name, TeX color spec, or #aabbcc)'
17
+ fg 'black'
18
+
19
+ desc 'The desired resolution in dpi (HxV)'
20
+ resolution '150x150'
21
+ }
22
+ }
23
+
4
24
  module Webby::Helpers
5
25
  module TexImgHelper
6
26
 
@@ -45,11 +65,11 @@ module TexImgHelper
45
65
  return if text.empty?
46
66
 
47
67
  defaults = ::Webby.site.tex2img
48
- path = opts.getopt(:path, defaults[:path])
49
- type = opts.getopt(:type, defaults[:type])
50
- bg = opts.getopt(:bg, defaults[:bg])
51
- fg = opts.getopt(:fg, defaults[:fg])
52
- res = opts.getopt(:resolution, defaults[:resolution])
68
+ path = opts.getopt(:path, defaults.path)
69
+ type = opts.getopt(:type, defaults.type)
70
+ bg = opts.getopt(:bg, defaults.bg)
71
+ fg = opts.getopt(:fg, defaults.fg)
72
+ res = opts.getopt(:resolution, defaults.resolution)
53
73
 
54
74
  # fix color escaping
55
75
  fg = fg =~ %r/^[a-zA-Z]+$/ ? fg : "\"#{fg}\""