Class: Runo::Set::Static::Folder

Inherits:
Runo::Set::Static show all
Defined in:
lib/_widget/crumb.rb,
lib/set/static_folder.rb,
lib/_widget/action_login.rb,
lib/_widget/action_signup.rb,
lib/_widget/me.rb

Overview

Author

Akira FUNAI

Copyright

Copyright © 2009-2010 Akira FUNAI

Constant Summary

Constants inherited from Field

Field::DEFAULT_META

Instance Attribute Summary

Attributes inherited from Field

#action, #result

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Runo::Set::Static

#commit, #meta_href

Methods included from Runo::Set

#collect, #each, #errors, #inspect_items, #item, #meta_base_path, #meta_path, #pending?, #val

Methods inherited from Field

#[], #[]=, #commit, #create, #default_action, #delete, #empty?, #errors, #find_ancestor, #get, h, #inspect, instance, #item, #load, #load_default, #meta_admins, #meta_client, #meta_folder, #meta_full_name, #meta_group, #meta_name, #meta_owner, #meta_owners, #meta_roles, #meta_sd, #meta_short_name, #pending?, #permit?, #post, #update, #val, #valid?

Methods included from I18n

_, bindtextdomain, domain, domain=, find_msg, lang, lang=, merge_msg!, msg, n_, parse_msg, po_dir, po_dir=

Constructor Details

#initialize(meta = {}) ⇒ Folder

Returns a new instance of Folder.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/set/static_folder.rb', line 12

def initialize(meta = {})
  meta[:dir]  = meta[:parent] ? ::File.join(meta[:parent][:dir], meta[:id]) : meta[:id]
  meta[:html] = load_html(meta[:dir], meta[:parent])
  super

  ::Dir.glob(::File.join Runo['skin_dir'], my[:html_dir].to_s, '*.html').each {|f|
    action = ::File.basename(f, '.*').intern
    merge_tmpl(@meta, Runo::Parser.parse_html(::File.read(f), action)) if action != :index
  }
  ::Dir.glob(::File.join Runo['skin_dir'], my[:html_dir].to_s, '*.xml').each {|f|
    action = ::File.basename(f, '.*').intern
    merge_tmpl(@meta, Runo::Parser.parse_xml(::File.read(f), action)) if action != :index
  }

  @meta[:tmpl].values.each {|tmpl|
    tmpl.sub!(/<head>([\s\n]*)/i) {
      "#{$&}<base href=\"@(href)\" />#{$1}"
    }
  } if @meta[:tmpl]

  @meta.merge! load_yaml(my[:dir], my[:parent])
end

Class Method Details

.rootObject



8
9
10
# File 'lib/set/static_folder.rb', line 8

def self.root
  self.new(:id => '')
end

Instance Method Details

#meta_dirObject



35
36
37
# File 'lib/set/static_folder.rb', line 35

def meta_dir
  @meta[:dir]
end

#meta_html_dirObject



39
40
41
42
43
44
45
# File 'lib/set/static_folder.rb', line 39

def meta_html_dir
  if ::File.readable? ::File.join(Runo['skin_dir'], my[:dir], 'index.html')
    my[:dir]
  elsif my[:parent]
    my[:parent][:html_dir]
  end
end