Class: Staticpress::Site
- Inherits:
-
Object
- Object
- Staticpress::Site
- Includes:
- Enumerable, Helpers
- Defined in:
- lib/staticpress/site.rb
Constant Summary collapse
- CONTENT_TYPES =
ordered by priority
[ Staticpress::Content::Page, Staticpress::Content::Post, Staticpress::Content::Index, Staticpress::Content::Category, Staticpress::Content::Tag, Staticpress::Content::Theme ]
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #find_content_by_env(env) ⇒ Object
-
#initialize ⇒ Site
constructor
A new instance of Site.
- #meta ⇒ Object
- #save ⇒ Object
Methods included from Helpers
#config, #extensionless_basename, #extensionless_path, #hash_from_array, #hash_from_match_data, #paginate, #settings, #spider_map, #titleize
Constructor Details
#initialize ⇒ Site
Returns a new instance of Site.
20 21 22 |
# File 'lib/staticpress/site.rb', line 20 def initialize @directory = Staticpress.blog_path + config.source_path end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
18 19 20 |
# File 'lib/staticpress/site.rb', line 18 def directory @directory end |
Instance Method Details
#each(&block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/staticpress/site.rb', line 24 def each(&block) threads = [] semaphore = Mutex.new CONTENT_TYPES.each do |content_type| threads << Thread.new do content_type.published.each do |content| semaphore.synchronize do block.call content end end end end threads.each &:join end |
#find_content_by_env(env) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/staticpress/site.rb', line 41 def find_content_by_env(env) catch :content do CONTENT_TYPES.detect do |content_type| content = content_type.find_by_url_path env['REQUEST_PATH'] throw :content, content if content && content.exist? end nil end end |
#meta ⇒ Object
52 53 54 55 |
# File 'lib/staticpress/site.rb', line 52 def # or something... inject(Staticpress::Metadata.new) { |, content| << content. } end |
#save ⇒ Object
57 58 59 60 61 |
# File 'lib/staticpress/site.rb', line 57 def save destination = Staticpress.blog_path + config.destination_path FileUtils.rm_r destination if destination.directory? each &:save end |