Class Atchoum::Website
In: lib/atchoum/website.rb
Parent: Markaby::Builder

Every Atchoum website script extends the Website class. A website is composed of pages (methods ending with _page). The index_page method is the root of the website. Every pages are passed trough the layout method as a block, the default layout wraps your stuff in a soft html and body tags.

Methods

layout   new   render   to_files  

Included Modules

Markup

Attributes

pages  [R] 
reloader  [R] 

Public Class methods

[Source]

    # File lib/atchoum/website.rb, line 12
12:     def initialize
13:       super
14:       @pages = public_methods.collect do |m|
15:         /^(\w+)_page$/ =~ m ? $1 : nil
16:       end.compact
17:     end

Public Instance methods

Default layout for every renderd page. Redefine this to setup a custom layout.

[Source]

    # File lib/atchoum/website.rb, line 21
21:     def layout
22:       html do
23:         body do
24:           self << yield
25:         end
26:       end
27:     end

Render the content of a page as a string containing the magic HTML.

[Source]

    # File lib/atchoum/website.rb, line 31
31:     def render(page)
32:       @rendered_page = page.to_sym
33:       s = capture { send("#{page}_page") }
34:       s = capture { send(:layout) { s } } if respond_to? :layout
35:       @rendered_page = nil
36:       s
37:     end

Render all pages to seperate html files in correponding folders. For exemple, index_page will be parsed to +/index.htm+ and contact_page to +/contact/index.htm+.

[Source]

    # File lib/atchoum/website.rb, line 42
42:     def to_files
43:       pages.each do |page|
44:         if page.to_s == 'index'
45:           path = '.'
46:         else
47:           path = page
48:           Dir::mkdir path if !File.exist? path
49:         end
50:         File.open("#{path}/index.htm", 'w') do |f|
51:           f << render(page)
52:         end
53:       end
54:     end

[Validate]