Module: Static
- Includes:
- FileBase
- Defined in:
- lib/static.rb
Constant Summary
collapse
- VERSION =
'0.1.0'
Constants included
from FileBase
FileBase::Home
Instance Method Summary
collapse
Methods included from FileBase
#copy, #destroy, #exists?, #file_path, #has_location?, #home, #items_under, #location, #make_dir, #mkdir, #move, #path, #reset_location, #set_home, #set_location, #setup_location, #write, #write_template
Instance Method Details
56
57
58
59
60
61
62
|
# File 'lib/static.rb', line 56
def collection, page
collection = collection.to_s
page = page.to_s
$active_site.info['paginate'] ||= {}
$active_site.info['paginate'].merge!({page => collection}) unless $active_site.info['paginate'].include?({page => collection})
$active_site.save_info
end
|
#load_collection(name) ⇒ Object
52
53
54
|
# File 'lib/static.rb', line 52
def load_collection name
Collection.load $ENV['STATIC_HOME'], $active_site.home, name.to_s
end
|
#load_site(name) ⇒ Object
38
39
40
|
# File 'lib/static.rb', line 38
def load_site name
Site.load($ENV['SITE_BANK'], name, $ENV['STATIC_VIEWING'], $ENV['TEMPLATE_HOME']) if name
end
|
#paginate(page, publishing_to = nil) ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
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
|
# File 'lib/static.rb', line 64
def paginate page, publishing_to=nil
return nil unless page
@page = Page.find(page)
Generator.load(load_collection($active_site.info['paginate'][@page.file_name]))
Generator.class_eval {
def self.entry_bank
if @tmp_entries and @tmp_entries.empty?
@tmp_entries = nil
return @tmp_entries
end
@tmp_entries ||= self.act_on.entries.dup
@tmp_entries
end
def self.entry_bank= what
@tmp_entries = what
end
}
publishing_to ||= "#{@page.home}blueprint/#{@page.page_location}_#{Generator.act_on.name}_for_#{@page.file_name}/"
mkdir publishing_to, :force
@page_list = []
Generator.act_on.instance_eval { def level; @level end; def level=(what); @level=what end }
Generator.entry_bank
while(Generator.entry_bank)
rbml = ::Rbml::Processor.new
publish_file = File.read(Generator.act_on.home+'paginate')
id = Generator.entry_bank.first[:id]
puts "writing partial for #{id}"
hold = Generator.entry_bank.dup
begin
write rbml.render('xhtml', rbml.load_language('xhtml'), :partial => true) { eval(publish_file) }, publishing_to+id
rescue
Generator.entry_bank = hold
write rbml.render('xhtml', rbml.load_language('xhtml'), :format => false, :partial => true) { eval(publish_file) }, publishing_to+id rescue puts $!
end
@page_list << id
File.open(publishing_to+'page.list', 'w') { |yf| YAML.dump(@page_list, yf) }
write_template Generator.act_on.home+'link_list', "#{@page.home}blueprint/#{@page.page_location}/_#{@page.file_name}_#{Generator.act_on.name}_links.rbml" rescue puts "writing template -- #{$!}"
puts "writing link list _#{@page.file_name}_#{Generator.act_on.name}_links"
end
@page_list = nil
Generator.act_on.instance_eval { @level = nil; undef :level; undef :level=}
Generator.unload
end
|
#publish_feeds(blank = nil) ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/static.rb', line 109
def publish_feeds blank = nil
$active_site.info['feeds'].each do |name|
col = load_collection(name)
col.publish
Generator.load col
Generator.act_on.instance_eval {
def level; @level end; def level=(what); @level=what end
def last_built
date = ''
listing.each {|item| date = item[:publish] if item[:publish] and not date}
date
end
}
write ::Rbml::Processor.run(col.home+'feed'), $active_site.site_loc.as_folder+name+'.rss' rescue puts $!
puts $active_site.site_loc.as_folder+name+'.rss'
Generator.act_on.instance_eval { @level = nil; undef :level; undef :level=}
Generator.unload
end if $active_site.info['feeds']
unless blank
puts "rsync -avz #{$active_site.site_loc}/* #{$active_site.info['user_name']}@#{$active_site.info['server']['address']}:#{$active_site.info['server']['directory']}"
system "rsync -avz #{$active_site.site_loc}/* #{$active_site.info['user_name']}@#{$active_site.info['server']['address']}:#{$active_site.info['server']['directory']}"
end
end
|
#set_layout(which, force) ⇒ Object
42
43
44
45
46
47
|
# File 'lib/static.rb', line 42
def set_layout which, force
return nil unless which
destroy $active_site.home+'layout/' if force
$active_site.set_layout(which, $ENV['LAYOUT_HOME']) unless exists? :folder, $active_site.home+'layout/'
$active_site.save_info('site.info')
end
|
#start_collection(name, attrs = []) ⇒ Object
49
50
51
|
# File 'lib/static.rb', line 49
def start_collection name, attrs=[]
Collection.start $ENV['STATIC_HOME'], $active_site.home, name, attrs
end
|
#start_site(name) ⇒ Object
33
34
35
36
|
# File 'lib/static.rb', line 33
def start_site name
site = Site.start($ENV['SITE_BANK'], name, $ENV['STATIC_VIEWING'], $ENV['TEMPLATE_HOME'])
site
end
|