class SiSU_Images::Source::Place

Public Class Methods

new(particulars) click to toggle source
# File lib/sisu/shared_images.rb, line 65
def initialize(particulars)
  @particulars=particulars
  @md=@particulars.md
  @env=@particulars.env
  @o_str ||=SiSU_Env::ProcessingSettings.new(@md).output_dir_structure
end

Public Instance Methods

copy(src_path,dest_path,images=nil) click to toggle source
# File lib/sisu/shared_images.rb, line 77
def copy(src_path,dest_path,images=nil)
  if FileTest.directory?(src_path)
    FileUtils::cd(src_path)
    unless images
      images=Dir.glob("*.{png,jpg,gif,ico}")
    end
    unless FileTest.directory?(dest_path) \
    or FileTest.symlink?(dest_path)
      FileUtils::mkdir_p(dest_path)
      FileUtils::chmod(0755,dest_path)
    end
    if images.length > 0
      images.each do |i|
        if FileTest.file?(i)
          FileUtils::cp_r(i,"#{dest_path}/#{i}")
          FileUtils::chmod(0644,"#{dest_path}/#{i}")
        else STDERR.puts %{\t*WARN* did not find image - "#{i}" [#{__FILE__}:#{__LINE__}]}
        end
      end
    end
    FileUtils::cd(@pwd)
  else STDERR.puts %{\t*WARN* did not find - "#{src_path}" [#{__FILE__}:#{__LINE__}]}
  end
end
dest_path(image_type) click to toggle source
# File lib/sisu/shared_images.rb, line 101
def dest_path(image_type)
  pth=if image_type==:image_sys
    pth=(@o_str.dump_or_redirect?) \
    ? "#{@md.file.output_path.html.dir}/image"
    : "#{@md.file.output_path.base.dir}/_sisu/image_sys"
  elsif image_type==:image
    pth=(@o_str.dump_or_redirect?) \
    ? "#{@md.file.output_path.html.dir}/image"
    : "#{@md.file.output_path.base.dir}/_sisu/image"
  end
  pth
end
images_set() click to toggle source
# File lib/sisu/shared_images.rb, line 75
def images_set
  @pwd=(/(\S+?)(?:\/(?:#{Px[:lng_lst_rgx]}))?$/).match(Dir.pwd)[1]
  def copy(src_path,dest_path,images=nil)
    if FileTest.directory?(src_path)
      FileUtils::cd(src_path)
      unless images
        images=Dir.glob("*.{png,jpg,gif,ico}")
      end
      unless FileTest.directory?(dest_path) \
      or FileTest.symlink?(dest_path)
        FileUtils::mkdir_p(dest_path)
        FileUtils::chmod(0755,dest_path)
      end
      if images.length > 0
        images.each do |i|
          if FileTest.file?(i)
            FileUtils::cp_r(i,"#{dest_path}/#{i}")
            FileUtils::chmod(0644,"#{dest_path}/#{i}")
          else STDERR.puts %{\t*WARN* did not find image - "#{i}" [#{__FILE__}:#{__LINE__}]}
          end
        end
      end
      FileUtils::cd(@pwd)
    else STDERR.puts %{\t*WARN* did not find - "#{src_path}" [#{__FILE__}:#{__LINE__}]}
    end
  end
  def dest_path(image_type)
    pth=if image_type==:image_sys
      pth=(@o_str.dump_or_redirect?) \
      ? "#{@md.file.output_path.html.dir}/image"
      : "#{@md.file.output_path.base.dir}/_sisu/image_sys"
    elsif image_type==:image
      pth=(@o_str.dump_or_redirect?) \
      ? "#{@md.file.output_path.html.dir}/image"
      : "#{@md.file.output_path.base.dir}/_sisu/image"
    end
    pth
  end
  def select_with_document
    images=@md.ec[:image]
    src_path=unless @md.opt.f_pth[:pth] =~/\/\S+?\/sisupod\/\S+?\/sisupod\/doc/
      "#{@pwd}/_sisu/image"
    else #sisupod
      pt=/(\/\S+?\/sisupod\/\S+?\/sisupod)\/doc/.match(@md.opt.f_pth[:pth])[1]
      pt + '/image'
    end
    dest=dest_path(:image)
    copy(src_path,dest,images)
  end
  def select_sisu_base
    images=%w[arrow_next_red.png arrow_prev_red.png arrow_up_red.png dot_clear.png dot_white.png b_doc.png b_epub.png b_odf.png b_pdf.png b_toc.png]
    src_path="#{SiSU_is.path_base_system_data?}/image"
    dest=dest_path(:image_sys)
    copy(src_path,dest,images)
  end
  self
end
select_sisu_base() click to toggle source
# File lib/sisu/shared_images.rb, line 124
def select_sisu_base
  images=%w[arrow_next_red.png arrow_prev_red.png arrow_up_red.png dot_clear.png dot_white.png b_doc.png b_epub.png b_odf.png b_pdf.png b_toc.png]
  src_path="#{SiSU_is.path_base_system_data?}/image"
  dest=dest_path(:image_sys)
  copy(src_path,dest,images)
end
select_with_document() click to toggle source
# File lib/sisu/shared_images.rb, line 113
def select_with_document
  images=@md.ec[:image]
  src_path=unless @md.opt.f_pth[:pth] =~/\/\S+?\/sisupod\/\S+?\/sisupod\/doc/
    "#{@pwd}/_sisu/image"
  else #sisupod
    pt=/(\/\S+?\/sisupod\/\S+?\/sisupod)\/doc/.match(@md.opt.f_pth[:pth])[1]
    pt + '/image'
  end
  dest=dest_path(:image)
  copy(src_path,dest,images)
end
songsheet() click to toggle source
# File lib/sisu/shared_images.rb, line 71
def songsheet
  images_set.select_sisu_base
  images_set.select_with_document
end