Compare commits

..

7 Commits

Author SHA1 Message Date
Pat Hawks
2d191bce81 Fix backwards compatible relative_path 2018-07-02 12:40:52 -05:00
Pat Hawks
49c4666ec9 I don't know why this works, but it does 2018-07-02 10:10:10 -05:00
Pat Hawks
b16080d016 Fix hash diffs 2018-07-02 08:53:45 -05:00
Pat Hawks
94fb5985b7 Fix bugs 2018-07-01 21:16:48 -05:00
Pat Hawks
0ae6fa4c7a Merge branch 'master' into pages-as-documents 2018-06-26 13:52:55 -05:00
Ben Balter
21d5dd7761 distinguish absolute_path from relative_path 2016-08-07 20:09:38 -04:00
Ben Balter
ef3e660620 initial pass at Pages as Documents 2016-08-07 19:03:24 -04:00
91 changed files with 1284 additions and 1732 deletions

View File

@@ -11,7 +11,6 @@ AllCops:
TargetRubyVersion: 2.3
Include:
- lib/**/*.rb
- test/**/*.rb
Exclude:
- bin/**/*
- exe/**/*
@@ -83,9 +82,6 @@ Metrics/PerceivedComplexity:
Max: 8
Naming/FileName:
Enabled: false
Naming/HeredocDelimiterNaming:
Exclude:
- test/**/*.rb
Naming/MemoizedInstanceVariableName:
Exclude:
- lib/jekyll/page_without_a_file.rb
@@ -108,9 +104,6 @@ Style/Alias:
EnforcedStyle: prefer_alias_method
Style/AndOr:
Severity: error
Style/ClassAndModuleChildren:
Exclude:
- test/**/*.rb
Style/FrozenStringLiteralComment:
EnforcedStyle: always
Style/Documentation:

View File

@@ -14,10 +14,8 @@ matrix:
include:
- rvm: *ruby1
env: TEST_SUITE=fmt
name: "🤖️ Code Format"
- rvm: *ruby1
env: TEST_SUITE=default-site
name: "🏠️ Default Site"
exclude:
- rvm: *jruby
env: TEST_SUITE=cucumber
@@ -54,4 +52,4 @@ after_success:
before_install:
- gem update --system
- gem install bundler --version 1.16.2
- gem install bundler

View File

@@ -1,46 +1,49 @@
# Code of Conduct
## Our Pledge
As contributors and maintainers of this project, and in the interest of
fostering an open and welcoming community, we pledge to respect all people who
contribute through reporting issues, posting feature requests, updating
documentation, submitting pull requests or patches, and other activities.
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
We are committed to making participation in this project a harassment-free
experience for everyone, regardless of level of experience, gender, gender
identity and expression, sexual orientation, disability, personal appearance,
body size, race, ethnicity, age, religion, or nationality.
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
* Publishing other's private information, such as physical or electronic
addresses, without explicit permission
* Other unethical or unprofessional conduct
## Our Responsibilities
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
By adopting this Code of Conduct, project maintainers commit themselves to
fairly and consistently applying these principles to every aspect of managing
this project. Project maintainers who do not follow or enforce the Code of
Conduct may be permanently removed from the project team.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community.
## Scope
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by opening an issue or contacting a project maintainer. All complaints
will be reviewed and investigated and will result in a response that is deemed
necessary and appropriate to the circumstances. Maintainers are obligated to
maintain confidentiality with regard to the reporter of an incident.
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 1.3.0, available at
[http://contributor-covenant.org/version/1/3/0/][version]
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting a project maintainer. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct.html][version]
[homepage]: https://www.contributor-covenant.org/
[version]: https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/3/0/

View File

@@ -28,18 +28,6 @@
* Added plugin json-get. (#7086)
* Update travis-ci.md to point out "this is an example Gemfile" (#7089)
* Adding `jekyll-info` plugin (#7091)
* GitHub enables you to use themes from other repos (#7112)
* Updates to CODE OF CONDUCT (v1.4.0) (#7105)
* Instructions to view themes files under Linux (#7095)
* add jekyll-xml-source (#7114)
* Add the jekyll-firstimage filter plugin (#7127)
* Use a real theme in the example (#7125)
* Update docs about post creation (#7138)
* Add DEV Community's Jekyll tag to community page (#7139)
* Initialize upgrading doc for v4.0 (#7140)
* Add version badge for date filters with ordinal (#7162)
* Add closing tags for <a> (#7163)
* Add TSV to list of supported _data files. (#7168)
### Minor Enhancements
@@ -47,9 +35,6 @@
* Memoize computing excerpt's relative_path (#6951)
* Liquefied link tag (#6269)
* Suggest re-running command with --trace on fail (#6551)
* Update item_property to return numbers as numbers instead of strings (#6608)
* Use .markdown for page templates (#7126)
* Fix custom 404 page for GitHub pages (#7132)
### Major Enhancements
@@ -61,8 +46,6 @@
* Drop support for older versions of Rouge (#6978)
* Remove support for Redcarpet (#6987)
* Remove support for rdiscount (#6988)
* Remove 'cache_dir' during `jekyll clean` (#7158)
* Output Jekyll Version while debugging (#7173)
### Development Fixes
@@ -76,21 +59,7 @@
* Update Rubocop's config (#7050)
* Remember to release docs gem (#7066)
* Use assert_include (#7093)
* Update rubocop version to 0.57.x ### -docs (#7078)
* Example of CircleCI deployment through CircleCI v2 (#7024)
* Fix Rubocop offences in test files (#7128)
* fix up refute_equal call (#7133)
* Fix incorrectly passed arguments to assert_equal (#7134)
* Lock Travis to Bundler-1.16.2 (#7144)
### Bug Fixes
* Add call to unused method `validate_options` in `commands/serve.rb` (#7122)
### feature
* Disable Liquid via front matter (#6824)
* Do not process Liquid in post excerpt when disabled in front matter (#7146)
* Update rubocop version to 0.57.x (#7078)
## 3.8.3 / 2018-06-05

View File

@@ -3,11 +3,9 @@
[![Gem Version](https://img.shields.io/gem/v/jekyll.svg)][ruby-gems]
[![Linux Build Status](https://img.shields.io/travis/jekyll/jekyll/master.svg?label=Linux%20build)][travis]
[![Windows Build status](https://img.shields.io/appveyor/ci/jekyll/jekyll/master.svg?label=Windows%20build)][appveyor]
[![Maintainability](https://api.codeclimate.com/v1/badges/8ba0cb5b17bb9848e128/maintainability)][codeclimate]
[![Test Coverage](https://api.codeclimate.com/v1/badges/8ba0cb5b17bb9848e128/test_coverage)][coverage]
[![Maintainability](https://api.codeclimate.com/v1/badges/8ba0cb5b17bb9848e128/maintainability)](codeclimate)
[![Test Coverage](https://api.codeclimate.com/v1/badges/8ba0cb5b17bb9848e128/test_coverage)](coverage)
[![Security](https://hakiri.io/github/jekyll/jekyll/master.svg)][hakiri]
[![Backers on Open Collective](https://opencollective.com/jekyll/backers/badge.svg)](#backers)
[![Sponsors on Open Collective](https://opencollective.com/jekyll/sponsors/badge.svg)](#sponsors)
[ruby-gems]: https://rubygems.org/gems/jekyll
[codeclimate]: https://codeclimate.com/github/jekyll/jekyll
@@ -56,28 +54,6 @@ these terms, please let one of our [core team members](https://jekyllrb.com/team
* Use the built-in [Liquid Extensions](https://jekyllrb.com/docs/templates/) to make your life easier
* Use custom [Plugins](https://jekyllrb.com/docs/plugins/) to generate content specific to your site
## Credits
### Contributors
This project exists thanks to all the people who contribute.
<a href="graphs/contributors"><img src="https://opencollective.com/jekyll/contributors.svg?width=890&button=false" /></a>
### Backers
Thank you to all our backers! 🙏 [Become a backer](https://opencollective.com/jekyll#backer)
<a href="https://opencollective.com/jekyll#backers" target="_blank"><img src="https://opencollective.com/jekyll/backers.svg?width=890" /></a>
### Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor!](https://opencollective.com/jekyll#sponsor)
<a href="https://opencollective.com/jekyll/sponsor/0/website" target="_blank"><img src="https://opencollective.com/jekyll/sponsor/0/avatar.svg" /></a>
<a href="https://opencollective.com/jekyll/sponsor/1/website" target="_blank"><img src="https://opencollective.com/jekyll/sponsor/1/avatar.svg" /></a>
<a href="https://opencollective.com/jekyll/sponsor/2/website" target="_blank"><img src="https://opencollective.com/jekyll/sponsor/2/avatar.svg" /></a>
## License
See the [LICENSE](https://github.com/jekyll/jekyll/blob/master/LICENSE) file.

View File

@@ -1,15 +0,0 @@
- name: Forestry.io
image: /img/forestry-logo.png
url: https://forestry.io
width: 140
height: 30
- name: CloudCannon
image: /img/cloudcannon-logo.png
url: https://cloudcannon.com
width: 75
height: 30
- name: Siteleaf
image: /img/siteleaf-logo.png
url: https://siteleaf.com
width: 40
height: 50

View File

@@ -61,7 +61,7 @@ test:
## Complete Example circle.yml File
When you put it all together, here's an example of what that `circle.yml` file could look like in v1:
When you put it all together, here's an example of what that `circle.yml` file could look like:
```yaml
machine:
@@ -83,75 +83,6 @@ deployment:
- rsync -va --delete ./_site username@my-website:/var/html
```
for CircleCI v2, a Docker-based system which new projects will follow, set the `S3_BUCKET_NAME` environment variable (an example of the required config file is shown below).
```yaml
defaults: &defaults
working_directory: ~/repo
version: 2
jobs:
build:
<<: *defaults
docker:
- image: circleci/ruby:2.5
environment:
BUNDLE_PATH: ~/repo/vendor/bundle
steps:
- checkout
- restore_cache:
keys:
- rubygems-v1-{% raw %}{{ checksum "Gemfile.lock" }}{% endraw %}
- rubygems-v1-fallback
- run:
name: Bundle Install
command: bundle check || bundle install
- run:
name: HTMLProofer tests
command: |
bundle exec htmlproofer ./_site \
--allow-hash-href \
--check-favicon \
--check-html \
--disable-external
- save_cache:
key: rubygems-v1-{% raw %}{{ checksum "Gemfile.lock" }}{% endraw %}
paths:
- vendor/bundle
- run:
name: Jekyll build
command: bundle exec jekyll build
- persist_to_workspace:
root: ./
paths:
- _site
deploy:
<<: *defaults
docker:
- image: circleci/python:3.6.3
environment:
S3_BUCKET_NAME: <<YOUR BUCKET NAME HERE>>
steps:
- attach_workspace:
at: ./
- run:
name: Install AWS CLI
command: pip install awscli --upgrade --user
- run:
name: Upload to s3
command: ~/.local/bin/aws s3 sync ./_site s3://$S3_BUCKET_NAME/ --delete --acl public-read
workflows:
version: 2
test-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: master
```
## Questions?
This entire guide is open-source. Go ahead and [edit it][7] if you have a fix or [ask for help][8] if you run into trouble and need some help. CircleCI also has an [online community][9] for help.

View File

@@ -16,7 +16,7 @@ Whether you're a developer, a designer, or just a Jekyll devotee, there are lots
* [Install Jekyll on your computer](https://jekyllrb.com/docs/installation/) and kick the tires. Does it work? Does it do what you'd expect? If not, [open an issue](https://github.com/jekyll/jekyll/issues/new) and let us know.
* Comment on some of the project's [open issues](https://github.com/jekyll/jekyll/issues). Have you experienced the same problem? Know a work around? Do you have a suggestion for how the feature could be better?
* Read through [the documentation](https://jekyllrb.com/docs/home/), and click the "improve this page" button, any time you see something confusing, or have a suggestion for something that could be improved.
* Read through [the documentation](https://jekyllrb.com/docs/home/), and click the "improve this page" button, any time you see something confusing, or have a suggestion on how to improve something.
* Browse through [the Jekyll discussion forum](https://talk.jekyllrb.com/), and lend a hand answering questions. There's a good chance you've already experienced what another user is experiencing.
* Find [an open issue](https://github.com/jekyll/jekyll/issues) (especially [those labeled `help-wanted`](https://github.com/jekyll/jekyll/issues?q=is%3Aopen+is%3Aissue+label%3Ahelp-wanted)), and submit a proposed fix. If it's your first pull request, we promise we won't bite, and are glad to answer any questions.
* Help evaluate [open pull requests](https://github.com/jekyll/jekyll/pulls), by testing the changes locally and reviewing what's proposed.

View File

@@ -86,7 +86,6 @@ For example, suppose you have a special image syntax with complex formatting, an
<a href="http://jekyllrb.com">
<img src="logo.png" style="max-width: 200px;"
alt="Jekyll logo" />
</a>
<figcaption>This is the Jekyll logo</figcaption>
</figure>
```
@@ -99,7 +98,6 @@ You could templatize this content in your include and make each value available
<a href="{{ include.url }}">
<img src="{{ include.file }}" style="max-width: {{ include.max-width }};"
alt="{{ include.alt }}"/>
</a>
<figcaption>{{ include.caption }}</figcaption>
</figure>
```

View File

@@ -828,7 +828,6 @@ You can find a few useful plugins at the following locations:
- [replace_regex](https://github.com/sparanoid/replace_regex): A Liquid filter to perform regex replace.
- [Jekyll Money](https://rubygems.org/gems/jekyll-money): A Jekyll plugin for dealing with money. Because we all have to at some point.
- [jekyll-random](https://github.com/codecalm/jekyll-random) by [codecalm](https://nodecalm.net): A Jekyll plugin that generates pseudo-random data. Very useful when you want to generate a large amount of random data.
- [jekyll-firstimage](https://github.com/nhoizey/jekyll-firstimage) adds a Liquid filter finding the first image in a HTML content string, including responsive images srcset.
#### Tags
@@ -941,7 +940,6 @@ You can find a few useful plugins at the following locations:
- [jekyll-pwa-plugin](https://github.com/lavas-project/jekyll-pwa): A plugin provides PWA support for Jekyll. It generates a service worker in Jekyll build process and makes precache and runtime cache available in the runtime with Google Workbox.
- [jekyll-algolia](https://community.algolia.com/jekyll-algolia/): Add fast and relevant search to your Jekyll site through the Algolia API.
- [jekyll-get](https://github.com/18F/jekyll-get): Download data from external JSON API sources to use in generating a site.
- [jekyll-xml-source](https://github.com/mcred/jekyll-xml-source): Download XML and RSS from external sites for use in site data.
<div class="note info">
<h5>Submit your gem plugins</h5>

View File

@@ -137,9 +137,9 @@ An overview of what each of these does:
<p>
Well-formatted site data should be placed here. The Jekyll engine
will autoload all data files (using either the <code>.yml</code>,
<code>.yaml</code>, <code>.json</code>, <code>.csv</code> or
<code>.tsv</code> formats and extensions) in this directory,
and they will be accessible via `site.data`. If there's a file
<code>.yaml</code>, <code>.json</code> or <code>.csv</code>
formats and extensions) in this directory, and they will be
accessible via `site.data`. If there's a file
<code>members.yml</code> under the directory, then you can access
contents of the file through <code>site.data.members</code>.
</p>

View File

@@ -94,8 +94,7 @@ you come up with your own tags via plugins.
<tr>
<td>
<p class="name"><strong>Date to String in ordinal US style</strong></p>
<p>Format a date to ordinal, US, short format.
{% include docs_version_badge.html version="3.8.0" %}</p>
<p>Format a date to ordinal, US, short format.</p>
</td>
<td class="align-center">
<p>
@@ -123,8 +122,7 @@ you come up with your own tags via plugins.
<tr>
<td>
<p class="name"><strong>Date to Long String in ordinal UK style</strong></p>
<p>Format a date to ordinal, UK, long format.
{% include docs_version_badge.html version="3.8.0" %}</p>
<p>Format a date to ordinal, UK, long format.</p>
</td>
<td class="align-center">
<p>

View File

@@ -19,8 +19,8 @@ In the case of Minima, you see only the following files in your Jekyll site dire
├── _config.yml
├── _posts
│ └── 2016-12-04-welcome-to-jekyll.markdown
├── about.markdown
└── index.markdown
├── about.md
└── index.md
```
The `Gemfile` and `Gemfile.lock` files are used by Bundler to keep track of the required gems and gem versions you need to build your Jekyll site.
@@ -52,8 +52,6 @@ To locate a theme's files on your computer:
open $(bundle show minima)
# On Windows
explorer /usr/local/lib/ruby/gems/2.3.0/gems/minima-2.1.0
# On Linux
xdg-open $(bundle show minima)
```
A Finder or Explorer window opens showing the theme's files and directories. The Minima theme gem contains these files:
@@ -166,21 +164,20 @@ For example, search for [jekyll theme on RubyGems](https://rubygems.org/search?u
To install a gem-based theme:
1. Add the theme gem to your site's `Gemfile`:
1. Add the theme to your site's `Gemfile`:
```ruby
# ./Gemfile
# This is an example, declare the theme gem you want to use here
gem "jekyll-theme-minimal"
gem "jekyll-theme-awesome"
```
Or if you've started with the `jekyll new` command, replace `gem "minima", "~> 2.0"` with the gem you want, e.g:
Or if you've started with the `jekyll new` command, replace `gem "minima", "~> 2.0"` with your theme-gem:
```diff
# ./Gemfile
- gem "minima", "~> 2.0"
+ gem "jekyll-theme-minimal"
+ gem "jekyll-theme-awesome"
```
2. Install the theme:
@@ -192,7 +189,7 @@ To install a gem-based theme:
3. Add the following to your site's `_config.yml` to activate the theme:
```yaml
theme: jekyll-theme-minimal
theme: jekyll-theme-awesome
```
4. Build your site:
@@ -204,7 +201,7 @@ To install a gem-based theme:
You can have multiple themes listed in your site's `Gemfile`, but only one theme can be selected in your site's `_config.yml`.
{: .note .info }
If you're publishing your Jekyll site on [GitHub Pages](https://pages.github.com/), note that GitHub Pages supports only [some gem-based themes](https://pages.github.com/themes/). GitHub Pages also supports [using any theme hosted on GitHub](https://help.github.com/articles/adding-a-jekyll-theme-to-your-github-pages-site/#adding-a-jekyll-theme-in-your-sites-_configyml-file) using the `remote_theme` configuration as if it were a gem-based theme.
If you're publishing your Jekyll site on [GitHub Pages](https://pages.github.com/), note that GitHub Pages supports only some gem-based themes. See [Supported Themes](https://pages.github.com/themes/) in GitHub's documentation to see which themes are supported.
## Creating a gem-based theme

View File

@@ -1,51 +0,0 @@
---
title: Upgrading from 3.x to 4.x
permalink: /docs/upgrading/3-to-4/
---
Upgrading from an older version of Jekyll? A few things have changed in Jekyll 4
that you'll want to know about.
Before we dive in, you need to have at least Ruby 2.3.0 installed. Run the following
in your terminal to check
```sh
ruby -v
```
If you're using Ruby >= 2.3.0, go ahead and fetch the latest version of Jekyll:
```sh
gem update jekyll
```
### Template rendering
We've slightly altered the way Jekyll parses and renders your various templates to improve
the overall build times. Jekyll now parses a template once, caches it internally and then
renders the parsed template multiple times as required by your pages and documents.
The downside to this is that some of the community-authored plugins may not work as they
previously used to.
#### For Plugin-authors
* If your plugin depends on the following code: `site.liquid_renderer.file(path).parse(content)`,
note that the return value (`template`, an instance of *`Liquid::Template`*), from that line will
always be the **same object** for a given `path`. <br/>
The *`template`* instance is then rendered as previously, with respect to the `payload` passed to it.
You'll therefore have to ensure that *`payload`* is not memoized or cached in your plugin instance.
* If its a requirement that `template` you get from the above step *be different* at all times,
you can invoke *`Liquid::Template`* directly:
```diff
- template = site.liquid_renderer.file(path).parse(content)
+ template = Liquid::Template.parse(content)
```
---
*Did we miss something? Please click "Improve this page" above and add a section. Thanks!*

View File

@@ -11,15 +11,5 @@
</a>
</p>
</div>
<div class="unit two-thirds align-right center-on-mobiles">
<p>
Sponsored by
{% for sponsor in site.data.sponsors %}
<a href="{{ sponsor.url }}" style="margin-left: 10px;">
<img src="{{ sponsor.image }}" height="{{ sponsor.height }}" width="{{ sponsor.width }}" alt="{{ sponsor.name }}">
</a>
{% endfor %}
</p>
</div>
</div>
</footer>

View File

@@ -1,68 +0,0 @@
---
title: "Sponsoring Jekyll's development"
date: 2018-08-01 15:00:00 +0200
author: oe
categories: [community]
---
_(TL;DR: We're open for sponsorships on our [OpenCollective page](https://opencollective.com/jekyll))_
Hi Jekyllers,
As you may know, Jekyll is a completely free and open source project. We offer our
software and its related plugins and documentation at no cost because we believe
that good software should not cost anything. We're not planning on changing that,
but today I want to talk about a different monetary aspect of open source.
Open source developers being paid for the work they do is a rare sight. Most open source
software is effectively the result of hundreds and thousands of hours of free labor provided
by individuals who are passionate enough to work outside of their day job to create
software that, ironically, is being used by almost every company that offers
digital services. It's a problem that has gotten more attention in recent years, with
the open source community becoming more diverse and more and more companies actively
investing in providing monetary support for open source developers.
Jekyll has always been a product of volunteers. Rarely has someone been paid to implement
a certain plugin or feature. Today, we're excited to announce that we will finally
be able to fund our contributors! __We are opening an OpenCollective to receive
individual and corporate sponsorships__. This is not unheard of, [Hugo](http://gohugo.io)
is also funded by sponsorships, as are many other similar projects, such as
[webpack](https://opencollective.com/webpack), [Babel](https://opencollective.com/babel) or
[RuboCop](https://opencollective.com/rubocop).
OpenCollective is a service that makes it easy for open source projects to receive funding
from individuals and companies alike. It's specifically designed for open source and
many other projects already use it for funding.
Sponsoring is, for us, a method to finally realize some of the more ambitious goals we've had
with the project for years. The closest thing we want to realize is to __release Jekyll 4.0, and
to make it as polished as we can__. In the future, we would also like to work on other things that
will improve the Jekyll ecosystem. Here's a couple of ideas:
- Create a comprehensive official plugin and theme directory site
- Improve tooling built around measuring and improving Jekyll's performance
- Improve maintenance for official plugins
- Including the community into official decisions; making Jekyll more friendly to folks in the community
Again, these are just some ideas, but with the help of sponsoring, they are now one step closer
to being realized :heart:
<div align="center">
<img src="/img/forestry-logo.png" width="300" />
</div>
With that, we would like to announce our very first sponsor: [__Forestry.io__](https://forestry.io)! Forestry is
a CMS that integrates with your Jekyll sites and lets you update content using a beautiful
interface, and then automatically commits it back to your GitHub repository. We're excited to have
them on board on a new, exciting step of our journey.
Will anything change for Jekyll users? The answer is no - this step does not impact the Jekyll software
in any aspect. In fact, you might see positive changes, such as more features and better
performance. Surprisingly, that's what happens when you properly fund people for their work!
If you have been a long time user for Jekyll and would like to give something back to the project,
you can consider a small monthly donation to our [OpenCollective page](http://opencollective.com/jekyll).
If your company heavily relies on Jekyll, do consider sponsoring us! Contact me at
`olivia at fastmail dot com` and we'll figure something out together.
Thanks for sticking with us, and happy Jekylling! :tada:

View File

@@ -224,7 +224,8 @@ footer {
img {
display: inline-block;
vertical-align: middle;
position: relative;
top: 8px;
margin-left: 5px;
opacity: .8;
padding: 1px;

View File

@@ -26,10 +26,6 @@ question!
Get live support at **#jekyll** on **irc.freenode.net**, the official
Jekyll IRC channel.
### [The Dev community](https://dev.to/)
[DEVs jekyll tag](https://dev.to/t/jekyll) is a place to share Jekyll projects, articles and tutorials as well as start discussions and ask for feedback on Jekyll-related topics. Developers of all skill-levels are welcome to take part.
### View source
Learn from the source of others, you'll find plenty of [jekyll sites](https://github.com/topics/jekyll-site) and [jekyll themes](https://github.com/topics/jekyll-themes) carefully handcrafted on GitHub.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -82,10 +82,10 @@ Feature: Create sites
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see "Page : Site contains 2 pages and 4 posts" in "_site/index.html"
And I should see "Page Index: Site contains 2 pages and 4 posts" in "_site/index.html"
And I should see "No replacement \{\{ site.posts.size \}\}" in "_site/about.html"
And I should see "" in "_site/another_file"
And I should see "Page : blog category index page" in "_site/blog/index.html"
And I should see "Page Index: blog category index page" in "_site/blog/index.html"
And I should see "Post entry1: <p>content for entry1.</p>" in "_site/2009/03/27/entry1.html"
And I should see "Post entry2: <p>content for entry2.</p>" in "_site/2009/04/27/entry2.html"
And I should see "Post entry3: <p>content for entry3.</p>" in "_site/category/2009/05/27/entry3.html"
@@ -200,6 +200,6 @@ Feature: Create sites
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see "Page : Site contains 1 pages and 2 posts; Related posts: 0" in "_site/index.html"
And I should see "Page Index: Site contains 1 pages and 2 posts; Related posts: 0" in "_site/index.html"
And I should see "Post entry1: <p>content for entry1.</p>\nRelated posts: 1" in "_site/2009/03/27/entry1.html"
And I should see "Post entry2: <p>content for entry2.</p>\nRelated posts: 1" in "_site/2009/04/27/entry2.html"

View File

@@ -106,4 +106,4 @@ Feature: Embed filters
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see exactly "The rule of 3: Fly, Run, Jump," in "_site/bird.html"
And I should see exactly "The rule of 3: Jump, Fly, Run," in "_site/bird.html"

View File

@@ -7,20 +7,9 @@ Feature: Hooks
And I have a "_plugins/ext.rb" file with content:
"""
Jekyll::Hooks.register :site, :after_reset do |site|
pageklass = Class.new(Jekyll::Page) do
def initialize(site, base)
@site = site
@base = base
@data = {}
@dir = '/'
@name = 'foo.html'
@content = 'mytinypage'
self.process(@name)
end
end
site.pages << pageklass.new(site, site.source)
page = Jekyll::Page.new(site, site.source, "/", "foo.html")
page.content = "mytinypage"
site.pages.docs << page
end
"""
When I run jekyll build
@@ -79,7 +68,7 @@ Feature: Hooks
And I have a "_plugins/ext.rb" file with content:
"""
Jekyll::Hooks.register :pages, :post_init do |page|
page.name = 'renamed.html'
page.instance_variable_set "@relative_path", '/renamed.html'
page.process(page.name)
end
"""
@@ -256,6 +245,7 @@ Feature: Hooks
And I have a "_plugins/ext.rb" file with content:
"""
Jekyll::Hooks.register :documents, :pre_render do |doc, payload|
doc.data['text'] ||= ''
doc.data['text'] = doc.data['text'] << ' are belong to us'
end
"""

View File

@@ -251,19 +251,6 @@ Feature: Post data
And I should see "Post categories: scifi and Movies" in "_site/scifi/movies/2009/03/27/star-wars.html"
And I should see "Post categories: SciFi and movies" in "_site/scifi/movies/2013/03/17/star-trek.html"
Scenario: Use page.render_with_liquid variable
Given I have a _posts directory
And I have the following posts:
| title | render_with_liquid | date | content |
| Unrendered Post | false | 2017-07-06 | Hello {{ page.title }} |
| Rendered Post | true | 2017-07-06 | Hello {{ page.title }} |
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should not see "Hello Unrendered Post" in "_site/2017/07/06/unrendered-post.html"
But I should see "Hello {{ page.title }}" in "_site/2017/07/06/unrendered-post.html"
And I should see "Hello Rendered Post" in "_site/2017/07/06/rendered-post.html"
Scenario Outline: Use page.path variable
Given I have a <dir>/_posts directory
And I have the following post in "<dir>":

View File

@@ -70,21 +70,3 @@ Feature: Post excerpts
And the "_site/2007/12/31/entry1.html" file should exist
And I should see "<p>content for entry1.</p>" in "_site/index.html"
And I should see "<html><head></head><body><p>content for entry1.</p>\n</body></html>" in "_site/2007/12/31/entry1.html"
Scenario: Excerpts from posts having 'render_with_liquid' in their front matter
Given I have an "index.html" page that contains "{% for post in site.posts %}{{ post.excerpt }}{% endfor %}"
And I have a _posts directory
And I have a _layouts directory
And I have a post layout that contains "{{ page.excerpt }}"
And I have the following posts:
| title | layout | render_with_liquid | date | content |
| Unrendered Post | post | false | 2017-07-06 | Liquid is not rendered at {{ page.url }} |
| Rendered Post | post | true | 2017-07-06 | Liquid is rendered at {{ page.url }} |
When I run jekyll build
Then I should get a zero exit status
And the _site/2017/07/06 directory should exist
And the "_site/2017/07/06/unrendered-post.html" file should exist
And the "_site/2017/07/06/rendered-post.html" file should exist
And I should see "Liquid is not rendered at {{ page.url }}" in "_site/2017/07/06/unrendered-post.html"
But I should see "<p>Liquid is rendered at /2017/07/06/rendered-post.html</p>" in "_site/2017/07/06/rendered-post.html"
And I should see "<p>Liquid is not rendered at {{ page.url }}</p>\n<p>Liquid is rendered at /2017/07/06/rendered-post.html</p>" in "_site/index.html"

View File

@@ -54,7 +54,6 @@ module Jekyll
autoload :FrontmatterDefaults, "jekyll/frontmatter_defaults"
autoload :Hooks, "jekyll/hooks"
autoload :Layout, "jekyll/layout"
autoload :Cache, "jekyll/cache"
autoload :CollectionReader, "jekyll/readers/collection_reader"
autoload :DataReader, "jekyll/readers/data_reader"
autoload :LayoutReader, "jekyll/readers/layout_reader"

View File

@@ -1,127 +0,0 @@
# frozen_string_literal: true
require "digest"
require "fileutils"
require "pstore"
module Jekyll
class Cache
extend Forwardable
# Get an existing named cache, or create a new one if none exists
#
# name - name of the cache
#
# Returns nothing.
# rubocop:disable Style/ClassVars
def initialize(name)
@@base_dir ||= File.expand_path(".jekyll-cache/Jekyll/Cache")
@@caches ||= {}
@cache = @@caches[name] ||= {}
@name = name
FileUtils.mkdir_p(path_to)
end
def self.clear
delete_cache_files
@@caches.each_value(&:clear)
end
# rubocop:enable Style/ClassVars
def clear
delete_cache_files
@cache.clear
end
def [](key)
return @cache[key] if @cache.key?(key)
path = path_to(hash(key))
if File.file?(path) && File.readable?(path)
@cache[key] = load(path)
else
raise
end
end
def getset(key)
return @cache[key] if @cache.key?(key)
path = path_to(hash(key))
if File.file?(path) && File.readable?(path)
value = load(path)
else
value = yield
dump(path, value)
end
@cache[key] = value
end
def []=(key, value)
@cache[key] = value
path = path_to(hash(key))
dump(path, value)
end
def delete(key)
@cache.delete(key)
path = path_to(hash(key))
File.delete(path)
end
def key?(key)
return true if @cache.key?(key)
path = path_to(hash(key))
File.file?(path) && File.readable?(path)
end
# rubocop:disable Style/ClassVars
def self.clear_if_config_changed(config)
config = config.inspect
cache = Jekyll::Cache.new "Jekyll::Cache"
unless cache.key?("config") && cache["config"] == config
delete_cache_files
@@caches = {}
cache = Jekyll::Cache.new "Jekyll::Cache"
cache["config"] = config
end
end
# rubocop:enable Style/ClassVars
private
def path_to(hash = nil)
@base_dir ||= File.join(@@base_dir, @name)
return @base_dir if hash.nil?
File.join(@base_dir, hash[0..1], hash[2..-1]).freeze
end
def hash(key)
Digest::SHA2.hexdigest(key).freeze
end
def delete_cache_files
FileUtils.rm_rf(path_to)
end
# rubocop:disable Security/MarshalLoad
def load(path)
cached_file = File.open(path, "rb")
value = Marshal.load(cached_file)
cached_file.close
value
end
# rubocop:enable Security/MarshalLoad
def dump(path, value)
dir, _file = File.split(path)
FileUtils.mkdir_p(dir)
cached_file = File.open(path, "wb")
Marshal.dump(value, cached_file)
cached_file.close
end
def self.delete_cache_files
FileUtils.rm_rf(@@base_dir)
end
private_class_method :delete_cache_files
end
end

View File

@@ -22,12 +22,10 @@ module Jekyll
options = configuration_from_options(options)
destination = options["destination"]
metadata_file = File.join(options["source"], ".jekyll-metadata")
cache_dir = File.join(options["source"], options["cache_dir"])
sass_cache = ".sass-cache"
remove(destination, :checker_func => :directory?)
remove(metadata_file, :checker_func => :file?)
remove(cache_dir, :checker_func => :directory?)
remove(sass_cache, :checker_func => :directory?)
end

View File

@@ -66,7 +66,7 @@ module Jekyll
def conflicting_urls(site)
conflicting_urls = false
urls = {}
urls = collect_urls(urls, site.pages, site.dest)
urls = collect_urls(urls, site.pages.docs, site.dest)
urls = collect_urls(urls, site.posts.docs, site.dest)
urls.each do |url, paths|
next unless paths.size > 1
@@ -95,7 +95,7 @@ module Jekyll
def urls_only_differ_by_case(site)
urls_only_differ_by_case = false
urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest)
urls = case_insensitive_urls(site.docs_to_write, site.dest)
urls.each_value do |real_urls|
next unless real_urls.uniq.size > 1
urls_only_differ_by_case = true

View File

@@ -91,10 +91,7 @@ module Jekyll
def process(opts)
opts = configuration_from_options(opts)
destination = opts["destination"]
if opts["livereload"]
validate_options(opts)
register_reload_hooks(opts)
end
register_reload_hooks(opts) if opts["livereload"]
setup(destination)
start_up_webrick(opts, destination)

View File

@@ -9,7 +9,6 @@ module Jekyll
"source" => Dir.pwd,
"destination" => File.join(Dir.pwd, "_site"),
"collections_dir" => "",
"cache_dir" => ".jekyll-cache",
"plugins_dir" => "_plugins",
"layouts_dir" => "_layouts",
"data_dir" => "_data",
@@ -258,9 +257,10 @@ module Jekyll
end
config["collections"] = Utils.deep_merge_hashes(
{ "posts" => {} }, config["collections"]
{ "posts" => {}, "pages" => {} }, config["collections"]
).tap do |collections|
collections["posts"]["output"] = true
collections["pages"]["output"] = true
if config["permalink"]
collections["posts"]["permalink"] ||= style_to_permalink(config["permalink"])
end

View File

@@ -19,8 +19,6 @@ module Jekyll
raise Errors::FatalException, "Bailing out; invalid Markdown processor."
end
@cache = Jekyll::Cache.new("Jekyll::Converters::Markdown")
@setup = true
end
@@ -72,9 +70,7 @@ module Jekyll
def convert(content)
setup
@cache.getset(content) do
@parser.convert(content)
end
@parser.convert(content)
end
private

View File

@@ -160,7 +160,6 @@ module Jekyll
#
# Returns true if the file has Liquid Tags or Variables, false otherwise.
def render_with_liquid?
return false if data["render_with_liquid"] == false
Jekyll::Utils.has_liquid_construct?(content)
end

View File

@@ -5,15 +5,28 @@ module Jekyll
include Comparable
extend Forwardable
attr_reader :path, :site, :extname, :collection
attr_reader :site, :extname, :collection
attr_accessor :content, :output
# In order to retain backwards compatability, @path is the absolute path
# in Documents, but the relative path in Pages. If you need the Document's
# path, it's better to use #absolute_path and #relative_path
attr_reader :path
def_delegator :self, :read_post_data, :post_read
YAML_FRONT_MATTER_REGEXP = %r!\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)!m
DATELESS_FILENAME_MATCHER = %r!^(?:.+/)*(.*)(\.[^.]+)$!
DATE_FILENAME_MATCHER = %r!^(?:.+/)*(\d{2,4}-\d{1,2}-\d{1,2})-(.*)(\.[^.]+)$!
# A set of extensions that are considered HTML or HTML-like so we
# should not alter them, this includes .xhtml through XHTM5.
HTML_EXTENSIONS = %w(
.html
.xhtml
.htm
).freeze
# Create a new Document.
#
# path - the path to the file
@@ -83,7 +96,23 @@ module Jekyll
# Returns a String path which represents the relative path from the collections_dir
# to this document.
def relative_path
@relative_path ||= path.sub("#{site.collections_path}/", "")
@relative_path ||= Pathname.new(absolute_path)
.relative_path_from(Pathname.new(site.source)).to_s
end
# The path to the document's containing directory, relative to the site source
#
# Returns a String path which represents the relative path
# from the site source to this document's containing directory
def relative_path_without_basename
@relative_path_without_basename = relative_path.sub(%r!#{basename}\z!, "")
end
# The absolute path to the document
#
# Returns a String path which represents the absolute pat to this document
def absolute_path
Pathname.new(@path).to_s
end
# The output extension of the document.
@@ -97,14 +126,14 @@ module Jekyll
#
# Returns the basename without the file extname.
def basename_without_ext
@basename_without_ext ||= File.basename(path, ".*")
@basename_without_ext ||= File.basename(absolute_path, ".*")
end
# The base filename of the document.
#
# Returns the base filename of the document.
def basename
@basename ||= File.basename(path)
@basename ||= File.basename(absolute_path)
end
# Produces a "cleaned" relative path.
@@ -159,8 +188,7 @@ module Jekyll
# or if the document doesn't contain any Liquid Tags or Variables,
# true otherwise.
def render_with_liquid?
return false if data["render_with_liquid"] == false
!(coffeescript_file? || yaml_file? || !Utils.has_liquid_construct?(content))
!(yaml_file? || !Utils.has_liquid_construct?(content))
end
# Determine whether the file should be rendered with a layout.
@@ -178,6 +206,16 @@ module Jekyll
!(asset_file? || yaml_file? || no_layout?)
end
# Returns the Boolean of whether this Page is HTML or not.
def html?
HTML_EXTENSIONS.include?(output_ext)
end
# Returns the Boolean of whether this Page is an index file or not.
def index?
basename_without_ext == "index"
end
# The URL template where the document would be accessible.
#
# Returns the URL template for the document.
@@ -225,7 +263,7 @@ module Jekyll
dest = site.in_dest_dir(base_directory)
path = site.in_dest_dir(dest, URL.unescape_path(url))
if url.end_with? "/"
path = File.join(path, "index.html")
path = File.join(path, "index#{output_ext}")
else
path << output_ext unless path.end_with? output_ext
end
@@ -263,7 +301,7 @@ module Jekyll
Jekyll.logger.debug "Reading:", relative_path
if yaml_file?
@data = SafeYAML.load_file(path)
@data = SafeYAML.load_file(absolute_path)
else
begin
merge_defaults
@@ -305,7 +343,7 @@ module Jekyll
def <=>(other)
return nil unless other.respond_to?(:data)
cmp = data["date"] <=> other.data["date"]
cmp = path <=> other.path if cmp.nil? || cmp.zero?
cmp = relative_path <=> other.relative_path if cmp.nil? || cmp.zero?
cmp
end
@@ -439,7 +477,7 @@ module Jekyll
end
def read_content(opts)
self.content = File.read(path, Utils.merged_file_read_opts(site, opts))
self.content = File.read(absolute_path, Utils.merged_file_read_opts(site, opts))
if content =~ YAML_FRONT_MATTER_REGEXP
self.content = $POSTMATCH
data_file = SafeYAML.load(Regexp.last_match(1))
@@ -456,9 +494,9 @@ module Jekyll
def handle_read_error(error)
if error.is_a? Psych::SyntaxError
Jekyll.logger.error "Error:", "YAML Exception reading #{path}: #{error.message}"
Jekyll.logger.error "Error:", "YAML Exception reading #{relative_path}: #{error.message}"
else
Jekyll.logger.error "Error:", "could not read file #{path}: #{error.message}"
Jekyll.logger.error "Error:", "could not read file #{relative_path}: #{error.message}"
end
if site.config["strict_front_matter"] || error.is_a?(Jekyll::Errors::FatalException)

View File

@@ -29,7 +29,7 @@ module Jekyll
end
def html_pages
@site_html_pages ||= @obj.pages.select do |page|
@site_html_pages ||= @obj.pages.docs.select do |page|
page.html? || page.url.end_with?("/")
end
end

View File

@@ -9,6 +9,7 @@ module Jekyll
def_delegator :@obj, :cleaned_relative_path, :path
def_delegator :@obj, :output_ext, :output_ext
def_delegator :@obj, :relative_path_without_basename
def collection
@obj.collection.label

View File

@@ -89,7 +89,6 @@ module Jekyll
end
def render_with_liquid?
return false if data["render_with_liquid"] == false
!(coffeescript_file? || yaml_file? || !Utils.has_liquid_construct?(content))
end

View File

@@ -299,16 +299,16 @@ module Jekyll
# We also utilize the Schwartzian transform to make this more efficient.
def sort_input(input, property, order)
input.map { |item| [item_property(item, property), item] }
.sort! do |a_info, b_info|
a_property = a_info.first
b_property = b_info.first
.sort! do |apple_info, orange_info|
apple_property = apple_info.first
orange_property = orange_info.first
if !a_property.nil? && b_property.nil?
if !apple_property.nil? && orange_property.nil?
- order
elsif a_property.nil? && !b_property.nil?
elsif apple_property.nil? && !orange_property.nil?
+ order
else
a_property <=> b_property || a_property.to_s <=> b_property.to_s
apple_property <=> orange_property
end
end
.map!(&:last)
@@ -317,22 +317,15 @@ module Jekyll
def item_property(item, property)
if item.respond_to?(:to_liquid)
property.to_s.split(".").reduce(item.to_liquid) do |subvalue, attribute|
parse_sort_input(subvalue[attribute])
subvalue[attribute]
end
elsif item.respond_to?(:data)
parse_sort_input(item.data[property.to_s])
item.data[property.to_s]
else
parse_sort_input(item[property.to_s])
item[property.to_s]
end
end
# return numeric values as numbers for proper sorting
def parse_sort_input(property)
number_like = %r!\A\s*-?(?:\d+\.?\d*|\.\d+)\s*\Z!
return property.to_f if property =~ number_like
property
end
def as_liquid(item)
case item
when Hash

View File

@@ -53,7 +53,7 @@ module Jekyll
private
def filename_regex
@filename_regex ||= %r!\A(#{source_dir}/|#{theme_dir}/|/*)(.*)!i
@filename_regex ||= %r!\A(#{source_dir}/|#{theme_dir}/|\W*)(.*)!i
end
def new_profile_hash

View File

@@ -10,9 +10,7 @@ module Jekyll
def parse(content)
measure_time do
@template = Jekyll::Cache.new("Jekyll::LiquidRenderer::File").getset(content) do
Liquid::Template.parse(content, :line_numbers => true)
end
@template = Liquid::Template.parse(content, :line_numbers => true)
end
self
@@ -26,7 +24,6 @@ module Jekyll
end
end
# This method simply 'rethrows any error' before attempting to render the template.
def render!(*args)
measure_time do
measure_bytes do

View File

@@ -43,7 +43,6 @@ module Jekyll
self.log_level = :debug
end
debug "Logging at level:", LOG_LEVELS.key(writer.level).to_s
debug "Jekyll Version:", Jekyll::VERSION
end
# Public: Print a debug message

View File

@@ -1,15 +1,13 @@
# frozen_string_literal: true
module Jekyll
class Page
include Convertible
class Page < Document
attr_writer :dir
attr_accessor :site, :pager
attr_accessor :name, :ext, :basename
attr_accessor :data, :content, :output
attr_accessor :pager
alias_method :extname, :ext
alias_method :ext, :extname
alias_method :name, :basename
alias_method :process, :read
# Attributes for Liquid templates
ATTRIBUTES_FOR_LIQUID = %w(
@@ -20,47 +18,39 @@ module Jekyll
url
).freeze
# A set of extensions that are considered HTML or HTML-like so we
# should not alter them, this includes .xhtml through XHTM5.
HTML_EXTENSIONS = %w(
.html
.xhtml
.htm
).freeze
# rubocop:disable Metrics/AbcSize
# Initialize a new Page.
#
# site - The Site object.
# base - The String path to the source.
# dir - The String path between the source and the file.
# name - The String filename of the file.
def initialize(site, base, dir, name)
@site = site
@base = base
@dir = dir
@name = name
@path = if site.in_theme_dir(base) == base # we're in a theme
site.in_theme_dir(base, dir, name)
else
site.in_source_dir(base, dir, name)
end
process(name)
read_yaml(File.join(base, dir), name)
data.default_proc = proc do |_, key|
site.frontmatter_defaults.find(File.join(dir, name), type, key)
def initialize(*args)
if args.size == 2 # Initialized as Document
super
elsif args.size == 4 # Legacy Page support
Jekyll::Deprecator.deprecation_message "Pages are now Documents."
Jekyll::Deprecator.deprecation_message "Called by #{caller(1..1).first}."
@site, @base, @dir, @name = args
@path = if site.in_theme_dir(@base) == @base # we're in a theme
site.in_theme_dir(@base, @dir, @name)
else
site.in_source_dir(@base, @dir, @name)
end
@relative_path = File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).sub(%r!\A\/!, "")
super(@path, :collection => site.pages, :site => @site)
read
backwards_compatibilize
else
raise ArugmentError, "Expected 2 or 4 arguments, #{args.size} given"
end
Jekyll::Hooks.trigger :pages, :post_init, self
end
# The generated directory into which the page will be placed
# upon generation. This is derived from the permalink or, if
# permalink is absent, will be '/'
#
# Returns the String destination directory.
# rubocop:enable Metrics/AbcSize
# Backwards compatible shim to return the generated directory into which
# the page will be placed upon generation. This is derived from the
# permalink or, if permalink is absent, will be '/'
def dir
if url.end_with?("/")
url
@@ -70,116 +60,45 @@ module Jekyll
end
end
# The full path and filename of the post. Defined in the YAML of the post
# body.
#
# Returns the String permalink or nil if none has been set.
def permalink
data.nil? ? nil : data["permalink"]
end
# The template of the permalink.
#
# Returns the template String.
def template
def url_template
if !html?
"/:path/:basename:output_ext"
"/:path:output_ext"
elsif index?
"/:path/"
"/:relative_path_without_basename/"
else
Utils.add_permalink_suffix("/:path/:basename", site.permalink_style)
Utils.add_permalink_suffix("/:path", site.permalink_style)
end
end
alias_method :template, :url_template
# The generated relative url of this page. e.g. /about.html.
#
# Returns the String url.
def url
@url ||= URL.new(
:template => template,
:placeholders => url_placeholders,
:permalink => permalink
).to_s
end
# Returns a hash of URL placeholder names (as symbols) mapping to the
# desired placeholder replacements. For details see "url.rb"
def url_placeholders
{
:path => @dir,
:basename => basename,
:output_ext => output_ext,
}
end
# Extract information from the page filename.
#
# name - The String filename of the page file.
#
# Returns nothing.
def process(name)
self.ext = File.extname(name)
self.basename = name[0..-ext.length - 1]
end
# Add any necessary layouts to this post
# Backwards compatible shim to add any necessary layouts to this post
#
# layouts - The Hash of {"name" => "layout"}.
# site_payload - The site payload Hash.
#
# Returns String rendered page.
def render(layouts, site_payload)
site_payload["page"] = to_liquid
site_payload["paginator"] = pager.to_liquid
do_layout(site_payload, layouts)
def render(_, site_payload = nil)
Jekyll::Renderer.new(site, self, site_payload).run
end
# The path to the source file
#
# Returns the path to the source file
# To maintain backwards compataiblity, path is relative for Pages
# but absolute for documents. Use #absolute_path to get the absolute path
def path
data.fetch("path") { relative_path }
Jekyll::Deprecator.deprecation_message "Page#path is now Page#relative_path."
Jekyll::Deprecator.deprecation_message "Called by #{caller(1..1).first}."
relative_path
end
# The path to the page source file, relative to the site source
def relative_path
File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).sub(%r!\A\/!, "")
end
private
# Obtain destination path.
#
# dest - The String path to the destination dir.
#
# Returns the destination file path String.
def destination(dest)
path = site.in_dest_dir(dest, URL.unescape_path(url))
path = File.join(path, "index") if url.end_with?("/")
path << output_ext unless path.end_with? output_ext
path
end
# Returns the object as a debug String.
def inspect
"#<Jekyll::Page @name=#{name.inspect}>"
end
# Returns the Boolean of whether this Page is HTML or not.
def html?
HTML_EXTENSIONS.include?(output_ext)
end
# Returns the Boolean of whether this Page is an index file or not.
def index?
basename == "index"
end
def trigger_hooks(hook_name, *args)
Jekyll::Hooks.trigger :pages, hook_name, self, *args
end
def write?
true
def backwards_compatibilize
ATTRIBUTES_FOR_LIQUID.each do |key|
data[key] = public_send(key.to_sym)
end
@url = nil
end
end
end

View File

@@ -14,5 +14,21 @@ module Jekyll
def inspect
"#<Jekyll:PageWithoutAFile @name=#{name.inspect}>"
end
def draft?
!!data["draft"]
end
def do_nothing(*)
nil
end
alias_method :process, :do_nothing
alias_method :read, :do_nothing
alias_method :read_content, :do_nothing
alias_method :read_post_data, :do_nothing
alias_method :categories_from_path, :do_nothing
alias_method :populate_categories, :do_nothing
alias_method :populate_tags, :do_nothing
alias_method :backwards_compatibilize, :do_nothing
end
end

View File

@@ -23,7 +23,6 @@ module Jekyll
# Sorts posts, pages, and static files.
def sort_files!
site.collections.each_value { |c| c.docs.sort! }
site.pages.sort_by!(&:name)
site.static_files.sort_by!(&:relative_path)
end
@@ -88,7 +87,7 @@ module Jekyll
#
# Returns nothing.
def retrieve_pages(dir, dot_pages)
site.pages.concat(PageReader.new(site, dir).read(dot_pages))
site.pages.docs.concat(PageReader.new(site, dir).read(dot_pages))
end
# Retrieve all the static files from the current directory,

View File

@@ -2,7 +2,7 @@
module Jekyll
class CollectionReader
SPECIAL_COLLECTIONS = %w(posts data).freeze
SPECIAL_COLLECTIONS = %w(posts data pages).freeze
attr_reader :site, :content
def initialize(site)

View File

@@ -17,9 +17,11 @@ module Jekyll
# Returns an array of static pages.
def read(files)
files.map do |page|
@unfiltered_content << Page.new(@site, @site.source, @dir, page)
end
@unfiltered_content.select { |page| site.publisher.publish?(page) }
path = File.join @site.source, @dir, page
doc = Page.new(path, :collection => site.pages, :site => site)
doc.read
doc if site.publisher.publish?(doc)
end.compact
end
end
end

View File

@@ -164,14 +164,14 @@ module Jekyll
def regenerate_page?(document)
document.asset_file? || document.data["regenerate"] ||
source_modified_or_dest_missing?(
site.in_source_dir(document.relative_path), document.destination(@site.dest)
document.absolute_path, document.destination(@site.dest)
)
end
def regenerate_document?(document)
!document.write? || document.data["regenerate"] ||
source_modified_or_dest_missing?(
document.path, document.destination(@site.dest)
document.absolute_path, document.destination(@site.dest)
)
end

View File

@@ -76,7 +76,7 @@ module Jekyll
output = document.content
if document.render_with_liquid?
Jekyll.logger.debug "Rendering Liquid:", document.relative_path
output = render_liquid(output, payload, info, document.path)
output = render_liquid(output, payload, info, document.relative_path)
end
Jekyll.logger.debug "Rendering Markup:", document.relative_path
@@ -203,7 +203,7 @@ module Jekyll
def add_regenerator_dependencies(layout)
return unless document.write?
site.regenerator.add_dependency(
site.in_source_dir(document.path),
site.in_source_dir(document.relative_path),
layout.path
)
end

View File

@@ -3,7 +3,7 @@
module Jekyll
class Site
attr_reader :source, :dest, :config
attr_accessor :layouts, :pages, :static_files, :drafts,
attr_accessor :layouts, :static_files, :drafts,
:exclude, :include, :lsi, :highlighter, :permalink_style,
:time, :future, :unpublished, :safe, :plugins, :limit_posts,
:show_drafts, :keep_files, :baseurl, :data, :file_read_opts,
@@ -88,7 +88,6 @@ module Jekyll
Time.now
end
self.layouts = {}
self.pages = []
self.static_files = []
self.data = {}
@site_data = nil
@@ -100,7 +99,6 @@ module Jekyll
raise ArgumentError, "limit_posts must be a non-negative number" if limit_posts.negative?
Jekyll::Cache.clear_if_config_changed config
Jekyll::Hooks.trigger :site, :after_reset, self
end
@@ -132,11 +130,18 @@ module Jekyll
# If config['collections'] is set, a new instance is created
# for each item in the collection, a new hash is returned otherwise.
#
# Note: For backwards compatibility, we want Pages to be the last
# collection to render so other documents have output at render time
#
# Returns a Hash containing collection name-to-instance pairs.
def collections
@collections ||= Hash[collection_names.map do |coll|
[coll, Jekyll::Collection.new(self, coll)]
end]
@collections ||= begin
collections = Hash[collection_names.map do |coll|
[coll, Jekyll::Collection.new(self, coll)]
end]
collections["pages"] = collections.delete("pages")
collections
end
end
# The list of collection names.
@@ -188,7 +193,6 @@ module Jekyll
Jekyll::Hooks.trigger :site, :pre_render, self, payload
render_docs(payload)
render_pages(payload)
Jekyll::Hooks.trigger :site, :post_render, self, payload
end
@@ -215,6 +219,10 @@ module Jekyll
collections["posts"] ||= Collection.new(self, "posts")
end
def pages
collections["pages"] ||= Collection.new(self, "pages")
end
# Construct a Hash of Posts indexed by the specified Post attribute.
#
# post_attr - The String name of the Post attribute.
@@ -326,7 +334,7 @@ module Jekyll
end
def each_site_file
%w(pages static_files docs_to_write).each do |type|
%w(static_files docs_to_write).each do |type|
send(type).each do |item|
yield item
end
@@ -460,12 +468,6 @@ module Jekyll
end
end
def render_pages(payload)
pages.flatten.each do |page|
render_regenerated(page, payload)
end
end
def render_regenerated(document, payload)
return unless regenerator.regenerate?(document)
document.output = Jekyll::Renderer.new(self, document, payload).run

View File

@@ -31,25 +31,22 @@ module Jekyll
def render(context)
prefix = context["highlighter_prefix"] || ""
suffix = context["highlighter_suffix"] || ""
key = super.to_s
cache.getset(key) do
code = key.gsub(%r!\A(\n|\r)+|(\n|\r)+\z!, "")
code = super.to_s.gsub(%r!\A(\n|\r)+|(\n|\r)+\z!, "")
is_safe = !!context.registers[:site].safe
is_safe = !!context.registers[:site].safe
output =
case context.registers[:site].highlighter
when "pygments"
render_pygments(code, is_safe)
when "rouge"
render_rouge(code)
else
render_codehighlighter(code)
end
output =
case context.registers[:site].highlighter
when "pygments"
render_pygments(code, is_safe)
when "rouge"
render_rouge(code)
else
render_codehighlighter(code)
end
rendered_output = add_code_tag(output)
prefix + rendered_output + suffix
end
rendered_output = add_code_tag(output)
prefix + rendered_output + suffix
end
def sanitized_opts(opts, is_safe)
@@ -70,10 +67,6 @@ module Jekyll
OPTIONS_REGEX = %r!(?:\w="[^"]*"|\w=\w|\w)+!
def cache
Jekyll::Cache.new("Jekyll::Tags::HighlightBlock")
end
def parse_options(input)
options = {}
return options if input.empty?

View File

@@ -90,7 +90,13 @@ module Jekyll
# Render the variable if required
def render_variable(context)
Liquid::Template.parse(@file).render(context) if @file =~ VARIABLE_SYNTAX
if @file =~ VARIABLE_SYNTAX
partial = context.registers[:site]
.liquid_renderer
.file("(variable)")
.parse(@file)
partial.render!(context)
end
end
def tag_includes_dirs(context)

View File

@@ -17,7 +17,9 @@ module Jekyll
def render(context)
site = context.registers[:site]
relative_path = Liquid::Template.parse(@relative_path).render(context)
liquid = site.liquid_renderer.file("(jekyll:link)")
relative_path = liquid.parse(@relative_path).render(context)
site.each_site_file do |item|
return item.url if item.relative_path == relative_path

View File

@@ -1,5 +1,4 @@
---
permalink: /404.html
layout: default
---

View File

@@ -6,11 +6,7 @@ categories: jekyll update
---
Youll find this post in your `_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated.
Jekyll requires blog post files to be named according to the following format:
`YEAR-MONTH-DAY-title.MARKUP`
Where `YEAR` is a four-digit number, `MONTH` and `DAY` are both two-digit numbers, and `MARKUP` is the file extension representing the format used in the file. After that, include the necessary front matter. Take a look at the source for this post to get an idea about how it works.
To add new posts, simply add a file in the `_posts` directory that follows the convention `YYYY-MM-DD-name-of-post.ext` and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works.
Jekyll also offers powerful support for code snippets:

View File

@@ -19,6 +19,9 @@ def site_configuration(overrides = {})
"source" => source_dir,
"destination" => dest_dir
}, build_configs(overrides))
.fix_common_issues
.backwards_compatibilize
.add_default_collections
end
def dest_dir(*subdirs)

View File

@@ -1,4 +0,0 @@
---
render_with_liquid: false
---
{% raw %}{% endraw %}

View File

@@ -111,13 +111,13 @@ class JekyllUnitTest < Minitest::Test
end
def fixture_document(relative_path)
site = fixture_site(
site = fixture_site({
"collections" => {
"methods" => {
"output" => true,
},
}
)
},
})
site.read
matching_doc = site.collections["methods"].docs.find do |doc|
doc.relative_path == relative_path
@@ -138,13 +138,13 @@ class JekyllUnitTest < Minitest::Test
end
def site_configuration(overrides = {})
full_overrides = build_configs(overrides, build_configs(
"destination" => dest_dir,
"incremental" => false
))
Configuration.from(full_overrides.merge(
"source" => source_dir
))
full_overrides = build_configs(overrides, build_configs({
"destination" => dest_dir,
"incremental" => false,
}))
Configuration.from(full_overrides.merge({
"source" => source_dir,
}))
end
def clear_dest
@@ -197,6 +197,7 @@ class FakeLogger
end
module TestWEBrick
module_function
def mount_server(&block)
@@ -204,7 +205,7 @@ module TestWEBrick
begin
server.mount("/", Jekyll::Commands::Serve::Servlet, document_root,
document_root_options)
document_root_options)
server.start
addr = server.listeners[0].addr
@@ -234,11 +235,11 @@ module TestWEBrick
end
def document_root_options
WEBrick::Config::FileHandler.merge(
WEBrick::Config::FileHandler.merge({
:FancyIndexing => true,
:NondisclosureName => [
".ht*", "~*",
]
)
],
})
end
end

View File

@@ -15,7 +15,7 @@ class TestAnsi < JekyllUnitTest
end
should "be able to strip colors" do
assert_equal "hello", @subject.strip(@subject.yellow(@subject.red("hello")))
assert_equal @subject.strip(@subject.yellow(@subject.red("hello"))), "hello"
end
should "be able to detect colors" do

View File

@@ -9,33 +9,33 @@ class TestCoffeeScript < JekyllUnitTest
@site = fixture_site
@site.process
@test_coffeescript_file = dest_dir("js/coffeescript.js")
@js_output = <<~JS
(function() {
$(function() {
var cube, cubes, list, num, square;
list = [1, 2, 3, 4, 5];
square = function(x) {
return x * x;
};
cube = function(x) {
return square(x) * x;
};
cubes = (function() {
var i, len, results;
results = [];
for (i = 0, len = list.length; i < len; i++) {
num = list[i];
results.push(math.cube(num));
}
return results;
})();
if (typeof elvis !== "undefined" && elvis !== null) {
return alert("I knew it!");
}
});
@js_output = <<-JS
(function() {
$(function() {
var cube, cubes, list, num, square;
list = [1, 2, 3, 4, 5];
square = function(x) {
return x * x;
};
cube = function(x) {
return square(x) * x;
};
cubes = (function() {
var i, len, results;
results = [];
for (i = 0, len = list.length; i < len; i++) {
num = list[i];
results.push(math.cube(num));
}
return results;
})();
if (typeof elvis !== "undefined" && elvis !== null) {
return alert("I knew it!");
}
});
}).call(this);
JS
}).call(this);
JS
end
should "write a JS file in place" do

View File

@@ -9,11 +9,11 @@ class TestCollections < JekyllUnitTest
end
should "sanitize the label name" do
assert_equal "....etcpassword", @collection.label
assert_equal @collection.label, "....etcpassword"
end
should "have a sanitized relative path name" do
assert_equal "_....etcpassword", @collection.relative_directory
assert_equal @collection.relative_directory, "_....etcpassword"
end
should "have a sanitized full path" do
@@ -27,11 +27,11 @@ class TestCollections < JekyllUnitTest
end
should "sanitize the label name" do
assert_equal "methods", @collection.label
assert_equal @collection.label, "methods"
end
should "have default URL template" do
assert_equal "/:collection/:path:output_ext", @collection.url_template
assert_equal @collection.url_template, "/:collection/:path:output_ext"
end
should "contain no docs when initialized" do
@@ -39,7 +39,7 @@ class TestCollections < JekyllUnitTest
end
should "know its relative directory" do
assert_equal "_methods", @collection.relative_directory
assert_equal @collection.relative_directory, "_methods"
end
should "know the full path to itself on the filesystem" do
@@ -48,15 +48,15 @@ class TestCollections < JekyllUnitTest
context "when turned into Liquid" do
should "have a label attribute" do
assert_equal "methods", @collection.to_liquid["label"]
assert_equal @collection.to_liquid["label"], "methods"
end
should "have a docs attribute" do
assert_equal [], @collection.to_liquid["docs"]
assert_equal @collection.to_liquid["docs"], []
end
should "have a files attribute" do
assert_equal [], @collection.to_liquid["files"]
assert_equal @collection.to_liquid["files"], []
end
should "have a directory attribute" do
@@ -64,18 +64,18 @@ class TestCollections < JekyllUnitTest
end
should "have a relative_directory attribute" do
assert_equal "_methods", @collection.to_liquid["relative_directory"]
assert_equal @collection.to_liquid["relative_directory"], "_methods"
end
should "have a output attribute" do
assert_equal false, @collection.to_liquid["output"]
assert_equal @collection.to_liquid["output"], false
end
end
should "know whether it should be written or not" do
assert_equal false, @collection.write?
assert_equal @collection.write?, false
@collection.metadata["output"] = true
assert_equal true, @collection.write?
assert_equal @collection.write?, true
@collection.metadata.delete "output"
end
end
@@ -87,35 +87,34 @@ class TestCollections < JekyllUnitTest
end
should "contain only the default collections" do
expected = {}
refute_equal expected, @site.collections
refute_equal @site.collections, {}
refute_nil @site.collections
end
end
context "a collection with permalink" do
setup do
@site = fixture_site(
@site = fixture_site({
"collections" => {
"methods" => {
"permalink" => "/awesome/:path/",
},
}
)
},
})
@site.process
@collection = @site.collections["methods"]
end
should "have custom URL template" do
assert_equal "/awesome/:path/", @collection.url_template
assert_equal @collection.url_template, "/awesome/:path/"
end
end
context "with a collection" do
setup do
@site = fixture_site(
"collections" => ["methods"]
)
@site = fixture_site({
"collections" => ["methods"],
})
@site.process
@collection = @site.collections["methods"]
end
@@ -155,36 +154,35 @@ class TestCollections < JekyllUnitTest
should "not include the underscored files in the list of docs" do
refute_includes @collection.docs.map(&:relative_path), "_methods/_do_not_read_me.md"
refute_includes @collection.docs.map(&:relative_path),
"_methods/site/_dont_include_me_either.md"
"_methods/site/_dont_include_me_either.md"
end
end
context "with a collection with metadata" do
setup do
@site = fixture_site(
@site = fixture_site({
"collections" => {
"methods" => {
"foo" => "bar",
"baz" => "whoo",
},
}
)
},
})
@site.process
@collection = @site.collections["methods"]
end
should "extract the configuration collection information as metadata" do
expected = { "foo" => "bar", "baz" => "whoo" }
assert_equal expected, @collection.metadata
assert_equal @collection.metadata, { "foo" => "bar", "baz" => "whoo" }
end
end
context "in safe mode" do
setup do
@site = fixture_site(
@site = fixture_site({
"collections" => ["methods"],
"safe" => true
)
"safe" => true,
})
@site.process
@collection = @site.collections["methods"]
end
@@ -204,10 +202,10 @@ class TestCollections < JekyllUnitTest
context "with dots in the filenames" do
setup do
@site = fixture_site(
@site = fixture_site({
"collections" => ["with.dots"],
"safe" => true
)
"safe" => true,
})
@site.process
@collection = @site.collections["with.dots"]
end
@@ -233,14 +231,14 @@ class TestCollections < JekyllUnitTest
context "a collection with included dotfiles" do
setup do
@site = fixture_site(
@site = fixture_site({
"collections" => {
"methods" => {
"permalink" => "/awesome/:path/",
},
},
"include" => %w(.htaccess .gitignore)
)
"include" => %w(.htaccess .gitignore),
})
@site.process
@collection = @site.collections["methods"]
end

View File

@@ -15,9 +15,7 @@ class TestCommand < JekyllUnitTest
context "when fatal error occurs" do
should "exit with non-zero error code" do
site = Object.new
def site.process
raise Jekyll::Errors::FatalException
end
def site.process; raise Jekyll::Errors::FatalException; end
error = assert_raises(SystemExit) { Command.process_site(site) }
refute_equal 0, error.status
end

View File

@@ -5,6 +5,7 @@ require "mercenary"
require "helper"
require "httpclient"
require "openssl"
require "thread"
require "tmpdir"
class TestCommandsServe < JekyllUnitTest
@@ -125,9 +126,9 @@ class TestCommandsServe < JekyllUnitTest
should "apply the max and min delay options" do
skip_if_windows "EventMachine support on Windows is limited"
opts = serve(@standard_options.merge(
"livereload_max_delay" => "1066",
"livereload_min_delay" => "3"
))
"livereload_max_delay" => "1066",
"livereload_min_delay" => "3"
))
content = @client.get_content(
"http://#{opts["host"]}:#{opts["port"]}/#{opts["baseurl"]}/hello.html"
)
@@ -154,7 +155,9 @@ class TestCommandsServe < JekyllUnitTest
end
should "label itself" do
assert_equal :serve, @merc.name
assert_equal(
@merc.name, :serve
)
end
should "have aliases" do
@@ -188,14 +191,14 @@ class TestCommandsServe < JekyllUnitTest
end
should "use user destinations" do
assert_equal "foo", custom_opts("destination" => "foo")[
assert_equal "foo", custom_opts({ "destination" => "foo" })[
:DocumentRoot
]
end
should "use user port" do
# WHAT?!?!1 Over 9000? That's impossible.
assert_equal 9001, custom_opts("port" => 9001)[
assert_equal 9001, custom_opts({ "port" => 9001 })[
:Port
]
end
@@ -234,20 +237,21 @@ class TestCommandsServe < JekyllUnitTest
expect(Jekyll::Commands::Serve).to receive(:start_up_webrick)
end
should "set the site url by default to `http://localhost:4000`" do
@merc.execute(:serve, "watch" => false, "url" => "https://jekyllrb.com/")
@merc.execute(:serve, { "watch" => false, "url" => "https://jekyllrb.com/" })
assert_equal 1, Jekyll.sites.count
assert_equal "http://localhost:4000", Jekyll.sites.first.config["url"]
end
should "take `host`, `port` and `ssl` into consideration if set" do
@merc.execute(:serve,
"watch" => false,
"host" => "example.com",
"port" => "9999",
"url" => "https://jekyllrb.com/",
"ssl_cert" => "foo",
"ssl_key" => "bar")
@merc.execute(:serve, {
"watch" => false,
"host" => "example.com",
"port" => "9999",
"url" => "https://jekyllrb.com/",
"ssl_cert" => "foo",
"ssl_key" => "bar",
})
assert_equal 1, Jekyll.sites.count
assert_equal "https://example.com:9999", Jekyll.sites.first.config["url"]
@@ -258,7 +262,7 @@ class TestCommandsServe < JekyllUnitTest
should "not update the site url" do
expect(Jekyll).to receive(:env).and_return("production")
expect(Jekyll::Commands::Serve).to receive(:start_up_webrick)
@merc.execute(:serve, "watch" => false, "url" => "https://jekyllrb.com/")
@merc.execute(:serve, { "watch" => false, "url" => "https://jekyllrb.com/" })
assert_equal 1, Jekyll.sites.count
assert_equal "https://jekyllrb.com/", Jekyll.sites.first.config["url"]
@@ -267,26 +271,26 @@ class TestCommandsServe < JekyllUnitTest
context "verbose" do
should "debug when verbose" do
assert_equal 5, custom_opts("verbose" => true)[:Logger].level
assert_equal custom_opts({ "verbose" => true })[:Logger].level, 5
end
should "warn when not verbose" do
assert_equal 3, custom_opts({})[:Logger].level
assert_equal custom_opts({})[:Logger].level, 3
end
end
context "enabling SSL" do
should "raise if enabling without key or cert" do
assert_raises RuntimeError do
custom_opts(
"ssl_key" => "foo"
)
custom_opts({
"ssl_key" => "foo",
})
end
assert_raises RuntimeError do
custom_opts(
"ssl_key" => "foo"
)
custom_opts({
"ssl_key" => "foo",
})
end
end
@@ -295,16 +299,16 @@ class TestCommandsServe < JekyllUnitTest
expect(OpenSSL::X509::Certificate).to receive(:new).and_return("c1")
allow(File).to receive(:read).and_return("foo")
result = custom_opts(
result = custom_opts({
"ssl_cert" => "foo",
"source" => "bar",
"enable_ssl" => true,
"ssl_key" => "bar"
)
"ssl_key" => "bar",
})
assert result[:SSLEnable]
assert_equal "c2", result[:SSLPrivateKey]
assert_equal "c1", result[:SSLCertificate]
assert_equal result[:SSLPrivateKey], "c2"
assert_equal result[:SSLCertificate], "c1"
end
end
end
@@ -313,7 +317,7 @@ class TestCommandsServe < JekyllUnitTest
allow(Jekyll::Commands::Serve).to receive(:start_up_webrick)
expect(Jekyll).to receive(:configuration).once.and_call_original
@merc.execute(:serve, "watch" => false)
@merc.execute(:serve, { "watch" => false })
end
end
end

View File

@@ -15,9 +15,9 @@ class TestConfiguration < JekyllUnitTest
end
should "merge input over defaults" do
result = Configuration.from("source" => "blah")
result = Configuration.from({ "source" => "blah" })
refute_equal result["source"], Configuration::DEFAULTS["source"]
assert_equal "blah", result["source"]
assert_equal result["source"], "blah"
end
should "return a valid Configuration instance" do
@@ -26,11 +26,18 @@ class TestConfiguration < JekyllUnitTest
should "add default collections" do
result = Configuration.from({})
expected = { "posts" => {
"output" => true,
"permalink" => "/:categories/:year/:month/:day/:title:output_ext",
}, }
assert_equal expected, result["collections"]
assert_equal(
{
"posts" => {
"output" => true,
"permalink" => "/:categories/:year/:month/:day/:title:output_ext",
},
"pages" => {
"output" => true,
}
},
result["collections"],
)
end
should "NOT backwards-compatibilize" do
@@ -66,29 +73,55 @@ class TestConfiguration < JekyllUnitTest
should "turn an array into a hash" do
result = Configuration[{ "collections" => %w(methods) }].add_default_collections
assert_instance_of Hash, result["collections"]
expected = { "posts" => { "output" => true }, "methods" => {} }
assert_equal expected, result["collections"]
assert_equal(
result["collections"],
{
"posts" => {
"output" => true
},
"pages" => {
"output" => true
},
"methods" => {}
}
)
end
should "only assign collections.posts.permalink if a permalink is specified" do
result = Configuration[{ "permalink" => "pretty", "collections" => {} }]
.add_default_collections
expected = { "posts" => {
"output" => true,
"permalink" => "/:categories/:year/:month/:day/:title/",
}, }
assert_equal expected, result["collections"]
assert_equal(
result["collections"],
{
"posts" => {
"output" => true,
"permalink" => "/:categories/:year/:month/:day/:title/",
},
"pages" => {
"output" => true
}
}
)
result = Configuration[{ "permalink" => nil, "collections" => {} }]
.add_default_collections
expected = { "posts" => { "output" => true } }
assert_equal expected, result["collections"]
assert_equal(
result["collections"],
{
"posts" => {
"output" => true
},
"pages" => {
"output" => true
}
}
)
end
should "forces posts to output" do
result = Configuration[{ "collections" => { "posts" => { "output" => false } } }]
.add_default_collections
assert_equal true, result["collections"]["posts"]["output"]
assert_equal result["collections"]["posts"]["output"], true
end
end
@@ -177,7 +210,7 @@ class TestConfiguration < JekyllUnitTest
allow(SafeYAML)
.to receive(:load_file)
.with("not_empty.yml")
.and_return("foo" => "bar", "include" => "", "exclude" => "")
.and_return({ "foo" => "bar", "include" => "", "exclude" => "" })
Jekyll.logger.log_level = :warn
read_config = @config.read_config_files(["empty.yml", "not_empty.yml"])
Jekyll.logger.log_level = :info
@@ -211,19 +244,23 @@ class TestConfiguration < JekyllUnitTest
should "transform string exclude into an array" do
assert @config.key?("exclude")
assert @config.backwards_compatibilize.key?("exclude")
expected = %w(READ-ME.md Gemfile CONTRIBUTING.hello.markdown)
assert_equal expected, @config.backwards_compatibilize["exclude"]
assert_equal(
@config.backwards_compatibilize["exclude"],
%w(READ-ME.md Gemfile CONTRIBUTING.hello.markdown)
)
end
should "transform string include into an array" do
assert @config.key?("include")
assert @config.backwards_compatibilize.key?("include")
expected = %w(STOP_THE_PRESSES.txt .heloses .git)
assert_equal expected, @config.backwards_compatibilize["include"]
assert_equal(
@config.backwards_compatibilize["include"],
%w(STOP_THE_PRESSES.txt .heloses .git)
)
end
should "set highlighter to pygments" do
assert @config.key?("pygments")
assert !@config.backwards_compatibilize.key?("pygments")
assert_equal "pygments", @config.backwards_compatibilize["highlighter"]
assert_equal @config.backwards_compatibilize["highlighter"], "pygments"
end
should "adjust directory names" do
assert @config.key?("layouts")
@@ -288,11 +325,11 @@ class TestConfiguration < JekyllUnitTest
allow($stderr)
.to receive(:puts)
.with(Colorator.red(
"Fatal: ".rjust(20) + \
"The configuration file '#{@user_config}' could not be found."
))
"Fatal: ".rjust(20) + \
"The configuration file '#{@user_config}' could not be found."
))
assert_raises LoadError do
Jekyll.configuration("config" => [@user_config])
Jekyll.configuration({ "config" => [@user_config] })
end
end
@@ -321,14 +358,14 @@ class TestConfiguration < JekyllUnitTest
allow(SafeYAML)
.to receive(:load_file)
.with(@paths[:other])
.and_return("baseurl" => "http://example.com")
.and_return({ "baseurl" => "http://example.com" })
allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}")
assert_equal \
site_configuration(
site_configuration({
"baseurl" => "http://example.com",
"config" => @paths[:other]
),
Jekyll.configuration(test_config.merge("config" => @paths[:other]))
"config" => @paths[:other],
}),
Jekyll.configuration(test_config.merge({ "config" => @paths[:other] }))
end
should "load different config if specified with symbol key" do
@@ -336,33 +373,33 @@ class TestConfiguration < JekyllUnitTest
allow(SafeYAML)
.to receive(:load_file)
.with(@paths[:other])
.and_return("baseurl" => "http://example.com")
.and_return({ "baseurl" => "http://example.com" })
allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}")
assert_equal \
site_configuration(
site_configuration({
"baseurl" => "http://example.com",
"config" => @paths[:other]
),
Jekyll.configuration(test_config.merge(:config => @paths[:other]))
"config" => @paths[:other],
}),
Jekyll.configuration(test_config.merge({ :config => @paths[:other] }))
end
should "load default config if path passed is empty" do
allow(SafeYAML).to receive(:load_file).with(@paths[:default]).and_return({})
allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:default]}")
assert_equal \
site_configuration("config" => [@paths[:empty]]),
Jekyll.configuration(test_config.merge("config" => [@paths[:empty]]))
site_configuration({ "config" => [@paths[:empty]] }),
Jekyll.configuration(test_config.merge({ "config" => [@paths[:empty]] }))
end
should "successfully load a TOML file" do
Jekyll.logger.log_level = :warn
assert_equal \
site_configuration(
site_configuration({
"baseurl" => "/you-beautiful-blog-you",
"title" => "My magnificent site, wut",
"config" => [@paths[:toml]]
),
Jekyll.configuration(test_config.merge("config" => [@paths[:toml]]))
"config" => [@paths[:toml]],
}),
Jekyll.configuration(test_config.merge({ "config" => [@paths[:toml]] }))
Jekyll.logger.log_level = :info
end
@@ -376,12 +413,12 @@ class TestConfiguration < JekyllUnitTest
allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}")
allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:toml]}")
assert_equal(
site_configuration(
"config" => [@paths[:default], @paths[:other], @paths[:toml]]
),
site_configuration({
"config" => [@paths[:default], @paths[:other], @paths[:toml]],
}),
Jekyll.configuration(
test_config.merge(
"config" => [@paths[:default], @paths[:other], @paths[:toml]]
{ "config" => [@paths[:default], @paths[:other], @paths[:toml]] }
)
)
)
@@ -391,11 +428,11 @@ class TestConfiguration < JekyllUnitTest
allow(SafeYAML)
.to receive(:load_file)
.with(@paths[:default])
.and_return("baseurl" => "http://example.dev")
.and_return({ "baseurl" => "http://example.dev" })
allow(SafeYAML)
.to receive(:load_file)
.with(@paths[:other])
.and_return("baseurl" => "http://example.com")
.and_return({ "baseurl" => "http://example.com" })
allow($stdout)
.to receive(:puts)
.with("Configuration file: #{@paths[:default]}")
@@ -403,12 +440,12 @@ class TestConfiguration < JekyllUnitTest
.to receive(:puts)
.with("Configuration file: #{@paths[:other]}")
assert_equal \
site_configuration(
site_configuration({
"baseurl" => "http://example.com",
"config" => [@paths[:default], @paths[:other]]
),
"config" => [@paths[:default], @paths[:other]],
}),
Jekyll.configuration(
test_config.merge("config" => [@paths[:default], @paths[:other]])
test_config.merge({ "config" => [@paths[:default], @paths[:other]] })
)
end
end
@@ -424,58 +461,67 @@ class TestConfiguration < JekyllUnitTest
conf = Configuration[default_configuration].tap do |c|
c["collections"] = ["docs"]
end
assert_equal conf.add_default_collections, conf.merge(
assert_equal conf.add_default_collections, conf.merge({
"collections" => {
"docs" => {},
"posts" => {
"output" => true,
"permalink" => "/:categories/:year/:month/:day/:title:output_ext",
},
}
)
"pages" => {
"output" => true,
},
"docs" => {},
},
})
end
should "force collections.posts.output = true" do
conf = Configuration[default_configuration].tap do |c|
c["collections"] = { "posts" => { "output" => false } }
end
assert_equal conf.add_default_collections, conf.merge(
assert_equal conf.add_default_collections, conf.merge({
"collections" => {
"posts" => {
"output" => true,
"permalink" => "/:categories/:year/:month/:day/:title:output_ext",
},
}
)
"pages" => {
"output" => true
},
},
})
end
should "set collections.posts.permalink if it's not set" do
conf = Configuration[default_configuration]
assert_equal conf.add_default_collections, conf.merge(
assert_equal conf.add_default_collections, conf.merge({
"collections" => {
"posts" => {
"output" => true,
"permalink" => "/:categories/:year/:month/:day/:title:output_ext",
},
}
)
"pages" => {
"output" => true
},
},
})
end
should "leave collections.posts.permalink alone if it is set" do
posts_permalink = "/:year/:title/"
conf = Configuration[default_configuration].tap do |c|
c["collections"] = {
"posts" => { "permalink" => posts_permalink },
}
end
assert_equal conf.add_default_collections, conf.merge(
conf = Configuration[default_configuration]
conf["collections"]["posts"] = { "permalink" => posts_permalink }
assert_equal conf.add_default_collections, conf.merge({
"collections" => {
"posts" => {
"output" => true,
"permalink" => posts_permalink,
"output" => true,
},
"pages" => {
"output" => true
}
}
)
})
end
end
@@ -491,13 +537,12 @@ class TestConfiguration < JekyllUnitTest
)
)
assert_equal(
"This string of text will ignore newlines till the next key.\n",
config["folded_string"]
config["folded_string"],
"This string of text will ignore newlines till the next key.\n"
)
assert_equal(
"This string of text will ignore newlines till the next key.",
config["clean_folded_string"]
config["clean_folded_string"],
"This string of text will ignore newlines till the next key."
)
end

View File

@@ -8,8 +8,8 @@ class TestConvertible < JekyllUnitTest
setup do
@convertible = OpenStruct.new(
"site" => Site.new(Jekyll.configuration(
"source" => File.expand_path("fixtures", __dir__)
))
"source" => File.expand_path("fixtures", __dir__)
))
)
@convertible.extend Jekyll::Convertible
@base = File.expand_path("fixtures", __dir__)
@@ -73,12 +73,5 @@ class TestConvertible < JekyllUnitTest
end
refute_match(%r!Invalid permalink!, out)
end
should "not parse Liquid if disabled in front matter" do
name = "no_liquid.erb"
@convertible.read_yaml(@base, name)
ret = @convertible.content.strip
assert_equal("{% raw %}{% endraw %}", ret)
end
end
end

View File

@@ -10,10 +10,10 @@ class TestDoctorCommand < JekyllUnitTest
end
should "return success on a valid site/page" do
@site = Site.new(Jekyll.configuration(
"source" => File.join(source_dir, "/_urls_differ_by_case_valid"),
"destination" => dest_dir
))
@site = Site.new(Jekyll.configuration({
"source" => File.join(source_dir, "/_urls_differ_by_case_valid"),
"destination" => dest_dir,
}))
@site.process
output = capture_stderr do
ret = Jekyll::Commands::Doctor.urls_only_differ_by_case(@site)
@@ -23,10 +23,10 @@ class TestDoctorCommand < JekyllUnitTest
end
should "return warning for pages only differing by case" do
@site = Site.new(Jekyll.configuration(
"source" => File.join(source_dir, "/_urls_differ_by_case_invalid"),
"destination" => dest_dir
))
@site = Site.new(Jekyll.configuration({
"source" => File.join(source_dir, "/_urls_differ_by_case_invalid"),
"destination" => dest_dir,
}))
@site.process
output = capture_stderr do
ret = Jekyll::Commands::Doctor.urls_only_differ_by_case(@site)

View File

@@ -10,9 +10,10 @@ class TestDocument < JekyllUnitTest
def setup_encoded_document(filename)
site = fixture_site("collections" => ["encodings"])
site.process
Document.new(site.in_source_dir(File.join("_encodings", filename)),
:site => site,
:collection => site.collections["encodings"]).tap(&:read)
Document.new(site.in_source_dir(File.join("_encodings", filename)), {
:site => site,
:collection => site.collections["encodings"],
}).tap(&:read)
end
def setup_document_with_dates(filename)
@@ -20,18 +21,19 @@ class TestDocument < JekyllUnitTest
site.process
docs = nil
with_env("TZ", "UTC") do
docs = Document.new(site.in_source_dir(File.join("_dates", filename)),
:site => site,
:collection => site.collections["dates"]).tap(&:read)
docs = Document.new(site.in_source_dir(File.join("_dates", filename)), {
:site => site,
:collection => site.collections["dates"],
}).tap(&:read)
end
docs
end
context "a document in a collection" do
setup do
@site = fixture_site(
"collections" => ["methods"]
)
@site = fixture_site({
"collections" => ["methods"],
})
@site.process
@document = @site.collections["methods"].docs.detect do |d|
d.relative_path == "_methods/configuration.md"
@@ -110,7 +112,7 @@ class TestDocument < JekyllUnitTest
context "with YAML ending in three dots" do
setup do
@site = fixture_site("collections" => ["methods"])
@site = fixture_site({ "collections" => ["methods"] })
@site.process
@document = @site.collections["methods"].docs.detect do |d|
d.relative_path == "_methods/yaml_with_dots.md"
@@ -124,17 +126,17 @@ class TestDocument < JekyllUnitTest
end
should "output the collection name in the #to_liquid method" do
assert_equal "methods", @document.to_liquid["collection"]
assert_equal @document.to_liquid["collection"], "methods"
end
should "output its relative path as path in Liquid" do
assert_equal "_methods/configuration.md", @document.to_liquid["path"]
assert_equal @document.to_liquid["path"], "_methods/configuration.md"
end
end
context "a document as part of a collection with front matter defaults" do
setup do
@site = fixture_site(
@site = fixture_site({
"collections" => ["slides"],
"defaults" => [{
"scope" => { "path" => "", "type" => "slides" },
@@ -143,8 +145,8 @@ class TestDocument < JekyllUnitTest
"key" => "myval",
},
},
},]
)
},],
})
@site.process
@document = @site.collections["slides"].docs.select { |d| d.is_a?(Document) }.first
end
@@ -164,7 +166,7 @@ class TestDocument < JekyllUnitTest
context "a document as part of a collection with overridden default values" do
setup do
@site = fixture_site(
@site = fixture_site({
"collections" => ["slides"],
"defaults" => [{
"scope" => { "path" => "", "type" => "slides" },
@@ -174,8 +176,8 @@ class TestDocument < JekyllUnitTest
"test2" => "default1",
},
},
},]
)
},],
})
@site.process
@document = @site.collections["slides"].docs[1]
end
@@ -192,7 +194,7 @@ class TestDocument < JekyllUnitTest
context "a document as part of a collection with valid path" do
setup do
@site = fixture_site(
@site = fixture_site({
"collections" => ["slides"],
"defaults" => [{
"scope" => { "path" => "_slides", "type" => "slides" },
@@ -201,8 +203,8 @@ class TestDocument < JekyllUnitTest
"key" => "value123",
},
},
},]
)
},],
})
@site.process
@document = @site.collections["slides"].docs.first
end
@@ -216,7 +218,7 @@ class TestDocument < JekyllUnitTest
context "a document as part of a collection with invalid path" do
setup do
@site = fixture_site(
@site = fixture_site({
"collections" => ["slides"],
"defaults" => [{
"scope" => { "path" => "somepath", "type" => "slides" },
@@ -225,8 +227,8 @@ class TestDocument < JekyllUnitTest
"key" => "myval",
},
},
},]
)
},],
})
@site.process
@document = @site.collections["slides"].docs.first
end
@@ -240,9 +242,9 @@ class TestDocument < JekyllUnitTest
context "a document in a collection with a custom permalink" do
setup do
@site = fixture_site(
"collections" => ["slides"]
)
@site = fixture_site({
"collections" => ["slides"],
})
@site.process
@document = @site.collections["slides"].docs[2]
@dest_file = dest_dir("slide/3/index.html")
@@ -259,15 +261,15 @@ class TestDocument < JekyllUnitTest
context "a document in a collection with custom filename permalinks" do
setup do
@site = fixture_site(
@site = fixture_site({
"collections" => {
"slides" => {
"output" => true,
"permalink" => "/slides/test/:name",
},
},
"permalink" => "pretty"
)
"permalink" => "pretty",
})
@site.process
@document = @site.collections["slides"].docs[0]
@dest_file = dest_dir("slides/test/example-slide-1.html")
@@ -288,13 +290,13 @@ class TestDocument < JekyllUnitTest
context "a document in a collection with pretty permalink style" do
setup do
@site = fixture_site(
@site = fixture_site({
"collections" => {
"slides" => {
"output" => true,
},
}
)
},
})
@site.permalink_style = :pretty
@site.process
@document = @site.collections["slides"].docs[0]
@@ -312,13 +314,13 @@ class TestDocument < JekyllUnitTest
context "a document in a collection with cased file name" do
setup do
@site = fixture_site(
@site = fixture_site({
"collections" => {
"slides" => {
"output" => true,
},
}
)
},
})
@site.permalink_style = :pretty
@site.process
@document = @site.collections["slides"].docs[7]
@@ -332,13 +334,13 @@ class TestDocument < JekyllUnitTest
context "a document in a collection with cased file name" do
setup do
@site = fixture_site(
@site = fixture_site({
"collections" => {
"slides" => {
"output" => true,
},
}
)
},
})
@site.process
@document = @site.collections["slides"].docs[6]
@dest_file = dest_dir("slides/example-slide-7.php")
@@ -363,14 +365,14 @@ class TestDocument < JekyllUnitTest
context "documents in a collection with custom title permalinks" do
setup do
@site = fixture_site(
@site = fixture_site({
"collections" => {
"slides" => {
"output" => true,
"permalink" => "/slides/:title",
},
}
)
},
})
@site.process
@document = @site.collections["slides"].docs[3]
@document_without_slug = @site.collections["slides"].docs[4]
@@ -408,9 +410,9 @@ class TestDocument < JekyllUnitTest
context "document with a permalink with dots & a trailing slash" do
setup do
@site = fixture_site("collections" => {
@site = fixture_site({ "collections" => {
"with.dots" => { "output" => true },
})
}, })
@site.process
@document = @site.collections["with.dots"].docs.last
@dest_file = dest_dir("with.dots", "permalink.with.slash.tho", "index.html")
@@ -431,13 +433,13 @@ class TestDocument < JekyllUnitTest
context "documents in a collection" do
setup do
@site = fixture_site(
@site = fixture_site({
"collections" => {
"slides" => {
"output" => true,
},
}
)
},
})
@site.process
@files = @site.collections["slides"].docs
end
@@ -463,13 +465,13 @@ class TestDocument < JekyllUnitTest
context "a static file in a collection" do
setup do
@site = fixture_site(
@site = fixture_site({
"collections" => {
"slides" => {
"output" => true,
},
}
)
},
})
@site.process
@document = @site.collections["slides"].files.find do |doc|
doc.relative_path == "_slides/octojekyll.png"
@@ -496,13 +498,13 @@ class TestDocument < JekyllUnitTest
context "a document in a collection with non-alphabetic file name" do
setup do
@site = fixture_site(
@site = fixture_site({
"collections" => {
"methods" => {
"output" => true,
},
}
)
},
})
@site.process
@document = @site.collections["methods"].docs.find do |doc|
doc.relative_path == "_methods/escape-+ #%20[].md"
@@ -525,13 +527,13 @@ class TestDocument < JekyllUnitTest
context "a document in a collection with dash-separated numeric file name" do
setup do
@site = fixture_site(
@site = fixture_site({
"collections" => {
"methods" => {
"output" => true,
},
}
)
},
})
@site.process
@document = @site.collections["methods"].docs.find do |doc|
doc.relative_path == "_methods/3940394-21-9393050-fifif1323-test.md"

View File

@@ -17,9 +17,9 @@ end
class TestDrop < JekyllUnitTest
context "Drops" do
setup do
@site = fixture_site(
"collections" => ["methods"]
)
@site = fixture_site({
"collections" => ["methods"],
})
@site.process
@document = @site.collections["methods"].docs.detect do |d|
d.relative_path == "_methods/configuration.md"

View File

@@ -10,7 +10,7 @@ class TestEntryFilter < JekyllUnitTest
should "filter entries" do
ent1 = %w(foo.markdown bar.markdown baz.markdown #baz.markdown#
.baz.markdow foo.markdown~ .htaccess _posts _pages ~$benbalter.docx)
.baz.markdow foo.markdown~ .htaccess _posts _pages ~$benbalter.docx)
entries = EntryFilter.new(@site).filter(ent1)
assert_equal %w(foo.markdown bar.markdown baz.markdown .htaccess), entries

View File

@@ -4,9 +4,10 @@ require "helper"
class TestExcerpt < JekyllUnitTest
def setup_post(file)
Document.new(@site.in_source_dir(File.join("_posts", file)),
:site => @site,
:collection => @site.posts).tap(&:read)
Document.new(@site.in_source_dir(File.join("_posts", file)), {
:site => @site,
:collection => @site.posts,
}).tap(&:read)
end
def do_render(document)
@@ -80,9 +81,9 @@ class TestExcerpt < JekyllUnitTest
context "#relative_path" do
should "return its document's relative path with '/#excerpt' appended" do
assert_equal "#{@excerpt.doc.relative_path}/#excerpt",
@excerpt.relative_path
@excerpt.relative_path
assert_equal "_posts/2013-07-22-post-excerpt-with-layout.markdown/#excerpt",
@excerpt.relative_path
@excerpt.relative_path
end
end

View File

@@ -28,7 +28,7 @@ class TestExcerptDrop < JekyllUnitTest
should "inherit the layout for the drop but not the excerpt" do
assert_nil @excerpt.data["layout"]
assert_equal @doc_drop["layout"], @excerpt_drop["layout"]
assert_equal @excerpt_drop["layout"], @doc_drop["layout"]
end
should "be inspectable" do
@@ -36,7 +36,7 @@ class TestExcerptDrop < JekyllUnitTest
end
should "inherit values from the document" do
assert_equal @doc_drop.keys.sort, @excerpt_drop.keys.sort
assert_equal @excerpt_drop.keys.sort, @doc_drop.keys.sort
end
end
end

View File

@@ -9,7 +9,7 @@ class TestFilters < JekyllUnitTest
def initialize(opts = {})
@site = Jekyll::Site.new(opts.merge("skip_config_files" => true))
@context = Liquid::Context.new(@site.site_payload, {}, :site => @site)
@context = Liquid::Context.new(@site.site_payload, {}, { :site => @site })
end
end
@@ -37,12 +37,12 @@ class TestFilters < JekyllUnitTest
context "filters" do
setup do
@sample_time = Time.utc(2013, 3, 27, 11, 22, 33)
@filter = make_filter_mock(
@filter = make_filter_mock({
"timezone" => "UTC",
"url" => "http://example.com",
"baseurl" => "/base",
"dont_show_posts_before" => @sample_time
)
"dont_show_posts_before" => @sample_time,
})
@sample_date = Date.parse("2013-03-02")
@time_as_string = "September 11, 2001 12:46:30 -0000"
@time_as_numeric = 1_399_680_607
@@ -88,7 +88,7 @@ class TestFilters < JekyllUnitTest
end
should "escapes special characters when configured to do so" do
kramdown = make_filter_mock(:kramdown => { :entity_output => :symbolic })
kramdown = make_filter_mock({ :kramdown => { :entity_output => :symbolic } })
assert_equal(
"&ldquo;This filter&rsquo;s test&hellip;&rdquo;",
kramdown.smartify(%q{"This filter's test..."})
@@ -406,82 +406,82 @@ class TestFilters < JekyllUnitTest
should "ensure the leading slash for the baseurl" do
page_url = "about/my_favorite_page/"
filter = make_filter_mock(
filter = make_filter_mock({
"url" => "http://example.com",
"baseurl" => "base"
)
"baseurl" => "base",
})
assert_equal "http://example.com/base/#{page_url}", filter.absolute_url(page_url)
end
should "be ok with a blank but present 'url'" do
page_url = "about/my_favorite_page/"
filter = make_filter_mock(
filter = make_filter_mock({
"url" => "",
"baseurl" => "base"
)
"baseurl" => "base",
})
assert_equal "/base/#{page_url}", filter.absolute_url(page_url)
end
should "be ok with a nil 'url'" do
page_url = "about/my_favorite_page/"
filter = make_filter_mock(
filter = make_filter_mock({
"url" => nil,
"baseurl" => "base"
)
"baseurl" => "base",
})
assert_equal "/base/#{page_url}", filter.absolute_url(page_url)
end
should "be ok with a nil 'baseurl'" do
page_url = "about/my_favorite_page/"
filter = make_filter_mock(
filter = make_filter_mock({
"url" => "http://example.com",
"baseurl" => nil
)
"baseurl" => nil,
})
assert_equal "http://example.com/#{page_url}", filter.absolute_url(page_url)
end
should "not prepend a forward slash if input is empty" do
page_url = ""
filter = make_filter_mock(
filter = make_filter_mock({
"url" => "http://example.com",
"baseurl" => "/base"
)
"baseurl" => "/base",
})
assert_equal "http://example.com/base", filter.absolute_url(page_url)
end
should "not append a forward slash if input is '/'" do
page_url = "/"
filter = make_filter_mock(
filter = make_filter_mock({
"url" => "http://example.com",
"baseurl" => "/base"
)
"baseurl" => "/base",
})
assert_equal "http://example.com/base/", filter.absolute_url(page_url)
end
should "not append a forward slash if input is '/' and nil 'baseurl'" do
page_url = "/"
filter = make_filter_mock(
filter = make_filter_mock({
"url" => "http://example.com",
"baseurl" => nil
)
"baseurl" => nil,
})
assert_equal "http://example.com/", filter.absolute_url(page_url)
end
should "not append a forward slash if both input and baseurl are simply '/'" do
page_url = "/"
filter = make_filter_mock(
filter = make_filter_mock({
"url" => "http://example.com",
"baseurl" => "/"
)
"baseurl" => "/",
})
assert_equal "http://example.com/", filter.absolute_url(page_url)
end
should "normalize international URLs" do
page_url = ""
filter = make_filter_mock(
filter = make_filter_mock({
"url" => "http://ümlaut.example.org/",
"baseurl" => nil
)
"baseurl" => nil,
})
assert_equal "http://xn--mlaut-jva.example.org/", filter.absolute_url(page_url)
end
@@ -492,19 +492,19 @@ class TestFilters < JekyllUnitTest
should "transform the input URL to a string" do
page_url = "/my-page.html"
filter = make_filter_mock("url" => Value.new(proc { "http://example.org" }))
filter = make_filter_mock({ "url" => Value.new(proc { "http://example.org" }) })
assert_equal "http://example.org#{page_url}", filter.absolute_url(page_url)
end
should "not raise a TypeError when passed a hash" do
assert @filter.absolute_url("foo" => "bar")
assert @filter.absolute_url({ "foo" => "bar" })
end
context "with a document" do
setup do
@site = fixture_site(
"collections" => ["methods"]
)
@site = fixture_site({
"collections" => ["methods"],
})
@site.process
@document = @site.collections["methods"].docs.detect do |d|
d.relative_path == "_methods/configuration.md"
@@ -531,7 +531,7 @@ class TestFilters < JekyllUnitTest
should "ensure the leading slash for the baseurl" do
page_url = "about/my_favorite_page/"
filter = make_filter_mock("baseurl" => "base")
filter = make_filter_mock({ "baseurl" => "base" })
assert_equal "/base/#{page_url}", filter.relative_url(page_url)
end
@@ -542,51 +542,51 @@ class TestFilters < JekyllUnitTest
should "be ok with a nil 'baseurl'" do
page_url = "about/my_favorite_page/"
filter = make_filter_mock(
filter = make_filter_mock({
"url" => "http://example.com",
"baseurl" => nil
)
"baseurl" => nil,
})
assert_equal "/#{page_url}", filter.relative_url(page_url)
end
should "not prepend a forward slash if input is empty" do
page_url = ""
filter = make_filter_mock(
filter = make_filter_mock({
"url" => "http://example.com",
"baseurl" => "/base"
)
"baseurl" => "/base",
})
assert_equal "/base", filter.relative_url(page_url)
end
should "not prepend a forward slash if baseurl ends with a single '/'" do
page_url = "/css/main.css"
filter = make_filter_mock(
filter = make_filter_mock({
"url" => "http://example.com",
"baseurl" => "/base/"
)
"baseurl" => "/base/",
})
assert_equal "/base/css/main.css", filter.relative_url(page_url)
end
should "not return valid URI if baseurl ends with multiple '/'" do
page_url = "/css/main.css"
filter = make_filter_mock(
filter = make_filter_mock({
"url" => "http://example.com",
"baseurl" => "/base//"
)
"baseurl" => "/base//",
})
refute_equal "/base/css/main.css", filter.relative_url(page_url)
end
should "not prepend a forward slash if both input and baseurl are simply '/'" do
page_url = "/"
filter = make_filter_mock(
filter = make_filter_mock({
"url" => "http://example.com",
"baseurl" => "/"
)
"baseurl" => "/",
})
assert_equal "/", filter.relative_url(page_url)
end
should "not return the url by reference" do
filter = make_filter_mock(:baseurl => nil)
filter = make_filter_mock({ :baseurl => nil })
page = Page.new(filter.site, test_dir("fixtures"), "", "front_matter.erb")
assert_equal "/front_matter.erb", page.url
url = filter.relative_url(page.url)
@@ -596,7 +596,7 @@ class TestFilters < JekyllUnitTest
should "transform the input baseurl to a string" do
page_url = "/my-page.html"
filter = make_filter_mock("baseurl" => Value.new(proc { "/baseurl/" }))
filter = make_filter_mock({ "baseurl" => Value.new(proc { "/baseurl/" }) })
assert_equal "/baseurl#{page_url}", filter.relative_url(page_url)
end
@@ -640,7 +640,7 @@ class TestFilters < JekyllUnitTest
context "jsonify filter" do
should "convert hash to json" do
assert_equal "{\"age\":18}", @filter.jsonify(:age => 18)
assert_equal "{\"age\":18}", @filter.jsonify({ :age => 18 })
end
should "convert array to json" do
@@ -687,11 +687,10 @@ class TestFilters < JekyllUnitTest
should "convert drop with drops to json" do
@filter.site.read
actual = @filter.jsonify(@filter.site.to_liquid)
expected = {
assert_equal JSON.parse(actual)["jekyll"], {
"environment" => "development",
"version" => Jekyll::VERSION,
}
assert_equal expected, JSON.parse(actual)["jekyll"]
end
# rubocop:disable Style/StructInheritance
@@ -705,7 +704,7 @@ class TestFilters < JekyllUnitTest
{
"name" => name,
:v => 1,
:thing => M.new(:kay => "jewelers"),
:thing => M.new({ :kay => "jewelers" }),
:stuff => true,
}
end
@@ -973,7 +972,7 @@ class TestFilters < JekyllUnitTest
@filter.site.tap(&:read)
posts = @filter.site.site_payload["site"]["posts"]
results = @filter.where_exp(posts, "post",
"post.date > site.dont_show_posts_before")
"post.date > site.dont_show_posts_before")
assert_equal posts.select { |p| p.date > @sample_time }.count, results.length
end
end
@@ -1075,6 +1074,10 @@ class TestFilters < JekyllUnitTest
end
should "return sorted strings" do
assert_equal %w(10 2), @filter.sort(%w(10 2))
assert_equal(
[{ "a" => "10" }, { "a" => "2" }],
@filter.sort([{ "a" => "10" }, { "a" => "2" }], "a")
)
assert_equal %w(FOO Foo foo), @filter.sort(%w(foo Foo FOO))
assert_equal %w(_foo foo foo_), @filter.sort(%w(foo_ _foo foo))
# Cyrillic
@@ -1085,19 +1088,7 @@ class TestFilters < JekyllUnitTest
end
should "return sorted by property array" do
assert_equal [{ "a" => 1 }, { "a" => 2 }, { "a" => 3 }, { "a" => 4 }],
@filter.sort([{ "a" => 4 }, { "a" => 3 }, { "a" => 1 }, { "a" => 2 }], "a")
end
should "return sorted by property array with numeric strings sorted as numbers" do
assert_equal([{ "a" => ".5" }, { "a" => "0.65" }, { "a" => "10" }],
@filter.sort([{ "a" => "10" }, { "a" => ".5" }, { "a" => "0.65" }], "a"))
end
should "return sorted by property array with numeric strings first" do
assert_equal([{ "a" => ".5" }, { "a" => "0.6" }, { "a" => "twelve" }],
@filter.sort([{ "a" => "twelve" }, { "a" => ".5" }, { "a" => "0.6" }], "a"))
end
should "return sorted by property array with numbers and strings " do
assert_equal([{ "a" => "1" }, { "a" => "1abc" }, { "a" => "20" }],
@filter.sort([{ "a" => "20" }, { "a" => "1" }, { "a" => "1abc" }], "a"))
@filter.sort([{ "a" => 4 }, { "a" => 3 }, { "a" => 1 }, { "a" => 2 }], "a")
end
should "return sorted by property array with nils first" do
ary = [{ "a" => 2 }, { "b" => 1 }, { "a" => 1 }]
@@ -1106,13 +1097,13 @@ class TestFilters < JekyllUnitTest
end
should "return sorted by property array with nils last" do
assert_equal [{ "a" => 1 }, { "a" => 2 }, { "b" => 1 }],
@filter.sort([{ "a" => 2 }, { "b" => 1 }, { "a" => 1 }], "a", "last")
@filter.sort([{ "a" => 2 }, { "b" => 1 }, { "a" => 1 }], "a", "last")
end
should "return sorted by subproperty array" do
assert_equal [{ "a" => { "b" => 1 } }, { "a" => { "b" => 2 } },
{ "a" => { "b" => 3 } },],
@filter.sort([{ "a" => { "b" => 2 } }, { "a" => { "b" => 1 } },
{ "a" => { "b" => 3 } },], "a.b")
@filter.sort([{ "a" => { "b" => 2 } }, { "a" => { "b" => 1 } },
{ "a" => { "b" => 3 } },], "a.b")
end
end
@@ -1140,7 +1131,7 @@ class TestFilters < JekyllUnitTest
context "inspect filter" do
should "return a HTML-escaped string representation of an object" do
assert_equal "{&quot;&lt;a&gt;&quot;=&gt;1}", @filter.inspect("<a>" => 1)
assert_equal "{&quot;&lt;a&gt;&quot;=&gt;1}", @filter.inspect({ "<a>" => 1 })
end
should "quote strings" do

View File

@@ -5,7 +5,7 @@ require "helper"
class TestFrontMatterDefaults < JekyllUnitTest
context "A site with full front matter defaults" do
setup do
@site = fixture_site(
@site = fixture_site({
"defaults" => [{
"scope" => {
"path" => "contacts",
@@ -14,15 +14,15 @@ class TestFrontMatterDefaults < JekyllUnitTest
"values" => {
"key" => "val",
},
},]
)
},],
})
@output = capture_output { @site.process }
@affected = @site.pages.find { |page| page.relative_path == "contacts/bar.html" }
@not_affected = @site.pages.find { |page| page.relative_path == "about.html" }
end
should "affect only the specified path and type" do
assert_equal "val", @affected.data["key"]
assert_equal @affected.data["key"], "val"
assert_nil @not_affected.data["key"]
end
@@ -33,7 +33,7 @@ class TestFrontMatterDefaults < JekyllUnitTest
context "A site with full front matter defaults (glob)" do
setup do
@site = fixture_site(
@site = fixture_site({
"defaults" => [{
"scope" => {
"path" => "contacts/*.html",
@@ -42,15 +42,15 @@ class TestFrontMatterDefaults < JekyllUnitTest
"values" => {
"key" => "val",
},
},]
)
},],
})
@output = capture_output { @site.process }
@affected = @site.pages.find { |page| page.relative_path == "contacts/bar.html" }
@not_affected = @site.pages.find { |page| page.relative_path == "about.html" }
end
should "affect only the specified path and type" do
assert_equal "val", @affected.data["key"]
assert_equal @affected.data["key"], "val"
assert_nil @not_affected.data["key"]
end
@@ -61,7 +61,7 @@ class TestFrontMatterDefaults < JekyllUnitTest
context "A site with front matter type pages and an extension" do
setup do
@site = fixture_site(
@site = fixture_site({
"defaults" => [{
"scope" => {
"path" => "index.html",
@@ -69,8 +69,8 @@ class TestFrontMatterDefaults < JekyllUnitTest
"values" => {
"key" => "val",
},
},]
)
},],
})
@site.process
@affected = @site.pages.find { |page| page.relative_path == "index.html" }
@@ -78,14 +78,14 @@ class TestFrontMatterDefaults < JekyllUnitTest
end
should "affect only the specified path" do
assert_equal "val", @affected.data["key"]
assert_equal @affected.data["key"], "val"
assert_nil @not_affected.data["key"]
end
end
context "A site with front matter defaults with no type" do
setup do
@site = fixture_site(
@site = fixture_site({
"defaults" => [{
"scope" => {
"path" => "win",
@@ -93,8 +93,8 @@ class TestFrontMatterDefaults < JekyllUnitTest
"values" => {
"key" => "val",
},
},]
)
},],
})
@site.process
@affected = @site.posts.docs.find { |page| page.relative_path =~ %r!win\/! }
@@ -102,14 +102,14 @@ class TestFrontMatterDefaults < JekyllUnitTest
end
should "affect only the specified path and all types" do
assert_equal "val", @affected.data["key"]
assert_equal @affected.data["key"], "val"
assert_nil @not_affected.data["key"]
end
end
context "A site with front matter defaults with no path and a deprecated type" do
setup do
@site = fixture_site(
@site = fixture_site({
"defaults" => [{
"scope" => {
"type" => "page",
@@ -117,8 +117,8 @@ class TestFrontMatterDefaults < JekyllUnitTest
"values" => {
"key" => "val",
},
},]
)
},],
})
@site.process
@affected = @site.pages
@@ -134,7 +134,7 @@ class TestFrontMatterDefaults < JekyllUnitTest
context "A site with front matter defaults with no path" do
setup do
@site = fixture_site(
@site = fixture_site({
"defaults" => [{
"scope" => {
"type" => "pages",
@@ -142,8 +142,8 @@ class TestFrontMatterDefaults < JekyllUnitTest
"values" => {
"key" => "val",
},
},]
)
},],
})
@site.process
@affected = @site.pages
@not_affected = @site.posts.docs
@@ -158,15 +158,15 @@ class TestFrontMatterDefaults < JekyllUnitTest
context "A site with front matter defaults with no path or type" do
setup do
@site = fixture_site(
@site = fixture_site({
"defaults" => [{
"scope" => {
},
"values" => {
"key" => "val",
},
},]
)
},],
})
@site.process
@affected = @site.pages
@not_affected = @site.posts
@@ -180,13 +180,13 @@ class TestFrontMatterDefaults < JekyllUnitTest
context "A site with front matter defaults with no scope" do
setup do
@site = fixture_site(
@site = fixture_site({
"defaults" => [{
"values" => {
"key" => "val",
},
},]
)
},],
})
@site.process
@affected = @site.pages
@not_affected = @site.posts
@@ -200,15 +200,15 @@ class TestFrontMatterDefaults < JekyllUnitTest
context "A site with front matter defaults with quoted date" do
setup do
@site = Site.new(Jekyll.configuration(
"source" => source_dir,
"destination" => dest_dir,
"defaults" => [{
"values" => {
"date" => "2015-01-01 00:00:01",
},
},]
))
@site = Site.new(Jekyll.configuration({
"source" => source_dir,
"destination" => dest_dir,
"defaults" => [{
"values" => {
"date" => "2015-01-01 00:00:01",
},
},],
}))
end
should "not raise error" do

View File

@@ -70,12 +70,12 @@ class TestGeneratedSite < JekyllUnitTest
time_regexp = "\\d+:\\d+"
#
# adding a pipe character at the beginning preserves formatting with newlines
expected_output = Regexp.new <<~OUTPUT
| - /css/screen.css last edited at #{time_regexp} with extname .css
- /pgp.key last edited at #{time_regexp} with extname .key
- /products.yml last edited at #{time_regexp} with extname .yml
- /symlink-test/symlinked-dir/screen.css last edited at #{time_regexp} with extname .css
OUTPUT
expected_output = Regexp.new <<-OUTPUT
| - /css/screen.css last edited at #{time_regexp} with extname .css
- /pgp.key last edited at #{time_regexp} with extname .key
- /products.yml last edited at #{time_regexp} with extname .yml
- /symlink-test/symlinked-dir/screen.css last edited at #{time_regexp} with extname .css
OUTPUT
assert_match expected_output, File.read(dest_dir("static_files.html"))
end
end

View File

@@ -40,18 +40,18 @@ class TestKramdown < JekyllUnitTest
@kramdown_config_keys.each do |key|
assert kramdown_config.key?(key.to_sym),
"Expected #{kramdown_config} to include key #{key.to_sym.inspect}"
"Expected #{kramdown_config} to include key #{key.to_sym.inspect}"
end
@syntax_highlighter_opts_config_keys.each do |key|
assert kramdown_config["syntax_highlighter_opts"].key?(key.to_sym),
"Expected #{kramdown_config["syntax_highlighter_opts"]} to include " \
"key #{key.to_sym.inspect}"
"Expected #{kramdown_config["syntax_highlighter_opts"]} to include " \
"key #{key.to_sym.inspect}"
end
assert_equal kramdown_config["smart_quotes"], kramdown_config[:smart_quotes]
assert_equal kramdown_config["syntax_highlighter_opts"]["css"],
kramdown_config[:syntax_highlighter_opts][:css]
kramdown_config[:syntax_highlighter_opts][:css]
end
should "run Kramdown" do
@@ -82,7 +82,7 @@ class TestKramdown < JekyllUnitTest
markdown = Converters::Markdown.new(Utils.deep_merge_hashes(@config, override))
assert_match %r!<p>(&#171;|«)Pit(&#8250;|)hy(&#187;|»)<\/p>!, \
markdown.convert(%("Pit'hy")).strip
markdown.convert(%("Pit'hy")).strip
end
end
@@ -142,20 +142,19 @@ class TestKramdown < JekyllUnitTest
should "move coderay to syntax_highlighter_opts" do
original = Kramdown::Document.method(:new)
markdown = Converters::Markdown.new(
Utils.deep_merge_hashes(@config,
"higlighter" => nil,
"markdown" => "kramdown",
"kramdown" => {
"syntax_highlighter" => "coderay",
"coderay" => {
"hello" => "world",
},
})
)
markdown = Converters::Markdown.new(Utils.deep_merge_hashes(@config, {
"higlighter" => nil,
"markdown" => "kramdown",
"kramdown" => {
"syntax_highlighter" => "coderay",
"coderay" => {
"hello" => "world",
},
},
}))
expect(Kramdown::Document).to receive(:new) do |arg1, hash|
assert_equal "world", hash["syntax_highlighter_opts"]["hello"]
assert_equal hash["syntax_highlighter_opts"]["hello"], "world"
original.call(arg1, hash)
end

View File

@@ -5,8 +5,8 @@ require "helper"
class TestLayoutReader < JekyllUnitTest
context "reading layouts" do
setup do
config = Jekyll::Configuration::DEFAULTS.merge("source" => source_dir,
"destination" => dest_dir)
config = Jekyll::Configuration::DEFAULTS.merge({ "source" => source_dir,
"destination" => dest_dir, })
@site = fixture_site(config)
end

View File

@@ -22,11 +22,11 @@ class TestLiquidExtensions < JekyllUnitTest
end
should "extract the var properly" do
assert_equal "hi tobi", @template.render("page" => { "name" => "tobi" })
assert_equal @template.render({ "page" => { "name" => "tobi" } }), "hi tobi"
end
should "return the variable name if the value isn't there" do
assert_equal "hi page.name", @template.render("page" => { "title" => "tobi" })
assert_equal @template.render({ "page" => { "title" => "tobi" } }), "hi page.name"
end
end
end

View File

@@ -57,7 +57,7 @@ class TestNewCommand < JekyllUnitTest
capture_output { Jekyll::Commands::New.process(@args) }
new_site_files = dir_contents(@full_path).reject do |f|
f.end_with?("welcome-to-jekyll.markdown")
File.extname(f) == ".markdown"
end
assert_same_elements static_template_files, new_site_files

View File

@@ -22,11 +22,11 @@ class TestPage < JekyllUnitTest
context "A Page" do
setup do
clear_dest
@site = Site.new(Jekyll.configuration(
"source" => source_dir,
"destination" => dest_dir,
"skip_config_files" => true
))
@site = Site.new(Jekyll.configuration({
"source" => source_dir,
"destination" => dest_dir,
"skip_config_files" => true,
}))
end
context "processing pages" do
@@ -66,7 +66,7 @@ class TestPage < JekyllUnitTest
@page = setup_page("dynamic_page.php")
@dest_file = dest_dir("dynamic_page.php")
assert_equal ".php", @page.ext
assert_equal "dynamic_page", @page.basename
assert_equal "dynamic_page", @page.basename_without_ext
assert_equal "/dynamic_page.php", @page.url
assert_equal @dest_file, @page.destination(dest_dir)
end
@@ -75,7 +75,7 @@ class TestPage < JekyllUnitTest
@page = setup_page("deal.with.dots.html")
@dest_file = dest_dir("deal.with.dots.html")
assert_equal "deal.with.dots", @page.basename
assert_equal "deal.with.dots", @page.basename_without_ext
assert_equal @dest_file, @page.destination(dest_dir)
end
@@ -84,7 +84,7 @@ class TestPage < JekyllUnitTest
attrs = {
:content => "All the properties.\n",
:dir => "/properties/",
:excerpt => nil,
# :excerpt => nil,
:foo => "bar",
:layout => "default",
:name => "properties.html",

View File

@@ -21,11 +21,11 @@ class TestPageWithoutAFile < JekyllUnitTest
context "A PageWithoutAFile" do
setup do
clear_dest
@site = Site.new(Jekyll.configuration(
"source" => source_dir,
"destination" => dest_dir,
"skip_config_files" => true
))
@site = Site.new(Jekyll.configuration({
"source" => source_dir,
"destination" => dest_dir,
"skip_config_files" => true,
}))
end
context "with default site configuration" do
@@ -34,17 +34,13 @@ class TestPageWithoutAFile < JekyllUnitTest
end
should "not have page-content and page-data defined within it" do
assert_equal "pages", @page.type.to_s
assert_equal "pages", @page.collection.label.to_s
assert_nil @page.content
assert_empty @page.data
end
should "have basic attributes defined in it" do
regular_page = setup_page("properties.html", :klass => Page)
# assert a couple of attributes accessible in a regular Jekyll::Page instance
assert_equal "All the properties.\n", regular_page["content"]
assert_equal "properties.html", regular_page["name"]
basic_attrs = %w(dir name path url)
attrs = {
"content" => "All the properties.\n",
@@ -60,13 +56,13 @@ class TestPageWithoutAFile < JekyllUnitTest
"url" => "/properties.html",
}
attrs.each do |prop, value|
# assert that all attributes (of a Jekyll::PageWithoutAFile instance) other than
# "dir", "name", "path", "url" are `nil`.
# For example, @page[dir] should be "/" but @page[content] or @page[layout], should
# simply be nil.
#
# assert the props being accessible in a Jekyll::Page instance
assert_equal "All the properties.\n", regular_page["content"]
assert_equal "properties.html", regular_page["name"]
# assert differences with Jekyll::PageWithoutAFile instance
if basic_attrs.include?(prop)
assert_equal value, @page[prop], "For Jekyll::PageWithoutAFile attribute '#{prop}':"
assert_equal @page[prop], value, "For <page[\"#{prop}\"]>:"
else
assert_nil @page[prop]
end

View File

@@ -24,7 +24,7 @@ class TestPluginManager < JekyllUnitTest
should "not require from bundler" do
with_env("JEKYLL_NO_BUNDLER_REQUIRE", "true") do
refute Jekyll::PluginManager.require_from_bundler,
"Gemfile plugins were required but shouldn't have been"
"Gemfile plugins were required but shouldn't have been"
assert ENV["JEKYLL_NO_BUNDLER_REQUIRE"]
end
end
@@ -35,7 +35,7 @@ class TestPluginManager < JekyllUnitTest
with_env("JEKYLL_NO_BUNDLER_REQUIRE", nil) do
with_no_gemfile do
refute Jekyll::PluginManager.require_from_bundler,
"Gemfile plugins were required but shouldn't have been"
"Gemfile plugins were required but shouldn't have been"
assert_nil ENV["JEKYLL_NO_BUNDLER_REQUIRE"]
end
end
@@ -68,9 +68,9 @@ class TestPluginManager < JekyllUnitTest
end
should "require plugin files" do
site = double(:safe => false,
:config => { "plugins_dir" => "_plugins" },
:in_source_dir => "/tmp/")
site = double({ :safe => false,
:config => { "plugins_dir" => "_plugins" },
:in_source_dir => "/tmp/", })
plugin_manager = PluginManager.new(site)
expect(Jekyll::External).to receive(:require_with_graceful_fail)
@@ -80,7 +80,7 @@ class TestPluginManager < JekyllUnitTest
context "site is marked as safe" do
should "allow plugins if they are whitelisted" do
site = double(:safe => true, :config => { "whitelist" => ["jemoji"] })
site = double({ :safe => true, :config => { "whitelist" => ["jemoji"] } })
plugin_manager = PluginManager.new(site)
assert plugin_manager.plugin_allowed?("jemoji")
@@ -88,7 +88,7 @@ class TestPluginManager < JekyllUnitTest
end
should "not require plugin files" do
site = double(:safe => true)
site = double({ :safe => true })
plugin_manager = PluginManager.new(site)
expect(Jekyll::External).to_not receive(:require_with_graceful_fail)
@@ -98,12 +98,12 @@ class TestPluginManager < JekyllUnitTest
context "plugins_dir is set to the default" do
should "call site's in_source_dir" do
site = double(
site = double({
:config => {
"plugins_dir" => Jekyll::Configuration::DEFAULTS["plugins_dir"],
},
:in_source_dir => "/tmp/"
)
:in_source_dir => "/tmp/",
})
plugin_manager = PluginManager.new(site)
expect(site).to receive(:in_source_dir).with("_plugins")
@@ -113,7 +113,7 @@ class TestPluginManager < JekyllUnitTest
context "plugins_dir is set to a different dir" do
should "expand plugin path" do
site = double(:config => { "plugins_dir" => "some_other_plugins_path" })
site = double({ :config => { "plugins_dir" => "some_other_plugins_path" } })
plugin_manager = PluginManager.new(site)
expect(File).to receive(:expand_path).with("some_other_plugins_path")
@@ -123,7 +123,7 @@ class TestPluginManager < JekyllUnitTest
context "`paginate` config is activated" do
should "print deprecation warning if jekyll-paginate is not present" do
site = double(:config => { "paginate" => true })
site = double({ :config => { "paginate" => true } })
plugin_manager = PluginManager.new(site)
expect(Jekyll::Deprecator).to(
@@ -133,9 +133,9 @@ class TestPluginManager < JekyllUnitTest
end
should "print no deprecation warning if jekyll-paginate is present" do
site = double(
:config => { "paginate" => true, "plugins" => ["jekyll-paginate"] }
)
site = double({
:config => { "paginate" => true, "plugins" => ["jekyll-paginate"] },
})
plugin_manager = PluginManager.new(site)
expect(Jekyll::Deprecator).to_not receive(:deprecation_message)
@@ -144,10 +144,10 @@ class TestPluginManager < JekyllUnitTest
end
should "conscientious require" do
site = double(
site = double({
:config => { "theme" => "test-dependency-theme" },
:in_dest_dir => "/tmp/_site/"
)
:in_dest_dir => "/tmp/_site/",
})
plugin_manager = PluginManager.new(site)
expect(site).to receive(:theme).and_return(true)

View File

@@ -7,14 +7,14 @@ class TestRegenerator < JekyllUnitTest
setup do
FileUtils.rm_rf(source_dir(".jekyll-metadata"))
@site = fixture_site(
@site = fixture_site({
"collections" => {
"methods" => {
"output" => true,
},
},
"incremental" => true
)
"incremental" => true,
})
@site.read
@page = @site.pages.first
@@ -93,9 +93,9 @@ class TestRegenerator < JekyllUnitTest
context "The site regenerator" do
setup do
FileUtils.rm_rf(source_dir(".jekyll-metadata"))
@site = fixture_site(
"incremental" => true
)
@site = fixture_site({
"incremental" => true,
})
@site.read
@post = @site.posts.first
@@ -128,11 +128,11 @@ class TestRegenerator < JekyllUnitTest
setup do
FileUtils.rm_rf(source_dir(".jekyll-metadata"))
@site = Site.new(Jekyll.configuration(
"source" => source_dir,
"destination" => dest_dir,
"incremental" => true
))
@site = Site.new(Jekyll.configuration({
"source" => source_dir,
"destination" => dest_dir,
"incremental" => true,
}))
@site.process
@path = @site.in_source_dir(@site.pages.first.path)
@@ -153,8 +153,7 @@ class TestRegenerator < JekyllUnitTest
assert @regenerator.cache[@path]
@regenerator.clear_cache
expected = {}
assert_equal expected, @regenerator.cache
assert_equal @regenerator.cache, {}
end
should "write to the metadata file" do
@@ -184,7 +183,7 @@ class TestRegenerator < JekyllUnitTest
should "not crash when reading corrupted marshal file" do
metadata_file = source_dir(".jekyll-metadata")
File.open(metadata_file, "w") do |file|
file.puts Marshal.dump(:foo => "bar")[0, 5]
file.puts Marshal.dump({ :foo => "bar" })[0, 5]
end
@regenerator = Regenerator.new(@site)
@@ -311,11 +310,11 @@ class TestRegenerator < JekyllUnitTest
context "when incremental regeneration is disabled" do
setup do
FileUtils.rm_rf(source_dir(".jekyll-metadata"))
@site = Site.new(Jekyll.configuration(
"source" => source_dir,
"destination" => dest_dir,
"incremental" => false
))
@site = Site.new(Jekyll.configuration({
"source" => source_dir,
"destination" => dest_dir,
"incremental" => false,
}))
@site.process
@path = @site.in_source_dir(@site.pages.first.path)

View File

@@ -29,9 +29,9 @@ class TestRelatedPosts < JekyllUnitTest
end
allow_any_instance_of(Jekyll::RelatedPosts).to receive(:display)
@site = fixture_site(
"lsi" => true
)
@site = fixture_site({
"lsi" => true,
})
@site.reset
@site.read

View File

@@ -5,10 +5,10 @@ require "helper"
class TestSass < JekyllUnitTest
context "importing partials" do
setup do
@site = Jekyll::Site.new(Jekyll.configuration(
"source" => source_dir,
"destination" => dest_dir
))
@site = Jekyll::Site.new(Jekyll.configuration({
"source" => source_dir,
"destination" => dest_dir,
}))
@site.process
@test_css_file = dest_dir("css/main.css")
end

View File

@@ -15,7 +15,7 @@ class TestSite < JekyllUnitTest
@site.posts.docs.concat(PostReader.new(@site).read_posts(""))
posts = Dir[source_dir("_posts", "**", "*")]
posts.delete_if do |post|
File.directory?(post) && post !~ Document::DATE_FILENAME_MATCHER
File.directory?(post) && !(post =~ Document::DATE_FILENAME_MATCHER)
end
end
@@ -31,15 +31,15 @@ class TestSite < JekyllUnitTest
end
should "have an array for plugins if passed as a string" do
site = Site.new(site_configuration("plugins_dir" => "/tmp/plugins"))
site = Site.new(site_configuration({ "plugins_dir" => "/tmp/plugins" }))
array = Utils::Platforms.windows? ? ["C:/tmp/plugins"] : ["/tmp/plugins"]
assert_equal array, site.plugins
end
should "have an array for plugins if passed as an array" do
site = Site.new(site_configuration(
"plugins_dir" => ["/tmp/plugins", "/tmp/otherplugins"]
))
site = Site.new(site_configuration({
"plugins_dir" => ["/tmp/plugins", "/tmp/otherplugins"],
}))
array = if Utils::Platforms.windows?
["C:/tmp/plugins", "C:/tmp/otherplugins"]
else
@@ -49,12 +49,12 @@ class TestSite < JekyllUnitTest
end
should "have an empty array for plugins if nothing is passed" do
site = Site.new(site_configuration("plugins_dir" => []))
site = Site.new(site_configuration({ "plugins_dir" => [] }))
assert_equal [], site.plugins
end
should "have the default for plugins if nil is passed" do
site = Site.new(site_configuration("plugins_dir" => nil))
site = Site.new(site_configuration({ "plugins_dir" => nil }))
assert_equal [source_dir("_plugins")], site.plugins
end
@@ -64,22 +64,19 @@ class TestSite < JekyllUnitTest
end
should "expose baseurl passed in from config" do
site = Site.new(site_configuration("baseurl" => "/blog"))
site = Site.new(site_configuration({ "baseurl" => "/blog" }))
assert_equal "/blog", site.baseurl
end
should "only include theme includes_path if the path exists" do
site = fixture_site("theme" => "test-theme")
site = fixture_site({ "theme" => "test-theme" })
assert_equal [source_dir("_includes"), theme_dir("_includes")],
site.includes_load_paths
site.includes_load_paths
allow(File).to receive(:directory?).with(theme_dir("_sass")).and_return(true)
allow(File).to receive(:directory?).with(theme_dir("_layouts")).and_return(true)
allow(File).to receive(:directory?).with(theme_dir("_includes")).and_return(false)
allow(File).to receive(:directory?).with(
File.expand_path(".jekyll-cache/Jekyll/Cache/Jekyll::Cache")
).and_return(true)
site = fixture_site("theme" => "test-theme")
site = fixture_site({ "theme" => "test-theme" })
assert_equal [source_dir("_includes")], site.includes_load_paths
end
end
@@ -90,7 +87,9 @@ class TestSite < JekyllUnitTest
end
teardown do
self.class.send(:remove_const, :MyGenerator) if defined?(MyGenerator)
if defined?(MyGenerator)
self.class.send(:remove_const, :MyGenerator)
end
end
should "have an empty tag hash by default" do
@@ -215,32 +214,34 @@ class TestSite < JekyllUnitTest
# exclude files in symlinked directories here and insert them in the
# following step when not on Windows.
sorted_pages = %w(
%#\ +.md
+/%#\ +.md
+/foo.md
.htaccess
about.html
application.coffee
bar.html
coffeescript.coffee
assets/application.coffee
contacts.html
contacts/bar.html
contacts/humans.txt
contacts/index.html
css/main.scss
deal.with.dots.html
dynamic_file.php
environment.html
exploit.md
foo.md
humans.txt
index.html
index.html
info.md
main.scss
js/coffeescript.coffee
properties.html
sitemap.xml
static_files.html
symlink-test/symlinked-dir/main.scss
symlink-test/symlinked-file
)
unless Utils::Platforms.really_windows?
# files in symlinked directories may appear twice
sorted_pages.push("main.scss", "symlinked-file").sort!
end
assert_equal sorted_pages, @site.pages.map(&:name)
assert_equal sorted_pages, @site.pages.docs.map(&:relative_path)
end
should "read posts" do
@@ -280,7 +281,7 @@ class TestSite < JekyllUnitTest
posts = Dir[source_dir("**", "_posts", "**", "*")]
posts.delete_if do |post|
File.directory?(post) && post !~ Document::DATE_FILENAME_MATCHER
File.directory?(post) && !(post =~ Document::DATE_FILENAME_MATCHER)
end
categories = %w(
2013 bar baz category foo z_category MixedCase Mixedcase publish_test win
@@ -306,9 +307,9 @@ class TestSite < JekyllUnitTest
should "raise for bad frontmatter if strict_front_matter is set" do
site = Site.new(site_configuration(
"collections" => ["broken"],
"strict_front_matter" => true
))
"collections" => ["broken"],
"strict_front_matter" => true
))
assert_raises(Psych::SyntaxError) do
site.process
end
@@ -316,9 +317,9 @@ class TestSite < JekyllUnitTest
should "not raise for bad frontmatter if strict_front_matter is not set" do
site = Site.new(site_configuration(
"collections" => ["broken"],
"strict_front_matter" => false
))
"collections" => ["broken"],
"strict_front_matter" => false
))
site.process
end
end
@@ -413,9 +414,9 @@ class TestSite < JekyllUnitTest
bad_processor = "Custom::Markdown"
s = Site.new(site_configuration(
"markdown" => bad_processor,
"incremental" => false
))
"markdown" => bad_processor,
"incremental" => false
))
assert_raises Jekyll::Errors::FatalException do
s.process
end
@@ -434,9 +435,9 @@ class TestSite < JekyllUnitTest
should "throw FatalException at process time" do
bad_processor = "not a processor name"
s = Site.new(site_configuration(
"markdown" => bad_processor,
"incremental" => false
))
"markdown" => bad_processor,
"incremental" => false
))
assert_raises Jekyll::Errors::FatalException do
s.process
end
@@ -490,8 +491,8 @@ class TestSite < JekyllUnitTest
site.process
file_content = SafeYAML.load_file(File.join(
source_dir, "_data", "categories", "dairy.yaml"
))
source_dir, "_data", "categories", "dairy.yaml"
))
assert_equal site.data["categories"]["dairy"], file_content
assert_equal(
@@ -505,8 +506,8 @@ class TestSite < JekyllUnitTest
site.process
file_content = SafeYAML.load_file(File.join(
source_dir, "_data", "categories.01", "dairy.yaml"
))
source_dir, "_data", "categories.01", "dairy.yaml"
))
assert_equal site.data["categories01"]["dairy"], file_content
assert_equal(
@@ -537,9 +538,9 @@ class TestSite < JekyllUnitTest
context "manipulating the Jekyll environment" do
setup do
@site = Site.new(site_configuration(
"incremental" => false
))
@site = Site.new(site_configuration({
"incremental" => false,
}))
@site.process
@page = @site.pages.find { |p| p.name == "environment.html" }
end
@@ -551,9 +552,9 @@ class TestSite < JekyllUnitTest
context "in production" do
setup do
ENV["JEKYLL_ENV"] = "production"
@site = Site.new(site_configuration(
"incremental" => false
))
@site = Site.new(site_configuration({
"incremental" => false,
}))
@site.process
@page = @site.pages.find { |p| p.name == "environment.html" }
end
@@ -572,13 +573,13 @@ class TestSite < JekyllUnitTest
should "set no theme if config is not set" do
expect($stderr).not_to receive(:puts)
expect($stdout).not_to receive(:puts)
site = fixture_site("theme" => nil)
site = fixture_site({ "theme" => nil })
assert_nil site.theme
end
should "set no theme if config is a hash" do
output = capture_output do
site = fixture_site("theme" => {})
site = fixture_site({ "theme" => {} })
assert_nil site.theme
end
expected_msg = "Theme: value of 'theme' in config should be String " \
@@ -590,7 +591,7 @@ class TestSite < JekyllUnitTest
[:debug, :info, :warn, :error].each do |level|
expect(Jekyll.logger.writer).not_to receive(level)
end
site = fixture_site("theme" => "test-theme")
site = fixture_site({ "theme" => "test-theme" })
assert_instance_of Jekyll::Theme, site.theme
assert_equal "test-theme", site.theme.name
end
@@ -617,9 +618,9 @@ class TestSite < JekyllUnitTest
context "incremental build" do
setup do
@site = Site.new(site_configuration(
"incremental" => true
))
@site = Site.new(site_configuration({
"incremental" => true,
}))
@site.read
end

View File

@@ -5,9 +5,9 @@ require "helper"
class TestSiteDrop < JekyllUnitTest
context "a site drop" do
setup do
@site = fixture_site(
"collections" => ["thanksgiving"]
)
@site = fixture_site({
"collections" => ["thanksgiving"],
})
@site.process
@drop = @site.to_liquid.site
end

View File

@@ -70,7 +70,7 @@ class TestStaticFile < JekyllUnitTest
"root",
"_foo/dir/subdir",
"file.html",
"output" => true
{ "output" => true }
)
assert_equal :foo, static_file.type
assert_equal "/foo/dir/subdir/file.html", static_file.url
@@ -82,7 +82,7 @@ class TestStaticFile < JekyllUnitTest
"root",
"_foo/dir/subdir",
"file.html",
"output" => true, "permalink" => "/:path/"
{ "output" => true, "permalink" => "/:path/" }
)
assert_equal :foo, static_file.type
assert_equal "/dir/subdir/file.html", static_file.url
@@ -92,7 +92,7 @@ class TestStaticFile < JekyllUnitTest
should "be writable by default" do
static_file = setup_static_file("root", "dir/subdir", "file.html")
assert(static_file.write?,
"static_file.write? should return true by default")
"static_file.write? should return true by default")
end
should "use the _config.yml defaults to determine writability" do
@@ -107,8 +107,8 @@ class TestStaticFile < JekyllUnitTest
defaults
)
assert(!static_file.write?,
"static_file.write? should return false when _config.yml sets " \
"`published: false`")
"static_file.write? should return false when _config.yml sets " \
"`published: false`")
end
should "respect front matter defaults" do

File diff suppressed because it is too large Load Diff

View File

@@ -202,20 +202,20 @@ class TestUtils < JekyllUnitTest
should "replace everything else but ASCII characters" do
assert_equal "the-config-yml-file",
Utils.slugify("The _config.yml file?", :mode => "ascii")
Utils.slugify("The _config.yml file?", :mode => "ascii")
assert_equal "f-rtive-glance",
Utils.slugify("fürtive glance!!!!", :mode => "ascii")
Utils.slugify("fürtive glance!!!!", :mode => "ascii")
end
should "map accented latin characters to ASCII characters" do
assert_equal "the-config-yml-file",
Utils.slugify("The _config.yml file?", :mode => "latin")
Utils.slugify("The _config.yml file?", :mode => "latin")
assert_equal "furtive-glance",
Utils.slugify("fürtive glance!!!!", :mode => "latin")
Utils.slugify("fürtive glance!!!!", :mode => "latin")
assert_equal "aaceeiioouu",
Utils.slugify("àáçèéíïòóúü", :mode => "latin")
Utils.slugify("àáçèéíïòóúü", :mode => "latin")
assert_equal "a-z",
Utils.slugify("Aあわれ鬱господинZ", :mode => "latin")
Utils.slugify("Aあわれ鬱господинZ", :mode => "latin")
end
should "only replace whitespace if mode is raw" do