Sha256: d72a3f0eb9d394e9650dc787a3f1747921267328fcd018f67d3a074bae1393cb

Contents?: true

Size: 1.2 KB

Versions: 10

Compression:

Stored size: 1.2 KB

Contents

# -*- coding: utf-8 -*-
#
# @file 
# @brief
# @author ongaeshi
# @date   2012/03/24

require 'milkode/cdweb/lib/database'
require 'yaml'

module Milkode
  class WebSetting
    DEFAULT_SETTING = {
      :home_title    => "Milkode",
      :home_icon     => "/images/MilkodeIcon135.png",

      :header_title => "Milkode",
      :header_icon  => "/images/MilkodeIcon135.png",

      :favicon      => "/images/favicon.ico",

      :display_about_milkode => true
    }

    def self.hash_method(name)
      define_method(name) do
        if @data[name]
          @data[name]
        else
          DEFAULT_SETTING[name]
        end
      end
    end

    def initialize
      fname = File.join(Database.dbdir, "milkweb.yaml")
      if FileTest.exist? fname
        open(fname) do |f|
          @data = YAML.load(f.read)
        end
      else
        @data = DEFAULT_SETTING
      end
    end

    hash_method :home_title
    hash_method :home_icon
    
    hash_method :header_title
    hash_method :header_icon

    hash_method :favicon
    
    def about_milkode
      if (@data[:display_about_milkode])
        ', <a href="http://milkode.ongaeshi.me">milkodeについて</a>'
      else
        ''
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
milkode-1.3.0 lib/milkode/cdweb/lib/web_setting.rb
milkode-1.2.0 lib/milkode/cdweb/lib/web_setting.rb
milkode-1.1.0 lib/milkode/cdweb/lib/web_setting.rb
milkode-1.0.2 lib/milkode/cdweb/lib/web_setting.rb
milkode-1.0.0 lib/milkode/cdweb/lib/web_setting.rb
milkode-0.9.9.9 lib/milkode/cdweb/lib/web_setting.rb
milkode-0.9.9 lib/milkode/cdweb/lib/web_setting.rb
milkode-0.9.8 lib/milkode/cdweb/lib/web_setting.rb
milkode-0.9.7 lib/milkode/cdweb/lib/web_setting.rb
milkode-0.9.6 lib/milkode/cdweb/lib/web_setting.rb