Class: Writecast::Base_view

Inherits:
Erector::Widget
  • Object
show all
Defined in:
lib/writecast/views/base.rb

Instance Method Summary collapse

Instance Method Details

#contentObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/writecast/views/base.rb', line 7

def content
    rawtext '<!DOCTYPE HTML>'
    html do
        head {render_head}
        body do
            div(:id => 'container') do
                render_body_top_inner
                div(:id => 'content') {render_content_inner}
                render_footer
            end
        end
    end
end

#render_body_top_innerObject



32
33
34
35
36
# File 'lib/writecast/views/base.rb', line 32

def render_body_top_inner
    div(:id => 'header') {p SITE_TITLE}
    div(:id => 'menu') {render_menu}
    div(:id => 'breadcrumb') {render_breadcrumb}
end


38
39
40
41
42
# File 'lib/writecast/views/base.rb', line 38

def render_footer
    div :id => 'footer' do
        p a 'valid html5', :href => 'http://validator.w3.org/check/referer'
    end
end

#render_headObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/writecast/views/base.rb', line 21

def render_head
    render_feed_link if defined? render_feed_link
    css "/static/style.css"
    css "/static/coderay.css"
    script :src => "/static/jquery.min.js", :type => "text/javascript"
    script :src => "/static/jquery.form.js", :type => "text/javascript"
    script :src => "/static/jquery.validate.js", :type => "text/javascript"
    script :src => "/static/comment.js", :type => "text/javascript"
    title @title_tag
end

#render_menuObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/writecast/views/base.rb', line 44

def render_menu
    ul :id => 'tabnav' do
        @pages.each do |page|
            block = ->{a page.title, :href => page.link_path}
            if ((@doc.is_a?(Page) || @doc.is_a?(Index)) && page.title == @doc.title) ||
                ((@doc.is_a?(Post) || @doc.is_a?(Month_index) ||
                  @doc.is_a?(Year_index) || @doc.is_a?(Tag_index) ||
                  @doc.is_a?(All_tags_index)) && page.title == INDEX_TITLE)
                li :id => 'selected', &block
            else
                li &block
            end
        end
    end
end

#render_post_summary(post) ⇒ Object

render a summary of a single post (as a li)



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/writecast/views/base.rb', line 61

def render_post_summary(post)
    li do
        p do
            a post.title, :href => post.link_path
            br
            text "last modified: #{post.time}"
        end
        rawtext Kramdown::Document.new(post.summary, KRAMDOWN_OPTS).to_html
        p {a "more...", :href => post.link_path}
    end
end