staticmatic 0.10.8 → 0.11.0.alpha.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -20,6 +20,7 @@ begin
20
20
  gem.add_dependency("haml", ">=2.0.0")
21
21
  gem.add_dependency("rack", ">=1.0")
22
22
  gem.add_dependency("mongrel", ">=1.1.5")
23
+ gem.add_dependency("compass")
23
24
  end
24
25
  rescue LoadError
25
26
  puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gemgem.github.com"
data/VERSION.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 10
4
- :patch: 8
3
+ :minor: 11
4
+ :patch: 0
5
+ :build: alpha.0
data/bin/staticmatic CHANGED
@@ -5,6 +5,8 @@ require File.dirname(__FILE__) + '/../lib/staticmatic'
5
5
  command = ARGV[0]
6
6
  directory = ARGV[1]
7
7
 
8
+ $:.push File.join(directory, "lib")
9
+
8
10
  if !command || !directory
9
11
  puts "Usage: #{$0} <build|setup|preview> <directory>"
10
12
  exit
@@ -12,7 +14,15 @@ end
12
14
 
13
15
  configuration = StaticMatic::Configuration.new
14
16
 
15
- config_file = "#{directory}/src/configuration.rb"
17
+ config_file = File.join(directory, "config", "site.rb")
18
+
19
+ if !File.exists?(config_file)
20
+ config_file = File.join(directory, "src", "configuration.rb")
21
+
22
+ if File.exists?(config_file)
23
+ puts "DEPRECATION: #{directory}/src/configuration.rb will be moved to #{directory}/config/site.rb in 0.12.0"
24
+ end
25
+ end
16
26
 
17
27
  if File.exists?(config_file)
18
28
  config = File.read(config_file)
@@ -1,24 +1,4 @@
1
- module StaticMatic
2
- # Directories generated for a new site setup
3
- BASE_DIRS = %w{
4
- site/
5
- site/stylesheets
6
- site/images
7
- site/javascripts
8
- src/
9
- src/pages/
10
- src/layouts
11
- src/stylesheets
12
- src/helpers
13
- }
14
-
15
- # Templates for setup and their location
16
- TEMPLATES = {
17
- 'application.haml' => 'layouts',
18
- 'application.sass' => 'stylesheets',
19
- 'index.haml' => 'pages'
20
- }
21
-
1
+ module StaticMatic
22
2
  class Base
23
3
 
24
4
  include StaticMatic::RenderMixin
@@ -39,15 +19,21 @@ module StaticMatic
39
19
  @configuration = configuration
40
20
  @current_page = nil
41
21
  @current_file_stack = []
42
- @base_dir = File.expand_path(base_dir)
43
- @src_dir = "#{@base_dir}/src"
44
- @site_dir = "#{@base_dir}/site"
45
- @templates_dir = File.dirname(__FILE__) + '/templates/default/'
22
+ @base_dir = base_dir
23
+ @src_dir = File.join(@base_dir, "src")
24
+ @site_dir = File.join(@base_dir, "site")
25
+
26
+ if File.exists?(File.join(@src_dir, "layouts", "application.haml"))
27
+ puts "DEPRECATION: layouts/application.haml will be renamed to layouts/default.haml in the 0.12.0"
28
+ @layout = "application"
29
+ else
30
+ @layout = "default"
31
+ end
46
32
 
47
- @layout = "application"
48
33
  @scope = Object.new
49
34
  @scope.instance_variable_set("@staticmatic", self)
50
35
 
36
+ configure_compass
51
37
  load_helpers
52
38
  end
53
39
 
@@ -56,6 +42,8 @@ module StaticMatic
56
42
  end
57
43
 
58
44
  def run(command)
45
+ puts "Site root is: #{@base_dir}"
46
+
59
47
  if %w(build setup preview).include?(command)
60
48
  send(command)
61
49
  else
@@ -77,13 +65,21 @@ module StaticMatic
77
65
  end
78
66
 
79
67
  def full_layout_path(name)
80
- "#{@src_dir}/layouts/#{name}.haml"
68
+ File.join(@src_dir, "layouts", "#{name}.haml")
81
69
  end
82
70
 
83
- class << self
84
- def base_dirs
85
- StaticMatic::BASE_DIRS
71
+ def configure_compass
72
+ Compass.configuration do |config|
73
+ config.output_style = :expanded
74
+ config.project_path = @base_dir
75
+ config.sass_dir = File.join(@base_dir, "src", "stylesheets")
76
+ config.css_dir = File.join(@base_dir, "site", "stylesheets")
77
+ config.images_dir = File.join(@base_dir, "site", "images")
78
+ config.http_path = "/"
79
+ config.http_images_path = "/images"
86
80
  end
81
+
82
+ configuration.sass_options.merge!(Compass.sass_engine_options)
87
83
  end
88
84
  end
89
85
  end
@@ -16,7 +16,7 @@ module StaticMatic::RenderMixin
16
16
  begin
17
17
  # clear all scope variables except @staticmatic
18
18
  @scope.instance_variables.each do |var|
19
- @scope.instance_variable_set(var, nil) unless var == '@staticmatic' || :@staticmatic
19
+ @scope.instance_variable_set(var, nil) unless var == '@staticmatic' || var == :@staticmatic
20
20
  end
21
21
  html = generate_html_from_template_source(File.read(full_file_path))
22
22
 
@@ -99,7 +99,7 @@ module StaticMatic::RenderMixin
99
99
  end
100
100
 
101
101
  def determine_layout(dir = '')
102
- layout_name = "application"
102
+ layout_name = @layout
103
103
 
104
104
  if @scope.instance_variable_get("@layout")
105
105
  layout_name = @scope.instance_variable_get("@layout")
@@ -2,19 +2,15 @@ module StaticMatic::SetupMixin
2
2
 
3
3
  def setup
4
4
  Dir.mkdir(@base_dir) unless File.exists?(@base_dir)
5
-
6
- StaticMatic::BASE_DIRS.each do |directory|
7
- directory = "#{@base_dir}/#{directory}"
8
- if !File.exists?(directory)
9
- Dir.mkdir(directory)
10
- puts "created #{directory}"
5
+
6
+ Dir[File.join(File.dirname(__FILE__), "..", "templates", "project", "*")].each do |template|
7
+ begin
8
+ FileUtils.cp_r(template, @base_dir)
9
+ rescue Errno::EEXIST
10
+ # ignore - template exists
11
11
  end
12
12
  end
13
13
 
14
- StaticMatic::TEMPLATES.each do |template, destination|
15
- copy_file("#{@templates_dir}/#{template}", "#{@src_dir}/#{destination}")
16
- end
17
-
18
14
  puts "Done"
19
15
  end
20
16
  end
@@ -0,0 +1,16 @@
1
+ # Default is 3000
2
+ # configuration.preview_server_port = 3000
3
+
4
+ # Default is localhost
5
+ # configuration.preview_server_host = "localhost"
6
+
7
+ # Default is true
8
+ # When false .html & index.html get stripped off generated urls
9
+ # configuration.use_extensions_for_page_links = true
10
+
11
+ # Default is an empty hash
12
+ # configuration.sass_options = {}
13
+
14
+ # Default is an empty hash
15
+ # http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#options
16
+ # configuration.haml_options = {}
data/lib/staticmatic.rb CHANGED
@@ -5,9 +5,10 @@ require 'sass/plugin'
5
5
  require 'rack'
6
6
  require 'rack/handler/mongrel'
7
7
  require 'fileutils'
8
+ require 'compass'
8
9
 
9
10
  module StaticMatic
10
- VERSION = '0.10.2'
11
+ VERSION = "0.11.0"
11
12
  end
12
13
 
13
14
  ["render", "build", "setup", "server", "helpers", "rescue"].each do |mixin|
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+
3
+ describe "Compass integration" do
4
+ before do
5
+ setup_staticmatic
6
+ end
7
+
8
+ it "should configure compass" do
9
+ Compass.configuration.project_path.should == TEST_SITE_PATH
10
+ Compass.configuration.sass_dir.should == File.join(TEST_SITE_PATH, "src", "stylesheets")
11
+ Compass.configuration.css_dir.should == File.join(TEST_SITE_PATH, "site", "stylesheets")
12
+ Compass.configuration.images_dir.should == File.join(TEST_SITE_PATH, "site", "images")
13
+ Compass.configuration.http_path.should == "/"
14
+ Compass.configuration.http_images_path.should == "/images"
15
+ end
16
+ end
@@ -0,0 +1 @@
1
+ # stub for testing
@@ -0,0 +1,2 @@
1
+ require "staticmatic"
2
+ require "staticmatic/tasks/staticmatic"
@@ -0,0 +1,11 @@
1
+
2
+ output_style = :expanded
3
+ project_path = File.join(File.dirname(__FILE__), "..", "/") # must be set for Compass to work
4
+ sass_dir = "src/stylesheets" # dir containing Sass / Compass source files
5
+ http_path = "/" # root when deployed
6
+ css_dir = "site/stylesheets" # final CSS
7
+ images_dir = "site/images" # final images
8
+ http_images_path = "/images"
9
+
10
+ # To enable relative paths to assets via compass helper functions. Uncomment:
11
+ # relative_assets = true
@@ -0,0 +1,16 @@
1
+ # Default is 3000
2
+ # configuration.preview_server_port = 3000
3
+
4
+ # Default is localhost
5
+ # configuration.preview_server_host = "localhost"
6
+
7
+ # Default is true
8
+ # When false .html & index.html get stripped off generated urls
9
+ # configuration.use_extensions_for_page_links = true
10
+
11
+ # Default is an empty hash
12
+ # configuration.sass_options = {}
13
+
14
+ # Default is an empty hash
15
+ # http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#options
16
+ # configuration.haml_options = {}
@@ -0,0 +1,7 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %title StaticMatic
5
+ = stylesheets
6
+ %body
7
+ = yield
@@ -0,0 +1,7 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %title StaticMatic
5
+ = stylesheets
6
+ %body
7
+ = yield
@@ -0,0 +1 @@
1
+ %h1 StaticMatic!
@@ -0,0 +1,4 @@
1
+ body
2
+ font:
3
+ family: Verdana
4
+ size: 10pt
data/spec/server_spec.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require File.dirname(__FILE__) + "/spec_helper"
2
2
 
3
-
4
3
  describe "StaticMatic::Server" do
5
4
  before do
6
5
  @base_dir = File.dirname(__FILE__) + '/sandbox/tmp'
data/spec/setup_spec.rb CHANGED
@@ -3,23 +3,20 @@ require File.dirname(__FILE__) + "/spec_helper"
3
3
  describe "StaticMatic::Setup" do
4
4
  before do
5
5
  setup_staticmatic
6
+ @tmp_dir = File.dirname(__FILE__) + '/sandbox/tmp'
7
+ staticmatic = StaticMatic::Base.new(@tmp_dir)
8
+ staticmatic.run('setup')
6
9
  end
7
10
 
8
- it "setup directories" do
9
- tmp_dir = File.dirname(__FILE__) + '/sandbox/tmp'
10
- staticmatic = StaticMatic::Base.new(tmp_dir)
11
- staticmatic.run('setup')
12
-
13
- StaticMatic::Base.base_dirs.each do |dir|
14
- File.exists?("#{tmp_dir}/#{dir}").should_not be_nil, "Should create #{dir}"
15
- end
16
-
17
- StaticMatic::Base.base_dirs.reverse.each do |dir|
18
- Dir.entries("#{tmp_dir}/#{dir}").each do |file|
19
- next if file.match(/^\./)
20
- File.delete("#{tmp_dir}/#{dir}/#{file}")
21
- end
22
- Dir.delete("#{tmp_dir}/#{dir}") if File.exists?("#{tmp_dir}/#{dir}")
23
- end
11
+ it "should set up project directory in given path" do
12
+ %w(
13
+ site/images
14
+ site/javascripts
15
+ site/stylesheets
16
+ src/layouts/site.haml
17
+ src/pages/index.haml
18
+ src/stylesheets/screen.sass
19
+ config/site.rb
20
+ ).each {|path| File.exists?(File.join(@tmp_dir, path)).should(be_true, "#{path} expected to exist in #{@tmp_dir}") }
24
21
  end
25
22
  end
data/spec/spec_helper.rb CHANGED
@@ -4,7 +4,7 @@ require 'spec'
4
4
 
5
5
  require File.dirname(__FILE__) + '/../lib/staticmatic'
6
6
 
7
- TEST_SITE_PATH = File.join(File.dirname(__FILE__), "sandbox", "test_site")
7
+ TEST_SITE_PATH = File.expand_path(File.join(File.dirname(__FILE__), "sandbox", "test_site"))
8
8
 
9
9
  Spec::Runner.configure do |config|
10
10
  end
metadata CHANGED
@@ -1,7 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: staticmatic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.8
4
+ prerelease: true
5
+ segments:
6
+ - 0
7
+ - 11
8
+ - 0
9
+ - alpha
10
+ - 0
11
+ version: 0.11.0.alpha.0
5
12
  platform: ruby
6
13
  authors:
7
14
  - Stephen Bartholomew
@@ -9,39 +16,62 @@ autorequire:
9
16
  bindir: bin
10
17
  cert_chain: []
11
18
 
12
- date: 2010-03-20 00:00:00 +00:00
19
+ date: 2010-04-20 00:00:00 +01:00
13
20
  default_executable: staticmatic
14
21
  dependencies:
15
22
  - !ruby/object:Gem::Dependency
16
23
  name: haml
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
20
26
  requirements:
21
27
  - - ">="
22
28
  - !ruby/object:Gem::Version
29
+ segments:
30
+ - 2
31
+ - 0
32
+ - 0
23
33
  version: 2.0.0
24
- version:
34
+ type: :runtime
35
+ version_requirements: *id001
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: rack
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
30
40
  requirements:
31
41
  - - ">="
32
42
  - !ruby/object:Gem::Version
43
+ segments:
44
+ - 1
45
+ - 0
33
46
  version: "1.0"
34
- version:
47
+ type: :runtime
48
+ version_requirements: *id002
35
49
  - !ruby/object:Gem::Dependency
36
50
  name: mongrel
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
40
53
  requirements:
41
54
  - - ">="
42
55
  - !ruby/object:Gem::Version
56
+ segments:
57
+ - 1
58
+ - 1
59
+ - 5
43
60
  version: 1.1.5
44
- version:
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: compass
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ type: :runtime
74
+ version_requirements: *id004
45
75
  description: Lightweight Static Site Framework
46
76
  email: steve@curve21.com
47
77
  executables:
@@ -70,25 +100,28 @@ files:
70
100
  - lib/staticmatic/mixins/setup.rb
71
101
  - lib/staticmatic/server.rb
72
102
  - lib/staticmatic/template_error.rb
73
- - lib/staticmatic/templates/default/application.haml
74
- - lib/staticmatic/templates/default/application.sass
75
- - lib/staticmatic/templates/default/index.haml
103
+ - lib/staticmatic/templates/project/config/site.rb
104
+ - lib/staticmatic/templates/project/src/layouts/default.haml
105
+ - lib/staticmatic/templates/project/src/pages/index.haml
106
+ - lib/staticmatic/templates/project/src/stylesheets/screen.sass
76
107
  - lib/staticmatic/templates/rescues/default.haml
77
108
  - lib/staticmatic/templates/rescues/template.haml
78
109
  - spec/base_spec.rb
110
+ - spec/compass_integration_spec.rb
79
111
  - spec/helpers_spec.rb
80
112
  - spec/render_spec.rb
81
113
  - spec/rescue_spec.rb
82
- - spec/sandbox/test_site/configuration.rb
114
+ - spec/sandbox/test_site/config/site.rb
83
115
  - spec/sandbox/test_site/site/index
84
116
  - spec/sandbox/test_site/site/layout_test
85
117
  - spec/sandbox/test_site/site/stylesheets/application.css
86
118
  - spec/sandbox/test_site/site/sub_folder/another_sub_folder/index.html
87
119
  - spec/sandbox/test_site/site/sub_folder/another_sub_folder/index.html.html
88
120
  - spec/sandbox/test_site/site/sub_folder/index.html
121
+ - spec/sandbox/test_site/src/configuration.rb
89
122
  - spec/sandbox/test_site/src/helpers/application_helper.rb
90
123
  - spec/sandbox/test_site/src/layouts/alternate_layout.haml
91
- - spec/sandbox/test_site/src/layouts/application.haml
124
+ - spec/sandbox/test_site/src/layouts/default.haml
92
125
  - spec/sandbox/test_site/src/layouts/projects.haml
93
126
  - spec/sandbox/test_site/src/pages/hello_world.erb
94
127
  - spec/sandbox/test_site/src/pages/index.haml
@@ -101,6 +134,13 @@ files:
101
134
  - spec/sandbox/test_site/src/stylesheets/css_with_error.sass
102
135
  - spec/sandbox/test_site/src/stylesheets/nested/a_nested_stylesheet.sass
103
136
  - spec/sandbox/test_site/src/stylesheets/partials/_forms.sass
137
+ - spec/sandbox/tmp/Rakefile
138
+ - spec/sandbox/tmp/config/compass.rb
139
+ - spec/sandbox/tmp/config/site.rb
140
+ - spec/sandbox/tmp/src/layouts/default.haml
141
+ - spec/sandbox/tmp/src/layouts/site.haml
142
+ - spec/sandbox/tmp/src/pages/index.haml
143
+ - spec/sandbox/tmp/src/stylesheets/screen.sass
104
144
  - spec/server_spec.rb
105
145
  - spec/setup_spec.rb
106
146
  - spec/spec_helper.rb
@@ -118,28 +158,36 @@ required_ruby_version: !ruby/object:Gem::Requirement
118
158
  requirements:
119
159
  - - ">="
120
160
  - !ruby/object:Gem::Version
161
+ segments:
162
+ - 0
121
163
  version: "0"
122
- version:
123
164
  required_rubygems_version: !ruby/object:Gem::Requirement
124
165
  requirements:
125
- - - ">="
166
+ - - ">"
126
167
  - !ruby/object:Gem::Version
127
- version: "0"
128
- version:
168
+ segments:
169
+ - 1
170
+ - 3
171
+ - 1
172
+ version: 1.3.1
129
173
  requirements: []
130
174
 
131
175
  rubyforge_project: staticmatic
132
- rubygems_version: 1.3.5
176
+ rubygems_version: 1.3.6
133
177
  signing_key:
134
178
  specification_version: 3
135
179
  summary: Lightweight Static Site Framework
136
180
  test_files:
137
181
  - spec/base_spec.rb
182
+ - spec/compass_integration_spec.rb
138
183
  - spec/helpers_spec.rb
139
184
  - spec/render_spec.rb
140
185
  - spec/rescue_spec.rb
141
- - spec/sandbox/test_site/configuration.rb
186
+ - spec/sandbox/test_site/config/site.rb
187
+ - spec/sandbox/test_site/src/configuration.rb
142
188
  - spec/sandbox/test_site/src/helpers/application_helper.rb
189
+ - spec/sandbox/tmp/config/compass.rb
190
+ - spec/sandbox/tmp/config/site.rb
143
191
  - spec/server_spec.rb
144
192
  - spec/setup_spec.rb
145
193
  - spec/spec_helper.rb