From a8493b259f8d166708601bb431267c86f1d78193 Mon Sep 17 00:00:00 2001
From: Ralph Amissah
Date: Mon, 28 May 2012 04:47:13 -0400
Subject: v3: css, ensure css available for generated content
* checks whether exists if not copies (for --init-site / --configure just
copies, takes as a re-copy request)
---
lib/sisu/v3/concordance.rb | 1 +
lib/sisu/v3/harvest.rb | 11 ++-
lib/sisu/v3/html.rb | 6 +-
lib/sisu/v3/manifest.rb | 3 +-
lib/sisu/v3/sysenv.rb | 191 ++++++++++++++++++++++++++++++---------------
lib/sisu/v3/xhtml.rb | 1 +
lib/sisu/v3/xml.rb | 1 +
lib/sisu/v3/xml_dom.rb | 1 +
8 files changed, 146 insertions(+), 69 deletions(-)
(limited to 'lib')
diff --git a/lib/sisu/v3/concordance.rb b/lib/sisu/v3/concordance.rb
index 12968935..2a3b585a 100644
--- a/lib/sisu/v3/concordance.rb
+++ b/lib/sisu/v3/concordance.rb
@@ -99,6 +99,7 @@ module SiSU_Concordance
__LINE__.to_s + ':' + __FILE__
end
ensure
+ SiSU_Env::CreateSite.new(@opt.cmd).cp_css
end
end
private
diff --git a/lib/sisu/v3/harvest.rb b/lib/sisu/v3/harvest.rb
index 4ce5a09b..ea967c37 100644
--- a/lib/sisu/v3/harvest.rb
+++ b/lib/sisu/v3/harvest.rb
@@ -70,9 +70,14 @@ module SiSU_Harvest
@env=SiSU_Env::InfoEnv.new
end
def read
- harvest_pth="#{@env.path.webserv}/#{@opt.base_stub}"
- FileUtils::mkdir_p(harvest_pth) unless FileTest.directory?(harvest_pth)
- cases(@opt,@env)
+ begin
+ harvest_pth="#{@env.path.webserv}/#{@opt.base_stub}"
+ FileUtils::mkdir_p(harvest_pth) unless FileTest.directory?(harvest_pth)
+ cases(@opt,@env)
+ rescue
+ ensure
+ SiSU_Env::CreateSite.new(@opt.cmd).cp_css
+ end
end
def help
puts <Document Metadata
- (metadata suggested links (if any)
+ metadata suggested links (if any)
WOK
diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb
index a28b4060..f699ee92 100644
--- a/lib/sisu/v3/sysenv.rb
+++ b/lib/sisu/v3/sysenv.rb
@@ -1737,47 +1737,6 @@ WOK
'./'
end
end
- def default_output_css
- if (@md.opt.opt_act[:dump][:bool] \
- && @md.opt.opt_act[:dump][:inst]) \
- || (@md.opt.opt_act[:redirect][:bool] \
- && @md.opt.opt_act[:redirect][:inst])
- './'
- elsif @env.output_dir_structure.by_language_code?
- '../../'
- elsif @env.output_dir_structure.by_filetype?
- '../'
- else
- '../'
- end
- end
- def html_scroll_css
- default_output_css
- end
- def xhtml_css
- default_output_css
- end
- def xml_css
- default_output_css
- end
- def html_seg_css
- if @env.output_dir_structure.by_language_code?
- '../../../'
- elsif @env.output_dir_structure.by_filetype?
- '../../'
- else
- '../'
- end
- end
- def manifest_css
- if @env.output_dir_structure.by_language_code?
- '../../_sisu/css'
- elsif @env.output_dir_structure.by_filetype?
- ''
- else
- '../'
- end
- end
self
end
def read_source_file(fns)
@@ -4024,6 +3983,86 @@ WOK
FileUtils::mkdir_p(@env.processing_path.dal) unless FileTest.directory?(@env.processing_path.dal)
FileUtils::mkdir_p(@env.processing_path.tune) unless FileTest.directory?(@env.processing_path.tune)
end
+ def path_rel_links
+ def html_scroll_2
+ if output_dir_structure.by_language_code?
+ '../../'
+ elsif output_dir_structure.by_filetype?
+ '../'
+ else
+ '../'
+ end
+ end
+ def html_seg_2
+ if output_dir_structure.by_language_code?
+ '../../../'
+ elsif output_dir_structure.by_filetype?
+ '../../'
+ else
+ '../'
+ end
+ end
+ def html_scroll_1
+ if output_dir_structure.by_language_code?
+ '../'
+ elsif output_dir_structure.by_filetype?
+ '../'
+ else
+ './'
+ end
+ end
+ def html_seg_1
+ if output_dir_structure.by_language_code?
+ '../../'
+ elsif output_dir_structure.by_filetype?
+ '../../'
+ else
+ './'
+ end
+ end
+ def default_output_css
+ if (@md.opt.opt_act[:dump][:bool] \
+ && @md.opt.opt_act[:dump][:inst]) \
+ || (@md.opt.opt_act[:redirect][:bool] \
+ && @md.opt.opt_act[:redirect][:inst])
+ './'
+ elsif output_dir_structure.by_language_code?
+ '../../'
+ elsif output_dir_structure.by_filetype?
+ '../'
+ else
+ '../'
+ end
+ end
+ def html_scroll_css
+ default_output_css
+ end
+ def xhtml_css
+ default_output_css
+ end
+ def xml_css
+ default_output_css
+ end
+ def html_seg_css
+ if output_dir_structure.by_language_code?
+ '../../../'
+ elsif output_dir_structure.by_filetype?
+ '../../'
+ else
+ '../'
+ end
+ end
+ def manifest_css
+ if output_dir_structure.by_language_code?
+ '../../_sisu/css'
+ elsif output_dir_structure.by_filetype?
+ ''
+ else
+ '../'
+ end
+ end
+ self
+ end
def mkdir
txt_path="#{output_path.base.dir}/#{@md.fnb}"
def output
@@ -5703,7 +5742,8 @@ WOK
"#{@md.doc_css}_html.css"
elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_html.css")
"#{@env.path.stub_pwd}_html.css"
- else SiSU_Env::CSS_Default.new.html
+ else
+ SiSU_Env::CSS_Default.new.html
end
end
def html_tables
@@ -5894,28 +5934,51 @@ WOK
css=SiSU_Style::CSS.new
path_style="#{@env.path.output}/#{@env.path.style}"
FileUtils::mkdir_p(path_style) unless FileTest.directory?(path_style)
- style=File.new("#{path_style}/#{fn_css.homepage}",'w')
- style << css.homepage
- style.close
- style=File.new("#{path_style}/#{fn_css.html_tables}",'w')
- style << css.html_tables
- style.close
- style=File.new("#{path_style}/#{fn_css.html}",'w')
- style << css.html
- style.close
- style=File.new("#{path_style}/#{fn_css.xml_sax}",'w')
- style << css.xml_sax
- style.close
- style=File.new("#{path_style}/#{fn_css.xml_dom}",'w')
- style << css.xml_dom
- style=File.new("#{path_style}/#{fn_css.docbook_xml}",'w')
- style << css.docbook_xml
- style.close
- style=File.new("#{path_style}/#{fn_css.xhtml}",'w')
- style << css.xhtml
- style=File.new("#{path_style}/#{fn_css.harvest}",'w')
- style << css.harvest
- style.close
+ if @cmd =~/C/ \
+ or not FileTest.file?("#{path_style}/#{fn_css.homepage}")
+ style=File.new("#{path_style}/#{fn_css.homepage}",'w')
+ style << css.homepage
+ style.close
+ end
+ if @cmd =~/C/ \
+ or not FileTest.file?("#{path_style}/#{fn_css.html_tables}")
+ style=File.new("#{path_style}/#{fn_css.html_tables}",'w')
+ style << css.html_tables
+ style.close
+ end
+ if @cmd =~/C/ \
+ or not FileTest.file?("#{path_style}/#{fn_css.html}")
+ style=File.new("#{path_style}/#{fn_css.html}",'w')
+ style << css.html
+ style.close
+ end
+ if @cmd =~/C/ \
+ or not FileTest.file?("#{path_style}/#{fn_css.harvest}")
+ style=File.new("#{path_style}/#{fn_css.harvest}",'w')
+ style << css.harvest
+ style.close
+ end
+ if @cmd =~/C/ \
+ or (@cmd =~/[x]/ \
+ and not FileTest.file?("#{path_style}/#{fn_css.xml_sax}"))
+ style=File.new("#{path_style}/#{fn_css.xml_sax}",'w')
+ style << css.xml_sax
+ style.close
+ end
+ if @cmd =~/C/ \
+ or (@cmd =~/[X]/ \
+ and not FileTest.file?("#{path_style}/#{fn_css.xml_dom}"))
+ style=File.new("#{path_style}/#{fn_css.xml_dom}",'w')
+ style << css.xml_dom
+ style.close
+ end
+ if @cmd =~/C/ \
+ or (@cmd =~/[b]/ \
+ and not FileTest.file?("#{path_style}/#{fn_css.xhtml}"))
+ style=File.new("#{path_style}/#{fn_css.xhtml}",'w')
+ style << css.xhtml
+ style.close
+ end
end
end
end
diff --git a/lib/sisu/v3/xhtml.rb b/lib/sisu/v3/xhtml.rb
index 98b445a6..e73b97b7 100644
--- a/lib/sisu/v3/xhtml.rb
+++ b/lib/sisu/v3/xhtml.rb
@@ -99,6 +99,7 @@ module SiSU_XHTML
__LINE__.to_s + ':' + __FILE__
end
ensure
+ SiSU_Env::CreateSite.new(@opt.cmd).cp_css
end
end
private
diff --git a/lib/sisu/v3/xml.rb b/lib/sisu/v3/xml.rb
index 65a9beee..1346f33e 100644
--- a/lib/sisu/v3/xml.rb
+++ b/lib/sisu/v3/xml.rb
@@ -98,6 +98,7 @@ module SiSU_XML_SAX
end
ensure
#file closed in songsheet
+ SiSU_Env::CreateSite.new(@opt.cmd).cp_css
end
end
private
diff --git a/lib/sisu/v3/xml_dom.rb b/lib/sisu/v3/xml_dom.rb
index 69cedff9..4508c389 100644
--- a/lib/sisu/v3/xml_dom.rb
+++ b/lib/sisu/v3/xml_dom.rb
@@ -98,6 +98,7 @@ module SiSU_XML_DOM
__LINE__.to_s + ':' + __FILE__
end
ensure
+ SiSU_Env::CreateSite.new(@opt.cmd).cp_css
end
end
private
--
cgit v1.2.3