aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-07-15 19:02:12 -0400
committerRalph Amissah <ralph@amissah.com>2014-07-15 19:02:12 -0400
commit4ef1c3099119cedff245acfe1ef26e5829e5bf62 (patch)
tree889a72066aaf70267f4209fd22dcf3aa6c8bbaa6 /lib
parentv5 v6: base images & css, continue (diff)
v5 v6: document images (more to clean up)sisu_5.5.1
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/v5/options.rb12
-rw-r--r--lib/sisu/v5/shared_markup_alt.rb7
-rw-r--r--lib/sisu/v5/src_shared.rb4
-rw-r--r--lib/sisu/v5/sysenv.rb18
-rw-r--r--lib/sisu/v5/utils.rb7
-rw-r--r--lib/sisu/v5/xml_docbook5.rb22
-rw-r--r--lib/sisu/v6/options.rb12
-rw-r--r--lib/sisu/v6/shared_markup_alt.rb7
-rw-r--r--lib/sisu/v6/src_shared.rb4
-rw-r--r--lib/sisu/v6/sysenv.rb18
-rw-r--r--lib/sisu/v6/utils.rb7
-rw-r--r--lib/sisu/v6/xml_docbook5.rb22
12 files changed, 112 insertions, 28 deletions
diff --git a/lib/sisu/v5/options.rb b/lib/sisu/v5/options.rb
index bc4d7da0..f40f0388 100644
--- a/lib/sisu/v5/options.rb
+++ b/lib/sisu/v5/options.rb
@@ -154,20 +154,20 @@ module SiSU_Commandline
end
end
class Options
- attr_accessor :cmd,:mod,:act,:dir_structure_by,:lingual,:f_pths,:files,:files_mod,:call_path,:base_path,:base_stub,:sub_location,:paths,:lngs,:f_pth,:pth,:fno,:fns,:fnb,:fnc,:fng,:fncb,:lng,:lng_base,:what,:make_instructions,:make_instructions_pod
+ attr_accessor :cmd,:mod,:act,:dir_structure_by,:lingual,:f_pths,:files,:files_mod,:call_path,:base_path,:base_stub,:sub_location,:image_src_path,:paths,:lngs,:f_pth,:pth,:fno,:fns,:fnb,:fnc,:fng,:fncb,:lng,:lng_base,:what,:make_instructions,:make_instructions_pod
@@act=nil
def initialize(a,call_path)
- @cmd=@f_pth=@pth=@fno=@fns=@fnb=@fnc=@fng=@fncb=@what=@lng=@lng_base=@call_path=@base_path=@base_stub=@sub_location=''
+ @cmd=@f_pth=@pth=@fno=@fns=@fnb=@fnc=@fng=@fncb=@what=@lng=@lng_base=@call_path=@base_path=@base_stub=@image_src_path=@sub_location=''
@f_pths,@files,@files_mod,@paths,@mod,@act=Array.new(5){[]}
@env=SiSU_Env::InfoEnv.new
@lng_base=@env.language_default_set
@dir_structure_by=SiSU_Env::EnvCall.new.output_dir_structure.by?
@lingual=SiSU_Env::EnvCall.new.mono_multi_lingual?
@call_path=call_path
- @base_path=SiSU_Utils::Path.new.base_markup(call_path)
- r=Px[:lng_lst_rgx]
- u=/.+?\/([^\/]+)(?:\/(?:#{r})$|$)/
- @base_stub=@base_path.gsub(u,'\1')
+ pth=SiSU_Utils::Path.new(call_path)
+ @base_path=pth.base_markup
+ @base_stub=pth.base_markup_stub
+ @image_src_path=pth.image_src
@a=sisu_glob_rules(a)
@a.freeze
@make_instructions=HeaderCommon.new.sisu_document_make_instructions
diff --git a/lib/sisu/v5/shared_markup_alt.rb b/lib/sisu/v5/shared_markup_alt.rb
index 1fb078c6..92db52f3 100644
--- a/lib/sisu/v5/shared_markup_alt.rb
+++ b/lib/sisu/v5/shared_markup_alt.rb
@@ -279,7 +279,12 @@ module SiSU_TextRepresentation
elsif FileTest.file?("#{@env.path.image_source_include}/#{i}")
@env.path.image_source_include
else
- SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"ERROR - image:", %{"#{i}" missing}, "search locations: #{@env.path.image_source_include_local}, #{@env.path.image_source_include_remote} and #{@env.path.image_source_include}").error2 unless @md.opt.act[:quiet][:set]==:on
+ SiSU_Screen::Ansi.new(
+ @md.opt.act[:color_state][:set],
+ "ERROR - image:",
+ %{"#{i}" missing},
+ "search locations: #{@env.path.image_source_include_local}, #{@env.path.image_source_include_remote} and #{@env.path.image_source_include}"
+ ).error2 unless @md.opt.act[:quiet][:set]==:on
nil
end
img_type = /\S+\.(png|jpg|gif)/.match(i)[1]
diff --git a/lib/sisu/v5/src_shared.rb b/lib/sisu/v5/src_shared.rb
index 03d902fd..068120f5 100644
--- a/lib/sisu/v5/src_shared.rb
+++ b/lib/sisu/v5/src_shared.rb
@@ -157,9 +157,7 @@ module SiSU_Source
images.delete_if {|x| x =~/https?:\/\// }
#images=images.sort
FileUtils::mkdir_p(@path_pod[:image])
- #unattractive hard coding ... !
- image_path='_sisu/image'
- images_pwd="#{@opt.base_path}/#{image_path}"
+ images_pwd=@opt.image_src_path
##sequence copies base images, defaults used in all html outputs
#image_source_base='/usr/share/sisu/image'
#dir_pwd=Dir.pwd
diff --git a/lib/sisu/v5/sysenv.rb b/lib/sisu/v5/sysenv.rb
index 324f96e0..8d73e832 100644
--- a/lib/sisu/v5/sysenv.rb
+++ b/lib/sisu/v5/sysenv.rb
@@ -2716,7 +2716,11 @@ WOK
else
if @@local_image==true
cmd=@cmd ? @cmd : ''
- SiSU_Screen::Ansi.new(cmd,"WARNING - no local image directory or images:", defaults[:image_local] ).warn unless cmd =~/q/
+ SiSU_Screen::Ansi.new(
+ cmd,
+ "WARNING - no local image directory or images:",
+ defaults[:image_local]
+ ).warn unless cmd =~/q/
@@local_image=false
end
url.images
@@ -2727,14 +2731,20 @@ WOK
if @@image_flag
images=Dir.glob("#{image_external}/*.{png,jpg,gif}")
pth="#{path.webserv}/#{@base_markup_dir_stub}"
- FileUtils::mkdir_p("#{pth}/_sisu/image_external") unless FileTest.directory?("#{pth}/_sisu/image_external")
- images.each { |i| File.install(i,"#{pth}/#{i}") } unless images.length > 0
+ FileUtils::mkdir_p("#{pth}/_sisu/image_external") \
+ unless FileTest.directory?("#{pth}/_sisu/image_external")
+ images.each { |i| File.install(i,"#{pth}/#{i}") } \
+ unless images.length > 0
@@image_flag=false
end
"#{Xx[:html_relative2]}/_sisu/image_external"
else
if @@local_image==true
- SiSU_Screen::Ansi.new(@cmd,"WARNING - image directory for external images or no such images:", :image_external ).warn unless @cmd =~/q/
+ SiSU_Screen::Ansi.new(
+ @cmd,
+ "WARNING - image directory for external images or no such images:",
+ :image_external
+ ).warn unless @cmd =~/q/
@@local_image=false
end
url.images_external
diff --git a/lib/sisu/v5/utils.rb b/lib/sisu/v5/utils.rb
index 7db4143a..4d30d031 100644
--- a/lib/sisu/v5/utils.rb
+++ b/lib/sisu/v5/utils.rb
@@ -184,6 +184,13 @@ module SiSU_Utils
m=/.+\/(?:src\/)?(\S+)/im
base_markup[m,1]
end
+ def image_src
+ if base_markup =~/sisupod\/doc[\/]?$/
+ base_markup.gsub(/\/doc[\/]?$/,'/image')
+ elsif FileTest.directory?("#{base_markup}/_sisu/image")
+ "#{base_markup}/_sisu/image"
+ end
+ end
def bmd
base_markup
end
diff --git a/lib/sisu/v5/xml_docbook5.rb b/lib/sisu/v5/xml_docbook5.rb
index 0fb6ee8d..62b8845c 100644
--- a/lib/sisu/v5/xml_docbook5.rb
+++ b/lib/sisu/v5/xml_docbook5.rb
@@ -128,8 +128,30 @@ module SiSU_XML_Docbook_Book
#extract_endnotes
data=markup_text(data)
structure_build_collapsed(data)
+ document_images if @md.ec[:image] and @md.ec[:image].length > 0
#tail
end
+ def document_images
+ img_pth={
+ src: @md.opt.image_src_path,
+ dest: @md.env.path.webserv + '/_sisu/image',
+ }
+ unless FileTest.directory?(img_pth[:dest])
+ #mkdir?
+ end
+ if FileTest.directory?(img_pth[:dest])
+ @md.ec[:image].each do |x|
+ img={
+ src: "#{img_pth[:src]}/#{x}",
+ dest: "#{img_pth[:dest]}/#{x}",
+ }
+ if FileTest.file?(img[:src])
+ FileUtils::cp(img[:src],img[:dest])
+ else p "Not Found: #{img[:src]}/#{x}"
+ end
+ end
+ end
+ end
def spaces
Ax[:spaces]
end
diff --git a/lib/sisu/v6/options.rb b/lib/sisu/v6/options.rb
index eed42e51..104243a3 100644
--- a/lib/sisu/v6/options.rb
+++ b/lib/sisu/v6/options.rb
@@ -154,20 +154,20 @@ module SiSU_Commandline
end
end
class Options
- attr_accessor :cmd,:mod,:act,:dir_structure_by,:lingual,:f_pths,:files,:files_mod,:call_path,:base_path,:base_stub,:sub_location,:paths,:lngs,:f_pth,:pth,:fno,:fns,:fnb,:fnc,:fng,:fncb,:lng,:lng_base,:what,:make_instructions,:make_instructions_pod
+ attr_accessor :cmd,:mod,:act,:dir_structure_by,:lingual,:f_pths,:files,:files_mod,:call_path,:base_path,:base_stub,:sub_location,:image_src_path,:paths,:lngs,:f_pth,:pth,:fno,:fns,:fnb,:fnc,:fng,:fncb,:lng,:lng_base,:what,:make_instructions,:make_instructions_pod
@@act=nil
def initialize(a,call_path)
- @cmd=@f_pth=@pth=@fno=@fns=@fnb=@fnc=@fng=@fncb=@what=@lng=@lng_base=@call_path=@base_path=@base_stub=@sub_location=''
+ @cmd=@f_pth=@pth=@fno=@fns=@fnb=@fnc=@fng=@fncb=@what=@lng=@lng_base=@call_path=@base_path=@base_stub=@image_src_path=@sub_location=''
@f_pths,@files,@files_mod,@paths,@mod,@act=Array.new(5){[]}
@env=SiSU_Env::InfoEnv.new
@lng_base=@env.language_default_set
@dir_structure_by=SiSU_Env::EnvCall.new.output_dir_structure.by?
@lingual=SiSU_Env::EnvCall.new.mono_multi_lingual?
@call_path=call_path
- @base_path=SiSU_Utils::Path.new.base_markup(call_path)
- r=Px[:lng_lst_rgx]
- u=/.+?\/([^\/]+)(?:\/(?:#{r})$|$)/
- @base_stub=@base_path.gsub(u,'\1')
+ pth=SiSU_Utils::Path.new(call_path)
+ @base_path=pth.base_markup
+ @base_stub=pth.base_markup_stub
+ @image_src_path=pth.image_src
@a=sisu_glob_rules(a)
@a.freeze
@make_instructions=HeaderCommon.new.sisu_document_make_instructions
diff --git a/lib/sisu/v6/shared_markup_alt.rb b/lib/sisu/v6/shared_markup_alt.rb
index 3bf3c7e4..1586f0c2 100644
--- a/lib/sisu/v6/shared_markup_alt.rb
+++ b/lib/sisu/v6/shared_markup_alt.rb
@@ -279,7 +279,12 @@ module SiSU_TextRepresentation
elsif FileTest.file?("#{@env.path.image_source_include}/#{i}")
@env.path.image_source_include
else
- SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"ERROR - image:", %{"#{i}" missing}, "search locations: #{@env.path.image_source_include_local}, #{@env.path.image_source_include_remote} and #{@env.path.image_source_include}").error2 unless @md.opt.act[:quiet][:set]==:on
+ SiSU_Screen::Ansi.new(
+ @md.opt.act[:color_state][:set],
+ "ERROR - image:",
+ %{"#{i}" missing},
+ "search locations: #{@env.path.image_source_include_local}, #{@env.path.image_source_include_remote} and #{@env.path.image_source_include}"
+ ).error2 unless @md.opt.act[:quiet][:set]==:on
nil
end
img_type = /\S+\.(png|jpg|gif)/.match(i)[1]
diff --git a/lib/sisu/v6/src_shared.rb b/lib/sisu/v6/src_shared.rb
index 495cc584..514e0458 100644
--- a/lib/sisu/v6/src_shared.rb
+++ b/lib/sisu/v6/src_shared.rb
@@ -157,9 +157,7 @@ module SiSU_Source
images.delete_if {|x| x =~/https?:\/\// }
#images=images.sort
FileUtils::mkdir_p(@path_pod[:image])
- #unattractive hard coding ... !
- image_path='_sisu/image'
- images_pwd="#{@opt.base_path}/#{image_path}"
+ images_pwd=@opt.image_src_path
##sequence copies base images, defaults used in all html outputs
#image_source_base='/usr/share/sisu/image'
#dir_pwd=Dir.pwd
diff --git a/lib/sisu/v6/sysenv.rb b/lib/sisu/v6/sysenv.rb
index f1b69edc..72aaf2b9 100644
--- a/lib/sisu/v6/sysenv.rb
+++ b/lib/sisu/v6/sysenv.rb
@@ -2716,7 +2716,11 @@ WOK
else
if @@local_image==true
cmd=@cmd ? @cmd : ''
- SiSU_Screen::Ansi.new(cmd,"WARNING - no local image directory or images:", defaults[:image_local] ).warn unless cmd =~/q/
+ SiSU_Screen::Ansi.new(
+ cmd,
+ "WARNING - no local image directory or images:",
+ defaults[:image_local]
+ ).warn unless cmd =~/q/
@@local_image=false
end
url.images
@@ -2727,14 +2731,20 @@ WOK
if @@image_flag
images=Dir.glob("#{image_external}/*.{png,jpg,gif}")
pth="#{path.webserv}/#{@base_markup_dir_stub}"
- FileUtils::mkdir_p("#{pth}/_sisu/image_external") unless FileTest.directory?("#{pth}/_sisu/image_external")
- images.each { |i| File.install(i,"#{pth}/#{i}") } unless images.length > 0
+ FileUtils::mkdir_p("#{pth}/_sisu/image_external") \
+ unless FileTest.directory?("#{pth}/_sisu/image_external")
+ images.each { |i| File.install(i,"#{pth}/#{i}") } \
+ unless images.length > 0
@@image_flag=false
end
"#{Xx[:html_relative2]}/_sisu/image_external"
else
if @@local_image==true
- SiSU_Screen::Ansi.new(@cmd,"WARNING - image directory for external images or no such images:", :image_external ).warn unless @cmd =~/q/
+ SiSU_Screen::Ansi.new(
+ @cmd,
+ "WARNING - image directory for external images or no such images:",
+ :image_external
+ ).warn unless @cmd =~/q/
@@local_image=false
end
url.images_external
diff --git a/lib/sisu/v6/utils.rb b/lib/sisu/v6/utils.rb
index 8995a860..4e7cb6e3 100644
--- a/lib/sisu/v6/utils.rb
+++ b/lib/sisu/v6/utils.rb
@@ -184,6 +184,13 @@ module SiSU_Utils
m=/.+\/(?:src\/)?(\S+)/im
base_markup[m,1]
end
+ def image_src
+ if base_markup =~/sisupod\/doc[\/]?$/
+ base_markup.gsub(/\/doc[\/]?$/,'/image')
+ elsif FileTest.directory?("#{base_markup}/_sisu/image")
+ "#{base_markup}/_sisu/image"
+ end
+ end
def bmd
base_markup
end
diff --git a/lib/sisu/v6/xml_docbook5.rb b/lib/sisu/v6/xml_docbook5.rb
index 3baa21d9..f105eab9 100644
--- a/lib/sisu/v6/xml_docbook5.rb
+++ b/lib/sisu/v6/xml_docbook5.rb
@@ -128,8 +128,30 @@ module SiSU_XML_Docbook_Book
#extract_endnotes
data=markup_text(data)
structure_build_collapsed(data)
+ document_images if @md.ec[:image] and @md.ec[:image].length > 0
#tail
end
+ def document_images
+ img_pth={
+ src: @md.opt.image_src_path,
+ dest: @md.env.path.webserv + '/_sisu/image',
+ }
+ unless FileTest.directory?(img_pth[:dest])
+ #mkdir?
+ end
+ if FileTest.directory?(img_pth[:dest])
+ @md.ec[:image].each do |x|
+ img={
+ src: "#{img_pth[:src]}/#{x}",
+ dest: "#{img_pth[:dest]}/#{x}",
+ }
+ if FileTest.file?(img[:src])
+ FileUtils::cp(img[:src],img[:dest])
+ else p "Not Found: #{img[:src]}/#{x}"
+ end
+ end
+ end
+ end
def spaces
Ax[:spaces]
end