middleman-sculptor 0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.editorconfig +10 -0
- data/.gitignore +9 -0
- data/Gemfile +3 -0
- data/Rakefile +2 -0
- data/bin/middleman-sculptor +7 -0
- data/bin/sculpt +7 -0
- data/lib/middleman-sculptor.rb +16 -0
- data/lib/middleman-sculptor/cli.rb +57 -0
- data/lib/middleman-sculptor/cli/init.rb +15 -0
- data/lib/middleman-sculptor/cli/version.rb +12 -0
- data/lib/middleman-sculptor/extension.rb +13 -0
- data/lib/middleman-sculptor/hash_dot_syntax.rb +6 -0
- data/lib/middleman-sculptor/helpers/model.rb +110 -0
- data/lib/middleman-sculptor/helpers/outliner.rb +44 -0
- data/lib/middleman-sculptor/helpers/resources.rb +155 -0
- data/lib/middleman-sculptor/resource_patch.rb +49 -0
- data/lib/middleman-sculptor/sprockets_patch.rb +48 -0
- data/lib/middleman-sculptor/template.rb +39 -0
- data/lib/middleman-sculptor/template/.bowerrc +3 -0
- data/lib/middleman-sculptor/template/.editorconfig +10 -0
- data/lib/middleman-sculptor/template/.gitignore +2 -0
- data/lib/middleman-sculptor/template/Gemfile.tt +11 -0
- data/lib/middleman-sculptor/template/bower.json +12 -0
- data/lib/middleman-sculptor/template/config.tt +149 -0
- data/lib/middleman-sculptor/template/data/.gitkeep +0 -0
- data/lib/middleman-sculptor/template/source/assets/images/.gitkeep +0 -0
- data/lib/middleman-sculptor/template/source/assets/scripts/app.js +6 -0
- data/lib/middleman-sculptor/template/source/assets/scripts/glyptotheque.js +8 -0
- data/lib/middleman-sculptor/template/source/assets/scripts/glyptotheque/controllers.js +1 -0
- data/lib/middleman-sculptor/template/source/assets/scripts/glyptotheque/directives.js +124 -0
- data/lib/middleman-sculptor/template/source/assets/scripts/glyptotheque/services.js +1 -0
- data/lib/middleman-sculptor/template/source/assets/scripts/head-js.js +1 -0
- data/lib/middleman-sculptor/template/source/assets/scripts/iframe-js.js +1 -0
- data/lib/middleman-sculptor/template/source/assets/styles/glyptotheque.scss +9 -0
- data/lib/middleman-sculptor/template/source/assets/styles/glyptotheque/_$variables.scss +3 -0
- data/lib/middleman-sculptor/template/source/assets/styles/glyptotheque/_base.scss +58 -0
- data/lib/middleman-sculptor/template/source/assets/styles/glyptotheque/_codehilite.scss +10 -0
- data/lib/middleman-sculptor/template/source/assets/styles/glyptotheque/_html-outline.scss +131 -0
- data/lib/middleman-sculptor/template/source/assets/styles/glyptotheque/_model-utils.scss +78 -0
- data/lib/middleman-sculptor/template/source/assets/styles/glyptotheque/_model.scss +48 -0
- data/lib/middleman-sculptor/template/source/assets/styles/glyptotheque/_nav.scss +172 -0
- data/lib/middleman-sculptor/template/source/assets/styles/main.scss +18 -0
- data/lib/middleman-sculptor/template/source/assets/styles/pygments/borland.css +46 -0
- data/lib/middleman-sculptor/template/source/assets/styles/pygments/colorful.css +61 -0
- data/lib/middleman-sculptor/template/source/assets/styles/pygments/github.css +61 -0
- data/lib/middleman-sculptor/template/source/assets/styles/pygments/trac.css +59 -0
- data/lib/middleman-sculptor/template/source/glyptotheque/_model-outline-element.slim +22 -0
- data/lib/middleman-sculptor/template/source/glyptotheque/_model-outline.slim +3 -0
- data/lib/middleman-sculptor/template/source/glyptotheque/_model-utils.slim +13 -0
- data/lib/middleman-sculptor/template/source/glyptotheque/_model.slim +26 -0
- data/lib/middleman-sculptor/template/source/glyptotheque/_nav.slim +31 -0
- data/lib/middleman-sculptor/template/source/glyptotheque/directory-index.html.slim +14 -0
- data/lib/middleman-sculptor/template/source/glyptotheque/site-index.html.slim +5 -0
- data/lib/middleman-sculptor/template/source/glyptotheque/sitemap.json.erb +1 -0
- data/lib/middleman-sculptor/template/source/layouts/glyptotheque.slim +19 -0
- data/lib/middleman-sculptor/template/source/layouts/isolated.slim +19 -0
- data/lib/middleman-sculptor/template/source/layouts/layout.slim +18 -0
- data/lib/middleman-sculptor/version.rb +5 -0
- data/lib/middleman_extension.rb +1 -0
- data/middleman-sculptor.gemspec +29 -0
- metadata +197 -0
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'middleman-core/sitemap/resource'
|
2
|
+
# This method is patched to make Middleman output the correct path
|
3
|
+
# when rendering multiple pages via proxy
|
4
|
+
module Middleman
|
5
|
+
module Sitemap
|
6
|
+
class Resource
|
7
|
+
# Render this resource
|
8
|
+
# @return [String]
|
9
|
+
def render(opts={}, locs={}, &block)
|
10
|
+
return app.template_data_for_file(source_file) unless template?
|
11
|
+
|
12
|
+
relative_source = Pathname(source_file).relative_path_from(Pathname(app.root))
|
13
|
+
|
14
|
+
instrument 'render.resource', path: relative_source, destination_path: destination_path do
|
15
|
+
md = metadata.dup
|
16
|
+
opts = md[:options].deep_merge(opts)
|
17
|
+
|
18
|
+
# Pass "renderer_options" hash from frontmatter along to renderer
|
19
|
+
if md[:page]['renderer_options']
|
20
|
+
opts[:renderer_options] = {}
|
21
|
+
md[:page]['renderer_options'].each do |k, v|
|
22
|
+
opts[:renderer_options][k.to_sym] = v
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
locs = md[:locals].deep_merge(locs)
|
27
|
+
|
28
|
+
# Forward remaining data to helpers
|
29
|
+
app.data.store('page', md[:page]) if md.key?(:page)
|
30
|
+
|
31
|
+
blocks = Array(md[:blocks]).dup
|
32
|
+
blocks << block if block_given?
|
33
|
+
|
34
|
+
# PATCH
|
35
|
+
# reset app.current_path to current resource on each render
|
36
|
+
# so that a prerendered resource has the correct mappings to original resource
|
37
|
+
app.current_path = destination_path
|
38
|
+
|
39
|
+
# Certain output file types don't use layouts
|
40
|
+
unless opts.key?(:layout)
|
41
|
+
opts[:layout] = false if %w(.js .json .css .txt).include?(ext)
|
42
|
+
end
|
43
|
+
|
44
|
+
app.render_template(source_file, locs, opts, blocks)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'middleman-sprockets/extension'
|
2
|
+
|
3
|
+
module Middleman
|
4
|
+
class SprocketsExtension < Extension
|
5
|
+
def after_configuration
|
6
|
+
::Tilt.register ::Sprockets::EjsTemplate, 'ejs'
|
7
|
+
::Tilt.register ::Sprockets::EcoTemplate, 'eco'
|
8
|
+
::Tilt.register ::Sprockets::JstProcessor, 'jst'
|
9
|
+
|
10
|
+
if app.respond_to?(:template_extensions)
|
11
|
+
app.template_extensions :jst => :js, :eco => :js, :ejs => :js
|
12
|
+
end
|
13
|
+
|
14
|
+
if app.config.defines_setting?(:debug_assets) && !options.setting(:debug_assets).value_set?
|
15
|
+
options[:debug_assets] = app.config[:debug_assets]
|
16
|
+
end
|
17
|
+
|
18
|
+
config_environment = @environment
|
19
|
+
debug_assets = !app.build? && options[:debug_assets]
|
20
|
+
@environment = ::Middleman::Sprockets::Environment.new(app, :debug_assets => debug_assets)
|
21
|
+
config_environment.apply_to_environment(@environment)
|
22
|
+
|
23
|
+
append_paths_from_gems
|
24
|
+
import_images_and_fonts_from_gems
|
25
|
+
|
26
|
+
# Setup Sprockets Sass options
|
27
|
+
if app.config.defines_setting?(:sass)
|
28
|
+
app.config[:sass].each { |k, v| ::Sprockets::Sass.options[k] = v }
|
29
|
+
end
|
30
|
+
|
31
|
+
# Intercept requests to /javascripts and /stylesheets and pass to sprockets
|
32
|
+
our_sprockets = self.environment
|
33
|
+
|
34
|
+
[app.config[:js_dir], app.config[:css_dir], app.config[:images_dir], app.config[:fonts_dir]].each do |dir|
|
35
|
+
app.map("/#{dir}") { run our_sprockets }
|
36
|
+
end
|
37
|
+
|
38
|
+
# PATCH: Pass any `scripts` directory in `source` through Sprockets
|
39
|
+
Dir.glob("#{app.root}/**/scripts").each do |dir|
|
40
|
+
relative_dir = (dir.split('/') - (app.root.split('/') << app.source)).join('/')
|
41
|
+
if app.config[:js_dir] != relative_dir
|
42
|
+
our_sprockets.append_path(dir) # Append custom JS path into our sprockets path
|
43
|
+
app.map("/#{relative_dir}") { run our_sprockets }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'middleman-core/templates'
|
2
|
+
|
3
|
+
module Middleman
|
4
|
+
module Sculptor
|
5
|
+
class Template < Middleman::Templates::Base
|
6
|
+
class_option 'css_dir', default: 'assets/styles'
|
7
|
+
class_option 'js_dir', default: 'assets/scripts'
|
8
|
+
class_option 'images_dir', default: 'assets/images'
|
9
|
+
|
10
|
+
def self.source_root
|
11
|
+
File.join(File.dirname(__FILE__), 'template')
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.gemfile_template
|
15
|
+
'Gemfile.tt'
|
16
|
+
end
|
17
|
+
|
18
|
+
def build_scaffold
|
19
|
+
template 'config.tt', File.join(location, 'config.rb')
|
20
|
+
copy_file '.gitignore', File.join(location, '.gitignore')
|
21
|
+
copy_file '.editorconfig', File.join(location, '.editorconfig')
|
22
|
+
copy_file '.bowerrc', File.join(location, '.bowerrc')
|
23
|
+
copy_file 'bower.json', File.join(location, 'bower.json')
|
24
|
+
|
25
|
+
directory 'source', File.join(location, 'source')
|
26
|
+
directory 'data', File.join(location, 'data')
|
27
|
+
end
|
28
|
+
|
29
|
+
def handle_bower
|
30
|
+
# Install Bower if necessary
|
31
|
+
run("command -v bower >/dev/null 2>&1 || npm install -g bower")
|
32
|
+
# Install dependencies
|
33
|
+
run("cd #{location}; bower install")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Middleman::Templates.register(:sculptor, Middleman::Sculptor::Template)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# If you have OpenSSL installed, we recommend updating
|
2
|
+
# the following line to use "https"
|
3
|
+
source 'http://rubygems.org'
|
4
|
+
|
5
|
+
gem 'middleman', '~> <%= Middleman::VERSION %>'
|
6
|
+
gem 'middleman-sculptor', '~> <%= Middleman::Sculptor::VERSION %>'
|
7
|
+
gem 'middleman-livereload', '~> 3.4.2'
|
8
|
+
gem 'middleman-deploy', '~> 1.0.0'
|
9
|
+
gem 'middleman-autoprefixer'
|
10
|
+
gem 'middleman-syntax'
|
11
|
+
gem 'bourbon'
|
@@ -0,0 +1,149 @@
|
|
1
|
+
###################
|
2
|
+
# Page options, layouts, aliases and proxies
|
3
|
+
###################
|
4
|
+
|
5
|
+
# With alternative layout
|
6
|
+
page '/**', layout: 'glyptotheque'
|
7
|
+
# With no layout
|
8
|
+
page "/glyptotheque/*", layout: false, directory_index: false
|
9
|
+
page '*.css', layout: false
|
10
|
+
page '*.js', layout: false
|
11
|
+
page '*.json', layout: false
|
12
|
+
|
13
|
+
# Proxy default site index to Glyptotheque index template
|
14
|
+
proxy 'index.html', 'glyptotheque/site-index.html'
|
15
|
+
proxy 'sitemap.json', 'glyptotheque/sitemap.json'
|
16
|
+
|
17
|
+
ready do
|
18
|
+
last_dir = nil
|
19
|
+
# Prerender resources to populate models
|
20
|
+
resources = resources_for('/', exclude_indexes: true, allow_hidden: true).each do |r|
|
21
|
+
r.render
|
22
|
+
end
|
23
|
+
|
24
|
+
# Create mappings for isolated component pages (iframe embeddable)
|
25
|
+
resources.each do |r|
|
26
|
+
# Create virtual index files
|
27
|
+
dir = File.dirname(r.path)
|
28
|
+
index_exists = !!sitemap.find_resource_by_path("#{dir}/index.html")
|
29
|
+
if last_dir != dir && !index_exists
|
30
|
+
proxy "#{dir}/index.html", 'glyptotheque/directory-index.html', locals: {
|
31
|
+
name: dir
|
32
|
+
}
|
33
|
+
last_dir = dir
|
34
|
+
end
|
35
|
+
|
36
|
+
if r.metadata[:models]
|
37
|
+
r.metadata.models.each do |id, model|
|
38
|
+
proxy "#{r.path.sub(r.ext, '')}-#{id}-isolated.html",
|
39
|
+
r.path,
|
40
|
+
layout: 'isolated',
|
41
|
+
id: id
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
activate :sculptor
|
48
|
+
activate :syntax, css_class: 'codehilite'
|
49
|
+
activate :autoprefixer
|
50
|
+
|
51
|
+
###################
|
52
|
+
# Helpers
|
53
|
+
###################
|
54
|
+
|
55
|
+
# helpers do
|
56
|
+
# end
|
57
|
+
|
58
|
+
<% if options[:css_dir] -%>
|
59
|
+
set :css_dir, '<%= options[:css_dir] -%>'
|
60
|
+
<% else -%>
|
61
|
+
# Change the CSS directory
|
62
|
+
# set :css_dir, "alternative_css_directory"
|
63
|
+
<% end -%>
|
64
|
+
<% if options[:js_dir] -%>
|
65
|
+
set :js_dir, '<%= options[:js_dir] -%>'
|
66
|
+
<% else -%>
|
67
|
+
# Change the JS directory
|
68
|
+
# set :js_dir, "alternative_js_directory"
|
69
|
+
<% end -%>
|
70
|
+
<% if options[:images_dir] -%>
|
71
|
+
set :images_dir, '<%= options[:images_dir] -%>'
|
72
|
+
<% else -%>
|
73
|
+
# Change the images directory
|
74
|
+
# set :images_dir, "alternative_image_directory"
|
75
|
+
<% end -%>
|
76
|
+
|
77
|
+
set :relative_links, true
|
78
|
+
|
79
|
+
bowerrc_dir = JSON.parse(IO.read("#{root}/.bowerrc"))['directory']
|
80
|
+
|
81
|
+
# Compass configuration
|
82
|
+
compass_config do |config|
|
83
|
+
config.sass_options = {
|
84
|
+
quiet: true
|
85
|
+
}
|
86
|
+
# For Style Guide CSS sources
|
87
|
+
# config.output_style = :expanded
|
88
|
+
end
|
89
|
+
|
90
|
+
# Sprockets
|
91
|
+
ready do
|
92
|
+
sprockets.append_path(File.join(root, bowerrc_dir))
|
93
|
+
end
|
94
|
+
|
95
|
+
Slim::Engine.disable_option_validator!
|
96
|
+
Slim::Engine.set_options pretty: true
|
97
|
+
Slim::Engine.set_options attr_list_delims: { '(' => ')', '[' => ']' }
|
98
|
+
|
99
|
+
# Development-secific configuration
|
100
|
+
configure :development do
|
101
|
+
activate :livereload, no_swf: true
|
102
|
+
end
|
103
|
+
|
104
|
+
# Build-specific configuration
|
105
|
+
configure :build do
|
106
|
+
compass_config do |config|
|
107
|
+
config.sass_options = { :line_comments => false }
|
108
|
+
end
|
109
|
+
|
110
|
+
# For example, change the Compass output style for deployment
|
111
|
+
# activate :minify_css
|
112
|
+
|
113
|
+
# Minify Javascript on build
|
114
|
+
# activate :minify_javascript
|
115
|
+
|
116
|
+
# Enable cache buster
|
117
|
+
# activate :asset_hash
|
118
|
+
|
119
|
+
# Use relative URLs
|
120
|
+
activate :relative_assets
|
121
|
+
|
122
|
+
# Or use a different image path
|
123
|
+
# set :http_prefix, "/Content/images/"
|
124
|
+
end
|
125
|
+
|
126
|
+
###################
|
127
|
+
# Additional tasks
|
128
|
+
###################
|
129
|
+
|
130
|
+
# Simple launcher for local evaluation build
|
131
|
+
# Double click `build/launch.command` (Mac)
|
132
|
+
after_build do |builder|
|
133
|
+
file = "#{build_dir}/launch.command"
|
134
|
+
open(file, 'w') do |f|
|
135
|
+
f << "#!/bin/bash\n"
|
136
|
+
f << 'cd `dirname $0` && open "http://localhost:8000" && python -m SimpleHTTPServer'
|
137
|
+
end
|
138
|
+
File.chmod(0555, file)
|
139
|
+
end
|
140
|
+
|
141
|
+
# Middleman Deploy
|
142
|
+
activate :deploy do |deploy|
|
143
|
+
deploy.method = :git
|
144
|
+
# Optional Settings
|
145
|
+
# deploy.remote = 'custom-remote' # remote name or git url, default: origin
|
146
|
+
# deploy.branch = 'custom-branch' # default: gh-pages
|
147
|
+
# deploy.strategy = :submodule # commit strategy: can be :force_push or :submodule, default: :force_push
|
148
|
+
# deploy.commit_message = 'custom-message' # commit message (can be empty), default: Automated commit at `timestamp` by middleman-deploy `version`
|
149
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
angular.module('controllers', []);
|
@@ -0,0 +1,124 @@
|
|
1
|
+
angular.module('directives', [])
|
2
|
+
|
3
|
+
.directive('glyptoModel', function($compile, $http, $templateCache) {
|
4
|
+
return {
|
5
|
+
restrict: 'C',
|
6
|
+
scope: true
|
7
|
+
};
|
8
|
+
})
|
9
|
+
|
10
|
+
.directive('glyptoNavToggle', function() {
|
11
|
+
return {
|
12
|
+
restrict: 'C',
|
13
|
+
link: function($scope, $element, $attrs) {
|
14
|
+
$scope.$root.navIsHidden = store.get('glypto-menu-hidden');
|
15
|
+
|
16
|
+
Mousetrap.bind('command+shift+e', function() {
|
17
|
+
$scope.toggle();
|
18
|
+
$scope.$apply();
|
19
|
+
});
|
20
|
+
|
21
|
+
$scope.toggle = function() {
|
22
|
+
$scope.$root.navIsHidden = !$scope.$root.navIsHidden;
|
23
|
+
store.set('glypto-menu-hidden', $scope.$root.navIsHidden);
|
24
|
+
};
|
25
|
+
}
|
26
|
+
};
|
27
|
+
})
|
28
|
+
|
29
|
+
.directive('glyptoMenu', function() {
|
30
|
+
return {
|
31
|
+
restrict: 'E',
|
32
|
+
replace: true,
|
33
|
+
scope: true,
|
34
|
+
templateUrl: 'glyptotheque/menu.html',
|
35
|
+
controller: function($scope) {
|
36
|
+
$scope.items = window.APP_CONTEXT.sitemap;
|
37
|
+
},
|
38
|
+
link: function() {
|
39
|
+
// Remove nav placeholder when menu is created
|
40
|
+
angular.element(document.getElementById('glypto-nav-placeholder')).remove();
|
41
|
+
}
|
42
|
+
};
|
43
|
+
})
|
44
|
+
|
45
|
+
.directive('glyptoMenuTree', function() {
|
46
|
+
return {
|
47
|
+
restrict: 'E',
|
48
|
+
replace: true,
|
49
|
+
transclude: true,
|
50
|
+
scope: {
|
51
|
+
items: '=',
|
52
|
+
filter: '='
|
53
|
+
},
|
54
|
+
templateUrl: 'glyptotheque/menu-tree.html'
|
55
|
+
};
|
56
|
+
})
|
57
|
+
|
58
|
+
.directive('glyptoMenuNode', function($compile) {
|
59
|
+
return {
|
60
|
+
restrict: 'E',
|
61
|
+
replace: true,
|
62
|
+
templateUrl: 'glyptotheque/menu-node.html',
|
63
|
+
link: function($scope, $element, $attrs) {
|
64
|
+
$scope.isSelected = $scope.node.url === window.APP_CONTEXT.current_url;
|
65
|
+
|
66
|
+
if ($scope.node.children && $scope.node.children.length > 0) {
|
67
|
+
var childNode = $compile('<glypto-menu-tree items="node.children" filter="filter"></glypto-menu-tree>')($scope);
|
68
|
+
$element.append(childNode);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
};
|
72
|
+
})
|
73
|
+
|
74
|
+
.directive('glyptoSearch', function() {
|
75
|
+
return {
|
76
|
+
restrict: 'A',
|
77
|
+
link: function($scope, $element, $attrs) {
|
78
|
+
var activated;
|
79
|
+
var placeholderText = $element.attr('placeholder');
|
80
|
+
|
81
|
+
Mousetrap.bind('/', function(evt) {
|
82
|
+
if(!activated) {
|
83
|
+
evt.preventDefault();
|
84
|
+
}
|
85
|
+
$element[0].focus();
|
86
|
+
$element.attr('placeholder', placeholderText.replace(/\(.*\)/, ''));
|
87
|
+
});
|
88
|
+
|
89
|
+
Mousetrap.bind('esc', function(evt) {
|
90
|
+
if(!activated) {
|
91
|
+
evt.preventDefault();
|
92
|
+
}
|
93
|
+
$element[0].blur();
|
94
|
+
$element.attr('placeholder', placeholderText);
|
95
|
+
});
|
96
|
+
|
97
|
+
$element.on('focus', function() {
|
98
|
+
activated = true;
|
99
|
+
});
|
100
|
+
|
101
|
+
$element.on('blur', function() {
|
102
|
+
activated = false;
|
103
|
+
});
|
104
|
+
}
|
105
|
+
};
|
106
|
+
})
|
107
|
+
|
108
|
+
.directive('iframe', function() {
|
109
|
+
return {
|
110
|
+
restrict: 'E',
|
111
|
+
link: function($scope, $element, $attrs) {
|
112
|
+
var iframe = $element[0];
|
113
|
+
|
114
|
+
$scope.$watch('navIsHidden', function() {
|
115
|
+
if(iframe.contentWindow.parentIFrame) {
|
116
|
+
// compensata for nav transition
|
117
|
+
setTimeout(function() {
|
118
|
+
iframe.contentWindow.parentIFrame.size();
|
119
|
+
}, 400)
|
120
|
+
}
|
121
|
+
});
|
122
|
+
}
|
123
|
+
};
|
124
|
+
});
|