static 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -20,7 +20,8 @@ templates/site.info
20
20
  templates/submenu.copy
21
21
  templates/disco/attributes
22
22
  templates/disco/display
23
- templates/disco/publish
23
+ templates/disco/paginate
24
+ templates/disco/feed
24
25
  templates/disco/link_list
25
26
  templates/layouts/default/contents.erbml
26
27
  templates/layouts/default/main_navigation.erbml
@@ -29,4 +30,5 @@ templates/layouts/default/submenu.erbml
29
30
  templates/layouts/default/structure/default.rbml
30
31
  templates/layouts/default/structure/footer.rbml
31
32
  templates/layouts/default/stylesheets/default.css
33
+ templates/layouts/default/copy/page.copy
32
34
 
data/README.txt CHANGED
@@ -1,4 +1,4 @@
1
- static
1
+ === static
2
2
  by evan short
3
3
 
4
4
  == DESCRIPTION:
@@ -11,6 +11,7 @@ paginated over a page. this allows such features as news, faqs,
11
11
  blogs and other galleries.
12
12
 
13
13
  == FEATURES:
14
+
14
15
  - command line interface
15
16
  - multiple site management
16
17
  - yaml site map
@@ -28,19 +29,38 @@ blogs and other galleries.
28
29
  - prompt context
29
30
  - tab completion
30
31
  - termios integration (or otherwise implemented command history)
31
- - error messaging
32
+ - better error messaging
32
33
  - documentation
33
34
  - how layouts work
34
35
  - how blueprints work
35
- - word is out on how well it takes to switching the site map. my
36
- own guess is not well.
37
36
  - there are no specs
38
37
  - ready for a re-factor
39
38
 
40
- == SYNOPSIS:
39
+ if i had to guess i would say that this will not work on windows. it
40
+ is organized for a mac, but works fine, im sure, under unix in general
41
+ i don't know that much about cygwin. i don't anticipate fixing this myself
42
+ (or even look into it) without some incentive. i will happily take patches.
43
+
44
+ == TODO:
45
+
46
+ - deal with resources (e.g. images, movies, etc)
47
+ - allow +display+ to take a block describing the layout
48
+ - command to preview in browser
49
+ - give better program hooks in the static home
50
+ - allow pages to override the default layout
51
+ - allow collections to override the default layout
52
+ - give a method to display the site map
53
+ - rename partials with underscores
54
+ - option to turn links off if current
55
+ - stop css from being overwritten when re-generating the blueprint
56
+ - simple site versioning
57
+ - css versioning
58
+ - page splitting in copy
59
+
60
+ == USAGE NOTES:
41
61
 
42
62
  so, first thing's first open up a terminal and run static. the first
43
- time it is run a folder called +static+ will be created in your ~/.
63
+ time it is run a folder called +static+ will be created in your <tt>~/</tt>.
44
64
  in this folder your layouts and projects will be kept, along with a
45
65
  few template files in <tt>.templates</tt> that will be used when
46
66
  creating a site.
@@ -80,7 +100,19 @@ page in your site map. you may then run
80
100
  to edit the contents of those pages. more desireably, perhaps, you may
81
101
  zip this folder up and send it off to someone more suited to edit copy.
82
102
 
83
- next you must choose a layout.
103
+ some things to note when editing copy:
104
+
105
+ - this must be a properly formatted yaml file
106
+ - use <tt>: |</tt> followed by an indented block of text to use multiline text in yaml
107
+ - use *s instead of -s to indicate list elements underneath <tt>: |</tt>s
108
+
109
+ if it is not a properly formatted yaml file, generate will simply fail. you will hardly
110
+ be given an error message, and certainly nothing helpful. it is for this reason i
111
+ suggest you check your contents files twice before sending them through the grinder.
112
+ definitely some robustness or something needed here.
113
+ given no me you will simp
114
+
115
+ anyway, next you must choose a layout.
84
116
 
85
117
  -> layout
86
118
 
@@ -112,11 +144,18 @@ once the layout is satisfactory, running
112
144
 
113
145
  will put the blueprint folder in place.
114
146
 
115
- -> edit blueprints
147
+ -> edit blueprint
116
148
 
117
149
  will take you there to edit.
118
150
 
119
- at this point you may generate your site by running
151
+ to build the copy, choose a layout, and build the blueprint in one go:
152
+
153
+ -> build all
154
+
155
+ it is worth noting that the edit commands may be used at any time, not only
156
+ directly after building that particular section.
157
+
158
+ either way you get here, at this point you may generate your site by running
120
159
 
121
160
  -> generate
122
161
 
@@ -215,18 +254,32 @@ as a lower-case symbol) as such:
215
254
 
216
255
  get :page_name, :collection_name => :links
217
256
 
218
- there is much more to say, but a lot of it can be gleaned by looking at the
219
- stuff that is generated by default. any questions may be directed to
257
+ == A Note from the Author
258
+
259
+ there is much more to say, and there is no doubt that this is a first release,
260
+ but a lot of what is going on can be gleaned by looking at the stuff that is
261
+ generated by default. any questions may be directed to
220
262
 
221
263
  evan.short @ pleasedontspam. gmail.please
222
264
 
265
+ suggestions and criticisms are welcome. i am aware that when things go sour
266
+ there is often no word as to what actually went wrong. you can tell me
267
+ about them if you feel so inclined, but i am of the opinion that some more
268
+ reasonable error messaging needs to happen in rbml rather than too much
269
+ more effort going into my dilligence at writing horribly nested if statements
270
+ in the cli script.
271
+
223
272
  == REQUIREMENTS:
224
273
 
225
274
  rbml v. 0.0.5.9.4.1
226
275
 
227
276
  == INSTALL:
228
277
 
229
- sudo gem install static
278
+ i looked into it briefly but found nothing about actually making a dependency
279
+ in a gem. if anyone knows how to do this, please let me know.
280
+
281
+ sudo gem install rbml
282
+ sudo gem install static
230
283
 
231
284
  == LICENSE:
232
285
 
data/bin/cli.rbml CHANGED
@@ -7,6 +7,24 @@ cli :name=>"static", :prompt=>"-> " do
7
7
  puts "command not found: #{method} \nwith args: #{args.join(' ')}"
8
8
  end
9
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
+
10
28
  set :start do |args|
11
29
  key(:site){ @active = :site }
12
30
  key(:collection){ @active = :collection }
@@ -14,7 +32,7 @@ cli :name=>"static", :prompt=>"-> " do
14
32
  flag(:help => 'h'){ puts "helpdocs for 'start' go here" }
15
33
 
16
34
  process(args)
17
- name = (remaining_argument == '' ? '.' : remaining_argument)
35
+ name = (remaining_argument == '' ? request_value('please enter a name: ') : remaining_argument)
18
36
  @active = ($active_site ? :collection : :site) unless @active
19
37
 
20
38
  case @active
@@ -75,7 +93,11 @@ cli :name=>"static", :prompt=>"-> " do
75
93
  if @page
76
94
  paginate @page
77
95
  else
78
- $active_site.info['paginate'].each { |page, collection| paginate page }
96
+ if $active_site.info['paginate']
97
+ $active_site.info['paginate'].each { |page, collection| paginate page }
98
+ else
99
+ puts 'please use `assign` to assign a collection to a page before paginating'
100
+ end
79
101
  end
80
102
  else
81
103
  puts 'please generate your blueprint before paginating'
@@ -115,8 +137,12 @@ cli :name=>"static", :prompt=>"-> " do
115
137
  @collection = $active_collection.name unless @collection
116
138
  @edit = [:attributes, :display]
117
139
  }
140
+ flag(:entry){
141
+ @edit = :entry
142
+ }
118
143
  flag(:collection => 'c'){ |name| @collection = name }
119
144
 
145
+
120
146
  @edit = []
121
147
  process args
122
148
  file = remaining_argument
@@ -124,6 +150,10 @@ cli :name=>"static", :prompt=>"-> " do
124
150
 
125
151
  if $active_site
126
152
  case
153
+ when @edit == :entry
154
+ @collection ||= $active_collection
155
+ file ||= :last
156
+ puts 'getting ready to edit an entry'
127
157
  when @collection
128
158
  @edit.each { |item|
129
159
  puts "opening #{@collection}'s attributes"
@@ -219,19 +249,19 @@ cli :name=>"static", :prompt=>"-> " do
219
249
  flag(:force => 'f'){ @force = true }
220
250
  process args
221
251
  @active = :contents unless @active
252
+ set_layout(choice('please choose a layout:', items_under($ENV['LAYOUT_HOME'])[:folders]), false) unless $active_site.info['layout']
222
253
  case @active
223
254
  when :contents then
224
255
  destroy $active_site.home+'contents' if @force
225
- $active_site.build(:contents)
256
+ $active_site.build(:contents)
226
257
  when :blueprint then
227
258
  destroy $active_site.home+'blueprint' if @force
228
- $active_site.info['layout'] ? $active_site.build(:blueprint) : puts('need to choosee a layout')
259
+ $active_site.build(:blueprint)
229
260
  when :all then
230
- destroy $active_site.home+'blueprint' if @force
261
+ destroy $active_site.home+'blueprint' if @force and not make_sure('do you want to destroy the blueprints?', 'N', 'y')
231
262
  destroy $active_site.home+'contents' if @force and not make_sure('do you want to destroy the contents?', 'N', 'y')
232
263
  $active_site.build(:contents)
233
- $active_site.info['layout'] ? $active_site.build(:blueprint) : set_layout(choice('please choose a layout:', items_under($ENV['LAYOUT_HOME'])[:folders]), false)
234
- $active_site.build(:blueprint) unless exists? :folder, $active_site.home+'blueprint'
264
+ $active_site.build(:blueprint)
235
265
  end
236
266
  end
237
267
 
@@ -239,7 +269,39 @@ cli :name=>"static", :prompt=>"-> " do
239
269
  system 'clear'
240
270
  end
241
271
 
272
+ set :publish do |args|
273
+ flag(:user => 'u'){ |value|
274
+ $active_site.info['user_name'] = value || request_value( 'username: ' )
275
+ }
276
+ flag(:address => 'a'){ |value|
277
+ $active_site.info['server'] ||= {}
278
+ $active_site.info['server']['address'] = value || request_value('server address: ' )
279
+ }
280
+ flag(:dir => 'd'){ |value|
281
+ $active_site.info['server'] ||= {}
282
+ $active_site.info['server']['location'] = value || request_value( 'site location on server: ' )
283
+ }
284
+ flag(:link => 'l'){ |value|
285
+ $active_site.info['server'] ||= {}
286
+ $active_site.info['server']['link'] = value || request_value( 'web address of site home: ' )
287
+ }
288
+ flag(:blank => 'b'){ @blank = true }
289
+ process args
290
+ $active_site.info['user_name'] ||= request_value 'username: '
291
+ $active_site.info['server'] ||= {}
292
+ $active_site.info['server']['address'] ||= request_value 'server address: '
293
+ $active_site.info['server']['directory'] ||= request_value 'directory on server: '
294
+ $active_site.info['server']['link'] ||= request_value('web address of site home: ' ).as_http
295
+ $active_site.info['server']['link'] = $active_site.info['server']['link'].as_http
296
+
297
+ $active_site.save_info 'site.info'
298
+ publish_feeds @blank
299
+ end
300
+
242
301
  set :quit do
243
302
  exit
244
303
  end
304
+ set :exit do
305
+ exit
306
+ end
245
307
  end
data/bin/static CHANGED
@@ -49,10 +49,33 @@ include Static
49
49
  ::Rbml::Processor.run(File.dirname(__FILE__)+'/cli.rbml')
50
50
 
51
51
  __END__
52
- $active_site = load_site('please')
53
- paginate :static
52
+ $active_site = load_site('static')
53
+ destroy $active_site.site_loc
54
+ $active_site.generate
55
+ set_layout($active_site.info['layout'], false)
56
+ $active_site.build :contents
57
+ $active_site.build :blueprint
58
+ $active_site.info['layout']='default'
59
+ $active_site.info['username'] = 'e'
60
+ $active_site.info['server'] = {}
61
+ $active_site.info['server']['link'] = 'http://newqdev.com'
62
+ $active_site.info['server']['address'] = 'newqdev.com'
63
+ $active_site.info['server']['directory'] = '~/newqdev.com'
64
+ $active_collection = $active_site.start_collection 'news', ['date', 'headline', 'entry']
65
+ $active_site.generate
66
+ destroy $active_site.site_loc
67
+ $active_site.generate
68
+ #system "vi #{$active_collection.home}attributes"
69
+ 5.times do
70
+ puts $active_collection.add_entry
71
+ $active_collection.save_listing
72
+ gets
73
+ end
74
+ $active_site.info['feeds'] = ['news']
75
+ $active_site.save_info 'site.info'
76
+ publish_feeds true
54
77
 
55
- $active_site.build :all
78
+ __END__
56
79
  #system "#{$ENV['EDITOR']} #{$active_site.home}"
57
80
  paginate :the_copy
58
81
  destroy $active_site.site_loc
@@ -61,7 +84,6 @@ $active_site.generate
61
84
  $active_site = start_site('static')
62
85
  $active_site.load_info
63
86
  $active_site.load_pages
64
- $active_site.start_collection 'news', ['date', 'headline', 'entry']
65
87
  $active_site.start_collection 'blog', ['date', 'title', 'entry']
66
88
 
67
89
  $active_site.build(:contents)
data/lib/collection.rb CHANGED
@@ -21,16 +21,20 @@ class Collection
21
21
  c = self.new base, where, name
22
22
  c.attrs << attrs
23
23
  c.attrs.flatten!
24
- c.write_attribute_file
24
+ c.write_attribute_file
25
25
  c.load_attributes
26
- c.write_display_file
26
+ c.write_display_file rescue puts $!
27
+ c.write_feed_file
27
28
  copy base+'.templates/disco/link_list', c.home
28
- c.write_publish_file
29
+ c.write_paginate_file
29
30
  c.write '', c.home+'listing'
30
31
  c.mkdir c.home+'entries'
31
32
  c
32
33
  end
33
34
 
35
+ def display_file
36
+ home+'display'
37
+ end
34
38
  def self.collection_exists?(base, where, name)
35
39
  exists?(:folder, base) && exists?(:folder, where+'collections/'+name) && exists?(:file, where+"collections/#{name}/attributes")
36
40
  end
@@ -45,7 +49,8 @@ class Collection
45
49
  end
46
50
 
47
51
  def save_listing
48
- File.open(home+'listing', 'w') { |yf| YAML.dump(@listing, yf) }
52
+ File.open(home+'listing', 'w') { |yf| YAML.dump(@listing, yf) }
53
+ @listing
49
54
  end
50
55
 
51
56
  def sanitize_listing
@@ -53,34 +58,32 @@ class Collection
53
58
  @listing.each { |item|
54
59
  entry = load_entry(item)
55
60
  add = false
61
+ attrs = File.open( home+'attributes' ) { |yf| @attrs = YAML::load( yf )[name] }
56
62
  entry.each { |key, value|
57
- add = true if value and key != 'date' and key != :id
63
+ if attrs.include? key
64
+ add = true if value and not attrs[key]
65
+ end
58
66
  }
59
67
  tmp << item if add
60
68
  }
61
69
  @listing = tmp
70
+ save_listing
62
71
  end
63
72
 
64
73
  def write_attribute_file
65
- write_template base+'.templates/disco/attributes', attributes
74
+ write_template base+'.templates/disco/attributes', home+'attributes'
66
75
  end
67
76
  def write_display_file
68
- write_template base+'.templates/disco/display', blueprint
69
- end
70
- def write_publish_file
71
- write_template base+'.templates/disco/publish', publish
77
+ write_template base+'.templates/disco/display', home+'display'
72
78
  end
73
- def write_link_list_file
74
- write_template base+'.templates/disco/link_list', publish
75
- end
76
- def publish
77
- home+'publish'
79
+ def write_feed_file
80
+ write_template base+'.templates/disco/feed', home+'feed'
78
81
  end
79
- def blueprint
80
- home+'display'
82
+ def write_paginate_file
83
+ write_template base+'.templates/disco/paginate', home+'paginate'
81
84
  end
82
- def attributes
83
- home+'attributes'
85
+ def write_link_list_file
86
+ write_template base+'.templates/disco/link_list', home+'link_list'
84
87
  end
85
88
  def load_attributes
86
89
  File.open( home+'attributes' ) { |yf| @attrs = YAML::load( yf )[name] }
@@ -88,7 +91,7 @@ class Collection
88
91
  def load_listing
89
92
  File.open( home+'listing' ) { |yf| @listing = YAML::load( yf ) }
90
93
  @listing ||= []
91
- @listing = @listing.sort.reverse
94
+ @listing = @listing.sort{|x, y| x[:id] <=> y[:id]}.reverse
92
95
  end
93
96
  def load_entries
94
97
  listing.each {|entry| entries << load_entry(entry) }
@@ -96,17 +99,28 @@ class Collection
96
99
  end
97
100
  def load_entry(file)
98
101
  tmp = nil
99
- File.open( home+'entries/'+file ) {|yf| tmp = YAML::load( yf )[name].merge({:id => file})}
102
+ File.open( home+'entries/'+file[:id].to_s ) {|yf| tmp = YAML::load( yf )[name].merge(file)} rescue puts "loading entry -- #{$!}"
100
103
  tmp
101
104
  end
102
105
  def add_entry title=nil
103
106
  timestamp = Time.now.to_i.to_s
104
107
  title ||= timestamp
105
108
  load_listing
106
- listing.unshift timestamp
109
+ listing.unshift({:id => timestamp, :publish => true})
107
110
  write_template home+'attributes', home+'entries/'+timestamp
108
111
  return home+'entries/'+timestamp
109
112
  end
113
+ def publish
114
+ tmp = {}
115
+ listing.each {|e|
116
+ if e[:publish] and not e[:publish].kind_of? String
117
+ e[:publish] = Time.now.to_s
118
+ end
119
+ }
120
+ save_listing
121
+ end
122
+
123
+
110
124
  end
111
125
 
112
126
 
@@ -6,5 +6,6 @@ class String
6
6
  def as_ext; self[0,0]='.' unless self[0,1]=='.'|| self==''; self end
7
7
  def as_file_title; self.as_file.gsub /_/, ' ' end
8
8
  def filename_as_symbol; self.as_file.to_sym end
9
+ def as_http; self =~ /^http\:\/\// ? "http://#{self.gsub(/^http\:\/\//, '').as_folder}" : "http://#{self.as_folder}" end
9
10
  end
10
11
 
data/lib/page.rb CHANGED
@@ -18,6 +18,12 @@
18
18
  pages << self
19
19
  end
20
20
 
21
+ def included_in? page_name, all_levels=false
22
+ ans = (file_name == page_name.to_s or Page.find(page_name).subs.include? name)
23
+ subs.each { |sub| ans = Page.find(sub.as_file).included_in?(page_name, all_levels) } if all_levels and !ans
24
+ ans
25
+ end
26
+
21
27
  def file_name
22
28
  name.as_file
23
29
  end
@@ -40,16 +46,16 @@
40
46
  if collection
41
47
  Generator.class_eval { cattr_accessor :include_text }
42
48
  Generator.include_text = File.read home+"blueprint/#{page_location}_#{collection_name}_for_#{file_name}/#{collection.first}"
43
- write ::Rbml::Processor.new.instance_eval(File.read(home+'layout/structure/default.rbml')), in_site_location+'index.html'
49
+ write ::Rbml::Processor.new.instance_eval(File.read(home+'base/default.rbml')), in_site_location+'index.html'
44
50
  puts 'writing the index'
45
51
  collection.each { |col|
46
52
  Generator.include_text = File.read home+"blueprint/#{page_location}_#{collection_name}_for_#{file_name}/#{col}"
47
- write ::Rbml::Processor.new.instance_eval(File.read(home+'layout/structure/default.rbml')), in_site_location+col+'.html'
53
+ write ::Rbml::Processor.new.instance_eval(File.read(home+'base/default.rbml')), in_site_location+col+'.html'
48
54
  puts "writing the entry for #{col}"
49
55
  }
50
56
  Generator.class_eval { @include_text = nil }
51
57
  else
52
- write ::Rbml::Processor.new.instance_eval(File.read(home+'layout/structure/default.rbml')), in_site_location+'index.html'
58
+ write ::Rbml::Processor.new.instance_eval(File.read(home+'base/default.rbml')), in_site_location+'index.html'
53
59
  end
54
60
  puts "writing #{in_site_location}index.html"
55
61
  end
@@ -81,7 +87,7 @@
81
87
  end
82
88
 
83
89
  def load_contents
84
- File.open(home+ 'contents/'+page_location+name.as_file+'.copy') { |yf| @contents = YAML::load( yf ) }
90
+ File.open(home+ 'contents/'+page_location+name.as_file+'.copy') { |yf| @contents = YAML::load( yf ) } rescue puts $!
85
91
  end
86
92
 
87
93
  def extentions
@@ -96,14 +102,16 @@
96
102
  page_path = home+type.to_s+'/'+page_location
97
103
  mkdir page_path unless exists? :folder, page_path
98
104
  template_file = case type
99
- when :contents : {:main => home+'.templates/page.copy', :sub => home+'.templates/submenu.copy'}
105
+ when :contents : {:main => home+'layout/copy/page.copy', :sub => home+'layout/copy/submenu.copy'}
100
106
  when :blueprint : {:main => home+'layout/contents.erbml', :sub => home+'layout/submenu.erbml'}
101
107
  end
102
108
 
103
109
  if subs && subs.kind_of?(Array)
104
110
  unless exists?(:file, page_path+'submenu'+extentions[type])
105
- write_template template_file[:sub], page_path+'submenu'+extentions[type]
106
- puts "writing #{page_path}submenu#{extentions[type]}"
111
+ unless type == :contents
112
+ write_template template_file[:sub], page_path+'_submenu'+extentions[type]
113
+ puts "writing #{page_path}submenu#{extentions[type]}"
114
+ end
107
115
  else
108
116
  puts "#{page_path}submenu#{extentions[type]} already exists"
109
117
  end
data/lib/site.rb CHANGED
@@ -30,9 +30,6 @@ class Site
30
30
  site.setup_location 'project_info'
31
31
  site.write_template templates+'site.map', site.path+'site.map'
32
32
  site.write_template templates+'site.info', site.path+'site.info'
33
- site.setup_location '.templates'
34
- site.copy templates+'page.copy', site.path+'page.copy'
35
- site.copy templates+'submenu.copy', site.path+'submenu.copy'
36
33
  site.load_info
37
34
  site
38
35
  end
@@ -114,15 +111,23 @@ class Site
114
111
  end
115
112
 
116
113
  def build_header
117
- puts info.inspect
118
- write_template home+"layout/page_head.erbml", home+'layout/structure/page_head.rbml'
119
- write_template home+"layout/main_navigation.erbml", home+'layout/structure/main_navigation.rbml'
114
+ write_template home+"layout/page_head.erbml", home+'base/page_head.rbml'
115
+ write_template home+"layout/main_navigation.erbml", home+'base/main_navigation.rbml'
120
116
  end
121
117
 
122
118
  def build(type)
123
119
  setup_location(type.to_s)
124
120
  if type == :blueprint
125
121
  @main_links = []
122
+ copy home+'layout/structure', home+'base'
123
+ begin
124
+ copy home+'layout/stylesheets', home+'base/stylesheets'
125
+ puts 'copied stylesheets'
126
+ rescue
127
+ puts "There are no stylesheets associated with this layout"
128
+ end
129
+ copy home+'layout/resources', home+'base/resources' rescue puts "There are no resources associated with this layout"
130
+ copy home+'layout/scripts', home+'base/scripts' rescue puts "There are no scripts associated with this layout"
126
131
  load_main_links
127
132
  build_header
128
133
  end
@@ -131,13 +136,16 @@ puts info.inspect
131
136
 
132
137
  def generate
133
138
  mkdir site_loc unless exists? :folder, site_loc
134
- copy home+'layout/stylesheets', site_loc rescue puts $!
139
+ copy home+'base/stylesheets', site_loc rescue puts $!
140
+ copy home+'base/resources', site_loc rescue puts $!
141
+ copy home+'base/scripts', site_loc rescue puts $!
135
142
  pages.each do |page|
136
143
  page.stylesheets = []
137
144
  Generator.load(page)
138
145
  page.load_contents
139
- page.stylesheets << info['stylesheets']
140
- page.generate info['paginate'] ? info['paginate'][page.file_name] : nil
146
+ page.stylesheets << info['stylesheets'] if info['stylesheets']
147
+ page.generate info['paginate'] ? info['paginate'][page.file_name] : nil rescue puts "site generator -- #{$!}"
148
+ Generator.unload
141
149
  end
142
150
  end
143
151
  end
data/lib/static.rb CHANGED
@@ -27,7 +27,7 @@ $ENV = {}
27
27
  $ENV['EDITOR'] = 'vi'
28
28
 
29
29
  module Static
30
- VERSION = '0.0.1'
30
+ VERSION = '0.1.0'
31
31
  include FileBase
32
32
 
33
33
  def start_site name
@@ -62,6 +62,7 @@ module Static
62
62
  end
63
63
 
64
64
  def paginate page, publishing_to=nil
65
+ return nil unless page
65
66
  @page = Page.find(page)
66
67
  Generator.load(load_collection($active_site.info['paginate'][@page.file_name]))
67
68
  Generator.class_eval {
@@ -73,24 +74,60 @@ module Static
73
74
  @tmp_entries ||= self.act_on.entries.dup
74
75
  @tmp_entries
75
76
  end
77
+ def self.entry_bank= what
78
+ @tmp_entries = what
79
+ end
76
80
  }
77
81
  publishing_to ||= "#{@page.home}blueprint/#{@page.page_location}_#{Generator.act_on.name}_for_#{@page.file_name}/"
78
82
  mkdir publishing_to, :force
79
83
  @page_list = []
80
- while(Generator.entry_bank and Generator.entry_bank)
84
+ Generator.act_on.instance_eval { def level; @level end; def level=(what); @level=what end }
85
+ Generator.entry_bank
86
+ while(Generator.entry_bank)
81
87
  rbml = ::Rbml::Processor.new
82
88
  #Generator.contents = {:id => entry_bank.first[:id]}
83
- publish_file = File.read(Generator.act_on.home+'publish')
89
+ publish_file = File.read(Generator.act_on.home+'paginate')
84
90
  id = Generator.entry_bank.first[:id]
85
91
  puts "writing partial for #{id}"
86
- write rbml.render('xhtml', rbml.load_language('xhtml'), :partial => true) { eval(publish_file) }, publishing_to+id
92
+ hold = Generator.entry_bank.dup
93
+ begin
94
+ write rbml.render('xhtml', rbml.load_language('xhtml'), :partial => true) { eval(publish_file) }, publishing_to+id
95
+ rescue
96
+ Generator.entry_bank = hold
97
+ write rbml.render('xhtml', rbml.load_language('xhtml'), :format => false, :partial => true) { eval(publish_file) }, publishing_to+id rescue puts $!
98
+ end
87
99
  @page_list << id
100
+ File.open(publishing_to+'page.list', 'w') { |yf| YAML.dump(@page_list, yf) }
101
+ 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 -- #{$!}"
102
+ puts "writing link list _#{@page.file_name}_#{Generator.act_on.name}_links"
88
103
  end
89
- File.open(publishing_to+'page.list', 'w') { |yf| YAML.dump(@page_list, yf) }
90
- write_template Generator.act_on.home+'link_list', "#{@page.home}blueprint/#{@page.page_location}/#{@page.file_name}_#{Generator.act_on.name}_links.rbml"
91
- puts "writing link list #{@page.file_name}_#{Generator.act_on.name}_links"
92
104
  @page_list = nil
105
+ Generator.act_on.instance_eval { @level = nil; undef :level; undef :level=}
93
106
  Generator.unload
94
107
  end
108
+
109
+ def publish_feeds blank = nil
110
+ $active_site.info['feeds'].each do |name|
111
+ col = load_collection(name) #Generator.load(name).inspect
112
+ col.publish
113
+ Generator.load col
114
+ Generator.act_on.instance_eval {
115
+ def level; @level end; def level=(what); @level=what end
116
+ def last_built
117
+ date = ''
118
+ listing.each {|item| date = item[:publish] if item[:publish] and not date}
119
+ date
120
+ end
121
+ }
122
+ write ::Rbml::Processor.run(col.home+'feed'), $active_site.site_loc.as_folder+name+'.rss' rescue puts $!
123
+ puts $active_site.site_loc.as_folder+name+'.rss'
124
+ Generator.act_on.instance_eval { @level = nil; undef :level; undef :level=}
125
+ Generator.unload
126
+ end if $active_site.info['feeds']
127
+ unless blank
128
+ puts "rsync -avz #{$active_site.site_loc}/* #{$active_site.info['user_name']}@#{$active_site.info['server']['address']}:#{$active_site.info['server']['directory']}"
129
+ system "rsync -avz #{$active_site.site_loc}/* #{$active_site.info['user_name']}@#{$active_site.info['server']['address']}:#{$active_site.info['server']['directory']}"
130
+ end
131
+ end
95
132
  end
96
133
 
data/lib/xhtml.rb CHANGED
@@ -10,10 +10,13 @@ module Inclusion
10
10
  end
11
11
  tmp+'.rbml'
12
12
  end
13
+ def partial from, what
14
+ get from, "_#{what}"
15
+ end
13
16
  def get from, what
14
17
  case from
15
18
  when :base
16
- run_file Generator.act_on.home+"layout/structure/#{what}.rbml"
19
+ run_file Generator.act_on.home+"base/#{what}.rbml"
17
20
  when :page
18
21
  run_file Generator.act_on.home+"blueprint/#{Generator.page_location}#{find_file_name(Generator.act_on, what)}"
19
22
  else
@@ -21,21 +24,67 @@ module Inclusion
21
24
  end
22
25
  end
23
26
 
24
- def display how_many, collection, entry_bank=nil
27
+ def display how_many, collection, entry_bank=nil, &blk
25
28
  col = load_collection(collection.to_s)
29
+ level = Generator.level
26
30
  how_many = col.entries.size if how_many == :all
27
31
  entry_bank ||= col.entries.dup
28
32
  Generator.load col
33
+ Generator.act_on.instance_eval { def level; @level end; def level=(what); @level=what end }
34
+ Generator.act_on.level = level
29
35
  how_many.times {
30
36
  break if entry_bank.empty?
31
- Generator.contents = entry_bank.shift
32
- run_file Generator.act_on.blueprint
37
+ Generator.act_on.contents = entry_bank.shift
38
+ block_given? ? run_block(&blk) : run_file(Generator.act_on.display_file) rescue puts $!
33
39
  }
40
+ Generator.act_on.instance_eval { @level = nil; undef :level; undef :level=}
34
41
  Generator.unload
35
42
  end
36
43
 
37
44
  def include_partial
38
45
  i Generator.include_text
46
+ Generator.include_text
47
+ end
48
+ end
49
+
50
+ module Rbml
51
+ module Language
52
+ module Doc
53
+ module Rss
54
+ def address_for what, options={}
55
+ where = options[:page] ? options[:page]+'.html' : ''
56
+ say = $active_site.info['server']['link']
57
+ $active_site.pages.each { |page|
58
+ if page.name.as_file == what.to_s
59
+ text ||= page.name
60
+ say += "#{page.in_site_link}#{where}"
61
+ end
62
+ }
63
+ say
64
+ end
65
+
66
+ def process_cdata what
67
+ what = what.to_s
68
+ exp = /\<\[.+?\]\>/
69
+ while(what =~ exp) do
70
+ what.sub!(exp) { |match|
71
+ eval(match.sub(/^\<\[/,'').sub(/\]\>$/, ''))
72
+ }
73
+ end
74
+ "<![CDATA[#{what}]]>"
75
+ end
76
+ def link_to where, text='', options={}
77
+ say=''
78
+ $active_site.pages.each { |page|
79
+ if page.name.as_file == where.to_s
80
+ text ||= page.name
81
+ say = "\"#{text}\":#{$active_site.info['server']['link']}#{page.in_site_link}"
82
+ end
83
+ }
84
+ say
85
+ end
86
+ end
87
+ end
39
88
  end
40
89
  end
41
90
 
@@ -46,20 +95,43 @@ module Rbml
46
95
  def put_title
47
96
  title(Generator.contents['title'])
48
97
  end
98
+ def use_stylesheets *sheets
99
+ tmp = []
100
+ sheets.each { |s| tmp << s.to_s }
101
+ stylesheets Generator.level+'stylesheets/', tmp
102
+ end
103
+ alias :use_stylesheet :use_stylesheets
104
+
105
+ def image which, alt=nil
106
+ i "< image src='#{place}/#{which.to_s}' alt='#{alt||which.to_s}' />"
107
+ "<image src='#{Generator.level}resources/#{which.to_s}' alt='#{alt||which.to_s}' />"
108
+ end
109
+ def resource_address which
110
+ i "#{Generator.level}resources/#{which.to_s}"
111
+ "#{Generator.level}resources/#{which.to_s}"
112
+ end
113
+ def script_address which
114
+ i "#{Generator.level}scripts/#{which.to_s}"
115
+ "#{Generator.level}scripts/#{which.to_s}"
116
+ end
117
+
49
118
  def put_stylesheets
50
119
  styles = []
51
- Generator.stylesheets.each{|style| styles << style}
52
- stylesheets Generator.level+'stylesheets/', styles
120
+ Generator.stylesheets.each{|style| styles << style if style}
121
+ styles.empty? ? '' : stylesheets(Generator.level+'stylesheets/', styles)
53
122
  end
54
- def breadcrumbs
123
+ def breadcrumbs(join_by=nil)
124
+ join_by ||= " >> "
55
125
  links = []
56
126
  Generator.breadcrumbs.each {|b| links << (Generator.act_on.name.as_file==b.to_s ? Generator.act_on.name : link_to(b)) }
57
- i links.join(" >> ")
58
- links.join(" >> ")
127
+ links.join(join_by)
59
128
  end
60
129
  def main_link_for what
61
130
  link_to what
62
131
  end
132
+ def feed name, title=nil
133
+ "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"#{title||name.to_s}\" href=\"#{Generator.act_on.level}#{name.to_s}.rss\" />"
134
+ end
63
135
  def link_to what, text=nil, options={}
64
136
  where = options[:page] ? options[:page]+'.html' : ''
65
137
  say=''
@@ -69,16 +141,22 @@ module Rbml
69
141
  say << "<a href='#{Generator.level}#{page.in_site_link}#{where}'>#{text}</a>"
70
142
  end
71
143
  }
72
- i say
73
144
  say
74
145
  end
75
- def put what
76
- stuff = Generator.contents[what.to_s] || ''
77
- t parse_context(stuff)
146
+ def put what, options={}
147
+ t find_contents(what, options)
148
+ end
149
+ def plain_put what, options={}
150
+ find_contents(what, options)
78
151
  end
79
- def plain_put what
80
- stuff = Generator.contents[what.to_s] || ''
81
- i parse_context(stuff)
152
+ def truncate what, how_many, options={}
153
+ options[:trail] ||= '...'
154
+ contents = find_contents(what)
155
+ contents = contents.size > how_many ? contents[0, how_many] + options[:trail] : contents
156
+ options[:textile] ? t(contents) : i(contents)
157
+ end
158
+ def find_contents what, options={}
159
+ parse_context(Generator.contents[what.to_s] || '')
82
160
  end
83
161
 
84
162
  def parse_context(what)
@@ -89,6 +167,12 @@ module Rbml
89
167
  eval(match.sub(/^\<\[/,'').sub(/\]\>$/, ''))
90
168
  }
91
169
  end
170
+ exp = /\<!\[.+?\]\>/
171
+ while(what =~ exp) do
172
+ what.sub!(exp) { |match|
173
+ match.sub!(/^\<!\[/,'<[')
174
+ }
175
+ end
92
176
  what
93
177
  end
94
178
 
@@ -1,4 +1,6 @@
1
+ # describe the base display for <%=name%> here.
1
2
  div(:class => '<%=name%>'){
2
- <% attrs.each do |a, v| %> put :<%= a %>
3
+ <% if attrs %>
4
+ <% attrs.each { |a, v| %> put :<%= a %> <% } %>
3
5
  <%end%>
4
6
  }
@@ -0,0 +1,21 @@
1
+ rss{
2
+ title <%=name.inspect%>
3
+ link $active_site.info['server']['link']
4
+ # description ''
5
+ language 'en-us'
6
+ pubDate Time.now.to_s
7
+ lastBuildDate Generator.last_built
8
+ docs 'http://blogs.law.harvard.edu/tech/rss'
9
+ generator 'static+rbml'
10
+ # managingEditor ''
11
+ # webMaster ''
12
+ display(5, :<%=name.as_file%>){
13
+ item {
14
+ title Generator.contents['title']
15
+ link Generator.contents['link'] if Generator.contents['link']
16
+ description { process_cdata(Generator.contents['entry']) }
17
+ pubDate Generator.contents[:publish]
18
+ guid { address_for(:<%=name.as_file%>, :page => Generator.contents[:id]) }
19
+ }
20
+ }
21
+ }
@@ -1,5 +1,5 @@
1
1
  ul{
2
- <% @page_list.each { |entry| %>
2
+ <% Generator.listing.each { |entry| %>
3
3
  <% contents = Generator.load_entry entry %>
4
4
  li { link_to :<%=@page.file_name%>, <%= contents['title'].inspect || entry.inspect %>, :page => <%= entry.inspect %> }
5
5
  <% } %>
File without changes
@@ -1,8 +1,8 @@
1
1
 
2
+ h3{plain_put :content_head}
2
3
 
3
- h3 'Main Content for <%= name %>'
4
- <%= 'breadcrumbs' if breadcrumbs.size > 1 %>
5
4
  <% if has_subs? %>
6
- div(:id => 'submenu'){ get :<%=menu_title.as_file%>, :submenu }
5
+ div(:id => 'submenu'){ partial :<%=menu_title.as_file%>, :submenu }
7
6
  <% end %>
7
+ <%= 'breadcrumbs' if breadcrumbs.size > 1 %>
8
8
  put :contents
@@ -0,0 +1,4 @@
1
+ title: <%=name%>
2
+ content_head: <%=name%>
3
+ contents: |
4
+ here are some *contents* for the time being! <[link_to :<%=name.as_file%>]>
@@ -1,6 +1,7 @@
1
1
  xhtml :doctype => {:type=>:xhtml, :version=>"1.0", :strict=>false} do
2
2
  head do
3
3
  put_title
4
+ use_stylesheet :default
4
5
  put_stylesheets
5
6
  charset 'utf-8'
6
7
  end
@@ -1,18 +1,23 @@
1
- body {
2
- background-color: #000;
1
+ body{
2
+ font-size: 62.5%;
3
+ font-family:"Lucida Grande", Arial, Verdana, sans-serif;
4
+ margin:0;
5
+ background:#f0ecd7 url(../resources/bg.jpg) top center repeat-y;
3
6
  }
4
7
 
5
8
  #container {
6
- width: 800px;
7
- margin-bottom: 10px;
8
- margin-left: auto;
9
- margin-right: auto;
10
- background-color: #fff;
9
+ font-size:1.1em;
10
+ width: 800px;
11
+ margin-bottom: 10px;
12
+ margin: auto;
13
+ background: #fff;
11
14
  }
12
15
 
13
16
  #header {
14
- background-color:#333;
17
+ height:75px;
18
+ background:#456;
15
19
  color: #eee;
20
+ border-bottom:1px solid #ccc;
16
21
  }
17
22
  #header h1 {
18
23
  font: 38px 'verdana', sans-serif;
@@ -20,57 +25,117 @@ background-color: #fff;
20
25
  margin-left:20px;
21
26
  padding:0px;
22
27
  padding-top:10px;
28
+
23
29
  }
24
30
 
25
- #header ul {
31
+ #news_header {
32
+ font-size: 1.6em;
33
+ padding-right: 10px;
34
+ font-family:"Lucida Grande", Arial, Verdana, sans-serif;
35
+ text-align: right;
36
+ color: #eee;
37
+ background:#456;
38
+ }
39
+ .news {
40
+ float: left;
41
+ padding-right: 10px;
42
+ padding-left: 10px;
43
+ width:350px;
44
+ border:1px solid #666;
45
+ margin-top:0px;
46
+ }
47
+
48
+ .clear { clear:both; }
49
+ .right { float:right; }
50
+ .left { float:left; }
51
+ .install {
52
+ width:80%;
26
53
  margin:auto;
27
- margin:0px;
28
- padding:0px;
54
+ background:#eee;
55
+ border-bottom:1px solid #333;
56
+ margin-bottom:10px;
57
+ }
58
+ .install p {
59
+ margin-left: 20px;
60
+ padding-right:20px;
61
+ }
62
+ .install pre {
63
+ margin-left: 20px;
64
+ }
65
+ .install h4 {
66
+ font-family:"Lucida Grande", Arial, Verdana, sans-serif;
67
+ margin-top: 5px;
68
+ padding-right: 20px;
69
+ background:#456;
70
+ color:#eee;
29
71
  text-align:right;
30
- margin-right:20px;
31
72
  }
32
73
 
33
- #header ul li {
34
- margin-top:35px;
35
- margin-right:20px;
74
+ .news .title {
75
+ font-size: 1.5em;
76
+ font-family:"Lucida Grande", Arial, Verdana, sans-serif;
77
+ border-bottom:1px solid #333;
78
+ margin-top:5px;
79
+ background-color: #eee;
80
+ }
81
+
82
+ .news .date {
83
+ font-size: .6em;
84
+ font-family:"Lucida Grande", Arial, Verdana, sans-serif;
85
+ margin-top: 0px;
86
+ text-align: right;
87
+ }
88
+
89
+ dt {
90
+ font-family: monospace;
36
91
  }
37
92
 
93
+ dl {
94
+ margin-left: 50px;
95
+ }
96
+ dd {
97
+ margin-bottom: 10px;
98
+ }
99
+
100
+
101
+ #main_navigation{float:right; margin:1px 0px 0px 0px;}
102
+
38
103
  #main_navigation li{
39
- display:inline;
104
+ float:left;
40
105
  }
41
106
 
42
107
  a {
43
- color:#e60066;
108
+ color:#456;
44
109
  }
45
110
 
46
111
  a:hover {
47
- background-color:#333;
48
- color:#fff;
112
+ color:#686;
49
113
  }
50
114
  .main_link a {
51
- color:#333;
52
- background-color:#fff;
53
- padding:5px;
54
- margin-bottom:5px;
115
+ color:#333;
116
+ background:#fff;
117
+ padding:5px;
118
+ border: solid 1px #ccc;
119
+ border-bottom:none;
120
+ text-decoration:none;
55
121
  }
56
122
 
57
123
  .main_link a:hover {
58
- color:#e60066;
59
- background-color:#333;
60
- border: solid 1px #fff;
124
+ padding:7px 7px 5px 7px;
125
+ font-size:1.15em;
61
126
  }
62
127
 
63
128
  #content {
64
129
  padding:10px;
65
- border-top: solid 3px #000;
66
- border-bottom: solid 3px #000;
67
- background-color: #ffffff;}
130
+ font-family:Baskerville, Times, Times New Roman, serif ;
131
+ font-size:1.5em;
132
+ background: #fff;}
68
133
 
69
134
  #content h3 {
70
135
  font: 22px 'verdana', sans-serif;
71
136
  margin: 0px;
72
137
  padding: 0px;
73
- border-bottom: solid 1px #333;
138
+ border-bottom: solid 2px #456;
74
139
  width:570px;
75
140
  }
76
141
 
@@ -79,28 +144,37 @@ text-align:justify;
79
144
  }
80
145
 
81
146
  #submenu {
82
- float: right;
83
- width: 200px;
84
- margin: 0px;
85
- padding: 0px;
86
- border: solid 1px #333;
87
- margin-left:10px;
147
+ float: right;
148
+ width: 200px;
149
+ margin: -3px 0px 0px 10px;
150
+ padding: 0;
151
+ border: solid 2px #456;
152
+ font-family:"Lucida Grande", Arial, Verdana, sans-serif;
88
153
  }
89
154
 
90
- li {
91
- list-style:none
155
+ #submenu a{
156
+ margin-left: 20px;
92
157
  }
158
+ #submenu ul{
159
+ margin-left: 10px;
160
+ padding:0px 7px 0px 7px;}
93
161
 
94
- #footer ul{
95
- text-align:center;
162
+ ul li {
163
+ list-style:none;
96
164
  }
97
165
 
166
+
98
167
  #footer {
99
168
  margin:auto;
100
- color:#fff;
169
+ color:#000;
170
+ background-color:#999;
101
171
  font: 10px 'verdana', sans-serif;
102
172
  padding-bottom:5px;
103
- background-color: #333;
104
173
  margin-top:0px;
174
+ border-top:1px solid #666;
175
+ border-bottom:1px solid #333;
105
176
  padding-top:5px;
106
177
  }
178
+
179
+ #footer .copyright{
180
+ text-align:center;}
data/templates/site.info CHANGED
@@ -1,5 +1,3 @@
1
1
  started_on: <%= Date.today %>
2
2
  title: "<%=name%> - [[current_page]]"
3
3
  working_name: "<%=name%>"
4
- stylesheets:
5
- - default
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: static
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.1
7
- date: 2007-06-15 00:00:00 -04:00
6
+ version: 0.1.0
7
+ date: 2007-07-20 00:00:00 -04:00
8
8
  summary: The author was too lazy to write a summary
9
9
  require_paths:
10
10
  - lib
@@ -50,7 +50,8 @@ files:
50
50
  - templates/submenu.copy
51
51
  - templates/disco/attributes
52
52
  - templates/disco/display
53
- - templates/disco/publish
53
+ - templates/disco/paginate
54
+ - templates/disco/feed
54
55
  - templates/disco/link_list
55
56
  - templates/layouts/default/contents.erbml
56
57
  - templates/layouts/default/main_navigation.erbml
@@ -59,6 +60,7 @@ files:
59
60
  - templates/layouts/default/structure/default.rbml
60
61
  - templates/layouts/default/structure/footer.rbml
61
62
  - templates/layouts/default/stylesheets/default.css
63
+ - templates/layouts/default/copy/page.copy
62
64
  test_files: []
63
65
 
64
66
  rdoc_options: