Merge branch 'master' into jekyll-utils-exec

This commit is contained in:
Pat Hawks 2017-01-06 05:42:15 -06:00
commit 0f2013114c
No known key found for this signature in database
GPG Key ID: F1746FF5F18B3D1B
31 changed files with 552 additions and 158 deletions

View File

@ -66,6 +66,26 @@ You can find the documentation for jekyllrb.com in the [docs](https://github.com
One gotcha, all pull requests should be directed at the `master` branch (the default branch).
### Updating FontAwesome iconset for jekyllrb.com
We use a custom version of FontAwesome which contains just the icons we use.
If you ever need to update our documentation with an icon that is not already available in our custom iconset, you'll have to regenerate the iconset using Icomoon's Generator:
1. Go to <https://icomoon.io/app/>.
2. Click `Import Icons` on the top-horizontal-bar and upload the existing `<jekyll>/docs/icomoon-selection.json`.
3. Click `Add Icons from Library..` further down on the page, and add 'Font Awesome'.
4. Select the required icon(s) from the Library (make sure its the 'FontAwesome' library instead of 'IcoMoon-Free' library).
5. Click `Generate Font` on the bottom-horizontal-bar.
6. Inspect the included icons and proceed by clicking `Download`.
7. Extract the font files and adapt the CSS to the paths we use in Jekyll:
- Copy the entire `fonts` directory over and overwrite existing ones at `<jekyll>/docs/`.
- Copy the contents of `selection.json` and overwrite existing content inside `<jekyll>/docs/icomoon-selection.json`.
- Copy the entire `@font-face {}` declaration and only the **new-icon(s)' css declarations** further below, to update the
`<jekyll>/docs/_sass/_font-awesome.scss` sass partial.
- Fix paths in the `@font-face {}` declaration by adding `../` before `fonts/FontAwesome.*` like so:
`('../fonts/Fontawesome.woff?9h6hxj')`.
### Adding plugins
If you want to add your plugin to the [list of plugins](https://jekyllrb.com/docs/plugins/#available-plugins), please submit a pull request modifying the [plugins page source file](https://github.com/jekyll/jekyll/blob/master/docs/_docs/plugins.md) by adding a link to your plugin under the proper subheading depending upon its type.

57
Gemfile
View File

@ -1,10 +1,10 @@
source "https://rubygems.org"
gemspec :name => "jekyll"
gem "rake", "~> 11.0"
gem "rake", "~> 12.0"
# Dependency of jekyll-mentions. RubyGems in Ruby 2.1 doesn't shield us from this.
gem "activesupport", "~> 4.2", :groups => [:test_legacy, :site] if RUBY_VERSION < '2.2.2'
gem "activesupport", "~> 4.2", :groups => [:test_legacy, :site] if RUBY_VERSION < "2.2.2"
group :development do
gem "launchy", "~> 2.3"
@ -18,15 +18,15 @@ end
#
group :test do
gem "rubocop", "~> 0.44.1"
gem "codeclimate-test-reporter", "~> 0.6.0"
gem "cucumber", "~> 2.1"
gem "jekyll_test_plugin"
gem "jekyll_test_plugin_malicious"
gem "codeclimate-test-reporter", "~> 0.6.0"
gem "rspec-mocks"
gem "nokogiri"
gem "rspec"
gem "test-theme", path: File.expand_path("./test/fixtures/test-theme", File.dirname(__FILE__))
gem "rspec-mocks"
gem "rubocop", "~> 0.44.1"
gem "test-theme", :path => File.expand_path("./test/fixtures/test-theme", File.dirname(__FILE__))
gem "jruby-openssl" if RUBY_ENGINE == "jruby"
end
@ -34,51 +34,54 @@ end
#
group :test_legacy do
if RUBY_PLATFORM =~ /cygwin/ || RUBY_VERSION.start_with?("2.2")
gem 'test-unit'
if RUBY_PLATFORM =~ %r!cygwin! || RUBY_VERSION.start_with?("2.2")
gem "test-unit"
end
gem "redgreen"
gem "simplecov"
gem "minitest-reporters"
gem "minitest-profile"
gem "minitest"
gem "minitest-profile"
gem "minitest-reporters"
gem "redgreen"
gem "shoulda"
gem "simplecov"
end
#
group :benchmark do
if ENV["BENCHMARK"]
gem "ruby-prof"
gem "benchmark-ips"
gem "stackprof"
gem "rbtrace"
gem "ruby-prof"
gem "stackprof"
end
end
#
group :jekyll_optional_dependencies do
gem "toml", "~> 0.1.0"
gem "coderay", "~> 1.1.0"
gem "jekyll-docs", :path => '../docs' if Dir.exist?('../docs') && ENV['JEKYLL_VERSION']
gem "jekyll-gist"
gem "jekyll-feed"
gem "jekyll-coffeescript"
gem "jekyll-redirect-from"
gem "jekyll-docs", :path => "../docs" if Dir.exist?("../docs") && ENV["JEKYLL_VERSION"]
gem "jekyll-feed"
gem "jekyll-gist"
gem "jekyll-paginate"
gem "mime-types", "~> 3.0"
gem "jekyll-redirect-from"
gem "kramdown", "~> 1.9"
gem "mime-types", "~> 3.0"
gem "rdoc", "~> 4.2"
gem "toml", "~> 0.1.0"
platform :ruby, :mswin, :mingw, :x64_mingw do
gem "rdiscount", "~> 2.0"
gem "pygments.rb", "~> 0.6.0"
gem "redcarpet", "~> 3.2", ">= 3.2.3"
gem "classifier-reborn", "~> 2.0"
gem "classifier-reborn", "~> 2.1.0"
gem "liquid-c", "~> 3.0"
gem "pygments.rb", "~> 0.6.0"
gem "rdiscount", "~> 2.0"
gem "redcarpet", "~> 3.2", ">= 3.2.3"
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", :platforms => [:mingw, :mswin, :x64_mingw, :jruby]
end
#
@ -88,9 +91,9 @@ group :site do
gem "html-proofer", "~> 2.0"
end
gem "jemoji", "0.5.1"
gem "jekyll-sitemap"
gem "jekyll-seo-tag"
gem "jekyll-avatar"
gem "jekyll-mentions"
gem "jekyll-seo-tag"
gem "jekyll-sitemap"
gem "jemoji", "0.5.1"
end

View File

@ -11,24 +11,44 @@
* Use only the used Font Awesome icons. (#5530)
* Switch to `https` when possible. (#5611)
* Update `_font-awesome.scss` to move .woff file before .ttf (#5614)
* Update documentation on updating FontAwesome Iconset (#5655)
* Improve quickstart docs (#5689)
* Add Jekyll-Post to list of plugins (#5705)
### Minor Enhancements
* Add connector param to array_to_sentence_string filter (#5597)
* Adds group_by_exp filter (#5513)
* Use the current year for the LICENSE of theme (#5712)
* Update License (#5713)
### Bug Fixes
* Escaped regular expressions when using post_url. (#5605)
* fix date parsing in file names to be stricter (#5609)
* Add a module to re-define `ENV["TZ"]` in Windows (#5612)
* Use each instead of map to actually return nothing (#5668)
### Development Fixes
* clean unit-test names in `test/test_tags.rb` (#5608)
* Add cucumber feature to test for bonafide theme gems (#5384)
* Use `assert_nil` instead of `assert_equal nil` (#5652)
* Rubocop -a on lib/jekyll (#5666)
* Bump to rake 12.0 (#5670)
* Rubocop Gemfile (#5671)
* update Classifier-Reborn to 2.1.0 (#5711)
### Documentation
* Fixed typo (#5632)
* use backticks for Gemfile for consistency since in the next sentence … (#5641)
* Update Core team list in the README file (#5643)
* Improve Permalinks documentation. (#5653)
* Fix typo in Variables doc page (#5657)
* Fix a couple of typos in the docs (#5658)
* Update windows.md (#5683)
* Improve permalinks docs (#5693)
## 3.3.1 / 2016-11-14

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2008-2016 Tom Preston-Werner
Copyright (c) 2008-2017 Tom Preston-Werner and Jekyll contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -43,8 +43,7 @@ conduct.
Please adhere to this code of conduct in any interactions you have in the
Jekyll community. It is strictly enforced on all official Jekyll
repositories, websites, and resources. If you encounter someone violating
these terms, please let a maintainer ([@parkr](https://github.com/parkr), [@envygeeks](https://github.com/envygeeks), or [@mattr-](https://github.com/mattr-)) know
and we will address it as soon as possible.
these terms, please let a maintainer ([@parkr](https://github.com/parkr), [@envygeeks](https://github.com/envygeeks), [@mattr-](https://github.com/mattr-), or [@alfredxing](https://github.com/alfredxing)) know and we will address it as soon as possible.
## Diving In

View File

@ -71,6 +71,26 @@ You can find the documentation for jekyllrb.com in the [docs](https://github.com
One gotcha, all pull requests should be directed at the `master` branch (the default branch).
### Updating FontAwesome iconset for jekyllrb.com
We use a custom version of FontAwesome which contains just the icons we use.
If you ever need to update our documentation with an icon that is not already available in our custom iconset, you'll have to regenerate the iconset using Icomoon's Generator:
1. Go to <https://icomoon.io/app/>.
2. Click `Import Icons` on the top-horizontal-bar and upload the existing `<jekyll>/docs/icomoon-selection.json`.
3. Click `Add Icons from Library..` further down on the page, and add 'Font Awesome'.
4. Select the required icon(s) from the Library (make sure its the 'FontAwesome' library instead of 'IcoMoon-Free' library).
5. Click `Generate Font` on the bottom-horizontal-bar.
6. Inspect the included icons and proceed by clicking `Download`.
7. Extract the font files and adapt the CSS to the paths we use in Jekyll:
- Copy the entire `fonts` directory over and overwrite existing ones at `<jekyll>/docs/`.
- Copy the contents of `selection.json` and overwrite existing content inside `<jekyll>/docs/icomoon-selection.json`.
- Copy the entire `@font-face {}` declaration and only the **new-icon(s)' css declarations** further below, to update the
`<jekyll>/docs/_sass/_font-awesome.scss` sass partial.
- Fix paths in the `@font-face {}` declaration by adding `../` before `fonts/FontAwesome.*` like so:
`('../fonts/Fontawesome.woff?9h6hxj')`.
### Adding plugins
If you want to add your plugin to the [list of plugins](https://jekyllrb.com/docs/plugins/#available-plugins), please submit a pull request modifying the [plugins page source file](https://github.com/jekyll/jekyll/blob/master/docs/_docs/plugins.md) by adding a link to your plugin under the proper subheading depending upon its type.

View File

@ -4,17 +4,54 @@ title: Permalinks
permalink: /docs/permalinks/
---
Jekyll supports a flexible way to build your sites URLs. You can specify the
permalinks for your site through the [Configuration](../configuration/) or in
the [YAML Front Matter](../frontmatter/) for each post. Youre free to choose
one of the built-in styles to create your links or craft your own. The default
style is `date`.
Permalinks refer to the URLs (excluding the domain name or directory folder) for your pages, posts, or collections.
Jekyll supports a flexible way to build permalinks, allowing you to leverage various template variables or choose built-in permalink styles (such as `date`) that automatically use a template-variable pattern.
Permalinks are constructed by creating a template URL where dynamic elements
are represented by colon-prefixed keywords. For example, the default `date`
permalink is defined according to the format `/:categories/:year/:month/:day/:title.html`.
You construct permalinks by creating a template URL where dynamic elements are represented by colon-prefixed keywords. The default template permalink is `/:categories/:year/:month/:day/:title.html`. Each of the colon-prefixed keywords is a template variable.
## Template variables
## Where to configure permalinks
You can configure your site's permalinks through the [Configuration]({% link _docs/configuration.md %}) file or in the [Front Matter]({% link _docs/frontmatter.md %}) for each post, page, or collection.
Setting permalink styles in your configuration file applies the setting globally in your project. You configure permalinks in your `_config.yml` file like this:
```yaml
permalink: /:categories/:year/:month/:day/:title.html
```
If you don't specify any permalink setting, Jekyll uses the above pattern as the default.
The permalink can also be set using a built-in permalink style:
```yaml
permalink: date
```
`date` is the same as `:categories/:year/:month/:day/:title.html`, the default. See [Built-in Permalink Styles](#builtinpermalinkstyles) below for more options.
Setting the permalink in your post, page, or collection's front matter overrides any global settings. Here's an example:
```yaml
---
title: My page title
permalink: /mypageurl/
---
```
Even if your configuration file specifies the `date` style, the URL for this page would be `http://somedomain.com/mypageurl/`.
When you use permalinks that omit the `.html` file extension (called "pretty URLs") Jekyll builds the file as index.html placed inside a folder with the page's name. For example:
```
├── mypageurl
│   └── index.html
```
With a URL such as `/mypageurl/`, servers automatically load the index.html file inside the folder, so users can simply navigate to `http://somedomain.com/mypageurl/` to get to `mypageurl/index.html`.
## Template variables for permalinks {#template-variables}
The following table lists the template variables available for permalinks. You can use these variables in the `permalink` property in your config file.
<div class="mobile-side-scroller">
<table>
@ -30,7 +67,7 @@ permalink is defined according to the format `/:categories/:year/:month/:day/:ti
<p><code>year</code></p>
</td>
<td>
<p>Year from the Posts filename</p>
<p>Year from the post's filename</p>
</td>
</tr>
<tr>
@ -38,7 +75,7 @@ permalink is defined according to the format `/:categories/:year/:month/:day/:ti
<p><code>month</code></p>
</td>
<td>
<p>Month from the Posts filename</p>
<p>Month from the post's filename</p>
</td>
</tr>
<tr>
@ -46,7 +83,7 @@ permalink is defined according to the format `/:categories/:year/:month/:day/:ti
<p><code>i_month</code></p>
</td>
<td>
<p>Month from the Posts filename without leading zeros.</p>
<p>Month from the post's filename without leading zeros.</p>
</td>
</tr>
<tr>
@ -54,7 +91,7 @@ permalink is defined according to the format `/:categories/:year/:month/:day/:ti
<p><code>day</code></p>
</td>
<td>
<p>Day from the Posts filename</p>
<p>Day from the post's filename</p>
</td>
</tr>
<tr>
@ -62,7 +99,7 @@ permalink is defined according to the format `/:categories/:year/:month/:day/:ti
<p><code>i_day</code></p>
</td>
<td>
<p>Day from the Posts filename without leading zeros.</p>
<p>Day from the post's filename without leading zeros.</p>
</td>
</tr>
<tr>
@ -70,7 +107,7 @@ permalink is defined according to the format `/:categories/:year/:month/:day/:ti
<p><code>short_year</code></p>
</td>
<td>
<p>Year from the Posts filename without the century.</p>
<p>Year from the post's filename without the century.</p>
</td>
</tr>
<tr>
@ -79,7 +116,7 @@ permalink is defined according to the format `/:categories/:year/:month/:day/:ti
</td>
<td>
<p>
Hour of the day, 24-hour clock, zero-padded from the posts <code>date</code> front matter. (00..23)
Hour of the day, 24-hour clock, zero-padded from the post's <code>date</code> front matter. (00..23)
</p>
</td>
</tr>
@ -89,7 +126,7 @@ permalink is defined according to the format `/:categories/:year/:month/:day/:ti
</td>
<td>
<p>
Minute of the hour from the posts <code>date</code> front matter. (00..59)
Minute of the hour from the post's <code>date</code> front matter. (00..59)
</p>
</td>
</tr>
@ -99,7 +136,7 @@ permalink is defined according to the format `/:categories/:year/:month/:day/:ti
</td>
<td>
<p>
Second of the minute from the posts <code>date</code> front matter. (00..59)
Second of the minute from the post's <code>date</code> front matter. (00..59)
</p>
</td>
</tr>
@ -132,7 +169,7 @@ permalink is defined according to the format `/:categories/:year/:month/:day/:ti
</td>
<td>
<p>
The specified categories for this Post. If a post has multiple
The specified categories for this post. If a post has multiple
categories, Jekyll will create a hierarchy (e.g. <code>/category1/category2</code>).
Also Jekyll automatically parses out double slashes in the URLs,
so if no categories are present, it will ignore this.
@ -143,10 +180,11 @@ permalink is defined according to the format `/:categories/:year/:month/:day/:ti
</table>
</div>
## Built-in permalink styles
Note that all template variables relating to time or categories are available to posts only.
While you can specify a custom permalink style using [template variables](#template-variables),
Jekyll also provides the following built-in styles for convenience.
## Built-in permalink styles {#builtinpermalinkstyles}
Although you can specify a custom permalink pattern using [template variables](#template-variables), Jekyll also provides the following built-in styles for convenience.
<div class="mobile-side-scroller">
<table>
@ -193,26 +231,16 @@ Jekyll also provides the following built-in styles for convenience.
</table>
</div>
## Pages and collections
Rather than typing `permalink: /:categories/:year/:month/:day/:title/`, you can just type `permalink: date`.
The `permalink` configuration setting specifies the permalink style used for
posts. Pages and collections each have their own default permalink style; the
default style for pages is `/:path/:basename` and the default for collections is
`/:collection/:path`.
<div class="note info">
<h5>Specifying permalinks through the YAML Front Matter</h5>
<p>Built-in permalink styles are not recognized in YAML Front Matter. As a result, <code>permalink: pretty</code> will not work.</p>
</div>
These styles are modified to match the suffix style specified in the post
permalink setting. For example, a permalink style of `pretty`, which contains a
trailing slash, will update page permalinks to also contain a trailing slash:
`/:path/:basename/`. A permalink style of `date`, which contains a trailing
file extension, will update page permalinks to also contain a file extension:
`/:path/:basename:output_ext`. The same is true for any custom permalink style.
## Permalink style examples with posts {#permalink-style-examples}
The permalink for an individual page or collection document can always be
overridden in the [YAML Front Matter](../frontmatter/) for the page or document.
Additionally, permalinks for a given collection can be customized [in the
collections configuration](../collections/).
## Permalink style examples
Here are a few examples to clarify how permalink styles get applied with posts.
Given a post named: `/2009-04-29-slap-chop.md`
@ -260,7 +288,7 @@ Given a post named: `/2009-04-29-slap-chop.md`
<tr>
<td>
<p><code>/:year/:month/:title</code></p>
<p>See <a href="#extensionless-permalinks">extensionless permalinks</a> for details.</p>
<p>See <a href="#extensionless-permalinks">Extensionless permalinks with no trailing slashes</a> for details.</p>
</td>
<td>
<p><code>/2009/04/slap-chop</code></p>
@ -270,24 +298,58 @@ Given a post named: `/2009-04-29-slap-chop.md`
</table>
</div>
## Extensionless permalinks
## Permalink settings for pages and collections {#pages-and-collections}
Jekyll supports permalinks that contain neither a trailing slash nor a file
extension, but this requires additional support from the web server to properly
serve. When using extensionless permalinks, output files written to disk will
still have the proper file extension (typically `.html`), so the web server
must be able to map requests without file extensions to these files.
The permalink setting in your configuration file specifies the permalink style used for posts, pages, and collections. However, because pages and collections don't have time or categories, these aspects of the permalink style are ignored with pages and collections.
Both [GitHub Pages](../github-pages/) and the Jekyll's built-in WEBrick server
handle these requests properly without any additional work.
For example:
* A permalink style of `/:categories/:year/:month/:day/:title.html` for posts becomes `/:title.html` for pages and collections.
* A permalink style of `pretty` (or `/:categories/:year/:month/:day/:title/`), which omits the file extension and contains a trailing slash, will update page and collection permalinks to also omit the file extension and contain a trailing slash: `/:title/`.
* A permalink style of `date`, which contains a trailing file extension, will update page permalinks to also contain a trailing file extension: `/:title.html`. But no time or category information will be included.
## Permalinks and default paths
The path to the post or page in the built site differs for posts, pages, and collections:
### Posts
The subfolders into which you may have organized your posts inside the `_posts` directory will not be part of the permalink.
If you use a permalink style that omits the `.html` file extension, each post is rendered as an `index.html` file inside a folder with the post's name (for example, `categoryname/2016/12/01/mypostname/index.html`).
### Pages
Unlike posts, pages by default mimic the source directory structure exactly. (The only exception is if your page has a `permalink` declared its front matter &mdash; in that case, the structure honors the permalink setting instead of the source folder structure.)
As with posts, if you use a permalink style that omits the `.html` file extension, each page is rendered as an `index.html` file inserted inside a folder with the page's name (for example, `mypage/index.html`).
### Collections
By default, collections follow a similar structure in the `_site` folder as pages, except that the path is prefaced by the collection name. For example: `collectionname/mypage.html`. For permalink settings that omit the file extension, the path would be `collection_name/mypage/index.html`.
Collections have their own way of setting permalinks. Additionally, collections have unique template variables available available (such as `path` and `output_ext`). See the [Configuring permalinks for collections]( ../collections#permalinks ) in Collections for more information.
## Flattening pages in \_site on build
If you want to flatten your pages (pull them out of subfolders) in the `_site` directory when your site builds (similar to posts), add the `permalink` property to the front matter of each page, with no path specified:
```
---
title: My page
permalink: mypageurl.html
---
```
## Extensionless permalinks with no trailing slashes {#extensionless-permalinks}
Jekyll supports permalinks that contain neither a trailing slash nor a file extension, but this requires additional support from the web server to properly serve. When using these types of permalinks, output files written to disk will still have the proper file extension (typically `.html`), so the web server must be able to map requests without file extensions to these files.
Both [GitHub Pages](../github-pages/) and the Jekyll's built-in WEBrick server handle these requests properly without any additional work.
### Apache
The Apache web server has very extensive support for content negotiation and can
handle extensionless URLs by setting the [multiviews][] option in your
`httpd.conf` or `.htaccess` file:
[multiviews]: https://httpd.apache.org/docs/current/content-negotiation.html#multiviews
The Apache web server has extensive support for content negotiation and can handle extensionless URLs by setting the [multiviews](https://httpd.apache.org/docs/current/content-negotiation.html#multiviews) option in your `httpd.conf` or `.htaccess` file:
{% highlight apache %}
Options +MultiViews
@ -295,13 +357,12 @@ Options +MultiViews
### Nginx
The [try_files][] directive allows you to specify a list of files to search for
to process a request. The following configuration will instruct nginx to search
for a file with an `.html` extension if an exact match for the requested URI is
not found.
[try_files]: http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files
The [try_files](http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files) directive allows you to specify a list of files to search for to process a request. The following configuration will instruct nginx to search for a file with an `.html` extension if an exact match for the requested URI is not found.
{% highlight nginx %}
try_files $uri $uri.html $uri/ =404;
{% endhighlight %}
## Linking without regard to permalink styles
You can create links in your topics to other posts, pages, or collection items in a way that is valid no matter what permalink configuration you choose. By using the `link` tag, if you change your permalinks, your links won't break. See [Linking to pages](../templates#link) in Templates for more details.

View File

@ -918,6 +918,7 @@ LESS.js files during generation.
- [jekyll-data](https://github.com/ashmaroli/jekyll-data): Read data files within Jekyll Theme Gems.
- [jekyll-pinboard](https://github.com/snaptortoise/jekyll-pinboard-plugin): Access your Pinboard bookmarks within your Jekyll theme.
- [jekyll-migrate-permalink](https://github.com/mpchadwick/jekyll-migrate-permalink): Adds a `migrate-permalink` sub-command to help deal with side effects of changing your permalink.
- [Jekyll-Post](https://github.com/robcrocombe/jekyll-post): A CLI tool to easily draft, edit, and publish Jekyll posts.
#### Editors

View File

@ -4,25 +4,42 @@ title: Quick-start guide
permalink: /docs/quickstart/
---
For the impatient, here's how to get a boilerplate Jekyll site up and running.
If you already have [Ruby](https://www.ruby-lang.org/en/downloads/) and [RubyGems](https://rubygems.org/pages/download) installed (see Jekyll's [requirements](/docs/installation/#requirements/)), you can create a new Jekyll site by doing the following:
```sh
# Install Jekyll and Bundler gems through RubyGems
~ $ gem install jekyll bundler
# Create a new Jekyll site at ./myblog
~ $ jekyll new myblog
# Change into your new directory
~ $ cd myblog
# Build the site on the preview server
~/myblog $ bundle exec jekyll serve
# => Now browse to http://localhost:4000
# Now browse to http://localhost:4000
```
The `jekyll new` command now automatically initiates `bundle install` and installs the dependencies required. To skip this, pass `--skip-bundle` option like so `jekyll new myblog --skip-bundle`.
## About Bundler
If you wish to install jekyll into an existing directory, you can do so by running `jekyll new .` from within the directory instead of creating a new one. If the existing directory isn't empty, you'll also have to pass the `--force` option like so `jekyll new . --force`.
`gem install jekyll bundler` installs the [jekyll](https://rubygems.org/gems/jekyll/) and [bundler](https://rubygems.org/gems/bundler) gems through [RubyGems](https://rubygems.org/). You need only to install the gems one time &mdash; not every time you create a new Jekyll project. Here are some additional details:
That's nothing, though. The real magic happens when you start creating blog
posts, using the front matter to control templates and layouts, and taking
advantage of all the awesome configuration options Jekyll makes available.
* `bundler` is a gem that manages other Ruby gems. It makes sure your gems and gem versions are compatible, and that you have all necessary dependencies each gem requires.
* The `Gemfile` and `Gemfile.lock` files inform Bundler about the gem requirements in your site. If your site doesn't have these Gemfiles, you can omit `bundle exec` and just run `jekyll serve`.
If you're running into problems, ensure you have all the [requirements
installed][Installation].
* When you run `bundle exec jekyll serve`, Bundler uses the gems and versions as specified in `Gemfile.lock` to ensure your Jekyll site builds with no compatibility or dependency conflicts.
[Installation]: /docs/installation/
## Options for creating a new site with Jekyll
`jekyll new <PATH>` installs a new Jekyll site at the path specified (relative to current directory). In this case, Jekyll will be installed in a directory called `myblog`. Here are some additional details:
* To install the Jekyll site into the directory you're currently in, run `jekyll new .` If the existing directory isn't empty, you can pass the `--force` option with `jekyll new . --force`.
* `jekyll new` automatically initiates `bundle install` to install the dependencies required. (If you don't want Bundler to install the gems, use `jekyll new myblog --skip-bundle`.)
* By default, the Jekyll site installed by `jekyll new` uses a gem-based theme called [Minima](https://github.com/jekyll/minima). With [gem-based themes](../themes), some of the directories and files are stored in the theme-gem, hidden from your immediate view.
* To learn about other parameters you can include with `jekyll new`, type `jekyll new --help`.
## Next steps
Building a Jekyll site with the default theme is just the first step. The real magic happens when you start creating blog posts, using the front matter to control templates and layouts, and taking advantage of all the awesome configuration options Jekyll makes available.

View File

@ -26,7 +26,7 @@ following metadata:
<td><p><code>file.path</code></p></td>
<td><p>
The relative path to the file, e.g <code>/assets/img/image.jpg</code>
The relative path to the file, e.g. <code>/assets/img/image.jpg</code>
</p></td>
</tr>
@ -34,7 +34,7 @@ following metadata:
<td><p><code>file.modified_time</code></p></td>
<td><p>
The `Time` the file was last modified, e.g <code>2016-04-01 16:35:26 +0200</code>
The `Time` the file was last modified, e.g. <code>2016-04-01 16:35:26 +0200</code>
</p></td>
</tr>

View File

@ -147,6 +147,22 @@ common tasks easier.
</p>
</td>
</tr>
<tr>
<td>
<p class="name"><strong>Group By Expression</strong></p>
<p>Group an array's items using a Liquid expression.</p>
</td>
<td class="align-center">
<p>
<code class="filter">{% raw %}{{ site.members | group_by_exp:"item",
"item.graduation_year | truncate: 3, \"\"" }}{% endraw %}</code>
</p>
<p>
<code class="output">[{"name"=>"201...", "items"=>[...]},
{"name"=>"200...", "items"=>[...]}]</code>
</p>
</td>
</tr>
<tr>
<td>
<p class="name"><strong>XML Escape</strong></p>

View File

@ -339,7 +339,7 @@ following is a reference of the available data.
If you specify front matter in a layout, access that via <code>layout</code>.
For example, if you specify <code>class: full_page</code>
in a pages front matter, that value will be available as
in a layouts front matter, that value will be available as
<code>layout.class</code> in the layout and its parents.
</p>

View File

@ -16,6 +16,9 @@ A quick way to install Jekyll is to follow the [installation instructions by Dav
2. Install Ruby via Chocolatey: `choco install ruby -y`
3. Reopen a command prompt and install Jekyll: `gem install jekyll`
Updates in the infrastructure of Ruby may cause SSL errors when attempting to use `gem install` with versions of the RubyGems package older than 2.6. (The RubyGems package installed via the Chocolatey tool is version 2.3) If you have installed an older version, you can update the RubyGems package using the directions [here.][ssl-certificate-update]
[ssl-certificate-update]: http://guides.rubygems.org/ssl-certificate-update/#installing-using-update-packages
For a more conventional way of installing Jekyll you can follow this [complete guide to install Jekyll 3 on Windows by Sverrir Sigmundarson][windows-installjekyll3].
[windows-installjekyll3]: https://labs.sverrirs.com/jekyll/
@ -34,6 +37,19 @@ the site generation process. It can be done with the following command:
$ chcp 65001
```
## Timezone Management
Since Windows doesn't have a native source of zoneinfo data, the Ruby Interpreter would not understand IANA Timezones and hence using them had the `TZ` environment variable default to UTC/GMT 00:00.
Though Windows users could alternatively define their blog's timezone by setting the key to use POSIX format of defining timezones, it wasn't as user-friendly when it came to having the clock altered to changing DST-rules.
Jekyll now uses a rubygem to internally configure Timezone based on established [IANA Timezone Database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
While 'new' blogs created with Jekyll v3.4 and greater, will have the following added to their 'Gemfile' by default, existing sites *will* have to update their 'Gemfile' (and installed) to enable development on Windows:
```ruby
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
```
## Auto-regeneration
As of v1.3.0, Jekyll uses the `listen` gem to watch for changes when the

View File

@ -162,7 +162,7 @@ Feature: Site configuration
And I have an "index.html" page with layout "page" that contains "site index page"
And I have a configuration file with:
| key | value |
| timezone | UTC+04:00 |
| timezone | America/New_York |
And I have a _posts directory
And I have the following posts:
| title | date | layout | content |
@ -172,8 +172,10 @@ Feature: Site configuration
Then I should get a zero exit status
And the _site directory should exist
And I should see "Page Layout: 2" in "_site/index.html"
And I should see "Post Layout: <p>content for entry1.</p>\n built at 2013-04-09T23:22:00-04:00" in "_site/2013/04/09/entry1.html"
And I should see "Post Layout: <p>content for entry2.</p>\n built at 2013-04-10T03:14:00-04:00" in "_site/2013/04/10/entry2.html"
And I should see "Post Layout: <p>content for entry1.</p>\n built at 2013-04-09T23:22:00-04:00" in "_site/2013/04/09/entry1.html" unless Windows
And I should see "Post Layout: <p>content for entry1.</p>\n built at 2013-04-09T22:22:00-05:00" in "_site/2013/04/09/entry1.html" if on Windows
And I should see "Post Layout: <p>content for entry2.</p>\n built at 2013-04-10T03:14:00-04:00" in "_site/2013/04/10/entry2.html" unless Windows
And I should see "Post Layout: <p>content for entry2.</p>\n built at 2013-04-10T02:14:00-05:00" in "_site/2013/04/10/entry2.html" if on Windows
Scenario: Generate proper dates with explicitly set timezone (different than posts' time)
Given I have a _layouts directory
@ -182,7 +184,7 @@ Feature: Site configuration
And I have an "index.html" page with layout "page" that contains "site index page"
And I have a configuration file with:
| key | value |
| timezone | UTC+10:00 |
| timezone | Pacific/Honolulu |
And I have a _posts directory
And I have the following posts:
| title | date | layout | content |

View File

@ -119,7 +119,11 @@ module Jekyll
# Returns nothing
# rubocop:disable Style/AccessorMethodName
def set_timezone(timezone)
ENV["TZ"] = timezone
ENV["TZ"] = if Utils::Platforms.really_windows?
Utils::WinTZ.calculate(timezone)
else
timezone
end
end
# rubocop:enable Style/AccessorMethodName

View File

@ -32,8 +32,8 @@ module Jekyll
# Override of method_missing to check in @data for the key.
def method_missing(method, *args, &blck)
if docs.respond_to?(method.to_sym)
Jekyll.logger.warn "Deprecation:", "#{label}.#{method} should be changed to" \
"#{label}.docs.#{method}."
Jekyll.logger.warn "Deprecation:",
"#{label}.#{method} should be changed to #{label}.docs.#{method}."
Jekyll.logger.warn "", "Called by #{caller.first}."
docs.public_send(method.to_sym, *args, &blck)
else
@ -197,6 +197,7 @@ module Jekyll
end
private
def read_document(full_path)
doc = Jekyll::Document.new(full_path, :site => site, :collection => self)
doc.read
@ -208,14 +209,20 @@ module Jekyll
end
private
def read_static_file(file_path, full_path)
relative_dir = Jekyll.sanitized_path(
relative_directory,
File.dirname(file_path)
).chomp("/.")
files << StaticFile.new(site, site.source, relative_dir,
File.basename(full_path), self)
files << StaticFile.new(
site,
site.source,
relative_dir,
File.basename(full_path),
self
)
end
end
end

View File

@ -84,6 +84,10 @@ gem "minima", "~> 2.0"
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.6"
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
RUBY
end

View File

@ -30,8 +30,7 @@ module Jekyll
@data
end
def trigger_hooks(*)
end
def trigger_hooks(*); end
# 'Path' of the excerpt.
#

View File

@ -8,6 +8,8 @@ require_all "jekyll/filters"
module Jekyll
module Filters
include URLFilters
include GroupingFilters
# Convert a Markdown string into HTML output.
#
# input - The Markdown String to convert.
@ -205,29 +207,6 @@ module Jekyll
as_liquid(input).to_json
end
# Group an array of items by a property
#
# input - the inputted Enumerable
# property - the property
#
# Returns an array of Hashes, each looking something like this:
# {"name" => "larry"
# "items" => [...] } # all the items where `property` == "larry"
def group_by(input, property)
if groupable?(input)
input.group_by { |item| item_property(item, property).to_s }
.each_with_object([]) do |item, array|
array << {
"name" => item.first,
"items" => item.last,
"size" => item.last.size
}
end
else
input
end
end
# Filter an array of objects
#
# input - the object array
@ -381,11 +360,6 @@ module Jekyll
end.localtime
end
private
def groupable?(element)
element.respond_to?(:group_by)
end
private
def item_property(item, property)
if item.respond_to?(:to_liquid)
@ -436,6 +410,7 @@ module Jekyll
condition
end
end
end

View File

@ -0,0 +1,63 @@
module Jekyll
module Filters
module GroupingFilters
# Group an array of items by a property
#
# input - the inputted Enumerable
# property - the property
#
# Returns an array of Hashes, each looking something like this:
# {"name" => "larry"
# "items" => [...] } # all the items where `property` == "larry"
def group_by(input, property)
if groupable?(input)
groups = input.group_by { |item| item_property(item, property).to_s }
grouped_array(groups)
else
input
end
end
# Group an array of items by an expression
#
# input - the object array
# variable - the variable to assign each item to in the expression
# expression -a Liquid comparison expression passed in as a string
#
# Returns the filtered array of objects
def group_by_exp(input, variable, expression)
return input unless groupable?(input)
parsed_expr = parse_expression(expression)
@context.stack do
groups = input.group_by do |item|
@context[variable] = item
parsed_expr.render(@context)
end
grouped_array(groups)
end
end
private
def parse_expression(str)
Liquid::Variable.new(str, {})
end
private
def groupable?(element)
element.respond_to?(:group_by)
end
private
def grouped_array(groups)
groups.each_with_object([]) do |item, array|
array << {
"name" => item.first,
"items" => item.last,
"size" => item.last.size
}
end
end
end
end
end

View File

@ -71,7 +71,7 @@ module Jekyll
#
# Returns nothing.
def retrieve_dirs(_base, dir, dot_dirs)
dot_dirs.map do |file|
dot_dirs.each do |file|
dir_path = site.in_source_dir(dir, file)
rel_path = File.join(dir, file)
unless @site.dest.sub(%r!/$!, "") == dir_path

View File

@ -5,6 +5,7 @@ module Jekyll
autoload :Ansi, "jekyll/utils/ansi"
autoload :Exec, "jekyll/utils/exec"
autoload :Platforms, "jekyll/utils/platforms"
autoload :WinTZ, "jekyll/utils/win_tz"
# Constants for use in #slugify
SLUGIFY_MODES = %w(raw default pretty ascii).freeze

View File

@ -0,0 +1,73 @@
module Jekyll
module Utils
module WinTZ
extend self
# Public: Calculate the Timezone for Windows when the config file has a defined
# 'timezone' key.
#
# timezone - the IANA Time Zone specified in "_config.yml"
#
# Returns a string that ultimately re-defines ENV["TZ"] in Windows
def calculate(timezone)
External.require_with_graceful_fail("tzinfo")
tz = TZInfo::Timezone.get(timezone)
difference = Time.now.to_i - tz.now.to_i
#
# POSIX style definition reverses the offset sign.
# e.g. Eastern Standard Time (EST) that is 5Hrs. to the 'west' of Prime Meridian
# is denoted as:
# EST+5 (or) EST+05:00
# Reference: http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
sign = difference < 0 ? "-" : "+"
offset = sign == "-" ? "+" : "-" unless difference.zero?
#
# convert the difference (in seconds) to hours, as a rational number, and perform
# a modulo operation on it.
modulo = modulo_of(rational_hour(difference))
#
# Format the hour as a two-digit number.
# Establish the minutes based on modulo expression.
hh = format("%02d", absolute_hour(difference).ceil)
mm = modulo.zero? ? "00" : "30"
Jekyll.logger.debug "Timezone:", "#{timezone} #{offset}#{hh}:#{mm}"
#
# Note: The 3-letter-word below doesn't have a particular significance.
"WTZ#{sign}#{hh}:#{mm}"
end
private
# Private: Convert given seconds to an hour as a rational number.
#
# seconds - supplied as an integer, it is converted to a rational number.
# 3600 - no. of seconds in an hour.
#
# Returns a rational number.
def rational_hour(seconds)
seconds.to_r/3600
end
# Private: Convert given seconds to an hour as an absolute number.
#
# seconds - supplied as an integer, it is converted to its absolute.
# 3600 - no. of seconds in an hour.
#
# Returns an integer.
def absolute_hour(seconds)
seconds.abs/3600
end
# Private: Perform a modulo operation on a given fraction.
#
# fraction - supplied as a rational number, its numerator is divided
# by its denominator and the remainder returned.
#
# Returns an integer.
def modulo_of(fraction)
fraction.numerator % fraction.denominator
end
end
end
end

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2016 <%= user_name %>
Copyright (c) <%= Time.now.year %> <%= user_name %>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -6,7 +6,7 @@ TODO: Delete this and the text above, and describe your gem
## Installation
Add this line to your Jekyll site's Gemfile:
Add this line to your Jekyll site's `Gemfile`:
```ruby
gem <%= theme_name.inspect %>

View File

@ -10,13 +10,17 @@ esac
export BENCHMARK=true
command -v stackprof > /dev/null || script/bootstrap
TEST_SCRIPT="Jekyll::Commands::Build.process({'source' => 'site'})"
TEST_SCRIPT="Jekyll::Commands::Build.process({'source' => 'docs'})"
PROF_OUTPUT_FILE=tmp/stackprof-${STACKPROF_MODE}-$(date +%Y%m%d%H%M).dump
GC_BEFORE="puts 'GC Stats:'; puts JSON.pretty_generate(GC.stat); GC.disable"
GC_AFTER="puts 'GC Stats:'; GC.start(full_mark: true, immediate_sweep: false); puts JSON.pretty_generate(GC.stat);"
echo Stackprof Mode: $STACKPROF_MODE
test -f "$PROF_OUTPUT_FILE" || {
bundle exec ruby -r./lib/jekyll -rstackprof \
-e "StackProf.run(mode: :${STACKPROF_MODE}, interval: 100, out: '${PROF_OUTPUT_FILE}') { ${TEST_SCRIPT} }"
bundle exec ruby -r./lib/jekyll -rstackprof -rjson \
-e "StackProf.run(mode: :${STACKPROF_MODE}, interval: 100, out: '${PROF_OUTPUT_FILE}') { ${GC_BEFORE}; ${TEST_SCRIPT}; ${GC_AFTER}; }"
}
bundle exec stackprof $PROF_OUTPUT_FILE $@
set -x
bundle exec stackprof $PROF_OUTPUT_FILE $@ --sort-total

View File

@ -206,7 +206,7 @@ class TestDocument < JekyllUnitTest
should "not know the specified front matter defaults" do
assert_equal "Example slide", @document.data["title"]
assert_equal "slide", @document.data["layout"]
assert_equal nil, @document.data["nested"]
assert_nil @document.data["nested"]
end
end

View File

@ -756,6 +756,91 @@ class TestFilters < JekyllUnitTest
end
end
context "group_by_exp filter" do
should "successfully group array of Jekyll::Page's" do
@filter.site.process
groups = @filter.group_by_exp(@filter.site.pages, "page", "page.layout | upcase")
groups.each do |g|
assert(
["DEFAULT", "NIL", ""].include?(g["name"]),
"#{g["name"]} isn't a valid grouping."
)
case g["name"]
when "DEFAULT"
assert(
g["items"].is_a?(Array),
"The list of grouped items for 'default' is not an Array."
)
# adjust array.size to ignore symlinked page in Windows
qty = Utils::Platforms.really_windows? ? 4 : 5
assert_equal qty, g["items"].size
when "nil"
assert(
g["items"].is_a?(Array),
"The list of grouped items for 'nil' is not an Array."
)
assert_equal 2, g["items"].size
when ""
assert(
g["items"].is_a?(Array),
"The list of grouped items for '' is not an Array."
)
# adjust array.size to ignore symlinked page in Windows
qty = Utils::Platforms.really_windows? ? 14 : 15
assert_equal qty, g["items"].size
end
end
end
should "include the size of each grouping" do
groups = @filter.group_by_exp(@filter.site.pages, "page", "page.layout")
groups.each do |g|
assert_equal(
g["items"].size,
g["size"],
"The size property for '#{g["name"]}' doesn't match the size of the Array."
)
end
end
should "allow more complex filters" do
items = [
{ "version"=>"1.0", "result"=>"slow" },
{ "version"=>"1.1.5", "result"=>"medium" },
{ "version"=>"2.7.3", "result"=>"fast" }
]
result = @filter.group_by_exp(items, "item", "item.version | split: '.' | first")
assert_equal 2, result.size
end
should "be equivalent of group_by" do
actual = @filter.group_by_exp(@filter.site.pages, "page", "page.layout")
expected = @filter.group_by(@filter.site.pages, "layout")
assert_equal expected, actual
end
should "return any input that is not an array" do
assert_equal "some string", @filter.group_by_exp("some string", "la", "le")
end
should "group by full element (as opposed to a field of the element)" do
items = %w(a b c d)
result = @filter.group_by_exp(items, "item", "item")
assert_equal 4, result.length
assert_equal ["a"], result.first["items"]
end
should "accept hashes" do
hash = { 1 => "a", 2 => "b", 3 => "c", 4 => "d" }
result = @filter.group_by_exp(hash, "item", "item")
assert_equal 4, result.length
end
end
context "sort filter" do
should "raise Exception when input is nil" do
err = assert_raises ArgumentError do

View File

@ -96,9 +96,13 @@ class TestPage < JekyllUnitTest
attrs.each do |attr, val|
attr_str = attr.to_s
result = page[attr_str]
if val.nil?
assert_nil result, "For <page[\"#{attr_str}\"]>:"
else
assert_equal val, result, "For <page[\"#{attr_str}\"]>:"
end
end
end
context "with pretty permalink style" do
setup do
@ -220,7 +224,7 @@ class TestPage < JekyllUnitTest
should "return nil permalink if no permalink exists" do
@page = setup_page("")
assert_equal nil, @page.permalink
assert_nil @page.permalink
end
should "not be writable outside of destination" do

View File

@ -57,7 +57,7 @@ class TestStaticFile < JekyllUnitTest
should "have a destination relative directory without a collection" do
static_file = setup_static_file("root", "dir/subdir", "file.html")
assert_equal nil, static_file.type
assert_nil static_file.type
assert_equal "dir/subdir/file.html", static_file.url
assert_equal "dir/subdir", static_file.destination_rel_dir
end

View File

@ -47,11 +47,11 @@ class TestTheme < JekyllUnitTest
end
should "not allow paths outside of the theme root" do
assert_equal nil, @theme.send(:path_for, "../../source")
assert_nil @theme.send(:path_for, "../../source")
end
should "return nil for paths that don't exist" do
assert_equal nil, @theme.send(:path_for, "foo")
assert_nil @theme.send(:path_for, "foo")
end
should "return the resolved path when a symlink & resolved path exists" do