static 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt ADDED
@@ -0,0 +1,5 @@
1
+ == 1.0.0 / 2007-04-17
2
+
3
+ * 1 major enhancement
4
+ * Birthday!
5
+
data/Manifest.txt ADDED
@@ -0,0 +1,32 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ bin/static
6
+ bin/cli.rbml
7
+ lib/static.rb
8
+ lib/collection.rb
9
+ lib/filebase.rb
10
+ lib/page.rb
11
+ lib/site.rb
12
+ lib/static.rb
13
+ lib/xhtml.rb
14
+ lib/generator.rb
15
+ lib/extentions/class.rb
16
+ lib/extentions/string.rb
17
+ templates/page.copy
18
+ templates/site.map
19
+ templates/site.info
20
+ templates/submenu.copy
21
+ templates/disco/attributes
22
+ templates/disco/display
23
+ templates/disco/publish
24
+ templates/disco/link_list
25
+ templates/layouts/default/contents.erbml
26
+ templates/layouts/default/main_navigation.erbml
27
+ templates/layouts/default/page_head.erbml
28
+ templates/layouts/default/submenu.erbml
29
+ templates/layouts/default/structure/default.rbml
30
+ templates/layouts/default/structure/footer.rbml
31
+ templates/layouts/default/stylesheets/default.css
32
+
data/README.txt ADDED
@@ -0,0 +1,254 @@
1
+ static
2
+ by evan short
3
+
4
+ == DESCRIPTION:
5
+
6
+ static is a command line environment for creating static websites.
7
+ it uses a yaml site map to produce a blueprint with decoupled copy
8
+ and structure. uses rbml for html processing. static incorporates
9
+ arbitrary collections that can be displayed both within a page and
10
+ paginated over a page. this allows such features as news, faqs,
11
+ blogs and other galleries.
12
+
13
+ == FEATURES:
14
+ - command line interface
15
+ - multiple site management
16
+ - yaml site map
17
+ - decoupled copy and structure
18
+ - flexible, sectioned copy
19
+ - html in block-syntax
20
+ - collections
21
+ - inner-page, such as news on a home page
22
+ - paginated, a blog, for instance
23
+ - plain ol' css for style
24
+
25
+ == PROBLEMS:
26
+
27
+ - cli needs some work
28
+ - prompt context
29
+ - tab completion
30
+ - termios integration (or otherwise implemented command history)
31
+ - error messaging
32
+ - documentation
33
+ - how layouts work
34
+ - 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
+ - there are no specs
38
+ - ready for a re-factor
39
+
40
+ == SYNOPSIS:
41
+
42
+ 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 ~/.
44
+ in this folder your layouts and projects will be kept, along with a
45
+ few template files in <tt>.templates</tt> that will be used when
46
+ creating a site.
47
+
48
+ === site generation
49
+
50
+ you will see a prompt: <tt>-></tt>
51
+
52
+ -> start sample site
53
+ starting a site map for sample
54
+
55
+ at this point the footprint of your site (named sample in this example)
56
+ has been created. a sitemap is generated from the site.map template
57
+ in the static home (~/static). initially this is populated with an
58
+ example map, but can be re-formatted or emptied if you choose.
59
+
60
+ -> edit site.map
61
+
62
+ this will open the previously mentioned site map in vi. there is a
63
+ variable to change editors but, currently, no place to actually do
64
+ it. sue me. i'll get to it soon.
65
+
66
+ after the site map has been exited the pages are loaded into memory
67
+ and you can then begin to build your site.
68
+
69
+ -> build
70
+
71
+ or
72
+
73
+ -> build copy
74
+
75
+ will generate the .copy yaml files that will hold the contents of each
76
+ page in your site map. you may then run
77
+
78
+ -> edit copy
79
+
80
+ to edit the contents of those pages. more desireably, perhaps, you may
81
+ zip this folder up and send it off to someone more suited to edit copy.
82
+
83
+ next you must choose a layout.
84
+
85
+ -> layout
86
+
87
+ will give you a choice of the possible layouts. by default there is only
88
+ one layout available. you may copy the default layout in the static home
89
+ to create new layouts. there are plans to incorporate some of this into
90
+ the cli. not yet, however.
91
+
92
+ because there is only one layout available by default, running +layout+
93
+ will choose it for you. if there were more than one you could run +layout+
94
+ with a regex for the layout you would like to choose (or not) and then
95
+ make a choice from the resulting list. choices in lists may be made by
96
+ regex or number selection. no word on what happens if there are numbers
97
+ in your possible selections.
98
+
99
+ as an example, because the word 'regex' can be frightening to some, i might
100
+ use <tt>layout def</tt> to find the default layout in a long list of selections.
101
+
102
+ once a layout is chosen it is possible to make edits to it before building
103
+ the basic structure of the site, called the blueprint. you may run
104
+
105
+ -> edit layout
106
+
107
+ to make changes to the layout you have chosen.
108
+
109
+ once the layout is satisfactory, running
110
+
111
+ -> build blueprint
112
+
113
+ will put the blueprint folder in place.
114
+
115
+ -> edit blueprints
116
+
117
+ will take you there to edit.
118
+
119
+ at this point you may generate your site by running
120
+
121
+ -> generate
122
+
123
+ you may edit your site and generate as many times as you like.
124
+ by default (not easily changable at the moment) your site will be
125
+ generated to ~/Sites/static/name_of_site.
126
+
127
+ use
128
+
129
+ -> load site
130
+
131
+ (which uses the choice module) to load a site or make a different
132
+ site active. you may simply use +load+ if there is not already an
133
+ active site.
134
+
135
+ == collection managment
136
+
137
+ once a site has been started that site will be active. once there is
138
+ an active site you may begin dealing with collections. to start a
139
+ collection
140
+
141
+ -> start faq collection with question answer
142
+
143
+ this will start a collection named faq with the attributes question and
144
+ answer.
145
+
146
+ because there is already an active site, the +collection+ key
147
+ is assumed and therefore sugar. +with+ is purely sugar.
148
+
149
+ the faq collection is now active (as it was just started and no other
150
+ collection has been loaded). you may run
151
+
152
+ -> edit attributes
153
+
154
+ to edit the yaml file describing the attributes
155
+
156
+ -> edit display
157
+
158
+ to edit the default way a member of the collection is displayed
159
+
160
+ and
161
+
162
+ -> add
163
+
164
+ to add an item to the collection. it is worth noting that the attribute
165
+ files are processed by erb before they make it to your editor. so in the
166
+ event you had a +date+ attribute in a collection, using +edit attributes+
167
+ to make <tt>date: <%= Date.today.to_s.inspect %></tt> will start each
168
+ added item with today's date ready for yaml.
169
+
170
+ to show a collection within a page add a line like
171
+
172
+ display 5, :faq
173
+
174
+ on the blueprint of the desired page. display also responds to :all in place
175
+ of the number.
176
+
177
+ to paginate a collection over a particular page you must assign the
178
+ collection to the page.
179
+
180
+ -> assign
181
+
182
+ will ask you first which collection you would like to choose and then which
183
+ page. because each page is only allowed to be paginated once your choices
184
+ will be limited to those that have not already been paginated. you may use
185
+ -c or --collection to regex for a desired collection.
186
+ likewise with -p and --page.
187
+
188
+ you may also run +assign paginate+ with the same possible flags to paginate
189
+ the collection automatically after the association.
190
+
191
+ after associating the collection and the page you may use
192
+
193
+ -> paginate
194
+
195
+ and then
196
+
197
+ -> generate
198
+
199
+ to update the pages. in the future there should probably be a more direct
200
+ way to generate over only paginated pages.
201
+
202
+ in order to see the paginated items on the desired page simply add the line
203
+
204
+ include_partial
205
+
206
+ where you would like the paginated section of your collection to be included.
207
+ to use the link list generated include the line
208
+
209
+ get :page, :collection_name => :links
210
+
211
+ <tt>:page</tt> is short for 'this page that we are in'. if you would like to
212
+ be moroe explicit (or use the list elsewhere) simply put in the file name of
213
+ the page (which would be the page name you gave it in the site map formatted
214
+ as a lower-case symbol) as such:
215
+
216
+ get :page_name, :collection_name => :links
217
+
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
220
+
221
+ evan.short @ pleasedontspam. gmail.please
222
+
223
+ == REQUIREMENTS:
224
+
225
+ rbml v. 0.0.5.9.4.1
226
+
227
+ == INSTALL:
228
+
229
+ sudo gem install static
230
+
231
+ == LICENSE:
232
+
233
+ (The MIT License)
234
+
235
+ Copyright (c) 2007 Evan Short
236
+
237
+ Permission is hereby granted, free of charge, to any person obtaining
238
+ a copy of this software and associated documentation files (the
239
+ 'Software'), to deal in the Software without restriction, including
240
+ without limitation the rights to use, copy, modify, merge, publish,
241
+ distribute, sublicense, and/or sell copies of the Software, and to
242
+ permit persons to whom the Software is furnished to do so, subject to
243
+ the following conditions:
244
+
245
+ The above copyright notice and this permission notice shall be
246
+ included in all copies or substantial portions of the Software.
247
+
248
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
249
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
250
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
251
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
252
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
253
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
254
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/static.rb'
6
+
7
+ Hoe.new('static', Static::VERSION) do |p|
8
+ p.rubyforge_name = 'static'
9
+ # p.summary = 'FIX'
10
+ # p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
11
+ # p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
12
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
13
+ end
14
+
15
+ # vim: syntax=Ruby
data/bin/cli.rbml ADDED
@@ -0,0 +1,245 @@
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 :start do |args|
11
+ key(:site){ @active = :site }
12
+ key(:collection){ @active = :collection }
13
+ key(:with)
14
+ flag(:help => 'h'){ puts "helpdocs for 'start' go here" }
15
+
16
+ process(args)
17
+ name = (remaining_argument == '' ? '.' : remaining_argument)
18
+ @active = ($active_site ? :collection : :site) unless @active
19
+
20
+ case @active
21
+ when :site
22
+ $active_site = start_site(name)
23
+ if $active_site
24
+ puts "starting a site map for #{$active_site.name}"
25
+ else
26
+ puts "looks like there is already a site called #{name}"
27
+ end
28
+ when :collection
29
+ if $active_site
30
+ name = remaining_arguments.shift
31
+ $active_collection = start_collection(name, remaining_arguments)
32
+ if $active_collection
33
+ puts "#{name} collection is active"
34
+ else
35
+ puts "looks like there is already a collection called #{name}"
36
+ end
37
+ else
38
+ puts 'gotta have a site to make a collection'
39
+ end
40
+ end
41
+ end
42
+
43
+ set :assign do |args|
44
+ flag(:page => 'p'){ |name|
45
+ @page = choice('please choose a page:', @possible_pages, name.downcase)
46
+ }
47
+ flag(:collection => 'c'){ |name|
48
+ @collection = load_collection(choice('please choose a collection:', items_under($active_site.home+'collections')[:folders], name.downcase))
49
+ }
50
+ key(:paginate){@paginate = true}
51
+
52
+ if $active_site
53
+ ready = exists? :folder, $active_site.home+'blueprint'
54
+ if ready
55
+ @possible_pages = []
56
+ $active_site.pages.each{ |page| @possible_pages << page unless $active_site.info['paginate'] && $active_site.info['paginate'].keys.include?(page.file_name) }
57
+ process(args)
58
+
59
+ @collection ||= load_collection(choice('please choose a collection:', items_under($active_site.home+'collections')[:folders]))
60
+ puts "\n - - - \n" unless @page
61
+ @page ||= choice('please choose a page:', @possible_pages)
62
+ assign_pagination @collection.file_name, @page.file_name
63
+ paginate @page.file_name if @paginate
64
+ else
65
+ puts 'please build a blueprint paginating collections'
66
+ end
67
+ else
68
+ ready ? message : 'please choose a site'
69
+ end
70
+ end
71
+
72
+ set :paginate do |name|
73
+ @page = choice('which page did you mean?', $active_site.info['paginate'].keys, name) if name
74
+ if exists? :folder, $active_site.home+'blueprint'
75
+ if @page
76
+ paginate @page
77
+ else
78
+ $active_site.info['paginate'].each { |page, collection| paginate page }
79
+ end
80
+ else
81
+ puts 'please generate your blueprint before paginating'
82
+ end
83
+ end
84
+
85
+ set :layout do |args|
86
+ key(:choose) { @active = :choose }
87
+ key(:save) { @active = :choose }
88
+ flag(:force => 'f'){ @force = true }
89
+ process args
90
+ name = (remaining_argument == '' ? '.' : remaining_argument)
91
+ @active = :choose unless @active
92
+ case @active
93
+ when :choose
94
+ if $active_site
95
+ if set_layout choice('please choose a layout:', items_under($ENV['LAYOUT_HOME'])[:folders], name), @force
96
+ puts "#{$active_site.info['layout']['name']} is now being used" else puts 'no new layout was chosen'
97
+ end
98
+ else
99
+ puts 'there is no active site right now.'
100
+ end
101
+ end
102
+ end
103
+
104
+ set :edit do |args|
105
+ key(:site)
106
+ key(:attributes){
107
+ @collection = $active_collection.name unless @collection
108
+ @edit << :attributes
109
+ }
110
+ key(:display){
111
+ @collection = $active_collection.name unless @collection
112
+ @edit << :display
113
+ }
114
+ key(:all){
115
+ @collection = $active_collection.name unless @collection
116
+ @edit = [:attributes, :display]
117
+ }
118
+ flag(:collection => 'c'){ |name| @collection = name }
119
+
120
+ @edit = []
121
+ process args
122
+ file = remaining_argument
123
+ file = 'contents' if file == 'copy'
124
+
125
+ if $active_site
126
+ case
127
+ when @collection
128
+ @edit.each { |item|
129
+ puts "opening #{@collection}'s attributes"
130
+ edit("#{$active_site.home}collections/#{@collection}/#{item.to_s}")
131
+ }
132
+ when exists?(:file, "#{$active_site.home}project_info/#{file}") then
133
+ puts "opening #{$active_site.name}'s #{file}"
134
+ edit("#{$active_site.home}project_info/#{file}")
135
+ $active_site.load_info(file)
136
+ $active_site.load_pages if file == 'site.map'
137
+ when exists?(:any, $active_site.home+file) : edit($active_site.home+file)
138
+ else
139
+ puts "no file found: #{$active_site.home}"
140
+ end
141
+ else
142
+ puts 'no active site'
143
+ end
144
+ end
145
+
146
+ set :load do |args|
147
+ key(:site){ @active = :site }
148
+ key(:collection){ @active = :collection }
149
+
150
+ flag(:help => 'h'){ puts "helpdocs for 'load' go here" }
151
+
152
+ process(args)
153
+ name = (remaining_argument == '' ? '.' : remaining_argument)
154
+ @active = $active_site ? :collection : :site unless @active
155
+
156
+ case @active
157
+ when :site then
158
+ $active_site = load_site(name)
159
+ if $active_site
160
+ puts "#{$active_site.name} site is active"
161
+ else
162
+ $active_site = load_site(choice('available sites', items_under($ENV['SITE_BANK'])[:folders], name))
163
+ puts 'sorry bub, nuthin there.' unless $active_site
164
+ end
165
+ when :collection then
166
+ $active_collection = nil
167
+ if $active_site
168
+ $active_collection = load_collection(name)
169
+ if $active_collection
170
+ puts("#{$active_collection.name} collection is active")
171
+ else
172
+ $active_collection = load_collection(choice('available collections', items_under($active_site.home+'collections')[:folders], name))
173
+ unless $active_collection
174
+ puts 'can\'t find a collection like that, baby'
175
+ else
176
+ puts("#{$active_collection.name} collection is active")
177
+ end
178
+ end
179
+ else
180
+ puts 'there must be an active site before starting a collection'
181
+ end
182
+ end
183
+ end
184
+
185
+ set :generate do
186
+ ready = exists? :folder, $active_site.home+'layout'
187
+ message = 'please choose a layout before generating html' unless ready
188
+ if ready
189
+ ready = exists? :folder, $active_site.home+'blueprint'
190
+ message = 'please build a blueprint before generating html' unless ready
191
+ if ready
192
+ ready = exists? :folder, $active_site.home+'contents'
193
+ message = 'please build the site content before generating html' unless ready
194
+ end
195
+ end
196
+ if $active_site
197
+ if ready
198
+ destroy $active_site.site_loc
199
+ $active_site.generate
200
+ else
201
+ puts(message)
202
+ end
203
+ else
204
+ puts 'need a site before you can generate one'
205
+ end
206
+ end
207
+
208
+ set :add do |args|
209
+ edit $active_collection.add_entry
210
+ $active_collection.sanitize_listing
211
+ $active_collection.save_listing
212
+ end
213
+
214
+ set :build do |args|
215
+ key(:copy){ @active = :contents }
216
+ key(:contents){ @active = :contents }
217
+ key(:blueprint){ @active = :blueprint }
218
+ key(:all){ @active = :all }
219
+ flag(:force => 'f'){ @force = true }
220
+ process args
221
+ @active = :contents unless @active
222
+ case @active
223
+ when :contents then
224
+ destroy $active_site.home+'contents' if @force
225
+ $active_site.build(:contents)
226
+ when :blueprint then
227
+ destroy $active_site.home+'blueprint' if @force
228
+ $active_site.info['layout'] ? $active_site.build(:blueprint) : puts('need to choosee a layout')
229
+ when :all then
230
+ destroy $active_site.home+'blueprint' if @force
231
+ destroy $active_site.home+'contents' if @force and not make_sure('do you want to destroy the contents?', 'N', 'y')
232
+ $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'
235
+ end
236
+ end
237
+
238
+ set :clear do
239
+ system 'clear'
240
+ end
241
+
242
+ set :quit do
243
+ exit
244
+ end
245
+ end
data/bin/static ADDED
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.dirname(__FILE__)+'/../lib/static'
4
+
5
+
6
+ $ENV['STATIC_HOME'] = "#{ENV['HOME']}/static/"
7
+ $ENV['STATIC_VIEWING'] = "#{ENV['HOME']}/Sites/static/"
8
+ $ENV['REPO_HOME'] = $ENV['STATIC_HOME']+'/repos/'
9
+ $ENV['SITE_BANK'] = $ENV['STATIC_HOME']+'projects/'
10
+ $ENV['TEMPLATE_HOME'] = $ENV['STATIC_HOME']+'.templates/'
11
+ $ENV['LAYOUT_HOME'] = $ENV['STATIC_HOME']+'layouts/'
12
+ $ENV['SCRIPT_HOME'] = $ENV['STATIC_HOME']+'lib/'
13
+ $ENV['TEMPLATE_BANK'] = File.dirname(__FILE__)+'/../templates'
14
+
15
+
16
+ include FileBase
17
+
18
+ #destroy $ENV['STATIC_HOME']
19
+ #destroy $ENV['STATIC_VIEWING']
20
+
21
+ mkdir $ENV['STATIC_HOME'] unless exists? :folder, $ENV['STATIC_HOME']
22
+ mkdir $ENV['SITE_BANK'] unless exists? :folder, $ENV['SITE_BANK']
23
+
24
+ copy File.dirname(__FILE__)+'/../templates', $ENV['TEMPLATE_HOME'] unless exists? :folder, $ENV['TEMPLATE_HOME']
25
+ move $ENV['TEMPLATE_HOME']+'layouts', $ENV['LAYOUT_HOME'] unless exists? :folder, $ENV['LAYOUT_HOME']
26
+ puts "home: #{$ENV['STATIC_HOME']}"
27
+
28
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))+'/lib/rbml')
29
+ $LOAD_PATH.unshift($ENV['STATIC_HOME'])
30
+
31
+ module Rbml
32
+ module Language
33
+ module Cli
34
+ module Cli
35
+ include Static
36
+
37
+ def helpdocs
38
+ puts 'these are the ellhp.'
39
+ end
40
+ def edit file
41
+ system "#{$ENV['EDITOR']} #{file}"
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ include Static
49
+ ::Rbml::Processor.run(File.dirname(__FILE__)+'/cli.rbml')
50
+
51
+ __END__
52
+ $active_site = load_site('please')
53
+ paginate :static
54
+
55
+ $active_site.build :all
56
+ #system "#{$ENV['EDITOR']} #{$active_site.home}"
57
+ paginate :the_copy
58
+ destroy $active_site.site_loc
59
+ $active_site.generate
60
+
61
+ $active_site = start_site('static')
62
+ $active_site.load_info
63
+ $active_site.load_pages
64
+ $active_site.start_collection 'news', ['date', 'headline', 'entry']
65
+ $active_site.start_collection 'blog', ['date', 'title', 'entry']
66
+
67
+ $active_site.build(:contents)
68
+ $active_site.info['layout'] = 'default'
69
+ set_layout($active_site.info['layout'], false)
70
+ $active_site.build(:blueprint)
71
+
72
+ assign_pagination :blog, :the_blueprint
73
+ #$active_collection = load_collection 'faq'
74
+ ::Rbml::Processor.run(File.dirname(__FILE__)+'/cli.rbml')
75
+ #system "vi #{$active_collection.add_entry}"
76
+ #$active_collection.save_listing
77
+ #$active_site.build :contents
78
+ #$active_site.set_layout('default', $ENV['LAYOUT_HOME'])
79
+ #$active_site.build :blueprint
80
+ #$active_site.start_collection 'faq', ['question', 'answer']
81
+ destroy $active_site.site_loc
82
+ $active_site.generate