aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/sisupod_make.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v3/sisupod_make.rb')
-rw-r--r--lib/sisu/v3/sisupod_make.rb79
1 files changed, 52 insertions, 27 deletions
diff --git a/lib/sisu/v3/sisupod_make.rb b/lib/sisu/v3/sisupod_make.rb
index 33ae8db2..984d807d 100644
--- a/lib/sisu/v3/sisupod_make.rb
+++ b/lib/sisu/v3/sisupod_make.rb
@@ -143,14 +143,14 @@ module SiSU_Doc
sk_doc,sk_dir="doc/#{skin}.rb","dir/skin_#{@env.stub_pwd}.rb"
skin_path.each do |v| #document skin priority 1
if FileTest.file?("#{v}/#{sk_doc}")
- @skin[:name],@skin[:type]="#{v}/#{sk_doc}",'doc'
+ @skin={ name_path: "#{v}/#{sk_doc}", type: :doc }
break
end
end
unless @skin.length > 0
skin_path.each do |v| #directory skin priority 2
if FileTest.file?("#{v}/#{sk_dir}")
- @skin[:name],@skin[:type]="#{v}/#{sk_dir}",'dir'
+ @skin={ name_path: "#{v}/#{sk_dir}", type: :dir }
break
end
end
@@ -167,7 +167,7 @@ module SiSU_Doc
end
def sisupod_build #see also sisupod in sysenv
@pwd=Dir.pwd
- @rgx_rb_image=/["'](\S+?\.(?:png|jpg|gif))["']/
+ @rgx_rb_image=/["']\S*?([a-zA-Z0-9_-]+?\.(?:png|jpg|gif))["']/
@rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/
@rgx_skin=/^\s+:skin:\s+(\S+)/
@rgx_doc_import=/^<<\s*(\S+?\.ss[ti])/
@@ -207,25 +207,28 @@ module SiSU_Doc
else
skin_source=select_skin
end
- docskin_place="#{@env.processing_path.processing_sisupod(@opt)}/doc/_sisu/skin/#{skin_source[:type]}"
+ docskin_place="#{@env.processing_path.processing_sisupod(@opt)}/doc/_sisu/skin/#{skin_source[:type].to_s}"
FileUtils::mkdir_p(docskin_place)
- if skin_source[:type] =~/dir/
+ if skin_source[:type] == :dir
docskin_with_path="#{docskin_place}/skin_#{@env.stub_pwd}.rb"
docskin=[docskin_with_path.gsub(/.+?\/(skin_\S+?)\.rb/,'\1')]
docskin='skin_sisupod'
end
if skin_source \
- and docskin #imperfect, revisit
- unless skin_source[:name].nil? \
- or skin_source[:name].empty?
- FileUtils::cp_r(skin_source[:name],"#{docskin_place}/#{docskin}.rb")
- skinfile_array=IO.readlines(skin_source[:name],'')
- para_images=[]
- skinfile_array.each do |f| #% work area
- unless f =~/^%+ / #hmmm
- images << f.scan(@rgx_rb_image).uniq if f =~@rgx_rb_image
- #does not really discriminate, may duplicate images in sisu file, and may take images from default image pool
+ and skin_source[:name_path]
+ unless skin_source[:name_path].nil? \
+ or skin_source[:name_path].empty?
+ if FileTest.file?(skin_source[:name_path])
+ FileUtils::cp(skin_source[:name_path],"#{docskin_place}/#{docskin}.rb")
+ skinfile_array=IO.readlines(skin_source[:name_path],'')
+ para_images=[]
+ skinfile_array.each do |f| #% work area
+ unless f =~/^%+ / #hmmm
+ images << f.scan(@rgx_rb_image).uniq if f =~@rgx_rb_image
+ #does not really discriminate, may duplicate images in sisu file, and may take images from default image pool
+ end
end
+ else STDERR.puts %{\t*WARN* did not find - "#{skin_source[:name_path]}" [#{__FILE__}:#{__LINE__}]}
end
end
end
@@ -255,15 +258,21 @@ module SiSU_Doc
if FileTest.directory?(images_pwd)
images=images.uniq
images.each do |i|
- FileUtils::cp_r("#{images_pwd}/#{i}","#{images_path_pod}/#{i}") if FileTest.file?("#{images_pwd}/#{i}")
+ if FileTest.file?("#{images_pwd}/#{i}")
+ FileUtils::cp("#{images_pwd}/#{i}","#{images_path_pod}/#{i}") if FileTest.file?("#{images_pwd}/#{i}")
+ else STDERR.puts %{\t*WARN* did not find image - "#{images_pwd}/#{i}" [#{__FILE__}:#{__LINE__}]}
+ end
end
- else puts "\tWARN, did not find - #{images_pwd} #{images_path_pod}"
+ else STDERR.puts %{\t*WARN* did not find - #{images_pwd} #{images_path_pod} [#{__FILE__}:#{__LINE__}]}
end
end
if doc_import.length > 0 \
and @opt.fno =~/\.ssm$/
doc_import.each do |f|
- FileUtils::cp_r("#{@env.path.pwd}#{doc_import_dir}/#{f}","#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f}")
+ if FileTest.file?("#{@env.path.pwd}#{doc_import_dir}/#{f}")
+ FileUtils::cp("#{@env.path.pwd}#{doc_import_dir}/#{f}","#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f}")
+ else STDERR.puts %{\t*WARN* did not find image - "#{@env.path.pwd}#{doc_import_dir}/#{f}" [#{__FILE__}:#{__LINE__}]}
+ end
end
end
x=@env.document_language_versions_found #check multiple document language versions (param not used)
@@ -275,18 +284,34 @@ module SiSU_Doc
if f[:f] =~/\~(\S{2,3})\.ss[tm]$/
lng_f=$1
if @opt.lng == lng_f
- (@opt.fno =~/\.ssm$/) \
- ? FileUtils::cp_r("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}",
+ if @opt.fno =~/\.ssm$/
+ if FileTest.file?("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}")
+ FileUtils::cp("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}",
+ "#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f[:n]}")
+ else STDERR.puts %{\t*WARN* did not find - "#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
+ end
+ else
+ if FileTest.file?("#{@env.path.pwd}/#{f[:f]}")
+ FileUtils::cp("#{@env.path.pwd}/#{f[:f]}",
+ "#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f[:n]}")
+ else STDERR.puts %{\t*WARN* did not find - "#{@env.path.pwd}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
+ end
+ end
+ end
+ else
+ if @opt.fno =~/\.ssm$/
+ if FileTest.file?("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}")
+ FileUtils::cp_r("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}",
"#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f[:n]}")
- : FileUtils::cp_r("#{@env.path.pwd}/#{f[:f]}",
+ else STDERR.puts %{\t*WARN* did not find - "#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
+ end
+ else
+ if FileTest.file?("#{@env.path.pwd}/#{f[:f]}")
+ FileUtils::cp("#{@env.path.pwd}/#{f[:f]}",
"#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f[:n]}")
+ else STDERR.puts %{\t*WARN* did not find - "#{@env.path.pwd}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
+ end
end
- else
- (@opt.fno =~/\.ssm$/) \
- ? FileUtils::cp_r("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}",
- "#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f[:n]}")
- : FileUtils::cp_r("#{@env.path.pwd}/#{f[:f]}",
- "#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f[:n]}")
end
end
end #NB not all possibilies met, revisit, also in case of composite file may wish to add README