Class: Marsdawn::Site::Page
- Inherits:
-
Object
- Object
- Marsdawn::Site::Page
- Defined in:
- lib/marsdawn/site/page.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
-
#sysinfo ⇒ Object
readonly
Returns the value of attribute sysinfo.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #breadcrumb ⇒ Object
-
#initialize(doc_info, page, site) ⇒ Page
constructor
A new instance of Page.
- #link ⇒ Object
- #neighbor ⇒ Object
- #page_nav ⇒ Object
- #parent ⇒ Object
- #search_box ⇒ Object
- #to_html(options = {}) ⇒ Object
- #to_page_html(options = {}) ⇒ Object
- #to_s ⇒ Object
- #top ⇒ Object
- #under ⇒ Object
Constructor Details
#initialize(doc_info, page, site) ⇒ Page
Returns a new instance of Page.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/marsdawn/site/page.rb', line 11 def initialize doc_info, page, site @doc_info = doc_info @site = site front_matter = page[:front_matter] @sysinfo = page[:sysinfo] @uri = @sysinfo[:uri] @title = front_matter[:title] @content = page[:content] @type = @sysinfo[:type] @level = @sysinfo[:level] @search_word = '' end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
9 10 11 |
# File 'lib/marsdawn/site/page.rb', line 9 def content @content end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
9 10 11 |
# File 'lib/marsdawn/site/page.rb', line 9 def level @level end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
9 10 11 |
# File 'lib/marsdawn/site/page.rb', line 9 def site @site end |
#sysinfo ⇒ Object (readonly)
Returns the value of attribute sysinfo.
9 10 11 |
# File 'lib/marsdawn/site/page.rb', line 9 def sysinfo @sysinfo end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
9 10 11 |
# File 'lib/marsdawn/site/page.rb', line 9 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/marsdawn/site/page.rb', line 9 def type @type end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
9 10 11 |
# File 'lib/marsdawn/site/page.rb', line 9 def uri @uri end |
Instance Method Details
#breadcrumb ⇒ Object
24 25 26 |
# File 'lib/marsdawn/site/page.rb', line 24 def @breadcrumb ||= Marsdawn::Site::Breadcrumb.new(@site, @sysinfo[:breadcrumb]) end |
#link ⇒ Object
48 49 50 |
# File 'lib/marsdawn/site/page.rb', line 48 def link @link ||= Marsdawn::Site::Link.new(@site, @uri, @title) end |
#neighbor ⇒ Object
28 29 30 |
# File 'lib/marsdawn/site/page.rb', line 28 def neighbor @neighbor ||= @site.index.neighbor(@uri) end |
#page_nav ⇒ Object
44 45 46 |
# File 'lib/marsdawn/site/page.rb', line 44 def page_nav @page_nav ||= Marsdawn::Site::PageNav.new(@site, @sysinfo[:prev_page], @sysinfo[:next_page]) end |
#parent ⇒ Object
36 37 38 |
# File 'lib/marsdawn/site/page.rb', line 36 def parent @parent ||= Marsdawn::Site::Link.new(@site, @sysinfo[:parent]) unless @sysinfo[:parent].nil? end |
#search_box ⇒ Object
52 53 54 |
# File 'lib/marsdawn/site/page.rb', line 52 def search_box @search_box ||= Marsdawn::Site::SearchBox.new(@site, @search_word) end |
#to_html(options = {}) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/marsdawn/site/page.rb', line 60 def to_html ={} <<-"EOS" <div class="main-container"> <div class="container"> <div class="row"> <div class="col-lg-3 sidebar"> <nav>#{neighbor}</nav> </div> <div class="col-lg-9 content"> <p>contents</p> </div> </div> </div> </div> EOS end |
#to_page_html(options = {}) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/marsdawn/site/page.rb', line 77 def to_page_html ={} opts = { css: ['http://dev.screw-axis.com/marsdawn/style.css'], js: [], title: CGI.escapeHTML(@title), title_suffix: " | #{CGI.escapeHTML(@site.title)}", lang: @doc_info[:lang], charset: @doc_info[:encoding] }.merge() css_html = opts[:css].map{|file| %!<link rel="stylesheet" href="#{file}" type="text/css" />!}.join("\n") js_html = opts[:js].map{|file| %!<script src="#{file}"></script>!}.join("\n") %|<!DOCTYPE html> <html lang="#{opts[:lang]}"> <head> <meta charset="#{opts[:encoding]}" /> <title>#{opts[:title]}#{opts[:title_suffix]}</title> #{css_html} #{js_html} </head> <body> <div id="container"> <div id="site-header"><h1 id="site-title">#{@site.title_link}</h1></div> <div id="side-menu"> #{search_box} <nav>#{neighbor}</nav> </div> <div id="site-body"> <div id="main-content"> <div id="breadcrumb"><nav>#{}</nav></div> <div id="page-content">#{@content}</div> <div id="under-index">#{under}</div> <div id="page-nav">#{page_nav}</div> </div> <div class="clear"></div> </div> </div> </body> </html>| end |
#to_s ⇒ Object
56 57 58 |
# File 'lib/marsdawn/site/page.rb', line 56 def to_s to_html end |
#top ⇒ Object
32 33 34 |
# File 'lib/marsdawn/site/page.rb', line 32 def top @site.top end |
#under ⇒ Object
40 41 42 |
# File 'lib/marsdawn/site/page.rb', line 40 def under @under ||= @site.index.under(@uri) end |