mirror of
https://github.com/seigler/dash-docs
synced 2025-07-27 09:46:12 +00:00
Merge pull request #1643 from harding/incremental-rebuild
Allow incremental rebuilding of previews
This commit is contained in:
commit
25f6b2a037
15 changed files with 48 additions and 109 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -11,3 +11,4 @@ Thumbs.db
|
|||
vendor
|
||||
_cache
|
||||
.jekyll-metadata
|
||||
.sass-cache/
|
||||
|
|
2
Makefile
2
Makefile
|
@ -16,7 +16,7 @@ default: clean build
|
|||
|
||||
## `make preview`: start the built-in Jekyll preview
|
||||
preview: clean
|
||||
$S bundle exec jekyll serve
|
||||
$S bundle exec jekyll serve --incremental
|
||||
|
||||
## `make test`: don't build, but do run all tests
|
||||
test: pre-build-tests post-build-tests
|
||||
|
|
|
@ -599,3 +599,7 @@ defaults:
|
|||
type: posts
|
||||
values:
|
||||
lang: en
|
||||
|
||||
## Options as of version 3.4.20 are: nested (default), compact, compressed, or expanded
|
||||
sass:
|
||||
style: compressed
|
||||
|
|
|
@ -9,11 +9,11 @@ http://opensource.org/licenses/MIT.
|
|||
<title>{% capture title %}{% translate title %}{% endcapture %}{% if title != '' %}{{ title }}{% else %}{{ page.title }}{% endif %}</title>
|
||||
{% capture metadescription %}{% translate metadescription %}{% endcapture %}{% if metadescription != '' %}<meta name="description" content="{{ metadescription }}">{% endif %}
|
||||
<link rel="stylesheet" href="/css/font-awesome-4.4.0/css/font-awesome.min.css">
|
||||
{% lesscss main.less %}
|
||||
<!--[if lt IE 8]>{% lesscss ie.css %}<script type="text/javascript" src="/js/ie.js"></script><![endif]-->
|
||||
<!--[if IE 8]>{% lesscss ie8.less %}<![endif]-->
|
||||
{% if page.lang == 'ar' or page.lang == 'fa' %}{% lesscss rtl.less %}{% endif %}
|
||||
{% if page.lang == 'bg' or page.lang == 'el' or page.lang == 'ko' or page.lang == 'hi' or page.lang == 'pl' or page.lang == 'sl' or page.lang == 'ro' or page.lang == 'ru' or page.lang == 'tr' or page.lang == 'uk' or page.lang == 'zh_CN' or page.lang == 'zh_TW' %}{% lesscss sans.less %}{% endif %}
|
||||
<link rel="stylesheet" href="/css/main.css">
|
||||
<!--[if lt IE 8]><link rel="stylesheet" href="/css/ie.css"><script type="text/javascript" src="/js/ie.js"></script><![endif]-->
|
||||
<!--[if IE 8]><link rel="stylesheet" href="/css/ie8.css"><![endif]-->
|
||||
{% if page.lang == 'ar' or page.lang == 'fa' %}<link rel="stylesheet" href="/css/rtl.css">{% endif %}
|
||||
{% if page.lang == 'bg' or page.lang == 'el' or page.lang == 'ko' or page.lang == 'hi' or page.lang == 'pl' or page.lang == 'sl' or page.lang == 'ro' or page.lang == 'ru' or page.lang == 'tr' or page.lang == 'uk' or page.lang == 'zh_CN' or page.lang == 'zh_TW' %}<link rel="stylesheet" href="/css/sans.css">{% endif %}
|
||||
<script type="text/javascript" src="/js/base.js"></script>
|
||||
{% if page.id != 'download' %}<script type="text/javascript" src="/js/main.js"></script>{% endif %}
|
||||
<link rel="shortcut icon" href="/favicon.png">
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
/*
|
||||
This file is licensed under the MIT License (MIT) available on
|
||||
http://opensource.org/licenses/MIT.
|
||||
*/
|
||||
|
||||
@import "normalize.less";
|
||||
@import "screen.less";
|
|
@ -78,6 +78,7 @@ module Jekyll
|
|||
|
||||
def generate(site)
|
||||
# Set site.contributors global variables for liquid/jekyll
|
||||
if ! site.respond_to?('corecontributors')
|
||||
class << site
|
||||
attr_accessor :corecontributors
|
||||
attr_accessor :sitecontributors
|
||||
|
@ -91,6 +92,7 @@ module Jekyll
|
|||
h
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Set site.corecontributors and site.sitecontributors arrays
|
||||
site.corecontributors = {}
|
||||
|
|
|
@ -42,8 +42,9 @@ module Jekyll
|
|||
|
||||
def generate(site)
|
||||
# Set site.meetups and site.conferences global variables for liquid/jekyll
|
||||
if ! site.respond_to?('conferences')
|
||||
class << site
|
||||
attr_accessor :conferences
|
||||
attr_accessor :meetups, :conferences
|
||||
alias event_site_payload site_payload
|
||||
def site_payload
|
||||
h = event_site_payload
|
||||
|
@ -53,6 +54,7 @@ module Jekyll
|
|||
h
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Set site.conferences array
|
||||
site.conferences = {}
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
# This file is licensed under the MIT License (MIT) available on
|
||||
# http://opensource.org/licenses/MIT.
|
||||
|
||||
require 'digest/md5'
|
||||
|
||||
module Jekyll
|
||||
|
||||
class LessCSSFile < StaticFile
|
||||
def write(dest)
|
||||
# do nothing
|
||||
end
|
||||
end
|
||||
|
||||
class LessCSS < Liquid::Tag
|
||||
def initialize(tag_name, file, tokens)
|
||||
super
|
||||
@file = file.strip
|
||||
end
|
||||
|
||||
def render(context)
|
||||
site = context.registers[:site]
|
||||
config = context.registers[:site].config
|
||||
if !config.has_key?('lessdone')
|
||||
config['lessdone'] = {}
|
||||
end
|
||||
less_dir = File.join(site.source, '_less')
|
||||
if File.symlink?(less_dir)
|
||||
return "LessCSS directory '#{less_dir}' cannot be a symlink"
|
||||
end
|
||||
#Process file only if it hasn't been processed yet
|
||||
if !config['lessdone'].has_key?(@file)
|
||||
Dir.chdir(less_dir) do
|
||||
choices = Dir['**/*'].reject { |x| File.symlink?(x) }
|
||||
if choices.include?(@file)
|
||||
#Generate file content with less, those that end with .css
|
||||
if /\.css$/.match(@file)
|
||||
f = file = File.new(@file, "r")
|
||||
else
|
||||
source = File.read(@file)
|
||||
f = IO.popen("lessc -x -", "w+")
|
||||
f.write(source)
|
||||
f.close_write()
|
||||
end
|
||||
#Keep MD5 hash of the file as the file name
|
||||
css = f.readlines().join()
|
||||
digest = Digest::MD5.hexdigest(css)
|
||||
css_file = digest + ".css"
|
||||
css_path = File.join(site.dest, css_file)
|
||||
#Write final file
|
||||
if !File.directory?(site.dest)
|
||||
Dir.mkdir(site.dest)
|
||||
end
|
||||
File.open(css_path, "w") do |f|
|
||||
f.write(css)
|
||||
end
|
||||
site.static_files << LessCSSFile.new(site, site.source, '', css_file)
|
||||
#Save the filename so the file isn't processed again
|
||||
config['lessdone'][@file] = css_file
|
||||
else
|
||||
return "LessCSS file '#{@file}' not found in '#{less_dir}'"
|
||||
end
|
||||
end
|
||||
end
|
||||
#Print CSS link in HTML layout
|
||||
'<link rel="stylesheet" type="text/css" href="/' + config['lessdone'][@file] + '" />'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Liquid::Template.register_tag('lesscss', Jekyll::LessCSS)
|
0
_less/normalize.less → _sass/normalize.scss
vendored
0
_less/normalize.less → _sass/normalize.scss
vendored
9
css/main.scss
Normal file
9
css/main.scss
Normal file
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
# This file is licensed under the MIT License (MIT) available on
|
||||
# http://opensource.org/licenses/MIT.
|
||||
---
|
||||
// Import partials from `sass_dir` (defaults to `_sass`)
|
||||
@import
|
||||
"normalize",
|
||||
"screen"
|
||||
;
|
|
@ -1,8 +1,7 @@
|
|||
/*
|
||||
This file is licensed under the MIT License (MIT) available on
|
||||
http://opensource.org/licenses/MIT.
|
||||
*/
|
||||
|
||||
---
|
||||
# This file is licensed under the MIT License (MIT) available on
|
||||
# http://opensource.org/licenses/MIT.
|
||||
---
|
||||
/*Language specific styles that override default*/
|
||||
|
||||
/*Styles for HTML tags*/
|
Loading…
Add table
Add a link
Reference in a new issue