helphelp 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/output.rb +27 -23
  2. data/lib/version.rb +1 -1
  3. metadata +53 -67
@@ -2,13 +2,13 @@ class Output
2
2
 
3
3
  def initialize input_repo
4
4
  @input_repo = input_repo
5
-
5
+
6
6
  @content_width = 600
7
7
  end
8
8
 
9
9
  def create output_dir
10
10
  @output_dir = output_dir
11
-
11
+
12
12
  if !File.exists? output_dir
13
13
  Dir::mkdir output_dir
14
14
  end
@@ -23,18 +23,18 @@ class Output
23
23
  cmd = "cp #{public_source_dir}/* #{public_dir}"
24
24
  system cmd
25
25
  end
26
-
26
+
27
27
  @input_path = Array.new
28
28
  @output_path = Array.new
29
29
 
30
30
  @root_page = Page.new
31
31
  @root_page.directory_path = @output_path
32
32
  @root_page.level = -1
33
-
33
+
34
34
  process_directory @input_repo, @root_page
35
35
 
36
36
  postprocess_page @root_page
37
-
37
+
38
38
  create_pages @root_page
39
39
  end
40
40
 
@@ -44,10 +44,11 @@ class Output
44
44
  postprocess_page page
45
45
  end
46
46
  end
47
-
47
+
48
48
  def process_directory dir, parent_page
49
49
  Dir.entries( dir ).sort.each do |entry|
50
- if entry =~ /^\d\d\d_(.*)$/
50
+ case entry
51
+ when /^\d\d\d_(.*)$/
51
52
  input_name = $1
52
53
  full_name = input_path + "/" + entry
53
54
  if File.directory?( full_name )
@@ -60,7 +61,7 @@ class Output
60
61
  page = Page.new
61
62
  parent_page.add_child page
62
63
  page.directory_path = full_name
63
-
64
+
64
65
  process_directory full_name, page
65
66
  @input_path.pop
66
67
  @output_path.pop
@@ -100,12 +101,15 @@ extension."
100
101
  end
101
102
  page.output_file = output_path + "/" + output_file_name
102
103
  end
103
- elsif entry =~ /.*\.png$/
104
+ when /.*\.png$/
104
105
  cmd = "cp #{input_path}/#{entry} #{output_path}/#{entry}"
105
106
  system cmd
106
107
  cmd = "mogrify -resize #{@content_width}x5000 #{output_path}/#{entry}"
107
108
  STDERR.puts "Resize picture: #{cmd}"
108
109
  system cmd
110
+ when /.*\.xml$/
111
+ cmd = "cp #{input_path}/#{entry} #{output_path}/#{entry}"
112
+ system cmd
109
113
  end
110
114
  end
111
115
  end
@@ -122,45 +126,45 @@ extension."
122
126
  def input_path
123
127
  @input_repo + "/" + @input_path.join( "/" )
124
128
  end
125
-
129
+
126
130
  def output_path
127
131
  @output_dir + "/" + @output_path.join( "/" )
128
132
  end
129
-
133
+
130
134
  def create_page page
131
135
  STDERR.puts "Create page: #{page.path} -> #{page.output_file}"
132
136
  @page = page
133
137
  create_file "_view/template.haml", page.output_file
134
138
  end
135
-
139
+
136
140
  def create_file template_name, output_filename
137
141
  template = File.read File.expand_path(template_name, @input_repo )
138
142
  engine = Haml::Engine.new template
139
-
143
+
140
144
  File.open output_filename, "w" do |file|
141
145
  file.puts engine.render( binding )
142
146
  end
143
147
  end
144
148
 
145
149
  def css name
146
- "<link rel='stylesheet' href='#{@page.relative_site_root}public/#{name}.css'" +
150
+ "<link rel='stylesheet' href='#{@page.relative_site_root}public/#{name}.css'" +
147
151
  " type='text/css'>"
148
152
  end
149
153
 
150
154
  def title
151
155
  @page.title
152
156
  end
153
-
157
+
154
158
  def render_content
155
159
  @out = ""
156
160
 
157
161
  on "<div class=\"content page-#{@page.file_basename}\">"
158
-
162
+
159
163
  doc = Maruku.new @page.content
160
164
  on doc.to_html
161
165
 
162
166
  on "</div>"
163
-
167
+
164
168
  @out
165
169
  end
166
170
 
@@ -172,16 +176,16 @@ extension."
172
176
 
173
177
  @out
174
178
  end
175
-
179
+
176
180
  def render_toc_section parent_page
177
181
  on "<ul>"
178
182
  parent_page.children.each do |page|
179
183
  item_classes = []
180
-
184
+
181
185
  if parent_page != @root_page
182
186
  item_classes.push "sub-item"
183
187
  end
184
-
188
+
185
189
  title = page.title
186
190
  if page.has_children?
187
191
  item_classes.push "has-children"
@@ -210,9 +214,9 @@ extension."
210
214
  end
211
215
  on "</ul>"
212
216
  end
213
-
217
+
214
218
  protected
215
-
219
+
216
220
  def o txt
217
221
  @out += txt.to_s
218
222
  end
@@ -220,5 +224,5 @@ extension."
220
224
  def on txt
221
225
  o txt + "\n"
222
226
  end
223
-
227
+
224
228
  end
@@ -1,5 +1,5 @@
1
1
  module Helphelp
2
2
 
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
 
5
5
  end
metadata CHANGED
@@ -1,107 +1,93 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: helphelp
3
- version: !ruby/object:Gem::Version
4
- hash: 19
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 6
10
- version: 0.0.6
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Cornelius Schumacher
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-08-01 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-08-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: maruku
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: haml
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: haml
32
+ requirement: !ruby/object:Gem::Requirement
39
33
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
47
38
  type: :runtime
48
- version_requirements: *id002
49
- description: |
50
- Generator for turning a directory hierarchy of markdown files into a static
51
- set of HTML pages. It's targeted at providing online help for web application.
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: ! 'Generator for turning a directory hierarchy of markdown files into
47
+ a static
52
48
 
49
+ set of HTML pages. It''s targeted at providing online help for web application.
50
+
51
+ '
53
52
  email: cschum@suse.de
54
- executables:
53
+ executables:
55
54
  - helphelp
56
55
  extensions: []
57
-
58
56
  extra_rdoc_files: []
59
-
60
- files:
57
+ files:
61
58
  - README
62
59
  - Rakefile
63
60
  - LICENSE
64
- - lib/parse_error.rb
65
61
  - lib/helphelp.rb
62
+ - lib/page.rb
63
+ - lib/parse_error.rb
66
64
  - lib/output.rb
67
65
  - lib/version.rb
68
- - lib/page.rb
69
66
  - bin/helphelp
70
67
  - test/page_test.rb
71
68
  - test/test_helper.rb
72
- has_rdoc: true
73
69
  homepage: http://github.com/susestudio/helphelp
74
70
  licenses: []
75
-
76
71
  post_install_message:
77
72
  rdoc_options: []
78
-
79
- require_paths:
73
+ require_paths:
80
74
  - lib
81
- required_ruby_version: !ruby/object:Gem::Requirement
75
+ required_ruby_version: !ruby/object:Gem::Requirement
82
76
  none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
88
- - 0
89
- version: "0"
90
- required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
82
  none: false
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- hash: 3
96
- segments:
97
- - 0
98
- version: "0"
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
99
87
  requirements: []
100
-
101
88
  rubyforge_project:
102
- rubygems_version: 1.5.0
89
+ rubygems_version: 1.8.23
103
90
  signing_key:
104
91
  specification_version: 3
105
92
  summary: Online help generator
106
93
  test_files: []
107
-