lib/Charu/CreateHtml.rb in Charu-0.0.12 vs lib/Charu/CreateHtml.rb in Charu-0.0.16

- old
+ new

@@ -1,13 +1,13 @@ -# -*- encoding: utf-8 -*- +# -*- encoding: utf-8 -*- require "erb" module Charu class PageCounter - def initialize() - changelogmemo = Charu::ChangeLogMemo.new() + def initialize(changelogmemo) + changelogmemo = changelogmemo @max_page = changelogmemo.article_size_max() p "Page MAX " + @max_page.to_s i = 0 @pages = [] @@ -20,36 +20,43 @@ p "Page " + i.to_s i = i + 1 end end - def create_html() + def create_html(mode) + p mode p "pages.size " + @pages.size.to_s @pages.each{|page| create_html = Charu::CreateHtml.new(page, @pages.size) + if mode == true then + create_html.create_body_private() + elsif mode == false then + create_html.create_body_public() + end } end end class CreateHtml - attr_accessor :keyword, :css_theme_path, :link, :hiduke, :day, :title, :config, :page, :page_max + attr_accessor :keyword, :css_theme_path, :link, :hiduke, :day, :title, :config, :page, :page_max, :changelogmemo def initialize(page, page_max) @config = Charu::Config.new() - @page_max = page_max + @page_max = page_max - 1 @page = page @header = File.open("./CharuConfig/template/header.erb").read @footer = File.open("./CharuConfig/template/footer.erb").read @body = File.open("./CharuConfig/template/body.erb").read @day_body = File.open("./CharuConfig/template/day_body.erb").read @autoupload_lftp = File.open("./CharuConfig/autoupload.lftp").read self.keyword() - self.create_body() + #self.create_body_public() + #self.create_body_private() self.lftp() end def keyword() @keyword = "" @@ -57,11 +64,11 @@ @keyword = "#{@keyword}, " + "#{key}" } return @keyword.encode!("UTF-8") end - def create_body() + def create_body_private() # くっつける @htmls = [] @page.each{|page, file_name, changelogmemo| p "page " + page.to_s + " 作成中" @@ -70,22 +77,37 @@ @html = @header + @body + @footer #p changelogmemo erb = ERB.new(@html) -=begin - changelogmemo.each{|key, items| - items.each{|item| - p item.date - p item.get_item_title#.encode(Encoding::SJIS) - p i.get_item_category() - } - } -=end + @html = erb.result(binding) + begin + File.write(@config.www_html_out_path_private + file_name, @html) + rescue + p "書き込みエラー" + end + } + end + def create_body_public() + # くっつける + + @htmls = [] + @page.each{|page, file_name, changelogmemo| + p "page " + page.to_s + " 作成中" + #p file_name + @changelogmemo = changelogmemo + + @html = @header + @body + @footer + #p changelogmemo + + erb = ERB.new(@html) + + @html = erb.result(binding) + begin File.write(@config.www_html_out_path + file_name, @html) rescue p "書き込みエラー" end @@ -124,16 +146,19 @@ File.write(@config.www_html_out_path + @file_name, html) } end def lftp() - erb = ERB.new(@autoupload_lftp) - lftp = erb.result(binding) + erb = ERB.new(@autoupload_lftp) + lftp = erb.result(binding) - begin - File.write("./CharuConfig/autoupload.lftp", lftp) - rescue - p "書き込みエラー" - end + begin + File.write("./CharuConfig/autoupload.lftp", lftp) + rescue + p "書き込みエラー" + end end + + + end end