awestruct 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/bin/awestruct CHANGED
@@ -87,7 +87,18 @@ def parse(args)
87
87
  options
88
88
  end
89
89
 
90
+ def site_path
91
+ dir = (@profiles_data.nil? || @profile_data.nil? || @profile_data['output_dir'].nil?) ? '_site' : @profile_data['output_dir']
92
+ path = File.join( Dir.pwd, dir )
93
+ end
94
+
90
95
  options = parse(ARGV)
96
+ unless options.init
97
+ site_yaml_file = File.join( Dir.pwd, '_config', 'site.yml' )
98
+ site_yaml = YAML.load( File.read( site_yaml_file ) )
99
+ @profiles_data = site_yaml ? site_yaml['profiles'] : {}
100
+ @profile_data = @profiles_data[options.profile]
101
+ end
91
102
 
92
103
  if ( options.init )
93
104
  if ( options.generate || options.auto || options.server )
@@ -101,7 +112,7 @@ end
101
112
 
102
113
  if ( options.deploy )
103
114
  if ( options.auto || options.server )
104
- $stderr.puts "--init may not be used with --generate, --auto or --server"
115
+ $stderr.puts "--deploy may not be used with --auto or --server"
105
116
  exit
106
117
  end
107
118
 
@@ -111,38 +122,29 @@ if ( options.deploy )
111
122
  end
112
123
 
113
124
 
114
- site_dir = File.join( Dir.pwd, '_site' )
115
- if ( ! File.exist?( site_dir ) )
116
- $stderr.puts "No _site/ generated yet."
125
+ if ( @profiles_data.nil? )
126
+ $stderr.puts "_config/site.yml must define a 'profiles' section"
117
127
  exit
118
128
  end
119
129
 
120
- site_yaml_file = File.join( Dir.pwd, '_config', 'site.yml' )
121
130
 
122
- site_yaml = YAML.load( File.read( site_yaml_file ) )
123
-
124
- profiles_data = site_yaml['profiles']
125
-
126
- if ( profiles_data.nil? )
127
- $stderr.puts "_config/site.yml must define a 'profiles' section"
131
+ if ( @profile_data.nil? )
132
+ $stderr.puts "Unknown profile '#{options.profile}'"
128
133
  exit
129
134
  end
130
135
 
131
- profile_data = profiles_data[options.profile]
132
-
133
- if ( profile_data.nil? )
134
- $stderr.puts "Unknown profile '#{options.profile}'"
136
+ if ( ! File.exist?( site_path ) )
137
+ $stderr.puts "No #{site_path}/ generated yet."
135
138
  exit
136
139
  end
137
140
 
138
- deploy_data = profile_data['deploy']
139
-
141
+ deploy_data = @profile_data['deploy']
140
142
  if ( deploy_data.nil? )
141
143
  $stderr.puts "No configuration for 'deploy'"
142
144
  exit
143
145
  end
144
146
 
145
- cmd = Awestruct::Commands::Deploy.new( site_dir, deploy_data )
147
+ cmd = Awestruct::Commands::Deploy.new( site_path, deploy_data )
146
148
 
147
149
  cmd.run
148
150
  exit
@@ -174,7 +176,8 @@ end
174
176
 
175
177
  if ( options.server )
176
178
  threads << Thread.new {
177
- server_cmd = Awestruct::Commands::Server.new( File.join( Dir.pwd, '_site' ), options.bind_addr, options.port )
179
+ puts "Serving site at #{site_path}"
180
+ server_cmd = Awestruct::Commands::Server.new( site_path, options.bind_addr, options.port )
178
181
  server_cmd.run
179
182
  }
180
183
  end
@@ -1,4 +1,4 @@
1
- require 'awestruct'
1
+ require 'awestruct/engine'
2
2
 
3
3
  module Awestruct
4
4
  module Commands
@@ -26,6 +26,7 @@ module Awestruct
26
26
  if ( @scaffold )
27
27
  manifest.copy_file( '_layouts/base.html.haml', File.join( File.dirname(__FILE__), '/base_layout.html.haml' ) )
28
28
  manifest.copy_file( 'index.html.haml', File.join( File.dirname(__FILE__), '/base_index.html.haml' ) )
29
+ manifest.touch_file( '_config/site.yml' )
29
30
  end
30
31
  manifest.perform( @dir )
31
32
  end
@@ -1,16 +1,31 @@
1
1
  require 'compass/logger'
2
2
  require 'compass/actions'
3
3
  require 'compass/commands/base'
4
+ require 'compass/commands/registry'
4
5
  require 'compass/commands/create_project'
5
- require 'compass/installers/stand_alone'
6
+ require 'compass/installers/bare_installer'
6
7
 
7
- class Compass::Installers::StandAloneInstaller
8
- def write_configuration_files(config_file=nil)
9
- # skip it!
8
+ module Compass::AppIntegration::StandAlone
9
+ end
10
+
11
+ class Compass::AppIntegration::StandAlone::Installer
12
+ def write_configuration_files(config_file = nil)
13
+ # no!
10
14
  end
15
+ def finalize(opts={})
16
+ puts <<-END.gsub(/^ {6}/, '')
17
+
18
+ Now you're awestruct!
19
+
20
+ To generate your site continuous during development, simply run:
11
21
 
12
- def compilation_required?
13
- false
22
+ awestruct -d
23
+
24
+ and visit your site at
25
+
26
+ http://localhost:4242/
27
+
28
+ END
14
29
  end
15
30
  end
16
31
 
@@ -34,6 +49,10 @@ module Awestruct
34
49
  def copy_file(path, input_path)
35
50
  steps << CopyFile.new( path, input_path )
36
51
  end
52
+
53
+ def touch_file(path)
54
+ steps << TouchFile.new(path)
55
+ end
37
56
 
38
57
  def install_compass(framework)
39
58
  steps << InstallCompass.new(framework)
@@ -104,6 +123,20 @@ module Awestruct
104
123
  FileUtils.rmdir( p )
105
124
  end
106
125
  end
126
+
127
+ class TouchFile
128
+ def initialize(path)
129
+ @path = path
130
+ end
131
+
132
+ def perform(dir)
133
+ FileUtils.touch(File.join(dir, @path))
134
+ end
135
+
136
+ def unperform(dir)
137
+ #nothing
138
+ end
139
+ end
107
140
 
108
141
  class CopyFile
109
142
  def initialize(path, input_path)
@@ -154,8 +187,8 @@ module Awestruct
154
187
  cmd = Compass::Commands::CreateProject.new( dir, {
155
188
  :framework=>@framework,
156
189
  :project_type=>:stand_alone,
157
- #:css_dir=>'_site/stylesheets',
158
- #:sass_dir=>'stylesheets',
190
+ :css_dir=>'_site/stylesheets',
191
+ :sass_dir=>'stylesheets',
159
192
  :images_dir=>'images',
160
193
  :javascripts_dir=>'javascripts',
161
194
  } )
@@ -7,8 +7,11 @@ require 'time'
7
7
  require 'awestruct/config'
8
8
  require 'awestruct/site'
9
9
  require 'awestruct/haml_file'
10
+ require 'awestruct/erb_file'
10
11
  require 'awestruct/maruku_file'
11
12
  require 'awestruct/sass_file'
13
+ require 'awestruct/scss_file'
14
+ require 'awestruct/org_mode_file'
12
15
  require 'awestruct/verbatim_file'
13
16
 
14
17
  require 'awestruct/context_helper'
@@ -86,10 +89,16 @@ module Awestruct
86
89
 
87
90
  if ( path =~ /\.haml$/ )
88
91
  page = HamlFile.new( site, path, fixed_relative_path )
92
+ elsif ( path =~ /\.erb$/ )
93
+ page = ErbFile.new( site, path, fixed_relative_path )
89
94
  elsif ( path =~ /\.md$/ )
90
95
  page = MarukuFile.new( site, path, fixed_relative_path )
91
96
  elsif ( path =~ /\.sass$/ )
92
97
  page = SassFile.new( site, path, fixed_relative_path )
98
+ elsif ( path =~ /\.scss$/ )
99
+ page = ScssFile.new( site, path, fixed_relative_path )
100
+ elsif ( path =~ /\.org$/ )
101
+ page = OrgModeFile.new( site, path, fixed_relative_path )
93
102
  elsif ( File.file?( path ) )
94
103
  page = VerbatimFile.new( site, path, fixed_relative_path )
95
104
  end
@@ -113,6 +122,9 @@ module Awestruct
113
122
  result = instance_eval( str )
114
123
  result
115
124
  end
125
+ def evaluate_erb(erb)
126
+ erb.result( binding )
127
+ end
116
128
  end
117
129
  context
118
130
  end
@@ -239,7 +251,7 @@ module Awestruct
239
251
  else
240
252
  site.send( "#{k}=", v )
241
253
  end
242
- end
254
+ end if data
243
255
 
244
256
  profile_data.each do |k,v|
245
257
  site.send( "#{k}=", v )
@@ -267,6 +279,7 @@ module Awestruct
267
279
  dir_pathname = Pathname.new( dir )
268
280
  site.pages.clear
269
281
  Find.find( dir ) do |path|
282
+ next if path == dir
270
283
  basename = File.basename( path )
271
284
  if ( basename == '.htaccess' )
272
285
  #special case
@@ -0,0 +1,24 @@
1
+
2
+ require 'haml'
3
+ require 'awestruct/front_matter_file'
4
+ require 'awestruct/erbable'
5
+
6
+ module Awestruct
7
+ class ErbFile < FrontMatterFile
8
+
9
+ include Erbable
10
+
11
+ def initialize(site, source_path, relative_source_path)
12
+ super(site, source_path, relative_source_path)
13
+ end
14
+
15
+ def output_filename
16
+ File.basename( self.source_path, '.erb' )
17
+ end
18
+
19
+ def output_extension
20
+ File.extname( output_filename )
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,19 @@
1
+ require 'sass'
2
+
3
+ require 'compass'
4
+
5
+ module Awestruct
6
+ module Erbable
7
+
8
+ def render(context)
9
+ erb = ERB.new( raw_page_content )
10
+ context.evaluate_erb( erb )
11
+ end
12
+
13
+ def content
14
+ context = site.engine.create_context( self )
15
+ render( context )
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,24 @@
1
+
2
+ require 'sass'
3
+ require 'awestruct/front_matter_file'
4
+ require 'awestruct/org_modeable'
5
+
6
+ module Awestruct
7
+ class OrgModeFile < FrontMatterFile
8
+
9
+ include OrgModeable
10
+
11
+ def initialize(site, source_path, relative_source_path)
12
+ super( site, source_path, relative_source_path )
13
+ end
14
+
15
+ def output_filename
16
+ File.basename( self.source_path, '.org' ) + output_extension
17
+ end
18
+
19
+ def output_extension
20
+ '.html'
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+
2
+ require 'org-ruby'
3
+
4
+ module Awestruct
5
+ module OrgModeable
6
+
7
+ def render(context)
8
+ Orgmode::Parser.new(raw_page_content).to_html
9
+ end
10
+
11
+ def output_extension
12
+ 'html'
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+
2
+ require 'sass'
3
+ require 'awestruct/renderable_file'
4
+ require 'awestruct/sassable'
5
+
6
+ module Awestruct
7
+ class ScssFile < RenderableFile
8
+
9
+ include Sassable
10
+
11
+ def initialize(site, source_path, relative_source_path)
12
+ super( site, source_path, relative_source_path )
13
+ end
14
+
15
+ def output_filename
16
+ File.basename( source_path, '.scss' ) + '.css'
17
+ end
18
+
19
+ end
20
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awestruct
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 19
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 5
9
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
10
11
  platform: ruby
11
12
  authors:
12
13
  - Bob McWhirter
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-03-01 00:00:00 -05:00
18
+ date: 2010-06-12 00:00:00 -04:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: hpricot
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 0
29
32
  version: "0"
@@ -33,9 +36,11 @@ dependencies:
33
36
  name: haml
34
37
  prerelease: false
35
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
36
40
  requirements:
37
41
  - - ">="
38
42
  - !ruby/object:Gem::Version
43
+ hash: 3
39
44
  segments:
40
45
  - 0
41
46
  version: "0"
@@ -45,9 +50,11 @@ dependencies:
45
50
  name: maruku
46
51
  prerelease: false
47
52
  requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
48
54
  requirements:
49
55
  - - ">="
50
56
  - !ruby/object:Gem::Version
57
+ hash: 3
51
58
  segments:
52
59
  - 0
53
60
  version: "0"
@@ -57,9 +64,11 @@ dependencies:
57
64
  name: compass
58
65
  prerelease: false
59
66
  requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
60
68
  requirements:
61
69
  - - ">="
62
70
  - !ruby/object:Gem::Version
71
+ hash: 3
63
72
  segments:
64
73
  - 0
65
74
  version: "0"
@@ -69,9 +78,11 @@ dependencies:
69
78
  name: mongrel
70
79
  prerelease: false
71
80
  requirement: &id005 !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
83
  - - ">="
74
84
  - !ruby/object:Gem::Version
85
+ hash: 3
75
86
  segments:
76
87
  - 0
77
88
  version: "0"
@@ -95,6 +106,8 @@ files:
95
106
  - lib/awestruct/config.rb
96
107
  - lib/awestruct/context_helper.rb
97
108
  - lib/awestruct/engine.rb
109
+ - lib/awestruct/erb_file.rb
110
+ - lib/awestruct/erbable.rb
98
111
  - lib/awestruct/extensions/atomizer.rb
99
112
  - lib/awestruct/extensions/google_analytics.rb
100
113
  - lib/awestruct/extensions/indexifier.rb
@@ -107,10 +120,13 @@ files:
107
120
  - lib/awestruct/hamlable.rb
108
121
  - lib/awestruct/maruku_file.rb
109
122
  - lib/awestruct/marukuable.rb
123
+ - lib/awestruct/org_mode_file.rb
124
+ - lib/awestruct/org_modeable.rb
110
125
  - lib/awestruct/renderable.rb
111
126
  - lib/awestruct/renderable_file.rb
112
127
  - lib/awestruct/sass_file.rb
113
128
  - lib/awestruct/sassable.rb
129
+ - lib/awestruct/scss_file.rb
114
130
  - lib/awestruct/site.rb
115
131
  - lib/awestruct/util/default_inflections.rb
116
132
  - lib/awestruct/util/inflector.rb
@@ -119,6 +135,7 @@ files:
119
135
  - lib/awestruct/commands/base_index.html.haml
120
136
  - lib/awestruct/commands/base_layout.html.haml
121
137
  - lib/awestruct/extensions/template.atom.haml
138
+ - bin/awestruct
122
139
  has_rdoc: true
123
140
  homepage:
124
141
  licenses: []
@@ -129,23 +146,27 @@ rdoc_options: []
129
146
  require_paths:
130
147
  - lib
131
148
  required_ruby_version: !ruby/object:Gem::Requirement
149
+ none: false
132
150
  requirements:
133
151
  - - ">="
134
152
  - !ruby/object:Gem::Version
153
+ hash: 3
135
154
  segments:
136
155
  - 0
137
156
  version: "0"
138
157
  required_rubygems_version: !ruby/object:Gem::Requirement
158
+ none: false
139
159
  requirements:
140
160
  - - ">="
141
161
  - !ruby/object:Gem::Version
162
+ hash: 3
142
163
  segments:
143
164
  - 0
144
165
  version: "0"
145
166
  requirements: []
146
167
 
147
168
  rubyforge_project:
148
- rubygems_version: 1.3.6
169
+ rubygems_version: 1.3.7
149
170
  signing_key:
150
171
  specification_version: 3
151
172
  summary: Static site-baking utility