awestruct 0.5.6.beta3 → 0.5.6.beta4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e5073ecf6050f1f66f3cbe58a36c5792b1d1094
4
- data.tar.gz: c8c018ab9bd8f434ee5ae5cc2804f33d27fe85b3
3
+ metadata.gz: 451184e1b282a5edaa7f91b42dbd97c3d65b1c8b
4
+ data.tar.gz: 4f974bef0f5cbd233b4fb5e170c64b5ccd2fb2ae
5
5
  SHA512:
6
- metadata.gz: c9e6167350a3a82b58da176e966df75d3380026cd0bdc6348eb0e65661cee4e010a050e0757b4f5610c0d8b373afe649e981a82c5a73141e788b238c54b5f8e6
7
- data.tar.gz: 8f3031a455d8cbd8bf9fc66afcf57a35c19c3fac151a4af4be5300bcea0a394523f1fe9f692307f5cfda5db990da9ee55aecd072fb4d0d023c58ef6d1735cb7f
6
+ metadata.gz: 050c58ea9b0d2147c60e761712761d8417daf42034576b6b1e88deb6fc49f68e9cbea02ee33f7b5feb1aa54d765c0ce58544d300934a643f3600163385bc7144
7
+ data.tar.gz: 5b6a63471993f469cfe4ca6ba5aa6896b31d8634aee872c60bee0ecb98d93fd607ce1a4a0d79c7881bdbe7f1df31b60402240bc1cd4c163681e90210b35c738a
@@ -4,7 +4,7 @@ require 'awestruct/version'
4
4
  spec = Gem::Specification.new do |s|
5
5
  s.name = 'awestruct'
6
6
  s.version = Awestruct::VERSION
7
- s.date = '2014-10-22'
7
+ s.date = '2014-10-24'
8
8
 
9
9
  s.authors = ['Bob McWhirter', 'Jason Porter', 'Lance Ball', 'Dan Allen', 'Torsten Curdt', 'other contributors']
10
10
  s.email = ['bob@mcwhirter.org', 'lightguard.jp@gmail.com', 'lball@redhat.com', 'dan.j.allen@gmail.com', 'tcurdt@vafer.org']
@@ -34,7 +34,6 @@ Haml and Markdown filters are touchy things. Redcarpet or Rdiscount work well if
34
34
 
35
35
  s.add_dependency 'haml', '~> 4.0.5'
36
36
  s.add_dependency 'asciidoctor' # we're pretty good about backwards compat
37
- s.add_dependency 'nokogiri', '~> 1.5.10'
38
37
  s.add_dependency 'tilt', '~> 2.0.1'
39
38
  s.add_dependency 'compass', '~> 1.0.1'
40
39
  s.add_dependency 'compass-960-plugin', '~> 0.10.4'
@@ -49,4 +48,6 @@ Haml and Markdown filters are touchy things. Redcarpet or Rdiscount work well if
49
48
  s.add_dependency 'guard-livereload', '~> 2.1.2'
50
49
  s.add_dependency 'colorize', '~> 0.7.1'
51
50
  s.add_dependency 'parallel', '> 1.1.1'
51
+
52
+ s.add_development_dependency 'nokogiri', '~> 1.5.10'
52
53
  end
@@ -31,58 +31,58 @@ module Awestruct
31
31
  modified.each do |path| # path is absolute path
32
32
  engine = ::Awestruct::Engine.instance
33
33
 
34
- unless ( path =~ %r(#{File.basename( engine.config.output_dir) }) || path =~ /.awestruct/ || path =~ /sass-cache/ )
35
- begin
36
- $LOG.info "Change detected for file #{path}" if $LOG.info?
37
- if path.eql? current_path
38
- unless generate_thread.nil?
39
- $LOG.info "Same path triggered, stopping previous generation" if generate_thread.alive? && $LOG.info?
40
- generate_thread.kill
41
- end
42
- else
43
- generate_thread.join unless generate_thread.nil?
44
- current_path = path
34
+ begin
35
+ $LOG.info "Change detected for file #{path}" if $LOG.info?
36
+ if path.eql? current_path
37
+ unless generate_thread.nil?
38
+ $LOG.info "Same path triggered, stopping previous generation" if generate_thread.alive? && $LOG.info?
39
+ generate_thread.kill
45
40
  end
41
+ else
42
+ generate_thread.join unless generate_thread.nil?
43
+ current_path = path
44
+ end
46
45
 
47
- generate_thread = Thread.new {
48
- begin
49
- if ( File.extname(path) == '.sass' || File.extname(path) == '.scss' )
50
- ::Compass::Commands::UpdateProject.new(engine.site.dir, {}).perform
46
+ generate_thread = Thread.new {
47
+ begin
48
+ if ( File.extname(path) == '.sass' || File.extname(path) == '.scss' )
49
+ # TODO use sass here, eventually
50
+ ::Compass::Commands::UpdateProject.new(engine.site.dir, {}).perform
51
+ else
52
+ page = engine.page_by_source_path(path)
53
+ pages = []
54
+ if ( page )
55
+ pages = engine.generate_page_and_dependencies( page )
51
56
  else
52
- page = engine.page_by_output_path(path)
53
- pages = []
54
- if ( page )
55
- pages = engine.generate_page_and_dependencies( page )
56
- else
57
- if File.exist? path
58
- # chances are this is an extension or yaml file
59
- pages = engine.run_auto_for_non_page(path)
60
- end
57
+ if File.exist? path
58
+ # chances are this is an extension or yaml file
59
+ pages = engine.run_auto_for_non_page(path)
61
60
  end
62
61
  end
62
+ end
63
63
 
64
- $LOG.info "Regeneration finished." if $LOG.info?
65
-
66
- if ( guard )
67
- urls = pages.map do |p|
68
- @base_url + p.url.to_s
69
- end
64
+ $LOG.info "Regeneration finished." if $LOG.info?
70
65
 
71
- guard.run_on_modifications(urls)
66
+ if ( guard )
67
+ urls = pages.map do |p|
68
+ @base_url + p.url.to_s
72
69
  end
73
70
 
74
- rescue => e
75
- ExceptionHelper.log_building_error e, path
71
+ guard.run_on_modifications(urls)
76
72
  end
77
- }
78
- rescue => e
79
- ExceptionHelper.log_building_error e, path
80
- end
73
+
74
+ rescue => e
75
+ ExceptionHelper.log_building_error e, path
76
+ end
77
+ }
78
+ rescue => e
79
+ ExceptionHelper.log_building_error e, path
81
80
  end
82
81
  end
83
82
  end
84
83
  listener.ignore( %r(\.awestruct) )
85
84
  listener.ignore( %r(^#{File.basename( @config.tmp_dir )}) )
85
+ listener.ignore( %r(\.sass-cache) )
86
86
  listener.ignore( %r(^#{File.basename( @config.output_dir )}) )
87
87
 
88
88
  @config.ignore.each do |i|
@@ -97,9 +97,11 @@ module Awestruct
97
97
  self.auto = true
98
98
  self.port = DEFAULT_PORT
99
99
  self.profile = 'development'
100
+ self.livereload = livereload
100
101
  end
101
102
  opts.on( '-a', '--auto', 'Auto-generate when changes are noticed' ) do |a|
102
103
  self.auto = a
104
+ self.livereload = livereload
103
105
  end
104
106
  opts.on( '--livereload', 'Support for browser livereload' ) do |livereload|
105
107
  self.livereload = livereload
@@ -1,7 +1,8 @@
1
- require 'nokogiri'
1
+ require 'rexml/document'
2
2
 
3
3
  module Awestruct
4
4
  module ContextHelper
5
+ include REXML
5
6
 
6
7
  def html_to_text(str)
7
8
  str.gsub( /<[^>]+>/, '' ).gsub( /&nbsp;/, ' ' )
@@ -38,16 +39,19 @@ module Awestruct
38
39
  end
39
40
 
40
41
  def fully_qualify_urls(base_url, text)
41
- doc = Nokogiri::HTML.fragment( text )
42
+ doc = Document.new text
43
+ doc.context[:attribute_quote] = :quote # Set double-quote as the attribute value delimiter
42
44
 
43
- doc.css( "a" ).each do |a|
44
- a['href'] = fix_url( base_url, a['href'] ) if a['href']
45
+ XPath.each(doc, "//a") do |a|
46
+ a.attributes['href'] = fix_url( base_url, a.attributes['href'] ) if a.attributes['href']
45
47
  end
46
- doc.css( "link" ).each do |link|
47
- link['href'] = fix_url( base_url, link['href'] )
48
+
49
+ XPath.each(doc, "//link") do |link|
50
+ link.attributes['href'] = fix_url( base_url, link.attributes['href'] )
48
51
  end
49
- doc.css( "img" ).each do |img|
50
- img['src'] = fix_url( base_url, img['src'] )
52
+
53
+ XPath.each(doc, "//img") do |img|
54
+ img.attributes['src'] = fix_url( base_url, img.attributes['src'] )
51
55
  end
52
56
 
53
57
  if RUBY_VERSION.start_with? '1.8'
@@ -105,6 +105,7 @@ module Awestruct
105
105
  end
106
106
 
107
107
  def add_dependency(dep)
108
+ return if dep.nil?
108
109
  return if @page.do_not_track_dependencies
109
110
  return if @page.output_path.nil?
110
111
  return if dep == @page
@@ -114,6 +115,7 @@ module Awestruct
114
115
  end
115
116
 
116
117
  def add_key_dependency(dep)
118
+ return if dep.nil?
117
119
  return if @page.do_not_track_dependencies
118
120
  return if @page.output_path.nil?
119
121
  return if dep == @page
@@ -122,14 +124,17 @@ module Awestruct
122
124
  end
123
125
 
124
126
  def add_dependent(dep)
127
+ return if dep.nil?
125
128
  @dependents << dep
126
129
  end
127
130
 
128
131
  def add_key_dependent(dep)
132
+ return if dep.nil?
129
133
  @key_dependents << dep
130
134
  end
131
135
 
132
136
  def remove_dependent(dep)
137
+ return if dep.nil?
133
138
  @dependents.delete( dep )
134
139
  end
135
140
 
@@ -86,11 +86,16 @@ module Awestruct
86
86
  def build_page_index
87
87
  site.pages_by_relative_source_path = {}
88
88
  site.pages.each do |p|
89
+ # Add the layout to the set of dependencies
90
+ p.dependencies.add_dependency(site.layouts.find_matching(p.layout, p.output_extension))
89
91
  if ( p.relative_source_path )
90
92
  site.pages_by_relative_source_path[ p.relative_source_path ] = p
91
93
  end
92
94
  end
93
95
  site.layouts.each do |p|
96
+ # Add the layout to the set of dependencies
97
+ p.dependencies.add_dependency(site.layouts.find_matching(p.layout, p.output_extension))
98
+
94
99
  if ( p.relative_source_path )
95
100
  site.pages_by_relative_source_path[ p.relative_source_path ] = p
96
101
  end
@@ -313,7 +318,7 @@ module Awestruct
313
318
  end
314
319
 
315
320
  # path - relative to output dir
316
- def page_by_output_path(path)
321
+ def page_by_source_path(path)
317
322
  if (path.include? '_layout')
318
323
  site.layouts.find { |p| p.source_path.to_s == path }
319
324
  elsif (path.include? '_partial')
@@ -333,50 +338,27 @@ module Awestruct
333
338
  generate_page_internal(page)
334
339
  end
335
340
 
336
- regen_pages = Set.new [ page ]
341
+ regen_pages = Set.new [ page ]
342
+ regen_pages.merge page.dependencies.dependents
337
343
 
338
- regen_pages.each do |p|
339
- if $LOG.debug?
340
- $LOG.debug "--------------------"
341
- $LOG.debug "Page: #{p.output_path} #{p.relative_source_path} #{p.__is_layout ? 'Layout':''}"
342
- $LOG.debug "Detected change in content (#{p.dependencies.content_hash})" if p.dependencies.has_changed_content
343
- $LOG.debug "!! Detected change in front matter. To fully reflect the change you'll need to restart Awestruct (#{p.dependencies.key_hash})" if p.dependencies.has_changed_keys
344
- $LOG.debug "No changes detected" unless p.dependencies.has_changed_content or p.dependencies.has_changed_keys
345
- $LOG.debug "Dependencies Matrix: (non unique source path)"
346
- $LOG.debug "\t Outgoing dependencies:"
347
- $LOG.debug "\t\t Content -> #{p.dependencies.dependencies.size}"
348
- $LOG.debug "\t\t Key -> #{p.dependencies.key_dependencies.size}"
349
- $LOG.debug "\t Incoming dependencies:"
350
- $LOG.debug "\t\t Content <- #{p.dependencies.dependents.size}"
351
- $LOG.debug "\t\t Key <- #{p.dependencies.key_dependents.size}"
352
- $LOG.debug "--------------------"
353
- end
344
+ # doing this in case someone has used key dependencies
345
+ page.dependencies.key_dependents.each do |kd|
346
+ if kd.is_a? Page
347
+ regen_pages << kd
348
+ end
354
349
  end
355
350
 
356
- if page.dependencies.has_changed_content || page.__is_layout || page.is_partial?
357
- regen_pages += page.dependencies.dependents
351
+ temp_set = Set.new
352
+ regen_pages.each do |p|
353
+ temp_set.merge find_transitive_dependents(page)
358
354
  end
359
355
 
360
- regen_pages = regen_pages.sort do |x, y|
361
- xf = "#{@site.dir}#{x.relative_source_path}"
362
- yf = "#{@site.dir}#{y.relative_source_path}"
363
- xt = 0
364
- yt = 0
365
- xt = File.mtime(xf).to_i if File.exist? xf
366
- yt = File.mtime(yf).to_i if File.exist? yf
367
-
368
- yt <=> xt
369
- end
356
+ regen_pages.merge temp_set
370
357
 
371
358
  $LOG.debug "Starting regeneration of content dependent pages:" if regen_pages.size > 0 && $LOG.debug?
372
359
 
373
- @pipeline = Pipeline.new
374
- load_yamls
375
- load_pipeline
376
- execute_pipeline
377
-
378
360
  regen_pages.each do |p|
379
- puts "Regenerating page #{p.output_path}" unless config.quiet
361
+ $LOG.info "Regenerating page #{p.output_path}" if $LOG.info?
380
362
  generate_page_internal(p)
381
363
  end
382
364
 
@@ -428,7 +410,7 @@ module Awestruct
428
410
  throw Exception.new( "too many choices for #{simple_path}" ) if candidates.size != 1
429
411
  dir_pathname = Pathname.new( site.config.dir )
430
412
  path_name = Pathname.new( candidates[0] )
431
- relative_path = path_name.relative_path_from( dir_pathname ).to_s
413
+ path_name.relative_path_from( dir_pathname ).to_s
432
414
  load_page( candidates[0] )
433
415
  end
434
416
 
@@ -436,6 +418,18 @@ module Awestruct
436
418
  page.create_context( content )
437
419
  end
438
420
 
421
+ def find_transitive_dependents(page)
422
+ deps = Set.new
423
+ deps << page
424
+ if page.dependencies.dependents.size > 0
425
+ page.dependencies.dependents.to_a.inject(deps) do |set, p|
426
+ set.merge find_transitive_dependents(p)
427
+ set
428
+ end
429
+ end
430
+ deps
431
+ end
432
+
439
433
  end
440
434
 
441
435
  end
@@ -89,7 +89,7 @@ module Awestruct
89
89
  paginator = Awestruct::Extensions::Paginator.new( @tagged_items_property, @input_path, options )
90
90
  primary_page = paginator.execute( site )
91
91
  tag.primary_page = primary_page
92
- tag.pages.each {|p| primary_page.dependencies.add_key_dependency(p)}
92
+ tag.pages.each {|p| primary_page.dependencies.add_dependency(p)}
93
93
  end
94
94
 
95
95
  site.send( "#{@tagged_items_property}_tags=", ordered_tags )
@@ -1,12 +1,9 @@
1
1
  require 'awestruct/handler_chain'
2
2
  require 'awestruct/handlers/verbatim_file_handler'
3
3
  require 'awestruct/handlers/css_tilt_handler'
4
- require 'awestruct/handlers/restructuredtext_handler'
5
4
  require 'awestruct/handlers/javascript_handler'
6
5
  require 'awestruct/handlers/redirect_handler'
7
6
  require 'awestruct/handlers/tilt_handler'
8
- # TC: shouldn't the asciidoctor be covered by the tilt handler?
9
- # JP: We have some additional asciidoctor integration that the tilt handler doesn't handle (yet, working on it)
10
7
  require 'awestruct/handlers/asciidoctor_handler'
11
8
 
12
9
  module Awestruct
@@ -16,7 +13,6 @@ module Awestruct
16
13
  DEFAULTS = [
17
14
  Awestruct::Handlers::CssTiltHandler::CHAIN,
18
15
  Awestruct::Handlers::RedirectHandler::CHAIN,
19
- Awestruct::Handlers::RestructuredtextHandler::CHAIN,
20
16
  Awestruct::Handlers::JavascriptHandler::CHAIN,
21
17
  Awestruct::Handlers::AsciidoctorHandler::CHAIN,
22
18
  Awestruct::Handlers::TiltHandler::NON_INTERPOLATION_CHAIN,
@@ -44,7 +44,8 @@ module Awestruct
44
44
  unless path.directory?
45
45
  $LOG.debug "loading #{relative_path}" if (site.config.verbose) if $LOG.debug?
46
46
  page = load_page( path, prepare )
47
- if ( page && (!page.draft || @site.show_drafts) )
47
+ if ( page )
48
+ next if (page.draft && !(@site.show_drafts || @site.profile == 'development'))
48
49
  $LOG.debug "loaded! #{path} and added to site" if $LOG.debug?
49
50
  #inherit_front_matter( page )
50
51
  site.send( @target ) << page
@@ -1,3 +1,3 @@
1
1
  module Awestruct
2
- VERSION = '0.5.6.beta3'
2
+ VERSION = '0.5.6.beta4'
3
3
  end
@@ -81,14 +81,12 @@ describe Awestruct::ContextHelper do
81
81
 
82
82
  it "should fix link tags" do
83
83
  str = "<link href='/foo' />"
84
- #nokogiri html doesn't close optional ending tags
85
- @tester.fully_qualify_urls('http://foobar.com', str).should == "<link href=\"http://foobar.com/foo\">"
84
+ @tester.fully_qualify_urls('http://foobar.com', str).should == "<link href=\"http://foobar.com/foo\"/>"
86
85
  end
87
86
 
88
87
  it "should fix image tags" do
89
88
  str = "<img src='/foo' />"
90
- #nokogiri html doesn't close optional ending tags
91
- @tester.fully_qualify_urls('http://foobar.com', str).should == "<img src=\"http://foobar.com/foo\">"
89
+ @tester.fully_qualify_urls('http://foobar.com', str).should == "<img src=\"http://foobar.com/foo\"/>"
92
90
  end
93
91
 
94
92
  it "should leave anchor tags with no href attribute (for page anchors) unchanged" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awestruct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6.beta3
4
+ version: 0.5.6.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob McWhirter
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2014-10-22 00:00:00.000000000 Z
16
+ date: 2014-10-24 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: haml
@@ -43,20 +43,6 @@ dependencies:
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: nokogiri
48
- requirement: !ruby/object:Gem::Requirement
49
- requirements:
50
- - - "~>"
51
- - !ruby/object:Gem::Version
52
- version: 1.5.10
53
- type: :runtime
54
- prerelease: false
55
- version_requirements: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: 1.5.10
60
46
  - !ruby/object:Gem::Dependency
61
47
  name: tilt
62
48
  requirement: !ruby/object:Gem::Requirement
@@ -253,6 +239,20 @@ dependencies:
253
239
  - - ">"
254
240
  - !ruby/object:Gem::Version
255
241
  version: 1.1.1
242
+ - !ruby/object:Gem::Dependency
243
+ name: nokogiri
244
+ requirement: !ruby/object:Gem::Requirement
245
+ requirements:
246
+ - - "~>"
247
+ - !ruby/object:Gem::Version
248
+ version: 1.5.10
249
+ type: :development
250
+ prerelease: false
251
+ version_requirements: !ruby/object:Gem::Requirement
252
+ requirements:
253
+ - - "~>"
254
+ - !ruby/object:Gem::Version
255
+ version: 1.5.10
256
256
  description: Awestruct is a static site baking and publishing tool. It supports an
257
257
  extensive list of both templating and markup languages via Tilt (Haml, Slim, AsciiDoc,
258
258
  Markdown, Sass via Compass, etc), provides mobile-first layout and styling via Bootstrap
@@ -303,7 +303,6 @@ files:
303
303
  - lib/awestruct/extensions/assets.rb
304
304
  - lib/awestruct/extensions/atomizer.rb
305
305
  - lib/awestruct/extensions/cachebuster.rb
306
- - lib/awestruct/extensions/coffeescripttransform.rb
307
306
  - lib/awestruct/extensions/data_dir.rb
308
307
  - lib/awestruct/extensions/disqus.rb
309
308
  - lib/awestruct/extensions/extend_string.rb
@@ -353,7 +352,6 @@ files:
353
352
  - lib/awestruct/handlers/no_op_handler.rb
354
353
  - lib/awestruct/handlers/page_delegating_handler.rb
355
354
  - lib/awestruct/handlers/redirect_handler.rb
356
- - lib/awestruct/handlers/restructuredtext_handler.rb
357
355
  - lib/awestruct/handlers/string_handler.rb
358
356
  - lib/awestruct/handlers/template/asciidoc.rb
359
357
  - lib/awestruct/handlers/template/mustache.rb
@@ -406,7 +404,6 @@ files:
406
404
  - spec/awestruct/handlers/orgmode_handler_spec.rb
407
405
  - spec/awestruct/handlers/page_delegating_handler_spec.rb
408
406
  - spec/awestruct/handlers/redirect_handler_spec.rb
409
- - spec/awestruct/handlers/restructuredtext_handler_spec.rb
410
407
  - spec/awestruct/handlers/sass_handler_spec.rb
411
408
  - spec/awestruct/handlers/scss_handler_spec.rb
412
409
  - spec/awestruct/handlers/slim_handler_spec.rb
@@ -570,7 +567,6 @@ test_files:
570
567
  - spec/awestruct/handlers/orgmode_handler_spec.rb
571
568
  - spec/awestruct/handlers/page_delegating_handler_spec.rb
572
569
  - spec/awestruct/handlers/redirect_handler_spec.rb
573
- - spec/awestruct/handlers/restructuredtext_handler_spec.rb
574
570
  - spec/awestruct/handlers/sass_handler_spec.rb
575
571
  - spec/awestruct/handlers/scss_handler_spec.rb
576
572
  - spec/awestruct/handlers/slim_handler_spec.rb
@@ -1,42 +0,0 @@
1
- require 'coffee-script'
2
- require 'nokogiri'
3
-
4
- ##
5
- # Awestruct:Extensions:CoffeeScript is a transformer that compiles inline CoffeeScript in HTML files as JavaScript.
6
-
7
- module Awestruct
8
- module Extensions
9
- class CoffeeScriptTransform
10
-
11
- def transform(site, page, input)
12
- ext = File.extname(page.output_path)[1..-1].to_sym
13
- case ext
14
- when :html
15
- encoding = 'UTF-8'
16
- encoding = site.encoding unless site.encoding.nil?
17
-
18
- return compile(input, encoding)
19
- end
20
- return input
21
- end
22
-
23
- private
24
-
25
- def compile(input, encoding)
26
- html = Nokogiri::HTML(input, nil, encoding);
27
- html.search('script').each do |script|
28
- next unless 'text/coffeescript'.eql? script.attr('type')
29
-
30
- if script.attr('src') =~ /\.coffee$/
31
- script.set_attribute('src', File.basename( script.attr('src'), '.coffee' ) + '.js')
32
- else
33
- script.inner_html = CoffeeScript.compile script.inner_html
34
- end
35
- script.set_attribute('type', 'text/javascript')
36
-
37
- end
38
- return html.to_html
39
- end
40
- end
41
- end
42
- end
@@ -1,65 +0,0 @@
1
- require 'awestruct/util/exception_helper'
2
- require 'awestruct/handler_chain'
3
- require 'awestruct/handlers/base_handler'
4
- require 'awestruct/handlers/file_handler'
5
- require 'awestruct/handlers/front_matter_handler'
6
- require 'awestruct/handlers/interpolation_handler'
7
- require 'awestruct/handlers/layout_handler'
8
-
9
- require 'nokogiri'
10
-
11
- module Awestruct
12
- module Handlers
13
- class RestructuredtextHandler < BaseHandler
14
-
15
- CHAIN = Awestruct::HandlerChain.new( /\.(rst)$/,
16
- Awestruct::Handlers::FileHandler,
17
- Awestruct::Handlers::FrontMatterHandler,
18
- Awestruct::Handlers::InterpolationHandler,
19
- Awestruct::Handlers::RestructuredtextHandler,
20
- Awestruct::Handlers::LayoutHandler
21
- )
22
-
23
- def initialize(site, delegate)
24
- super( site, delegate )
25
- end
26
-
27
- def simple_name
28
- File.basename( relative_source_path, '.rst' )
29
- end
30
-
31
- def output_filename
32
- simple_name + output_extension
33
- end
34
-
35
- def output_extension
36
- '.html'
37
- end
38
-
39
- def content_syntax
40
- :rst
41
- end
42
-
43
- def rendered_content(context, with_layouts=true)
44
- content = delegate.rendered_content( context, with_layouts )
45
-
46
- hl = 1
47
- if front_matter['initial_header_level'].to_s =~ /^[1-6]$/
48
- hl = front_matter['initial_header_level']
49
- end
50
- begin
51
- doc = execute_shell( [ "rst2html",
52
- "--strip-comments",
53
- "--no-doc-title",
54
- " --initial-header-level=#{hl}" ].join(' '),
55
- content )
56
- content = Nokogiri::HTML( doc ).at( '/html/body/div[@class="document"]' ).inner_html.strip
57
- content.gsub( "\r", '' )
58
- rescue => e
59
- ExceptionHelper.log_building_error e, relative_source_path
60
- ExceptionHelper.html_error_report e, relative_source_path
61
- end
62
- end
63
- end
64
- end
65
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
-
3
- verify = lambda { |output|
4
- #output.should == "<h3>Test</h3>" ? unknown
5
- }
6
-
7
- theories =
8
- [
9
- {
10
- :page => "restructuredtext-page.rst",
11
- :simple_name => "restructuredtext-page",
12
- :syntax => :rst,
13
- :extension => '.html'
14
- #:matcher => verify ? requires rst2html command line tool
15
- }
16
- ]
17
-
18
- describe Awestruct::Handlers::TiltHandler.to_s + "-reStructuredText" do
19
- it_should_behave_like "a handler", theories
20
- end