Top Level Namespace

Defined Under Namespace

Modules: Broadway Classes: Array, Date, Hash

Instance Method Summary collapse

Instance Method Details

#content_path(content, action) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/broadway/main.rb', line 42

def content_path(content, action)
  path = File.join(content.dir, action).squeeze("/")
  exists = false
  extensions = %w(html haml erb html.haml html.erb)
  target_path = File.join(site.config[:source], path)
  extensions.each do |ext|
    exists = true if File.exists?("#{target_path}.#{ext}")
  end
  return path if exists
  checked = [target_path]
  path = target_path = File.join(site.config[:theme_path], path).squeeze("/")
  exists = false
  extensions.each do |ext|
    exists = true if File.exists?(File.join(site.config[:source], "#{target_path}.#{ext}"))
  end
  return path if exists
  if content.url == "/"
    return File.join(site.config[:theme_path], "index")
  end
  checked << target_path
  puts "Couldn't find paths for #{content.class.to_s.downcase.split(":").last} ('#{content.url}'): #{checked.inspect}"
  return nil
end

#default_locals(locals = {}) ⇒ Object



17
18
19
# File 'lib/broadway/main.rb', line 17

def default_locals(locals = {})
  locals#.merge(site.config.dup).merge({:menu => menu})
end

#files(path, from = __FILE__, &block) ⇒ Object



1
2
3
# File 'lib/broadway/base.rb', line 1

def files(path, from = __FILE__, &block)
  Dir.glob(File.join(File.dirname(from), path)) {|file| yield file}
end

#page_path(page) ⇒ Object



34
35
36
# File 'lib/broadway/main.rb', line 34

def page_path(page)
  content_path(page, "index")
end

#pagesObject



25
26
27
# File 'lib/broadway/main.rb', line 25

def pages
  Dir.entries("public")
end

#post_path(post) ⇒ Object



38
39
40
# File 'lib/broadway/main.rb', line 38

def post_path(post)
  content_path(post, "show")
end

#require_local(path, from = __FILE__) ⇒ Object



5
6
7
# File 'lib/broadway/base.rb', line 5

def require_local(path, from = __FILE__)
  files(path, from) {|file| require file}
end

#siteObject



13
14
15
# File 'lib/broadway/main.rb', line 13

def site
  @site
end

#theme_pathObject



21
22
23
# File 'lib/broadway/main.rb', line 21

def theme_path
  site.config[:theme_path]
end