middleman 1.1.0.beta.8 → 1.1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. data/bin/mm-init +7 -19
  2. data/features/step_definitions/generator_steps.rb +1 -1
  3. data/lib/middleman/builder.rb +1 -1
  4. data/lib/middleman/features.rb +4 -0
  5. data/lib/middleman/features/data.rb +30 -0
  6. data/lib/middleman/features/lorem.rb +22 -0
  7. data/lib/middleman/server.rb +6 -3
  8. data/lib/middleman/templates.rb +31 -0
  9. data/lib/middleman/templates/default.rb +16 -0
  10. data/lib/middleman/templates/html5.rb +13 -0
  11. data/lib/middleman/templates/html5/config.ru +4 -0
  12. data/lib/middleman/templates/{html5boilerplate → html5}/config.tt +0 -0
  13. data/lib/middleman/templates/{html5boilerplate → html5}/public/404.html +0 -0
  14. data/lib/middleman/templates/{html5boilerplate → html5}/public/apple-touch-icon.png +0 -0
  15. data/lib/middleman/templates/{html5boilerplate → html5}/public/crossdomain.xml +0 -0
  16. data/lib/middleman/templates/{html5boilerplate → html5}/public/css/handheld.css +0 -0
  17. data/lib/middleman/templates/{html5boilerplate → html5}/public/css/style.css +0 -0
  18. data/lib/middleman/templates/{html5boilerplate → html5}/public/favicon.ico +0 -0
  19. data/lib/middleman/templates/{html5boilerplate → html5}/public/humans.txt +0 -0
  20. data/lib/middleman/templates/{html5boilerplate → html5}/public/images/.gitignore +0 -0
  21. data/lib/middleman/templates/{html5boilerplate → html5}/public/index.html +0 -0
  22. data/lib/middleman/templates/{html5boilerplate → html5}/public/js/libs/dd_belatedpng.js +0 -0
  23. data/lib/middleman/templates/{html5boilerplate → html5}/public/js/libs/jquery-1.5.0.js +0 -0
  24. data/lib/middleman/templates/{html5boilerplate → html5}/public/js/libs/jquery-1.5.0.min.js +0 -0
  25. data/lib/middleman/templates/{html5boilerplate → html5}/public/js/libs/modernizr-1.6.min.js +0 -0
  26. data/lib/middleman/templates/{html5boilerplate → html5}/public/js/mylibs/.gitignore +0 -0
  27. data/lib/middleman/templates/{html5boilerplate → html5}/public/js/plugins.js +0 -0
  28. data/lib/middleman/templates/{html5boilerplate → html5}/public/js/script.js +0 -0
  29. data/lib/middleman/templates/{html5boilerplate → html5}/public/robots.txt +0 -0
  30. data/lib/middleman/version.rb +1 -1
  31. data/middleman.gemspec +1 -0
  32. metadata +32 -30
data/bin/mm-init CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.join(File.dirname(File.dirname(__FILE__)), 'lib', 'middleman')
3
- require "thor"
4
- require "thor/group"
3
+ require "middleman/templates"
5
4
 
6
5
  module Middleman
7
6
  class Generator < ::Thor::Group
@@ -9,29 +8,18 @@ module Middleman
9
8
 
10
9
  argument :location, :type => :string, :desc => "New project location"
11
10
 
12
- class_option :template, :aliases => "-T", :default => "default", :desc => 'Optionally use a pre-defined project template: html5, default'
13
-
14
- def self.source_root
15
- File.join(File.dirname(__FILE__), '..', 'lib', 'middleman', 'templates')
16
- end
11
+ available_templates = Middleman::Templates.registered_names.join(", ")
12
+ class_option :template, :aliases => "-T", :default => "default", :desc => "Optionally use a pre-defined project template: #{available_templates}"
17
13
 
18
14
  class_option :css_dir, :default => "stylesheets", :desc => 'The path to the css files'
19
15
  class_option :js_dir, :default => "javascripts", :desc => 'The path to the javascript files'
20
16
  class_option :images_dir, :default => "images", :desc => 'The path to the image files'
21
17
 
22
18
  def create_project
23
- if options[:template] == "html5"
24
- template "html5boilerplate/config.tt", File.join(location, "config.rb")
25
- directory "html5boilerplate/public", File.join(location, "public")
26
- empty_directory File.join(location, "views")
27
- else
28
- template "default/config.tt", File.join(location, "config.rb")
29
- template "default/config.ru", File.join(location, "config.ru")
30
- directory "default/views", File.join(location, "views")
31
- empty_directory File.join(location, "public", options[:css_dir])
32
- empty_directory File.join(location, "public", options[:js_dir])
33
- empty_directory File.join(location, "public", options[:images_dir])
34
- end
19
+ key = options[:template].to_sym
20
+ key = :default unless Middleman::Templates.registered_templates.has_key?(key)
21
+
22
+ Middleman::Templates.registered_templates[key].start
35
23
  end
36
24
  end
37
25
  end
@@ -8,7 +8,7 @@ end
8
8
 
9
9
  Then /^template files should exist at "([^\"]*)"$/ do |dirname|
10
10
  target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", dirname)
11
- template_glob = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "lib", "middleman", "template", "*/**/*")
11
+ template_glob = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "lib", "middleman", "templates", "default", "*/**/*")
12
12
 
13
13
  Dir[template_glob].each do |f|
14
14
  next if File.directory?(f)
@@ -96,7 +96,7 @@ module Middleman
96
96
 
97
97
  handled_by_tilt = ::Tilt.mappings.keys.include?(file_extension.gsub(/^\./, ""))
98
98
  if handled_by_tilt || (file_extension == ".js")
99
- new_file_extension = ""
99
+ new_file_extension = (file_extension == ".js") ? ".js" : ""
100
100
  next if file_source.split('/').last.split('.').length < 3
101
101
 
102
102
  file_destination.gsub!(file_extension, new_file_extension)
@@ -75,6 +75,10 @@ module Middleman::Features
75
75
  # paragraphs, fake images, names and email addresses.
76
76
  autoload :Lorem, "middleman/features/lorem"
77
77
 
78
+ # Data looks at the data/ folder for YAML files and makes them available
79
+ # to dynamic requests.
80
+ autoload :Data, "middleman/features/data"
81
+
78
82
  # LiveReload will auto-reload browsers with the live reload extension installed after changes
79
83
  # Currently disabled and untested.
80
84
  #autoload :LiveReload, "middleman/features/live_reload"
@@ -0,0 +1,30 @@
1
+ require "yaml"
2
+
3
+ module Middleman::Features::Data
4
+ class << self
5
+ def registered(app)
6
+ app.helpers Middleman::Features::Data::Helpers
7
+ end
8
+ alias :included :registered
9
+ end
10
+
11
+ module Helpers
12
+ def data
13
+ @@data ||= Middleman::Features::Data::DataObject.new(self)
14
+ end
15
+ end
16
+
17
+ class DataObject
18
+ def initialize(app)
19
+ @app = app
20
+ end
21
+
22
+ def method_missing(path)
23
+ file_path = File.join(@app.class.root, "data", "#{path}.yml")
24
+ if File.exists? file_path
25
+ return YAML.load_file(file_path)
26
+ end
27
+ end
28
+ end
29
+
30
+ end
@@ -14,6 +14,28 @@ module Middleman::Features::Lorem
14
14
 
15
15
  # Adapted from Frank:
16
16
  # https://github.com/blahed/frank/
17
+ # Copyright (c) 2010 Travis Dunn
18
+ #
19
+ # Permission is hereby granted, free of charge, to any person
20
+ # obtaining a copy of this software and associated documentation
21
+ # files (the "Software"), to deal in the Software without
22
+ # restriction, including without limitation the rights to use,
23
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell
24
+ # copies of the Software, and to permit persons to whom the
25
+ # Software is furnished to do so, subject to the following
26
+ # conditions:
27
+ #
28
+ # The above copyright notice and this permission notice shall be
29
+ # included in all copies or substantial portions of the Software.
30
+ #
31
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
33
+ # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
35
+ # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
36
+ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
37
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
38
+ # OTHER DEALINGS IN THE SOFTWARE.
17
39
  class LoremObject
18
40
  WORDS = %w(alias consequatur aut perferendis sit voluptatem accusantium doloremque aperiam eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo aspernatur aut odit aut fugit sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt neque dolorem ipsum quia dolor sit amet consectetur adipisci velit sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem ut enim ad minima veniam quis nostrum exercitationem ullam corporis nemo enim ipsam voluptatem quia voluptas sit suscipit laboriosam nisi ut aliquid ex ea commodi consequatur quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae et iusto odio dignissimos ducimus qui blanditiis praesentium laudantium totam rem voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident sed ut perspiciatis unde omnis iste natus error similique sunt in culpa qui officia deserunt mollitia animi id est laborum et dolorum fuga et harum quidem rerum facilis est et expedita distinctio nam libero tempore cum soluta nobis est eligendi optio cumque nihil impedit quo porro quisquam est qui minus id quod maxime placeat facere possimus omnis voluptas assumenda est omnis dolor repellendus temporibus autem quibusdam et aut consequatur vel illum qui dolorem eum fugiat quo voluptas nulla pariatur at vero eos et accusamus officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae itaque earum rerum hic tenetur a sapiente delectus ut aut reiciendis voluptatibus maiores doloribus asperiores repellat)
19
41
 
@@ -9,7 +9,7 @@ module Middleman
9
9
  class Server < Sinatra::Base
10
10
  # Basic Sinatra config
11
11
  set :app_file, __FILE__
12
- #set :root, ENV["MM_DIR"] || Dir.pwd
12
+ set :root, ENV["MM_DIR"] || Dir.pwd
13
13
  set :reload, false
14
14
  set :sessions, false
15
15
  set :logging, false
@@ -40,6 +40,9 @@ module Middleman
40
40
  # Activate built-in helpers
41
41
  register Middleman::Features::DefaultHelpers
42
42
 
43
+ # Activate Yaml Data package
44
+ register Middleman::Features::Data
45
+
43
46
  # Activate Lorem helpers
44
47
  register Middleman::Features::Lorem
45
48
 
@@ -154,7 +157,7 @@ require "middleman/assets"
154
157
 
155
158
  # The Rack App
156
159
  class Middleman::Server
157
- def self.new(*args, &block)
160
+ def self.new(*args, &block)
158
161
  # Check for and evaluate local configuration
159
162
  local_config = File.join(self.root, "config.rb")
160
163
  if File.exists? local_config
@@ -162,7 +165,7 @@ class Middleman::Server
162
165
  Middleman::Server.class_eval File.read(local_config)
163
166
  set :app_file, File.expand_path(local_config)
164
167
  end
165
-
168
+
166
169
  use ::Rack::ConditionalGet
167
170
  use ::Rack::Static, :urls => ["/#{self.images_dir}"], :root => "public"
168
171
 
@@ -0,0 +1,31 @@
1
+ require "thor"
2
+ require "thor/group"
3
+
4
+ module Middleman::Templates
5
+ @@template_mappings = {}
6
+ def self.register(name, klass)
7
+ @@template_mappings[name] = klass
8
+ end
9
+
10
+ def self.registered_names
11
+ @@template_mappings.keys
12
+ end
13
+
14
+ def self.registered_templates
15
+ @@template_mappings
16
+ end
17
+
18
+ class Base < ::Thor::Group
19
+ include Thor::Actions
20
+
21
+ argument :location, :type => :string
22
+ class_option :css_dir, :default => "stylesheets", :desc => 'The path to the css files'
23
+ class_option :js_dir, :default => "javascripts", :desc => 'The path to the javascript files'
24
+ class_option :images_dir, :default => "images", :desc => 'The path to the image files'
25
+ end
26
+ end
27
+
28
+ # Default template
29
+ require "middleman/templates/default"
30
+ # HTML5 template
31
+ require "middleman/templates/html5"
@@ -0,0 +1,16 @@
1
+ class Middleman::Templates::Default < Middleman::Templates::Base
2
+ def self.source_root
3
+ File.join(File.dirname(__FILE__), 'default')
4
+ end
5
+
6
+ def build_scaffold
7
+ template "config.tt", File.join(location, "config.rb")
8
+ template "config.ru", File.join(location, "config.ru")
9
+ directory "views", File.join(location, "views")
10
+ empty_directory File.join(location, "public", options[:css_dir])
11
+ empty_directory File.join(location, "public", options[:js_dir])
12
+ empty_directory File.join(location, "public", options[:images_dir])
13
+ end
14
+ end
15
+
16
+ Middleman::Templates.register(:default, Middleman::Templates::Default)
@@ -0,0 +1,13 @@
1
+ class Middleman::Templates::Html5 < Middleman::Templates::Base
2
+ def self.source_root
3
+ File.join(File.dirname(__FILE__), 'html5')
4
+ end
5
+
6
+ def build_scaffold
7
+ template "config.tt", File.join(location, "config.rb")
8
+ directory "public", File.join(location, "public")
9
+ empty_directory File.join(location, "views")
10
+ end
11
+ end
12
+
13
+ Middleman::Templates.register(:html5, Middleman::Templates::Html5)
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'middleman'
3
+
4
+ run Middleman::Server
@@ -1,3 +1,3 @@
1
1
  module Middleman
2
- VERSION = "1.1.0.beta.8"
2
+ VERSION = "1.1.0.1"
3
3
  end
data/middleman.gemspec CHANGED
@@ -39,6 +39,7 @@ Gem::Specification.new do |s|
39
39
  s.add_runtime_dependency("compass-slickmap", ["~> 0.4.0"])
40
40
  s.add_runtime_dependency("coffee-script", ["~> 2.1.0"])
41
41
  s.add_runtime_dependency("less", ["~> 1.2.0"])
42
+ # s.add_runtime_dependency("fssm", ["~> 0.2.0"])
42
43
  s.add_development_dependency("cucumber", ["~> 0.10.0"])
43
44
  s.add_development_dependency("rspec", [">= 0"])
44
45
  s.add_development_dependency("rocco", [">= 0"]) unless defined?(JRUBY_VERSION)
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196355
5
- prerelease: 6
4
+ hash: 85
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
9
  - 0
10
- - beta
11
- - 8
12
- version: 1.1.0.beta.8
10
+ - 1
11
+ version: 1.1.0.1
13
12
  platform: ruby
14
13
  authors:
15
14
  - Thomas Reynolds
@@ -17,7 +16,7 @@ autorequire:
17
16
  bindir: bin
18
17
  cert_chain: []
19
18
 
20
- date: 2011-04-10 00:00:00 -07:00
19
+ date: 2011-04-15 00:00:00 -07:00
21
20
  default_executable:
22
21
  dependencies:
23
22
  - !ruby/object:Gem::Dependency
@@ -468,6 +467,7 @@ files:
468
467
  - lib/middleman/features/automatic_image_sizes/fastimage.rb
469
468
  - lib/middleman/features/cache_buster.rb
470
469
  - lib/middleman/features/code_ray.rb
470
+ - lib/middleman/features/data.rb
471
471
  - lib/middleman/features/default_helpers.rb
472
472
  - lib/middleman/features/live_reload.rb
473
473
  - lib/middleman/features/lorem.rb
@@ -482,29 +482,33 @@ files:
482
482
  - lib/middleman/renderers/haml.rb
483
483
  - lib/middleman/renderers/sass.rb
484
484
  - lib/middleman/server.rb
485
+ - lib/middleman/templates.rb
486
+ - lib/middleman/templates/default.rb
485
487
  - lib/middleman/templates/default/config.ru
486
488
  - lib/middleman/templates/default/config.tt
487
489
  - lib/middleman/templates/default/views/index.html.haml
488
490
  - lib/middleman/templates/default/views/layout.haml
489
491
  - lib/middleman/templates/default/views/stylesheets/site.css.sass
490
- - lib/middleman/templates/html5boilerplate/config.tt
491
- - lib/middleman/templates/html5boilerplate/public/404.html
492
- - lib/middleman/templates/html5boilerplate/public/apple-touch-icon.png
493
- - lib/middleman/templates/html5boilerplate/public/crossdomain.xml
494
- - lib/middleman/templates/html5boilerplate/public/css/handheld.css
495
- - lib/middleman/templates/html5boilerplate/public/css/style.css
496
- - lib/middleman/templates/html5boilerplate/public/favicon.ico
497
- - lib/middleman/templates/html5boilerplate/public/humans.txt
498
- - lib/middleman/templates/html5boilerplate/public/images/.gitignore
499
- - lib/middleman/templates/html5boilerplate/public/index.html
500
- - lib/middleman/templates/html5boilerplate/public/js/libs/dd_belatedpng.js
501
- - lib/middleman/templates/html5boilerplate/public/js/libs/jquery-1.5.0.js
502
- - lib/middleman/templates/html5boilerplate/public/js/libs/jquery-1.5.0.min.js
503
- - lib/middleman/templates/html5boilerplate/public/js/libs/modernizr-1.6.min.js
504
- - lib/middleman/templates/html5boilerplate/public/js/mylibs/.gitignore
505
- - lib/middleman/templates/html5boilerplate/public/js/plugins.js
506
- - lib/middleman/templates/html5boilerplate/public/js/script.js
507
- - lib/middleman/templates/html5boilerplate/public/robots.txt
492
+ - lib/middleman/templates/html5.rb
493
+ - lib/middleman/templates/html5/config.ru
494
+ - lib/middleman/templates/html5/config.tt
495
+ - lib/middleman/templates/html5/public/404.html
496
+ - lib/middleman/templates/html5/public/apple-touch-icon.png
497
+ - lib/middleman/templates/html5/public/crossdomain.xml
498
+ - lib/middleman/templates/html5/public/css/handheld.css
499
+ - lib/middleman/templates/html5/public/css/style.css
500
+ - lib/middleman/templates/html5/public/favicon.ico
501
+ - lib/middleman/templates/html5/public/humans.txt
502
+ - lib/middleman/templates/html5/public/images/.gitignore
503
+ - lib/middleman/templates/html5/public/index.html
504
+ - lib/middleman/templates/html5/public/js/libs/dd_belatedpng.js
505
+ - lib/middleman/templates/html5/public/js/libs/jquery-1.5.0.js
506
+ - lib/middleman/templates/html5/public/js/libs/jquery-1.5.0.min.js
507
+ - lib/middleman/templates/html5/public/js/libs/modernizr-1.6.min.js
508
+ - lib/middleman/templates/html5/public/js/mylibs/.gitignore
509
+ - lib/middleman/templates/html5/public/js/plugins.js
510
+ - lib/middleman/templates/html5/public/js/script.js
511
+ - lib/middleman/templates/html5/public/robots.txt
508
512
  - lib/middleman/version.rb
509
513
  - middleman.gemspec
510
514
  has_rdoc: true
@@ -528,14 +532,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
528
532
  required_rubygems_version: !ruby/object:Gem::Requirement
529
533
  none: false
530
534
  requirements:
531
- - - ">"
535
+ - - ">="
532
536
  - !ruby/object:Gem::Version
533
- hash: 25
537
+ hash: 3
534
538
  segments:
535
- - 1
536
- - 3
537
- - 1
538
- version: 1.3.1
539
+ - 0
540
+ version: "0"
539
541
  requirements: []
540
542
 
541
543
  rubyforge_project: middleman