static 0.1.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +213 -0
- data/README.md +50 -0
- data/Rakefile +40 -11
- data/bin/static +5 -93
- data/lib/static.rb +6 -145
- data/lib/static/cli.rb +32 -0
- data/lib/static/cli/app/download.rb +40 -0
- data/lib/static/version.rb +5 -0
- metadata +111 -79
- data/History.txt +0 -5
- data/Manifest.txt +0 -36
- data/README.txt +0 -307
- data/bin/cli.rbml +0 -321
- data/lib/collection.rb +0 -161
- data/lib/extentions/class.rb +0 -43
- data/lib/extentions/string.rb +0 -11
- data/lib/filebase.rb +0 -84
- data/lib/generator.rb +0 -20
- data/lib/page.rb +0 -135
- data/lib/site.rb +0 -153
- data/lib/xhtml.rb +0 -198
- data/templates/disco/attributes +0 -3
- data/templates/disco/display +0 -6
- data/templates/disco/feed +0 -21
- data/templates/disco/link_list +0 -6
- data/templates/disco/paginate +0 -1
- data/templates/helpers/content.rb +0 -393
- data/templates/helpers/prototype.js +0 -3277
- data/templates/layouts/default/contents.erbml +0 -8
- data/templates/layouts/default/copy/page.copy +0 -4
- data/templates/layouts/default/main_navigation.erbml +0 -10
- data/templates/layouts/default/page_head.erbml +0 -7
- data/templates/layouts/default/structure/default.rbml +0 -22
- data/templates/layouts/default/structure/footer.rbml +0 -6
- data/templates/layouts/default/stylesheets/default.css +0 -180
- data/templates/layouts/default/submenu.erbml +0 -13
- data/templates/page.copy +0 -3
- data/templates/site.info +0 -3
- data/templates/site.map +0 -15
- data/templates/submenu.copy +0 -0
data/bin/cli.rbml
DELETED
@@ -1,321 +0,0 @@
|
|
1
|
-
cli :name=>"static", :prompt=>"-> " do
|
2
|
-
set :help do
|
3
|
-
helpdocs
|
4
|
-
end
|
5
|
-
|
6
|
-
set :unknown_command do |method, args|
|
7
|
-
puts "command not found: #{method} \nwith args: #{args.join(' ')}"
|
8
|
-
end
|
9
|
-
|
10
|
-
set :feed do |args|
|
11
|
-
flag(:new => 'n'){@new = true}
|
12
|
-
process(args)
|
13
|
-
feeds = []
|
14
|
-
name = (remaining_argument == '' ? '.' : remaining_argument)
|
15
|
-
feeds << unless @new
|
16
|
-
name = choice('please choose a collection:', items_under($active_site.home+'collections')[:folders], name)
|
17
|
-
name
|
18
|
-
else
|
19
|
-
name
|
20
|
-
end
|
21
|
-
$active_site.info['feeds'] ||= []
|
22
|
-
$active_site.info['feeds'] << feeds
|
23
|
-
$active_site.info['feeds'].flatten!.uniq!
|
24
|
-
$active_site.save_info 'site.info'
|
25
|
-
puts "add this to base/default.rbml to host:\n\t`feed :#{name}`"
|
26
|
-
end
|
27
|
-
|
28
|
-
set :start do |args|
|
29
|
-
key(:editor){ @active = :editor }
|
30
|
-
key(:site){ @active = :site }
|
31
|
-
key(:collection){ @active = :collection }
|
32
|
-
key(:with)
|
33
|
-
flag(:help => 'h'){ puts "helpdocs for 'start' go here" }
|
34
|
-
|
35
|
-
process(args)
|
36
|
-
name = (remaining_argument == '' ? request_value('please enter a name: ') : remaining_argument) unless @active == :editor
|
37
|
-
@active = ($active_site ? :collection : :site) unless @active
|
38
|
-
|
39
|
-
case @active
|
40
|
-
when :site
|
41
|
-
$active_site = start_site(name)
|
42
|
-
if $active_site
|
43
|
-
puts "starting a site map for #{$active_site.name}"
|
44
|
-
else
|
45
|
-
puts "looks like there is already a site called #{name}"
|
46
|
-
end
|
47
|
-
when :collection
|
48
|
-
if $active_site
|
49
|
-
name = remaining_arguments.shift
|
50
|
-
$active_collection = start_collection(name, remaining_arguments)
|
51
|
-
if $active_collection
|
52
|
-
puts "#{name} collection is active"
|
53
|
-
else
|
54
|
-
puts "looks like there is already a collection called #{name}"
|
55
|
-
end
|
56
|
-
else
|
57
|
-
puts 'gotta have a site to make a collection'
|
58
|
-
end
|
59
|
-
when :editor
|
60
|
-
$active_site.info['user_name'] ||= request_value 'username on your server: '
|
61
|
-
$active_site.info['server'] ||= {}
|
62
|
-
$active_site.info['local'] ||= {}
|
63
|
-
$active_site.info['server']['address'] ||= request_value 'server address (that you would use to ssh): '
|
64
|
-
$active_site.info['server']['directory'] ||= request_value 'directory on server (e.g. ~/www): '
|
65
|
-
$active_site.info['server']['link'] ||= request_value('web address of site home (e.g. somesite.com): ' ).as_http
|
66
|
-
$active_site.info['local']['link'] ||= request_value('local address of site home (e.g. localhost/~username/): ' ).as_http+"static/#{$active_site.info['working_name']}"
|
67
|
-
|
68
|
-
$active_site.info['server']['link'] = $active_site.info['server']['link'].as_http
|
69
|
-
$active_site.save_info 'site.info'
|
70
|
-
system "camping #{$active_site.home}helpers/content.rb"
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
set :assign do |args|
|
75
|
-
flag(:page => 'p'){ |name|
|
76
|
-
@page = choice('please choose a page:', @possible_pages, name.downcase)
|
77
|
-
}
|
78
|
-
flag(:collection => 'c'){ |name|
|
79
|
-
@collection = load_collection(choice('please choose a collection:', items_under($active_site.home+'collections')[:folders], name.downcase))
|
80
|
-
}
|
81
|
-
key(:paginate){@paginate = true}
|
82
|
-
|
83
|
-
if $active_site
|
84
|
-
ready = exists? :folder, $active_site.home+'blueprint'
|
85
|
-
if ready
|
86
|
-
@possible_pages = []
|
87
|
-
$active_site.pages.each{ |page| @possible_pages << page unless $active_site.info['paginate'] && $active_site.info['paginate'].keys.include?(page.file_name) }
|
88
|
-
process(args)
|
89
|
-
|
90
|
-
@collection ||= load_collection(choice('please choose a collection:', items_under($active_site.home+'collections')[:folders]))
|
91
|
-
puts "\n - - - \n" unless @page
|
92
|
-
@page ||= choice('please choose a page:', @possible_pages)
|
93
|
-
assign_pagination @collection.file_name, @page.file_name
|
94
|
-
paginate @page.file_name if @paginate
|
95
|
-
else
|
96
|
-
puts 'please build a blueprint paginating collections'
|
97
|
-
end
|
98
|
-
else
|
99
|
-
ready ? message : 'please choose a site'
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
set :paginate do |name|
|
104
|
-
@page = choice('which page did you mean?', $active_site.info['paginate'].keys, name) if name
|
105
|
-
if exists? :folder, $active_site.home+'blueprint'
|
106
|
-
if @page
|
107
|
-
paginate @page
|
108
|
-
else
|
109
|
-
if $active_site.info['paginate']
|
110
|
-
$active_site.info['paginate'].each { |page, collection| paginate page }
|
111
|
-
else
|
112
|
-
puts 'please use `assign` to assign a collection to a page before paginating'
|
113
|
-
end
|
114
|
-
end
|
115
|
-
else
|
116
|
-
puts 'please generate your blueprint before paginating'
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
set :layout do |args|
|
121
|
-
key(:choose) { @active = :choose }
|
122
|
-
key(:save) { @active = :choose }
|
123
|
-
flag(:force => 'f'){ @force = true }
|
124
|
-
process args
|
125
|
-
name = (remaining_argument == '' ? '.' : remaining_argument)
|
126
|
-
@active = :choose unless @active
|
127
|
-
case @active
|
128
|
-
when :choose
|
129
|
-
if $active_site
|
130
|
-
if set_layout choice('please choose a layout:', items_under($ENV['LAYOUT_HOME'])[:folders], name), @force
|
131
|
-
puts "#{$active_site.info['layout']['name']} is now being used" else puts 'no new layout was chosen'
|
132
|
-
end
|
133
|
-
else
|
134
|
-
puts 'there is no active site right now.'
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
set :edit do |args|
|
140
|
-
key(:site)
|
141
|
-
key(:attributes){
|
142
|
-
@collection = $active_collection.name unless @collection
|
143
|
-
@edit << :attributes
|
144
|
-
}
|
145
|
-
key(:display){
|
146
|
-
@collection = $active_collection.name unless @collection
|
147
|
-
@edit << :display
|
148
|
-
}
|
149
|
-
key(:all){
|
150
|
-
@collection = $active_collection.name unless @collection
|
151
|
-
@edit = [:attributes, :display]
|
152
|
-
}
|
153
|
-
flag(:entry){
|
154
|
-
@edit = :entry
|
155
|
-
}
|
156
|
-
flag(:collection => 'c'){ |name| @collection = name }
|
157
|
-
|
158
|
-
|
159
|
-
@edit = []
|
160
|
-
process args
|
161
|
-
file = remaining_argument
|
162
|
-
file = 'contents' if file == 'copy'
|
163
|
-
|
164
|
-
if $active_site
|
165
|
-
case
|
166
|
-
when @edit == :entry
|
167
|
-
@collection ||= $active_collection
|
168
|
-
file ||= :last
|
169
|
-
puts 'getting ready to edit an entry'
|
170
|
-
when @collection
|
171
|
-
@edit.each { |item|
|
172
|
-
puts "opening #{@collection}'s attributes"
|
173
|
-
edit("#{$active_site.home}collections/#{@collection}/#{item.to_s}")
|
174
|
-
}
|
175
|
-
when exists?(:file, "#{$active_site.home}project_info/#{file}") then
|
176
|
-
puts "opening #{$active_site.name}'s #{file}"
|
177
|
-
edit("#{$active_site.home}project_info/#{file}")
|
178
|
-
$active_site.load_info(file)
|
179
|
-
$active_site.load_pages if file == 'site.map'
|
180
|
-
when exists?(:any, $active_site.home+file) : edit($active_site.home+file)
|
181
|
-
else
|
182
|
-
puts "no file found: #{$active_site.home}"
|
183
|
-
end
|
184
|
-
else
|
185
|
-
puts 'no active site'
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
set :load do |args|
|
190
|
-
key(:site){ @active = :site }
|
191
|
-
key(:collection){ @active = :collection }
|
192
|
-
|
193
|
-
flag(:help => 'h'){ puts "helpdocs for 'load' go here" }
|
194
|
-
|
195
|
-
process(args)
|
196
|
-
name = (remaining_argument == '' ? '.' : remaining_argument)
|
197
|
-
@active = $active_site ? :collection : :site unless @active
|
198
|
-
|
199
|
-
case @active
|
200
|
-
when :site then
|
201
|
-
$active_site = load_site(name)
|
202
|
-
if $active_site
|
203
|
-
puts "#{$active_site.name} site is active"
|
204
|
-
else
|
205
|
-
$active_site = load_site(choice('available sites', items_under($ENV['SITE_BANK'])[:folders], name))
|
206
|
-
puts 'sorry bub, nuthin there.' unless $active_site
|
207
|
-
end
|
208
|
-
when :collection then
|
209
|
-
$active_collection = nil
|
210
|
-
if $active_site
|
211
|
-
$active_collection = load_collection(name)
|
212
|
-
if $active_collection
|
213
|
-
puts("#{$active_collection.name} collection is active")
|
214
|
-
else
|
215
|
-
$active_collection = load_collection(choice('available collections', items_under($active_site.home+'collections')[:folders], name))
|
216
|
-
unless $active_collection
|
217
|
-
puts 'can\'t find a collection like that, baby'
|
218
|
-
else
|
219
|
-
puts("#{$active_collection.name} collection is active")
|
220
|
-
end
|
221
|
-
end
|
222
|
-
else
|
223
|
-
puts 'there must be an active site before starting a collection'
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
set :generate do
|
229
|
-
ready = exists? :folder, $active_site.home+'layout'
|
230
|
-
message = 'please choose a layout before generating html' unless ready
|
231
|
-
if ready
|
232
|
-
ready = exists? :folder, $active_site.home+'blueprint'
|
233
|
-
message = 'please build a blueprint before generating html' unless ready
|
234
|
-
if ready
|
235
|
-
ready = exists? :folder, $active_site.home+'contents'
|
236
|
-
message = 'please build the site content before generating html' unless ready
|
237
|
-
end
|
238
|
-
end
|
239
|
-
if $active_site
|
240
|
-
if ready
|
241
|
-
destroy $active_site.site_loc
|
242
|
-
$active_site.generate
|
243
|
-
else
|
244
|
-
puts(message)
|
245
|
-
end
|
246
|
-
else
|
247
|
-
puts 'need a site before you can generate one'
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
|
-
set :add do |args|
|
252
|
-
edit $active_collection.add_entry[:file]
|
253
|
-
$active_collection.sanitize_listing
|
254
|
-
$active_collection.save_listing
|
255
|
-
end
|
256
|
-
|
257
|
-
set :build do |args|
|
258
|
-
key(:copy){ @active = :contents }
|
259
|
-
key(:contents){ @active = :contents }
|
260
|
-
key(:blueprint){ @active = :blueprint }
|
261
|
-
key(:all){ @active = :all }
|
262
|
-
flag(:force => 'f'){ @force = true }
|
263
|
-
process args
|
264
|
-
@active = :contents unless @active
|
265
|
-
set_layout(choice('please choose a layout:', items_under($ENV['LAYOUT_HOME'])[:folders]), false) unless $active_site.info['layout']
|
266
|
-
case @active
|
267
|
-
when :contents then
|
268
|
-
destroy $active_site.home+'contents' if @force
|
269
|
-
$active_site.build(:contents)
|
270
|
-
when :blueprint then
|
271
|
-
destroy $active_site.home+'blueprint' if @force
|
272
|
-
$active_site.build(:blueprint)
|
273
|
-
when :all then
|
274
|
-
destroy $active_site.home+'blueprint' if @force and not make_sure('do you want to destroy the blueprints?', 'N', 'y')
|
275
|
-
destroy $active_site.home+'contents' if @force and not make_sure('do you want to destroy the contents?', 'N', 'y')
|
276
|
-
$active_site.build(:contents)
|
277
|
-
$active_site.build(:blueprint)
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
set :clear do
|
282
|
-
system 'clear'
|
283
|
-
end
|
284
|
-
|
285
|
-
set :publish do |args|
|
286
|
-
flag(:user => 'u'){ |value|
|
287
|
-
$active_site.info['user_name'] = value || request_value( 'username: ' )
|
288
|
-
}
|
289
|
-
flag(:address => 'a'){ |value|
|
290
|
-
$active_site.info['server'] ||= {}
|
291
|
-
$active_site.info['server']['address'] = value || request_value('server address: ' )
|
292
|
-
}
|
293
|
-
flag(:dir => 'd'){ |value|
|
294
|
-
$active_site.info['server'] ||= {}
|
295
|
-
$active_site.info['server']['location'] = value || request_value( 'site location on server: ' )
|
296
|
-
}
|
297
|
-
flag(:link => 'l'){ |value|
|
298
|
-
$active_site.info['server'] ||= {}
|
299
|
-
$active_site.info['server']['link'] = value || request_value( 'web address of site home: ' )
|
300
|
-
}
|
301
|
-
flag(:blank => 'b'){ @blank = true }
|
302
|
-
process args
|
303
|
-
$active_site.info['user_name'] ||= request_value 'username: '
|
304
|
-
$active_site.info['server'] ||= {}
|
305
|
-
$active_site.info['server']['address'] ||= request_value 'server address: '
|
306
|
-
$active_site.info['server']['directory'] ||= request_value 'directory on server: '
|
307
|
-
$active_site.info['server']['link'] ||= request_value('web address of site home: ' ).as_http
|
308
|
-
$active_site.info['server']['link'] = $active_site.info['server']['link'].as_http
|
309
|
-
|
310
|
-
$active_site.save_info 'site.info'
|
311
|
-
publish_feeds @blank
|
312
|
-
end
|
313
|
-
|
314
|
-
|
315
|
-
set :quit do
|
316
|
-
exit
|
317
|
-
end
|
318
|
-
set :exit do
|
319
|
-
exit
|
320
|
-
end
|
321
|
-
end
|
data/lib/collection.rb
DELETED
@@ -1,161 +0,0 @@
|
|
1
|
-
class Collection
|
2
|
-
attr_accessor :name, :attrs, :base, :listing, :entries, :contents, :unpublished
|
3
|
-
include FileBase
|
4
|
-
def initialize base, where, name
|
5
|
-
set_home where
|
6
|
-
@base = base
|
7
|
-
@name = name
|
8
|
-
@attrs = []
|
9
|
-
@listing = []
|
10
|
-
@entries = []
|
11
|
-
@unpublished = []
|
12
|
-
setup_location 'collections'
|
13
|
-
set_home path+name
|
14
|
-
end
|
15
|
-
|
16
|
-
def file_name
|
17
|
-
name.as_file
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.start base, where, name, attrs
|
21
|
-
return nil if self.collection_exists?(base, where, name)
|
22
|
-
c = self.new base, where, name
|
23
|
-
c.attrs << attrs
|
24
|
-
c.attrs.flatten!
|
25
|
-
c.write_attribute_file
|
26
|
-
c.load_attributes
|
27
|
-
c.write_display_file rescue puts $!
|
28
|
-
c.write_feed_file
|
29
|
-
copy base+'.templates/disco/link_list', c.home
|
30
|
-
c.write_paginate_file
|
31
|
-
c.write '', c.home+'listing'
|
32
|
-
c.mkdir c.home+'entries'
|
33
|
-
c
|
34
|
-
end
|
35
|
-
|
36
|
-
def display_file
|
37
|
-
home+'display'
|
38
|
-
end
|
39
|
-
def self.collection_exists?(base, where, name)
|
40
|
-
exists?(:folder, base) && exists?(:folder, where+'collections/'+name) && exists?(:file, where+"collections/#{name}/attributes")
|
41
|
-
end
|
42
|
-
def self.load base, where, name
|
43
|
-
return nil unless self.collection_exists?(base, where, name)
|
44
|
-
c = self.new base, where, name
|
45
|
-
c.load_attributes
|
46
|
-
c.load_listing
|
47
|
-
c.sanitize_listing
|
48
|
-
c.load_entries
|
49
|
-
c
|
50
|
-
end
|
51
|
-
|
52
|
-
def save_listing
|
53
|
-
File.open(home+'listing', 'w') { |yf| YAML.dump(@listing, yf) }
|
54
|
-
@listing
|
55
|
-
end
|
56
|
-
|
57
|
-
def sanitize_listing
|
58
|
-
tmp = []
|
59
|
-
@listing.each { |item|
|
60
|
-
entry = load_entry(item)
|
61
|
-
add = false
|
62
|
-
attrs = File.open( home+'attributes' ) { |yf| @attrs = YAML::load( yf )[name] }
|
63
|
-
entry.each { |key, value|
|
64
|
-
if attrs.include? key
|
65
|
-
add = true if value and not attrs[key]
|
66
|
-
end
|
67
|
-
}
|
68
|
-
item[:publish] = false unless add or item[:publish]
|
69
|
-
tmp << item
|
70
|
-
}
|
71
|
-
@listing = tmp
|
72
|
-
save_listing
|
73
|
-
end
|
74
|
-
|
75
|
-
def write_attribute_file
|
76
|
-
write_template base+'.templates/disco/attributes', home+'attributes'
|
77
|
-
end
|
78
|
-
def write_display_file
|
79
|
-
write_template base+'.templates/disco/display', home+'display'
|
80
|
-
end
|
81
|
-
def write_feed_file
|
82
|
-
write_template base+'.templates/disco/feed', home+'feed'
|
83
|
-
end
|
84
|
-
def write_paginate_file
|
85
|
-
write_template base+'.templates/disco/paginate', home+'paginate'
|
86
|
-
end
|
87
|
-
def write_link_list_file
|
88
|
-
write_template base+'.templates/disco/link_list', home+'link_list'
|
89
|
-
end
|
90
|
-
def load_attributes
|
91
|
-
File.open( home+'attributes' ) { |yf| @attrs = YAML::load( yf )[name] }
|
92
|
-
end
|
93
|
-
def load_listing
|
94
|
-
File.open( home+'listing' ) { |yf| @listing = YAML::load( yf ) }
|
95
|
-
@listing ||= []
|
96
|
-
@listing = @listing.sort{|x, y| x[:id] <=> y[:id]}.reverse
|
97
|
-
end
|
98
|
-
def save_entry(id)
|
99
|
-
File.open( home+'entries/'+id, 'w' ) {|yf|
|
100
|
-
tmp={}
|
101
|
-
tmp[name] = find_entry id
|
102
|
-
tmp[name] = tmp[name].reject{|key, value| key.kind_of? Symbol }
|
103
|
-
YAML::dump( tmp, yf)
|
104
|
-
}
|
105
|
-
find_entry id
|
106
|
-
end
|
107
|
-
def load_entries
|
108
|
-
@entries = []
|
109
|
-
@unpublished = []
|
110
|
-
listing.each {|entry|
|
111
|
-
if entry[:publish]
|
112
|
-
@entries << load_entry(entry)
|
113
|
-
else
|
114
|
-
@unpublished << load_entry(entry)
|
115
|
-
end
|
116
|
-
}
|
117
|
-
entries
|
118
|
-
end
|
119
|
-
def delete entry
|
120
|
-
listing.delete_if{|e| e[:id] == entry }
|
121
|
-
save_listing
|
122
|
-
end
|
123
|
-
def load_entry(file)
|
124
|
-
tmp = nil
|
125
|
-
File.open( home+'entries/'+file[:id].to_s ) {|yf| tmp = YAML::load( yf )[name].merge(file)} rescue puts "loading entry -- #{$!}"
|
126
|
-
tmp
|
127
|
-
end
|
128
|
-
def add_entry title=nil
|
129
|
-
timestamp = Time.now.to_i.to_s
|
130
|
-
title ||= timestamp
|
131
|
-
listing.unshift({:id => timestamp})
|
132
|
-
save_listing
|
133
|
-
write_template home+'attributes', home+'entries/'+timestamp
|
134
|
-
load_entries
|
135
|
-
return {:id => timestamp, :file => home+'entries/'+timestamp}
|
136
|
-
end
|
137
|
-
def publish
|
138
|
-
tmp = {}
|
139
|
-
listing.each {|e|
|
140
|
-
if e[:publish] and not e[:publish].kind_of? String
|
141
|
-
e[:publish] = Time.now.to_s
|
142
|
-
end
|
143
|
-
}
|
144
|
-
save_listing
|
145
|
-
end
|
146
|
-
|
147
|
-
def set_to_publish entry
|
148
|
-
listing.find{|e| e[:id] == entry}[:publish] = true
|
149
|
-
save_listing
|
150
|
-
end
|
151
|
-
|
152
|
-
def find_entry entry
|
153
|
-
tmp = entries.find{|e| e[:id] == entry}
|
154
|
-
tmp ||= unpublished.find{|e| e[:id] == entry}
|
155
|
-
tmp
|
156
|
-
end
|
157
|
-
|
158
|
-
|
159
|
-
end
|
160
|
-
|
161
|
-
|