mirror of
				https://github.com/middleman/middleman.git
				synced 2022-11-09 12:20:27 -05:00 
			
		
		
		
	WIP
This commit is contained in:
		
							parent
							
								
									776681f42a
								
							
						
					
					
						commit
						3fee617946
					
				
					 18 changed files with 19 additions and 147 deletions
				
			
		| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
# master
 | 
			
		||||
# Unreleased 4.x
 | 
			
		||||
 | 
			
		||||
# 4.4.0
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -7,6 +7,8 @@
 | 
			
		|||
- Require ActiveSupport 6.1+ (required for Ruby 3.0)
 | 
			
		||||
- Drop Ruby 2.5 support (required by activesupport 6.x)
 | 
			
		||||
- Replace URI.escape with WEBrick::HTTPUtils.escape (#2383)
 | 
			
		||||
- Drop Stylus support
 | 
			
		||||
- Drop Less support
 | 
			
		||||
 | 
			
		||||
# 4.3.11
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										4
									
								
								Gemfile
									
										
									
									
									
								
							
							
						
						
									
										4
									
								
								Gemfile
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -23,14 +23,12 @@ gem 'haml', '~> 4.0', require: false
 | 
			
		|||
gem 'kramdown', '~> 1.2', require: false
 | 
			
		||||
gem 'liquid', '~> 3.0', require: false
 | 
			
		||||
gem 'redcarpet', '>= 3.1', require: false
 | 
			
		||||
gem 'sinatra', '>= 2.0.0.beta2', require: false
 | 
			
		||||
gem 'sinatra', '~> 2.0', require: false
 | 
			
		||||
gem 'slim', '>= 2.0', require: false
 | 
			
		||||
gem 'stylus', '>= 1.0', require: false
 | 
			
		||||
 | 
			
		||||
# Dns server to test preview server
 | 
			
		||||
gem 'rubydns', '~> 1.0.1', require: false
 | 
			
		||||
 | 
			
		||||
# For less, note there is no compatible JS runtime for windows
 | 
			
		||||
# gem 'therubyracer', '>= 0.12', platforms: :ruby
 | 
			
		||||
gem 'therubyrhino', '>= 2.0', platforms: :jruby
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -212,10 +212,6 @@ GEM
 | 
			
		|||
    slim (4.1.0)
 | 
			
		||||
      temple (>= 0.7.6, < 0.9)
 | 
			
		||||
      tilt (>= 2.0.6, < 2.1)
 | 
			
		||||
    stylus (1.0.2)
 | 
			
		||||
      execjs
 | 
			
		||||
      stylus-source
 | 
			
		||||
    stylus-source (0.54.5)
 | 
			
		||||
    sync (0.5.0)
 | 
			
		||||
    sys-uname (1.2.2)
 | 
			
		||||
      ffi (~> 1.1)
 | 
			
		||||
| 
						 | 
				
			
			@ -265,9 +261,8 @@ DEPENDENCIES
 | 
			
		|||
  rspec (~> 3.0)
 | 
			
		||||
  rubydns (~> 1.0.1)
 | 
			
		||||
  simplecov (~> 0.10)
 | 
			
		||||
  sinatra (>= 2.0.0.beta2)
 | 
			
		||||
  sinatra (~> 2.0)
 | 
			
		||||
  slim (>= 2.0)
 | 
			
		||||
  stylus (>= 1.0)
 | 
			
		||||
  therubyrhino (>= 2.0)
 | 
			
		||||
  yard (~> 0.9.20)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,7 +43,7 @@ Feature: Templates should be chainable
 | 
			
		|||
    """
 | 
			
		||||
    Then I should see:
 | 
			
		||||
    """
 | 
			
		||||
    <h2 id="my-partial">My Partial</h2>
 | 
			
		||||
    <h2>My Partial</h2>
 | 
			
		||||
    """
 | 
			
		||||
    Then I should see:
 | 
			
		||||
    """
 | 
			
		||||
| 
						 | 
				
			
			@ -68,11 +68,11 @@ Feature: Templates should be chainable
 | 
			
		|||
    When I go to "/my_template.html"
 | 
			
		||||
    Then I should see:
 | 
			
		||||
    """
 | 
			
		||||
    <h1 id="my-template">My Template</h1>
 | 
			
		||||
    <h1>My Template</h1>
 | 
			
		||||
    """
 | 
			
		||||
    Then I should see:
 | 
			
		||||
    """
 | 
			
		||||
    <h2 id="my-partial">My Partial</h2>
 | 
			
		||||
    <h2>My Partial</h2>
 | 
			
		||||
    """
 | 
			
		||||
    Then I should see:
 | 
			
		||||
    """
 | 
			
		||||
| 
						 | 
				
			
			@ -97,7 +97,7 @@ Feature: Templates should be chainable
 | 
			
		|||
    When I go to "/my_template.html"
 | 
			
		||||
    Then I should see:
 | 
			
		||||
    """
 | 
			
		||||
    <h1 id="my-template">My Template</h1>
 | 
			
		||||
    <h1>My Template</h1>
 | 
			
		||||
    """
 | 
			
		||||
    Then I should see:
 | 
			
		||||
    """
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,54 +0,0 @@
 | 
			
		|||
Feature: Stylus Updates and Partials
 | 
			
		||||
  Scenario: The preview server should update stylesheets when Stylus changes
 | 
			
		||||
    Given the Server is running at "stylus-preview-app"
 | 
			
		||||
    And the file "source/stylesheets/plain.css.styl" has the contents
 | 
			
		||||
      """
 | 
			
		||||
      red
 | 
			
		||||
        color: #f0f0f0
 | 
			
		||||
      """
 | 
			
		||||
    When I go to "/stylesheets/plain.css"
 | 
			
		||||
    Then I should see "color: #f0f0f0;"
 | 
			
		||||
    And the file "source/stylesheets/plain.css.styl" has the contents
 | 
			
		||||
      """
 | 
			
		||||
      red
 | 
			
		||||
        color: #0f0f0f
 | 
			
		||||
      """
 | 
			
		||||
    When I go to "/stylesheets/plain.css"
 | 
			
		||||
    Then I should see "color: #0f0f0f;"
 | 
			
		||||
 | 
			
		||||
  Scenario: The preview server should update stylesheets when Stylus partials change
 | 
			
		||||
    Given the Server is running at "stylus-preview-app"
 | 
			
		||||
    And the file "source/stylesheets/main.css.styl" has the contents
 | 
			
		||||
      """
 | 
			
		||||
      @import '_partial'
 | 
			
		||||
 | 
			
		||||
      red
 | 
			
		||||
        color: #f0f0f0
 | 
			
		||||
      """
 | 
			
		||||
    And the file "source/stylesheets/_partial.styl" has the contents
 | 
			
		||||
      """
 | 
			
		||||
      body
 | 
			
		||||
        font-size: 14px
 | 
			
		||||
      """
 | 
			
		||||
    When I go to "/stylesheets/main.css"
 | 
			
		||||
    Then I should see "color: #f0f0f0;"
 | 
			
		||||
    And I should see "font-size: 14px;"
 | 
			
		||||
    And the file "source/stylesheets/main.css.styl" has the contents
 | 
			
		||||
      """
 | 
			
		||||
      @import '_partial'
 | 
			
		||||
 | 
			
		||||
      red
 | 
			
		||||
        color: #0f0f0f
 | 
			
		||||
      """
 | 
			
		||||
    And the file "source/stylesheets/_partial.styl" has the contents
 | 
			
		||||
      """
 | 
			
		||||
      body
 | 
			
		||||
        font-size: 18px
 | 
			
		||||
      """
 | 
			
		||||
    When I go to "/stylesheets/main.css"
 | 
			
		||||
    Then I should see "color: #0f0f0f;"
 | 
			
		||||
    And I should see "font-size: 18px"
 | 
			
		||||
 | 
			
		||||
  Scenario: Stylus partials should work when building
 | 
			
		||||
    Given a successfully built app at "stylus-preview-app"
 | 
			
		||||
    Then the file "build/stylesheets/main.css" should contain "font-size: 18px"
 | 
			
		||||
| 
						 | 
				
			
			@ -1,5 +0,0 @@
 | 
			
		|||
---
 | 
			
		||||
layout: false
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
Hola Mundo
 | 
			
		||||
| 
						 | 
				
			
			@ -1,2 +0,0 @@
 | 
			
		|||
body
 | 
			
		||||
  font-size: 18px
 | 
			
		||||
| 
						 | 
				
			
			@ -1,2 +0,0 @@
 | 
			
		|||
body
 | 
			
		||||
  font-size: 18px
 | 
			
		||||
| 
						 | 
				
			
			@ -1,4 +0,0 @@
 | 
			
		|||
@import '_partial'
 | 
			
		||||
 | 
			
		||||
red
 | 
			
		||||
  color: blue
 | 
			
		||||
| 
						 | 
				
			
			@ -1,4 +0,0 @@
 | 
			
		|||
//= require "_partial2.css.styl"
 | 
			
		||||
 | 
			
		||||
red
 | 
			
		||||
  color: blue
 | 
			
		||||
| 
						 | 
				
			
			@ -1,2 +0,0 @@
 | 
			
		|||
red
 | 
			
		||||
  color: blue
 | 
			
		||||
| 
						 | 
				
			
			@ -2,7 +2,7 @@ module Middleman
 | 
			
		|||
  module CoreExtensions
 | 
			
		||||
    module Collections
 | 
			
		||||
      class LazyCollectorStep < BasicObject
 | 
			
		||||
        DELEGATE = [:hash, :eql?].freeze
 | 
			
		||||
        DELEGATE = [:hash, :eql?,].freeze
 | 
			
		||||
 | 
			
		||||
        def initialize(name, args, block, parent=nil)
 | 
			
		||||
          @name = name
 | 
			
		||||
| 
						 | 
				
			
			@ -37,6 +37,11 @@ module Middleman
 | 
			
		|||
          data.send(@name, *@args.deep_dup, &b)
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        def to_str
 | 
			
		||||
          require "pry"
 | 
			
		||||
          binding.pry
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        def method_missing(name, *args, &block)
 | 
			
		||||
          return ::Kernel.send(name, *args, &block) if DELEGATE.include? name
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,6 +6,7 @@ require 'padrino-helpers/format_helpers'
 | 
			
		|||
require 'padrino-helpers/number_helpers'
 | 
			
		||||
require 'padrino-helpers/output_helpers'
 | 
			
		||||
require 'padrino-helpers/render_helpers'
 | 
			
		||||
require 'active_support/core_ext/array/extract_options'
 | 
			
		||||
require 'middleman-core/contracts'
 | 
			
		||||
 | 
			
		||||
# Don't fail on invalid locale, that's not what our current
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,14 +42,4 @@ Middleman::Extensions.register :slim_renderer, auto_activate: :before_configurat
 | 
			
		|||
  Middleman::Renderers::Slim
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# Less Support
 | 
			
		||||
Middleman::Extensions.register :less_renderer, auto_activate: :before_configuration do
 | 
			
		||||
  require 'middleman-core/renderers/less'
 | 
			
		||||
  Middleman::Renderers::Less
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# Stylus Support
 | 
			
		||||
Middleman::Extensions.register :stylus_renderer, auto_activate: :before_configuration do
 | 
			
		||||
  require 'middleman-core/renderers/stylus'
 | 
			
		||||
  Middleman::Renderers::Stylus
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,36 +0,0 @@
 | 
			
		|||
require 'less'
 | 
			
		||||
 | 
			
		||||
module Middleman
 | 
			
		||||
  module Renderers
 | 
			
		||||
    # Sass renderer
 | 
			
		||||
    class Less < ::Middleman::Extension
 | 
			
		||||
      define_setting :less, {}, 'LESS compiler options'
 | 
			
		||||
 | 
			
		||||
      def initialize(app, options={}, &block)
 | 
			
		||||
        super
 | 
			
		||||
 | 
			
		||||
        # Tell Tilt to use it as well (for inline sass blocks)
 | 
			
		||||
        ::Tilt.register 'less', LocalLoadingLessTemplate
 | 
			
		||||
        ::Tilt.prefer(LocalLoadingLessTemplate)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def after_configuration
 | 
			
		||||
        app.files.by_type(:source).watchers.each do |source|
 | 
			
		||||
          ::Less.paths << (source.directory + app.config[:css_dir]).to_s
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      # A SassTemplate for Tilt which outputs debug messages
 | 
			
		||||
      class LocalLoadingLessTemplate < ::Tilt::LessTemplate
 | 
			
		||||
        def prepare
 | 
			
		||||
          if ::Less.const_defined? :Engine
 | 
			
		||||
            @engine = ::Less::Engine.new(data)
 | 
			
		||||
          else
 | 
			
		||||
            parser = ::Less::Parser.new({}.merge!(options).merge!(filename: eval_file, line: line, paths: ['.', File.dirname(eval_file)]))
 | 
			
		||||
            @engine = parser.parse(data)
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -1,10 +0,0 @@
 | 
			
		|||
require 'stylus'
 | 
			
		||||
require 'stylus/tilt'
 | 
			
		||||
 | 
			
		||||
module Middleman
 | 
			
		||||
  module Renderers
 | 
			
		||||
    class Stylus < ::Middleman::Extension
 | 
			
		||||
      define_setting :styl, {}, 'Stylus config options'
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -99,8 +99,8 @@ module Middleman
 | 
			
		|||
    # @param [Hash] options
 | 
			
		||||
    # @param [Proc] block A block will be evaluated to return internal contents.
 | 
			
		||||
    # @return [String]
 | 
			
		||||
    Contract Any, Or[Symbol, String], Hash => String, Maybe[Proc] => String
 | 
			
		||||
    def render(_, name, options={}, &block)
 | 
			
		||||
    Contract Any, Or[Symbol, String], Hash, Hash, Maybe[Proc] => String
 | 
			
		||||
    def render(_, name, options={}, locals={}, &block)
 | 
			
		||||
      name = name.to_s
 | 
			
		||||
 | 
			
		||||
      partial_file = locate_partial(name, false) || locate_partial(name, true)
 | 
			
		||||
| 
						 | 
				
			
			@ -114,7 +114,7 @@ module Middleman
 | 
			
		|||
        partial_file.read
 | 
			
		||||
      else
 | 
			
		||||
        opts = options.dup
 | 
			
		||||
        locs = opts.delete(:locals)
 | 
			
		||||
        locs = locals.dup
 | 
			
		||||
 | 
			
		||||
        render_file(partial_file, locs, opts, &block)
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue