Class: Broadway::Site
- Inherits:
-
Object
- Object
- Broadway::Site
- Includes:
- Configurable, Processable, Resourceful
- Defined in:
- lib/broadway/resources/site.rb
Instance Attribute Summary collapse
-
#assets ⇒ Object
Returns the value of attribute assets.
-
#categories ⇒ Object
Returns the value of attribute categories.
-
#configuration ⇒ Object
Returns the value of attribute configuration.
-
#files ⇒ Object
Returns the value of attribute files.
-
#layouts ⇒ Object
Returns the value of attribute layouts.
-
#links ⇒ Object
Returns the value of attribute links.
-
#posts ⇒ Object
Returns the value of attribute posts.
-
#roots ⇒ Object
Returns the value of attribute roots.
-
#tags ⇒ Object
Returns the value of attribute tags.
Instance Method Summary collapse
- #build! ⇒ Object
- #data ⇒ Object
- #find(type, attributes) ⇒ Object
- #first(type, attributes) ⇒ Object
- #generate(&block) ⇒ Object
- #generate! ⇒ Object
- #index_path ⇒ Object
-
#initialize(settings) ⇒ Site
constructor
A new instance of Site.
- #language ⇒ Object
- #menu(name) ⇒ Object
- #num_pages ⇒ Object
- #num_posts ⇒ Object
- #pages ⇒ Object
- #permalink_style ⇒ Object
- #posts_path ⇒ Object
- #production_url ⇒ Object
- #public_path ⇒ Object
-
#render ⇒ Object
While in Jekyll this method renders the content explicitly, I’m using Sinatra, partly because I like having the flexibility of using their get/post methods, and partly because I don’t have the time/desire to try to hack jekyll to use haml.
- #setting(path) ⇒ Object
- #settings ⇒ Object
- #setup ⇒ Object
- #source ⇒ Object
- #title ⇒ Object
- #url ⇒ Object
- #views_path ⇒ Object
Methods included from Configurable
Methods included from Processable
Methods included from Resourceful
Constructor Details
Instance Attribute Details
#assets ⇒ Object
Returns the value of attribute assets.
8 9 10 |
# File 'lib/broadway/resources/site.rb', line 8 def assets @assets end |
#categories ⇒ Object
Returns the value of attribute categories.
8 9 10 |
# File 'lib/broadway/resources/site.rb', line 8 def categories @categories end |
#configuration ⇒ Object
Returns the value of attribute configuration.
8 9 10 |
# File 'lib/broadway/resources/site.rb', line 8 def configuration @configuration end |
#files ⇒ Object
Returns the value of attribute files.
8 9 10 |
# File 'lib/broadway/resources/site.rb', line 8 def files @files end |
#layouts ⇒ Object
Returns the value of attribute layouts.
8 9 10 |
# File 'lib/broadway/resources/site.rb', line 8 def layouts @layouts end |
#links ⇒ Object
Returns the value of attribute links.
8 9 10 |
# File 'lib/broadway/resources/site.rb', line 8 def links @links end |
#posts ⇒ Object
Returns the value of attribute posts.
8 9 10 |
# File 'lib/broadway/resources/site.rb', line 8 def posts @posts end |
#roots ⇒ Object
Returns the value of attribute roots.
8 9 10 |
# File 'lib/broadway/resources/site.rb', line 8 def roots @roots end |
#tags ⇒ Object
Returns the value of attribute tags.
8 9 10 |
# File 'lib/broadway/resources/site.rb', line 8 def @tags end |
Instance Method Details
#build! ⇒ Object
14 15 16 |
# File 'lib/broadway/resources/site.rb', line 14 def build! processor.build end |
#data ⇒ Object
58 59 60 |
# File 'lib/broadway/resources/site.rb', line 58 def data settings end |
#find(type, attributes) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/broadway/resources/site.rb', line 95 def find(type, attributes) result = [] self.send(type.to_s.pluralize).each do |resource| failed_to_match = false attributes.each do |method, value| if resource.respond_to?(method) failed_to_match = (resource.send(method) != value) else failed_to_match = !resource.send(method.to_s.pluralize).include?(value) end break if failed_to_match end result << resource unless failed_to_match end result end |
#first(type, attributes) ⇒ Object
112 113 114 |
# File 'lib/broadway/resources/site.rb', line 112 def first(type, attributes) find(type, attributes).first end |
#generate(&block) ⇒ Object
26 27 28 |
# File 'lib/broadway/resources/site.rb', line 26 def generate(&block) processor.generate(&block) end |
#generate! ⇒ Object
22 23 24 |
# File 'lib/broadway/resources/site.rb', line 22 def generate! processor.generate end |
#index_path ⇒ Object
38 39 40 |
# File 'lib/broadway/resources/site.rb', line 38 def index_path settings[:index_path] end |
#language ⇒ Object
66 67 68 |
# File 'lib/broadway/resources/site.rb', line 66 def language settings[:language] end |
#menu(name) ⇒ Object
168 169 170 |
# File 'lib/broadway/resources/site.rb', line 168 def (name) link_roots_by_category(name) end |
#num_pages ⇒ Object
160 161 162 |
# File 'lib/broadway/resources/site.rb', line 160 def num_pages pages.length end |
#num_posts ⇒ Object
156 157 158 |
# File 'lib/broadway/resources/site.rb', line 156 def num_posts posts.length end |
#pages ⇒ Object
164 165 166 |
# File 'lib/broadway/resources/site.rb', line 164 def pages posts.select { |post| post.kind == "page" } end |
#permalink_style ⇒ Object
70 71 72 |
# File 'lib/broadway/resources/site.rb', line 70 def permalink_style settings[:permalink].to_sym end |
#posts_path ⇒ Object
82 83 84 |
# File 'lib/broadway/resources/site.rb', line 82 def posts_path self.settings[:posts] end |
#production_url ⇒ Object
34 35 36 |
# File 'lib/broadway/resources/site.rb', line 34 def production_url settings[:production_url] end |
#public_path ⇒ Object
46 47 48 |
# File 'lib/broadway/resources/site.rb', line 46 def public_path settings[:public_path] end |
#render ⇒ Object
While in Jekyll this method renders the content explicitly, I’m using Sinatra, partly because I like having the flexibility of using their get/post methods, and partly because I don’t have the time/desire to try to hack jekyll to use haml. I’d rather just start over
91 92 93 |
# File 'lib/broadway/resources/site.rb', line 91 def render server.render end |
#setting(path) ⇒ Object
50 51 52 |
# File 'lib/broadway/resources/site.rb', line 50 def setting(path) configuration.get(path) end |
#settings ⇒ Object
54 55 56 |
# File 'lib/broadway/resources/site.rb', line 54 def settings configuration.settings end |
#setup ⇒ Object
74 75 76 |
# File 'lib/broadway/resources/site.rb', line 74 def setup configuration.setup end |
#source ⇒ Object
78 79 80 |
# File 'lib/broadway/resources/site.rb', line 78 def source self.settings[:source] end |
#title ⇒ Object
62 63 64 |
# File 'lib/broadway/resources/site.rb', line 62 def title settings[:title] end |
#url ⇒ Object
30 31 32 |
# File 'lib/broadway/resources/site.rb', line 30 def url settings[:url] || "http://localhost" end |
#views_path ⇒ Object
42 43 44 |
# File 'lib/broadway/resources/site.rb', line 42 def views_path settings[:views_path] end |