sculptor 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.editorconfig +10 -0
- data/Gemfile +0 -1
- data/Guardfile +5 -0
- data/Rakefile +1 -0
- data/bin/sculptor +14 -0
- data/features/create.feature +36 -0
- data/features/step_definitions/custom.rb +3 -0
- data/features/support/setup.rb +5 -0
- data/lib/sculptor/cli/create.rb +54 -0
- data/lib/sculptor/cli/init.rb +73 -0
- data/lib/sculptor/cli/server.rb +5 -0
- data/lib/sculptor/cli.rb +52 -0
- data/lib/sculptor/extensions/data_loaders.rb +53 -0
- data/lib/sculptor/extensions/model.rb +54 -0
- data/lib/sculptor/extensions/resource_helpers.rb +61 -0
- data/lib/sculptor/extensions.rb +8 -0
- data/lib/sculptor/load_paths.rb +53 -0
- data/lib/sculptor/method_missing.rb +6 -0
- data/lib/sculptor/templates/glyptotheque/.bowerrc +3 -0
- data/lib/sculptor/templates/glyptotheque/.editorconfig +10 -0
- data/lib/sculptor/templates/glyptotheque/.gitignore +1 -0
- data/lib/sculptor/templates/glyptotheque/Gemfile.tt +22 -0
- data/lib/sculptor/templates/glyptotheque/bower.json +11 -0
- data/lib/sculptor/templates/glyptotheque/config.tt +126 -0
- data/lib/sculptor/templates/glyptotheque/data/.gitkeep +0 -0
- data/lib/sculptor/templates/glyptotheque/source/assets/img/.gitkeep +0 -0
- data/lib/sculptor/templates/glyptotheque/source/assets/js/app.js +5 -0
- data/lib/sculptor/templates/glyptotheque/source/assets/js/glyptotheque/controllers.js +1 -0
- data/lib/sculptor/templates/glyptotheque/source/assets/js/glyptotheque/directives.js +29 -0
- data/lib/sculptor/templates/glyptotheque/source/assets/js/glyptotheque.js +3 -0
- data/lib/sculptor/templates/glyptotheque/source/assets/styles/glyptotheque/_$variables.scss +2 -0
- data/lib/sculptor/templates/glyptotheque/source/assets/styles/glyptotheque/_base.scss +14 -0
- data/lib/sculptor/templates/glyptotheque/source/assets/styles/glyptotheque/_model.scss +145 -0
- data/lib/sculptor/templates/glyptotheque/source/assets/styles/glyptotheque/_nav.scss +104 -0
- data/lib/sculptor/templates/glyptotheque/source/assets/styles/glyptotheque.scss +6 -0
- data/lib/sculptor/templates/glyptotheque/source/assets/styles/main.scss +14 -0
- data/lib/sculptor/templates/glyptotheque/source/assets/styles/pygments/borland.css +46 -0
- data/lib/sculptor/templates/glyptotheque/source/assets/styles/pygments/colorful.css +61 -0
- data/lib/sculptor/templates/glyptotheque/source/assets/styles/pygments/github.css +61 -0
- data/lib/sculptor/templates/glyptotheque/source/assets/styles/pygments/trac.css +59 -0
- data/lib/sculptor/templates/glyptotheque/source/index.html.slim +3 -0
- data/lib/sculptor/templates/glyptotheque/source/layouts/glyptotheque.slim +8 -0
- data/lib/sculptor/templates/glyptotheque/source/layouts/layout.slim +18 -0
- data/lib/sculptor/templates/glyptotheque/source/partials/glyptotheque/_model-index.slim +11 -0
- data/lib/sculptor/templates/glyptotheque/source/partials/glyptotheque/_model-source.slim +5 -0
- data/lib/sculptor/templates/glyptotheque/source/partials/glyptotheque/_model.slim +23 -0
- data/lib/sculptor/templates/glyptotheque/source/partials/glyptotheque/_nav.slim +14 -0
- data/lib/sculptor/templates/glyptotheque.rb +34 -0
- data/lib/sculptor/templates/model/data.tt +4 -0
- data/lib/sculptor/templates/model/index-template.tt +5 -0
- data/lib/sculptor/templates/model/styles.tt +12 -0
- data/lib/sculptor/templates/model/template.tt +34 -0
- data/lib/sculptor/templates.rb +1 -0
- data/lib/sculptor/version.rb +1 -1
- data/lib/sculptor.rb +6 -5
- data/sculptor.gemspec +13 -1
- metadata +240 -12
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NmYzYTM2Yjg3ZDlkMDJiYTYwMDVhNmRlODYwZGVlMjg4ZmJhOWI0ZA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e8892ec5089d558ff641359ff69733d048e314ef
|
4
|
+
data.tar.gz: 67d2fc8ee63e505b326ac3d7e656b7fc92ad4156
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NDVmOWI3NDU3Yjc3NmUyM2QyNTdjMDM2M2NmNjI5ZjU0Yjk0OWJiMWZjMTdl
|
11
|
-
NmQ4OWZjMGE5Y2QwMjZiYjQ5OTVmN2E4MTI2MTJlZWI0OTEzMmY=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
N2FjOWVlYzhjNjNmZmIyZGI2ZWNmODJjNzIwNzU1YTNkNDc5MjE0ZDM4MWQ4
|
14
|
-
MDM1OTllNzVkYmQ1NmJlZmQxN2JhNDBmMmY2MzdkN2IyZTNlOGI3YjNlNmU1
|
15
|
-
Yzg3ZGNhMjNlNjFjMGRhZTA0OTI2MTI1YWFlOThmM2FmN2Y5Njg=
|
6
|
+
metadata.gz: b88e45b635671467b563f201163d0a65e99315347f3044e0b3615a9eec54d6e6a25933850adf7cefc96fab4e7acf3e59d1ae9c259b37e74d42cdafe12ca481d5
|
7
|
+
data.tar.gz: 5080d19bf694387499df1975c8f889aa04d1b2d45fbbdc5b3657bd1226aff5ac7d9470edf8bfb87536d05e0870bb604dec41021c34474af420fd1ec0ce7927ea
|
data/.editorconfig
ADDED
data/Gemfile
CHANGED
data/Guardfile
ADDED
data/Rakefile
CHANGED
data/bin/sculptor
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'middleman-core/profiling'
|
4
|
+
if ARGV.include? '--profile'
|
5
|
+
Middleman::Profiling.profiler = Middleman::Profiling::RubyProfProfiler.new
|
6
|
+
end
|
7
|
+
Middleman::Profiling.start
|
8
|
+
|
9
|
+
require "sculptor/load_paths"
|
10
|
+
Sculptor.setup_load_paths
|
11
|
+
|
12
|
+
require 'sculptor/cli'
|
13
|
+
|
14
|
+
Sculptor::CLI::Base.start
|
@@ -0,0 +1,36 @@
|
|
1
|
+
Feature: Run `create` command
|
2
|
+
In order to create new models
|
3
|
+
|
4
|
+
Scenario: Create a new model scaffold
|
5
|
+
Given I run `sculptor create test` interactively
|
6
|
+
Then I wait for output to contain "Creating model: source/test"
|
7
|
+
And I wait for output to contain "Title"
|
8
|
+
Then I hit enter
|
9
|
+
And I wait for output to contain "Description"
|
10
|
+
Then I hit enter
|
11
|
+
And I wait for output to contain "Stylesheet"
|
12
|
+
Then I hit enter
|
13
|
+
And I wait for output to contain "Include data?"
|
14
|
+
Then I type "n"
|
15
|
+
And the exit status should be 0
|
16
|
+
Then the output should contain "create"
|
17
|
+
|
18
|
+
Scenario: Create a new model scaffold and set meta data
|
19
|
+
Given I run `sculptor create test` interactively
|
20
|
+
Then I wait for output to contain "Creating model: source/test"
|
21
|
+
And I wait for output to contain "Title"
|
22
|
+
Then I type "Hello World"
|
23
|
+
And I wait for output to contain "Description"
|
24
|
+
Then I type "My model description"
|
25
|
+
And I wait for output to contain "Stylesheet"
|
26
|
+
Then I type "styles"
|
27
|
+
And I wait for output to contain "Include data?"
|
28
|
+
Then I type "y"
|
29
|
+
And the exit status should be 0
|
30
|
+
Then the output should contain "create"
|
31
|
+
And a directory named "source/test" should exist
|
32
|
+
Then the file "source/test/test.html.slim" should contain "Hello World"
|
33
|
+
And the file "source/test/test.html.slim" should contain "My model description"
|
34
|
+
And the file "source/test/index.html.slim" should contain "'partials/glyptotheque/model-index', locals: { dir: '/test' }"
|
35
|
+
And the file "source/test/test.yaml" should contain "hello: World"
|
36
|
+
And the file "source/test/styles.scss" should contain "@import 'bourbon'"
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Sculptor::CLI
|
2
|
+
class Create < Thor
|
3
|
+
include Thor::Actions
|
4
|
+
|
5
|
+
check_unknown_options!
|
6
|
+
|
7
|
+
namespace :create
|
8
|
+
|
9
|
+
def self.source_root
|
10
|
+
File.join(File.dirname(__FILE__), '..', 'templates', 'model')
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.exit_on_failure?
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'create NAME', 'Create new model NAME'
|
18
|
+
def create(name)
|
19
|
+
model_path = "source/#{name}"
|
20
|
+
|
21
|
+
say(set_color("Creating model: ", :yellow) + set_color(model_path, :white, :bold))
|
22
|
+
|
23
|
+
is_subdir = name.split('/').count > 1
|
24
|
+
parent_path = is_subdir ? model_path.split('/')[0..-2].join('/') : model_path
|
25
|
+
|
26
|
+
@name = name
|
27
|
+
@title = options[:title] || ask('Title: ')
|
28
|
+
@description = options[:desc] || ask('Description: ')
|
29
|
+
@stylesheet = ask('Stylesheet: ')
|
30
|
+
@dir = is_subdir ? name.split('/')[0..-2].join('/') : name
|
31
|
+
|
32
|
+
@has_data = if yes?('Include data?')
|
33
|
+
@model_name = name.split('/').last
|
34
|
+
template 'data', (is_subdir ? model_path : File.join(model_path, name)) + '.yaml'
|
35
|
+
end
|
36
|
+
|
37
|
+
template 'template', (is_subdir ? model_path : File.join(model_path, name)) + '.html.slim'
|
38
|
+
|
39
|
+
has_index = File.file?(File.join(parent_path, 'index.html.slim'))
|
40
|
+
unless has_index
|
41
|
+
template 'index-template', (is_subdir ? File.join(parent_path, 'index') : File.join(model_path, 'index')) + '.html.slim'
|
42
|
+
end
|
43
|
+
|
44
|
+
unless @stylesheet.empty?
|
45
|
+
stylesheet_path = is_subdir ? Pathname(model_path).join("../#{@stylesheet}").to_s : File.join(model_path, "#{@stylesheet}")
|
46
|
+
template 'styles', "#{stylesheet_path}.scss" unless File.file? "#{stylesheet_path}.scss"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
Base.map(
|
51
|
+
'c' => 'create'
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'sculptor/templates'
|
2
|
+
|
3
|
+
# Copied from `middleman-core/lib/middleman-core/cli/init.rb`
|
4
|
+
# in order to modify default template
|
5
|
+
module Middleman::Cli
|
6
|
+
# A thor task for creating new projects
|
7
|
+
class Init < Thor
|
8
|
+
check_unknown_options!
|
9
|
+
|
10
|
+
namespace :init
|
11
|
+
|
12
|
+
desc 'init NAME [options]', 'Create new project NAME'
|
13
|
+
available_templates = ::Middleman::Templates.registered.keys.join(', ')
|
14
|
+
method_option 'template',
|
15
|
+
aliases: '-T',
|
16
|
+
default: 'glyptotheque',
|
17
|
+
desc: "Use a project template: #{available_templates}"
|
18
|
+
method_option 'css_dir',
|
19
|
+
# :default => "stylesheets",
|
20
|
+
desc: 'The path to the css files'
|
21
|
+
method_option 'js_dir',
|
22
|
+
# :default => "javascripts",
|
23
|
+
desc: 'The path to the javascript files'
|
24
|
+
method_option 'images_dir',
|
25
|
+
# :default => "images",
|
26
|
+
desc: 'The path to the image files'
|
27
|
+
method_option 'rack',
|
28
|
+
type: :boolean,
|
29
|
+
default: false,
|
30
|
+
desc: 'Include a config.ru file'
|
31
|
+
method_option 'skip-gemfile',
|
32
|
+
type: :boolean,
|
33
|
+
default: false,
|
34
|
+
desc: "Don't create a Gemfile"
|
35
|
+
method_option 'skip-bundle',
|
36
|
+
type: :boolean,
|
37
|
+
aliases: '-B',
|
38
|
+
default: false,
|
39
|
+
desc: "Don't run bundle install"
|
40
|
+
method_option 'skip-git',
|
41
|
+
type: :boolean,
|
42
|
+
default: false,
|
43
|
+
desc: 'Skip Git ignores and keeps'
|
44
|
+
# The init task
|
45
|
+
# @param [String] name
|
46
|
+
def init(name='.')
|
47
|
+
key = options[:template].to_sym
|
48
|
+
unless ::Middleman::Templates.registered.key?(key)
|
49
|
+
raise Thor::Error, "Unknown project template '#{key}'"
|
50
|
+
end
|
51
|
+
|
52
|
+
thor_group = ::Middleman::Templates.registered[key]
|
53
|
+
thor_group.new([name], options).invoke_all
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.exit_on_failure?
|
58
|
+
true
|
59
|
+
end
|
60
|
+
|
61
|
+
# Map "i", "new" and "n" to "init"
|
62
|
+
Base.map(
|
63
|
+
'i' => 'init',
|
64
|
+
'new' => 'init',
|
65
|
+
'n' => 'init'
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
module Sculptor::CLI
|
70
|
+
class Init < Thor
|
71
|
+
register(Middleman::Cli::Init, :init, "init NAME", "Create new project NAME")
|
72
|
+
end
|
73
|
+
end
|
data/lib/sculptor/cli.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'middleman-core/version'
|
3
|
+
require 'middleman-core/cli'
|
4
|
+
|
5
|
+
module Sculptor
|
6
|
+
module CLI
|
7
|
+
class Base < Middleman::Cli::Base
|
8
|
+
desc 'version', 'Show version'
|
9
|
+
def version
|
10
|
+
say "Sculptor #{Sculptor::VERSION} (Middleman #{Middleman::VERSION})"
|
11
|
+
end
|
12
|
+
|
13
|
+
def help(meth=nil, subcommand=false)
|
14
|
+
if meth && !self.respond_to?(meth)
|
15
|
+
klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}")
|
16
|
+
klass.start(['-h', task].compact, shell: shell)
|
17
|
+
else
|
18
|
+
list = []
|
19
|
+
Thor::Util.thor_classes_in(Sculptor::CLI).each do |thor_class|
|
20
|
+
list += thor_class.printable_tasks(false)
|
21
|
+
end
|
22
|
+
list.sort! { |a, b| a[0] <=> b[0] }
|
23
|
+
|
24
|
+
shell.say "\n"
|
25
|
+
shell.print_table(list, ident: 2, truncate: true)
|
26
|
+
shell.say
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Intercept missing methods and search subtasks for them
|
31
|
+
# @param [Symbol] meth
|
32
|
+
def method_missing(meth, *args)
|
33
|
+
meth = meth.to_s
|
34
|
+
meth = self.class.map[meth] if self.class.map.key?(meth)
|
35
|
+
|
36
|
+
klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}")
|
37
|
+
|
38
|
+
if klass.nil?
|
39
|
+
raise Thor::Error, "There's no '#{meth}' command for Sculptor. Try 'sculptor help' for a list of commands."
|
40
|
+
else
|
41
|
+
args.unshift(task) if task
|
42
|
+
klass.start(args, shell: shell)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
require 'sculptor/version'
|
50
|
+
require 'sculptor/cli/create'
|
51
|
+
require 'sculptor/cli/init'
|
52
|
+
require 'sculptor/cli/server'
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class Middleman::Extensions::DataLoaders < ::Middleman::Extension
|
2
|
+
def initialize(app, options_hash={})
|
3
|
+
super
|
4
|
+
|
5
|
+
require 'open-uri'
|
6
|
+
end
|
7
|
+
|
8
|
+
helpers do
|
9
|
+
def pwd
|
10
|
+
File.dirname(File.expand_path(current_page.path, root))
|
11
|
+
end
|
12
|
+
|
13
|
+
def load_data(path, options = nil)
|
14
|
+
resource = if path.start_with? 'http'
|
15
|
+
load_remote_data(path, options)
|
16
|
+
else
|
17
|
+
sitemap.find_resource_by_path(relative_dir(current_page.path, path).to_s)
|
18
|
+
end
|
19
|
+
|
20
|
+
raise "#{path} not found" unless resource
|
21
|
+
|
22
|
+
if ['.yaml', '.yml'].include? resource.ext
|
23
|
+
yaml = resource.render
|
24
|
+
elsif resource.ext == '.json'
|
25
|
+
json = resource.render
|
26
|
+
end
|
27
|
+
|
28
|
+
if json
|
29
|
+
JSON.parse(resource.render)
|
30
|
+
elsif yaml
|
31
|
+
YAML.load(resource.render)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def load_remote_data(url, options)
|
38
|
+
begin
|
39
|
+
if(options)
|
40
|
+
resource = open(url, http_basic_authentication: [options[:user], options[:password]])
|
41
|
+
else
|
42
|
+
resource = open(url)
|
43
|
+
end
|
44
|
+
rescue
|
45
|
+
raise "Couldn't load the remote: #{url}."
|
46
|
+
end
|
47
|
+
{
|
48
|
+
ext: '.json',
|
49
|
+
render: resource.read
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class Middleman::Extensions::Model < ::Middleman::Extension
|
2
|
+
def initialize(app, options_hash={})
|
3
|
+
super
|
4
|
+
|
5
|
+
require 'open-uri'
|
6
|
+
require 'nokogiri'
|
7
|
+
end
|
8
|
+
|
9
|
+
helpers do
|
10
|
+
# Requires one of `&block` or `url + selector`
|
11
|
+
# Parameters:
|
12
|
+
# * `title` (optional) - Model title
|
13
|
+
# * `description` (optional) - Model description
|
14
|
+
# * `component_url` (optional) - Model URL
|
15
|
+
# * `component_selector` (required if `url` is provided)
|
16
|
+
# * `&block` (optional)
|
17
|
+
def model(options={}, &block)
|
18
|
+
[:title, :description].each { |k| options[k] ||= nil }
|
19
|
+
|
20
|
+
if block_given?
|
21
|
+
html = capture_html(&block)
|
22
|
+
metadata = options
|
23
|
+
elsif options[:component]
|
24
|
+
component_path = "components/#{options[:component]}"
|
25
|
+
resource = sitemap.find_resource_by_path("#{component_path}.html")
|
26
|
+
metadata = resource.metadata.page
|
27
|
+
html = resource.render
|
28
|
+
elsif options[:component_url] && options[:component_selector]
|
29
|
+
metadata = options
|
30
|
+
doc = Nokogiri::HTML(open(options[:component_url]))
|
31
|
+
result = doc.css(options[:component_selector])
|
32
|
+
if result.empty?
|
33
|
+
raise "Selector `#{options[:component_selector]}` not found in remote location`#{options[:component_url]}`"
|
34
|
+
end
|
35
|
+
html = result.to_html
|
36
|
+
else
|
37
|
+
raise "Model `#{options[:title]}`: No `component` of HTML block was given"
|
38
|
+
end
|
39
|
+
|
40
|
+
options.reverse_merge!(metadata.symbolize_keys!)
|
41
|
+
options[:html] = html
|
42
|
+
|
43
|
+
options[:source_code] = html unless options.has_key? :source_code
|
44
|
+
options[:source_type] ||= 'html'
|
45
|
+
|
46
|
+
partial('partials/glyptotheque/model', locals: options)
|
47
|
+
end
|
48
|
+
|
49
|
+
def model_source(type, &block)
|
50
|
+
source_code = capture_html(&block)
|
51
|
+
partial('partials/glyptotheque/model-source', locals: { source_type: type, source_code: source_code })
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class Middleman::Extensions::ResourceHelpers < ::Middleman::Extension
|
2
|
+
helpers do
|
3
|
+
def include_stylesheets(stylesheets)
|
4
|
+
return unless stylesheets && stylesheets.is_a?(Array) && stylesheets.length > 0
|
5
|
+
stylesheets.map { |s|
|
6
|
+
include_stylesheet(s)
|
7
|
+
}.join("\n")
|
8
|
+
end
|
9
|
+
|
10
|
+
def include_stylesheet(stylesheet)
|
11
|
+
return if stylesheet.empty?
|
12
|
+
stylesheet_link_tag(relative_dir(current_page.path, stylesheet)) + "\n"
|
13
|
+
end
|
14
|
+
|
15
|
+
def include_javascripts(javascripts)
|
16
|
+
return unless javascripts && javascripts.is_a?(Array) && javascripts.length > 0
|
17
|
+
javascripts.map { |j|
|
18
|
+
path = j.start_with?('http') ? j : relative_dir(current_page.path, j)
|
19
|
+
javascript_include_tag(path) + "\n"
|
20
|
+
}.join("\n")
|
21
|
+
end
|
22
|
+
|
23
|
+
# Constructs path relative to base path (first argument)
|
24
|
+
def relative_dir(path, *args)
|
25
|
+
relative_path = args ? args.join('/') : ''
|
26
|
+
Pathname(path).dirname.join(relative_path)
|
27
|
+
end
|
28
|
+
|
29
|
+
def resource_file(resource)
|
30
|
+
resource.path.split('/').last.gsub(resource.ext, '')
|
31
|
+
end
|
32
|
+
|
33
|
+
def resource_dir(resource)
|
34
|
+
resource.url.split('/').last
|
35
|
+
end
|
36
|
+
|
37
|
+
def subpages_for(dir, ext = 'html', exclude_indexes: false)
|
38
|
+
resources = sitemap.resources
|
39
|
+
.select {|r| r.ext == ".#{ext}"} # Select files only HTML files
|
40
|
+
.reject {|r| r.data.hidden} # reject hidden (Front matter)
|
41
|
+
.select {|r| r.url.start_with?(dir)} # Select files in the given dir
|
42
|
+
.sort_by(&:url) # Sort by URL (ensures indexes first)
|
43
|
+
.reject {|r| r.url == dir} # Exclude main directory index
|
44
|
+
|
45
|
+
if exclude_indexes
|
46
|
+
resources = resources.reject {|r| r.directory_index? } # Exclude all directory indexes
|
47
|
+
end
|
48
|
+
|
49
|
+
resources.reject {|r| r.path.end_with? ("-full#{r.ext}")} # Ignore proxied '-full' mode pages
|
50
|
+
end
|
51
|
+
|
52
|
+
# Use in layouts, in templates either Frontmatter or this method can be used
|
53
|
+
def append_class(block_name, appended_classes='')
|
54
|
+
current_page_classes = current_page.data[block_name] || ''
|
55
|
+
existing_classes_a = current_page_classes.split(' ')
|
56
|
+
appended_classes_a = appended_classes.split(' ')
|
57
|
+
classes = existing_classes_a.concat(appended_classes_a).reverse.join(' ')
|
58
|
+
content_for(block_name, classes)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'sculptor/extensions/model'
|
2
|
+
Middleman::Extensions::Model.register
|
3
|
+
|
4
|
+
require 'sculptor/extensions/data_loaders'
|
5
|
+
Middleman::Extensions::DataLoaders.register
|
6
|
+
|
7
|
+
require 'sculptor/extensions/resource_helpers'
|
8
|
+
Middleman::Extensions::ResourceHelpers.register
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Core Pathname library used for traversal
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
module Sculptor
|
5
|
+
class << self
|
6
|
+
def setup_load_paths
|
7
|
+
@_is_setup ||= begin
|
8
|
+
|
9
|
+
# Only look for config.rb if MM_ROOT isn't set
|
10
|
+
if !ENV['MM_ROOT'] && found_path = locate_root
|
11
|
+
ENV['MM_ROOT'] = found_path
|
12
|
+
end
|
13
|
+
|
14
|
+
is_bundler_setup = false
|
15
|
+
|
16
|
+
# If we've found the root, try to setup Bundler
|
17
|
+
if ENV['MM_ROOT']
|
18
|
+
|
19
|
+
root_gemfile = File.expand_path('Gemfile', ENV['MM_ROOT'])
|
20
|
+
ENV['BUNDLE_GEMFILE'] ||= root_gemfile
|
21
|
+
|
22
|
+
unless File.exist?(ENV['BUNDLE_GEMFILE'])
|
23
|
+
git_gemfile = Pathname.new(__FILE__).expand_path.parent.parent.parent + 'Gemfile'
|
24
|
+
ENV['BUNDLE_GEMFILE'] = git_gemfile.to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
if File.exist?(ENV['BUNDLE_GEMFILE'])
|
28
|
+
is_bundler_setup = true
|
29
|
+
require 'bundler/setup'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Automatically discover extensions in RubyGems
|
34
|
+
require 'middleman-core/extensions'
|
35
|
+
|
36
|
+
if is_bundler_setup
|
37
|
+
Bundler.require
|
38
|
+
else
|
39
|
+
::Middleman.load_extensions_in_path
|
40
|
+
end
|
41
|
+
|
42
|
+
true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Recursive method to find config.rb
|
47
|
+
def locate_root(cwd=Pathname.new(Dir.pwd))
|
48
|
+
return cwd.to_s if (cwd + 'config.rb').exist?
|
49
|
+
return false if cwd.root?
|
50
|
+
locate_root(cwd.parent)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
bower_components
|
@@ -0,0 +1,22 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'sculptor'
|
4
|
+
gem 'middleman'
|
5
|
+
gem 'nokogiri'
|
6
|
+
gem 'middleman-pry'
|
7
|
+
gem 'sass', '~>3.3'
|
8
|
+
gem 'compass', github: 'chriseppstein/compass'
|
9
|
+
gem 'sass-css-importer'
|
10
|
+
gem 'slim'
|
11
|
+
gem 'bourbon'
|
12
|
+
gem 'neat'
|
13
|
+
|
14
|
+
gem 'middleman-syntax', github: 'middleman/middleman-syntax'
|
15
|
+
|
16
|
+
# Custom LiveReload (animate transitions)
|
17
|
+
gem 'rack-livereload',
|
18
|
+
github: 'tyom/rack-livereload',
|
19
|
+
branch: 'livereload-animate'
|
20
|
+
gem 'middleman-livereload',
|
21
|
+
github: 'tyom/middleman-livereload',
|
22
|
+
branch: 'animate-transitions'
|