mirror of
https://github.com/jekyll/jekyll.git
synced 2026-04-28 03:01:03 -04:00
Compare commits
35 Commits
pull/markd
...
v0.4.5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d41549c9ef | ||
|
|
586898d824 | ||
|
|
999ec1bf2b | ||
|
|
85f3ba2088 | ||
|
|
5eea9d9827 | ||
|
|
89d98211b1 | ||
|
|
89330140d9 | ||
|
|
4d6f36e97b | ||
|
|
e11f403aab | ||
|
|
dba797da04 | ||
|
|
d8f9a80dbb | ||
|
|
28c3a3836d | ||
|
|
8efff3f99a | ||
|
|
d134fbf5ac | ||
|
|
71a6f8a288 | ||
|
|
ae7eb14ae4 | ||
|
|
8fc41d867a | ||
|
|
3df209d8d6 | ||
|
|
1eafe90852 | ||
|
|
b70cfc734a | ||
|
|
9ee5a36d75 | ||
|
|
fe71d2b783 | ||
|
|
eac6b03086 | ||
|
|
f682c8ffa4 | ||
|
|
9478f1bb5e | ||
|
|
7e178fff10 | ||
|
|
4a97573465 | ||
|
|
eb60603f51 | ||
|
|
698192122d | ||
|
|
a8266e3397 | ||
|
|
4761d54b93 | ||
|
|
512e515d15 | ||
|
|
e53ac7a16c | ||
|
|
36466f13b8 | ||
|
|
d595cd7ee9 |
@@ -1,33 +0,0 @@
|
||||
engines:
|
||||
fixme:
|
||||
enabled: false
|
||||
rubocop:
|
||||
enabled: true
|
||||
|
||||
exclude_paths:
|
||||
- .codeclimate.yml
|
||||
- .gitignore
|
||||
- .rspec
|
||||
- .rubocop.yml
|
||||
- .travis.yml
|
||||
|
||||
- Gemfile.lock
|
||||
- CHANGELOG.{md,markdown,txt,textile}
|
||||
- CONTRIBUTING.{md,markdown,txt,textile}
|
||||
- readme.{md,markdown,txt,textile}
|
||||
- README.{md,markdown,txt,textile}
|
||||
- Readme.{md,markdown,txt,textile}
|
||||
- ReadMe.{md,markdown,txt,textile}
|
||||
- COPYING
|
||||
- LICENSE
|
||||
|
||||
- features/**/*
|
||||
- script/**/*
|
||||
- site/**/*
|
||||
- spec/**/*
|
||||
- test/**/*
|
||||
- vendor/**/*
|
||||
|
||||
ratings:
|
||||
paths:
|
||||
- lib/**/*.rb
|
||||
@@ -1,14 +0,0 @@
|
||||
# editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
122
.github/CONTRIBUTING.markdown
vendored
122
.github/CONTRIBUTING.markdown
vendored
@@ -1,122 +0,0 @@
|
||||
# Contributing to Jekyll
|
||||
|
||||
Hi there! Interested in contributing to Jekyll? We'd love your help. Jekyll is an open source project, built one contribution at a time by users like you.
|
||||
|
||||
## Where to get help or report a problem
|
||||
|
||||
* If you have a question about using Jekyll, start a discussion on [Jekyll Talk](https://talk.jekyllrb.com).
|
||||
* If you think you've found a bug within a Jekyll plugin, open an issue in that plugin's repository.
|
||||
* If you think you've found a bug within Jekyll itself, [open an issue](https://github.com/jekyll/jekyll/issues/new).
|
||||
* More resources are listed on our [Help page](https://jekyllrb.com/help/).
|
||||
|
||||
## Ways to contribute
|
||||
|
||||
Whether you're a developer, a designer, or just a Jekyll devotee, there are lots of ways to contribute. Here's a few ideas:
|
||||
|
||||
* [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.
|
||||
* 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.
|
||||
|
||||
## Submitting a pull request
|
||||
|
||||
### Pull requests generally
|
||||
|
||||
* The smaller the proposed change, the better. If you'd like to propose two unrelated changes, submit two pull requests.
|
||||
|
||||
* The more information, the better. Make judicious use of the pull request body. Describe what changes were made, why you made them, and what impact they will have for users.
|
||||
|
||||
* Pull request are easy and fun. If this is your first pull request, it may help to [understand GitHub Flow](https://guides.github.com/introduction/flow/).
|
||||
|
||||
* If you're submitting a code contribution, be sure to read the [code contributions](#code-contributions) section below.
|
||||
|
||||
### Submitting a pull request via github.com
|
||||
|
||||
Many small changes can be made entirely through the github.com web interface.
|
||||
|
||||
1. Navigate to the file within [`jekyll/jekyll`](https://github.com/jekyll/jekyll) that you'd like to edit.
|
||||
2. Click the pencil icon in the top right corner to edit the file
|
||||
3. Make your proposed changes
|
||||
4. Click "Propose file change"
|
||||
5. Click "Create pull request"
|
||||
6. Add a descriptive title and detailed description for your proposed change. The more information the better.
|
||||
7. Click "Create pull request"
|
||||
|
||||
That's it! You'll be automatically subscribed to receive updates as others review your proposed change and provide feedback.
|
||||
|
||||
### Submitting a pull request via Git command line
|
||||
|
||||
1. Fork the project by clicking "Fork" in the top right corner of [`jekyll/jekyll`](https://github.com/jekyll/jekyll).
|
||||
2. Clone the repository locally `git clone https://github.com/<you-username>/jekyll`.
|
||||
3. Create a new, descriptively named branch to contain your change ( `git checkout -b my-awesome-feature` ).
|
||||
4. Hack away, add tests. Not necessarily in that order.
|
||||
5. Make sure everything still passes by running `script/cibuild` (see [the tests section](#running-tests-locally) below)
|
||||
6. Push the branch up ( `git push origin my-awesome-feature` ).
|
||||
7. Create a pull request by visiting `https://github.com/<your-username>/jekyll` and following the instructions at the top of the screen.
|
||||
|
||||
## Proposing updates to the documentation
|
||||
|
||||
We want the Jekyll documentation to be the best it can be. We've open-sourced our docs and we welcome any pull requests if you find it lacking.
|
||||
|
||||
### How to submit changes
|
||||
|
||||
You can find the documentation for jekyllrb.com in the [site](https://github.com/jekyll/jekyll/tree/master/site) directory. See the section above, [submitting a pull request](#submitting-a-pull-request) for information on how to propose a change.
|
||||
|
||||
One gotcha, all pull requests should be directed at the `master` branch (the default branch).
|
||||
|
||||
### Adding plugins
|
||||
|
||||
If you want to add your plugin to the [list of plugins](https://jekyllrb.com/docs/plugins/#available-plugins), please submit a pull request modifying the [plugins page source file](https://github.com/jekyll/jekyll/blob/master/site/_docs/plugins.md) by adding a link to your plugin under the proper subheading depending upon its type.
|
||||
|
||||
## Code Contributions
|
||||
|
||||
Interesting in submitting a pull request? Awesome. Read on. There's a few common gotchas that we'd love to help you avoid.
|
||||
|
||||
### Tests and documentation
|
||||
|
||||
Any time you propose a code change, you should also include updates to the documentation and tests within the same pull request.
|
||||
|
||||
#### Documentation
|
||||
|
||||
If your contribution changes any Jekyll behavior, make sure to update the documentation. Documentation lives in the `site/_docs` folder (spoiler alert: it's a Jekyll site!). If the docs are missing information, please feel free to add it in. Great docs make a great project. Include changes to the documentation within your pull request, and once merged, `jekyllrb.com` will be updated.
|
||||
|
||||
#### Tests
|
||||
|
||||
* If you're creating a small fix or patch to an existing feature, a simple test is more than enough. You can usually copy/paste from an existing example in the `tests` folder, but if you need you can find out about our tests suites [Shoulda](https://github.com/thoughtbot/shoulda/tree/master) and [RSpec-Mocks](https://github.com/rspec/rspec-mocks).
|
||||
|
||||
* If it's a brand new feature, create a new [Cucumber](https://github.com/cucumber/cucumber/) feature, reusing existing steps where appropriate.
|
||||
|
||||
### Code contributions generally
|
||||
|
||||
* Jekyll uses the [Rubocop](https://github.com/bbatsov/rubocop) static analyzer to ensure that contributions follow the [GitHub Ruby Styleguide](https://github.com/styleguide/ruby). Please check your code using `script/fmt` and resolve any errors before pushing your branch.
|
||||
|
||||
* Don't bump the Gem version in your pull request (if you don't know what that means, you probably didn't).
|
||||
|
||||
## Running tests locally
|
||||
|
||||
### Test Dependencies
|
||||
|
||||
To run the test suite and build the gem you'll need to install Jekyll's dependencies by running the following command:
|
||||
|
||||
<pre class="highlight"><code>$ script/bootstrap</code></pre>
|
||||
|
||||
Before you make any changes, run the tests and make sure that they pass (to confirm your environment is configured properly):
|
||||
|
||||
<pre class="highlight"><code>$ script/cibuild</code></pre>
|
||||
|
||||
If you are only updating a file in `test/`, you can use the command:
|
||||
|
||||
<pre class="highlight"><code>$ script/test test/blah_test.rb</code></pre>
|
||||
|
||||
If you are only updating a `.feature` file, you can use the command:
|
||||
|
||||
<pre class="highlight"><code>$ script/cucumber features/blah.feature</code></pre>
|
||||
|
||||
Both `script/test` and `script/cucumber` can be run without arguments to
|
||||
run its entire respective suite.
|
||||
|
||||
## A thank you
|
||||
|
||||
Thanks! Hacking on Jekyll should be fun. If you find any of this hard to figure out, let us know so we can improve our process or documentation!
|
||||
82
.github/ISSUE_TEMPLATE.md
vendored
82
.github/ISSUE_TEMPLATE.md
vendored
@@ -1,82 +0,0 @@
|
||||
<!--
|
||||
Hi! Thanks for considering to file a bug with Jekyll. Please take the time to
|
||||
answer the basic questions. You can convert `[ ]` into `[x]` to check boxes (or submit
|
||||
and check.) If there is no need for certain fields like output and redirection, please delete
|
||||
those headers before submitting. We know not all tickets require those steps.
|
||||
Otherwise, please try to be as detailed as possible.
|
||||
|
||||
If you are unsure this is a bug in Jekyll, or this is a bug caused
|
||||
by a plugin that isn't directly related to Jekyll, or if this is just
|
||||
a generic usage question, please consider asking your question at
|
||||
https://talk.jekyllrb.com where non-bug questions go.
|
||||
|
||||
Please make sure to mention an affinity team whose responsibilities
|
||||
most closely align with your issue.
|
||||
|
||||
Thanks!
|
||||
-->
|
||||
|
||||
- [ ] I believe this to be a bug, not a question about using Jekyll.
|
||||
- [ ] I updated to the latest Jekyll (or) if on GitHub Pages to the latest `github-pages`
|
||||
- [ ] I read the CONTRIBUTION file at https://jekyllrb.com/docs/contributing/
|
||||
- [ ] This is a feature request.
|
||||
|
||||
---
|
||||
|
||||
- [ ] I am on (or have tested on) ***macOS*** 10+
|
||||
- [ ] I am on (or have tested on) ***Debian/Ubuntu*** GNU/Linux
|
||||
- [ ] I am on (or have tested on) ***Fedora*** GNU/Linux
|
||||
- [ ] I am on (or have tested on) ***Arch*** GNU/Linux
|
||||
- [ ] I am on (or have tested on) ***Other*** GNU/Linux
|
||||
- [ ] I am on (or have tested on) ***Windows*** 10+
|
||||
|
||||
<!--
|
||||
Other GNU/Linux includes Scientific GNU/Linux, CentOS GNU/Linux, and others.
|
||||
If you are on a minor sub-distro (such as ElementaryOS which does not diverge from
|
||||
Ubuntu much, please check the parent distro. Kubuntu, Edubuntu, Lubuntu should
|
||||
also be flagged as Ubuntu as their packages come from upstream Ubuntu.
|
||||
-->
|
||||
|
||||
---
|
||||
|
||||
- [ ] I was trying to install.
|
||||
- [ ] There is a broken Plugin API.
|
||||
- [ ] I had an error on GitHub Pages, and I have reproduced it locally.
|
||||
- [ ] I had an error on GitHub Pages, and GitHub Support said it was a Jekyll Bug.
|
||||
- [ ] I had an error on GitHub Pages and I did not test it locally.
|
||||
- [ ] I was trying to build.
|
||||
- [ ] It was another bug.
|
||||
|
||||
## My Reproduction Steps
|
||||
|
||||
<!--
|
||||
If this error occured on GitHub Pages, please try to provide us with logs,
|
||||
and look at them yourself, to determine if this is an actual Jekyll bug. In
|
||||
the event you are unsure, file a ticket, however, when you do please provide
|
||||
the logs (strip them of personal information.)
|
||||
|
||||
If you have trouble finding your logs, please email support@github.com and
|
||||
they will happily help you. If you cannot find logs, please try your best to
|
||||
replicate it locally because we cannot fix a problem if we do not know
|
||||
exactly what caused it, or within a relatively close distance.
|
||||
-->
|
||||
|
||||
<!--
|
||||
Insert the steps you took to for this problem to exist. Such as the
|
||||
directories you created and, the full command you ran, and include any
|
||||
plugins you have installed, this is very important.
|
||||
|
||||
If your steps are complicated, you can also submit a GitHub
|
||||
repository (please no zips, they will be removed and rejected by maintainers,)
|
||||
and just supply a command for us to reproduce it ourselves.
|
||||
-->
|
||||
|
||||
## The Output I Wanted
|
||||
|
||||
<!--
|
||||
Insert the output from the command. Alter it as little as you can.
|
||||
The minimum should be personal information. Though we normally don't log
|
||||
anything like that so there should be no need to alter it.
|
||||
-->
|
||||
|
||||
/cc include any Jekyll affinity teams here (see https://teams.jekyllrb.com/ for more info)
|
||||
22
.gitignore
vendored
22
.gitignore
vendored
@@ -1,23 +1,5 @@
|
||||
test/dest/
|
||||
*.gem
|
||||
pkg/
|
||||
*.swp
|
||||
*~
|
||||
.DS_Store
|
||||
.analysis
|
||||
.bundle/
|
||||
.byebug_history
|
||||
.jekyll-metadata
|
||||
.ruby-gemset
|
||||
.ruby-version
|
||||
.sass-cache
|
||||
/test/source/file_name.txt
|
||||
/vendor
|
||||
Gemfile.lock
|
||||
_site/
|
||||
bin/
|
||||
bbin/
|
||||
coverage
|
||||
gh-pages/
|
||||
pkg/
|
||||
site/_site/
|
||||
test/dest
|
||||
tmp/*
|
||||
|
||||
133
.rubocop.yml
133
.rubocop.yml
@@ -1,133 +0,0 @@
|
||||
---
|
||||
AllCops:
|
||||
TargetRubyVersion: 2.0
|
||||
Include:
|
||||
- lib/**/*.rb
|
||||
Exclude:
|
||||
- lib/jekyll/renderer.rb
|
||||
- bin/**/*
|
||||
- exe/**/*
|
||||
- benchmark/**/*
|
||||
- script/**/*
|
||||
- vendor/**/*
|
||||
Lint/EndAlignment:
|
||||
Severity: error
|
||||
Lint/UnreachableCode:
|
||||
Severity: error
|
||||
Lint/UselessAccessModifier:
|
||||
Enabled: false
|
||||
Metrics/AbcSize:
|
||||
Max: 21
|
||||
Metrics/BlockLength:
|
||||
Exclude:
|
||||
- test/**/*.rb
|
||||
- lib/jekyll/configuration.rb
|
||||
Metrics/ClassLength:
|
||||
Exclude:
|
||||
- !ruby/regexp /features\/.*.rb$/
|
||||
- !ruby/regexp /test\/.*.rb$/
|
||||
Max: 300
|
||||
Metrics/CyclomaticComplexity:
|
||||
Max: 9
|
||||
Metrics/LineLength:
|
||||
Exclude:
|
||||
- !ruby/regexp /features\/.*.rb/
|
||||
Max: 90
|
||||
Severity: warning
|
||||
Metrics/MethodLength:
|
||||
CountComments: false
|
||||
Max: 20
|
||||
Severity: error
|
||||
Metrics/ModuleLength:
|
||||
Exclude:
|
||||
- lib/jekyll/filters.rb
|
||||
Max: 240
|
||||
Metrics/ParameterLists:
|
||||
Max: 4
|
||||
Metrics/PerceivedComplexity:
|
||||
Max: 8
|
||||
Style/Alias:
|
||||
Enabled: false
|
||||
Style/AlignArray:
|
||||
Enabled: false
|
||||
Style/AlignHash:
|
||||
EnforcedHashRocketStyle: table
|
||||
Style/AlignParameters:
|
||||
Enabled: false
|
||||
EnforcedStyle: with_fixed_indentation
|
||||
Style/AndOr:
|
||||
Severity: error
|
||||
Style/Attr:
|
||||
Enabled: false
|
||||
Style/BracesAroundHashParameters:
|
||||
Enabled: false
|
||||
Style/ClassAndModuleChildren:
|
||||
Enabled: false
|
||||
Style/Documentation:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- !ruby/regexp /features\/.*.rb$/
|
||||
Style/DoubleNegation:
|
||||
Enabled: false
|
||||
Style/EmptyLinesAroundAccessModifier:
|
||||
Enabled: false
|
||||
Style/EmptyLinesAroundModuleBody:
|
||||
Enabled: false
|
||||
Style/ExtraSpacing:
|
||||
AllowForAlignment: true
|
||||
Style/FileName:
|
||||
Enabled: false
|
||||
Style/FirstParameterIndentation:
|
||||
EnforcedStyle: consistent
|
||||
Style/GuardClause:
|
||||
Enabled: false
|
||||
Style/HashSyntax:
|
||||
EnforcedStyle: hash_rockets
|
||||
Severity: error
|
||||
Style/IfUnlessModifier:
|
||||
Enabled: false
|
||||
Style/IndentArray:
|
||||
EnforcedStyle: consistent
|
||||
Style/IndentHash:
|
||||
EnforcedStyle: consistent
|
||||
Style/IndentationWidth:
|
||||
Severity: error
|
||||
Style/ModuleFunction:
|
||||
Enabled: false
|
||||
Style/MultilineMethodCallIndentation:
|
||||
EnforcedStyle: indented
|
||||
Style/MultilineOperationIndentation:
|
||||
EnforcedStyle: indented
|
||||
Style/MultilineTernaryOperator:
|
||||
Severity: error
|
||||
Style/PercentLiteralDelimiters:
|
||||
PreferredDelimiters:
|
||||
"%q": "{}"
|
||||
"%Q": "{}"
|
||||
"%r": "!!"
|
||||
"%s": "()"
|
||||
"%w": "()"
|
||||
"%W": "()"
|
||||
"%x": "()"
|
||||
Style/RedundantReturn:
|
||||
Enabled: false
|
||||
Style/RedundantSelf:
|
||||
Enabled: false
|
||||
Style/RegexpLiteral:
|
||||
EnforcedStyle: percent_r
|
||||
Style/RescueModifier:
|
||||
Enabled: false
|
||||
Style/SignalException:
|
||||
EnforcedStyle: only_raise
|
||||
Style/SingleLineMethods:
|
||||
Enabled: false
|
||||
Style/SpaceAroundOperators:
|
||||
Enabled: false
|
||||
Style/SpaceInsideBrackets:
|
||||
Enabled: false
|
||||
Style/StringLiterals:
|
||||
EnforcedStyle: double_quotes
|
||||
Style/StringLiteralsInInterpolation:
|
||||
EnforcedStyle: double_quotes
|
||||
Style/UnneededCapitalW:
|
||||
Enabled: false
|
||||
47
.travis.yml
47
.travis.yml
@@ -1,47 +0,0 @@
|
||||
bundler_args: --without benchmark:site:development
|
||||
script: script/cibuild
|
||||
cache: bundler
|
||||
language: ruby
|
||||
sudo: false
|
||||
|
||||
rvm:
|
||||
- &ruby1 2.3.1
|
||||
- &ruby2 2.2.5
|
||||
- &ruby3 2.1.9
|
||||
- &jruby jruby-9.1.2.0
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- rvm: *ruby1
|
||||
env: TEST_SUITE=fmt
|
||||
- rvm: *ruby1
|
||||
env: TEST_SUITE=default-site
|
||||
exclude:
|
||||
- rvm: *jruby
|
||||
env: TEST_SUITE=cucumber
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- TEST_SUITE=test
|
||||
- TEST_SUITE=cucumber
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- themes
|
||||
|
||||
notifications:
|
||||
slack:
|
||||
secure: "\
|
||||
dNdKk6nahNURIUbO3ULhA09/vTEQjK0fNbgjVjeYPEvROHgQBP1cIP3AJy8aWs8rl5Yyow4Y\
|
||||
GEilNRzKPz18AsFptVXofpwyqcBxaCfmHP809NX5PHBaadydveLm+TNVao2XeLXSWu+HUNAY\
|
||||
O1AanCUbJSEyJTju347xCBGzESU=\
|
||||
"
|
||||
|
||||
addons:
|
||||
code_climate:
|
||||
repo_token:
|
||||
secure: "\
|
||||
mAuvDu+nrzB8dOaLqsublDGt423mGRyZYM3vsrXh4Tf1sT+L1PxsRzU4gLmcV27HtX2Oq9\
|
||||
DA4vsRURfABU0fIhwYkQuZqEcA3d8TL36BZcGEshG6MQ2AmnYsmFiTcxqV5bmlElHEqQuT\
|
||||
5SUFXLafgZPBnL0qDwujQcHukID41sE=\
|
||||
"
|
||||
@@ -1,49 +0,0 @@
|
||||
# Code of Conduct
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
* Personal attacks
|
||||
* Trolling or insulting/derogatory comments
|
||||
* Public or private harassment
|
||||
* Publishing other's private information, such as physical or electronic
|
||||
addresses, without explicit permission
|
||||
* Other unethical or unprofessional conduct
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community.
|
||||
|
||||
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 is adapted from the [Contributor Covenant][homepage],
|
||||
version 1.3.0, available at
|
||||
[http://contributor-covenant.org/version/1/3/0/][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/3/0/
|
||||
96
Gemfile
96
Gemfile
@@ -1,96 +0,0 @@
|
||||
source "https://rubygems.org"
|
||||
gemspec :name => "jekyll"
|
||||
|
||||
gem "rake", "~> 11.0"
|
||||
|
||||
# Dependency of jekyll-mentions. RubyGems in Ruby 2.1 doesn't shield us from this.
|
||||
gem "activesupport", "~> 4.2", :groups => [:test_legacy, :site] if RUBY_VERSION < '2.2.2'
|
||||
|
||||
group :development do
|
||||
gem "launchy", "~> 2.3"
|
||||
gem "pry"
|
||||
|
||||
unless RUBY_ENGINE == "jruby"
|
||||
gem "pry-byebug"
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
group :test do
|
||||
gem "rubocop", "~> 0.44.1"
|
||||
gem "cucumber", "~> 2.1"
|
||||
gem "jekyll_test_plugin"
|
||||
gem "jekyll_test_plugin_malicious"
|
||||
gem "codeclimate-test-reporter"
|
||||
gem "rspec-mocks"
|
||||
gem "nokogiri"
|
||||
gem "rspec"
|
||||
gem "test-theme", path: File.expand_path("./test/fixtures/test-theme", File.dirname(__FILE__))
|
||||
|
||||
gem "jruby-openssl" if RUBY_ENGINE == "jruby"
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
group :test_legacy do
|
||||
if RUBY_PLATFORM =~ /cygwin/ || RUBY_VERSION.start_with?("2.2")
|
||||
gem 'test-unit'
|
||||
end
|
||||
|
||||
gem "redgreen"
|
||||
gem "simplecov"
|
||||
gem "minitest-reporters"
|
||||
gem "minitest-profile"
|
||||
gem "minitest"
|
||||
gem "shoulda"
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
group :benchmark do
|
||||
if ENV["BENCHMARK"]
|
||||
gem "ruby-prof"
|
||||
gem "benchmark-ips"
|
||||
gem "stackprof"
|
||||
gem "rbtrace"
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
group :jekyll_optional_dependencies do
|
||||
gem "toml", "~> 0.1.0"
|
||||
gem "coderay", "~> 1.1.0"
|
||||
gem "jekyll-docs", :path => '../docs' if Dir.exist?('../docs') && ENV['JEKYLL_VERSION']
|
||||
gem "jekyll-gist"
|
||||
gem "jekyll-feed"
|
||||
gem "jekyll-coffeescript"
|
||||
gem "jekyll-redirect-from"
|
||||
gem "jekyll-paginate"
|
||||
gem "mime-types", "~> 3.0"
|
||||
gem "kramdown", "~> 1.9"
|
||||
gem "rdoc", "~> 4.2"
|
||||
|
||||
platform :ruby, :mswin, :mingw, :x64_mingw do
|
||||
gem "rdiscount", "~> 2.0"
|
||||
gem "pygments.rb", "~> 0.6.0"
|
||||
gem "redcarpet", "~> 3.2", ">= 3.2.3"
|
||||
gem "classifier-reborn", "~> 2.0"
|
||||
gem "liquid-c", "~> 3.0"
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
group :site do
|
||||
if ENV["PROOF"]
|
||||
gem "html-proofer", "~> 2.0"
|
||||
end
|
||||
|
||||
gem "jemoji", "0.5.1"
|
||||
gem "jekyll-sitemap"
|
||||
gem "jekyll-seo-tag"
|
||||
gem "jekyll-avatar"
|
||||
gem "jekyll-mentions"
|
||||
end
|
||||
2404
History.markdown
2404
History.markdown
File diff suppressed because it is too large
Load Diff
105
History.txt
Normal file
105
History.txt
Normal file
@@ -0,0 +1,105 @@
|
||||
==
|
||||
* Minor Enhancements
|
||||
* Ability to set post categories via YAML [github.com/qrush]
|
||||
* Ability to set prevent a post from publishing via YAML [github.com/qrush]
|
||||
* Add textilize filter [github.com/willcodeforfoo]
|
||||
* Bug Fixes
|
||||
* Use block syntax of popen4 to ensure that subprocesses are properly disposed [github.com/jqr]
|
||||
|
||||
== 0.4.1
|
||||
* Minor Enhancements
|
||||
* Changed date format on wordpress converter (zeropadding) [github.com/dysinger]
|
||||
* Bug Fixes
|
||||
* Add jekyll binary as executable to gemspec [github.com/dysinger]
|
||||
|
||||
== 0.4.0 / 2009-02-03
|
||||
* Major Enhancements
|
||||
* Switch to Jeweler for packaging tasks
|
||||
* Minor Enhancements
|
||||
* Type importer [github.com/codeslinger]
|
||||
* site.topics accessor [github.com/baz]
|
||||
* Add array_to_sentence_string filter [github.com/mchung]
|
||||
* Add a converter for textpattern [github.com/PerfectlyNormal]
|
||||
* Add a working Mephisto / MySQL converter [github.com/ivey]
|
||||
* Allowing .htaccess files to be copied over into the generated site [github.com/briandoll]
|
||||
* Add option to not put file date in permalink URL [github.com/mreid]
|
||||
* Add line number capabilities to highlight blocks [github.com/jcon]
|
||||
* Bug Fixes
|
||||
* Fix permalink behavior [github.com/cavalle]
|
||||
* Fixed an issue with pygments, markdown, and newlines [github.com/zpinter]
|
||||
* Ampersands need to be escaped [github.com/pufuwozu, github.com/ap]
|
||||
* Test and fix the site.categories hash [github.com/zzot]
|
||||
* Fix site payload available to files [github.com/matrix9180]
|
||||
|
||||
== 0.3.0 / 2008-12-24
|
||||
* Major Enhancements
|
||||
* Added --server option to start a simple WEBrick server on destination directory [github.com/johnreilly and github.com/mchung]
|
||||
* Minor Enhancements
|
||||
* Added post categories based on directories containing _posts [github.com/mreid]
|
||||
* Added post topics based on directories underneath _posts
|
||||
* Added new date filter that shows the full month name [github.com/mreid]
|
||||
* Merge Post's YAML front matter into its to_liquid payload [github.com/remi]
|
||||
* Restrict includes to regular files underneath _includes
|
||||
* Bug Fixes
|
||||
* Change YAML delimiter matcher so as to not chew up 2nd level markdown headers [github.com/mreid]
|
||||
* Fix bug that meant page data (such as the date) was not available in templates [github.com/mreid]
|
||||
* Properly reject directories in _layouts
|
||||
|
||||
== 0.2.1 / 2008-12-15
|
||||
* Major Changes
|
||||
* Use Maruku (pure Ruby) for Markdown by default [github.com/mreid]
|
||||
* Allow use of RDiscount with --rdiscount flag
|
||||
* Minor Enhancements
|
||||
* Don't load directory_watcher unless it's needed [github.com/pjhyett]
|
||||
|
||||
== 0.2.0 / 2008-12-14
|
||||
* Major Changes
|
||||
* related_posts is now found in site.related_posts
|
||||
|
||||
== 0.1.6 / 2008-12-13
|
||||
* Major Features
|
||||
* Include files in _includes with {% include x.textile %}
|
||||
|
||||
== 0.1.5 / 2008-12-12
|
||||
* Major Features
|
||||
* Code highlighting with Pygments if --pygments is specified
|
||||
* Disable true LSI by default, enable with --lsi
|
||||
* Minor Enhancements
|
||||
* Output informative message if RDiscount is not available [github.com/JackDanger]
|
||||
* Bug Fixes
|
||||
* Prevent Jekyll from picking up the output directory as a source [github.com/JackDanger]
|
||||
* Skip related_posts when there is only one post [github.com/JackDanger]
|
||||
|
||||
== 0.1.4 / 2008-12-08
|
||||
* Bug Fixes
|
||||
* DATA does not work properly with rubygems
|
||||
|
||||
== 0.1.3 / 2008-12-06
|
||||
* Major Features
|
||||
* Markdown support [github.com/vanpelt]
|
||||
* Mephisto and CSV converters [github.com/vanpelt]
|
||||
* Code hilighting [github.com/vanpelt]
|
||||
* Autobuild
|
||||
* Bug Fixes
|
||||
* Accept both \r\n and \n in YAML header [github.com/vanpelt]
|
||||
|
||||
== 0.1.2 / 2008-11-22
|
||||
* Major Features
|
||||
* Add a real "related posts" implementation using Classifier
|
||||
* Command Line Changes
|
||||
* Allow cli to be called with 0, 1, or 2 args intuiting dir paths
|
||||
if they are omitted
|
||||
|
||||
== 0.1.1 / 2008-11-22
|
||||
* Minor Additions
|
||||
* Posts now support introspectional data e.g. {{ page.url }}
|
||||
|
||||
== 0.1.0 / 2008-11-05
|
||||
* First release
|
||||
* Converts posts written in Textile
|
||||
* Converts regular site pages
|
||||
* Simple copy of binary files
|
||||
|
||||
== 0.0.0 / 2008-10-19
|
||||
* Birthday!
|
||||
|
||||
21
LICENSE
21
LICENSE
@@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2008-2016 Tom Preston-Werner
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,60 +0,0 @@
|
||||
# [Jekyll](https://jekyllrb.com/)
|
||||
|
||||
[][ruby-gems]
|
||||
[][travis]
|
||||
[][appveyor]
|
||||
[][coverage]
|
||||
[][codeclimate]
|
||||
[][gemnasium]
|
||||
[][hakiri]
|
||||
|
||||
[ruby-gems]: https://rubygems.org/gems/jekyll
|
||||
[gemnasium]: https://gemnasium.com/jekyll/jekyll
|
||||
[codeclimate]: https://codeclimate.com/github/jekyll/jekyll
|
||||
[coverage]: https://codeclimate.com/github/jekyll/jekyll/coverage
|
||||
[hakiri]: https://hakiri.io/github/jekyll/jekyll/master
|
||||
[travis]: https://travis-ci.org/jekyll/jekyll
|
||||
[appveyor]: https://ci.appveyor.com/project/jekyll/jekyll/branch/master
|
||||
|
||||
Jekyll is a simple, blog-aware, static site generator perfect for personal, project, or organization sites. Think of it like a file-based CMS, without all the complexity. Jekyll takes your content, renders Markdown and Liquid templates, and spits out a complete, static website ready to be served by Apache, Nginx or another web server. Jekyll is the engine behind [GitHub Pages](https://pages.github.com), which you can use to host sites right from your GitHub repositories.
|
||||
|
||||
## Philosophy
|
||||
|
||||
Jekyll does what you tell it to do — no more, no less. It doesn't try to outsmart users by making bold assumptions, nor does it burden them with needless complexity and configuration. Put simply, Jekyll gets out of your way and allows you to concentrate on what truly matters: your content.
|
||||
|
||||
## Having trouble with OS X El Capitan?
|
||||
|
||||
See: https://jekyllrb.com/docs/troubleshooting/#jekyll-amp-mac-os-x-1011
|
||||
|
||||
## Getting Started
|
||||
|
||||
* [Install](https://jekyllrb.com/docs/installation/) the gem
|
||||
* Read up about its [Usage](https://jekyllrb.com/docs/usage/) and [Configuration](https://jekyllrb.com/docs/configuration/)
|
||||
* Take a gander at some existing [Sites](https://wiki.github.com/jekyll/jekyll/sites)
|
||||
* [Fork](https://github.com/jekyll/jekyll/fork) and [Contribute](https://jekyllrb.com/docs/contributing/) your own modifications
|
||||
* Have questions? Check out our official forum community [Jekyll Talk](https://talk.jekyllrb.com/) or [`#jekyll` on irc.freenode.net](https://botbot.me/freenode/jekyll/)
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
In order to have a more open and welcoming community, Jekyll adheres to a
|
||||
[code of conduct](CONDUCT.markdown) adapted from the Ruby on Rails code of
|
||||
conduct.
|
||||
|
||||
Please adhere to this code of conduct in any interactions you have in the
|
||||
Jekyll community. It is strictly enforced on all official Jekyll
|
||||
repositories, websites, and resources. If you encounter someone violating
|
||||
these terms, please let a maintainer ([@parkr](https://github.com/parkr), [@envygeeks](https://github.com/envygeeks), or [@mattr-](https://github.com/mattr-)) know
|
||||
and we will address it as soon as possible.
|
||||
|
||||
## Diving In
|
||||
|
||||
* [Migrate](http://import.jekyllrb.com/docs/home/) from your previous system
|
||||
* Learn how the [YAML Front Matter](https://jekyllrb.com/docs/frontmatter/) works
|
||||
* Put information on your site with [Variables](https://jekyllrb.com/docs/variables/)
|
||||
* Customize the [Permalinks](https://jekyllrb.com/docs/permalinks/) your posts are generated with
|
||||
* 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
|
||||
|
||||
## License
|
||||
|
||||
See the [LICENSE](https://github.com/jekyll/jekyll/blob/master/LICENSE) file.
|
||||
499
README.textile
Normal file
499
README.textile
Normal file
@@ -0,0 +1,499 @@
|
||||
h1. Jekyll LOL
|
||||
|
||||
Jekyll is a simple, blog aware, static site generator. It takes a template
|
||||
directory (representing the raw form of a website), runs it through Textile or
|
||||
Markdown and Liquid converters, and spits out a complete, static website
|
||||
suitable for serving with Apache or your favorite web server. Visit
|
||||
"http://tom.preston-werner.com":http://tom.preston-werner.com to see an
|
||||
example of a Jekyll generated blog.
|
||||
|
||||
Some more changes...
|
||||
|
||||
To understand how this all works, open up my
|
||||
"TPW":http://github.com/mojombo/tpw repo in a new browser window. I'll be
|
||||
referencing the code there.
|
||||
|
||||
Take a look at
|
||||
"index.html":http://github.com/mojombo/tpw/tree/master/index.html. This file
|
||||
represents the homepage of the site. At the top of the file is a chunk of YAML
|
||||
that contains metadata about the file. This data tells Jekyll what layout to
|
||||
give the file, what the page's title should be, etc. In this case, I specify
|
||||
that the "default" template should be used. You can find the layout files in
|
||||
the "_layouts":http://github.com/mojombo/tpw/tree/master/_layouts directory.
|
||||
If you open
|
||||
"default.html":http://github.com/mojombo/tpw/tree/master/_layouts/default.html
|
||||
you can see that the homepage is constructed by wrapping index.html with this
|
||||
layout.
|
||||
|
||||
You'll also notice Liquid templating code in these files.
|
||||
"Liquid":http://www.liquidmarkup.org/ is a simple, extensible templating
|
||||
language that makes it easy to embed data in your templates. For my homepage I
|
||||
wanted to have a list of all my blog posts. Jekyll hands me a Hash containing
|
||||
various data about my site. A reverse chronological list of all my blog posts
|
||||
can be found in <code>site.posts</code>. Each post, in turn, contains various
|
||||
fields such as <code>title</code> and <code>date</code>.
|
||||
|
||||
Jekyll gets the list of blog posts by parsing the files in any
|
||||
"_posts":http://github.com/mojombo/tpw/tree/master/_posts directory found in
|
||||
subdirectories below the root.
|
||||
Each post's filename contains (by default) the publishing date and slug (what shows up in the
|
||||
URL) that the final HTML file should have. Open up the file corresponding to a
|
||||
blog post:
|
||||
"2008-11-17-blogging-like-a-hacker.textile":http://github.com/mojombo/tpw/tree/master/_posts/2008-11-17-blogging-like-a-hacker.textile.
|
||||
GitHub renders textile files by default, so to better understand the file,
|
||||
click on the
|
||||
"raw":http://github.com/mojombo/tpw/tree/master/_posts/2008-11-17-blogging-like-a-hacker.textile?raw=true
|
||||
view to see the original file. Here I've specified the <code>post</code>
|
||||
layout. If you look at that file you'll see an example of a nested layout.
|
||||
Layouts can contain other layouts allowing you a great deal of flexibility in
|
||||
how pages are assembled. In my case I use a nested layout in order to show
|
||||
related posts for each blog entry. The YAML also specifies the post's title
|
||||
which is then embedded in the post's body via Liquid.
|
||||
|
||||
Posts are handled in a special way by Jekyll. The date you specify in the
|
||||
filename is used to construct the URL in the generated site. The example post,
|
||||
for instance, ends up at
|
||||
<code>http://tom.preston-werner.com/2008/11/17/blogging-like-a-hacker.html</code>.
|
||||
|
||||
Categories for posts are derived from the directory structure the posts were
|
||||
found within. A post that appears in the directory foo/bar/_posts is placed in
|
||||
the categories 'foo' and 'bar'. By selecting posts from particular categories
|
||||
in your Liquid templates, you will be able to host multiple blogs within a
|
||||
site.
|
||||
|
||||
Files that do not reside in directories prefixed with an underscore are
|
||||
mirrored into a corresponding directory structure in the generated site. If a
|
||||
file does not have a YAML preface, it is not run through the Liquid
|
||||
interpreter. Binary files are copied over unmodified.
|
||||
|
||||
Jekyll is still a very young project. I've only developed the exact
|
||||
functionality that I've needed. As time goes on I'd like to see the project
|
||||
mature and support additional features. If you end up using Jekyll for your
|
||||
own blog, drop me a line and let me know what you'd like to see in future
|
||||
versions. Better yet, fork the project over at GitHub and hack in the features
|
||||
yourself!
|
||||
|
||||
h2. Example Proto-Site
|
||||
|
||||
My own personal site/blog is generated with Jekyll.
|
||||
|
||||
The proto-site repo
|
||||
("http://github.com/mojombo/tpw":http://github.com/mojombo/tpw) is converted
|
||||
into the actual site
|
||||
("http://tom.preston-werner.com/":http://tom.preston-werner.com)
|
||||
|
||||
h2. Install
|
||||
|
||||
The best way to install Jekyll is via RubyGems:
|
||||
|
||||
$ sudo gem install mojombo-jekyll -s http://gems.github.com/
|
||||
|
||||
Jekyll requires the gems `directory_watcher`, `liquid`, `open4`,
|
||||
and `maruku` (for markdown support). These are automatically
|
||||
installed by the gem install command.
|
||||
|
||||
Maruku comes with optional support for LaTeX to PNG rendering via
|
||||
"blahtex":http://gva.noekeon.org/blahtexml/ (Version 0.6) which must be in
|
||||
your $PATH along with `dvips`.
|
||||
|
||||
(NOTE: the version of maruku I am using is `remi-maruku` on GitHub as it
|
||||
does not assume a fixed location for `dvips`.)
|
||||
|
||||
h2. Run
|
||||
|
||||
$ cd /path/to/proto/site
|
||||
$ jekyll
|
||||
|
||||
This will generate the site and place it in /path/to/proto/site/_site. If
|
||||
you'd like the generated site placed somewhere else:
|
||||
|
||||
$ jekyll /path/to/place/generated/site
|
||||
|
||||
And if you don't want to be in the proto site root to run Jekyll:
|
||||
|
||||
$ jekyll /path/to/proto/site /path/to/place/generated/site
|
||||
|
||||
h2. Run Options
|
||||
|
||||
There is an autobuild feature that will regenerate your site if any of the
|
||||
files change. The autobuild feature can be used on any of the invocations:
|
||||
|
||||
$ jekyll --auto
|
||||
|
||||
By default, the "related posts" functionality will produce crappy results.
|
||||
In order to get high quality results with a true LSI algorithm, you must
|
||||
enable it (it may take some time to run if you have many posts):
|
||||
|
||||
$ jekyll --lsi
|
||||
|
||||
For static code highlighting, you can install Pygments (see below) and then
|
||||
use that to make your code blocks look pretty. To activate Pygments support
|
||||
during the conversion:
|
||||
|
||||
$ jekyll --pygments
|
||||
|
||||
By default, Jekyll uses "Maruku":http://maruku.rubyforge.org (pure Ruby) for
|
||||
Markdown support. If you'd like to use RDiscount (faster, but requires
|
||||
compilation), you must install it (gem install rdiscount) and then you can
|
||||
have it used instead:
|
||||
|
||||
$ jekyll --rdiscount
|
||||
|
||||
As another alternative, just because to make it a hat trick, you can also
|
||||
use BlueCloth (gem install bluecloth).
|
||||
|
||||
$ jekyll --bluecloth
|
||||
|
||||
When previewing complex sites locally, simply opening the site in a web
|
||||
browser (using file://) can cause problems with links that are relative to
|
||||
the site root (e.g., "/stylesheets/style.css"). To get around this, Jekyll
|
||||
can launch a simple WEBrick server (works well in conjunction with --auto).
|
||||
Default port is 4000:
|
||||
|
||||
$ jekyll --server [PORT]
|
||||
|
||||
By default, the permalink for each post begins with its date in 'YYYY/MM/DD'
|
||||
format. If you do not wish to have the date appear in the URL of each post,
|
||||
you can change the permalink style to 'none' so that only the 'slug' part of
|
||||
the filename is used. For example, with the permalink style set to 'none' the
|
||||
file '2009-01-01-happy-new-year.markdown' will have a permalink like
|
||||
'http://yoursite.com/happy-new-year.html'. The date of the post will still be
|
||||
read from the filename (and is required!) to be used elsewhere in Jekyll.
|
||||
Also supported is the permalink format shortdate, which will use the YYYY/M/D
|
||||
for days and months < 10.
|
||||
Example usage:
|
||||
|
||||
$ jekyll --permalink none
|
||||
|
||||
h2. Data
|
||||
|
||||
Jekyll traverses your site looking for files to process. Any files with YAML
|
||||
front matter (see below) are subject to processing. For each of these files,
|
||||
Jekyll makes a variety of data available to the pages via the Liquid
|
||||
templating system. The following is a reference of the available data.
|
||||
|
||||
h3. Global
|
||||
|
||||
site
|
||||
Sitewide information.
|
||||
|
||||
page
|
||||
For Posts, this is the union of the data in the YAML front matter and the
|
||||
computed data (such as URL and date). For regular pages, this is just the
|
||||
YAML front matter.
|
||||
|
||||
content
|
||||
In layout files, this contains the content of the subview(s). In Posts or
|
||||
Pages, this is undefined.
|
||||
|
||||
h3. Site
|
||||
|
||||
site.time
|
||||
The current Time (when you run the jekyll command).
|
||||
|
||||
site.posts
|
||||
A reverse chronological list of all Posts.
|
||||
|
||||
site.related_posts
|
||||
If the page being processed is a Post, this contains a list of up to ten
|
||||
related Posts. By default, these are low quality but fast to compute. For
|
||||
high quality but slow to compute results, run the jekyll command with the
|
||||
--lsi (latent semantic indexing) option.
|
||||
|
||||
site.categories.CATEGORY
|
||||
The list of all Posts in category CATEGORY.
|
||||
|
||||
h3. Post
|
||||
|
||||
post.title
|
||||
The title of the Post.
|
||||
|
||||
post.url
|
||||
The URL of the Post without the domain.
|
||||
e.g. /2008/12/14/my-post.html
|
||||
|
||||
post.date
|
||||
The Date assigned to the Post.
|
||||
|
||||
post.id
|
||||
An identifier unique to the Post (useful in RSS feeds).
|
||||
e.g. /2008/12/14/my-post
|
||||
|
||||
post.categories
|
||||
The list of categories to which this post belongs. Categories are
|
||||
derived from the directory structure above the _posts directory. For
|
||||
example, a post at /work/code/_posts/2008-12-24-closures.textile
|
||||
would have this field set to ['work', 'code'].
|
||||
|
||||
post.topics
|
||||
The list of topics for this Post. Topics are derived from the directory
|
||||
structure beneath the _posts directory. For example, a post at
|
||||
/_posts/music/metal/2008-12-24-metalocalypse.textile would have this field
|
||||
set to ['music', 'metal'].
|
||||
|
||||
post.content
|
||||
The content of the Post.
|
||||
|
||||
h2. YAML Front Matter
|
||||
|
||||
Any files that contain a YAML front matter block will be processed by Jekyll
|
||||
as special files. The front matter must be the first thing in the file and
|
||||
takes the form of:
|
||||
|
||||
<pre>
|
||||
---
|
||||
layout: post
|
||||
title: Blogging Like a Hacker
|
||||
---
|
||||
</pre>
|
||||
|
||||
Between the triple-dashed lines, you can set predefined variables (see below
|
||||
for a reference) or custom data of your own.
|
||||
|
||||
h3. Predefined Global Variables
|
||||
|
||||
layout
|
||||
If set, this specifies the layout file to use. Use the layout file
|
||||
name without file extension. Layout files must be placed in the
|
||||
<code>_layouts</code> directory.
|
||||
|
||||
h3. Predefined Post Variables
|
||||
|
||||
permalink
|
||||
If you need your processed URLs to be something other than the default
|
||||
/year/month/day/title.html then you can set this variable and it will
|
||||
be used as the final URL.
|
||||
|
||||
published
|
||||
Set to false if you don't want a post to show up when the site is
|
||||
generated.
|
||||
|
||||
category/categories
|
||||
Instead of placing posts inside of folders, you can specify one or more
|
||||
categories that the post belongs to. When the site is generated the post
|
||||
will act as though it had been set with these categories normally.
|
||||
|
||||
h3. Custom Variables
|
||||
|
||||
Any variables in the front matter that are not predefined are mixed into the
|
||||
data that is sent to the Liquid templating engine during the conversion. For
|
||||
instance, if you set a <code>title</code>, you can use that in your layout to
|
||||
set the page title:
|
||||
|
||||
<pre>
|
||||
<title>{{ page.title }}</title>
|
||||
</pre>
|
||||
|
||||
h2. Filters, Tags, and Blocks
|
||||
|
||||
In addition to the built-in Liquid filters, tags, and blocks, Jekyll provides
|
||||
some additional items that you can use in your site.
|
||||
|
||||
h3. Date to XML Schema (Filter)
|
||||
|
||||
Convert a Time into XML Schema format.
|
||||
|
||||
{{ site.time | date_to_xmlschema }}
|
||||
|
||||
becomes
|
||||
|
||||
2008-11-17T13:07:54-08:00
|
||||
|
||||
h3. XML Escape (Filter)
|
||||
|
||||
Escape some text for use in XML.
|
||||
|
||||
{{ post.content | xml_escape }}
|
||||
|
||||
h3. Number of Words (Filter)
|
||||
|
||||
Count the number of words in some text.
|
||||
|
||||
{{ post.content | number_of_words }}
|
||||
|
||||
becomes
|
||||
|
||||
1337
|
||||
|
||||
h3. Array to Sentence String
|
||||
|
||||
Convert an array into a sentence.
|
||||
|
||||
{{ page.tags | array_to_sentence_string }}
|
||||
|
||||
becomes
|
||||
|
||||
foo, bar, and baz
|
||||
|
||||
h3. Textilize
|
||||
|
||||
Convert a Textile-formatted string into HTML, formatted via RedCloth
|
||||
|
||||
{{ page.excerpt | textilize }}
|
||||
|
||||
h3. Include (Tag)
|
||||
|
||||
If you have small page fragments that you wish to include in multiple places
|
||||
on your site, you can use the <code>include</code> tag.
|
||||
|
||||
<pre>{% include sig.textile %}</pre>
|
||||
|
||||
Jekyll expects all include files to be placed in an <code>_includes</code>
|
||||
directory at the root of your source dir. So this will embed the contents of
|
||||
<code>/path/to/proto/site/_includes/sig.textile</code> into the calling file.
|
||||
|
||||
h3. Code Highlighting (Block)
|
||||
|
||||
Jekyll has built in support for syntax highlighting of over "100
|
||||
languages":http://pygments.org/languages/ via "Pygments":http://pygments.org/.
|
||||
In order to take advantage of this you'll need to have Pygments installed, and
|
||||
the pygmentize binary must be in your path. When you run Jekyll, make sure you
|
||||
run it with Pygments support:
|
||||
|
||||
$ jekyll --pygments
|
||||
|
||||
To denote a code block that should be highlighted:
|
||||
|
||||
<pre>
|
||||
{% highlight ruby %}
|
||||
def foo
|
||||
puts 'foo'
|
||||
end
|
||||
{% endhighlight %}
|
||||
</pre>
|
||||
|
||||
The argument to <code>highlight</code> is the language identifier. To find the
|
||||
appropriate identifier to use for your favorite language, look for the "short
|
||||
name" on the "Lexers":http://pygments.org/docs/lexers/ page.
|
||||
|
||||
There is a second argument to <code>highlight</code> called
|
||||
<code>linenos</code> that is optional. Including the <code>linenos</code>
|
||||
argument will force the highlighted code to include line numbers. For
|
||||
instance, the following code block would include line numbers next to each
|
||||
line:
|
||||
|
||||
<pre>
|
||||
{% highlight ruby linenos %}
|
||||
def foo
|
||||
puts 'foo'
|
||||
end
|
||||
{% endhighlight %}
|
||||
</pre>
|
||||
|
||||
In order for the highlighting to show up, you'll need to include a
|
||||
highlighting stylesheet. For an example stylesheet you can look at
|
||||
"syntax.css":http://github.com/mojombo/tpw/tree/master/css/syntax.css. These
|
||||
are the same styles as used by GitHub and you are free to use them for your
|
||||
own site. If you use linenos, you might want to include an additional CSS
|
||||
class definition for <code>lineno</code> in syntax.css to distinguish the line
|
||||
numbers from the highlighted code.
|
||||
|
||||
h2. Categories
|
||||
|
||||
Posts are placed into categories based on the directory structure they are
|
||||
found within (see above for an example). The categories can be accessed from
|
||||
within a Liquid template as follows:
|
||||
|
||||
<pre>
|
||||
{% for post in site.categories.foo %}
|
||||
<li><span>{{ post.date | date_to_string }}</span> - {{ post.title }}</li>
|
||||
{% endfor %}
|
||||
</pre>
|
||||
|
||||
This would list all the posts in the category 'foo' by date and title.
|
||||
|
||||
The posts within each category are sorted in reverse chronological order.
|
||||
|
||||
h2. Blog migrations
|
||||
|
||||
h3. Movable Type
|
||||
|
||||
To migrate your MT blog into Jekyll, you'll need read access to the database.
|
||||
The lib/jekyll/converters/mt.rb module provides a simple convert to create
|
||||
.markdown files in a _posts directory based on the entries contained therein.
|
||||
|
||||
$ export DB=my_mtdb
|
||||
$ export USER=dbuser
|
||||
$ export PASS=dbpass
|
||||
$ ruby -r './lib/jekyll/converters/mt' -e 'Jekyll::MT.process( \
|
||||
"#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")'
|
||||
|
||||
You may need to adjust the SQL query used to retrieve MT entries. Left alone,
|
||||
it will attempt to pull all entries across all blogs regardless of status.
|
||||
Please check the results and verify the posts before publishing.
|
||||
|
||||
h3. Typo 4+
|
||||
|
||||
To migrate your Typo blog into Jekyll, you'll need read access to the MySQL
|
||||
database. The lib/jekyll/converters/typo.rb module provides a simple convert
|
||||
to create .html, .textile, or .markdown files in a _posts directory based on
|
||||
the entries contained therein.
|
||||
|
||||
$ export DB=my_typo_db
|
||||
$ export USER=dbuser
|
||||
$ export PASS=dbpass
|
||||
$ ruby -r './lib/jekyll/converters/typo' -e 'Jekyll::Typo.process( \
|
||||
"#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")'
|
||||
|
||||
You may need to adjust the code used to filter Typo entries. Left alone,
|
||||
it will attempt to pull all entries across all blogs that were published.
|
||||
This code also has only been tested with Typo version 4+. Previous versions
|
||||
of Typo may not convert correctly. Please check the results and verify the
|
||||
posts before publishing.
|
||||
|
||||
h3. TextPattern 4
|
||||
|
||||
To migrate your TextPattern blog into Jekyll, you'll need read access to the MySQL
|
||||
database. The lib/jekyll/converters/textpattern.rb module provides a simple convert to create .textile files in a _posts directory based on
|
||||
the entries contained therein.
|
||||
|
||||
$ ruby -r './lib/jekyll/converters/textpattern' -e 'Jekyll::TextPattern.process( \
|
||||
"database_name", "username", "password", "hostname")'
|
||||
|
||||
The hostname defaults to _localhost_, all other variables are needed
|
||||
You may need to adjust the code used to filter entries. Left alone,
|
||||
it will attempt to pull all entries that are live or sticky.
|
||||
|
||||
h2. Contribute
|
||||
|
||||
If you'd like to hack on Jekyll, start by forking my repo on GitHub:
|
||||
|
||||
http://github.com/mojombo/jekyll
|
||||
|
||||
To get all of the dependencies, install the gem first. The best way to get
|
||||
your changes merged back into core is as follows:
|
||||
|
||||
# Clone down your fork
|
||||
# Create a topic branch to contain your change
|
||||
# Hack away
|
||||
# Add tests and make sure everything still passes by running `rake`
|
||||
# If you are adding new functionality, document it in README.textile
|
||||
# Do not change the version number, I will do that on my end
|
||||
# If necessary, rebase your commits into logical chunks, without errors
|
||||
# Push the branch up to GitHub
|
||||
# Send me (mojombo) a pull request for your branch
|
||||
|
||||
h2. License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2008 Tom Preston-Werner
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
200
Rakefile
200
Rakefile
@@ -1,160 +1,76 @@
|
||||
require 'rubygems'
|
||||
require 'rake'
|
||||
require 'rdoc'
|
||||
require 'date'
|
||||
require 'yaml'
|
||||
|
||||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w[lib]))
|
||||
require 'jekyll/version'
|
||||
|
||||
Dir.glob('rake/**.rake').each { |f| import f }
|
||||
|
||||
#############################################################################
|
||||
#
|
||||
# Helper functions
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
def name
|
||||
"jekyll"
|
||||
end
|
||||
|
||||
def version
|
||||
Jekyll::VERSION
|
||||
end
|
||||
|
||||
def docs_name
|
||||
"#{name}-docs"
|
||||
end
|
||||
|
||||
def gemspec_file
|
||||
"#{name}.gemspec"
|
||||
end
|
||||
|
||||
def gem_file
|
||||
"#{name}-#{Gem::Version.new(version).to_s}.gem"
|
||||
end
|
||||
|
||||
def normalize_bullets(markdown)
|
||||
markdown.gsub(/\n\s{2}\*{1}/, "\n-")
|
||||
end
|
||||
|
||||
def linkify_prs(markdown)
|
||||
markdown.gsub(/#(\d+)/) do |word|
|
||||
"[#{word}]({{ site.repository }}/issues/#{word.delete("#")})"
|
||||
end
|
||||
end
|
||||
|
||||
def linkify_users(markdown)
|
||||
markdown.gsub(/(@\w+)/) do |username|
|
||||
"[#{username}](https://github.com/#{username.delete("@")})"
|
||||
end
|
||||
end
|
||||
|
||||
def linkify(markdown)
|
||||
linkify_users(linkify_prs(markdown))
|
||||
end
|
||||
|
||||
def liquid_escape(markdown)
|
||||
markdown.gsub(/(`{[{%].+[}%]}`)/, "{% raw %}\\1{% endraw %}")
|
||||
end
|
||||
|
||||
def custom_release_header_anchors(markdown)
|
||||
header_regexp = /^(\d{1,2})\.(\d{1,2})\.(\d{1,2}) \/ \d{4}-\d{2}-\d{2}/
|
||||
section_regexp = /^### \w+ \w+$/
|
||||
markdown.split(/^##\s/).map do |release_notes|
|
||||
_, major, minor, patch = *release_notes.match(header_regexp)
|
||||
release_notes
|
||||
.gsub(header_regexp, "\\0\n{: #v\\1-\\2-\\3}")
|
||||
.gsub(section_regexp) { |section| "#{section}\n{: ##{sluffigy(section)}-v#{major}-#{minor}-#{patch}}" }
|
||||
end.join("\n## ")
|
||||
end
|
||||
|
||||
def sluffigy(header)
|
||||
header.gsub(/#/, '').strip.downcase.gsub(/\s+/, '-')
|
||||
end
|
||||
|
||||
def remove_head_from_history(markdown)
|
||||
index = markdown =~ /^##\s+\d+\.\d+\.\d+/
|
||||
markdown[index..-1]
|
||||
end
|
||||
|
||||
def converted_history(markdown)
|
||||
remove_head_from_history(
|
||||
custom_release_header_anchors(
|
||||
liquid_escape(
|
||||
linkify(
|
||||
normalize_bullets(markdown)))))
|
||||
end
|
||||
|
||||
def siteify_file(file, overrides_front_matter = {})
|
||||
abort "You seem to have misplaced your #{file} file. I can haz?" unless File.exists?(file)
|
||||
title = begin
|
||||
File.read(file).match(/\A# (.*)$/)[1]
|
||||
rescue
|
||||
File.basename(file, ".*").downcase.capitalize
|
||||
end
|
||||
slug = File.basename(file, ".markdown").downcase
|
||||
front_matter = {
|
||||
"title" => title,
|
||||
"layout" => "docs",
|
||||
"permalink" => "/docs/#{slug}/",
|
||||
"note" => "This file is autogenerated. Edit /#{file} instead."
|
||||
}.merge(overrides_front_matter)
|
||||
contents = "#{front_matter.to_yaml}---\n\n#{content_for(file)}"
|
||||
File.write("site/_docs/#{slug}.md", contents)
|
||||
end
|
||||
|
||||
def content_for(file)
|
||||
contents = File.read(file)
|
||||
case file
|
||||
when "History.markdown"
|
||||
converted_history(contents)
|
||||
else
|
||||
contents.gsub(/\A# .*\n\n?/, "")
|
||||
end
|
||||
end
|
||||
|
||||
#############################################################################
|
||||
#
|
||||
# Standard tasks
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
multitask :default => [:test, :features]
|
||||
|
||||
task :spec => :test
|
||||
require 'rake/testtask'
|
||||
Rake::TestTask.new(:test) do |test|
|
||||
test.libs << 'lib' << 'test'
|
||||
test.pattern = 'test/**/test_*.rb'
|
||||
test.verbose = true
|
||||
require 'rake/rdoctask'
|
||||
|
||||
begin
|
||||
require 'jeweler'
|
||||
Jeweler::Tasks.new do |s|
|
||||
s.name = "jekyll"
|
||||
s.summary = %Q{Jekyll is a simple, blog aware, static site generator.}
|
||||
s.email = "tom@mojombo.com"
|
||||
s.homepage = "http://github.com/mojombo/jekyll"
|
||||
s.description = "Jekyll is a simple, blog aware, static site generator."
|
||||
s.authors = ["Tom Preston-Werner"]
|
||||
s.rubyforge_project = "jekyll"
|
||||
s.files = FileList["[A-Z]*", "{bin,lib,test}/**/*"]
|
||||
s.add_dependency('RedCloth', '>= 4.0.4')
|
||||
s.add_dependency('liquid', '>= 1.9.0')
|
||||
s.add_dependency('classifier', '>= 1.3.1')
|
||||
s.add_dependency('maruku', '>= 0.5.9')
|
||||
s.add_dependency('directory_watcher', '>= 1.1.1')
|
||||
s.add_dependency('open4', '>= 0.9.6')
|
||||
s.executables = "jekyll"
|
||||
end
|
||||
rescue LoadError
|
||||
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
||||
end
|
||||
|
||||
Rake::TestTask.new do |t|
|
||||
t.libs << 'lib'
|
||||
t.pattern = 'test/**/test_*.rb'
|
||||
t.verbose = false
|
||||
end
|
||||
|
||||
require 'rdoc/task'
|
||||
Rake::RDocTask.new do |rdoc|
|
||||
rdoc.rdoc_dir = 'rdoc'
|
||||
rdoc.title = "#{name} #{version}"
|
||||
rdoc.title = 'jekyll'
|
||||
rdoc.options << '--line-numbers' << '--inline-source'
|
||||
rdoc.rdoc_files.include('README*')
|
||||
rdoc.rdoc_files.include('lib/**/*.rb')
|
||||
end
|
||||
|
||||
begin
|
||||
require 'cucumber/rake/task'
|
||||
Cucumber::Rake::Task.new(:features) do |t|
|
||||
t.profile = "travis"
|
||||
end
|
||||
Cucumber::Rake::Task.new(:"features:html", "Run Cucumber features and produce HTML output") do |t|
|
||||
t.profile = "html_report"
|
||||
require 'rcov/rcovtask'
|
||||
Rcov::RcovTask.new do |t|
|
||||
t.libs << 'test'
|
||||
t.test_files = FileList['test/**/test_*.rb']
|
||||
t.verbose = true
|
||||
end
|
||||
rescue LoadError
|
||||
desc 'Cucumber rake task not available'
|
||||
task :features do
|
||||
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
||||
end
|
||||
end
|
||||
|
||||
task :default => :test
|
||||
|
||||
# console
|
||||
|
||||
desc "Open an irb session preloaded with this library"
|
||||
task :console do
|
||||
sh "irb -rubygems -r ./lib/#{name}.rb"
|
||||
sh "irb -rubygems -I lib -r jekyll.rb"
|
||||
end
|
||||
|
||||
# converters
|
||||
|
||||
namespace :convert do
|
||||
desc "Migrate from mephisto in the current directory"
|
||||
task :mephisto do
|
||||
sh %q(ruby -r './lib/jekyll/converters/mephisto' -e 'Jekyll::Mephisto.postgres(:database => "#{ENV["DB"]}")')
|
||||
end
|
||||
desc "Migrate from Movable Type in the current directory"
|
||||
task :mt do
|
||||
sh %q(ruby -r './lib/jekyll/converters/mt' -e 'Jekyll::MT.process("#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")')
|
||||
end
|
||||
desc "Migrate from Typo in the current directory"
|
||||
task :typo do
|
||||
sh %q(ruby -r './lib/jekyll/converters/typo' -e 'Jekyll::Typo.process("#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")')
|
||||
end
|
||||
end
|
||||
|
||||
3
TODO
Normal file
3
TODO
Normal file
@@ -0,0 +1,3 @@
|
||||
[x] Easier configuration of Maruka and blahtex directories [mdreid]
|
||||
[x] Accurate "related posts" calculator
|
||||
[x] Autobuild
|
||||
4
VERSION.yml
Normal file
4
VERSION.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
:major: 0
|
||||
:minor: 4
|
||||
:patch: 5
|
||||
42
appveyor.yml
42
appveyor.yml
@@ -1,42 +0,0 @@
|
||||
version: "{build}"
|
||||
|
||||
clone_depth: 10
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- themes
|
||||
|
||||
build: off
|
||||
|
||||
install:
|
||||
- SET PATH=C:\Ruby%RUBY_FOLDER_VER%\bin;%PATH%
|
||||
- bundle install --retry 5 --jobs=%NUMBER_OF_PROCESSORS% --clean --path vendor\bundle
|
||||
|
||||
environment:
|
||||
BUNDLE_WITHOUT: "benchmark:site:development"
|
||||
matrix:
|
||||
- RUBY_FOLDER_VER: "23"
|
||||
TEST_SUITE: "test"
|
||||
- RUBY_FOLDER_VER: "23"
|
||||
TEST_SUITE: "cucumber"
|
||||
- RUBY_FOLDER_VER: "23"
|
||||
TEST_SUITE: "fmt"
|
||||
- RUBY_FOLDER_VER: "23"
|
||||
TEST_SUITE: "default-site"
|
||||
- RUBY_FOLDER_VER: "23-x64"
|
||||
TEST_SUITE: "test"
|
||||
- RUBY_FOLDER_VER: "22"
|
||||
TEST_SUITE: "test"
|
||||
- RUBY_FOLDER_VER: "21"
|
||||
TEST_SUITE: "test"
|
||||
|
||||
test_script:
|
||||
- ruby --version
|
||||
- gem --version
|
||||
- bundler --version
|
||||
- bash ./script/cibuild
|
||||
|
||||
cache:
|
||||
# If one of the files after the right arrow changes, cache will be skipped
|
||||
- 'vendor\bundle -> appveyor.yml,Gemfile,jekyll.gemspec'
|
||||
@@ -1,20 +0,0 @@
|
||||
require "liquid"
|
||||
require "benchmark/ips"
|
||||
|
||||
puts "Ruby #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
|
||||
puts "Liquid #{Liquid::VERSION}"
|
||||
|
||||
template1 = '{% capture foobar %}foo{{ bar }}{% endcapture %}{{ foo }}{{ foobar }}'
|
||||
template2 = '{% assign foobar = "foo" | append: bar %}{{ foobar }}'
|
||||
|
||||
def render(template)
|
||||
Liquid::Template.parse(template).render("bar" => "42")
|
||||
end
|
||||
|
||||
puts render(template1)
|
||||
puts render(template2)
|
||||
|
||||
Benchmark.ips do |x|
|
||||
x.report('capture') { render(template1) }
|
||||
x.report('assign') { render(template2) }
|
||||
end
|
||||
@@ -1,15 +0,0 @@
|
||||
require 'benchmark/ips'
|
||||
|
||||
Benchmark.ips do |x|
|
||||
path_without_ending_slash = '/some/very/very/long/path/to/a/file/i/like'
|
||||
x.report('no slash regexp') { path_without_ending_slash =~ /\/$/ }
|
||||
x.report('no slash end_with?') { path_without_ending_slash.end_with?("/") }
|
||||
x.report('no slash [-1, 1]') { path_without_ending_slash[-1, 1] == "/" }
|
||||
end
|
||||
|
||||
Benchmark.ips do |x|
|
||||
path_with_ending_slash = '/some/very/very/long/path/to/a/file/i/like/'
|
||||
x.report('slash regexp') { path_with_ending_slash =~ /\/$/ }
|
||||
x.report('slash end_with?') { path_with_ending_slash.end_with?("/") }
|
||||
x.report('slash [-1, 1]') { path_with_ending_slash[-1, 1] == "/" }
|
||||
end
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
require 'benchmark/ips'
|
||||
|
||||
# For this pull request, which changes Page#dir
|
||||
# https://github.com/jekyll/jekyll/pull/4403
|
||||
|
||||
FORWARD_SLASH = '/'.freeze
|
||||
|
||||
def pre_pr(url)
|
||||
url[-1, 1] == FORWARD_SLASH ? url : File.dirname(url)
|
||||
end
|
||||
|
||||
def pr(url)
|
||||
if url.end_with?(FORWARD_SLASH)
|
||||
url
|
||||
else
|
||||
url_dir = File.dirname(url)
|
||||
url_dir.end_with?(FORWARD_SLASH) ? url_dir : "#{url_dir}/"
|
||||
end
|
||||
end
|
||||
|
||||
def envygeeks(url)
|
||||
return url if url.end_with?(FORWARD_SLASH) || url == FORWARD_SLASH
|
||||
|
||||
url = File.dirname(url)
|
||||
url == FORWARD_SLASH ? url : "#{url}/"
|
||||
end
|
||||
|
||||
# Just a slash
|
||||
Benchmark.ips do |x|
|
||||
path = '/'
|
||||
x.report("pre_pr:#{path}") { pre_pr(path) }
|
||||
x.report("pr:#{path}") { pr(path) }
|
||||
x.report("envygeeks:#{path}") { pr(path) }
|
||||
x.compare!
|
||||
end
|
||||
|
||||
# No trailing slash
|
||||
Benchmark.ips do |x|
|
||||
path = '/some/very/very/long/path/to/a/file/i/like'
|
||||
x.report("pre_pr:#{path}") { pre_pr(path) }
|
||||
x.report("pr:#{path}") { pr(path) }
|
||||
x.report("envygeeks:#{path}") { pr(path) }
|
||||
x.compare!
|
||||
end
|
||||
|
||||
# No trailing slash
|
||||
Benchmark.ips do |x|
|
||||
path = '/some/very/very/long/path/to/a/file/i/like/'
|
||||
x.report("pre_pr:#{path}") { pre_pr(path) }
|
||||
x.report("pr:#{path}") { pr(path) }
|
||||
x.report("envygeeks:#{path}") { pr(path) }
|
||||
x.compare!
|
||||
end
|
||||
@@ -1,16 +0,0 @@
|
||||
require 'benchmark/ips'
|
||||
|
||||
enum = (0..50).to_a
|
||||
nested = enum.map { |i| [i] }
|
||||
|
||||
def do_thing(blah)
|
||||
blah * 1
|
||||
end
|
||||
|
||||
Benchmark.ips do |x|
|
||||
x.report('.map.flatten with nested arrays') { nested.map { |i| do_thing(i) }.flatten(1) }
|
||||
x.report('.flat_map with nested arrays') { nested.flat_map { |i| do_thing(i) } }
|
||||
|
||||
x.report('.map.flatten with no nested arrays') { enum.map { |i| do_thing(i) }.flatten(1) }
|
||||
x.report('.flat_map with no nested arrays') { enum.flat_map { |i| do_thing(i) } }
|
||||
end
|
||||
@@ -1,9 +0,0 @@
|
||||
require 'benchmark/ips'
|
||||
|
||||
h = {:bar => 'uco'}
|
||||
|
||||
Benchmark.ips do |x|
|
||||
x.report('fetch with no block') { h.fetch(:bar, (0..9).to_a) }
|
||||
x.report('fetch with a block') { h.fetch(:bar) { (0..9).to_a } }
|
||||
x.report('brackets with an ||') { h[:bar] || (0..9).to_a }
|
||||
end
|
||||
@@ -1,46 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require_relative '../lib/jekyll'
|
||||
require 'benchmark/ips'
|
||||
|
||||
base_directory = Dir.pwd
|
||||
|
||||
Benchmark.ips do |x|
|
||||
#
|
||||
# Does not include the base_directory
|
||||
#
|
||||
x.report('with no questionable path') do
|
||||
Jekyll.sanitized_path(base_directory, '')
|
||||
end
|
||||
x.report('with a single-part questionable path') do
|
||||
Jekyll.sanitized_path(base_directory, 'thingy')
|
||||
end
|
||||
x.report('with a multi-part questionable path') do
|
||||
Jekyll.sanitized_path(base_directory, 'thingy/in/my/soup')
|
||||
end
|
||||
x.report('with a single-part traversal path') do
|
||||
Jekyll.sanitized_path(base_directory, '../thingy')
|
||||
end
|
||||
x.report('with a multi-part traversal path') do
|
||||
Jekyll.sanitized_path(base_directory, '../thingy/in/my/../../soup')
|
||||
end
|
||||
|
||||
#
|
||||
# Including the base_directory
|
||||
#
|
||||
x.report('with the exact same paths') do
|
||||
Jekyll.sanitized_path(base_directory, base_directory)
|
||||
end
|
||||
x.report('with a single-part absolute path including the base_directory') do
|
||||
Jekyll.sanitized_path(base_directory, File.join(base_directory, 'thingy'))
|
||||
end
|
||||
x.report('with a multi-part absolute path including the base_directory') do
|
||||
Jekyll.sanitized_path(base_directory, File.join(base_directory, 'thingy/in/my/soup'))
|
||||
end
|
||||
x.report('with a single-part traversal path including the base_directory') do
|
||||
Jekyll.sanitized_path(base_directory, File.join(base_directory, 'thingy/..'))
|
||||
end
|
||||
x.report('with a multi-part traversal path including the base_directory') do
|
||||
Jekyll.sanitized_path(base_directory, File.join('thingy/in/my/../../soup'))
|
||||
end
|
||||
end
|
||||
@@ -1,14 +0,0 @@
|
||||
require 'benchmark/ips'
|
||||
|
||||
def fast
|
||||
yield
|
||||
end
|
||||
|
||||
def slow(&block)
|
||||
block.call
|
||||
end
|
||||
|
||||
Benchmark.ips do |x|
|
||||
x.report('yield') { fast { (0..9).to_a } }
|
||||
x.report('block.call') { slow { (0..9).to_a } }
|
||||
end
|
||||
@@ -1,51 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
require 'benchmark/ips'
|
||||
|
||||
# For this pull request, which changes Page#dir
|
||||
# https://github.com/jekyll/jekyll/pull/4403
|
||||
|
||||
CONTENT_CONTAINING = <<-HTML.freeze
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="UTF-8">
|
||||
<title>Jemoji</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<link rel="stylesheet" href="/css/screen.css">
|
||||
</head>
|
||||
<body class="wrap">
|
||||
<p><img class="emoji" title=":+1:" alt=":+1:" src="https://assets.github.com/images/icons/emoji/unicode/1f44d.png" height="20" width="20" align="absmiddle"></p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
HTML
|
||||
CONTENT_NOT_CONTAINING = <<-HTML.freeze
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="UTF-8">
|
||||
<title>Jemoji</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<link rel="stylesheet" href="/css/screen.css">
|
||||
</head>
|
||||
<body class="wrap">
|
||||
<p><img class="emoji" title=":+1:" alt=":+1:" src="https://assets.github.com/images/icons/emoji/unicode/1f44d.png" height="20" width="20" align="absmiddle"></p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
HTML
|
||||
|
||||
Benchmark.ips do |x|
|
||||
x.report("no body include?") { CONTENT_NOT_CONTAINING.include?('<body') }
|
||||
x.report("no body regexp") { CONTENT_NOT_CONTAINING =~ /<\s*body/ }
|
||||
x.compare!
|
||||
end
|
||||
|
||||
# No trailing slash
|
||||
Benchmark.ips do |x|
|
||||
x.report("with body include?") { CONTENT_CONTAINING.include?('<body') }
|
||||
x.report("with body regexp") { CONTENT_CONTAINING =~ /<\s*body/ }
|
||||
x.compare!
|
||||
end
|
||||
@@ -1,11 +0,0 @@
|
||||
require 'benchmark/ips'
|
||||
|
||||
Benchmark.ips do |x|
|
||||
x.report('parallel assignment') do
|
||||
a, b = 1, 2
|
||||
end
|
||||
x.report('multi-line assignment') do
|
||||
a = 1
|
||||
b = 2
|
||||
end
|
||||
end
|
||||
@@ -1,8 +0,0 @@
|
||||
require 'benchmark/ips'
|
||||
|
||||
url = "http://jekyllrb.com"
|
||||
|
||||
Benchmark.ips do |x|
|
||||
x.report('+=') { url += '/' }
|
||||
x.report('<<') { url << '/' }
|
||||
end
|
||||
@@ -1,13 +0,0 @@
|
||||
require 'benchmark/ips'
|
||||
|
||||
def str
|
||||
'http://baruco.org/2014/some-talk-with-some-amount-of-value'
|
||||
end
|
||||
|
||||
Benchmark.ips do |x|
|
||||
x.report('#tr') { str.tr('some', 'a') }
|
||||
x.report('#gsub') { str.gsub('some', 'a') }
|
||||
x.report('#gsub!') { str.gsub!('some', 'a') }
|
||||
x.report('#sub') { str.sub('some', 'a') }
|
||||
x.report('#sub!') { str.sub!('some', 'a') }
|
||||
end
|
||||
@@ -1,6 +0,0 @@
|
||||
require 'benchmark/ips'
|
||||
|
||||
Benchmark.ips do |x|
|
||||
x.report('block') { (1..100).map { |i| i.to_s } }
|
||||
x.report('&:to_s') { (1..100).map(&:to_s) }
|
||||
end
|
||||
146
bin/jekyll
Executable file
146
bin/jekyll
Executable file
@@ -0,0 +1,146 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
||||
|
||||
help = <<HELP
|
||||
Jekyll is a blog-aware, static site generator.
|
||||
|
||||
Basic Command Line Usage:
|
||||
jekyll # . -> ./_site
|
||||
jekyll <path to write generated site> # . -> <path>
|
||||
jekyll <path to source> <path to write generated site> # <path> -> <path>
|
||||
|
||||
Options:
|
||||
HELP
|
||||
|
||||
require 'optparse'
|
||||
require 'jekyll'
|
||||
|
||||
options = {}
|
||||
|
||||
opts = OptionParser.new do |opts|
|
||||
opts.banner = help
|
||||
|
||||
opts.on("--auto", "Auto-regenerate") do
|
||||
options[:auto] = true
|
||||
end
|
||||
|
||||
opts.on("--server [PORT]", "Start web server (default port 4000)") do |port|
|
||||
options[:server] = true
|
||||
options[:server_port] = port || 4000
|
||||
end
|
||||
|
||||
opts.on("--lsi", "Use LSI for better related posts") do
|
||||
Jekyll.lsi = true
|
||||
end
|
||||
|
||||
opts.on("--pygments", "Use pygments to highlight code") do
|
||||
Jekyll.pygments = true
|
||||
end
|
||||
|
||||
opts.on("--rdiscount", "Use rdiscount gem for Markdown") do
|
||||
begin
|
||||
require 'rdiscount'
|
||||
Jekyll.markdown_proc = Proc.new { |x| RDiscount.new(x).to_html }
|
||||
puts 'Using rdiscount for Markdown'
|
||||
rescue LoadError
|
||||
puts 'You must have the rdiscount gem installed first'
|
||||
end
|
||||
end
|
||||
|
||||
opts.on("--bluecloth", "Use bluecloth gem for Markdown") do
|
||||
begin
|
||||
require 'bluecloth'
|
||||
Jekyll.markdown_proc = Proc.new { |x| BlueCloth.new(x).to_html }
|
||||
puts 'Using BlueCloth for Markdown'
|
||||
rescue LoadError
|
||||
puts 'You must have the BlueCloth gem installed first'
|
||||
end
|
||||
end
|
||||
|
||||
opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style|
|
||||
Jekyll.permalink_style = (style || 'date').to_sym
|
||||
end
|
||||
|
||||
opts.on("--version", "Display current version") do
|
||||
puts "Jekyll " + Jekyll.version
|
||||
exit 0
|
||||
end
|
||||
end
|
||||
|
||||
opts.parse!
|
||||
|
||||
def clean(dest)
|
||||
FileUtils.rm_rf(dest)
|
||||
FileUtils.mkdir_p(dest)
|
||||
end
|
||||
|
||||
def globs(source)
|
||||
Dir.chdir(source) do
|
||||
dirs = Dir['*'].select { |x| File.directory?(x) }
|
||||
dirs -= ['_site']
|
||||
dirs = dirs.map { |x| "#{x}/**/*" }
|
||||
dirs += ['*']
|
||||
end
|
||||
end
|
||||
|
||||
source = nil
|
||||
destination = nil
|
||||
|
||||
case ARGV.size
|
||||
when 0
|
||||
source = '.'
|
||||
destination = File.join('.', '_site')
|
||||
when 1
|
||||
source = '.'
|
||||
destination = ARGV[0]
|
||||
when 2
|
||||
source = ARGV[0]
|
||||
destination = ARGV[1]
|
||||
else
|
||||
puts "Invalid options. Run `jekyll --help` for assistance."
|
||||
exit(1)
|
||||
end
|
||||
|
||||
if options[:auto]
|
||||
require 'directory_watcher'
|
||||
|
||||
puts "Auto-regenerating enabled: #{source} -> #{destination}"
|
||||
|
||||
dw = DirectoryWatcher.new(source)
|
||||
dw.interval = 1
|
||||
dw.glob = globs(source)
|
||||
|
||||
dw.add_observer do |*args|
|
||||
t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
||||
puts "[#{t}] regeneration: #{args.size} files changed"
|
||||
Jekyll.process(source, destination)
|
||||
end
|
||||
|
||||
dw.start
|
||||
|
||||
unless options[:server]
|
||||
loop { sleep 1000 }
|
||||
end
|
||||
else
|
||||
Jekyll.process(source, destination)
|
||||
puts "Successfully generated site in #{destination}"
|
||||
end
|
||||
|
||||
if options[:server]
|
||||
require 'webrick'
|
||||
include WEBrick
|
||||
|
||||
FileUtils.mkdir_p(destination)
|
||||
|
||||
s = HTTPServer.new(
|
||||
:Port => options[:server_port],
|
||||
:DocumentRoot => destination
|
||||
)
|
||||
t = Thread.new {
|
||||
s.start
|
||||
}
|
||||
|
||||
trap("INT") { s.shutdown }
|
||||
t.join()
|
||||
end
|
||||
@@ -1,25 +0,0 @@
|
||||
# Affinity Team Captains
|
||||
|
||||
**This guide is for affinity team captains.** These special people are **team maintainers** of one of our [affinity teams][] and help triage and evaluate the issues and contributions of others. You may find what is written here interesting, but it’s definitely not for everyone.
|
||||
|
||||
## Affinity teams & their captains
|
||||
|
||||
The Jekyll project uses [affinity teams][] to help break up the work of incoming issues and pull requests from community members. We receive a sizeable number of issues and pull requests each week; the use of affinity teams helps distribute this load across a number of specialized groups instead of pushing it all onto @jekyll/core.
|
||||
|
||||
## Responsibilities of Team Captains
|
||||
|
||||
Each affinity team has a few captains who manage the issues and pull requests for that team. When an issue or PR is opened with a `/cc` for a given affinity team, @jekyllbot automatically assigns a random affinity team captain to the issue to triage it. They have access to add labels, reassign the issue, give LGTM's, and so forth. While they do not merge PR's today, they are still asked to review PR's for parts of the codebase under their purview.
|
||||
|
||||
## How do I become a team captain?
|
||||
|
||||
Just ask! Feel free to open an issue on `jekyll/jekyll` and add `/cc @jekyll/core`. We can add you. :smile:
|
||||
|
||||
Alternatively, you can email or otherwise reach out to [@parkr](https://github.com/parkr) directly if you prefer the more private route.
|
||||
|
||||
## Ugh, I'm tired and don't have time to be a captain anymore. What now?
|
||||
|
||||
No sweat at all! Email [@parkr](https://github.com/parkr) and ask to be removed. Alternatively, you should be able to go to your team's page on GitHub.com (go to https://github.com/jekyll, click "Teams", click the link to your team) and change your status to either "member" or leave the team.
|
||||
|
||||
We realize that being a captain is no easy feat so we want to make it a great experience. As always, communicate as much as you can with us about what is working, and what isn't. Thanks for dedicating some time to Jekyll! :sparkles:
|
||||
|
||||
[affinity teams]: https://teams.jekyllrb.com/
|
||||
@@ -1,27 +0,0 @@
|
||||
# Maintainers: Avoiding Burnout
|
||||
|
||||
**This guide is for maintainers.** These special people have **write access** to one or more of Jekyll's repositories and help merge the contributions of others. You may find what is written here interesting, but it’s definitely not for everyone.
|
||||
|
||||
# 1. Use Jekyll
|
||||
|
||||
Maintainers of Jekyll should be using it regularly. This is partly because you won't be a good maintainer unless you can put yourself in the shoes of our users but also because you may decide to stop using Jekyll and at that point you should also decide not to be a maintainer and find other things to work on.
|
||||
|
||||
# 2. No Guilt About Leaving
|
||||
|
||||
All maintainers can stop working on Jekyll at any time without any guilt or explanation (like a job). We may still ask for your help with questions after you leave but you are under no obligation to answer them. Like a job, if you create a big mess and then leave you still have no obligations but we may think less of you (or, realistically, probably just revert the problematic work). Like a job, you should probably take a break from Jekyll at least a few times a year.
|
||||
|
||||
This also means contributors should be consumers. If a maintainer finds they are not using a project in the real-world, they should reconsider their involvement with the project.
|
||||
|
||||
# 3. Prioritise Maintainers Over Users
|
||||
|
||||
It's important to be user-focused but ultimately, as long as you follow #1 above, Jekyll's minimum number of users will be the number of maintainers. However, if Jekyll has no maintainers it will quickly become useless to all users and the project will die. As a result, no user complaint, behaviour or need takes priority over the burnout of maintainers. If users do not like the direction of the project, the easiest way to influence it is to make significant, high-quality code contributions and become a maintainer.
|
||||
|
||||
# 4. Learn To Say No
|
||||
|
||||
Jekyll gets a lot of feature requests, non-reproducible bug reports, usage questions and PRs we won't accept. These should be closed out as soon as we realise that they aren't going to be resolved or merged. This is kinder than deciding this after a long period of review. Our issue tracker should reflect work to be done.
|
||||
|
||||
---
|
||||
|
||||
Thanks to https://gist.github.com/ryanflorence/124070e7c4b3839d4573 which influenced this document.
|
||||
|
||||
Thanks to [Homebrew's "Avoiding Burnout" document](https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Maintainers-Avoiding-Burnout.md) for providing a perfect base for this document.
|
||||
@@ -1,35 +0,0 @@
|
||||
# Contributors: Becoming a Maintainer
|
||||
|
||||
**This guide is for contributors.** These special people have contributed to one or more of Jekyll's repositories, but do not yet have write access to any. You may find what is written here interesting, but it’s definitely not for everyone.
|
||||
|
||||
So you want to become a maintainer of a Jekyll project? We'd love to have you! Here are some things we like to see from community members before we promote them to maintainers.
|
||||
|
||||
## 1. Use Jekyll
|
||||
|
||||
You want to maintain Jekyll? Use it often. Do weird things with it. Do normal things with it. Does it work? Does it have any weaknesses? Is there a gap in the product that you think should be filled?
|
||||
|
||||
## 2. Help Triage Issues
|
||||
|
||||
Watch the repository you're interested in. Join [an Affinity Team](https://teams.jekyllrb.com) and receive mentions regarding a particular interest area of the project. When you receive a notification for an issue that has not been triaged by a maintainer, dive in. Can you reproduce the issue? Can you determine the fix? [More tips on Triaging an Issue in our maintainer guide](triaging-an-issue.md). Every maintainer loves an issue that is resolved before they get to it. :smiley:
|
||||
|
||||
## 3. Write Documentation
|
||||
|
||||
Good documentation means less confusion for our users and fewer issues to triage. Documentation is always in need of fixes and updates as we change the code. Read through the documentation during your normal usage of the product and submit changes as you feel they are necessary.
|
||||
|
||||
## 4. Write Code
|
||||
|
||||
As a maintainer, you will be reviewing pull requests which update code. You should feel comfortable with the Jekyll codebase enough to confidently review any pull request put forward. In order to become more comfortable, write some code of your own and send a pull request. A great place to start is with any issue labeled "bug" in the issue tracker. Write a test which replicates the problem and fails, then work on fixing the code such that the test passes.
|
||||
|
||||
## 5. Review Pull Requests
|
||||
|
||||
Start by reviewing one pull request a week. Leave detailed comments and [follow our guide for reviewing pull requests](reviewing-a-pull-request.md).
|
||||
|
||||
## 6. Ask!
|
||||
|
||||
Open an issue describing your contributions to the project and why you wish to be a maintainer. Issues are nice because you can easily reference where you have demonstrated that you help triage issues, write code & documentation, and review pull requests. You may also email any maintainer privately if you do not feel comfortable asking in the open.
|
||||
|
||||
We would love to expand the team and look forward to many more community members becoming maintainers!
|
||||
|
||||
# Helping Out Elsewhere
|
||||
|
||||
In addition to maintainers of our core and plugin code, the Jekyll team is comprised of moderators for our forums. These helpful community members take a look at the topics posted to https://help.jekyllrb.com and ensure they are properly categorized and are acceptable under our Code of Conduct. If you would like to be a moderator, email one of the maintainers with links to where you have answered questions and a request to be added as a moderator. More help is always welcome.
|
||||
@@ -1,50 +0,0 @@
|
||||
# Maintainers: Merging a Pull Request
|
||||
|
||||
**This guide is for maintainers.** These special people have **write access** to one or more of Jekyll's repositories and help merge the contributions of others. You may find what is written here interesting, but it’s definitely not for everyone.
|
||||
|
||||
## Code Review
|
||||
|
||||
All pull requests should be subject to code review. Code review is a [foundational value](https://blog.fullstory.com/what-we-learned-from-google-code-reviews-arent-just-for-catching-bugs-b125a13aa292) of good engineering teams. Besides providing validation of correctness, it promotes a sense of community and gives other maintainers understanding of all parts of the code base. In short, code review is crucial to a healthy open source project.
|
||||
|
||||
**Read our guide for [Reviewing a pull request](reviewing-a-pull-request.md) before merging.** Notably, the change must have tests if for code, and at least two maintainers must give it an OK.
|
||||
|
||||
## Merging
|
||||
|
||||
We have [a helpful little bot](https://github.com/jekyllbot) which we use to merge pull requests. We don't use the GitHub.com interface for two reasons:
|
||||
|
||||
1. You can't modify anything on mobile (e.g. titles, labels)
|
||||
2. Provide a consistent paper trail in the `History.markdown` file for each release
|
||||
|
||||
To merge a pull request, leave a comment thanking the contributor, then add the special merge request:
|
||||
|
||||
```text
|
||||
Thank you very much for your contribution. Folks like you make this project and community strong. :heart:
|
||||
|
||||
@jekyllbot: merge +dev
|
||||
```
|
||||
|
||||
The merge request is made up of three things:
|
||||
|
||||
1. `@jekyllbot:` – this is the prefix our bot looks for when processing commands
|
||||
2. `merge` – the command
|
||||
3. `+dev` – the category to which the changes belong
|
||||
|
||||
The categories match the H3's in the history/changelog file, and they are:
|
||||
|
||||
1. Major Enhancements (`+major`) – major updates or breaking changes to the code which necessitate a major version bump (v3 ~> v4)
|
||||
2. Minor Enhancements (`+minor`) – minor updates (feature, enhancement) which necessitate a minor version bump (v3.1 ~> v3.2)
|
||||
3. Bug Fixes (`+bug`) – corrections to code which do not change or add functionality, which necessitate a patch version bump (v3.1.0 ~> v3.1.1)
|
||||
4. Site Enhancements (`+site`) – changes to the source of https://jekyllrb.com, found in `site/`
|
||||
5. Development Fixes (`+dev`) – changes which do not affect user-facing functionality or documentation, such as test fixes or bumping internal dependencies
|
||||
|
||||
Once @jekyllbot has merged the pull request, you should see three things:
|
||||
|
||||
1. A successful merge
|
||||
2. Addition of labels for the necessary category if they aren't already applied
|
||||
3. A commit to the `History.markdown` file which adds a note about the change
|
||||
|
||||
If you forget the category, that's just fine. You can always go back and move the line to the proper category header later. The category is always necessary for `jekyll/jekyll`, but many plugins have too few changes to necessitate changelog categories.
|
||||
|
||||
## Rejoice
|
||||
|
||||
You did it! Thanks for being a maintainer for one of our official Jekyll projects. Your work means the world to our thousands of users who rely on Jekyll daily. :heart:
|
||||
@@ -1,13 +0,0 @@
|
||||
# Maintaining Jekyll
|
||||
|
||||
Hello! This is where we document various processes for maintaining Jekyll. Being a maintainer for any Jekyll project is a big responsibility, so we put together some helpful documentation for various tasks you might do as a maintainer.
|
||||
|
||||
1. [Triaging and issue](triaging-an-issue.md)
|
||||
2. [Reviewing a pull request](reviewing-a-pull-request.md)
|
||||
3. [Merging a pull request](merging-a-pull-request.md)
|
||||
4. [Avoiding burnout](avoiding-burnout.md)
|
||||
5. [Special Labels](special-labels.md)
|
||||
|
||||
Interested in becoming a maintainer? Here is some documentation for **contributors**:
|
||||
|
||||
1. [Becoming a maintainer](becoming-a-maintainer.md)
|
||||
@@ -1,44 +0,0 @@
|
||||
# Maintainers: Reviewing a Pull Request
|
||||
|
||||
**This guide is for maintainers.** These special people have **write access** to one or more of Jekyll's repositories and help merge the contributions of others. You may find what is written here interesting, but it’s definitely not for everyone.
|
||||
|
||||
## Respond Kindly
|
||||
|
||||
Above all else, please review a pull request kindly. Our community can only be strong if we make it a welcoming and inclusive environment. To further promote this, the Jekyll community is governed by a [Code of Conduct](../CONDUCT.markdown) by which all community members must abide.
|
||||
|
||||
Use emoji liberally :heart: :tada: :sparkles: :confetti_ball: and feel free to be emotive!! Contributions keep this project moving forward and we're always happy to receive them, even if the pull request isn't ultimately merged.
|
||||
|
||||
Mike McQuaid's post on the GitHub blog entitled ["Kindly Closing Pull Requests"](https://github.com/blog/2124-kindly-closing-pull-requests) is a great place to start. It describes various scenarios in which it would be acceptable to close a pull request for reasons other than lack of technical integrity or accuracy. Part of being kind is responding to and resolving pull requests quickly.
|
||||
|
||||
## Respond Quickly
|
||||
|
||||
We should be able to review all pull requests within one week. The only time initial review should take longer is if all the maintainers mysteriously took vacation during the same week. Promptness encourages frequent, high-quality contributions from community members and other maintainers.
|
||||
|
||||
If your response requires a response on the part of the author, please add the `pending-feedback` tag. @jekyllbot will automatically remove the tag once the author of the pull request responds.
|
||||
|
||||
## Resolve Quickly
|
||||
|
||||
Similarly, we should aim to resolve pull requests quickly. If a pull request introduces a feature which does not fit into the core purpose or goal of the project, close it promptly with a kind explanation of why it is not acceptable.
|
||||
|
||||
Leave detailed comments wherever possible. Provide the contributor with context around why the change you are requesting is necessary, or why the question you are asking is important to resolve. The more context we can clearly communicate to the contributor, the better able the contributor is to provide high-quality patches.
|
||||
|
||||
You may close a pull request if more than 30 days pass without a response from the author.
|
||||
|
||||
In some cases, review will involve many weeks of back-and-forth. As long as communication continues, this is fine. Ideally, any PR would be capable of resolution within 30 days of it being opened.
|
||||
|
||||
## Look for Tests
|
||||
|
||||
If this is a code change, are there tests for the updated or added behaviour? Shipping a version with bugs is inevitable, but ensuring changes are tested helps keep bugs and regressions to a minimum.
|
||||
|
||||
## CI Must Pass
|
||||
|
||||
It is fine to ask a contributor to investigate failures on Travis and patch them up before you begin your review. It is helpful to leave a message for the contributor indicating that the tests have failed and that no review will occur before the tests pass. If they ask for help, take a look and assist if you can.
|
||||
|
||||
## Rule of Two
|
||||
|
||||
A pull request may be merged once two maintainers have reviewed the pull request and indicated that it is acceptable to them. There is no need to wait for a third unless one of the two reviewers wishes for another set of eyes.
|
||||
|
||||
## Think Security
|
||||
|
||||
We owe it to our users to ensure that using a theme from the community or building someone else's site doesn't come with built-in security vulnerabilities. Things like where files may be read from and written to are important to keep secure. Jekyll is also the basis for hosted services such as [GitHub Pages](https://pages.github.com), which cannot upgrade when security issues are introduced.
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
# Maintainers: Special Labels
|
||||
|
||||
**This guide is for maintainers.** These special people have **write access** to one or more of Jekyll's repositories and help merge the contributions of others. You may find what is written here interesting, but it’s definitely not for everyone.
|
||||
|
||||
We use a series of "special labels" on GitHub.com to automate handling of some parts of the pull request and issue process. @jekyllbot may automatically apply or remove certain labels based on actions taken by users or maintainers. Below are the labels and how they work:
|
||||
|
||||
## `pending-feedback`
|
||||
|
||||
This label is used to indicate that we need more information from the issue/PR author in order to continue. It may be that you need more info before you can properly triage a bug report, or that you have some unanswered questions about a PR that need to be resolved before moving forward. You can safely ignore any issue with this label, as it is waiting for feedback.
|
||||
|
||||
## `needs-work` & `pending-rebase`
|
||||
|
||||
These labels are used to indicate that the Git state of a pull request must change. Both are removed once a push is registered (a "synchronize" event for the pull request) and the pull request becomes mergable. Add `needs-work` to a PR if, after your review, it requires code changes. Add `pending-rebase` to a PR if the code is fine but the branch is not automatically mergable with the target branch (e.g. `master`).
|
||||
|
||||
## `stale`
|
||||
|
||||
This label is automatically added and removed by @jekyllbot based on activity on an issue or pull request. The rules for this label are laid out in [Triaging an Issue: Staleness and automatic closure](triaging-an-issue.md#staleness-and-automatic-closure).
|
||||
@@ -1,51 +0,0 @@
|
||||
# Maintainers: Triaging an Issue
|
||||
|
||||
**This guide is for maintainers.** These special people have **write access** to one or more of Jekyll's repositories and help merge the contributions of others. You may find what is written here interesting, but it’s definitely not for everyone.
|
||||
|
||||
Before evaluating an issue, it is important to identify if it is a feature
|
||||
request or a bug. For the Jekyll project the following definitions are used
|
||||
to identify a feature or a bug:
|
||||
|
||||
**Feature** - A feature is defined as a request that adds functionality to
|
||||
Jekyll outside of its current capabilities.
|
||||
**Bug** - A bug is defined as an issue that identifies an error that a user
|
||||
(or users) encounter when using current Jekyll functionalities.
|
||||
|
||||
## Feature?
|
||||
|
||||
If the issue describes a feature request, ask:
|
||||
|
||||
1. Is this a setting? [Settings are a crutch](http://ben.balter.com/2016/03/08/optimizing-for-power-users-and-edge-cases/#settings-are-a-crutch) for doing "the right thing". Settings usually point to a bad default or an edge case that could be solved easily with a plugin. Keep the :christmas_tree: of settings as small as possible so as not to reduce the usability of the product. We like the philosophy "decisions not options."
|
||||
2. Would at least 80% of users find it useful? If even a quarter of our users won't use it, it's very likely that the request doesn't fit our product's core goal.
|
||||
3. Is there another way to accomplish the end goal of the request? Most feature requests are due to bad documentation for or understanding of a pre-existing feature. See if you can clarify the end goal of the request. What is the user trying to do? Could they accomplish that goal through another feature we already support?
|
||||
4. Even if 80% of our users will use it, does it fit the core goal of our project? We are writing a tool for making static websites, not a swiss army knife for publishing more generally.
|
||||
|
||||
Feel free to get others' opinions and ask questions of the issue author, but depending upon the answers to the questions above, it may be out of scope for our project.
|
||||
|
||||
If the request is within scope, prioritize it on the product roadmap with the other maintainers. Apply the appropriate tags and ensure the right people have weighed in to define the feature's scope and implementation. If you want to be the _best ever_, submit a PR yourself which adds the feature.
|
||||
|
||||
## Bug?
|
||||
|
||||
### Reproducibility
|
||||
|
||||
If the bug has clear reproduction steps, take a minute to try them. If it helps, write a test in our test suite for the scenario which replicates the problem. Can you reliably replicate the issue?
|
||||
|
||||
If you can't replicate the issue, post your replication steps which didn't work and ask for clarification from the issue author.
|
||||
|
||||
### Supported Platform
|
||||
|
||||
Is the author using a supported platform? We support the latest versions of macOS, Ubuntu, Debian, CentOS, Fedora, and Arch Linux.
|
||||
|
||||
You may close the issue immediately if the author cannot reproduce the issue on a supported platform. For Windows-related problems, leave a comment letting the user know that Windows is not officially supported, but that they may absolutely continue using the issue to communicate with folks from `@jekyll/windows` to further investigate. Additionally, you can point them to Jekyll Talk (https://talk.jekyllrb.com) as a means of getting support from the community.
|
||||
|
||||
If the user is experiencing issues with GitHub Pages or another hosted platform that we cannot reproduce, please direct them to the platform's support channel and close the issue.
|
||||
|
||||
### What they wanted vs. what they got
|
||||
|
||||
An issue without a clear explanation of what the user got and what they were expecting to get is not an issue we can accurately respond to. If the user doesn't provide this information, please ask for clarification and apply the `pending-feedback` label. This information helps us build test cases such that we do not break the behaviour again in the future. The `pending-feedback` label will be removed automatically once the issue author posts a reply.
|
||||
|
||||
Is what they wanted to get something we want to happen? Sometimes a bug report is actually masquerading as a feature request. See the guidance above for handling feature requests.
|
||||
|
||||
### Staleness and automatic closure
|
||||
|
||||
@jekyllbot will automatically mark issues as `stale` if no activity occurs for at least one month. @jekyllbot leaves a comment asking for information about reproducibility in current versions. If no one responds after another month, the issue is automatically closed.
|
||||
55
exe/jekyll
55
exe/jekyll
@@ -1,55 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
STDOUT.sync = true
|
||||
|
||||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
||||
|
||||
require "jekyll"
|
||||
require "mercenary"
|
||||
|
||||
Jekyll::PluginManager.require_from_bundler
|
||||
|
||||
Jekyll::Deprecator.process(ARGV)
|
||||
|
||||
Mercenary.program(:jekyll) do |p|
|
||||
p.version Jekyll::VERSION
|
||||
p.description "Jekyll is a blog-aware, static site generator in Ruby"
|
||||
p.syntax "jekyll <subcommand> [options]"
|
||||
|
||||
p.option "source", "-s", "--source [DIR]", "Source directory (defaults to ./)"
|
||||
p.option "destination", "-d", "--destination [DIR]",
|
||||
"Destination directory (defaults to ./_site)"
|
||||
p.option "safe", "--safe", "Safe mode (defaults to false)"
|
||||
p.option "plugins_dir", "-p", "--plugins PLUGINS_DIR1[,PLUGINS_DIR2[,...]]", Array,
|
||||
"Plugins directory (defaults to ./_plugins)"
|
||||
p.option "layouts_dir", "--layouts DIR", String,
|
||||
"Layouts directory (defaults to ./_layouts)"
|
||||
p.option "profile", "--profile", "Generate a Liquid rendering profile"
|
||||
|
||||
Jekyll::External.require_if_present(Jekyll::External.blessed_gems) do |g|
|
||||
cmd = g.split("-").last
|
||||
p.command(cmd.to_sym) do |c|
|
||||
c.syntax cmd
|
||||
c.action do
|
||||
Jekyll.logger.abort_with "You must install the '#{g}' gem" \
|
||||
" to use the 'jekyll #{cmd}' command."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Jekyll::Command.subclasses.each { |c| c.init_with_program(p) }
|
||||
|
||||
p.action do |args, _|
|
||||
if args.empty?
|
||||
Jekyll.logger.error "A subcommand is required."
|
||||
puts p
|
||||
abort
|
||||
else
|
||||
subcommand = args.first
|
||||
unless p.has_command? subcommand
|
||||
Jekyll.logger.abort_with "fatal: 'jekyll #{args.first}' could not" \
|
||||
" be found. You may need to install the jekyll-#{args.first} gem" \
|
||||
" or a related gem to be able to use this subcommand."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,174 +0,0 @@
|
||||
Feature: Collections
|
||||
As a hacker who likes to structure content
|
||||
I want to be able to create collections of similar information
|
||||
And render them
|
||||
|
||||
Scenario: Unrendered collection
|
||||
Given I have an "index.html" page that contains "Collections: {{ site.methods }}"
|
||||
And I have fixture collections
|
||||
And I have a configuration file with "collections" set to "['methods']"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And the "_site/methods/configuration.html" file should not exist
|
||||
|
||||
Scenario: Rendered collection
|
||||
Given I have an "index.html" page that contains "Collections: output => {{ site.collections[0].output }} label => {{ site.collections[0].label }}"
|
||||
And I have an "collection_metadata.html" page that contains "Methods metadata: {{ site.collections[0].foo }} {{ site.collections[0] }}"
|
||||
And I have fixture collections
|
||||
And I have a "_config.yml" file with content:
|
||||
"""
|
||||
collections:
|
||||
methods:
|
||||
output: true
|
||||
foo: bar
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Collections: output => true" in "_site/index.html"
|
||||
And I should see "label => methods" in "_site/index.html"
|
||||
And I should see "Methods metadata: bar" in "_site/collection_metadata.html"
|
||||
And I should see "<p>Whatever: foo.bar</p>" in "_site/methods/configuration.html"
|
||||
|
||||
Scenario: Rendered collection at a custom URL
|
||||
Given I have an "index.html" page that contains "Collections: {{ site.collections }}"
|
||||
And I have fixture collections
|
||||
And I have a "_config.yml" file with content:
|
||||
"""
|
||||
collections:
|
||||
methods:
|
||||
output: true
|
||||
permalink: /:collection/:path/
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "<p>Whatever: foo.bar</p>" in "_site/methods/configuration/index.html"
|
||||
|
||||
Scenario: Rendered document in a layout
|
||||
Given I have an "index.html" page that contains "Collections: output => {{ site.collections[0].output }} label => {{ site.collections[0].label }} foo => {{ site.collections[0].foo }}"
|
||||
And I have a default layout that contains "<div class='title'>Tom Preston-Werner</div> {{content}}"
|
||||
And I have fixture collections
|
||||
And I have a "_config.yml" file with content:
|
||||
"""
|
||||
collections:
|
||||
methods:
|
||||
output: true
|
||||
foo: bar
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Collections: output => true" in "_site/index.html"
|
||||
And I should see "label => methods" in "_site/index.html"
|
||||
And I should see "foo => bar" in "_site/index.html"
|
||||
And I should see "<p>Run your generators! default</p>" in "_site/methods/site/generate.html"
|
||||
And I should see "<div class='title'>Tom Preston-Werner</div>" in "_site/methods/site/generate.html"
|
||||
|
||||
Scenario: Collections specified as an array
|
||||
Given I have an "index.html" page that contains "Collections: {% for method in site.methods %}{{ method.relative_path }} {% endfor %}"
|
||||
And I have fixture collections
|
||||
And I have a "_config.yml" file with content:
|
||||
"""
|
||||
collections:
|
||||
- methods
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
Then the _site directory should exist
|
||||
And I should see "Collections: _methods/collection/entries _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html"
|
||||
|
||||
Scenario: Collections specified as an hash
|
||||
Given I have an "index.html" page that contains "Collections: {% for method in site.methods %}{{ method.relative_path }} {% endfor %}"
|
||||
And I have fixture collections
|
||||
And I have a "_config.yml" file with content:
|
||||
"""
|
||||
collections:
|
||||
- methods
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
Then the _site directory should exist
|
||||
And I should see "Collections: _methods/collection/entries _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html"
|
||||
|
||||
Scenario: All the documents
|
||||
Given I have an "index.html" page that contains "All documents: {% for doc in site.documents %}{{ doc.relative_path }} {% endfor %}"
|
||||
And I have fixture collections
|
||||
And I have a "_config.yml" file with content:
|
||||
"""
|
||||
collections:
|
||||
- methods
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
Then the _site directory should exist
|
||||
And I should see "All documents: _methods/collection/entries _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html"
|
||||
|
||||
Scenario: Documents have an output attribute, which is the converted HTML
|
||||
Given I have an "index.html" page that contains "Second document's output: {{ site.documents[1].output }}"
|
||||
And I have fixture collections
|
||||
And I have a "_config.yml" file with content:
|
||||
"""
|
||||
collections:
|
||||
- methods
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
Then the _site directory should exist
|
||||
And I should see "Second document's output: <p>Use <code class=\"highlighter-rouge\">Jekyll.configuration</code> to build a full configuration for use w/Jekyll.</p>\n\n<p>Whatever: foo.bar</p>" in "_site/index.html"
|
||||
|
||||
Scenario: Filter documents by where
|
||||
Given I have an "index.html" page that contains "{% assign items = site.methods | where: 'whatever','foo.bar' %}Item count: {{ items.size }}"
|
||||
And I have fixture collections
|
||||
And I have a "_config.yml" file with content:
|
||||
"""
|
||||
collections:
|
||||
- methods
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Item count: 2" in "_site/index.html"
|
||||
|
||||
Scenario: Sort by title
|
||||
Given I have an "index.html" page that contains "{% assign items = site.methods | sort: 'title' %}2. of {{ items.size }}: {{ items[1].output }}"
|
||||
And I have fixture collections
|
||||
And I have a "_config.yml" file with content:
|
||||
"""
|
||||
collections:
|
||||
- methods
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "2. of 8: <p>Page without title.</p>" in "_site/index.html"
|
||||
|
||||
Scenario: Sort by relative_path
|
||||
Given I have an "index.html" page that contains "Collections: {% assign methods = site.methods | sort: 'relative_path' %}{{ methods | map:"title" | join: ", " }}"
|
||||
And I have fixture collections
|
||||
And I have a "_config.yml" file with content:
|
||||
"""
|
||||
collections:
|
||||
- methods
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
Then the _site directory should exist
|
||||
And I should see "Collections: Collection#entries, Jekyll.configuration, Jekyll.escape, Jekyll.sanitized_path, Site#generate, Initialize, Site#generate," in "_site/index.html"
|
||||
|
||||
Scenario: Rendered collection with date/dateless filename
|
||||
Given I have an "index.html" page that contains "Collections: {% for method in site.thanksgiving %}{{ method.title }} {% endfor %}"
|
||||
And I have fixture collections
|
||||
And I have a "_config.yml" file with content:
|
||||
"""
|
||||
collections:
|
||||
thanksgiving:
|
||||
output: true
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Thanksgiving Black Friday" in "_site/index.html"
|
||||
And I should see "Happy Thanksgiving" in "_site/thanksgiving/2015-11-26-thanksgiving.html"
|
||||
And I should see "Black Friday" in "_site/thanksgiving/black-friday.html"
|
||||
@@ -1,205 +0,0 @@
|
||||
Feature: Create sites
|
||||
As a hacker who likes to blog
|
||||
I want to be able to make a static site
|
||||
In order to share my awesome ideas with the interwebs
|
||||
|
||||
Scenario: Blank site
|
||||
Given I do not have a "test_blank" directory
|
||||
When I run jekyll new test_blank --blank
|
||||
Then the test_blank/_layouts directory should exist
|
||||
And the test_blank/_posts directory should exist
|
||||
And the "test_blank/index.html" file should exist
|
||||
|
||||
Scenario: Basic site
|
||||
Given I have an "index.html" file that contains "Basic Site"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Basic Site" in "_site/index.html"
|
||||
|
||||
Scenario: Basic site with a post
|
||||
Given I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | date | content |
|
||||
| Hackers | 2009-03-27 | My First Exploit |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "My First Exploit" in "_site/2009/03/27/hackers.html"
|
||||
|
||||
Scenario: Basic site with layout and a page
|
||||
Given I have a _layouts directory
|
||||
And I have an "index.html" page with layout "default" that contains "Basic Site with Layout"
|
||||
And I have a default layout that contains "Page Layout: {{ content }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Page Layout: Basic Site with Layout" in "_site/index.html"
|
||||
|
||||
Scenario: Basic site with layout and a post
|
||||
Given I have a _layouts directory
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| Wargames | 2009-03-27 | default | The only winning move is not to play. |
|
||||
And I have a default layout that contains "Post Layout: {{ content }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post Layout: <p>The only winning move is not to play.</p>" in "_site/2009/03/27/wargames.html"
|
||||
|
||||
Scenario: Basic site with layout inside a subfolder and a post
|
||||
Given I have a _layouts directory
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| Wargames | 2009-03-27 | post/simple | The only winning move is not to play. |
|
||||
And I have a post/simple layout that contains "Post Layout: {{ content }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post Layout: <p>The only winning move is not to play.</p>" in "_site/2009/03/27/wargames.html"
|
||||
|
||||
Scenario: Basic site with layouts, pages, posts and files
|
||||
Given I have a _layouts directory
|
||||
And I have a page layout that contains "Page {{ page.title }}: {{ content }}"
|
||||
And I have a post layout that contains "Post {{ page.title }}: {{ content }}"
|
||||
And I have an "index.html" page with layout "page" that contains "Site contains {{ site.pages.size }} pages and {{ site.posts.size }} posts"
|
||||
And I have a blog directory
|
||||
And I have a "blog/index.html" page with layout "page" that contains "blog category index page"
|
||||
And I have an "about.html" file that contains "No replacement {{ site.posts.size }}"
|
||||
And I have an "another_file" file that contains ""
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| entry1 | 2009-03-27 | post | content for entry1. |
|
||||
| entry2 | 2009-04-27 | post | content for entry2. |
|
||||
And I have a category/_posts directory
|
||||
And I have the following posts in "category":
|
||||
| title | date | layout | content |
|
||||
| entry3 | 2009-05-27 | post | content for entry3. |
|
||||
| entry4 | 2009-06-27 | post | content for entry4. |
|
||||
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 "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 "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"
|
||||
And I should see "Post entry4: <p>content for entry4.</p>" in "_site/category/2009/06/27/entry4.html"
|
||||
|
||||
Scenario: Basic site with include tag
|
||||
Given I have a _includes directory
|
||||
And I have an "index.html" page that contains "Basic Site with include tag: {% include about.textile %}"
|
||||
And I have an "_includes/about.textile" file that contains "Generated by Jekyll"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Basic Site with include tag: Generated by Jekyll" in "_site/index.html"
|
||||
|
||||
Scenario: Basic site with subdir include tag
|
||||
Given I have a _includes directory
|
||||
And I have an "_includes/about.textile" file that contains "Generated by Jekyll"
|
||||
And I have an info directory
|
||||
And I have an "info/index.html" page that contains "Basic Site with subdir include tag: {% include about.textile %}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Basic Site with subdir include tag: Generated by Jekyll" in "_site/info/index.html"
|
||||
|
||||
Scenario: Basic site with nested include tag
|
||||
Given I have a _includes directory
|
||||
And I have an "_includes/about.textile" file that contains "Generated by {% include jekyll.textile %}"
|
||||
And I have an "_includes/jekyll.textile" file that contains "Jekyll"
|
||||
And I have an "index.html" page that contains "Basic Site with include tag: {% include about.textile %}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Basic Site with include tag: Generated by Jekyll" in "_site/index.html"
|
||||
|
||||
Scenario: Basic site with internal post linking
|
||||
Given I have an "index.html" page that contains "URL: {% post_url 2008-01-01-entry2 %}"
|
||||
And I have a configuration file with "permalink" set to "pretty"
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| entry1 | 2007-12-31 | post | content for entry1. |
|
||||
| entry2 | 2008-01-01 | post | content for entry2. |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "URL: /2008/01/01/entry2/" in "_site/index.html"
|
||||
|
||||
Scenario: Basic site with whitelisted dotfile
|
||||
Given I have an ".htaccess" file that contains "SomeDirective"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "SomeDirective" in "_site/.htaccess"
|
||||
|
||||
Scenario: File was replaced by a directory
|
||||
Given I have a "test" file that contains "some stuff"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
When I delete the file "test"
|
||||
Given I have a test directory
|
||||
And I have a "test/index.html" file that contains "some other stuff"
|
||||
When I run jekyll build
|
||||
Then the _site/test directory should exist
|
||||
And I should see "some other stuff" in "_site/test/index.html"
|
||||
|
||||
Scenario: Basic site with unpublished page
|
||||
Given I have an "index.html" page with title "index" that contains "Published page"
|
||||
And I have a "public.html" page with published "true" that contains "Explicitly published page"
|
||||
And I have a "secret.html" page with published "false" that contains "Unpublished page"
|
||||
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And the "_site/index.html" file should exist
|
||||
And the "_site/public.html" file should exist
|
||||
But the "_site/secret.html" file should not exist
|
||||
|
||||
When I run jekyll build --unpublished
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And the "_site/index.html" file should exist
|
||||
And the "_site/public.html" file should exist
|
||||
And the "_site/secret.html" file should exist
|
||||
|
||||
Scenario: Basic site with page with future date
|
||||
Given I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | content |
|
||||
| entry1 | 2020-12-31 | post | content for entry1. |
|
||||
| entry2 | 2007-12-31 | post | content for entry2. |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "content for entry2" in "_site/2007/12/31/entry2.html"
|
||||
And the "_site/2020/12/31/entry1.html" file should not exist
|
||||
When I run jekyll build --future
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And the "_site/2020/12/31/entry1.html" file should exist
|
||||
|
||||
Scenario: Basic site with layouts, posts and related posts
|
||||
Given I have a _layouts directory
|
||||
And I have a page layout that contains "Page {{ page.title }}: {{ content }}"
|
||||
And I have a post layout that contains "Post {{ page.title }}: {{ content }}Related posts: {{ site.related_posts | size }}"
|
||||
And I have an "index.html" page with layout "page" that contains "Site contains {{ site.pages.size }} pages and {{ site.posts.size }} posts; Related posts: {{ site.related_posts | size }}"
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| entry1 | 2009-03-27 | post | content for entry1. |
|
||||
| entry2 | 2009-04-27 | post | content for entry2. |
|
||||
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 "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"
|
||||
@@ -1,119 +0,0 @@
|
||||
Feature: Data
|
||||
In order to use well-formatted data in my blog
|
||||
As a blog's user
|
||||
I want to use _data directory in my site
|
||||
|
||||
Scenario: autoload *.yaml files in _data directory
|
||||
Given I have a _data directory
|
||||
And I have a "_data/products.yaml" file with content:
|
||||
"""
|
||||
- name: sugar
|
||||
price: 5.3
|
||||
- name: salt
|
||||
price: 2.5
|
||||
"""
|
||||
And I have an "index.html" page that contains "{% for product in site.data.products %}{{product.name}}{% endfor %}"
|
||||
When I run jekyll build
|
||||
Then the "_site/index.html" file should exist
|
||||
And I should see "sugar" in "_site/index.html"
|
||||
And I should see "salt" in "_site/index.html"
|
||||
|
||||
Scenario: autoload *.yml files in _data directory
|
||||
Given I have a _data directory
|
||||
And I have a "_data/members.yml" file with content:
|
||||
"""
|
||||
- name: Jack
|
||||
age: 28
|
||||
- name: Leon
|
||||
age: 34
|
||||
"""
|
||||
And I have an "index.html" page that contains "{% for member in site.data.members %}{{member.name}}{% endfor %}"
|
||||
When I run jekyll build
|
||||
Then the "_site/index.html" file should exist
|
||||
And I should see "Jack" in "_site/index.html"
|
||||
And I should see "Leon" in "_site/index.html"
|
||||
|
||||
Scenario: autoload *.json files in _data directory
|
||||
Given I have a _data directory
|
||||
And I have a "_data/members.json" file with content:
|
||||
"""
|
||||
[{"name": "Jack", "age": 28},{"name": "Leon", "age": 34}]
|
||||
"""
|
||||
And I have an "index.html" page that contains "{% for member in site.data.members %}{{member.name}}{% endfor %}"
|
||||
When I run jekyll build
|
||||
Then the "_site/index.html" file should exist
|
||||
And I should see "Jack" in "_site/index.html"
|
||||
And I should see "Leon" in "_site/index.html"
|
||||
|
||||
Scenario: autoload *.csv files in _data directory
|
||||
Given I have a _data directory
|
||||
And I have a "_data/members.csv" file with content:
|
||||
"""
|
||||
name,age
|
||||
Jack,28
|
||||
Leon,34
|
||||
"""
|
||||
And I have an "index.html" page that contains "{% for member in site.data.members %}{{member.name}}{% endfor %}"
|
||||
When I run jekyll build
|
||||
Then the "_site/index.html" file should exist
|
||||
And I should see "Jack" in "_site/index.html"
|
||||
And I should see "Leon" in "_site/index.html"
|
||||
|
||||
Scenario: autoload *.yml files in _data directory with space in file name
|
||||
Given I have a _data directory
|
||||
And I have a "_data/team members.yml" file with content:
|
||||
"""
|
||||
- name: Jack
|
||||
age: 28
|
||||
- name: Leon
|
||||
age: 34
|
||||
"""
|
||||
And I have an "index.html" page that contains "{% for member in site.data.team_members %}{{member.name}}{% endfor %}"
|
||||
When I run jekyll build
|
||||
Then the "_site/index.html" file should exist
|
||||
And I should see "Jack" in "_site/index.html"
|
||||
And I should see "Leon" in "_site/index.html"
|
||||
|
||||
Scenario: autoload *.yaml files in subdirectories in _data directory
|
||||
Given I have a _data directory
|
||||
And I have a _data/categories directory
|
||||
And I have a "_data/categories/dairy.yaml" file with content:
|
||||
"""
|
||||
name: Dairy Products
|
||||
"""
|
||||
And I have an "index.html" page that contains "{{ site.data.categories.dairy.name }}"
|
||||
When I run jekyll build
|
||||
Then the "_site/index.html" file should exist
|
||||
And I should see "Dairy Products" in "_site/index.html"
|
||||
|
||||
Scenario: folders should have precedence over files with the same name
|
||||
Given I have a _data directory
|
||||
And I have a _data/categories directory
|
||||
And I have a "_data/categories/dairy.yaml" file with content:
|
||||
"""
|
||||
name: Dairy Products
|
||||
"""
|
||||
And I have a "_data/categories.yaml" file with content:
|
||||
"""
|
||||
dairy:
|
||||
name: Should not display this
|
||||
"""
|
||||
And I have an "index.html" page that contains "{{ site.data.categories.dairy.name }}"
|
||||
When I run jekyll build
|
||||
Then the "_site/index.html" file should exist
|
||||
And I should see "Dairy Products" in "_site/index.html"
|
||||
|
||||
Scenario: should be backward compatible with site.data in _config.yml
|
||||
Given I have a "_config.yml" file with content:
|
||||
"""
|
||||
data:
|
||||
- name: Jack
|
||||
age: 28
|
||||
- name: Leon
|
||||
age: 34
|
||||
"""
|
||||
And I have an "index.html" page that contains "{% for member in site.data %}{{member.name}}{% endfor %}"
|
||||
When I run jekyll build
|
||||
Then the "_site/index.html" file should exist
|
||||
And I should see "Jack" in "_site/index.html"
|
||||
And I should see "Leon" in "_site/index.html"
|
||||
@@ -1,50 +0,0 @@
|
||||
Feature: Draft Posts
|
||||
As a hacker who likes to blog
|
||||
I want to be able to preview drafts locally
|
||||
In order to see if they look alright before publishing
|
||||
|
||||
Scenario: Preview a draft
|
||||
Given I have a configuration file with "permalink" set to "none"
|
||||
And I have a _drafts directory
|
||||
And I have the following draft:
|
||||
| title | date | layout | content |
|
||||
| Recipe | 2009-03-27 | default | Not baked yet. |
|
||||
When I run jekyll build --drafts
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Not baked yet." in "_site/recipe.html"
|
||||
|
||||
Scenario: Don't preview a draft
|
||||
Given I have a configuration file with "permalink" set to "none"
|
||||
And I have an "index.html" page that contains "Totally index"
|
||||
And I have a _drafts directory
|
||||
And I have the following draft:
|
||||
| title | date | layout | content |
|
||||
| Recipe | 2009-03-27 | default | Not baked yet. |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And the "_site/recipe.html" file should not exist
|
||||
|
||||
Scenario: Don't preview a draft that is not published
|
||||
Given I have a configuration file with "permalink" set to "none"
|
||||
And I have an "index.html" page that contains "Totally index"
|
||||
And I have a _drafts directory
|
||||
And I have the following draft:
|
||||
| title | date | layout | published | content |
|
||||
| Recipe | 2009-03-27 | default | false | Not baked yet. |
|
||||
When I run jekyll build --drafts
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And the "_site/recipe.html" file should not exist
|
||||
|
||||
Scenario: Use page.path variable
|
||||
Given I have a configuration file with "permalink" set to "none"
|
||||
And I have a _drafts directory
|
||||
And I have the following draft:
|
||||
| title | date | layout | content |
|
||||
| Recipe | 2009-03-27 | simple | Post path: {{ page.path }} |
|
||||
When I run jekyll build --drafts
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post path: _drafts/recipe.markdown" in "_site/recipe.html"
|
||||
@@ -1,121 +0,0 @@
|
||||
Feature: Embed filters
|
||||
As a hacker who likes to blog
|
||||
I want to be able to transform text inside a post or page
|
||||
In order to perform cool stuff in my posts
|
||||
|
||||
Scenario: Convert date to XML schema
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | content |
|
||||
| Star Wars | 2009-03-27 | default | These aren't the droids you're looking for. |
|
||||
And I have a default layout that contains "{{ site.time | date_to_xmlschema }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see today's date in "_site/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Escape text for XML
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | content |
|
||||
| Star & Wars | 2009-03-27 | default | These aren't the droids you're looking for. |
|
||||
And I have a default layout that contains "{{ page.title | xml_escape }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Star & Wars" in "_site/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Calculate number of words
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | content |
|
||||
| Star Wars | 2009-03-27 | default | These aren't the droids you're looking for. |
|
||||
And I have a default layout that contains "{{ content | number_of_words }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "7" in "_site/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Convert an array into a sentence
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | tags | content |
|
||||
| Star Wars | 2009-03-27 | default | [scifi, movies, force] | These aren't the droids you're looking for. |
|
||||
And I have a default layout that contains "{{ page.tags | array_to_sentence_string }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "scifi, movies, and force" in "_site/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Markdownify a given string
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | content |
|
||||
| Star Wars | 2009-03-27 | default | These aren't the droids you're looking for. |
|
||||
And I have a default layout that contains "By {{ '_Obi-wan_' | markdownify }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "By <p><em>Obi-wan</em></p>" in "_site/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Markdownify a given inline string
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | content |
|
||||
| Star Wars | 2009-03-27 | default | These aren't the droids you're looking for. |
|
||||
And I have a default layout that contains "By {{ '_Obi-wan_' | markdownify:'inline' }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "By <em>Obi-wan</em>" in "_site/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Sort by an arbitrary variable
|
||||
Given I have a _layouts directory
|
||||
And I have the following page:
|
||||
| title | layout | value | content |
|
||||
| Page-1 | default | 8 | Something |
|
||||
And I have the following page:
|
||||
| title | layout | value | content |
|
||||
| Page-2 | default | 6 | Something |
|
||||
And I have a default layout that contains "{{ site.pages | sort:'value' | map:'title' | join:', ' }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see exactly "Page-2, Page-1" in "_site/page-1.html"
|
||||
And I should see exactly "Page-2, Page-1" in "_site/page-2.html"
|
||||
|
||||
Scenario: Sort pages by the title
|
||||
Given I have a _layouts directory
|
||||
And I have the following pages:
|
||||
| title | layout | content |
|
||||
| Dog | default | Run |
|
||||
| Bird | default | Fly |
|
||||
And I have the following page:
|
||||
| layout | content |
|
||||
| default | Jump |
|
||||
And I have a default layout that contains "{% assign sorted_pages = site.pages | sort: 'title' %}The rule of {{ sorted_pages.size }}: {% for p in sorted_pages %}{{ p.content | strip_html | strip_newlines }}, {% endfor %}"
|
||||
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: Jump, Fly, Run," in "_site/bird.html"
|
||||
|
||||
Scenario: Sort pages by the title ordering pages without title last
|
||||
Given I have a _layouts directory
|
||||
And I have the following pages:
|
||||
| title | layout | content |
|
||||
| Dog | default | Run |
|
||||
| Bird | default | Fly |
|
||||
And I have the following page:
|
||||
| layout | content |
|
||||
| default | Jump |
|
||||
And I have a default layout that contains "{% assign sorted_pages = site.pages | sort: 'title', 'last' %}The rule of {{ sorted_pages.size }}: {% for p in sorted_pages %}{{ p.content | strip_html | strip_newlines }}, {% endfor %}"
|
||||
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"
|
||||
@@ -1,195 +0,0 @@
|
||||
Feature: frontmatter defaults
|
||||
Scenario: Use default for frontmatter variables internally
|
||||
Given I have a _layouts directory
|
||||
And I have a pretty layout that contains "THIS IS THE LAYOUT: {{content}}"
|
||||
|
||||
And I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | date | content |
|
||||
| default layout | 2013-09-11 | just some post |
|
||||
And I have an "index.html" page with title "some title" that contains "just some page"
|
||||
|
||||
And I have a configuration file with "defaults" set to "[{scope: {path: ""}, values: {layout: "pretty"}}]"
|
||||
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "THIS IS THE LAYOUT: <p>just some post</p>" in "_site/2013/09/11/default-layout.html"
|
||||
And I should see "THIS IS THE LAYOUT: just some page" in "_site/index.html"
|
||||
|
||||
Scenario: Use default for frontmatter variables in Liquid
|
||||
Given I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | date | content |
|
||||
| default data | 2013-09-11 | <p>{{page.custom}}</p><div>{{page.author}}</div> |
|
||||
And I have an "index.html" page that contains "just {{page.custom}} by {{page.author}}"
|
||||
And I have a configuration file with "defaults" set to "[{scope: {path: ""}, values: {custom: "some special data", author: "Ben"}}]"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "<p>some special data</p>\n<div>Ben</div>" in "_site/2013/09/11/default-data.html"
|
||||
And I should see "just some special data by Ben" in "_site/index.html"
|
||||
|
||||
Scenario: Override frontmatter defaults by path
|
||||
Given I have a _layouts directory
|
||||
And I have a root layout that contains "root: {{ content }}"
|
||||
And I have a subfolder layout that contains "subfolder: {{ content }}"
|
||||
|
||||
And I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | date | content |
|
||||
| about | 2013-10-14 | info on {{page.description}} |
|
||||
And I have a special/_posts directory
|
||||
And I have the following post in "special":
|
||||
| title | date | path | content |
|
||||
| about | 2013-10-14 | local | info on {{page.description}} |
|
||||
|
||||
And I have an "index.html" page with title "overview" that contains "Overview for {{page.description}}"
|
||||
And I have an "special/index.html" page with title "section overview" that contains "Overview for {{page.description}}"
|
||||
|
||||
And I have a configuration file with "defaults" set to "[{scope: {path: "special"}, values: {layout: "subfolder", description: "the special section"}}, {scope: {path: ""}, values: {layout: "root", description: "the webpage"}}]"
|
||||
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "root: <p>info on the webpage</p>" in "_site/2013/10/14/about.html"
|
||||
And I should see "subfolder: <p>info on the special section</p>" in "_site/special/2013/10/14/about.html"
|
||||
And I should see "root: Overview for the webpage" in "_site/index.html"
|
||||
And I should see "subfolder: Overview for the special section" in "_site/special/index.html"
|
||||
|
||||
Scenario: Use frontmatter variables by relative path
|
||||
Given I have a _layouts directory
|
||||
And I have a main layout that contains "main: {{ content }}"
|
||||
|
||||
And I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | date | content |
|
||||
| about | 2013-10-14 | content of site/2013/10/14/about.html |
|
||||
And I have a special/_posts directory
|
||||
And I have the following post in "special":
|
||||
| title | date | path | content |
|
||||
| about1 | 2013-10-14 | local | content of site/special/2013/10/14/about1.html |
|
||||
| about2 | 2013-10-14 | local | content of site/special/2013/10/14/about2.html |
|
||||
|
||||
And I have a configuration file with "defaults" set to "[{scope: {path: "special"}, values: {layout: "main"}}, {scope: {path: "special/_posts"}, values: {layout: "main"}}, {scope: {path: "_posts"}, values: {layout: "main"}}]"
|
||||
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "main: <p>content of site/2013/10/14/about.html</p>" in "_site/2013/10/14/about.html"
|
||||
And I should see "main: <p>content of site/special/2013/10/14/about1.html</p>" in "_site/special/2013/10/14/about1.html"
|
||||
And I should see "main: <p>content of site/special/2013/10/14/about2.html</p>" in "_site/special/2013/10/14/about2.html"
|
||||
|
||||
Scenario: Use frontmatter scopes for subdirectories
|
||||
Given I have a _layouts directory
|
||||
And I have a main layout that contains "main: {{ content }}"
|
||||
|
||||
And I have a _posts/en directory
|
||||
And I have the following post under "en":
|
||||
| title | date | content |
|
||||
| helloworld | 2014-09-01 | {{page.lang}} is the current language |
|
||||
And I have a _posts/de directory
|
||||
And I have the following post under "de":
|
||||
| title | date | content |
|
||||
| hallowelt | 2014-09-01 | {{page.lang}} is the current language |
|
||||
|
||||
And I have a configuration file with "defaults" set to "[{scope: {path: "_posts/en"}, values: {layout: "main", lang: "en"}}, {scope: {path: "_posts/de"}, values: {layout: "main", lang: "de"}}]"
|
||||
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "main: <p>en is the current language</p>" in "_site/2014/09/01/helloworld.html"
|
||||
And I should see "main: <p>de is the current language</p>" in "_site/2014/09/01/hallowelt.html"
|
||||
|
||||
Scenario: Override frontmatter defaults by type
|
||||
Given I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | date | content |
|
||||
| this is a post | 2013-10-14 | blabla |
|
||||
And I have an "index.html" page that contains "interesting stuff"
|
||||
And I have a configuration file with "defaults" set to "[{scope: {path: "", type: "post"}, values: {permalink: "/post.html"}}, {scope: {path: "", type: "page"}, values: {permalink: "/page.html"}}, {scope: {path: ""}, values: {permalink: "/perma.html"}}]"
|
||||
When I run jekyll build
|
||||
Then I should see "blabla" in "_site/post.html"
|
||||
And I should see "interesting stuff" in "_site/page.html"
|
||||
But the "_site/perma.html" file should not exist
|
||||
|
||||
Scenario: Actual frontmatter overrides defaults
|
||||
Given I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | date | permalink | author | content |
|
||||
| override | 2013-10-14 | /frontmatter.html | some guy | a blog by {{page.author}} |
|
||||
And I have an "index.html" page with permalink "override.html" that contains "nothing"
|
||||
And I have a configuration file with "defaults" set to "[{scope: {path: ""}, values: {permalink: "/perma.html", author: "Chris"}}]"
|
||||
When I run jekyll build
|
||||
Then I should see "a blog by some guy" in "_site/frontmatter.html"
|
||||
And I should see "nothing" in "_site/override.html"
|
||||
But the "_site/perma.html" file should not exist
|
||||
|
||||
Scenario: Define permalink default for posts
|
||||
Given I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | date | category | content |
|
||||
| testpost | 2013-10-14 | blog | blabla |
|
||||
And I have a configuration file with "defaults" set to "[{scope: {path: "", type: "posts"}, values: {permalink: "/:categories/:title/"}}]"
|
||||
When I run jekyll build
|
||||
Then I should see "blabla" in "_site/blog/testpost/index.html"
|
||||
|
||||
Scenario: Use frontmatter defaults in collections
|
||||
Given I have a _slides directory
|
||||
And I have a "index.html" file that contains "nothing"
|
||||
And I have a "_slides/slide1.html" file with content:
|
||||
"""
|
||||
---
|
||||
---
|
||||
Value: {{ page.myval }}
|
||||
"""
|
||||
And I have a "_config.yml" file with content:
|
||||
"""
|
||||
collections:
|
||||
slides:
|
||||
output: true
|
||||
defaults:
|
||||
-
|
||||
scope:
|
||||
path: ""
|
||||
type: slides
|
||||
values:
|
||||
myval: "Test"
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Value: Test" in "_site/slides/slide1.html"
|
||||
|
||||
Scenario: Override frontmatter defaults inside a collection
|
||||
Given I have a _slides directory
|
||||
And I have a "index.html" file that contains "nothing"
|
||||
And I have a "_slides/slide2.html" file with content:
|
||||
"""
|
||||
---
|
||||
myval: Override
|
||||
---
|
||||
Value: {{ page.myval }}
|
||||
"""
|
||||
And I have a "_config.yml" file with content:
|
||||
"""
|
||||
collections:
|
||||
slides:
|
||||
output: true
|
||||
defaults:
|
||||
-
|
||||
scope:
|
||||
path: ""
|
||||
type: slides
|
||||
values:
|
||||
myval: "Test"
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Value: Override" in "_site/slides/slide2.html"
|
||||
|
||||
Scenario: Deep merge frontmatter defaults
|
||||
Given I have an "index.html" page with fruit "{orange: 1}" that contains "Fruits: {{ page.fruit.orange | plus: page.fruit.apple }}"
|
||||
And I have a configuration file with "defaults" set to "[{scope: {path: ""}, values: {fruit: {apple: 2}}}]"
|
||||
When I run jekyll build
|
||||
Then I should see "Fruits: 3" in "_site/index.html"
|
||||
@@ -1,33 +0,0 @@
|
||||
Feature: Syntax Highlighting
|
||||
As a hacker who likes to blog
|
||||
I want to share code snippets in my blog
|
||||
And make them pretty for all the world to see
|
||||
|
||||
Scenario: highlighting an apache configuration
|
||||
Given I have an "index.html" file with content:
|
||||
"""
|
||||
---
|
||||
---
|
||||
|
||||
{% highlight apache %}
|
||||
RewriteEngine On
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^(.*)$ index.php [QSA,L]
|
||||
{% endhighlight %}
|
||||
|
||||
```apache
|
||||
RewriteEngine On
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^(.*)$ index.php [QSA,L]
|
||||
```
|
||||
"""
|
||||
And I have a "_config.yml" file with content:
|
||||
"""
|
||||
kramdown:
|
||||
input: GFM
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit-status
|
||||
And I should see "<span class="nc">RewriteCond</span>" in "_site/index.html"
|
||||
@@ -1,360 +0,0 @@
|
||||
Feature: Hooks
|
||||
As a plugin author
|
||||
I want to be able to run code during various stages of the build process
|
||||
|
||||
Scenario: Run some code after site reset
|
||||
Given I have a _plugins directory
|
||||
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)
|
||||
end
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "mytinypage" in "_site/foo.html"
|
||||
|
||||
Scenario: Modify the payload before rendering the site
|
||||
Given I have a _plugins directory
|
||||
And I have a "index.html" page that contains "{{ site.injected }}!"
|
||||
And I have a "_plugins/ext.rb" file with content:
|
||||
"""
|
||||
Jekyll::Hooks.register :site, :pre_render do |site, payload|
|
||||
payload['site']['injected'] = 'myparam'
|
||||
end
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "myparam!" in "_site/index.html"
|
||||
|
||||
Scenario: Modify the site contents after reading
|
||||
Given I have a _plugins directory
|
||||
And I have a "page1.html" page that contains "page1"
|
||||
And I have a "page2.html" page that contains "page2"
|
||||
And I have a "_plugins/ext.rb" file with content:
|
||||
"""
|
||||
Jekyll::Hooks.register :site, :post_read do |site|
|
||||
site.pages.delete_if { |p| p.name == 'page1.html' }
|
||||
end
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And the "_site/page1.html" file should not exist
|
||||
And I should see "page2" in "_site/page2.html"
|
||||
|
||||
Scenario: Work with the site files after they've been written to disk
|
||||
Given I have a _plugins directory
|
||||
And I have a "_plugins/ext.rb" file with content:
|
||||
"""
|
||||
Jekyll::Hooks.register :site, :post_write do |site|
|
||||
firstpage = site.pages.first
|
||||
content = File.read firstpage.destination(site.dest)
|
||||
File.write(File.join(site.dest, 'firstpage.html'), content)
|
||||
end
|
||||
"""
|
||||
And I have a "page1.html" page that contains "page1"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "page1" in "_site/firstpage.html"
|
||||
|
||||
Scenario: Alter a page right after it is initialized
|
||||
Given I have a _plugins directory
|
||||
And I have a "_plugins/ext.rb" file with content:
|
||||
"""
|
||||
Jekyll::Hooks.register :pages, :post_init do |page|
|
||||
page.name = 'renamed.html'
|
||||
page.process(page.name)
|
||||
end
|
||||
"""
|
||||
And I have a "page1.html" page that contains "page1"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "page1" in "_site/renamed.html"
|
||||
|
||||
Scenario: Alter the payload for one page but not another
|
||||
Given I have a _plugins directory
|
||||
And I have a "_plugins/ext.rb" file with content:
|
||||
"""
|
||||
Jekyll::Hooks.register :pages, :pre_render do |page, payload|
|
||||
payload['page']['myparam'] = 'special' if page.name == 'page1.html'
|
||||
end
|
||||
"""
|
||||
And I have a "page1.html" page that contains "{{ page.myparam }}"
|
||||
And I have a "page2.html" page that contains "{{ page.myparam }}"
|
||||
When I run jekyll build
|
||||
Then I should see "special" in "_site/page1.html"
|
||||
And I should not see "special" in "_site/page2.html"
|
||||
|
||||
Scenario: Modify page contents before writing to disk
|
||||
Given I have a _plugins directory
|
||||
And I have a "index.html" page that contains "WRAP ME"
|
||||
And I have a "_plugins/ext.rb" file with content:
|
||||
"""
|
||||
Jekyll::Hooks.register :pages, :post_render do |page|
|
||||
page.output = "{{{{{ #{page.output.chomp} }}}}}"
|
||||
end
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should see "{{{{{ WRAP ME }}}}}" in "_site/index.html"
|
||||
|
||||
Scenario: Work with a page after writing it to disk
|
||||
Given I have a _plugins directory
|
||||
And I have a "index.html" page that contains "HELLO FROM A PAGE"
|
||||
And I have a "_plugins/ext.rb" file with content:
|
||||
"""
|
||||
Jekyll::Hooks.register :pages, :post_write do |page|
|
||||
require 'fileutils'
|
||||
filename = page.destination(page.site.dest)
|
||||
FileUtils.mv(filename, "#{filename}.moved")
|
||||
end
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should see "HELLO FROM A PAGE" in "_site/index.html.moved"
|
||||
|
||||
Scenario: Alter a post right after it is initialized
|
||||
Given I have a _plugins directory
|
||||
And I have a "_plugins/ext.rb" file with content:
|
||||
"""
|
||||
Jekyll::Hooks.register :posts, :post_init do |post|
|
||||
post.data['harold'] = "content for entry1.".tr!('abcdefghijklmnopqrstuvwxyz',
|
||||
'nopqrstuvwxyzabcdefghijklm')
|
||||
end
|
||||
"""
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| entry1 | 2015-03-14 | nil | {{ page.harold }} |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "pbagrag sbe ragel1." in "_site/2015/03/14/entry1.html"
|
||||
|
||||
Scenario: Alter the payload for certain posts
|
||||
Given I have a _plugins directory
|
||||
And I have a "_plugins/ext.rb" file with content:
|
||||
"""
|
||||
# Add myvar = 'old' to posts before 2015-03-15, and myvar = 'new' for
|
||||
# others
|
||||
Jekyll::Hooks.register :posts, :pre_render do |post, payload|
|
||||
if post.date < Time.new(2015, 3, 15)
|
||||
payload['myvar'] = 'old'
|
||||
else
|
||||
payload['myvar'] = 'new'
|
||||
end
|
||||
end
|
||||
"""
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| entry1 | 2015-03-14 | nil | {{ myvar }} post |
|
||||
| entry2 | 2015-03-15 | nil | {{ myvar }} post |
|
||||
When I run jekyll build
|
||||
Then I should see "old post" in "_site/2015/03/14/entry1.html"
|
||||
And I should see "new post" in "_site/2015/03/15/entry2.html"
|
||||
|
||||
Scenario: Modify post contents before writing to disk
|
||||
Given I have a _plugins directory
|
||||
And I have a "_plugins/ext.rb" file with content:
|
||||
"""
|
||||
# Replace content after rendering
|
||||
Jekyll::Hooks.register :posts, :post_render do |post|
|
||||
post.output.gsub! /42/, 'the answer to life, the universe and everything'
|
||||
end
|
||||
"""
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| entry1 | 2015-03-14 | nil | {{ 6 \| times: 7 }} |
|
||||
| entry2 | 2015-03-15 | nil | {{ 6 \| times: 8 }} |
|
||||
When I run jekyll build
|
||||
Then I should see "the answer to life, the universe and everything" in "_site/2015/03/14/entry1.html"
|
||||
And I should see "48" in "_site/2015/03/15/entry2.html"
|
||||
|
||||
Scenario: Work with a post after writing it to disk
|
||||
Given I have a _plugins directory
|
||||
And I have a "_plugins/ext.rb" file with content:
|
||||
"""
|
||||
# Log all post filesystem writes
|
||||
Jekyll::Hooks.register :posts, :post_write do |post|
|
||||
filename = post.destination(post.site.dest)
|
||||
open('_site/post-build.log', 'a') do |f|
|
||||
f.puts "Wrote #{filename} at #{Time.now}"
|
||||
end
|
||||
end
|
||||
"""
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| entry1 | 2015-03-14 | nil | entry one |
|
||||
| entry2 | 2015-03-15 | nil | entry two |
|
||||
When I run jekyll build
|
||||
Then I should see "_site/2015/03/14/entry1.html at" in "_site/post-build.log"
|
||||
Then I should see "_site/2015/03/15/entry2.html at" in "_site/post-build.log"
|
||||
|
||||
Scenario: Register a hook on multiple owners at the same time
|
||||
Given I have a _plugins directory
|
||||
And I have a "_plugins/ext.rb" file with content:
|
||||
"""
|
||||
Jekyll::Hooks.register [:pages, :posts], :post_render do |owner|
|
||||
owner.output = "{{{{{ #{owner.output.chomp} }}}}}"
|
||||
end
|
||||
"""
|
||||
And I have a "index.html" page that contains "WRAP ME"
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| entry1 | 2015-03-14 | nil | entry one |
|
||||
When I run jekyll build
|
||||
Then I should see "{{{{{ WRAP ME }}}}}" in "_site/index.html"
|
||||
And I should see "{{{{{ <p>entry one</p> }}}}}" in "_site/2015/03/14/entry1.html"
|
||||
|
||||
Scenario: Allow hooks to have a named priority
|
||||
Given I have a _plugins directory
|
||||
And I have a "_plugins/ext.rb" file with content:
|
||||
"""
|
||||
Jekyll::Hooks.register :pages, :post_render, priority: :normal do |owner|
|
||||
# first normal runs second
|
||||
owner.output = "1 #{owner.output.chomp}"
|
||||
end
|
||||
Jekyll::Hooks.register :pages, :post_render, priority: :high do |owner|
|
||||
# high runs first
|
||||
owner.output = "2 #{owner.output.chomp}"
|
||||
end
|
||||
Jekyll::Hooks.register :pages, :post_render do |owner|
|
||||
# second normal runs third (normal is default)
|
||||
owner.output = "3 #{owner.output.chomp}"
|
||||
end
|
||||
Jekyll::Hooks.register :pages, :post_render, priority: :low do |owner|
|
||||
# low runs last
|
||||
owner.output = "4 #{owner.output.chomp}"
|
||||
end
|
||||
"""
|
||||
And I have a "index.html" page that contains "WRAP ME"
|
||||
When I run jekyll build
|
||||
Then I should see "4 3 1 2 WRAP ME" in "_site/index.html"
|
||||
|
||||
Scenario: Alter a document right after it is initialized
|
||||
Given I have a _plugins directory
|
||||
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'] << ' are belong to us'
|
||||
end
|
||||
"""
|
||||
And I have a "_config.yml" file that contains "collections: [ memes ]"
|
||||
And I have a _memes directory
|
||||
And I have a "_memes/doc1.md" file with content:
|
||||
"""
|
||||
---
|
||||
text: all your base
|
||||
---
|
||||
"""
|
||||
And I have an "index.md" file with content:
|
||||
"""
|
||||
---
|
||||
---
|
||||
{{ site.memes.first.text }}
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "all your base are belong to us" in "_site/index.html"
|
||||
|
||||
Scenario: Update a document after rendering it, but before writing it to disk
|
||||
Given I have a _plugins directory
|
||||
And I have a "_plugins/ext.rb" file with content:
|
||||
"""
|
||||
Jekyll::Hooks.register :documents, :post_render do |doc|
|
||||
doc.output.gsub! /<p>/, '<p class="meme">'
|
||||
end
|
||||
"""
|
||||
And I have a "_config.yml" file with content:
|
||||
"""
|
||||
collections:
|
||||
memes:
|
||||
output: true
|
||||
"""
|
||||
And I have a _memes directory
|
||||
And I have a "_memes/doc1.md" file with content:
|
||||
"""
|
||||
---
|
||||
text: all your base are belong to us
|
||||
---
|
||||
{{ page.text }}
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "<p class=\"meme\">all your base are belong to us" in "_site/memes/doc1.html"
|
||||
|
||||
Scenario: Perform an action after every document is written
|
||||
Given I have a _plugins directory
|
||||
And I have a "_plugins/ext.rb" file with content:
|
||||
"""
|
||||
Jekyll::Hooks.register :documents, :post_write do |doc|
|
||||
open('_site/document-build.log', 'a') do |f|
|
||||
f.puts "Wrote document #{doc.collection.docs.index doc} at #{Time.now}"
|
||||
end
|
||||
end
|
||||
"""
|
||||
And I have a "_config.yml" file with content:
|
||||
"""
|
||||
collections:
|
||||
memes:
|
||||
output: true
|
||||
"""
|
||||
And I have a _memes directory
|
||||
And I have a "_memes/doc1.md" file with content:
|
||||
"""
|
||||
---
|
||||
text: all your base are belong to us
|
||||
---
|
||||
{{ page.text }}
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Wrote document 0" in "_site/document-build.log"
|
||||
|
||||
Scenario: Set a custom payload['page'] property
|
||||
Given I have a _plugins directory
|
||||
And I have a "_plugins/ext.rb" file with content:
|
||||
"""
|
||||
Jekyll::Hooks.register :pages, :pre_render do |page, payload|
|
||||
payload['page']['foo'] = "hello world"
|
||||
end
|
||||
"""
|
||||
And I have a _layouts directory
|
||||
And I have a "_layouts/custom.html" file with content:
|
||||
"""
|
||||
---
|
||||
---
|
||||
{{ content }} {% include foo.html %}
|
||||
"""
|
||||
And I have a _includes directory
|
||||
And I have a "_includes/foo.html" file with content:
|
||||
"""
|
||||
{{page.foo}}
|
||||
"""
|
||||
And I have an "index.html" page with layout "custom" that contains "page content"
|
||||
When I run jekyll build
|
||||
Then the "_site/index.html" file should exist
|
||||
And I should see "page content\n hello world" in "_site/index.html"
|
||||
@@ -1,106 +0,0 @@
|
||||
Feature: Include tags
|
||||
In order to share their content across several pages
|
||||
As a hacker who likes to blog
|
||||
I want to be able to include files in my blog posts
|
||||
|
||||
Scenario: Include a file with parameters
|
||||
Given I have an _includes directory
|
||||
And I have an "_includes/header.html" file that contains "<header>My awesome blog header: {{include.param}}</header>"
|
||||
And I have an "_includes/params.html" file that contains "Parameters:<ul>{% for param in include %}<li>{{param[0]}} = {{param[1]}}</li>{% endfor %}</ul>"
|
||||
And I have an "_includes/ignore.html" file that contains "<footer>My blog footer</footer>"
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | type | content |
|
||||
| Include Files | 2013-03-21 | html | {% include header.html param="myparam" %} |
|
||||
| Ignore params if unused | 2013-03-21 | html | {% include ignore.html date="today" %} |
|
||||
| List multiple parameters | 2013-03-21 | html | {% include params.html date="today" start="tomorrow" %} |
|
||||
| Dont keep parameters | 2013-03-21 | html | {% include ignore.html param="test" %}\n{% include header.html %} |
|
||||
| Allow params with spaces and quotes | 2013-04-07 | html | {% include params.html cool="param with spaces" super="\\"quoted\\"" single='has "quotes"' escaped='\\'single\\' quotes' %} |
|
||||
| Parameter syntax | 2013-04-12 | html | {% include params.html param1_or_2="value" %} |
|
||||
| Pass a variable | 2013-06-22 | html | {% assign var = 'some text' %}{% include params.html local=var title=page.title %} |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "<header>My awesome blog header: myparam</header>" in "_site/2013/03/21/include-files.html"
|
||||
And I should not see "myparam" in "_site/2013/03/21/ignore-params-if-unused.html"
|
||||
And I should see "<li>date = today</li>" in "_site/2013/03/21/list-multiple-parameters.html"
|
||||
And I should see "<li>start = tomorrow</li>" in "_site/2013/03/21/list-multiple-parameters.html"
|
||||
And I should not see "<header>My awesome blog header: myparam</header>" in "_site/2013/03/21/dont-keep-parameters.html"
|
||||
But I should see "<header>My awesome blog header: </header>" in "_site/2013/03/21/dont-keep-parameters.html"
|
||||
And I should see "<li>cool = param with spaces</li>" in "_site/2013/04/07/allow-params-with-spaces-and-quotes.html"
|
||||
And I should see "<li>super = \"quoted\"</li>" in "_site/2013/04/07/allow-params-with-spaces-and-quotes.html"
|
||||
And I should see "<li>single = has \"quotes\"</li>" in "_site/2013/04/07/allow-params-with-spaces-and-quotes.html"
|
||||
And I should see "<li>escaped = 'single' quotes</li>" in "_site/2013/04/07/allow-params-with-spaces-and-quotes.html"
|
||||
And I should see "<li>param1_or_2 = value</li>" in "_site/2013/04/12/parameter-syntax.html"
|
||||
And I should see "<li>local = some text</li>" in "_site/2013/06/22/pass-a-variable.html"
|
||||
And I should see "<li>title = Pass a variable</li>" in "_site/2013/06/22/pass-a-variable.html"
|
||||
|
||||
Scenario: Include a file from a variable
|
||||
Given I have an _includes directory
|
||||
And I have an "_includes/snippet.html" file that contains "a snippet"
|
||||
And I have an "_includes/parametrized.html" file that contains "works with {{include.what}}"
|
||||
And I have a configuration file with:
|
||||
| key | value |
|
||||
| include_file1 | snippet.html |
|
||||
| include_file2 | parametrized.html |
|
||||
And I have an "index.html" page that contains "{% include {{site.include_file1}} %} that {% include {{site.include_file2}} what='parameters' %}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "a snippet that works with parameters" in "_site/index.html"
|
||||
|
||||
Scenario: Include a variable file in a loop
|
||||
Given I have an _includes directory
|
||||
And I have an "_includes/one.html" file that contains "one"
|
||||
And I have an "_includes/two.html" file that contains "two"
|
||||
And I have an "index.html" page with files "[one.html, two.html]" that contains "{% for file in page.files %}{% include {{file}} %} {% endfor %}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "one two" in "_site/index.html"
|
||||
|
||||
Scenario: Include a file with variables and filters
|
||||
Given I have an _includes directory
|
||||
And I have an "_includes/one.html" file that contains "one included"
|
||||
And I have a configuration file with:
|
||||
| key | value |
|
||||
| include_file | one |
|
||||
And I have an "index.html" page that contains "{% include {{ site.include_file | append: '.html' }} %}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "one included" in "_site/index.html"
|
||||
|
||||
Scenario: Include a file with partial variables
|
||||
Given I have an _includes directory
|
||||
And I have an "_includes/one.html" file that contains "one included"
|
||||
And I have a configuration file with:
|
||||
| key | value |
|
||||
| include_file | one |
|
||||
And I have an "index.html" page that contains "{% include {{ site.include_file }}.html %}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "one included" in "_site/index.html"
|
||||
|
||||
Scenario: Include a file and rebuild when include content is changed
|
||||
Given I have an _includes directory
|
||||
And I have an "_includes/one.html" file that contains "include"
|
||||
And I have an "index.html" page that contains "{% include one.html %}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "include" in "_site/index.html"
|
||||
When I wait 1 second
|
||||
Then I have an "_includes/one.html" file that contains "include content changed"
|
||||
When I run jekyll build
|
||||
Then I should see "include content changed" in "_site/index.html"
|
||||
|
||||
Scenario: Include a file with multiple variables
|
||||
Given I have an _includes directory
|
||||
And I have an "_includes/header-en.html" file that contains "include"
|
||||
And I have an "index.html" page that contains "{% assign name = 'header' %}{% assign locale = 'en' %}{% include {{name}}-{{locale}}.html %}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "include" in "_site/index.html"
|
||||
@@ -1,68 +0,0 @@
|
||||
Feature: Incremental rebuild
|
||||
As an impatient hacker who likes to blog
|
||||
I want to be able to make a static site
|
||||
Without waiting too long for it to build
|
||||
|
||||
Scenario: Produce correct output site
|
||||
Given I have a _layouts directory
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| Wargames | 2009-03-27 | default | The only winning move is not to play. |
|
||||
And I have a default layout that contains "Post Layout: {{ content }}"
|
||||
When I run jekyll build -I
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post Layout: <p>The only winning move is not to play.</p>" in "_site/2009/03/27/wargames.html"
|
||||
When I run jekyll build -I
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post Layout: <p>The only winning move is not to play.</p>" in "_site/2009/03/27/wargames.html"
|
||||
|
||||
Scenario: Generate a metadata file
|
||||
Given I have an "index.html" file that contains "Basic Site"
|
||||
When I run jekyll build -I
|
||||
Then the ".jekyll-metadata" file should exist
|
||||
|
||||
Scenario: Rebuild when content is changed
|
||||
Given I have an "index.html" file that contains "Basic Site"
|
||||
When I run jekyll build -I
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Basic Site" in "_site/index.html"
|
||||
When I wait 1 second
|
||||
Then I have an "index.html" file that contains "Bacon Site"
|
||||
When I run jekyll build -I
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Bacon Site" in "_site/index.html"
|
||||
|
||||
Scenario: Rebuild when layout is changed
|
||||
Given I have a _layouts directory
|
||||
And I have an "index.html" page with layout "default" that contains "Basic Site with Layout"
|
||||
And I have a default layout that contains "Page Layout: {{ content }}"
|
||||
When I run jekyll build -I
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Page Layout: Basic Site with Layout" in "_site/index.html"
|
||||
When I wait 1 second
|
||||
Then I have a default layout that contains "Page Layout Changed: {{ content }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Page Layout Changed: Basic Site with Layout" in "_site/index.html"
|
||||
|
||||
Scenario: Rebuild when an include is changed
|
||||
Given I have a _includes directory
|
||||
And I have an "index.html" page that contains "Basic Site with include tag: {% include about.textile %}"
|
||||
And I have an "_includes/about.textile" file that contains "Generated by Jekyll"
|
||||
When I run jekyll build -I
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Basic Site with include tag: Generated by Jekyll" in "_site/index.html"
|
||||
When I wait 1 second
|
||||
Then I have an "_includes/about.textile" file that contains "Regenerated by Jekyll"
|
||||
When I run jekyll build -I
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Basic Site with include tag: Regenerated by Jekyll" in "_site/index.html"
|
||||
@@ -1,70 +0,0 @@
|
||||
Feature: Layout data
|
||||
As a hacker who likes to avoid repetition
|
||||
I want to be able to embed data into my layouts
|
||||
In order to make the layouts slightly dynamic
|
||||
|
||||
Scenario: Use custom layout data
|
||||
Given I have a _layouts directory
|
||||
And I have a "_layouts/custom.html" file with content:
|
||||
"""
|
||||
---
|
||||
foo: my custom data
|
||||
---
|
||||
{{ content }} foo: {{ layout.foo }}
|
||||
"""
|
||||
And I have an "index.html" page with layout "custom" that contains "page content"
|
||||
When I run jekyll build
|
||||
Then the "_site/index.html" file should exist
|
||||
And I should see "page content\n foo: my custom data" in "_site/index.html"
|
||||
|
||||
Scenario: Inherit custom layout data
|
||||
Given I have a _layouts directory
|
||||
And I have a "_layouts/custom.html" file with content:
|
||||
"""
|
||||
---
|
||||
layout: base
|
||||
foo: my custom data
|
||||
---
|
||||
{{ content }}
|
||||
"""
|
||||
And I have a "_layouts/base.html" file with content:
|
||||
"""
|
||||
{{ content }} foo: {{ layout.foo }}
|
||||
"""
|
||||
And I have an "index.html" page with layout "custom" that contains "page content"
|
||||
When I run jekyll build
|
||||
Then the "_site/index.html" file should exist
|
||||
And I should see "page content\n foo: my custom data" in "_site/index.html"
|
||||
|
||||
Scenario: Inherit custom layout data and clear when not present
|
||||
Given I have a _layouts directory
|
||||
And I have a "_layouts/default.html" file with content:
|
||||
"""
|
||||
---
|
||||
bar: i'm default
|
||||
---
|
||||
{{ content }} foo: '{{ layout.foo }}' bar: '{{ layout.bar }}'
|
||||
"""
|
||||
And I have a "_layouts/special.html" file with content:
|
||||
"""
|
||||
---
|
||||
layout: default
|
||||
foo: my special data
|
||||
bar: im special
|
||||
---
|
||||
{{ content }}
|
||||
"""
|
||||
And I have a "_layouts/page.html" file with content:
|
||||
"""
|
||||
---
|
||||
layout: default
|
||||
bar: im page
|
||||
---
|
||||
{{ content }}
|
||||
"""
|
||||
And I have an "index.html" page with layout "special" that contains "page content"
|
||||
And I have an "jekyll.html" page with layout "page" that contains "page content"
|
||||
When I run jekyll build
|
||||
Then the "_site/index.html" file should exist
|
||||
And I should see "page content\n foo: 'my special data' bar: 'im special'" in "_site/index.html"
|
||||
And I should see "page content\n foo: '' bar: 'im page'" in "_site/jekyll.html"
|
||||
@@ -1,34 +0,0 @@
|
||||
Feature: Markdown
|
||||
As a hacker who likes to blog
|
||||
I want to be able to make a static site
|
||||
In order to share my awesome ideas with the interwebs
|
||||
|
||||
Scenario: Markdown in list on index
|
||||
Given I have a configuration file with "paginate" set to "5"
|
||||
And I have an "index.html" page that contains "Index - {% for post in site.posts %} {{ post.content }} {% endfor %}"
|
||||
And I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | date | content | type |
|
||||
| Hackers | 2009-03-27 | # My Title | markdown |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Index" in "_site/index.html"
|
||||
And I should see "<h1 id=\"my-title\">My Title</h1>" in "_site/2009/03/27/hackers.html"
|
||||
And I should see "<h1 id=\"my-title\">My Title</h1>" in "_site/index.html"
|
||||
|
||||
Scenario: Markdown in pagination on index
|
||||
Given I have a configuration file with:
|
||||
| key | value |
|
||||
| paginate | 5 |
|
||||
| gems | [jekyll-paginate] |
|
||||
And I have an "index.html" page that contains "Index - {% for post in paginator.posts %} {{ post.content }} {% endfor %}"
|
||||
And I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | date | content | type |
|
||||
| Hackers | 2009-03-27 | # My Title | markdown |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Index" in "_site/index.html"
|
||||
And I should see "<h1 id=\"my-title\">My Title</h1>" in "_site/index.html"
|
||||
@@ -1,87 +0,0 @@
|
||||
Feature: Site pagination
|
||||
In order to paginate my blog
|
||||
As a blog's user
|
||||
I want divide the posts in several pages
|
||||
|
||||
Scenario Outline: Paginate with N posts per page
|
||||
Given I have a configuration file with:
|
||||
| key | value |
|
||||
| paginate | <num> |
|
||||
| gems | [jekyll-paginate] |
|
||||
And I have a _layouts directory
|
||||
And I have an "index.html" page that contains "{{ paginator.posts.size }}"
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| Wargames | 2009-03-27 | default | The only winning move is not to play. |
|
||||
| Wargames2 | 2009-04-27 | default | The only winning move is not to play2. |
|
||||
| Wargames3 | 2009-05-27 | default | The only winning move is not to play3. |
|
||||
| Wargames4 | 2009-06-27 | default | The only winning move is not to play4. |
|
||||
When I run jekyll build
|
||||
Then the _site/page<exist> directory should exist
|
||||
And the "_site/page<exist>/index.html" file should exist
|
||||
And I should see "<posts>" in "_site/page<exist>/index.html"
|
||||
And the "_site/page<not_exist>/index.html" file should not exist
|
||||
|
||||
Examples:
|
||||
| num | exist | posts | not_exist |
|
||||
| 1 | 4 | 1 | 5 |
|
||||
| 2 | 2 | 2 | 3 |
|
||||
| 3 | 2 | 1 | 3 |
|
||||
|
||||
Scenario Outline: Setting a custom pagination path
|
||||
Given I have a configuration file with:
|
||||
| key | value |
|
||||
| paginate | 1 |
|
||||
| paginate_path | /blog/page-:num |
|
||||
| permalink | /blog/:year/:month/:day/:title |
|
||||
| gems | [jekyll-paginate] |
|
||||
And I have a blog directory
|
||||
And I have an "blog/index.html" page that contains "{{ paginator.posts.size }}"
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| Wargames | 2009-03-27 | default | The only winning move is not to play. |
|
||||
| Wargames2 | 2009-04-27 | default | The only winning move is not to play2. |
|
||||
| Wargames3 | 2009-05-27 | default | The only winning move is not to play3. |
|
||||
| Wargames4 | 2009-06-27 | default | The only winning move is not to play4. |
|
||||
When I run jekyll build
|
||||
Then the _site/blog/page-<exist> directory should exist
|
||||
And the "_site/blog/page-<exist>/index.html" file should exist
|
||||
And I should see "<posts>" in "_site/blog/page-<exist>/index.html"
|
||||
And the "_site/blog/page-<not_exist>/index.html" file should not exist
|
||||
|
||||
Examples:
|
||||
| exist | posts | not_exist |
|
||||
| 2 | 1 | 5 |
|
||||
| 3 | 1 | 6 |
|
||||
| 4 | 1 | 7 |
|
||||
|
||||
Scenario Outline: Setting a custom pagination path without an index.html in it
|
||||
Given I have a configuration file with:
|
||||
| key | value |
|
||||
| paginate | 1 |
|
||||
| paginate_path | /blog/page/:num |
|
||||
| permalink | /blog/:year/:month/:day/:title |
|
||||
| gems | [jekyll-paginate] |
|
||||
And I have a blog directory
|
||||
And I have an "blog/index.html" page that contains "{{ paginator.posts.size }}"
|
||||
And I have an "index.html" page that contains "Don't pick me!"
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| Wargames | 2009-03-27 | default | The only winning move is not to play. |
|
||||
| Wargames2 | 2009-04-27 | default | The only winning move is not to play2. |
|
||||
| Wargames3 | 2009-05-27 | default | The only winning move is not to play3. |
|
||||
| Wargames4 | 2009-06-27 | default | The only winning move is not to play4. |
|
||||
When I run jekyll build
|
||||
Then the _site/blog/page/<exist> directory should exist
|
||||
And the "_site/blog/page/<exist>/index.html" file should exist
|
||||
And I should see "<posts>" in "_site/blog/page/<exist>/index.html"
|
||||
And the "_site/blog/page/<not_exist>/index.html" file should not exist
|
||||
|
||||
Examples:
|
||||
| exist | posts | not_exist |
|
||||
| 2 | 1 | 5 |
|
||||
| 3 | 1 | 6 |
|
||||
| 4 | 1 | 7 |
|
||||
@@ -1,144 +0,0 @@
|
||||
Feature: Fancy permalinks
|
||||
As a hacker who likes to blog
|
||||
I want to be able to set permalinks
|
||||
In order to make my blog URLs awesome
|
||||
|
||||
Scenario: Use none permalink schema
|
||||
Given I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | date | content |
|
||||
| None Permalink Schema | 2009-03-27 | Totally nothing. |
|
||||
And I have a configuration file with "permalink" set to "none"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Totally nothing." in "_site/none-permalink-schema.html"
|
||||
|
||||
Scenario: Use pretty permalink schema
|
||||
Given I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | date | content |
|
||||
| Pretty Permalink Schema | 2009-03-27 | Totally wordpress. |
|
||||
And I have a configuration file with "permalink" set to "pretty"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Totally wordpress." in "_site/2009/03/27/pretty-permalink-schema/index.html"
|
||||
|
||||
Scenario: Use pretty permalink schema for pages
|
||||
Given I have an "index.html" page that contains "Totally index"
|
||||
And I have an "awesome.html" page that contains "Totally awesome"
|
||||
And I have an "sitemap.xml" page that contains "Totally uhm, sitemap"
|
||||
And I have a configuration file with "permalink" set to "pretty"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Totally index" in "_site/index.html"
|
||||
And I should see "Totally awesome" in "_site/awesome/index.html"
|
||||
And I should see "Totally uhm, sitemap" in "_site/sitemap.xml"
|
||||
|
||||
Scenario: Use custom permalink schema with prefix
|
||||
Given I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | category | date | content |
|
||||
| Custom Permalink Schema | stuff | 2009-03-27 | Totally custom. |
|
||||
And I have a configuration file with "permalink" set to "/blog/:year/:month/:day/:title/"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Totally custom." in "_site/blog/2009/03/27/custom-permalink-schema/index.html"
|
||||
|
||||
Scenario: Use custom permalink schema with category
|
||||
Given I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | category | date | content |
|
||||
| Custom Permalink Schema | stuff | 2009-03-27 | Totally custom. |
|
||||
And I have a configuration file with "permalink" set to "/:categories/:title.html"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Totally custom." in "_site/stuff/custom-permalink-schema.html"
|
||||
|
||||
Scenario: Use custom permalink schema with squished date
|
||||
Given I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | category | date | content |
|
||||
| Custom Permalink Schema | stuff | 2009-03-27 | Totally custom. |
|
||||
And I have a configuration file with "permalink" set to "/:month-:day-:year/:title.html"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Totally custom." in "_site/03-27-2009/custom-permalink-schema.html"
|
||||
|
||||
Scenario: Use custom permalink schema with date and time
|
||||
Given I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | category | date | content |
|
||||
| Custom Permalink Schema | stuff | 2009-03-27 22:31:07 | Totally custom. |
|
||||
And I have a configuration file with:
|
||||
| key | value |
|
||||
| permalink | "/:year:month:day:hour:minute:second.html" |
|
||||
| timezone | UTC |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Totally custom." in "_site/20090327223107.html"
|
||||
|
||||
Scenario: Use per-post permalink
|
||||
Given I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | date | permalink | content |
|
||||
| Some post | 2013-04-14 | /custom/posts/1/ | bla bla |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And the _site/custom/posts/1 directory should exist
|
||||
And I should see "bla bla" in "_site/custom/posts/1/index.html"
|
||||
|
||||
Scenario: Use per-post ending in .html
|
||||
Given I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | date | permalink | content |
|
||||
| Some post | 2013-04-14 | /custom/posts/some.html | bla bla |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And the _site/custom/posts directory should exist
|
||||
And I should see "bla bla" in "_site/custom/posts/some.html"
|
||||
|
||||
Scenario: Use pretty permalink schema with cased file name
|
||||
Given I have a _posts directory
|
||||
And I have an "_posts/2009-03-27-Pretty-Permalink-Schema.md" page that contains "Totally wordpress"
|
||||
And I have a configuration file with "permalink" set to "pretty"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Totally wordpress." in "_site/2009/03/27/Pretty-Permalink-Schema/index.html"
|
||||
|
||||
Scenario: Use custom permalink schema with cased file name
|
||||
Given I have a _posts directory
|
||||
And I have an "_posts/2009-03-27-Custom-Schema.md" page with title "Custom Schema" that contains "Totally awesome"
|
||||
And I have a configuration file with "permalink" set to "/:year/:month/:day/:slug/"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Totally awesome" in "_site/2009/03/27/custom-schema/index.html"
|
||||
|
||||
Scenario: Use pretty permalink schema with title containing underscore
|
||||
Given I have a _posts directory
|
||||
And I have an "_posts/2009-03-27-Custom_Schema.md" page with title "Custom Schema" that contains "Totally awesome"
|
||||
And I have a configuration file with "permalink" set to "pretty"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Totally awesome" in "_site/2009/03/27/Custom_Schema/index.html"
|
||||
|
||||
Scenario: Use a non-HTML file extension in the permalink
|
||||
Given I have a _posts directory
|
||||
And I have an "_posts/2016-01-18-i-am-php.md" page with permalink "/2016/i-am-php.php" that contains "I am PHP"
|
||||
And I have a "i-am-also-php.md" page with permalink "/i-am-also-php.php" that contains "I am also PHP"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "I am PHP" in "_site/2016/i-am-php.php"
|
||||
And I should see "I am also PHP" in "_site/i-am-also-php.php"
|
||||
@@ -1,37 +0,0 @@
|
||||
Feature: Configuring and using plugins
|
||||
As a hacker
|
||||
I want to specify my own plugins that can modify Jekyll's behaviour
|
||||
|
||||
Scenario: Add a gem-based plugin
|
||||
Given I have an "index.html" file that contains "Whatever"
|
||||
And I have a configuration file with "gems" set to "[jekyll_test_plugin]"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Whatever" in "_site/index.html"
|
||||
And I should see "this is a test" in "_site/test.txt"
|
||||
|
||||
Scenario: Add an empty whitelist to restrict all gems
|
||||
Given I have an "index.html" file that contains "Whatever"
|
||||
And I have a configuration file with:
|
||||
| key | value |
|
||||
| gems | [jekyll_test_plugin] |
|
||||
| whitelist | [] |
|
||||
When I run jekyll build --safe
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Whatever" in "_site/index.html"
|
||||
And the "_site/test.txt" file should not exist
|
||||
|
||||
Scenario: Add a whitelist to restrict some gems but allow others
|
||||
Given I have an "index.html" file that contains "Whatever"
|
||||
And I have a configuration file with:
|
||||
| key | value |
|
||||
| gems | [jekyll_test_plugin, jekyll_test_plugin_malicious] |
|
||||
| whitelist | [jekyll_test_plugin] |
|
||||
When I run jekyll build --safe
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Whatever" in "_site/index.html"
|
||||
And the "_site/test.txt" file should exist
|
||||
And I should see "this is a test" in "_site/test.txt"
|
||||
@@ -1,329 +0,0 @@
|
||||
Feature: Post data
|
||||
As a hacker who likes to blog
|
||||
I want to be able to embed data into my posts
|
||||
In order to make the posts slightly dynamic
|
||||
|
||||
Scenario: Use post.title variable
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | content |
|
||||
| Star Wars | 2009-03-27 | simple | Luke, I am your father. |
|
||||
And I have a simple layout that contains "Post title: {{ page.title }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post title: Star Wars" in "_site/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Use post.url variable
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | content |
|
||||
| Star Wars | 2009-03-27 | simple | Luke, I am your father. |
|
||||
And I have a simple layout that contains "Post url: {{ page.url }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post url: /2009/03/27/star-wars.html" in "_site/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Use post.date variable
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | content |
|
||||
| Star Wars | 2009-03-27 | simple | Luke, I am your father. |
|
||||
And I have a simple layout that contains "Post date: {{ page.date | date_to_string }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post date: 27 Mar 2009" in "_site/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Use post.date variable with invalid
|
||||
Given I have a _posts directory
|
||||
And I have a "_posts/2016-01-01-test.md" page with date "tuesday" that contains "I have a bad date."
|
||||
When I run jekyll build
|
||||
Then the _site directory should not exist
|
||||
And I should see "Document '_posts/2016-01-01-test.md' does not have a valid date in the YAML front matter." in the build output
|
||||
|
||||
Scenario: Invalid date in filename
|
||||
Given I have a _posts directory
|
||||
And I have a "_posts/2016-22-01-test.md" page that contains "I have a bad date."
|
||||
When I run jekyll build
|
||||
Then the _site directory should not exist
|
||||
And I should see "Document '_posts/2016-22-01-test.md' does not have a valid date in the filename." in the build output
|
||||
|
||||
Scenario: Use post.id variable
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | content |
|
||||
| Star Wars | 2009-03-27 | simple | Luke, I am your father. |
|
||||
And I have a simple layout that contains "Post id: {{ page.id }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post id: /2009/03/27/star-wars" in "_site/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Use post.content variable
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | content |
|
||||
| Star Wars | 2009-03-27 | simple | Luke, I am your father. |
|
||||
And I have a simple layout that contains "Post content: {{ content }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post content: <p>Luke, I am your father.</p>" in "_site/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Use post.categories variable when category is in a folder
|
||||
Given I have a movies directory
|
||||
And I have a movies/_posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post in "movies":
|
||||
| title | date | layout | content |
|
||||
| Star Wars | 2009-03-27 | simple | Luke, I am your father. |
|
||||
And I have a simple layout that contains "Post category: {{ page.categories }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Use post.categories variable when category is in a folder and has category in YAML
|
||||
Given I have a movies directory
|
||||
And I have a movies/_posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post in "movies":
|
||||
| title | date | layout | category | content |
|
||||
| Star Wars | 2009-03-27 | simple | film | Luke, I am your father. |
|
||||
And I have a simple layout that contains "Post category: {{ page.categories }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post category: movies" in "_site/movies/film/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Use post.categories variable when category is in a folder and has categories in YAML
|
||||
Given I have a movies directory
|
||||
And I have a movies/_posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post in "movies":
|
||||
| title | date | layout | categories | content |
|
||||
| Star Wars | 2009-03-27 | simple | [film, scifi] | Luke, I am your father. |
|
||||
And I have a simple layout that contains "Post category: {{ page.categories }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post category: movies" in "_site/movies/film/scifi/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Use post.categories variable when category is in a folder and duplicated category is in YAML
|
||||
Given I have a movies directory
|
||||
And I have a movies/_posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post in "movies":
|
||||
| title | date | layout | category | content |
|
||||
| Star Wars | 2009-03-27 | simple | movies | Luke, I am your father. |
|
||||
And I have a simple layout that contains "Post category: {{ page.categories }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Use post.tags variable
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | tag | content |
|
||||
| Star Wars | 2009-05-18 | simple | twist | Luke, I am your father. |
|
||||
And I have a simple layout that contains "Post tags: {{ page.tags }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post tags: twist" in "_site/2009/05/18/star-wars.html"
|
||||
|
||||
Scenario: Use post.categories variable when categories are in folders
|
||||
Given I have a scifi directory
|
||||
And I have a scifi/movies directory
|
||||
And I have a scifi/movies/_posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post in "scifi/movies":
|
||||
| title | date | layout | content |
|
||||
| Star Wars | 2009-03-27 | simple | Luke, I am your father. |
|
||||
And I have a simple layout that contains "Post categories: {{ page.categories | array_to_sentence_string }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post categories: scifi and movies" in "_site/scifi/movies/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Use post.categories variable when categories are in folders with mixed case
|
||||
Given I have a scifi directory
|
||||
And I have a scifi/Movies directory
|
||||
And I have a scifi/Movies/_posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post in "scifi/Movies":
|
||||
| title | date | layout | content |
|
||||
| Star Wars | 2009-03-27 | simple | Luke, I am your father. |
|
||||
And I have a simple layout that contains "Post categories: {{ page.categories | array_to_sentence_string }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post categories: scifi and Movies" in "_site/scifi/movies/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Use post.categories variable when category is in YAML
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | category | content |
|
||||
| Star Wars | 2009-03-27 | simple | movies | Luke, I am your father. |
|
||||
And I have a simple layout that contains "Post category: {{ page.categories }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Use post.categories variable when category is in YAML and is mixed-case
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | category | content |
|
||||
| Star Wars | 2009-03-27 | simple | Movies | Luke, I am your father. |
|
||||
And I have a simple layout that contains "Post category: {{ page.categories }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post category: Movies" in "_site/movies/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Use post.categories variable when categories are in YAML
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | categories | content |
|
||||
| Star Wars | 2009-03-27 | simple | ['scifi', 'movies'] | Luke, I am your father. |
|
||||
And I have a simple layout that contains "Post categories: {{ page.categories | array_to_sentence_string }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post categories: scifi and movies" in "_site/scifi/movies/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Use post.categories variable when categories are in YAML and are duplicated
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | categories | content |
|
||||
| Star Wars | 2009-03-27 | simple | ['movies', 'movies'] | Luke, I am your father. |
|
||||
And I have a simple layout that contains "Post category: {{ page.categories }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Superdirectories of _posts applied to post.categories
|
||||
Given I have a movies/_posts directory
|
||||
And I have a "movies/_posts/2009-03-27-star-wars.html" page with layout "simple" that contains "hi"
|
||||
And I have a _layouts directory
|
||||
And I have a simple layout that contains "Post category: {{ page.categories }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Subdirectories of _posts not applied to post.categories
|
||||
Given I have a movies/_posts/scifi directory
|
||||
And I have a "movies/_posts/scifi/2009-03-27-star-wars.html" page with layout "simple" that contains "hi"
|
||||
And I have a _layouts directory
|
||||
And I have a simple layout that contains "Post category: {{ page.categories }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Use post.categories variable when categories are in YAML with mixed case
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | categories | content |
|
||||
| Star Wars | 2009-03-27 | simple | ['scifi', 'Movies'] | Luke, I am your father. |
|
||||
| Star Trek | 2013-03-17 | simple | ['SciFi', 'movies'] | Jean Luc, I am your father. |
|
||||
And I have a simple layout that contains "Post categories: {{ page.categories | array_to_sentence_string }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
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 Outline: Use page.path variable
|
||||
Given I have a <dir>/_posts directory
|
||||
And I have the following post in "<dir>":
|
||||
| title | type | date | content |
|
||||
| my-post | html | 2013-04-12 | Source path: {{ page.path }} |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Source path: <path_prefix>_posts/2013-04-12-my-post.html" in "_site/<dir>/2013/04/12/my-post.html"
|
||||
|
||||
Examples:
|
||||
| dir | path_prefix |
|
||||
| . | |
|
||||
| dir | dir/ |
|
||||
| dir/nested | dir/nested/ |
|
||||
|
||||
Scenario: Cannot override page.path variable
|
||||
Given I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | date | path | content |
|
||||
| override | 2013-04-12 | override-path.html | Non-custom path: {{ page.path }} |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Non-custom path: _posts/2013-04-12-override.markdown" in "_site/2013/04/12/override.html"
|
||||
|
||||
Scenario: Disable a post from being published
|
||||
Given I have a _posts directory
|
||||
And I have an "index.html" file that contains "Published!"
|
||||
And I have the following post:
|
||||
| title | date | layout | published | content |
|
||||
| Star Wars | 2009-03-27 | simple | false | Luke, I am your father. |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And the "_site/2009/03/27/star-wars.html" file should not exist
|
||||
And I should see "Published!" in "_site/index.html"
|
||||
|
||||
Scenario: Use a custom variable
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | author | content |
|
||||
| Star Wars | 2009-03-27 | simple | Darth Vader | Luke, I am your father. |
|
||||
And I have a simple layout that contains "Post author: {{ page.author }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Post author: Darth Vader" in "_site/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Use a variable which is a reserved keyword in Ruby
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | class | content |
|
||||
| My post | 2016-01-21 | simple | kewl-post | Luke, I am your father. |
|
||||
And I have a simple layout that contains "{{page.title}} has class {{page.class}}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "My post has class kewl-post" in "_site/2016/01/21/my-post.html"
|
||||
|
||||
Scenario: Previous and next posts title
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | author | content |
|
||||
| Star Wars | 2009-03-27 | ordered | Darth Vader | Luke, I am your father. |
|
||||
| Some like it hot | 2009-04-27 | ordered | Osgood | Nobody is perfect. |
|
||||
| Terminator | 2009-05-27 | ordered | Arnold | Sayonara, baby |
|
||||
And I have a ordered layout that contains "Previous post: {{ page.previous.title }} and next post: {{ page.next.title }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "next post: Some like it hot" in "_site/2009/03/27/star-wars.html"
|
||||
And I should see "Previous post: Some like it hot" in "_site/2009/05/27/terminator.html"
|
||||
@@ -1,53 +0,0 @@
|
||||
Feature: Post excerpts
|
||||
As a hacker who likes to blog
|
||||
I want to be able to make a static site
|
||||
In order to share my awesome ideas with the interwebs
|
||||
But some people can only focus for a few moments
|
||||
So just give them a taste
|
||||
|
||||
Scenario: An excerpt without a layout
|
||||
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 the following posts:
|
||||
| title | date | layout | content |
|
||||
| entry1 | 2007-12-31 | post | content for entry1. |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see exactly "<p>content for entry1.</p>" in "_site/index.html"
|
||||
|
||||
Scenario: An excerpt from a post with a layout
|
||||
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 | date | layout | content |
|
||||
| entry1 | 2007-12-31 | post | content for entry1. |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And the _site/2007 directory should exist
|
||||
And the _site/2007/12 directory should exist
|
||||
And the _site/2007/12/31 directory should exist
|
||||
And the "_site/2007/12/31/entry1.html" file should exist
|
||||
And I should see exactly "<p>content for entry1.</p>" in "_site/2007/12/31/entry1.html"
|
||||
And I should see exactly "<p>content for entry1.</p>" in "_site/index.html"
|
||||
|
||||
Scenario: An excerpt from a post with a layout which has context
|
||||
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 "<html><head></head><body>{{ page.excerpt }}</body></html>"
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| entry1 | 2007-12-31 | post | content for entry1. |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And the _site/2007 directory should exist
|
||||
And the _site/2007/12 directory should exist
|
||||
And the _site/2007/12/31 directory should exist
|
||||
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"
|
||||
@@ -1,55 +0,0 @@
|
||||
Feature: Rendering
|
||||
As a hacker who likes to blog
|
||||
I want to be able to make a static site
|
||||
In order to share my awesome ideas with the interwebs
|
||||
But I want to make it as simply as possible
|
||||
So render with Liquid and place in Layouts
|
||||
|
||||
Scenario: When receiving bad Liquid
|
||||
Given I have a "index.html" page with layout "simple" that contains "{% include invalid.html %}"
|
||||
And I have a simple layout that contains "{{ content }}"
|
||||
When I run jekyll build
|
||||
Then I should get a non-zero exit-status
|
||||
And I should see "Liquid Exception" in the build output
|
||||
|
||||
Scenario: Render Liquid and place in layout
|
||||
Given I have a "index.html" page with layout "simple" that contains "Hi there, Jekyll {{ jekyll.environment }}!"
|
||||
And I have a simple layout that contains "{{ content }}Ahoy, indeed!"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Hi there, Jekyll development!\nAhoy, indeed" in "_site/index.html"
|
||||
|
||||
Scenario: Don't place asset files in layout
|
||||
Given I have an "index.scss" page with layout "simple" that contains ".foo-bar { color:black; }"
|
||||
And I have an "index.coffee" page with layout "simple" that contains "whatever()"
|
||||
And I have a configuration file with "gems" set to "[jekyll-coffeescript]"
|
||||
And I have a simple layout that contains "{{ content }}Ahoy, indeed!"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should not see "Ahoy, indeed!" in "_site/index.css"
|
||||
And I should not see "Ahoy, indeed!" in "_site/index.js"
|
||||
|
||||
Scenario: Render liquid in Sass
|
||||
Given I have an "index.scss" page that contains ".foo-bar { color:{{site.color}}; }"
|
||||
And I have a configuration file with "color" set to "red"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see ".foo-bar {\n color: red; }" in "_site/index.css"
|
||||
|
||||
Scenario: Not render liquid in CoffeeScript without explicitly including jekyll-coffeescript
|
||||
Given I have an "index.coffee" page with animal "cicada" that contains "hey='for {{page.animal}}'"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And the "_site/index.js" file should not exist
|
||||
|
||||
Scenario: Render liquid in CoffeeScript with jekyll-coffeescript enabled
|
||||
Given I have an "index.coffee" page with animal "cicada" that contains "hey='for {{page.animal}}'"
|
||||
And I have a configuration file with "gems" set to "[jekyll-coffeescript]"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "hey = 'for cicada';" in "_site/index.js"
|
||||
@@ -1,259 +0,0 @@
|
||||
Feature: Site configuration
|
||||
As a hacker who likes to blog
|
||||
I want to be able to configure jekyll
|
||||
In order to make setting up a site easier
|
||||
|
||||
Scenario: Change source directory
|
||||
Given I have a blank site in "_sourcedir"
|
||||
And I have an "_sourcedir/index.html" file that contains "Changing source directory"
|
||||
And I have a configuration file with "source" set to "_sourcedir"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Changing source directory" in "_site/index.html"
|
||||
|
||||
Scenario: Change destination directory
|
||||
Given I have an "index.html" file that contains "Changing destination directory"
|
||||
And I have a configuration file with "destination" set to "_mysite"
|
||||
When I run jekyll build
|
||||
Then the _mysite directory should exist
|
||||
And I should see "Changing destination directory" in "_mysite/index.html"
|
||||
|
||||
Scenario Outline: Similarly named source and destination
|
||||
Given I have a blank site in "<source>"
|
||||
And I have an "<source>/index.md" page that contains "markdown"
|
||||
And I have a configuration file with:
|
||||
| key | value |
|
||||
| source | <source> |
|
||||
| destination | <dest> |
|
||||
When I run jekyll build
|
||||
Then the <source> directory should exist
|
||||
And the "<dest>/index.html" file should <file_exist> exist
|
||||
And I should see "markdown" in "<source>/index.md"
|
||||
|
||||
Examples:
|
||||
| source | dest | file_exist |
|
||||
| mysite_source | mysite | |
|
||||
| mysite | mysite_dest | |
|
||||
| mysite/ | mysite | not |
|
||||
| mysite | ./mysite | not |
|
||||
| mysite/source | mysite | not |
|
||||
| mysite | mysite/dest | |
|
||||
|
||||
Scenario: Exclude files inline
|
||||
Given I have an "Rakefile" file that contains "I want to be excluded"
|
||||
And I have an "README" file that contains "I want to be excluded"
|
||||
And I have an "index.html" file that contains "I want to be included"
|
||||
And I have a configuration file with "exclude" set to "['Rakefile', 'README']"
|
||||
When I run jekyll build
|
||||
Then I should see "I want to be included" in "_site/index.html"
|
||||
And the "_site/Rakefile" file should not exist
|
||||
And the "_site/README" file should not exist
|
||||
|
||||
Scenario: Exclude files with YAML array
|
||||
Given I have an "Rakefile" file that contains "I want to be excluded"
|
||||
And I have an "README" file that contains "I want to be excluded"
|
||||
And I have an "index.html" file that contains "I want to be included"
|
||||
And I have a configuration file with "exclude" set to:
|
||||
| value |
|
||||
| README |
|
||||
| Rakefile |
|
||||
When I run jekyll build
|
||||
Then I should see "I want to be included" in "_site/index.html"
|
||||
And the "_site/Rakefile" file should not exist
|
||||
And the "_site/README" file should not exist
|
||||
|
||||
Scenario: Use RDiscount for markup
|
||||
Given I have an "index.markdown" page that contains "[Google](http://google.com)"
|
||||
And I have a configuration file with "markdown" set to "rdiscount"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "<a href=\"http://google.com\">Google</a>" in "_site/index.html"
|
||||
|
||||
Scenario: Use Kramdown for markup
|
||||
Given I have an "index.markdown" page that contains "[Google](http://google.com)"
|
||||
And I have a configuration file with "markdown" set to "kramdown"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "<a href=\"http://google.com\">Google</a>" in "_site/index.html"
|
||||
|
||||
Scenario: Use Redcarpet for markup
|
||||
Given I have an "index.markdown" page that contains "[Google](http://google.com)"
|
||||
And I have a configuration file with "markdown" set to "redcarpet"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "<a href=\"http://google.com\">Google</a>" in "_site/index.html"
|
||||
|
||||
Scenario: Highlight code with pygments
|
||||
Given I have an "index.html" page that contains "{% highlight ruby %} puts 'Hello world!' {% endhighlight %}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Hello world!" in "_site/index.html"
|
||||
And I should see "class=\"highlight\"" in "_site/index.html"
|
||||
|
||||
Scenario: Highlight code with rouge
|
||||
Given I have an "index.html" page that contains "{% highlight ruby %} puts 'Hello world!' {% endhighlight %}"
|
||||
And I have a configuration file with "highlighter" set to "rouge"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Hello world!" in "_site/index.html"
|
||||
And I should see "class=\"highlight\"" in "_site/index.html"
|
||||
|
||||
Scenario: Rouge renders code block once
|
||||
Given I have a configuration file with "highlighter" set to "rouge"
|
||||
And I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | content |
|
||||
| foo | 2014-04-27 11:34 | default | {% highlight text %} test {% endhighlight %} |
|
||||
When I run jekyll build
|
||||
Then I should not see "highlight(.*)highlight" in "_site/2014/04/27/foo.html"
|
||||
|
||||
Scenario: Set time and no future dated posts
|
||||
Given I have a _layouts directory
|
||||
And I have a page layout that contains "Page Layout: {{ site.posts.size }} on {{ site.time | date: "%Y-%m-%d" }}"
|
||||
And I have a post layout that contains "Post Layout: {{ content }}"
|
||||
And I have an "index.html" page with layout "page" that contains "site index page"
|
||||
And I have a configuration file with:
|
||||
| key | value |
|
||||
| time | 2010-01-01 |
|
||||
| future | false |
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| entry1 | 2007-12-31 | post | content for entry1. |
|
||||
| entry2 | 2020-01-31 | post | content for entry2. |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Page Layout: 1 on 2010-01-01" in "_site/index.html"
|
||||
And I should see "Post Layout: <p>content for entry1.</p>" in "_site/2007/12/31/entry1.html"
|
||||
And the "_site/2020/01/31/entry2.html" file should not exist
|
||||
|
||||
Scenario: Set time and future dated posts allowed
|
||||
Given I have a _layouts directory
|
||||
And I have a page layout that contains "Page Layout: {{ site.posts.size }} on {{ site.time | date: "%Y-%m-%d" }}"
|
||||
And I have a post layout that contains "Post Layout: {{ content }}"
|
||||
And I have an "index.html" page with layout "page" that contains "site index page"
|
||||
And I have a configuration file with:
|
||||
| key | value |
|
||||
| time | 2010-01-01 |
|
||||
| future | true |
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| entry1 | 2007-12-31 | post | content for entry1. |
|
||||
| entry2 | 2020-01-31 | post | content for entry2. |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Page Layout: 2 on 2010-01-01" in "_site/index.html"
|
||||
And I should see "Post Layout: <p>content for entry1.</p>" in "_site/2007/12/31/entry1.html"
|
||||
And I should see "Post Layout: <p>content for entry2.</p>" in "_site/2020/01/31/entry2.html"
|
||||
|
||||
Scenario: Generate proper dates with explicitly set timezone (same as posts' time)
|
||||
Given I have a _layouts directory
|
||||
And I have a page layout that contains "Page Layout: {{ site.posts.size }}"
|
||||
And I have a post layout that contains "Post Layout: {{ content }} built at {{ page.date | date_to_xmlschema }}"
|
||||
And I have an "index.html" page with layout "page" that contains "site index page"
|
||||
And I have a configuration file with:
|
||||
| key | value |
|
||||
| timezone | UTC+04:00 |
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| entry1 | 2013-04-09 23:22 -0400 | post | content for entry1. |
|
||||
| entry2 | 2013-04-10 03:14 -0400 | post | content for entry2. |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Page Layout: 2" in "_site/index.html"
|
||||
And I should see "Post Layout: <p>content for entry1.</p>\n built at 2013-04-09T23:22:00-04:00" in "_site/2013/04/09/entry1.html"
|
||||
And I should see "Post Layout: <p>content for entry2.</p>\n built at 2013-04-10T03:14:00-04:00" in "_site/2013/04/10/entry2.html"
|
||||
|
||||
Scenario: Generate proper dates with explicitly set timezone (different than posts' time)
|
||||
Given I have a _layouts directory
|
||||
And I have a page layout that contains "Page Layout: {{ site.posts.size }}"
|
||||
And I have a post layout that contains "Post Layout: {{ content }} built at {{ page.date | date_to_xmlschema }}"
|
||||
And I have an "index.html" page with layout "page" that contains "site index page"
|
||||
And I have a configuration file with:
|
||||
| key | value |
|
||||
| timezone | UTC+10:00 |
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| entry1 | 2013-04-09 23:22 +0400 | post | content for entry1. |
|
||||
| entry2 | 2013-04-10 03:14 +0400 | post | content for entry2. |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Page Layout: 2" in "_site/index.html"
|
||||
And the "_site/2013/04/09/entry1.html" file should exist
|
||||
And the "_site/2013/04/09/entry2.html" file should exist
|
||||
And I should see "Post Layout: <p>content for entry1.</p>\n built at 2013-04-09T09:22:00-10:00" in "_site/2013/04/09/entry1.html"
|
||||
And I should see "Post Layout: <p>content for entry2.</p>\n built at 2013-04-09T13:14:00-10:00" in "_site/2013/04/09/entry2.html"
|
||||
|
||||
Scenario: Limit the number of posts generated by most recent date
|
||||
Given I have a _posts directory
|
||||
And I have a configuration file with:
|
||||
| key | value |
|
||||
| limit_posts | 2 |
|
||||
And I have the following posts:
|
||||
| title | date | content |
|
||||
| Apples | 2009-03-27 | An article about apples |
|
||||
| Oranges | 2009-04-01 | An article about oranges |
|
||||
| Bananas | 2009-04-05 | An article about bananas |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And the "_site/2009/04/05/bananas.html" file should exist
|
||||
And the "_site/2009/04/01/oranges.html" file should exist
|
||||
And the "_site/2009/03/27/apples.html" file should not exist
|
||||
|
||||
Scenario: Copy over normally excluded files when they are explicitly included
|
||||
Given I have a ".gitignore" file that contains ".DS_Store"
|
||||
And I have an ".htaccess" file that contains "SomeDirective"
|
||||
And I have a configuration file with "include" set to:
|
||||
| value |
|
||||
| .gitignore |
|
||||
| .foo |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see ".DS_Store" in "_site/.gitignore"
|
||||
And the "_site/.htaccess" file should not exist
|
||||
|
||||
Scenario: Using a different layouts directory
|
||||
Given I have a _theme directory
|
||||
And I have a page theme that contains "Page Layout: {{ site.posts.size }} on {{ site.time | date: "%Y-%m-%d" }}"
|
||||
And I have a post theme that contains "Post Layout: {{ content }}"
|
||||
And I have an "index.html" page with layout "page" that contains "site index page"
|
||||
And I have a configuration file with:
|
||||
| key | value |
|
||||
| time | 2010-01-01 |
|
||||
| future | true |
|
||||
| layouts_dir | _theme |
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| entry1 | 2007-12-31 | post | content for entry1. |
|
||||
| entry2 | 2020-01-31 | post | content for entry2. |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Page Layout: 2 on 2010-01-01" in "_site/index.html"
|
||||
And I should see "Post Layout: <p>content for entry1.</p>" in "_site/2007/12/31/entry1.html"
|
||||
And I should see "Post Layout: <p>content for entry2.</p>" in "_site/2020/01/31/entry2.html"
|
||||
|
||||
Scenario: arbitrary file reads via layouts
|
||||
Given I have an "index.html" page with layout "page" that contains "FOO"
|
||||
And I have a "_config.yml" file that contains "layouts: '../../../../../../../../../../../../../../usr/include'"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "FOO" in "_site/index.html"
|
||||
And I should not see " " in "_site/index.html"
|
||||
@@ -1,118 +0,0 @@
|
||||
Feature: Site data
|
||||
As a hacker who likes to blog
|
||||
I want to be able to embed data into my site
|
||||
In order to make the site slightly dynamic
|
||||
|
||||
Scenario: Use page variable in a page
|
||||
Given I have an "contact.html" page with title "Contact" that contains "{{ page.title }}: email@example.com"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Contact: email@example.com" in "_site/contact.html"
|
||||
|
||||
Scenario Outline: Use page.path variable in a page
|
||||
Given I have a <dir> directory
|
||||
And I have a "<path>" page that contains "Source path: {{ page.path }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Source path: <path>" in "_site/<path>"
|
||||
|
||||
Examples:
|
||||
| dir | path |
|
||||
| . | index.html |
|
||||
| dir | dir/about.html |
|
||||
| dir/nested | dir/nested/page.html |
|
||||
|
||||
Scenario: Override page.path
|
||||
Given I have an "override.html" page with path "custom-override.html" that contains "Custom path: {{ page.path }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Custom path: custom-override.html" in "_site/override.html"
|
||||
|
||||
Scenario: Use site.time variable
|
||||
Given I have an "index.html" page that contains "{{ site.time }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see today's time in "_site/index.html"
|
||||
|
||||
Scenario: Use site.posts variable for latest post
|
||||
Given I have a _posts directory
|
||||
And I have an "index.html" page that contains "{{ site.posts.first.title }}: {{ site.posts.first.url }}"
|
||||
And I have the following posts:
|
||||
| title | date | content |
|
||||
| First Post | 2009-03-25 | My First Post |
|
||||
| Second Post | 2009-03-26 | My Second Post |
|
||||
| Third Post | 2009-03-27 | My Third Post |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Third Post: /2009/03/27/third-post.html" in "_site/index.html"
|
||||
|
||||
Scenario: Use site.posts variable in a loop
|
||||
Given I have a _posts directory
|
||||
And I have an "index.html" page that contains "{% for post in site.posts %} {{ post.title }} {% endfor %}"
|
||||
And I have the following posts:
|
||||
| title | date | content |
|
||||
| First Post | 2009-03-25 | My First Post |
|
||||
| Second Post | 2009-03-26 | My Second Post |
|
||||
| Third Post | 2009-03-27 | My Third Post |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Third Post Second Post First Post" in "_site/index.html"
|
||||
|
||||
Scenario: Use site.categories.code variable
|
||||
Given I have a _posts directory
|
||||
And I have an "index.html" page that contains "{% for post in site.categories.code %} {{ post.title }} {% endfor %}"
|
||||
And I have the following posts:
|
||||
| title | date | category | content |
|
||||
| Awesome Hack | 2009-03-26 | code | puts 'Hello World' |
|
||||
| Delicious Beer | 2009-03-26 | food | 1) Yuengling |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Awesome Hack" in "_site/index.html"
|
||||
|
||||
Scenario: Use site.tags variable
|
||||
Given I have a _posts directory
|
||||
And I have an "index.html" page that contains "{% for post in site.tags.beer %} {{ post.content }} {% endfor %}"
|
||||
And I have the following posts:
|
||||
| title | date | tag | content |
|
||||
| Delicious Beer | 2009-03-26 | beer | 1) Yuengling |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "Yuengling" in "_site/index.html"
|
||||
|
||||
Scenario: Order Posts by name when on the same date
|
||||
Given I have a _posts directory
|
||||
And I have an "index.html" page that contains "{% for post in site.posts %}{{ post.title }}:{{ post.previous.title}},{{ post.next.title}} {% endfor %}"
|
||||
And I have the following posts:
|
||||
| title | date | content |
|
||||
| first | 2009-02-26 | first |
|
||||
| A | 2009-03-26 | A |
|
||||
| B | 2009-03-26 | B |
|
||||
| C | 2009-03-26 | C |
|
||||
| last | 2009-04-26 | last |
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "last:C, C:B,last B:A,C A:first,B first:,A" in "_site/index.html"
|
||||
|
||||
Scenario: Use configuration date in site payload
|
||||
Given I have an "index.html" page that contains "{{ site.url }}"
|
||||
And I have a configuration file with "url" set to "http://example.com"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "http://example.com" in "_site/index.html"
|
||||
|
||||
Scenario: Access Jekyll version via jekyll.version
|
||||
Given I have an "index.html" page that contains "{{ jekyll.version }}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "\d+\.\d+\.\d+" in "_site/index.html"
|
||||
@@ -1,247 +0,0 @@
|
||||
Before do
|
||||
FileUtils.rm_rf(Paths.test_dir) if Paths.test_dir.exist?
|
||||
FileUtils.mkdir_p(Paths.test_dir) unless Paths.test_dir.directory?
|
||||
Dir.chdir(Paths.test_dir)
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
After do
|
||||
FileUtils.rm_rf(Paths.test_dir) if Paths.test_dir.exist?
|
||||
Paths.output_file.delete if Paths.output_file.exist?
|
||||
Paths.status_file.delete if Paths.status_file.exist?
|
||||
Dir.chdir(Paths.test_dir.parent)
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Given(%r!^I have a blank site in "(.*)"$!) do |path|
|
||||
unless File.exist?(path)
|
||||
then FileUtils.mkdir_p(path)
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Given(%r!^I do not have a "(.*)" directory$!) do |path|
|
||||
Paths.test_dir.join(path).directory?
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Given(%r!^I have an? "(.*)" page(?: with (.*) "(.*)")? that contains "(.*)"$!) do |file, key, value, text|
|
||||
File.write(file, Jekyll::Utils.strip_heredoc(<<-DATA))
|
||||
---
|
||||
#{key || "layout"}: #{value || "nil"}
|
||||
---
|
||||
|
||||
#{text}
|
||||
DATA
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Given(%r!^I have an? "(.*)" file that contains "(.*)"$!) do |file, text|
|
||||
File.write(file, text)
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Given(%r!^I have an? (.*) (layout|theme) that contains "(.*)"$!) do |name, type, text|
|
||||
folder = type == "layout" ? "_layouts" : "_theme"
|
||||
|
||||
destination_file = Pathname.new(File.join(folder, "#{name}.html"))
|
||||
FileUtils.mkdir_p(destination_file.parent) unless destination_file.parent.directory?
|
||||
File.write(destination_file, text)
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Given(%r!^I have an? "(.*)" file with content:$!) do |file, text|
|
||||
File.write(file, text)
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Given(%r!^I have an? (.*) directory$!) do |dir|
|
||||
unless File.directory?(dir)
|
||||
then FileUtils.mkdir_p(dir)
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Given(%r!^I have the following (draft|page|post)s?(?: (in|under) "([^"]+)")?:$!) do |status, direction, folder, table|
|
||||
table.hashes.each do |input_hash|
|
||||
title = slug(input_hash["title"])
|
||||
ext = input_hash["type"] || "markdown"
|
||||
filename = "#{title}.#{ext}" if %w(draft page).include?(status)
|
||||
before, after = location(folder, direction)
|
||||
dest_folder = "_drafts" if status == "draft"
|
||||
dest_folder = "_posts" if status == "post"
|
||||
dest_folder = "" if status == "page"
|
||||
|
||||
if status == "post"
|
||||
parsed_date = Time.xmlschema(input_hash["date"]) rescue Time.parse(input_hash["date"])
|
||||
filename = "#{parsed_date.strftime("%Y-%m-%d")}-#{title}.#{ext}"
|
||||
end
|
||||
|
||||
path = File.join(before, dest_folder, after, filename)
|
||||
File.write(path, file_content_from_hash(input_hash))
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Given(%r!^I have a configuration file with "(.*)" set to "(.*)"$!) do |key, value|
|
||||
config = \
|
||||
if source_dir.join("_config.yml").exist?
|
||||
SafeYAML.load_file(source_dir.join("_config.yml"))
|
||||
else
|
||||
{}
|
||||
end
|
||||
config[key] = YAML.load(value)
|
||||
File.write("_config.yml", YAML.dump(config))
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Given(%r!^I have a configuration file with:$!) do |table|
|
||||
table.hashes.each do |row|
|
||||
step %(I have a configuration file with "#{row["key"]}" set to "#{row["value"]}")
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Given(%r!^I have a configuration file with "([^\"]*)" set to:$!) do |key, table|
|
||||
File.open("_config.yml", "w") do |f|
|
||||
f.write("#{key}:\n")
|
||||
table.hashes.each do |row|
|
||||
f.write("- #{row["value"]}\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Given(%r!^I have fixture collections$!) do
|
||||
FileUtils.cp_r Paths.source_dir.join("test", "source", "_methods"), source_dir
|
||||
FileUtils.cp_r Paths.source_dir.join("test", "source", "_thanksgiving"), source_dir
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Given(%r!^I wait (\d+) second(s?)$!) do |time, _|
|
||||
sleep(time.to_f)
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
When(%r!^I run jekyll(.*)$!) do |args|
|
||||
run_jekyll(args)
|
||||
if args.include?("--verbose") || ENV["DEBUG"]
|
||||
$stderr.puts "\n#{jekyll_run_output}\n"
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
When(%r!^I run bundle(.*)$!) do |args|
|
||||
run_bundle(args)
|
||||
if args.include?("--verbose") || ENV["DEBUG"]
|
||||
$stderr.puts "\n#{jekyll_run_output}\n"
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
When(%r!^I change "(.*)" to contain "(.*)"$!) do |file, text|
|
||||
File.open(file, "a") do |f|
|
||||
f.write(text)
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
When(%r!^I delete the file "(.*)"$!) do |file|
|
||||
File.delete(file)
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Then(%r!^the (.*) directory should +(not )?exist$!) do |dir, negative|
|
||||
if negative.nil?
|
||||
expect(Pathname.new(dir)).to exist
|
||||
else
|
||||
expect(Pathname.new(dir)).to_not exist
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
Then(%r!^I should (not )?see "(.*)" in "(.*)"$!) do |negative, text, file|
|
||||
step %(the "#{file}" file should exist)
|
||||
regexp = Regexp.new(text, Regexp::MULTILINE)
|
||||
if negative.nil? || negative.empty?
|
||||
expect(file_contents(file)).to match regexp
|
||||
else
|
||||
expect(file_contents(file)).not_to match regexp
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Then(%r!^I should see exactly "(.*)" in "(.*)"$!) do |text, file|
|
||||
step %(the "#{file}" file should exist)
|
||||
expect(file_contents(file).strip).to eq text
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Then(%r!^I should see escaped "(.*)" in "(.*)"$!) do |text, file|
|
||||
step %(I should see "#{Regexp.escape(text)}" in "#{file}")
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Then(%r!^the "(.*)" file should +(not )?exist$!) do |file, negative|
|
||||
if negative.nil?
|
||||
expect(Pathname.new(file)).to exist
|
||||
else
|
||||
expect(Pathname.new(file)).to_not exist
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Then(%r!^I should see today's time in "(.*)"$!) do |file|
|
||||
step %(I should see "#{seconds_agnostic_time(Time.now)}" in "#{file}")
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Then(%r!^I should see today's date in "(.*)"$!) do |file|
|
||||
step %(I should see "#{Date.today}" in "#{file}")
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Then(%r!^I should (not )?see "(.*)" in the build output$!) do |negative, text|
|
||||
if negative.nil? || negative.empty?
|
||||
expect(jekyll_run_output).to match Regexp.new(text)
|
||||
else
|
||||
expect(jekyll_run_output).not_to match Regexp.new(text)
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Then(%r!^I should get a zero exit(?:\-| )status$!) do
|
||||
step %(I should see "EXIT STATUS: 0" in the build output)
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
Then(%r!^I should get a non-zero exit(?:\-| )status$!) do
|
||||
step %(I should not see "EXIT STATUS: 0" in the build output)
|
||||
end
|
||||
@@ -1,214 +0,0 @@
|
||||
require "fileutils"
|
||||
require "colorator"
|
||||
require "cucumber/formatter/console"
|
||||
require "cucumber/formatter/io"
|
||||
|
||||
module Jekyll
|
||||
module Cucumber
|
||||
class Formatter
|
||||
attr_accessor :indent, :runtime
|
||||
include ::Cucumber::Formatter::Console
|
||||
include ::Cucumber::Formatter::Io
|
||||
include FileUtils
|
||||
|
||||
CHARS = {
|
||||
:failed => "\u2718".red,
|
||||
:pending => "\u203D".yellow,
|
||||
:undefined => "\u2718".red,
|
||||
:passed => "\u2714".green,
|
||||
:skipped => "\u203D".blue
|
||||
}.freeze
|
||||
|
||||
#
|
||||
|
||||
def initialize(runtime, path_or_io, options)
|
||||
@runtime = runtime
|
||||
@snippets_input = []
|
||||
@io = ensure_io(path_or_io)
|
||||
@prefixes = options[:prefixes] || {}
|
||||
@delayed_messages = []
|
||||
@options = options
|
||||
@exceptions = []
|
||||
@indent = 0
|
||||
@timings = {}
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def before_features(_features)
|
||||
print_profile_information
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def after_features(features)
|
||||
@io.puts
|
||||
print_worst_offenders
|
||||
print_summary(features)
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def before_feature(_feature)
|
||||
@exceptions = []
|
||||
@indent = 0
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def feature_element_timing_key(feature_element)
|
||||
"\"#{feature_element.name.to_s.sub("Scenario: ", "")}\" (#{feature_element.location})"
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def before_feature_element(feature_element)
|
||||
@indent = 2
|
||||
@scenario_indent = 2
|
||||
@timings[feature_element_timing_key(feature_element)] = Time.now
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def after_feature_element(feature_element)
|
||||
@timings[feature_element_timing_key(feature_element)] = Time.now - @timings[feature_element_timing_key(feature_element)]
|
||||
@io.print " (#{@timings[feature_element_timing_key(feature_element)]}s)"
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def tag_name(tag_name); end
|
||||
|
||||
def comment_line(comment_line); end
|
||||
|
||||
def after_tags(tags); end
|
||||
|
||||
#
|
||||
|
||||
def before_background(_background)
|
||||
@scenario_indent = 2
|
||||
@in_background = true
|
||||
@indent = 2
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def after_background(_background)
|
||||
@in_background = nil
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def background_name(keyword, name, source_line, indent)
|
||||
print_feature_element_name(
|
||||
keyword, name, source_line, indent
|
||||
)
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def scenario_name(keyword, name, source_line, indent)
|
||||
print_feature_element_name(
|
||||
keyword, name, source_line, indent
|
||||
)
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def before_step(step)
|
||||
@current_step = step
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
# rubocop:disable Metrics/ParameterLists
|
||||
def before_step_result(_keyword, _step_match, _multiline_arg, status, exception, \
|
||||
_source_indent, background, _file_colon_line)
|
||||
|
||||
@hide_this_step = false
|
||||
if exception
|
||||
if @exceptions.include?(exception)
|
||||
@hide_this_step = true
|
||||
return
|
||||
end
|
||||
|
||||
@exceptions << exception
|
||||
end
|
||||
|
||||
if status != :failed && @in_background ^ background
|
||||
@hide_this_step = true
|
||||
return
|
||||
end
|
||||
|
||||
@status = status
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def step_name(_keyword, _step_match, status, _source_indent, _background, _file_colon_line)
|
||||
@io.print CHARS[status]
|
||||
@io.print " "
|
||||
end
|
||||
# rubocop:enable Metrics/ParameterLists
|
||||
|
||||
#
|
||||
|
||||
def exception(exception, status)
|
||||
return if @hide_this_step
|
||||
|
||||
@io.puts
|
||||
print_exception(exception, status, @indent)
|
||||
@io.flush
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def after_test_step(test_step, result)
|
||||
collect_snippet_data(
|
||||
test_step, result
|
||||
)
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
private
|
||||
def print_feature_element_name(keyword, name, source_line, _indent)
|
||||
@io.puts
|
||||
|
||||
names = name.empty? ? [name] : name.each_line.to_a
|
||||
line = " #{keyword}: #{names[0]}"
|
||||
|
||||
@io.print(source_line) if @options[:source]
|
||||
@io.print(line)
|
||||
@io.print " "
|
||||
@io.flush
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def cell_prefix(status)
|
||||
@prefixes[status]
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def print_worst_offenders
|
||||
@io.puts
|
||||
@io.puts "Worst offenders:"
|
||||
@timings.sort_by { |_f, t| -t }.take(10).each do |(f, t)|
|
||||
@io.puts " #{t}s for #{f}"
|
||||
end
|
||||
@io.puts
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def print_summary(features)
|
||||
@io.puts
|
||||
print_stats(features, @options)
|
||||
print_snippets(@options)
|
||||
print_passing_wip(@options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,166 +0,0 @@
|
||||
require "fileutils"
|
||||
require "jekyll/utils"
|
||||
require "open3"
|
||||
require "time"
|
||||
require "safe_yaml/load"
|
||||
|
||||
class Paths
|
||||
SOURCE_DIR = Pathname.new(File.expand_path("../..", __dir__))
|
||||
def self.test_dir; source_dir.join("tmp", "jekyll"); end
|
||||
|
||||
def self.output_file; test_dir.join("jekyll_output.txt"); end
|
||||
|
||||
def self.status_file; test_dir.join("jekyll_status.txt"); end
|
||||
|
||||
def self.jekyll_bin; source_dir.join("exe", "jekyll"); end
|
||||
|
||||
def self.source_dir; SOURCE_DIR; end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def file_content_from_hash(input_hash)
|
||||
matter_hash = input_hash.reject { |k, _v| k == "content" }
|
||||
matter = matter_hash.map do |k, v|
|
||||
"#{k}: #{v}\n"
|
||||
end
|
||||
|
||||
matter = matter.join.chomp
|
||||
content = \
|
||||
if !input_hash["input"] || !input_hash["filter"]
|
||||
then input_hash["content"]
|
||||
else "{{ #{input_hash["input"]} | " \
|
||||
"#{input_hash["filter"]} }}"
|
||||
end
|
||||
|
||||
Jekyll::Utils.strip_heredoc(<<-EOF)
|
||||
---
|
||||
#{matter.gsub(
|
||||
%r!\n!, "\n "
|
||||
)}
|
||||
---
|
||||
#{content}
|
||||
EOF
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def source_dir(*files)
|
||||
return Paths.test_dir(*files)
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def all_steps_to_path(path)
|
||||
source = source_dir
|
||||
dest = Pathname.new(path).expand_path
|
||||
paths = []
|
||||
|
||||
dest.ascend do |f|
|
||||
break if f == source
|
||||
paths.unshift f.to_s
|
||||
end
|
||||
|
||||
paths
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def jekyll_run_output
|
||||
if Paths.output_file.file?
|
||||
then return Paths.output_file.read
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def jekyll_run_status
|
||||
if Paths.status_file.file?
|
||||
then return Paths.status_file.read
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def run_bundle(args)
|
||||
run_in_shell("bundle", *args.strip.split(" "))
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def run_jekyll(args)
|
||||
args = args.strip.split(" ") # Shellwords?
|
||||
process = run_in_shell("ruby", Paths.jekyll_bin.to_s, *args, "--trace")
|
||||
process.exitstatus.zero?
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def run_in_shell(*args)
|
||||
i, o, e, p = Open3.popen3(*args)
|
||||
out = o.read.strip
|
||||
err = e.read.strip
|
||||
|
||||
[i, o, e].each(&:close)
|
||||
|
||||
File.write(Paths.status_file, p.value.exitstatus)
|
||||
File.open(Paths.output_file, "wb") do |f|
|
||||
f.puts "$ " << args.join(" ")
|
||||
f.puts out
|
||||
f.puts err
|
||||
f.puts "EXIT STATUS: #{p.value.exitstatus}"
|
||||
end
|
||||
|
||||
p.value
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
#
|
||||
|
||||
def slug(title = nil)
|
||||
if !title
|
||||
then Time.now.strftime("%s%9N") # nanoseconds since the Epoch
|
||||
else title.downcase.gsub(%r![^\w]!, " ").strip.gsub(%r!\s+!, "-")
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def location(folder, direction)
|
||||
if folder
|
||||
before = folder if direction == "in"
|
||||
after = folder if direction == "under"
|
||||
end
|
||||
|
||||
[before || ".",
|
||||
after || "."]
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def file_contents(path)
|
||||
return Pathname.new(path).read
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def seconds_agnostic_datetime(datetime = Time.now)
|
||||
date, time, zone = datetime.to_s.split(" ")
|
||||
time = seconds_agnostic_time(time)
|
||||
|
||||
[
|
||||
Regexp.escape(date),
|
||||
"#{time}:\\d{2}",
|
||||
Regexp.escape(zone)
|
||||
] \
|
||||
.join("\\ ")
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def seconds_agnostic_time(time)
|
||||
time = time.strftime("%H:%M:%S") if time.is_a?(Time)
|
||||
hour, minutes, = time.split(":")
|
||||
"#{hour}:#{minutes}"
|
||||
end
|
||||
@@ -1,72 +0,0 @@
|
||||
Feature: Writing themes
|
||||
As a hacker who likes to share my expertise
|
||||
I want to be able to make a gemified theme
|
||||
In order to share my awesome style skillz with other Jekyllites
|
||||
|
||||
Scenario: Generating a new theme scaffold
|
||||
When I run jekyll new-theme my-cool-theme
|
||||
Then I should get a zero exit status
|
||||
And the my-cool-theme directory should exist
|
||||
|
||||
Scenario: Generating a new theme scaffold with a code of conduct
|
||||
When I run jekyll new-theme my-cool-theme --code-of-conduct
|
||||
Then I should get a zero exit status
|
||||
And the my-cool-theme directory should exist
|
||||
And the "my-cool-theme/CODE_OF_CONDUCT.md" file should exist
|
||||
|
||||
Scenario: A theme with SCSS
|
||||
Given I have a configuration file with "theme" set to "test-theme"
|
||||
And I have a css directory
|
||||
And I have a "css/main.scss" page that contains "@import 'test-theme-black';"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see ".sample {\n color: black; }" in "_site/css/main.css"
|
||||
|
||||
Scenario: A theme with an include
|
||||
Given I have a configuration file with "theme" set to "test-theme"
|
||||
And I have an _includes directory
|
||||
And I have an "_includes/in_project.html" file that contains "I'm in the project."
|
||||
And I have an "index.html" page that contains "{% include in_project.html %} {% include include.html %}"
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "I'm in the project." in "_site/index.html"
|
||||
And I should see "<span class=\"sample\">include.html from test-theme</span>" in "_site/index.html"
|
||||
|
||||
Scenario: A theme with a layout
|
||||
Given I have a configuration file with "theme" set to "test-theme"
|
||||
And I have an _layouts directory
|
||||
And I have an "_layouts/post.html" file that contains "post.html from the project: {{ content }}"
|
||||
And I have an "index.html" page with layout "default" that contains "I'm content."
|
||||
And I have a "post.html" page with layout "post" that contains "I'm more content."
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "default.html from test-theme: I'm content." in "_site/index.html"
|
||||
And I should see "post.html from the project: I'm more content." in "_site/post.html"
|
||||
|
||||
Scenario: Complicated site that puts it all together
|
||||
Given I have a configuration file with "theme" set to "test-theme"
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| entry1 | 2016-04-21 | post | I am using a local layout. {% include include.html %} |
|
||||
| entry2 | 2016-04-21 | default | I am using a themed layout. {% include include.html %} {% include in_project.html %} |
|
||||
And I have a _layouts directory
|
||||
And I have a "_layouts/post.html" page with layout "default" that contains "I am a post layout! {{ content }}"
|
||||
And I have an _includes directory
|
||||
And I have an "_includes/in_project.html" file that contains "I am in the project, not the theme."
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit status
|
||||
And the _site directory should exist
|
||||
And I should see "I am in the project, not the theme." in "_site/2016/04/21/entry2.html"
|
||||
And I should see "<span class=\"sample\">include.html from test-theme</span>" in "_site/2016/04/21/entry2.html"
|
||||
And I should see "default.html from test-theme:" in "_site/2016/04/21/entry2.html"
|
||||
And I should see "I am using a themed layout." in "_site/2016/04/21/entry2.html"
|
||||
And I should not see "I am a post layout!" in "_site/2016/04/21/entry2.html"
|
||||
And I should not see "I am in the project, not the theme." in "_site/2016/04/21/entry1.html"
|
||||
And I should see "<span class=\"sample\">include.html from test-theme</span>" in "_site/2016/04/21/entry1.html"
|
||||
And I should see "default.html from test-theme:" in "_site/2016/04/21/entry1.html"
|
||||
And I should see "I am using a local layout." in "_site/2016/04/21/entry1.html"
|
||||
And I should see "I am a post layout!" in "_site/2016/04/21/entry1.html"
|
||||
@@ -1,42 +1,50 @@
|
||||
# coding: utf-8
|
||||
lib = File.expand_path('../lib', __FILE__)
|
||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||
require 'jekyll/version'
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.specification_version = 2 if s.respond_to? :specification_version=
|
||||
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
||||
s.rubygems_version = '2.2.2'
|
||||
s.required_ruby_version = '>= 2.0.0'
|
||||
s.name = %q{jekyll}
|
||||
s.version = "0.4.5"
|
||||
|
||||
s.name = 'jekyll'
|
||||
s.version = Jekyll::VERSION
|
||||
s.license = 'MIT'
|
||||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||
s.authors = ["Tom Preston-Werner"]
|
||||
s.date = %q{2009-03-08}
|
||||
s.default_executable = %q{jekyll}
|
||||
s.description = %q{Jekyll is a simple, blog aware, static site generator.}
|
||||
s.email = %q{tom@mojombo.com}
|
||||
s.executables = ["jekyll"]
|
||||
s.files = ["History.txt", "Rakefile", "README.textile", "TODO", "VERSION.yml", "bin/jekyll", "lib/jekyll", "lib/jekyll/albino.rb", "lib/jekyll/converters", "lib/jekyll/converters/csv.rb", "lib/jekyll/converters/mephisto.rb", "lib/jekyll/converters/mt.rb", "lib/jekyll/converters/textpattern.rb", "lib/jekyll/converters/typo.rb", "lib/jekyll/converters/wordpress.rb", "lib/jekyll/convertible.rb", "lib/jekyll/core_ext.rb", "lib/jekyll/filters.rb", "lib/jekyll/layout.rb", "lib/jekyll/page.rb", "lib/jekyll/post.rb", "lib/jekyll/site.rb", "lib/jekyll/tags", "lib/jekyll/tags/highlight.rb", "lib/jekyll/tags/include.rb", "lib/jekyll.rb", "test/dest", "test/dest/2008", "test/dest/2008/10", "test/dest/2008/10/18", "test/dest/2008/10/18/foo-bar.html", "test/dest/2008/11", "test/dest/2008/11/21", "test/dest/2008/11/21/complex.html", "test/dest/2008/12", "test/dest/2008/12/13", "test/dest/2008/12/13/include.html", "test/dest/2009", "test/dest/2009/01", "test/dest/2009/01/27", "test/dest/2009/01/27/no-categories.html", "test/dest/2009/01/27/no-topics.html", "test/dest/2009/01/27/topic.html", "test/dest/2009/01/27/topics.html", "test/dest/_posts", "test/dest/_posts/2008-02-02-not-published.html", "test/dest/_posts/2008-02-02-published.html", "test/dest/_posts/2008-10-18-foo-bar.html", "test/dest/_posts/2008-11-21-complex.html", "test/dest/_posts/2008-12-03-permalinked-post.html", "test/dest/_posts/2008-12-13-include.html", "test/dest/_posts/2009-01-27-categories.html", "test/dest/_posts/2009-01-27-category.html", "test/dest/_posts/2009-01-27-no-categories.html", "test/dest/_posts/2009-01-27-no-topics.html", "test/dest/_posts/2009-01-27-topic.html", "test/dest/_posts/2009-01-27-topics.html", "test/dest/category", "test/dest/category/2008", "test/dest/category/2008/09", "test/dest/category/2008/09/23", "test/dest/category/2008/09/23/categories.html", "test/dest/category/_posts", "test/dest/category/_posts/2008-9-23-categories.html", "test/dest/css", "test/dest/css/screen.css", "test/dest/foo", "test/dest/foo/2008", "test/dest/foo/2008/12", "test/dest/foo/2008/12/12", "test/dest/foo/2008/12/12/topical-post.html", "test/dest/foo/2009", "test/dest/foo/2009/01", "test/dest/foo/2009/01/27", "test/dest/foo/2009/01/27/category.html", "test/dest/foo/_posts", "test/dest/foo/_posts/bar", "test/dest/foo/_posts/bar/2008-12-12-topical-post.html", "test/dest/foo/bar", "test/dest/foo/bar/baz", "test/dest/foo/bar/baz/2009", "test/dest/foo/bar/baz/2009/01", "test/dest/foo/bar/baz/2009/01/27", "test/dest/foo/bar/baz/2009/01/27/categories.html", "test/dest/index.html", "test/dest/my_category", "test/dest/my_category/permalinked-post", "test/dest/publish_test", "test/dest/publish_test/2008", "test/dest/publish_test/2008/02", "test/dest/publish_test/2008/02/02", "test/dest/publish_test/2008/02/02/published.html", "test/dest/z_category", "test/dest/z_category/2008", "test/dest/z_category/2008/09", "test/dest/z_category/2008/09/23", "test/dest/z_category/2008/09/23/categories.html", "test/dest/z_category/_posts", "test/dest/z_category/_posts/2008-9-23-categories.html", "test/helper.rb", "test/source", "test/source/_includes", "test/source/_includes/sig.markdown", "test/source/_layouts", "test/source/_layouts/default.html", "test/source/_layouts/simple.html", "test/source/_posts", "test/source/_posts/2008-02-02-not-published.textile", "test/source/_posts/2008-02-02-published.textile", "test/source/_posts/2008-10-18-foo-bar.textile", "test/source/_posts/2008-11-21-complex.textile", "test/source/_posts/2008-12-03-permalinked-post.textile", "test/source/_posts/2008-12-13-include.markdown", "test/source/_posts/2009-01-27-categories.textile", "test/source/_posts/2009-01-27-category.textile", "test/source/_posts/2009-01-27-no-categories.textile", "test/source/_posts/2009-01-27-no-topics.textile", "test/source/_posts/2009-01-27-topic.textile", "test/source/_posts/2009-01-27-topics.textile", "test/source/category", "test/source/category/_posts", "test/source/category/_posts/2008-9-23-categories.textile", "test/source/css", "test/source/css/screen.css", "test/source/foo", "test/source/foo/_posts", "test/source/foo/_posts/bar", "test/source/foo/_posts/bar/2008-12-12-topical-post.textile", "test/source/index.html", "test/source/z_category", "test/source/z_category/_posts", "test/source/z_category/_posts/2008-9-23-categories.textile", "test/suite.rb", "test/test_filters.rb", "test/test_generated_site.rb", "test/test_jekyll.rb", "test/test_post.rb", "test/test_site.rb", "test/test_tags.rb"]
|
||||
s.has_rdoc = true
|
||||
s.homepage = %q{http://github.com/mojombo/jekyll}
|
||||
s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
|
||||
s.require_paths = ["lib"]
|
||||
s.rubyforge_project = %q{jekyll}
|
||||
s.rubygems_version = %q{1.3.1}
|
||||
s.summary = %q{Jekyll is a simple, blog aware, static site generator.}
|
||||
|
||||
s.summary = 'A simple, blog aware, static site generator.'
|
||||
s.description = 'Jekyll is a simple, blog aware, static site generator.'
|
||||
if s.respond_to? :specification_version then
|
||||
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
||||
s.specification_version = 2
|
||||
|
||||
s.authors = ['Tom Preston-Werner']
|
||||
s.email = 'tom@mojombo.com'
|
||||
s.homepage = 'https://github.com/jekyll/jekyll'
|
||||
|
||||
all_files = `git ls-files -z`.split("\x0")
|
||||
s.files = all_files.grep(%r{^(exe|lib)/|^.rubocop.yml$})
|
||||
s.executables = all_files.grep(%r{^exe/}) { |f| File.basename(f) }
|
||||
s.bindir = "exe"
|
||||
s.require_paths = ['lib']
|
||||
|
||||
s.rdoc_options = ['--charset=UTF-8']
|
||||
s.extra_rdoc_files = %w[README.markdown LICENSE]
|
||||
|
||||
s.add_runtime_dependency('liquid', '~> 3.0')
|
||||
s.add_runtime_dependency('kramdown', '~> 1.3')
|
||||
s.add_runtime_dependency('mercenary', '~> 0.3.3')
|
||||
s.add_runtime_dependency('safe_yaml', '~> 1.0')
|
||||
s.add_runtime_dependency('colorator', '~> 1.0')
|
||||
s.add_runtime_dependency('rouge', '~> 1.7')
|
||||
s.add_runtime_dependency('jekyll-sass-converter', '~> 1.0')
|
||||
s.add_runtime_dependency('jekyll-watch', '~> 1.1')
|
||||
s.add_runtime_dependency("pathutil", "~> 0.9")
|
||||
s.add_runtime_dependency('addressable', '~> 2.4')
|
||||
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
||||
s.add_runtime_dependency(%q<RedCloth>, [">= 4.0.4"])
|
||||
s.add_runtime_dependency(%q<liquid>, [">= 1.9.0"])
|
||||
s.add_runtime_dependency(%q<classifier>, [">= 1.3.1"])
|
||||
s.add_runtime_dependency(%q<maruku>, [">= 0.5.9"])
|
||||
s.add_runtime_dependency(%q<directory_watcher>, [">= 1.1.1"])
|
||||
s.add_runtime_dependency(%q<open4>, [">= 0.9.6"])
|
||||
else
|
||||
s.add_dependency(%q<RedCloth>, [">= 4.0.4"])
|
||||
s.add_dependency(%q<liquid>, [">= 1.9.0"])
|
||||
s.add_dependency(%q<classifier>, [">= 1.3.1"])
|
||||
s.add_dependency(%q<maruku>, [">= 0.5.9"])
|
||||
s.add_dependency(%q<directory_watcher>, [">= 1.1.1"])
|
||||
s.add_dependency(%q<open4>, [">= 0.9.6"])
|
||||
end
|
||||
else
|
||||
s.add_dependency(%q<RedCloth>, [">= 4.0.4"])
|
||||
s.add_dependency(%q<liquid>, [">= 1.9.0"])
|
||||
s.add_dependency(%q<classifier>, [">= 1.3.1"])
|
||||
s.add_dependency(%q<maruku>, [">= 0.5.9"])
|
||||
s.add_dependency(%q<directory_watcher>, [">= 1.1.1"])
|
||||
s.add_dependency(%q<open4>, [">= 0.9.6"])
|
||||
end
|
||||
end
|
||||
|
||||
235
lib/jekyll.rb
235
lib/jekyll.rb
@@ -1,188 +1,67 @@
|
||||
$LOAD_PATH.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
|
||||
|
||||
# Require all of the Ruby files in the given directory.
|
||||
#
|
||||
# path - The String relative path from here to the directory.
|
||||
#
|
||||
# Returns nothing.
|
||||
def require_all(path)
|
||||
glob = File.join(File.dirname(__FILE__), path, "*.rb")
|
||||
Dir[glob].sort.each do |f|
|
||||
require f
|
||||
end
|
||||
end
|
||||
$:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
|
||||
|
||||
# rubygems
|
||||
require "rubygems"
|
||||
require 'rubygems'
|
||||
|
||||
# core
|
||||
require 'fileutils'
|
||||
require 'time'
|
||||
require 'yaml'
|
||||
|
||||
# stdlib
|
||||
require "pathutil"
|
||||
require "forwardable"
|
||||
require "fileutils"
|
||||
require "time"
|
||||
require "English"
|
||||
require "pathname"
|
||||
require "logger"
|
||||
require "set"
|
||||
|
||||
# 3rd party
|
||||
require "safe_yaml/load"
|
||||
require "liquid"
|
||||
require "kramdown"
|
||||
require "colorator"
|
||||
require 'liquid'
|
||||
require 'redcloth'
|
||||
begin
|
||||
require 'maruku'
|
||||
require 'maruku/ext/math'
|
||||
# Switch off MathML output
|
||||
MaRuKu::Globals[:html_math_output_mathml] = false
|
||||
MaRuKu::Globals[:html_math_engine] = 'none'
|
||||
|
||||
SafeYAML::OPTIONS[:suppress_warnings] = true
|
||||
|
||||
module Jekyll
|
||||
# internal requires
|
||||
autoload :Cleaner, "jekyll/cleaner"
|
||||
autoload :Collection, "jekyll/collection"
|
||||
autoload :Configuration, "jekyll/configuration"
|
||||
autoload :Convertible, "jekyll/convertible"
|
||||
autoload :Deprecator, "jekyll/deprecator"
|
||||
autoload :Document, "jekyll/document"
|
||||
autoload :EntryFilter, "jekyll/entry_filter"
|
||||
autoload :Errors, "jekyll/errors"
|
||||
autoload :Excerpt, "jekyll/excerpt"
|
||||
autoload :External, "jekyll/external"
|
||||
autoload :FrontmatterDefaults, "jekyll/frontmatter_defaults"
|
||||
autoload :Hooks, "jekyll/hooks"
|
||||
autoload :Layout, "jekyll/layout"
|
||||
autoload :CollectionReader, "jekyll/readers/collection_reader"
|
||||
autoload :DataReader, "jekyll/readers/data_reader"
|
||||
autoload :LayoutReader, "jekyll/readers/layout_reader"
|
||||
autoload :PostReader, "jekyll/readers/post_reader"
|
||||
autoload :PageReader, "jekyll/readers/page_reader"
|
||||
autoload :StaticFileReader, "jekyll/readers/static_file_reader"
|
||||
autoload :ThemeAssetsReader, "jekyll/readers/theme_assets_reader"
|
||||
autoload :LogAdapter, "jekyll/log_adapter"
|
||||
autoload :Page, "jekyll/page"
|
||||
autoload :PluginManager, "jekyll/plugin_manager"
|
||||
autoload :Publisher, "jekyll/publisher"
|
||||
autoload :Reader, "jekyll/reader"
|
||||
autoload :Regenerator, "jekyll/regenerator"
|
||||
autoload :RelatedPosts, "jekyll/related_posts"
|
||||
autoload :Renderer, "jekyll/renderer"
|
||||
autoload :LiquidRenderer, "jekyll/liquid_renderer"
|
||||
autoload :Site, "jekyll/site"
|
||||
autoload :StaticFile, "jekyll/static_file"
|
||||
autoload :Stevenson, "jekyll/stevenson"
|
||||
autoload :Theme, "jekyll/theme"
|
||||
autoload :ThemeBuilder, "jekyll/theme_builder"
|
||||
autoload :URL, "jekyll/url"
|
||||
autoload :Utils, "jekyll/utils"
|
||||
autoload :VERSION, "jekyll/version"
|
||||
|
||||
# extensions
|
||||
require "jekyll/plugin"
|
||||
require "jekyll/converter"
|
||||
require "jekyll/generator"
|
||||
require "jekyll/command"
|
||||
require "jekyll/liquid_extensions"
|
||||
require "jekyll/filters"
|
||||
|
||||
class << self
|
||||
# Public: Tells you which Jekyll environment you are building in so you can skip tasks
|
||||
# if you need to. This is useful when doing expensive compression tasks on css and
|
||||
# images and allows you to skip that when working in development.
|
||||
|
||||
def env
|
||||
ENV["JEKYLL_ENV"] || "development"
|
||||
end
|
||||
|
||||
# Public: Generate a Jekyll configuration Hash by merging the default
|
||||
# options with anything in _config.yml, and adding the given options on top.
|
||||
#
|
||||
# override - A Hash of config directives that override any options in both
|
||||
# the defaults and the config file.
|
||||
# See Jekyll::Configuration::DEFAULTS for a
|
||||
# list of option names and their defaults.
|
||||
#
|
||||
# Returns the final configuration Hash.
|
||||
def configuration(override = {})
|
||||
config = Configuration.new
|
||||
override = Configuration[override].stringify_keys
|
||||
unless override.delete("skip_config_files")
|
||||
config = config.read_config_files(config.config_files(override))
|
||||
end
|
||||
|
||||
# Merge DEFAULTS < _config.yml < override
|
||||
Configuration.from(Utils.deep_merge_hashes(config, override)).tap do |obj|
|
||||
set_timezone(obj["timezone"]) if obj["timezone"]
|
||||
end
|
||||
end
|
||||
|
||||
# Public: Set the TZ environment variable to use the timezone specified
|
||||
#
|
||||
# timezone - the IANA Time Zone
|
||||
#
|
||||
# Returns nothing
|
||||
# rubocop:disable Style/AccessorMethodName
|
||||
def set_timezone(timezone)
|
||||
ENV["TZ"] = timezone
|
||||
end
|
||||
# rubocop:enable Style/AccessorMethodName
|
||||
|
||||
# Public: Fetch the logger instance for this Jekyll process.
|
||||
#
|
||||
# Returns the LogAdapter instance.
|
||||
def logger
|
||||
@logger ||= LogAdapter.new(Stevenson.new, (ENV["JEKYLL_LOG_LEVEL"] || :info).to_sym)
|
||||
end
|
||||
|
||||
# Public: Set the log writer.
|
||||
# New log writer must respond to the same methods
|
||||
# as Ruby's interal Logger.
|
||||
#
|
||||
# writer - the new Logger-compatible log transport
|
||||
#
|
||||
# Returns the new logger.
|
||||
def logger=(writer)
|
||||
@logger = LogAdapter.new(writer, (ENV["JEKYLL_LOG_LEVEL"] || :info).to_sym)
|
||||
end
|
||||
|
||||
# Public: An array of sites
|
||||
#
|
||||
# Returns the Jekyll sites created.
|
||||
def sites
|
||||
@sites ||= []
|
||||
end
|
||||
|
||||
# Public: Ensures the questionable path is prefixed with the base directory
|
||||
# and prepends the questionable path with the base directory if false.
|
||||
#
|
||||
# base_directory - the directory with which to prefix the questionable path
|
||||
# questionable_path - the path we're unsure about, and want prefixed
|
||||
#
|
||||
# Returns the sanitized path.
|
||||
def sanitized_path(base_directory, questionable_path)
|
||||
return base_directory if base_directory.eql?(questionable_path)
|
||||
|
||||
questionable_path.insert(0, "/") if questionable_path.start_with?("~")
|
||||
clean_path = File.expand_path(questionable_path, "/")
|
||||
|
||||
return clean_path if clean_path.eql?(base_directory)
|
||||
|
||||
if clean_path.start_with?(base_directory.sub(%r!\z!, "/"))
|
||||
clean_path
|
||||
else
|
||||
clean_path.sub!(%r!\A\w:/!, "/")
|
||||
File.join(base_directory, clean_path)
|
||||
end
|
||||
end
|
||||
|
||||
# Conditional optimizations
|
||||
Jekyll::External.require_if_present("liquid-c")
|
||||
end
|
||||
# Turn on math to PNG support with blahtex
|
||||
# Resulting PNGs stored in `images/latex`
|
||||
MaRuKu::Globals[:html_math_output_png] = true
|
||||
MaRuKu::Globals[:html_png_engine] = 'blahtex'
|
||||
MaRuKu::Globals[:html_png_dir] = 'images/latex'
|
||||
MaRuKu::Globals[:html_png_url] = '/images/latex/'
|
||||
rescue LoadError
|
||||
puts "The maruku gem is required for markdown support!"
|
||||
end
|
||||
|
||||
require "jekyll/drops/drop"
|
||||
require "jekyll/drops/document_drop"
|
||||
require_all "jekyll/commands"
|
||||
require_all "jekyll/converters"
|
||||
require_all "jekyll/converters/markdown"
|
||||
require_all "jekyll/drops"
|
||||
require_all "jekyll/generators"
|
||||
require_all "jekyll/tags"
|
||||
# internal requires
|
||||
require 'jekyll/core_ext'
|
||||
require 'jekyll/site'
|
||||
require 'jekyll/convertible'
|
||||
require 'jekyll/layout'
|
||||
require 'jekyll/page'
|
||||
require 'jekyll/post'
|
||||
require 'jekyll/filters'
|
||||
require 'jekyll/tags/highlight'
|
||||
require 'jekyll/tags/include'
|
||||
require 'jekyll/albino'
|
||||
|
||||
require "jekyll-sass-converter"
|
||||
module Jekyll
|
||||
class << self
|
||||
attr_accessor :source, :dest, :lsi, :pygments, :markdown_proc, :content_type, :permalink_style
|
||||
end
|
||||
|
||||
Jekyll.lsi = false
|
||||
Jekyll.pygments = false
|
||||
Jekyll.markdown_proc = Proc.new { |x| Maruku.new(x).to_html }
|
||||
Jekyll.permalink_style = :date
|
||||
|
||||
def self.process(source, dest)
|
||||
require 'classifier' if Jekyll.lsi
|
||||
|
||||
Jekyll.source = source
|
||||
Jekyll.dest = dest
|
||||
Jekyll::Site.new(source, dest).process
|
||||
end
|
||||
|
||||
def self.version
|
||||
yml = YAML.load(File.read(File.join(File.dirname(__FILE__), *%w[.. VERSION.yml])))
|
||||
"#{yml[:major]}.#{yml[:minor]}.#{yml[:patch]}"
|
||||
end
|
||||
end
|
||||
|
||||
119
lib/jekyll/albino.rb
Normal file
119
lib/jekyll/albino.rb
Normal file
@@ -0,0 +1,119 @@
|
||||
##
|
||||
# Wrapper for the Pygments command line tool, pygmentize.
|
||||
#
|
||||
# Pygments: http://pygments.org/
|
||||
#
|
||||
# Assumes pygmentize is in the path. If not, set its location
|
||||
# with Albino.bin = '/path/to/pygmentize'
|
||||
#
|
||||
# Use like so:
|
||||
#
|
||||
# @syntaxer = Albino.new('/some/file.rb', :ruby)
|
||||
# puts @syntaxer.colorize
|
||||
#
|
||||
# This'll print out an HTMLized, Ruby-highlighted version
|
||||
# of '/some/file.rb'.
|
||||
#
|
||||
# To use another formatter, pass it as the third argument:
|
||||
#
|
||||
# @syntaxer = Albino.new('/some/file.rb', :ruby, :bbcode)
|
||||
# puts @syntaxer.colorize
|
||||
#
|
||||
# You can also use the #colorize class method:
|
||||
#
|
||||
# puts Albino.colorize('/some/file.rb', :ruby)
|
||||
#
|
||||
# Another also: you get a #to_s, for somewhat nicer use in Rails views.
|
||||
#
|
||||
# ... helper file ...
|
||||
# def highlight(text)
|
||||
# Albino.new(text, :ruby)
|
||||
# end
|
||||
#
|
||||
# ... view file ...
|
||||
# <%= highlight text %>
|
||||
#
|
||||
# The default lexer is 'text'. You need to specify a lexer yourself;
|
||||
# because we are using STDIN there is no auto-detect.
|
||||
#
|
||||
# To see all lexers and formatters available, run `pygmentize -L`.
|
||||
#
|
||||
# Chris Wanstrath // chris@ozmm.org
|
||||
# GitHub // http://github.com
|
||||
#
|
||||
require 'open4'
|
||||
|
||||
class Albino
|
||||
@@bin = Rails.development? ? 'pygmentize' : '/usr/bin/pygmentize' rescue 'pygmentize'
|
||||
|
||||
def self.bin=(path)
|
||||
@@bin = path
|
||||
end
|
||||
|
||||
def self.colorize(*args)
|
||||
new(*args).colorize
|
||||
end
|
||||
|
||||
def initialize(target, lexer = :text, format = :html)
|
||||
@target = File.exists?(target) ? File.read(target) : target rescue target
|
||||
@options = { :l => lexer, :f => format }
|
||||
end
|
||||
|
||||
def execute(command)
|
||||
output = ''
|
||||
Open4.popen4(command) do |pid, stdin, stdout, stderr|
|
||||
stdin.puts @target
|
||||
stdin.close
|
||||
output = stdout.read.strip
|
||||
end
|
||||
output
|
||||
end
|
||||
|
||||
def colorize(options = {})
|
||||
execute @@bin + convert_options(options)
|
||||
end
|
||||
alias_method :to_s, :colorize
|
||||
|
||||
def convert_options(options = {})
|
||||
@options.merge(options).inject('') do |string, (flag, value)|
|
||||
string + " -#{flag} #{value}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if $0 == __FILE__
|
||||
require 'rubygems'
|
||||
require 'test/spec'
|
||||
require 'mocha'
|
||||
begin require 'redgreen'; rescue LoadError; end
|
||||
|
||||
context "Albino" do
|
||||
setup do
|
||||
@syntaxer = Albino.new(__FILE__, :ruby)
|
||||
end
|
||||
|
||||
specify "defaults to text" do
|
||||
syntaxer = Albino.new(__FILE__)
|
||||
syntaxer.expects(:execute).with('pygmentize -f html -l text').returns(true)
|
||||
syntaxer.colorize
|
||||
end
|
||||
|
||||
specify "accepts options" do
|
||||
@syntaxer.expects(:execute).with('pygmentize -f html -l ruby').returns(true)
|
||||
@syntaxer.colorize
|
||||
end
|
||||
|
||||
specify "works with strings" do
|
||||
syntaxer = Albino.new('class New; end', :ruby)
|
||||
assert_match %r(highlight), syntaxer.colorize
|
||||
end
|
||||
|
||||
specify "aliases to_s" do
|
||||
assert_equal @syntaxer.colorize, @syntaxer.to_s
|
||||
end
|
||||
|
||||
specify "class method colorize" do
|
||||
assert_equal @syntaxer.colorize, Albino.colorize(__FILE__, :ruby)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,108 +0,0 @@
|
||||
require "set"
|
||||
|
||||
module Jekyll
|
||||
# Handles the cleanup of a site's destination before it is built.
|
||||
class Cleaner
|
||||
HIDDEN_FILE_REGEX = %r!\/\.{1,2}$!
|
||||
attr_reader :site
|
||||
|
||||
def initialize(site)
|
||||
@site = site
|
||||
end
|
||||
|
||||
# Cleans up the site's destination directory
|
||||
def cleanup!
|
||||
FileUtils.rm_rf(obsolete_files)
|
||||
FileUtils.rm_rf(metadata_file) unless @site.incremental?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Private: The list of files and directories to be deleted during cleanup process
|
||||
#
|
||||
# Returns an Array of the file and directory paths
|
||||
def obsolete_files
|
||||
(existing_files - new_files - new_dirs + replaced_files).to_a
|
||||
end
|
||||
|
||||
# Private: The metadata file storing dependency tree and build history
|
||||
#
|
||||
# Returns an Array with the metdata file as the only item
|
||||
def metadata_file
|
||||
[site.regenerator.metadata_file]
|
||||
end
|
||||
|
||||
# Private: The list of existing files, apart from those included in
|
||||
# keep_files and hidden files.
|
||||
#
|
||||
# Returns a Set with the file paths
|
||||
def existing_files
|
||||
files = Set.new
|
||||
regex = keep_file_regex
|
||||
dirs = keep_dirs
|
||||
|
||||
Utils.safe_glob(site.in_dest_dir, ["**", "*"], File::FNM_DOTMATCH).each do |file|
|
||||
next if file =~ HIDDEN_FILE_REGEX || file =~ regex || dirs.include?(file)
|
||||
files << file
|
||||
end
|
||||
|
||||
files
|
||||
end
|
||||
|
||||
# Private: The list of files to be created when site is built.
|
||||
#
|
||||
# Returns a Set with the file paths
|
||||
def new_files
|
||||
files = Set.new
|
||||
site.each_site_file { |item| files << item.destination(site.dest) }
|
||||
files
|
||||
end
|
||||
|
||||
# Private: The list of directories to be created when site is built.
|
||||
# These are the parent directories of the files in #new_files.
|
||||
#
|
||||
# Returns a Set with the directory paths
|
||||
def new_dirs
|
||||
new_files.map { |file| parent_dirs(file) }.flatten.to_set
|
||||
end
|
||||
|
||||
# Private: The list of parent directories of a given file
|
||||
#
|
||||
# Returns an Array with the directory paths
|
||||
def parent_dirs(file)
|
||||
parent_dir = File.dirname(file)
|
||||
if parent_dir == site.dest
|
||||
[]
|
||||
else
|
||||
[parent_dir] + parent_dirs(parent_dir)
|
||||
end
|
||||
end
|
||||
|
||||
# Private: The list of existing files that will be replaced by a directory
|
||||
# during build
|
||||
#
|
||||
# Returns a Set with the file paths
|
||||
def replaced_files
|
||||
new_dirs.select { |dir| File.file?(dir) }.to_set
|
||||
end
|
||||
|
||||
# Private: The list of directories that need to be kept because they are
|
||||
# parent directories of files specified in keep_files
|
||||
#
|
||||
# Returns a Set with the directory paths
|
||||
def keep_dirs
|
||||
site.keep_files.map { |file| parent_dirs(site.in_dest_dir(file)) }.flatten.to_set
|
||||
end
|
||||
|
||||
# Private: Creates a regular expression from the config's keep_files array
|
||||
#
|
||||
# Examples
|
||||
# ['.git','.svn'] with site.dest "/myblog/_site" creates
|
||||
# the following regex: /\A\/myblog\/_site\/(\.git|\/.svn)/
|
||||
#
|
||||
# Returns the regular expression
|
||||
def keep_file_regex
|
||||
%r!\A#{Regexp.quote(site.dest)}\/(#{Regexp.union(site.keep_files).source})!
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,221 +0,0 @@
|
||||
module Jekyll
|
||||
class Collection
|
||||
attr_reader :site, :label, :metadata
|
||||
attr_writer :docs
|
||||
|
||||
# Create a new Collection.
|
||||
#
|
||||
# site - the site to which this collection belongs.
|
||||
# label - the name of the collection
|
||||
#
|
||||
# Returns nothing.
|
||||
def initialize(site, label)
|
||||
@site = site
|
||||
@label = sanitize_label(label)
|
||||
@metadata = extract_metadata
|
||||
end
|
||||
|
||||
# Fetch the Documents in this collection.
|
||||
# Defaults to an empty array if no documents have been read in.
|
||||
#
|
||||
# Returns an array of Jekyll::Document objects.
|
||||
def docs
|
||||
@docs ||= []
|
||||
end
|
||||
|
||||
# Override of normal respond_to? to match method_missing's logic for
|
||||
# looking in @data.
|
||||
def respond_to_missing?(method, include_private = false)
|
||||
docs.respond_to?(method.to_sym, include_private) || super
|
||||
end
|
||||
|
||||
# Override of method_missing to check in @data for the key.
|
||||
def method_missing(method, *args, &blck)
|
||||
if docs.respond_to?(method.to_sym)
|
||||
Jekyll.logger.warn "Deprecation:", "#{label}.#{method} should be changed to" \
|
||||
"#{label}.docs.#{method}."
|
||||
Jekyll.logger.warn "", "Called by #{caller.first}."
|
||||
docs.public_send(method.to_sym, *args, &blck)
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
# Fetch the static files in this collection.
|
||||
# Defaults to an empty array if no static files have been read in.
|
||||
#
|
||||
# Returns an array of Jekyll::StaticFile objects.
|
||||
def files
|
||||
@files ||= []
|
||||
end
|
||||
|
||||
# Read the allowed documents into the collection's array of docs.
|
||||
#
|
||||
# Returns the sorted array of docs.
|
||||
def read
|
||||
filtered_entries.each do |file_path|
|
||||
full_path = collection_dir(file_path)
|
||||
next if File.directory?(full_path)
|
||||
if Utils.has_yaml_header? full_path
|
||||
read_document(full_path)
|
||||
else
|
||||
read_static_file(file_path, full_path)
|
||||
end
|
||||
end
|
||||
docs.sort!
|
||||
end
|
||||
|
||||
# All the entries in this collection.
|
||||
#
|
||||
# Returns an Array of file paths to the documents in this collection
|
||||
# relative to the collection's directory
|
||||
def entries
|
||||
return [] unless exists?
|
||||
@entries ||=
|
||||
Utils.safe_glob(collection_dir, ["**", "*"]).map do |entry|
|
||||
entry["#{collection_dir}/"] = ""
|
||||
entry
|
||||
end
|
||||
end
|
||||
|
||||
# Filtered version of the entries in this collection.
|
||||
# See `Jekyll::EntryFilter#filter` for more information.
|
||||
#
|
||||
# Returns a list of filtered entry paths.
|
||||
def filtered_entries
|
||||
return [] unless exists?
|
||||
@filtered_entries ||=
|
||||
Dir.chdir(directory) do
|
||||
entry_filter.filter(entries).reject do |f|
|
||||
path = collection_dir(f)
|
||||
File.directory?(path) || entry_filter.symlink?(f)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# The directory for this Collection, relative to the site source.
|
||||
#
|
||||
# Returns a String containing the directory name where the collection
|
||||
# is stored on the filesystem.
|
||||
def relative_directory
|
||||
@relative_directory ||= "_#{label}"
|
||||
end
|
||||
|
||||
# The full path to the directory containing the collection.
|
||||
#
|
||||
# Returns a String containing th directory name where the collection
|
||||
# is stored on the filesystem.
|
||||
def directory
|
||||
@directory ||= site.in_source_dir(relative_directory)
|
||||
end
|
||||
|
||||
# The full path to the directory containing the collection, with
|
||||
# optional subpaths.
|
||||
#
|
||||
# *files - (optional) any other path pieces relative to the
|
||||
# directory to append to the path
|
||||
#
|
||||
# Returns a String containing th directory name where the collection
|
||||
# is stored on the filesystem.
|
||||
def collection_dir(*files)
|
||||
return directory if files.empty?
|
||||
site.in_source_dir(relative_directory, *files)
|
||||
end
|
||||
|
||||
# Checks whether the directory "exists" for this collection.
|
||||
# The directory must exist on the filesystem and must not be a symlink
|
||||
# if in safe mode.
|
||||
#
|
||||
# Returns false if the directory doesn't exist or if it's a symlink
|
||||
# and we're in safe mode.
|
||||
def exists?
|
||||
File.directory?(directory) && !entry_filter.symlink?(directory)
|
||||
end
|
||||
|
||||
# The entry filter for this collection.
|
||||
# Creates an instance of Jekyll::EntryFilter.
|
||||
#
|
||||
# Returns the instance of Jekyll::EntryFilter for this collection.
|
||||
def entry_filter
|
||||
@entry_filter ||= Jekyll::EntryFilter.new(site, relative_directory)
|
||||
end
|
||||
|
||||
# An inspect string.
|
||||
#
|
||||
# Returns the inspect string
|
||||
def inspect
|
||||
"#<Jekyll::Collection @label=#{label} docs=#{docs}>"
|
||||
end
|
||||
|
||||
# Produce a sanitized label name
|
||||
# Label names may not contain anything but alphanumeric characters,
|
||||
# underscores, and hyphens.
|
||||
#
|
||||
# label - the possibly-unsafe label
|
||||
#
|
||||
# Returns a sanitized version of the label.
|
||||
def sanitize_label(label)
|
||||
label.gsub(%r![^a-z0-9_\-\.]!i, "")
|
||||
end
|
||||
|
||||
# Produce a representation of this Collection for use in Liquid.
|
||||
# Exposes two attributes:
|
||||
# - label
|
||||
# - docs
|
||||
#
|
||||
# Returns a representation of this collection for use in Liquid.
|
||||
def to_liquid
|
||||
Drops::CollectionDrop.new self
|
||||
end
|
||||
|
||||
# Whether the collection's documents ought to be written as individual
|
||||
# files in the output.
|
||||
#
|
||||
# Returns true if the 'write' metadata is true, false otherwise.
|
||||
def write?
|
||||
!!metadata.fetch("output", false)
|
||||
end
|
||||
|
||||
# The URL template to render collection's documents at.
|
||||
#
|
||||
# Returns the URL template to render collection's documents at.
|
||||
def url_template
|
||||
@url_template ||= metadata.fetch("permalink") do
|
||||
Utils.add_permalink_suffix("/:collection/:path", site.permalink_style)
|
||||
end
|
||||
end
|
||||
|
||||
# Extract options for this collection from the site configuration.
|
||||
#
|
||||
# Returns the metadata for this collection
|
||||
def extract_metadata
|
||||
if site.config["collections"].is_a?(Hash)
|
||||
site.config["collections"][label] || {}
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def read_document(full_path)
|
||||
doc = Jekyll::Document.new(full_path, :site => site, :collection => self)
|
||||
doc.read
|
||||
if site.publisher.publish?(doc) || !write?
|
||||
docs << doc
|
||||
else
|
||||
Jekyll.logger.debug "Skipped From Publishing:", doc.relative_path
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def read_static_file(file_path, full_path)
|
||||
relative_dir = Jekyll.sanitized_path(
|
||||
relative_directory,
|
||||
File.dirname(file_path)
|
||||
).chomp("/.")
|
||||
|
||||
files << StaticFile.new(site, site.source, relative_dir,
|
||||
File.basename(full_path), self)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,71 +0,0 @@
|
||||
module Jekyll
|
||||
class Command
|
||||
class << self
|
||||
# A list of subclasses of Jekyll::Command
|
||||
def subclasses
|
||||
@subclasses ||= []
|
||||
end
|
||||
|
||||
# Keep a list of subclasses of Jekyll::Command every time it's inherited
|
||||
# Called automatically.
|
||||
#
|
||||
# base - the subclass
|
||||
#
|
||||
# Returns nothing
|
||||
def inherited(base)
|
||||
subclasses << base
|
||||
super(base)
|
||||
end
|
||||
|
||||
# Run Site#process and catch errors
|
||||
#
|
||||
# site - the Jekyll::Site object
|
||||
#
|
||||
# Returns nothing
|
||||
def process_site(site)
|
||||
site.process
|
||||
rescue Jekyll::Errors::FatalException => e
|
||||
Jekyll.logger.error "ERROR:", "YOUR SITE COULD NOT BE BUILT:"
|
||||
Jekyll.logger.error "", "------------------------------------"
|
||||
Jekyll.logger.error "", e.message
|
||||
exit(1)
|
||||
end
|
||||
|
||||
# Create a full Jekyll configuration with the options passed in as overrides
|
||||
#
|
||||
# options - the configuration overrides
|
||||
#
|
||||
# Returns a full Jekyll configuration
|
||||
def configuration_from_options(options)
|
||||
Jekyll.configuration(options)
|
||||
end
|
||||
|
||||
# Add common options to a command for building configuration
|
||||
#
|
||||
# c - the Jekyll::Command to add these options to
|
||||
#
|
||||
# Returns nothing
|
||||
def add_build_options(c)
|
||||
c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]",
|
||||
Array, "Custom configuration file"
|
||||
c.option "destination", "-d", "--destination DESTINATION",
|
||||
"The current folder will be generated into DESTINATION"
|
||||
c.option "source", "-s", "--source SOURCE", "Custom source directory"
|
||||
c.option "future", "--future", "Publishes posts with a future date"
|
||||
c.option "limit_posts", "--limit_posts MAX_POSTS", Integer,
|
||||
"Limits the number of posts to parse and publish"
|
||||
c.option "watch", "-w", "--[no-]watch", "Watch for changes and rebuild"
|
||||
c.option "baseurl", "-b", "--baseurl URL",
|
||||
"Serve the website from the given base URL"
|
||||
c.option "force_polling", "--force_polling", "Force watch to use polling"
|
||||
c.option "lsi", "--lsi", "Use LSI for improved related posts"
|
||||
c.option "show_drafts", "-D", "--drafts", "Render posts in the _drafts folder"
|
||||
c.option "unpublished", "--unpublished",
|
||||
"Render posts that were marked as unpublished"
|
||||
c.option "quiet", "-q", "--quiet", "Silence output."
|
||||
c.option "verbose", "-V", "--verbose", "Print verbose output."
|
||||
c.option "incremental", "-I", "--incremental", "Enable incremental rebuild."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,96 +0,0 @@
|
||||
module Jekyll
|
||||
module Commands
|
||||
class Build < Command
|
||||
class << self
|
||||
# Create the Mercenary command for the Jekyll CLI for this Command
|
||||
def init_with_program(prog)
|
||||
prog.command(:build) do |c|
|
||||
c.syntax "build [options]"
|
||||
c.description "Build your site"
|
||||
c.alias :b
|
||||
|
||||
add_build_options(c)
|
||||
|
||||
c.action do |_, options|
|
||||
options["serving"] = false
|
||||
Jekyll::Commands::Build.process(options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Build your jekyll site
|
||||
# Continuously watch if `watch` is set to true in the config.
|
||||
def process(options)
|
||||
# Adjust verbosity quickly
|
||||
Jekyll.logger.adjust_verbosity(options)
|
||||
|
||||
options = configuration_from_options(options)
|
||||
site = Jekyll::Site.new(options)
|
||||
|
||||
if options.fetch("skip_initial_build", false)
|
||||
Jekyll.logger.warn "Build Warning:", "Skipping the initial build." \
|
||||
" This may result in an out-of-date site."
|
||||
else
|
||||
build(site, options)
|
||||
end
|
||||
|
||||
if options.fetch("detach", false)
|
||||
Jekyll.logger.info "Auto-regeneration:",
|
||||
"disabled when running server detached."
|
||||
elsif options.fetch("watch", false)
|
||||
watch(site, options)
|
||||
else
|
||||
Jekyll.logger.info "Auto-regeneration:", "disabled. Use --watch to enable."
|
||||
end
|
||||
end
|
||||
|
||||
# Build your Jekyll site.
|
||||
#
|
||||
# site - the Jekyll::Site instance to build
|
||||
# options - A Hash of options passed to the command
|
||||
#
|
||||
# Returns nothing.
|
||||
def build(site, options)
|
||||
t = Time.now
|
||||
source = options["source"]
|
||||
destination = options["destination"]
|
||||
incremental = options["incremental"]
|
||||
Jekyll.logger.info "Source:", source
|
||||
Jekyll.logger.info "Destination:", destination
|
||||
Jekyll.logger.info "Incremental build:",
|
||||
(incremental ? "enabled" : "disabled. Enable with --incremental")
|
||||
Jekyll.logger.info "Generating..."
|
||||
process_site(site)
|
||||
Jekyll.logger.info "", "done in #{(Time.now - t).round(3)} seconds."
|
||||
end
|
||||
|
||||
# Private: Watch for file changes and rebuild the site.
|
||||
#
|
||||
# site - A Jekyll::Site instance
|
||||
# options - A Hash of options passed to the command
|
||||
#
|
||||
# Returns nothing.
|
||||
def watch(site, options)
|
||||
if Utils::Platforms.windows?
|
||||
Jekyll.logger.warn "", "--watch arg is unsupported on Windows. "
|
||||
Jekyll.logger.warn "", "If you are on Windows Bash, please see: " \
|
||||
"https://github.com/Microsoft/BashOnWindows/issues/216"
|
||||
|
||||
else
|
||||
External.require_with_graceful_fail "jekyll-watch"
|
||||
watch_method = Jekyll::Watcher.method(:watch)
|
||||
if watch_method.parameters.size == 1
|
||||
watch_method.call(
|
||||
options
|
||||
)
|
||||
else
|
||||
watch_method.call(
|
||||
options, site
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end # end of class << self
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,41 +0,0 @@
|
||||
module Jekyll
|
||||
module Commands
|
||||
class Clean < Command
|
||||
class << self
|
||||
def init_with_program(prog)
|
||||
prog.command(:clean) do |c|
|
||||
c.syntax "clean [subcommand]"
|
||||
c.description "Clean the site " \
|
||||
"(removes site output and metadata file) without building."
|
||||
|
||||
add_build_options(c)
|
||||
|
||||
c.action do |_, options|
|
||||
Jekyll::Commands::Clean.process(options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def process(options)
|
||||
options = configuration_from_options(options)
|
||||
destination = options["destination"]
|
||||
metadata_file = File.join(options["source"], ".jekyll-metadata")
|
||||
sass_cache = File.join(options["source"], ".sass-cache")
|
||||
|
||||
remove(destination, :checker_func => :directory?)
|
||||
remove(metadata_file, :checker_func => :file?)
|
||||
remove(sass_cache, :checker_func => :directory?)
|
||||
end
|
||||
|
||||
def remove(filename, checker_func: :file?)
|
||||
if File.public_send(checker_func, filename)
|
||||
Jekyll.logger.info "Cleaner:", "Removing #{filename}..."
|
||||
FileUtils.rm_rf(filename)
|
||||
else
|
||||
Jekyll.logger.info "Cleaner:", "Nothing to do for #{filename}."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,116 +0,0 @@
|
||||
module Jekyll
|
||||
module Commands
|
||||
class Doctor < Command
|
||||
class << self
|
||||
def init_with_program(prog)
|
||||
prog.command(:doctor) do |c|
|
||||
c.syntax "doctor"
|
||||
c.description "Search site and print specific deprecation warnings"
|
||||
c.alias(:hyde)
|
||||
|
||||
c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array,
|
||||
"Custom configuration file"
|
||||
|
||||
c.action do |_, options|
|
||||
Jekyll::Commands::Doctor.process(options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def process(options)
|
||||
site = Jekyll::Site.new(configuration_from_options(options))
|
||||
site.reset
|
||||
site.read
|
||||
site.generate
|
||||
|
||||
if healthy?(site)
|
||||
Jekyll.logger.info "Your test results", "are in. Everything looks fine."
|
||||
else
|
||||
abort
|
||||
end
|
||||
end
|
||||
|
||||
def healthy?(site)
|
||||
[
|
||||
fsnotify_buggy?(site),
|
||||
!deprecated_relative_permalinks(site),
|
||||
!conflicting_urls(site),
|
||||
!urls_only_differ_by_case(site)
|
||||
].all?
|
||||
end
|
||||
|
||||
def deprecated_relative_permalinks(site)
|
||||
if site.config["relative_permalinks"]
|
||||
Jekyll::Deprecator.deprecation_message "Your site still uses relative" \
|
||||
" permalinks, which was removed in" \
|
||||
" Jekyll v3.0.0."
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
def conflicting_urls(site)
|
||||
conflicting_urls = false
|
||||
urls = {}
|
||||
urls = collect_urls(urls, site.pages, site.dest)
|
||||
urls = collect_urls(urls, site.posts.docs, site.dest)
|
||||
urls.each do |url, paths|
|
||||
next unless paths.size > 1
|
||||
conflicting_urls = true
|
||||
Jekyll.logger.warn "Conflict:", "The URL '#{url}' is the destination" \
|
||||
" for the following pages: #{paths.join(", ")}"
|
||||
end
|
||||
conflicting_urls
|
||||
end
|
||||
|
||||
def fsnotify_buggy?(_site)
|
||||
return true unless Utils::Platforms.osx?
|
||||
if Dir.pwd != `pwd`.strip
|
||||
Jekyll.logger.error " " + <<-STR.strip.gsub(%r!\n\s+!, "\n ")
|
||||
We have detected that there might be trouble using fsevent on your
|
||||
operating system, you can read https://github.com/thibaudgg/rb-fsevent/wiki/no-fsevents-fired-(OSX-bug)
|
||||
for possible work arounds or you can work around it immediately
|
||||
with `--force-polling`.
|
||||
STR
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
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.each do |_case_insensitive_url, real_urls|
|
||||
next unless real_urls.uniq.size > 1
|
||||
urls_only_differ_by_case = true
|
||||
Jekyll.logger.warn "Warning:", "The following URLs only differ" \
|
||||
" by case. On a case-insensitive file system one of the URLs" \
|
||||
" will be overwritten by the other: #{real_urls.join(", ")}"
|
||||
end
|
||||
urls_only_differ_by_case
|
||||
end
|
||||
|
||||
private
|
||||
def collect_urls(urls, things, destination)
|
||||
things.each do |thing|
|
||||
dest = thing.destination(destination)
|
||||
if urls[dest]
|
||||
urls[dest] << thing.path
|
||||
else
|
||||
urls[dest] = [thing.path]
|
||||
end
|
||||
end
|
||||
urls
|
||||
end
|
||||
|
||||
def case_insensitive_urls(things, destination)
|
||||
things.each_with_object({}) do |thing, memo|
|
||||
dest = thing.destination(destination)
|
||||
(memo[dest.downcase] ||= []) << dest
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,32 +0,0 @@
|
||||
module Jekyll
|
||||
module Commands
|
||||
class Help < Command
|
||||
class << self
|
||||
def init_with_program(prog)
|
||||
prog.command(:help) do |c|
|
||||
c.syntax "help [subcommand]"
|
||||
c.description "Show the help message, optionally for a given subcommand."
|
||||
|
||||
c.action do |args, _|
|
||||
cmd = (args.first || "").to_sym
|
||||
if args.empty?
|
||||
puts prog
|
||||
elsif prog.has_command? cmd
|
||||
puts prog.commands[cmd]
|
||||
else
|
||||
invalid_command(prog, cmd)
|
||||
abort
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def invalid_command(prog, cmd)
|
||||
Jekyll.logger.error "Error:",
|
||||
"Hmm... we don't know what the '#{cmd}' command is."
|
||||
Jekyll.logger.info "Valid commands:", prog.commands.keys.join(", ")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,146 +0,0 @@
|
||||
require "erb"
|
||||
|
||||
module Jekyll
|
||||
module Commands
|
||||
class New < Command
|
||||
class << self
|
||||
def init_with_program(prog)
|
||||
prog.command(:new) do |c|
|
||||
c.syntax "new PATH"
|
||||
c.description "Creates a new Jekyll site scaffold in PATH"
|
||||
|
||||
c.option "force", "--force", "Force creation even if PATH already exists"
|
||||
c.option "blank", "--blank", "Creates scaffolding but with empty files"
|
||||
c.option "skip-bundle", "--skip-bundle", "Skip 'bundle install'"
|
||||
|
||||
c.action do |args, options|
|
||||
Jekyll::Commands::New.process(args, options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def process(args, options = {})
|
||||
raise ArgumentError, "You must specify a path." if args.empty?
|
||||
|
||||
new_blog_path = File.expand_path(args.join(" "), Dir.pwd)
|
||||
FileUtils.mkdir_p new_blog_path
|
||||
if preserve_source_location?(new_blog_path, options)
|
||||
Jekyll.logger.abort_with "Conflict:",
|
||||
"#{new_blog_path} exists and is not empty."
|
||||
end
|
||||
|
||||
if options["blank"]
|
||||
create_blank_site new_blog_path
|
||||
else
|
||||
create_site new_blog_path
|
||||
end
|
||||
|
||||
after_install(new_blog_path, options)
|
||||
end
|
||||
|
||||
def create_blank_site(path)
|
||||
Dir.chdir(path) do
|
||||
FileUtils.mkdir(%w(_layouts _posts _drafts))
|
||||
FileUtils.touch("index.html")
|
||||
end
|
||||
end
|
||||
|
||||
def scaffold_post_content
|
||||
ERB.new(File.read(File.expand_path(scaffold_path, site_template))).result
|
||||
end
|
||||
|
||||
# Internal: Gets the filename of the sample post to be created
|
||||
#
|
||||
# Returns the filename of the sample post, as a String
|
||||
def initialized_post_name
|
||||
"_posts/#{Time.now.strftime("%Y-%m-%d")}-welcome-to-jekyll.markdown"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def gemfile_contents
|
||||
<<-RUBY
|
||||
source "https://rubygems.org"
|
||||
ruby RUBY_VERSION
|
||||
|
||||
# Hello! This is where you manage which Jekyll version is used to run.
|
||||
# When you want to use a different version, change it below, save the
|
||||
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
|
||||
#
|
||||
# bundle exec jekyll serve
|
||||
#
|
||||
# This will help ensure the proper Jekyll version is running.
|
||||
# Happy Jekylling!
|
||||
gem "jekyll", "#{Jekyll::VERSION}"
|
||||
|
||||
# This is the default theme for new Jekyll sites. You may change this to anything you like.
|
||||
gem "minima", "~> 2.0"
|
||||
|
||||
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
|
||||
# uncomment the line below. To upgrade, run `bundle update github-pages`.
|
||||
# gem "github-pages", group: :jekyll_plugins
|
||||
|
||||
# If you have any plugins, put them here!
|
||||
group :jekyll_plugins do
|
||||
gem "jekyll-feed", "~> 0.6"
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
|
||||
def create_site(new_blog_path)
|
||||
create_sample_files new_blog_path
|
||||
|
||||
File.open(File.expand_path(initialized_post_name, new_blog_path), "w") do |f|
|
||||
f.write(scaffold_post_content)
|
||||
end
|
||||
|
||||
File.open(File.expand_path("Gemfile", new_blog_path), "w") do |f|
|
||||
f.write(gemfile_contents)
|
||||
end
|
||||
end
|
||||
|
||||
def preserve_source_location?(path, options)
|
||||
!options["force"] && !Dir["#{path}/**/*"].empty?
|
||||
end
|
||||
|
||||
def create_sample_files(path)
|
||||
FileUtils.cp_r site_template + "/.", path
|
||||
FileUtils.rm File.expand_path(scaffold_path, path)
|
||||
end
|
||||
|
||||
def site_template
|
||||
File.expand_path("../../site_template", File.dirname(__FILE__))
|
||||
end
|
||||
|
||||
def scaffold_path
|
||||
"_posts/0000-00-00-welcome-to-jekyll.markdown.erb"
|
||||
end
|
||||
|
||||
# After a new blog has been created, print a success notification and
|
||||
# then automatically execute bundle install from within the new blog dir
|
||||
# unless the user opts to generate a blank blog or skip 'bundle install'.
|
||||
|
||||
def after_install(path, options = {})
|
||||
Jekyll.logger.info "New jekyll site installed in #{path.cyan}."
|
||||
Jekyll.logger.info "Bundle install skipped." if options["skip-bundle"]
|
||||
|
||||
unless options["blank"] || options["skip-bundle"]
|
||||
bundle_install path
|
||||
end
|
||||
end
|
||||
|
||||
def bundle_install(path)
|
||||
Jekyll::External.require_with_graceful_fail "bundler"
|
||||
Jekyll.logger.info "Running bundle install in #{path.cyan}..."
|
||||
Dir.chdir(path) do
|
||||
if ENV["CI"]
|
||||
system("bundle", "install", "--quiet")
|
||||
else
|
||||
system("bundle", "install")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,38 +0,0 @@
|
||||
require "erb"
|
||||
|
||||
class Jekyll::Commands::NewTheme < Jekyll::Command
|
||||
class << self
|
||||
def init_with_program(prog)
|
||||
prog.command(:"new-theme") do |c|
|
||||
c.syntax "new-theme NAME"
|
||||
c.description "Creates a new Jekyll theme scaffold"
|
||||
c.option "code_of_conduct", \
|
||||
"-c", "--code-of-conduct", \
|
||||
"Include a Code of Conduct. (defaults to false)"
|
||||
|
||||
c.action do |args, opts|
|
||||
Jekyll::Commands::NewTheme.process(args, opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def process(args, opts)
|
||||
if !args || args.empty?
|
||||
raise Jekyll::Errors::InvalidThemeName, "You must specify a theme name."
|
||||
end
|
||||
|
||||
new_theme_name = args.join("_")
|
||||
theme = Jekyll::ThemeBuilder.new(new_theme_name, opts)
|
||||
if theme.path.exist?
|
||||
Jekyll.logger.abort_with "Conflict:", "#{theme.path} already exists."
|
||||
end
|
||||
|
||||
theme.create!
|
||||
Jekyll.logger.info "Your new Jekyll theme, #{theme.name.cyan}," \
|
||||
" is ready for you in #{theme.path.to_s.cyan}!"
|
||||
Jekyll.logger.info "For help getting started, read #{theme.path}/README.md."
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
end
|
||||
end
|
||||
@@ -1,242 +0,0 @@
|
||||
module Jekyll
|
||||
module Commands
|
||||
class Serve < Command
|
||||
class << self
|
||||
COMMAND_OPTIONS = {
|
||||
"ssl_cert" => ["--ssl-cert [CERT]", "X.509 (SSL) certificate."],
|
||||
"host" => ["host", "-H", "--host [HOST]", "Host to bind to"],
|
||||
"open_url" => ["-o", "--open-url", "Launch your site in a browser"],
|
||||
"detach" => ["-B", "--detach", "Run the server in the background"],
|
||||
"ssl_key" => ["--ssl-key [KEY]", "X.509 (SSL) Private Key."],
|
||||
"port" => ["-P", "--port [PORT]", "Port to listen on"],
|
||||
"show_dir_listing" => ["--show-dir-listing",
|
||||
"Show a directory listing instead of loading your index file."],
|
||||
"skip_initial_build" => ["skip_initial_build", "--skip-initial-build",
|
||||
"Skips the initial site build which occurs before the server is started."]
|
||||
}.freeze
|
||||
|
||||
#
|
||||
|
||||
def init_with_program(prog)
|
||||
prog.command(:serve) do |cmd|
|
||||
cmd.description "Serve your site locally"
|
||||
cmd.syntax "serve [options]"
|
||||
cmd.alias :server
|
||||
cmd.alias :s
|
||||
|
||||
add_build_options(cmd)
|
||||
COMMAND_OPTIONS.each do |key, val|
|
||||
cmd.option key, *val
|
||||
end
|
||||
|
||||
cmd.action do |_, opts|
|
||||
opts["serving"] = true
|
||||
opts["watch" ] = true unless opts.key?("watch")
|
||||
config = opts["config"]
|
||||
opts["url"] = default_url(opts) if Jekyll.env == "development"
|
||||
Build.process(opts)
|
||||
opts["config"] = config
|
||||
Serve.process(opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def process(opts)
|
||||
opts = configuration_from_options(opts)
|
||||
destination = opts["destination"]
|
||||
setup(destination)
|
||||
|
||||
start_up_webrick(opts, destination)
|
||||
end
|
||||
|
||||
# Do a base pre-setup of WEBRick so that everything is in place
|
||||
# when we get ready to party, checking for an setting up an error page
|
||||
# and making sure our destination exists.
|
||||
|
||||
private
|
||||
def setup(destination)
|
||||
require_relative "serve/servlet"
|
||||
|
||||
FileUtils.mkdir_p(destination)
|
||||
if File.exist?(File.join(destination, "404.html"))
|
||||
WEBrick::HTTPResponse.class_eval do
|
||||
def create_error_page
|
||||
@header["Content-Type"] = "text/html; charset=UTF-8"
|
||||
@body = IO.read(File.join(@config[:DocumentRoot], "404.html"))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
private
|
||||
def webrick_opts(opts)
|
||||
opts = {
|
||||
:JekyllOptions => opts,
|
||||
:DoNotReverseLookup => true,
|
||||
:MimeTypes => mime_types,
|
||||
:DocumentRoot => opts["destination"],
|
||||
:StartCallback => start_callback(opts["detach"]),
|
||||
:BindAddress => opts["host"],
|
||||
:Port => opts["port"],
|
||||
:DirectoryIndex => %W(
|
||||
index.htm
|
||||
index.html
|
||||
index.rhtml
|
||||
index.cgi
|
||||
index.xml
|
||||
)
|
||||
}
|
||||
|
||||
opts[:DirectoryIndex] = [] if opts[:JekyllOptions]["show_dir_listing"]
|
||||
|
||||
enable_ssl(opts)
|
||||
enable_logging(opts)
|
||||
opts
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
private
|
||||
def start_up_webrick(opts, destination)
|
||||
server = WEBrick::HTTPServer.new(webrick_opts(opts)).tap { |o| o.unmount("") }
|
||||
server.mount(opts["baseurl"], Servlet, destination, file_handler_opts)
|
||||
Jekyll.logger.info "Server address:", server_address(server, opts)
|
||||
launch_browser server, opts if opts["open_url"]
|
||||
boot_or_detach server, opts
|
||||
end
|
||||
|
||||
# Recreate NondisclosureName under utf-8 circumstance
|
||||
|
||||
private
|
||||
def file_handler_opts
|
||||
WEBrick::Config::FileHandler.merge({
|
||||
:FancyIndexing => true,
|
||||
:NondisclosureName => [
|
||||
".ht*", "~*"
|
||||
]
|
||||
})
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
private
|
||||
def server_address(server, options = {})
|
||||
format_url(
|
||||
server.config[:SSLEnable],
|
||||
server.config[:BindAddress],
|
||||
server.config[:Port],
|
||||
options["baseurl"]
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
def format_url(ssl_enabled, address, port, baseurl = nil)
|
||||
format("%{prefix}://%{address}:%{port}%{baseurl}", {
|
||||
:prefix => ssl_enabled ? "https" : "http",
|
||||
:address => address,
|
||||
:port => port,
|
||||
:baseurl => baseurl ? "#{baseurl}/" : ""
|
||||
})
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
private
|
||||
def default_url(opts)
|
||||
config = configuration_from_options(opts)
|
||||
format_url(
|
||||
config["ssl_cert"] && config["ssl_key"],
|
||||
config["host"] == "127.0.0.1" ? "localhost" : config["host"],
|
||||
config["port"]
|
||||
)
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
private
|
||||
def launch_browser(server, opts)
|
||||
address = server_address(server, opts)
|
||||
return system "start", address if Utils::Platforms.windows?
|
||||
return system "xdg-open", address if Utils::Platforms.linux?
|
||||
return system "open", address if Utils::Platforms.osx?
|
||||
Jekyll.logger.error "Refusing to launch browser; " \
|
||||
"Platform launcher unknown."
|
||||
end
|
||||
|
||||
# Keep in our area with a thread or detach the server as requested
|
||||
# by the user. This method determines what we do based on what you
|
||||
# ask us to do.
|
||||
|
||||
private
|
||||
def boot_or_detach(server, opts)
|
||||
if opts["detach"]
|
||||
pid = Process.fork do
|
||||
server.start
|
||||
end
|
||||
|
||||
Process.detach(pid)
|
||||
Jekyll.logger.info "Server detached with pid '#{pid}'.", \
|
||||
"Run `pkill -f jekyll' or `kill -9 #{pid}' to stop the server."
|
||||
else
|
||||
t = Thread.new { server.start }
|
||||
trap("INT") { server.shutdown }
|
||||
t.join
|
||||
end
|
||||
end
|
||||
|
||||
# Make the stack verbose if the user requests it.
|
||||
|
||||
private
|
||||
def enable_logging(opts)
|
||||
opts[:AccessLog] = []
|
||||
level = WEBrick::Log.const_get(opts[:JekyllOptions]["verbose"] ? :DEBUG : :WARN)
|
||||
opts[:Logger] = WEBrick::Log.new($stdout, level)
|
||||
end
|
||||
|
||||
# Add SSL to the stack if the user triggers --enable-ssl and they
|
||||
# provide both types of certificates commonly needed. Raise if they
|
||||
# forget to add one of the certificates.
|
||||
|
||||
private
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def enable_ssl(opts)
|
||||
return if !opts[:JekyllOptions]["ssl_cert"] && !opts[:JekyllOptions]["ssl_key"]
|
||||
if !opts[:JekyllOptions]["ssl_cert"] || !opts[:JekyllOptions]["ssl_key"]
|
||||
# rubocop:disable Style/RedundantException
|
||||
raise RuntimeError, "--ssl-cert or --ssl-key missing."
|
||||
end
|
||||
require "openssl"
|
||||
require "webrick/https"
|
||||
source_key = Jekyll.sanitized_path(opts[:JekyllOptions]["source"], \
|
||||
opts[:JekyllOptions]["ssl_key" ])
|
||||
source_certificate = Jekyll.sanitized_path(opts[:JekyllOptions]["source"], \
|
||||
opts[:JekyllOptions]["ssl_cert"])
|
||||
opts[:SSLCertificate] =
|
||||
OpenSSL::X509::Certificate.new(File.read(source_certificate))
|
||||
opts[:SSLPrivateKey ] = OpenSSL::PKey::RSA.new(File.read(source_key))
|
||||
opts[:SSLEnable] = true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def start_callback(detached)
|
||||
unless detached
|
||||
proc do
|
||||
Jekyll.logger.info("Server running...", "press ctrl-c to stop.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def mime_types
|
||||
file = File.expand_path("../mime.types", File.dirname(__FILE__))
|
||||
WEBrick::HTTPUtils.load_mime_types(file)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,60 +0,0 @@
|
||||
require "webrick"
|
||||
|
||||
module Jekyll
|
||||
module Commands
|
||||
class Serve
|
||||
class Servlet < WEBrick::HTTPServlet::FileHandler
|
||||
DEFAULTS = {
|
||||
"Cache-Control" => "private, max-age=0, proxy-revalidate, " \
|
||||
"no-store, no-cache, must-revalidate"
|
||||
}.freeze
|
||||
|
||||
def initialize(server, root, callbacks)
|
||||
# So we can access them easily.
|
||||
@jekyll_opts = server.config[:JekyllOptions]
|
||||
set_defaults
|
||||
super
|
||||
end
|
||||
|
||||
# Add the ability to tap file.html the same way that Nginx does on our
|
||||
# Docker images (or on GitHub Pages.) The difference is that we might end
|
||||
# up with a different preference on which comes first.
|
||||
|
||||
def search_file(req, res, basename)
|
||||
# /file.* > /file/index.html > /file.html
|
||||
super || super(req, res, "#{basename}.html")
|
||||
end
|
||||
|
||||
# rubocop:disable Style/MethodName
|
||||
def do_GET(req, res)
|
||||
rtn = super
|
||||
validate_and_ensure_charset(req, res)
|
||||
res.header.merge!(@headers)
|
||||
rtn
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
private
|
||||
def validate_and_ensure_charset(_req, res)
|
||||
key = res.header.keys.grep(%r!content-type!i).first
|
||||
typ = res.header[key]
|
||||
|
||||
unless typ =~ %r!;\s*charset=!
|
||||
res.header[key] = "#{typ}; charset=#{@jekyll_opts["encoding"]}"
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
private
|
||||
def set_defaults
|
||||
hash_ = @jekyll_opts.fetch("webrick", {}).fetch("headers", {})
|
||||
DEFAULTS.each_with_object(@headers = hash_) do |(key, val), hash|
|
||||
hash[key] = val unless hash.key?(key)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,386 +0,0 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
module Jekyll
|
||||
class Configuration < Hash
|
||||
# Default options. Overridden by values in _config.yml.
|
||||
# Strings rather than symbols are used for compatibility with YAML.
|
||||
DEFAULTS = Configuration[{
|
||||
# Where things are
|
||||
"source" => Dir.pwd,
|
||||
"destination" => File.join(Dir.pwd, "_site"),
|
||||
"plugins_dir" => "_plugins",
|
||||
"layouts_dir" => "_layouts",
|
||||
"data_dir" => "_data",
|
||||
"includes_dir" => "_includes",
|
||||
"collections" => {},
|
||||
|
||||
# Handling Reading
|
||||
"safe" => false,
|
||||
"include" => [".htaccess"],
|
||||
"exclude" => %w(node_modules vendor),
|
||||
"keep_files" => [".git", ".svn"],
|
||||
"encoding" => "utf-8",
|
||||
"markdown_ext" => "markdown,mkdown,mkdn,mkd,md",
|
||||
|
||||
# Filtering Content
|
||||
"show_drafts" => nil,
|
||||
"limit_posts" => 0,
|
||||
"future" => false,
|
||||
"unpublished" => false,
|
||||
|
||||
# Plugins
|
||||
"whitelist" => [],
|
||||
"gems" => [],
|
||||
|
||||
# Conversion
|
||||
"markdown" => "kramdown",
|
||||
"highlighter" => "rouge",
|
||||
"lsi" => false,
|
||||
"excerpt_separator" => "\n\n",
|
||||
"incremental" => false,
|
||||
|
||||
# Serving
|
||||
"detach" => false, # default to not detaching the server
|
||||
"port" => "4000",
|
||||
"host" => "127.0.0.1",
|
||||
"baseurl" => "",
|
||||
"show_dir_listing" => false,
|
||||
|
||||
# Output Configuration
|
||||
"permalink" => "date",
|
||||
"paginate_path" => "/page:num",
|
||||
"timezone" => nil, # use the local timezone
|
||||
|
||||
"quiet" => false,
|
||||
"verbose" => false,
|
||||
"defaults" => [],
|
||||
|
||||
"liquid" => {
|
||||
"error_mode" => "warn"
|
||||
},
|
||||
|
||||
"rdiscount" => {
|
||||
"extensions" => []
|
||||
},
|
||||
|
||||
"redcarpet" => {
|
||||
"extensions" => []
|
||||
},
|
||||
|
||||
"kramdown" => {
|
||||
"auto_ids" => true,
|
||||
"toc_levels" => "1..6",
|
||||
"entity_output" => "as_char",
|
||||
"smart_quotes" => "lsquo,rsquo,ldquo,rdquo",
|
||||
"input" => "GFM",
|
||||
"hard_wrap" => false,
|
||||
"footnote_nr" => 1
|
||||
}
|
||||
}.map { |k, v| [k, v.freeze] }].freeze
|
||||
|
||||
class << self
|
||||
# Static: Produce a Configuration ready for use in a Site.
|
||||
# It takes the input, fills in the defaults where values do not
|
||||
# exist, and patches common issues including migrating options for
|
||||
# backwards compatiblity. Except where a key or value is being fixed,
|
||||
# the user configuration will override the defaults.
|
||||
#
|
||||
# user_config - a Hash or Configuration of overrides.
|
||||
#
|
||||
# Returns a Configuration filled with defaults and fixed for common
|
||||
# problems and backwards-compatibility.
|
||||
def from(user_config)
|
||||
Utils.deep_merge_hashes(DEFAULTS, Configuration[user_config].stringify_keys)
|
||||
.fix_common_issues.add_default_collections
|
||||
end
|
||||
end
|
||||
|
||||
# Public: Turn all keys into string
|
||||
#
|
||||
# Return a copy of the hash where all its keys are strings
|
||||
def stringify_keys
|
||||
reduce({}) { |hsh, (k, v)| hsh.merge(k.to_s => v) }
|
||||
end
|
||||
|
||||
def get_config_value_with_override(config_key, override)
|
||||
override[config_key] || self[config_key] || DEFAULTS[config_key]
|
||||
end
|
||||
|
||||
# Public: Directory of the Jekyll source folder
|
||||
#
|
||||
# override - the command-line options hash
|
||||
#
|
||||
# Returns the path to the Jekyll source directory
|
||||
def source(override)
|
||||
get_config_value_with_override("source", override)
|
||||
end
|
||||
|
||||
def quiet(override = {})
|
||||
get_config_value_with_override("quiet", override)
|
||||
end
|
||||
alias_method :quiet?, :quiet
|
||||
|
||||
def verbose(override = {})
|
||||
get_config_value_with_override("verbose", override)
|
||||
end
|
||||
alias_method :verbose?, :verbose
|
||||
|
||||
def safe_load_file(filename)
|
||||
case File.extname(filename)
|
||||
when %r!\.toml!i
|
||||
Jekyll::External.require_with_graceful_fail("toml") unless defined?(TOML)
|
||||
TOML.load_file(filename)
|
||||
when %r!\.ya?ml!i
|
||||
SafeYAML.load_file(filename) || {}
|
||||
else
|
||||
raise ArgumentError, "No parser for '#{filename}' is available.
|
||||
Use a .toml or .y(a)ml file instead."
|
||||
end
|
||||
end
|
||||
|
||||
# Public: Generate list of configuration files from the override
|
||||
#
|
||||
# override - the command-line options hash
|
||||
#
|
||||
# Returns an Array of config files
|
||||
def config_files(override)
|
||||
# Adjust verbosity quickly
|
||||
Jekyll.logger.adjust_verbosity(
|
||||
:quiet => quiet?(override),
|
||||
:verbose => verbose?(override)
|
||||
)
|
||||
|
||||
# Get configuration from <source>/_config.yml or <source>/<config_file>
|
||||
config_files = override.delete("config")
|
||||
if config_files.to_s.empty?
|
||||
default = %w(yml yaml).find(-> { "yml" }) do |ext|
|
||||
File.exist?(Jekyll.sanitized_path(source(override), "_config.#{ext}"))
|
||||
end
|
||||
config_files = Jekyll.sanitized_path(source(override), "_config.#{default}")
|
||||
@default_config_file = true
|
||||
end
|
||||
config_files = [config_files] unless config_files.is_a? Array
|
||||
config_files
|
||||
end
|
||||
|
||||
# Public: Read configuration and return merged Hash
|
||||
#
|
||||
# file - the path to the YAML file to be read in
|
||||
#
|
||||
# Returns this configuration, overridden by the values in the file
|
||||
def read_config_file(file)
|
||||
next_config = safe_load_file(file)
|
||||
check_config_is_hash!(next_config, file)
|
||||
Jekyll.logger.info "Configuration file:", file
|
||||
next_config
|
||||
rescue SystemCallError
|
||||
if @default_config_file ||= nil
|
||||
Jekyll.logger.warn "Configuration file:", "none"
|
||||
{}
|
||||
else
|
||||
Jekyll.logger.error "Fatal:", "The configuration file '#{file}'
|
||||
could not be found."
|
||||
raise LoadError, "The Configuration file '#{file}' could not be found."
|
||||
end
|
||||
end
|
||||
|
||||
# Public: Read in a list of configuration files and merge with this hash
|
||||
#
|
||||
# files - the list of configuration file paths
|
||||
#
|
||||
# Returns the full configuration, with the defaults overridden by the values in the
|
||||
# configuration files
|
||||
def read_config_files(files)
|
||||
configuration = clone
|
||||
|
||||
begin
|
||||
files.each do |config_file|
|
||||
next if config_file.nil? || config_file.empty?
|
||||
new_config = read_config_file(config_file)
|
||||
configuration = Utils.deep_merge_hashes(configuration, new_config)
|
||||
end
|
||||
rescue ArgumentError => err
|
||||
Jekyll.logger.warn "WARNING:", "Error reading configuration. " \
|
||||
"Using defaults (and options)."
|
||||
$stderr.puts err
|
||||
end
|
||||
|
||||
configuration.fix_common_issues.backwards_compatibilize.add_default_collections
|
||||
end
|
||||
|
||||
# Public: Split a CSV string into an array containing its values
|
||||
#
|
||||
# csv - the string of comma-separated values
|
||||
#
|
||||
# Returns an array of the values contained in the CSV
|
||||
def csv_to_array(csv)
|
||||
csv.split(",").map(&:strip)
|
||||
end
|
||||
|
||||
# Public: Ensure the proper options are set in the configuration to allow for
|
||||
# backwards-compatibility with Jekyll pre-1.0
|
||||
#
|
||||
# Returns the backwards-compatible configuration
|
||||
def backwards_compatibilize
|
||||
config = clone
|
||||
# Provide backwards-compatibility
|
||||
check_auto(config)
|
||||
check_server(config)
|
||||
|
||||
renamed_key "server_port", "port", config
|
||||
renamed_key "plugins", "plugins_dir", config
|
||||
renamed_key "layouts", "layouts_dir", config
|
||||
renamed_key "data_source", "data_dir", config
|
||||
|
||||
check_pygments(config)
|
||||
check_include_exclude(config)
|
||||
check_coderay(config)
|
||||
check_maruku(config)
|
||||
|
||||
config
|
||||
end
|
||||
|
||||
def fix_common_issues
|
||||
config = clone
|
||||
|
||||
if config.key?("paginate") && (!config["paginate"].is_a?(Integer) ||
|
||||
config["paginate"] < 1)
|
||||
|
||||
Jekyll.logger.warn "Config Warning:", "The `paginate` key must be a positive" \
|
||||
" integer or nil. It's currently set to '#{config["paginate"].inspect}'."
|
||||
config["paginate"] = nil
|
||||
end
|
||||
|
||||
config
|
||||
end
|
||||
|
||||
def add_default_collections
|
||||
config = clone
|
||||
|
||||
# It defaults to `{}`, so this is only if someone sets it to null manually.
|
||||
return config if config["collections"].nil?
|
||||
|
||||
# Ensure we have a hash.
|
||||
if config["collections"].is_a?(Array)
|
||||
config["collections"] = Hash[config["collections"].map { |c| [c, {}] }]
|
||||
end
|
||||
|
||||
config["collections"] = Utils.deep_merge_hashes(
|
||||
{ "posts" => {} }, config["collections"]
|
||||
).tap do |collections|
|
||||
collections["posts"]["output"] = true
|
||||
if config["permalink"]
|
||||
collections["posts"]["permalink"] ||= style_to_permalink(config["permalink"])
|
||||
end
|
||||
end
|
||||
|
||||
config
|
||||
end
|
||||
|
||||
def renamed_key(old, new, config, _ = nil)
|
||||
if config.key?(old)
|
||||
Jekyll::Deprecator.deprecation_message "The '#{old}' configuration" \
|
||||
" option has been renamed to '#{new}'. Please update your config" \
|
||||
" file accordingly."
|
||||
config[new] = config.delete(old)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def style_to_permalink(permalink_style)
|
||||
case permalink_style.to_sym
|
||||
when :pretty
|
||||
"/:categories/:year/:month/:day/:title/"
|
||||
when :none
|
||||
"/:categories/:title:output_ext"
|
||||
when :date
|
||||
"/:categories/:year/:month/:day/:title:output_ext"
|
||||
when :ordinal
|
||||
"/:categories/:year/:y_day/:title:output_ext"
|
||||
else
|
||||
permalink_style.to_s
|
||||
end
|
||||
end
|
||||
|
||||
# Private: Checks if a given config is a hash
|
||||
#
|
||||
# extracted_config - the value to check
|
||||
# file - the file from which the config was extracted
|
||||
#
|
||||
# Raises an ArgumentError if given config is not a hash
|
||||
private
|
||||
def check_config_is_hash!(extracted_config, file)
|
||||
unless extracted_config.is_a?(Hash)
|
||||
raise ArgumentError, "Configuration file: (INVALID) #{file}".yellow
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def check_auto(config)
|
||||
if config.key?("auto") || config.key?("watch")
|
||||
Jekyll::Deprecator.deprecation_message "Auto-regeneration can no longer" \
|
||||
" be set from your configuration file(s). Use the" \
|
||||
" --[no-]watch/-w command-line option instead."
|
||||
config.delete("auto")
|
||||
config.delete("watch")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def check_server(config)
|
||||
if config.key?("server")
|
||||
Jekyll::Deprecator.deprecation_message "The 'server' configuration option" \
|
||||
" is no longer accepted. Use the 'jekyll serve'" \
|
||||
" subcommand to serve your site with WEBrick."
|
||||
config.delete("server")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def check_pygments(config)
|
||||
if config.key?("pygments")
|
||||
Jekyll::Deprecator.deprecation_message "The 'pygments' configuration option" \
|
||||
" has been renamed to 'highlighter'. Please update your" \
|
||||
" config file accordingly. The allowed values are 'rouge', " \
|
||||
"'pygments' or null."
|
||||
|
||||
config["highlighter"] = "pygments" if config["pygments"]
|
||||
config.delete("pygments")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def check_include_exclude(config)
|
||||
%w(include exclude).each do |option|
|
||||
if config[option].is_a?(String)
|
||||
Jekyll::Deprecator.deprecation_message "The '#{option}' configuration option" \
|
||||
" must now be specified as an array, but you specified" \
|
||||
" a string. For now, we've treated the string you provided" \
|
||||
" as a list of comma-separated values."
|
||||
config[option] = csv_to_array(config[option])
|
||||
end
|
||||
config[option].map!(&:to_s) if config[option]
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def check_coderay(config)
|
||||
if (config["kramdown"] || {}).key?("use_coderay")
|
||||
Jekyll::Deprecator.deprecation_message "Please change 'use_coderay'" \
|
||||
" to 'enable_coderay' in your configuration file."
|
||||
config["kramdown"]["use_coderay"] = config["kramdown"].delete("enable_coderay")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def check_maruku(config)
|
||||
if config.fetch("markdown", "kramdown").to_s.casecmp("maruku").zero?
|
||||
Jekyll.logger.abort_with "Error:", "You're using the 'maruku' " \
|
||||
"Markdown processor, which has been removed as of 3.0.0. " \
|
||||
"We recommend you switch to Kramdown. To do this, replace " \
|
||||
"`markdown: maruku` with `markdown: kramdown` in your " \
|
||||
"`_config.yml` file."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,52 +0,0 @@
|
||||
module Jekyll
|
||||
class Converter < Plugin
|
||||
# Public: Get or set the highlighter prefix. When an argument is specified,
|
||||
# the prefix will be set. If no argument is specified, the current prefix
|
||||
# will be returned.
|
||||
#
|
||||
# highlighter_prefix - The String prefix (default: nil).
|
||||
#
|
||||
# Returns the String prefix.
|
||||
def self.highlighter_prefix(highlighter_prefix = nil)
|
||||
if !defined?(@highlighter_prefix) || !highlighter_prefix.nil?
|
||||
@highlighter_prefix = highlighter_prefix
|
||||
end
|
||||
@highlighter_prefix
|
||||
end
|
||||
|
||||
# Public: Get or set the highlighter suffix. When an argument is specified,
|
||||
# the suffix will be set. If no argument is specified, the current suffix
|
||||
# will be returned.
|
||||
#
|
||||
# highlighter_suffix - The String suffix (default: nil).
|
||||
#
|
||||
# Returns the String suffix.
|
||||
def self.highlighter_suffix(highlighter_suffix = nil)
|
||||
if !defined?(@highlighter_suffix) || !highlighter_suffix.nil?
|
||||
@highlighter_suffix = highlighter_suffix
|
||||
end
|
||||
@highlighter_suffix
|
||||
end
|
||||
|
||||
# Initialize the converter.
|
||||
#
|
||||
# Returns an initialized Converter.
|
||||
def initialize(config = {})
|
||||
@config = config
|
||||
end
|
||||
|
||||
# Get the highlighter prefix.
|
||||
#
|
||||
# Returns the String prefix.
|
||||
def highlighter_prefix
|
||||
self.class.highlighter_prefix
|
||||
end
|
||||
|
||||
# Get the highlighter suffix.
|
||||
#
|
||||
# Returns the String suffix.
|
||||
def highlighter_suffix
|
||||
self.class.highlighter_suffix
|
||||
end
|
||||
end
|
||||
end
|
||||
26
lib/jekyll/converters/csv.rb
Normal file
26
lib/jekyll/converters/csv.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
module Jekyll
|
||||
module CSV
|
||||
#Reads a csv with title, permalink, body, published_at, and filter.
|
||||
#It creates a post file for each row in the csv
|
||||
def self.process(file = "posts.csv")
|
||||
FileUtils.mkdir_p "_posts"
|
||||
posts = 0
|
||||
FasterCSV.foreach(file) do |row|
|
||||
next if row[0] == "title"
|
||||
posts += 1
|
||||
name = row[3].split(" ")[0]+"-"+row[1]+(row[4] =~ /markdown/ ? ".markdown" : ".textile")
|
||||
File.open("_posts/#{name}", "w") do |f|
|
||||
f.puts <<-HEADER
|
||||
---
|
||||
layout: post
|
||||
title: #{row[0]}
|
||||
---
|
||||
|
||||
HEADER
|
||||
f.puts row[2]
|
||||
end
|
||||
end
|
||||
"Created #{posts} posts!"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,21 +0,0 @@
|
||||
module Jekyll
|
||||
module Converters
|
||||
class Identity < Converter
|
||||
safe true
|
||||
|
||||
priority :lowest
|
||||
|
||||
def matches(_ext)
|
||||
true
|
||||
end
|
||||
|
||||
def output_ext(ext)
|
||||
ext
|
||||
end
|
||||
|
||||
def convert(content)
|
||||
content
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,102 +0,0 @@
|
||||
module Jekyll
|
||||
module Converters
|
||||
class Markdown < Converter
|
||||
highlighter_prefix "\n"
|
||||
highlighter_suffix "\n"
|
||||
safe true
|
||||
|
||||
def setup
|
||||
return if @setup ||= false
|
||||
unless (@parser = get_processor)
|
||||
Jekyll.logger.error "Invalid Markdown processor given:", @config["markdown"]
|
||||
if @config["safe"]
|
||||
Jekyll.logger.info "", "Custom processors are not loaded in safe mode"
|
||||
end
|
||||
Jekyll.logger.error(
|
||||
"",
|
||||
"Available processors are: #{valid_processors.join(", ")}"
|
||||
)
|
||||
raise Errors::FatalException, "Bailing out; invalid Markdown processor."
|
||||
end
|
||||
|
||||
@setup = true
|
||||
end
|
||||
|
||||
# Rubocop does not allow reader methods to have names starting with `get_`
|
||||
# To ensure compatibility, this check has been disabled on this method
|
||||
#
|
||||
# rubocop:disable Style/AccessorMethodName
|
||||
def get_processor
|
||||
case @config["markdown"].downcase
|
||||
when "redcarpet" then return RedcarpetParser.new(@config)
|
||||
when "kramdown" then return KramdownParser.new(@config)
|
||||
when "rdiscount" then return RDiscountParser.new(@config)
|
||||
else
|
||||
custom_processor
|
||||
end
|
||||
end
|
||||
# rubocop:enable Style/AccessorMethodName
|
||||
|
||||
# Public: Provides you with a list of processors, the ones we
|
||||
# support internally and the ones that you have provided to us (if you
|
||||
# are not in safe mode.)
|
||||
|
||||
def valid_processors
|
||||
%W(rdiscount kramdown redcarpet) + third_party_processors
|
||||
end
|
||||
|
||||
# Public: A list of processors that you provide via plugins.
|
||||
# This is really only available if you are not in safe mode, if you are
|
||||
# in safe mode (re: GitHub) then there will be none.
|
||||
|
||||
def third_party_processors
|
||||
self.class.constants - \
|
||||
%w(KramdownParser RDiscountParser RedcarpetParser PRIORITIES).map(
|
||||
&:to_sym
|
||||
)
|
||||
end
|
||||
|
||||
def extname_list
|
||||
@extname_list ||= @config["markdown_ext"].split(",").map do |e|
|
||||
".#{e.downcase}"
|
||||
end
|
||||
end
|
||||
|
||||
def matches(ext)
|
||||
extname_list.include?(ext.downcase)
|
||||
end
|
||||
|
||||
def output_ext(_ext)
|
||||
".html"
|
||||
end
|
||||
|
||||
def convert(content)
|
||||
setup
|
||||
@parser.convert(content)
|
||||
end
|
||||
|
||||
private
|
||||
def custom_processor
|
||||
converter_name = @config["markdown"]
|
||||
if custom_class_allowed?(converter_name)
|
||||
self.class.const_get(converter_name).new(@config)
|
||||
end
|
||||
end
|
||||
|
||||
# Private: Determine whether a class name is an allowed custom
|
||||
# markdown class name.
|
||||
#
|
||||
# parser_name - the name of the parser class
|
||||
#
|
||||
# Returns true if the parser name contains only alphanumeric
|
||||
# characters and is defined within Jekyll::Converters::Markdown
|
||||
|
||||
private
|
||||
def custom_class_allowed?(parser_name)
|
||||
parser_name !~ %r![^A-Za-z0-9_]! && self.class.constants.include?(
|
||||
parser_name.to_sym
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,35 +0,0 @@
|
||||
class Kramdown::Parser::Inline < Kramdown::Parser::Kramdown
|
||||
def initialize(source, options)
|
||||
super
|
||||
@block_parsers = [:block_html].freeze
|
||||
end
|
||||
end
|
||||
|
||||
module Jekyll
|
||||
module Converters
|
||||
class Markdown
|
||||
class Inline < Converter
|
||||
safe true
|
||||
priority :low
|
||||
|
||||
def initialize(config)
|
||||
Jekyll::External.require_with_graceful_fail "kramdown"
|
||||
@config = config["kramdown"].dup || {}
|
||||
@config[:input] = :Inline
|
||||
end
|
||||
|
||||
def matches(_)
|
||||
false
|
||||
end
|
||||
|
||||
def output_ext(_)
|
||||
nil
|
||||
end
|
||||
|
||||
def convert(content)
|
||||
Kramdown::Document.new(content, @config).to_html.chomp
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,125 +0,0 @@
|
||||
# Frozen-string-literal: true
|
||||
# Encoding: utf-8
|
||||
|
||||
module Jekyll
|
||||
module Converters
|
||||
class Markdown
|
||||
class KramdownParser
|
||||
CODERAY_DEFAULTS = {
|
||||
"css" => "style",
|
||||
"bold_every" => 10,
|
||||
"line_numbers" => "inline",
|
||||
"line_number_start" => 1,
|
||||
"tab_width" => 4,
|
||||
"wrap" => "div"
|
||||
}.freeze
|
||||
|
||||
def initialize(config)
|
||||
Jekyll::External.require_with_graceful_fail "kramdown"
|
||||
@main_fallback_highlighter = config["highlighter"] || "rouge"
|
||||
@config = config["kramdown"] || {}
|
||||
@highlighter = nil
|
||||
setup
|
||||
end
|
||||
|
||||
# Setup and normalize the configuration:
|
||||
# * Create Kramdown if it doesn't exist.
|
||||
# * Set syntax_highlighter, detecting enable_coderay and merging
|
||||
# highlighter if none.
|
||||
# * Merge kramdown[coderay] into syntax_highlighter_opts stripping coderay_.
|
||||
# * Make sure `syntax_highlighter_opts` exists.
|
||||
|
||||
def setup
|
||||
@config["syntax_highlighter"] ||= highlighter
|
||||
@config["syntax_highlighter_opts"] ||= {}
|
||||
@config["coderay"] ||= {} # XXX: Legacy.
|
||||
modernize_coderay_config
|
||||
make_accessible
|
||||
end
|
||||
|
||||
def convert(content)
|
||||
Kramdown::Document.new(content, @config).to_html
|
||||
end
|
||||
|
||||
private
|
||||
def make_accessible(hash = @config)
|
||||
proc_ = proc { |hash_, key| hash_[key.to_s] if key.is_a?(Symbol) }
|
||||
hash.default_proc = proc_
|
||||
|
||||
hash.each do |_, val|
|
||||
make_accessible val if val.is_a?(
|
||||
Hash
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
# config[kramdown][syntax_higlighter] >
|
||||
# config[kramdown][enable_coderay] >
|
||||
# config[highlighter]
|
||||
# Where `enable_coderay` is now deprecated because Kramdown
|
||||
# supports Rouge now too.
|
||||
|
||||
private
|
||||
def highlighter
|
||||
return @highlighter if @highlighter
|
||||
|
||||
if @config["syntax_highlighter"]
|
||||
return @highlighter = @config[
|
||||
"syntax_highlighter"
|
||||
]
|
||||
end
|
||||
|
||||
@highlighter = begin
|
||||
if @config.key?("enable_coderay") && @config["enable_coderay"]
|
||||
Jekyll::Deprecator.deprecation_message(
|
||||
"You are using 'enable_coderay', " \
|
||||
"use syntax_highlighter: coderay in your configuration file."
|
||||
)
|
||||
|
||||
"coderay"
|
||||
else
|
||||
@main_fallback_highlighter
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def strip_coderay_prefix(hash)
|
||||
hash.each_with_object({}) do |(key, val), hsh|
|
||||
cleaned_key = key.gsub(%r!\Acoderay_!, "")
|
||||
|
||||
if key != cleaned_key
|
||||
Jekyll::Deprecator.deprecation_message(
|
||||
"You are using '#{key}'. Normalizing to #{cleaned_key}."
|
||||
)
|
||||
end
|
||||
|
||||
hsh[cleaned_key] = val
|
||||
end
|
||||
end
|
||||
|
||||
# If our highlighter is CodeRay we go in to merge the CodeRay defaults
|
||||
# with your "coderay" key if it's there, deprecating it in the
|
||||
# process of you using it.
|
||||
|
||||
private
|
||||
def modernize_coderay_config
|
||||
unless @config["coderay"].empty?
|
||||
Jekyll::Deprecator.deprecation_message(
|
||||
"You are using 'kramdown.coderay' in your configuration, " \
|
||||
"please use 'syntax_highlighter_opts' instead."
|
||||
)
|
||||
|
||||
@config["syntax_highlighter_opts"] = begin
|
||||
strip_coderay_prefix(
|
||||
@config["syntax_highlighter_opts"] \
|
||||
.merge(CODERAY_DEFAULTS) \
|
||||
.merge(@config["coderay"])
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,33 +0,0 @@
|
||||
module Jekyll
|
||||
module Converters
|
||||
class Markdown
|
||||
class RDiscountParser
|
||||
def initialize(config)
|
||||
Jekyll::External.require_with_graceful_fail "rdiscount"
|
||||
@config = config
|
||||
@rdiscount_extensions = @config["rdiscount"]["extensions"].map(&:to_sym)
|
||||
end
|
||||
|
||||
def convert(content)
|
||||
rd = RDiscount.new(content, *@rdiscount_extensions)
|
||||
html = rd.to_html
|
||||
if @config["rdiscount"]["toc_token"]
|
||||
html = replace_generated_toc(rd, html, @config["rdiscount"]["toc_token"])
|
||||
end
|
||||
html
|
||||
end
|
||||
|
||||
private
|
||||
def replace_generated_toc(rd, html, toc_token)
|
||||
if rd.generate_toc && html.include?(toc_token)
|
||||
utf8_toc = rd.toc_content
|
||||
utf8_toc.force_encoding("utf-8") if utf8_toc.respond_to?(:force_encoding)
|
||||
html.gsub(toc_token, utf8_toc)
|
||||
else
|
||||
html
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,108 +0,0 @@
|
||||
class Jekyll::Converters::Markdown::RedcarpetParser
|
||||
module CommonMethods
|
||||
def add_code_tags(code, lang)
|
||||
code = code.to_s
|
||||
code = code.sub(
|
||||
%r!<pre>!,
|
||||
"<pre><code class=\"language-#{lang}\" data-lang=\"#{lang}\">"
|
||||
)
|
||||
code = code.sub(%r!</pre>!, "</code></pre>")
|
||||
code
|
||||
end
|
||||
end
|
||||
|
||||
module WithPygments
|
||||
include CommonMethods
|
||||
def block_code(code, lang)
|
||||
Jekyll::External.require_with_graceful_fail("pygments")
|
||||
lang = lang && lang.split.first || "text"
|
||||
add_code_tags(
|
||||
Pygments.highlight(
|
||||
code,
|
||||
{
|
||||
:lexer => lang,
|
||||
:options => { :encoding => "utf-8" }
|
||||
}
|
||||
),
|
||||
lang
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
module WithoutHighlighting
|
||||
require "cgi"
|
||||
|
||||
include CommonMethods
|
||||
|
||||
def code_wrap(code)
|
||||
"<figure class=\"highlight\"><pre>#{CGI.escapeHTML(code)}</pre></figure>"
|
||||
end
|
||||
|
||||
def block_code(code, lang)
|
||||
lang = lang && lang.split.first || "text"
|
||||
add_code_tags(code_wrap(code), lang)
|
||||
end
|
||||
end
|
||||
|
||||
module WithRouge
|
||||
def block_code(code, lang)
|
||||
code = "<pre>#{super}</pre>"
|
||||
|
||||
output = "<div class=\"highlight\">"
|
||||
output << add_code_tags(code, lang)
|
||||
output << "</div>"
|
||||
end
|
||||
|
||||
protected
|
||||
def rouge_formatter(_lexer)
|
||||
Rouge::Formatters::HTML.new(:wrap => false)
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(config)
|
||||
Jekyll::External.require_with_graceful_fail("redcarpet")
|
||||
@config = config
|
||||
@redcarpet_extensions = {}
|
||||
@config["redcarpet"]["extensions"].each do |e|
|
||||
@redcarpet_extensions[e.to_sym] = true
|
||||
end
|
||||
|
||||
@renderer ||= class_with_proper_highlighter(@config["highlighter"])
|
||||
end
|
||||
|
||||
def class_with_proper_highlighter(highlighter)
|
||||
Class.new(Redcarpet::Render::HTML) do
|
||||
case highlighter
|
||||
when "pygments"
|
||||
include WithPygments
|
||||
when "rouge"
|
||||
Jekyll::External.require_with_graceful_fail(%w(
|
||||
rouge rouge/plugins/redcarpet
|
||||
))
|
||||
|
||||
unless Gem::Version.new(Rouge.version) > Gem::Version.new("1.3.0")
|
||||
abort "Please install Rouge 1.3.0 or greater and try running Jekyll again."
|
||||
end
|
||||
|
||||
include Rouge::Plugins::Redcarpet
|
||||
include CommonMethods
|
||||
include WithRouge
|
||||
else
|
||||
include WithoutHighlighting
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def convert(content)
|
||||
@redcarpet_extensions[:fenced_code_blocks] = \
|
||||
!@redcarpet_extensions[:no_fenced_code_blocks]
|
||||
if @redcarpet_extensions[:smart]
|
||||
@renderer.send :include, Redcarpet::Render::SmartyPants
|
||||
end
|
||||
markdown = Redcarpet::Markdown.new(
|
||||
@renderer.new(@redcarpet_extensions),
|
||||
@redcarpet_extensions
|
||||
)
|
||||
markdown.render(content)
|
||||
end
|
||||
end
|
||||
79
lib/jekyll/converters/mephisto.rb
Normal file
79
lib/jekyll/converters/mephisto.rb
Normal file
@@ -0,0 +1,79 @@
|
||||
# Quickly hacked together my Michael Ivey
|
||||
# Based on mt.rb by Nick Gerakines, open source and publically
|
||||
# available under the MIT license. Use this module at your own risk.
|
||||
|
||||
require 'rubygems'
|
||||
require 'sequel'
|
||||
require 'fastercsv'
|
||||
require 'fileutils'
|
||||
require File.join(File.dirname(__FILE__),"csv.rb")
|
||||
|
||||
# NOTE: This converter requires Sequel and the MySQL gems.
|
||||
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
|
||||
# installed, running the following commands should work:
|
||||
# $ sudo gem install sequel
|
||||
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
||||
|
||||
module Jekyll
|
||||
module Mephisto
|
||||
#Accepts a hash with database config variables, exports mephisto posts into a csv
|
||||
#export PGPASSWORD if you must
|
||||
def self.postgres(c)
|
||||
sql = <<-SQL
|
||||
BEGIN;
|
||||
CREATE TEMP TABLE jekyll AS
|
||||
SELECT title, permalink, body, published_at, filter FROM contents
|
||||
WHERE user_id = 1 AND type = 'Article' ORDER BY published_at;
|
||||
COPY jekyll TO STDOUT WITH CSV HEADER;
|
||||
ROLLBACK;
|
||||
SQL
|
||||
command = %Q(psql -h #{c[:host] || "localhost"} -c "#{sql.strip}" #{c[:database]} #{c[:username]} -o #{c[:filename] || "posts.csv"})
|
||||
puts command
|
||||
`#{command}`
|
||||
CSV.process
|
||||
end
|
||||
|
||||
# This query will pull blog posts from all entries across all blogs. If
|
||||
# you've got unpublished, deleted or otherwise hidden posts please sift
|
||||
# through the created posts to make sure nothing is accidently published.
|
||||
|
||||
QUERY = "SELECT id, permalink, body, published_at, title FROM contents WHERE user_id = 1 AND type = 'Article' AND published_at IS NOT NULL ORDER BY published_at"
|
||||
|
||||
def self.process(dbname, user, pass, host = 'localhost')
|
||||
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
|
||||
|
||||
FileUtils.mkdir_p "_posts"
|
||||
|
||||
db[QUERY].each do |post|
|
||||
title = post[:title]
|
||||
slug = post[:permalink]
|
||||
date = post[:published_at]
|
||||
content = post[:body]
|
||||
# more_content = ''
|
||||
|
||||
# Be sure to include the body and extended body.
|
||||
# if more_content != nil
|
||||
# content = content + " \n" + more_content
|
||||
# end
|
||||
|
||||
# Ideally, this script would determine the post format (markdown, html
|
||||
# , etc) and create files with proper extensions. At this point it
|
||||
# just assumes that markdown will be acceptable.
|
||||
name = [date.year, date.month, date.day, slug].join('-') + ".markdown"
|
||||
|
||||
data = {
|
||||
'layout' => 'post',
|
||||
'title' => title.to_s,
|
||||
'mt_id' => post[:entry_id],
|
||||
}.delete_if { |k,v| v.nil? || v == ''}.to_yaml
|
||||
|
||||
File.open("_posts/#{name}", "w") do |f|
|
||||
f.puts data
|
||||
f.puts "---"
|
||||
f.puts content
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
59
lib/jekyll/converters/mt.rb
Normal file
59
lib/jekyll/converters/mt.rb
Normal file
@@ -0,0 +1,59 @@
|
||||
# Created by Nick Gerakines, open source and publically available under the
|
||||
# MIT license. Use this module at your own risk.
|
||||
# I'm an Erlang/Perl/C++ guy so please forgive my dirty ruby.
|
||||
|
||||
require 'rubygems'
|
||||
require 'sequel'
|
||||
require 'fileutils'
|
||||
|
||||
# NOTE: This converter requires Sequel and the MySQL gems.
|
||||
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
|
||||
# installed, running the following commands should work:
|
||||
# $ sudo gem install sequel
|
||||
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
||||
|
||||
module Jekyll
|
||||
module MT
|
||||
# This query will pull blog posts from all entries across all blogs. If
|
||||
# you've got unpublished, deleted or otherwise hidden posts please sift
|
||||
# through the created posts to make sure nothing is accidently published.
|
||||
QUERY = "SELECT entry_id, entry_basename, entry_text, entry_text_more, entry_created_on, entry_title FROM mt_entry"
|
||||
|
||||
def self.process(dbname, user, pass, host = 'localhost')
|
||||
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
|
||||
|
||||
FileUtils.mkdir_p "_posts"
|
||||
|
||||
db[QUERY].each do |post|
|
||||
title = post[:entry_title]
|
||||
slug = post[:entry_basename]
|
||||
date = post[:entry_created_on]
|
||||
content = post[:entry_text]
|
||||
more_content = post[:entry_text_more]
|
||||
|
||||
# Be sure to include the body and extended body.
|
||||
if more_content != nil
|
||||
content = content + " \n" + more_content
|
||||
end
|
||||
|
||||
# Ideally, this script would determine the post format (markdown, html
|
||||
# , etc) and create files with proper extensions. At this point it
|
||||
# just assumes that markdown will be acceptable.
|
||||
name = [date.year, date.month, date.day, slug].join('-') + ".markdown"
|
||||
|
||||
data = {
|
||||
'layout' => 'post',
|
||||
'title' => title.to_s,
|
||||
'mt_id' => post[:entry_id],
|
||||
}.delete_if { |k,v| v.nil? || v == ''}.to_yaml
|
||||
|
||||
File.open("_posts/#{name}", "w") do |f|
|
||||
f.puts data
|
||||
f.puts "---"
|
||||
f.puts content
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,34 +0,0 @@
|
||||
class Kramdown::Parser::SmartyPants < Kramdown::Parser::Kramdown
|
||||
def initialize(source, options)
|
||||
super
|
||||
@block_parsers = [:block_html]
|
||||
@span_parsers = [:smart_quotes, :html_entity, :typographic_syms, :span_html]
|
||||
end
|
||||
end
|
||||
|
||||
module Jekyll
|
||||
module Converters
|
||||
class SmartyPants < Converter
|
||||
safe true
|
||||
priority :low
|
||||
|
||||
def initialize(config)
|
||||
Jekyll::External.require_with_graceful_fail "kramdown"
|
||||
@config = config["kramdown"].dup || {}
|
||||
@config[:input] = :SmartyPants
|
||||
end
|
||||
|
||||
def matches(_)
|
||||
false
|
||||
end
|
||||
|
||||
def output_ext(_)
|
||||
nil
|
||||
end
|
||||
|
||||
def convert(content)
|
||||
Kramdown::Document.new(content, @config).to_html.chomp
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
50
lib/jekyll/converters/textpattern.rb
Normal file
50
lib/jekyll/converters/textpattern.rb
Normal file
@@ -0,0 +1,50 @@
|
||||
require 'rubygems'
|
||||
require 'sequel'
|
||||
require 'fileutils'
|
||||
|
||||
# NOTE: This converter requires Sequel and the MySQL gems.
|
||||
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
|
||||
# installed, running the following commands should work:
|
||||
# $ sudo gem install sequel
|
||||
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
||||
|
||||
module Jekyll
|
||||
module TextPattern
|
||||
# Reads a MySQL database via Sequel and creates a post file for each post.
|
||||
# The only posts selected are those with a status of 4 or 5, which means "live"
|
||||
# and "sticky" respectively.
|
||||
# Other statuses is 1 => draft, 2 => hidden and 3 => pending
|
||||
QUERY = "select Title, url_title, Posted, Body, Keywords from textpattern where Status = '4' or Status = '5'"
|
||||
|
||||
def self.process(dbname, user, pass, host = 'localhost')
|
||||
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
|
||||
|
||||
FileUtils.mkdir_p "_posts"
|
||||
|
||||
db[QUERY].each do |post|
|
||||
# Get required fields and construct Jekyll compatible name
|
||||
title = post[:Title]
|
||||
slug = post[:url_title]
|
||||
date = post[:Posted]
|
||||
content = post[:Body]
|
||||
|
||||
name = [date.strftime("%Y-%m-%d"), slug].join('-') + ".textile"
|
||||
|
||||
# Get the relevant fields as a hash, delete empty fields and convert
|
||||
# to YAML for the header
|
||||
data = {
|
||||
'layout' => 'post',
|
||||
'title' => title.to_s,
|
||||
'tags' => post[:Keywords].split(',')
|
||||
}.delete_if { |k,v| v.nil? || v == ''}.to_yaml
|
||||
|
||||
# Write out the data and content to file
|
||||
File.open("_posts/#{name}", "w") do |f|
|
||||
f.puts data
|
||||
f.puts "---"
|
||||
f.puts content
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
49
lib/jekyll/converters/typo.rb
Normal file
49
lib/jekyll/converters/typo.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
# Author: Toby DiPasquale <toby@cbcg.net>
|
||||
require 'fileutils'
|
||||
require 'rubygems'
|
||||
require 'sequel'
|
||||
|
||||
module Jekyll
|
||||
module Typo
|
||||
# this SQL *should* work for both MySQL and PostgreSQL, but I haven't
|
||||
# tested PostgreSQL yet (as of 2008-12-16)
|
||||
SQL = <<-EOS
|
||||
SELECT c.id id,
|
||||
c.title title,
|
||||
c.permalink slug,
|
||||
c.body body,
|
||||
c.published_at date,
|
||||
c.state state,
|
||||
COALESCE(tf.name, 'html') filter
|
||||
FROM contents c
|
||||
LEFT OUTER JOIN text_filters tf
|
||||
ON c.text_filter_id = tf.id
|
||||
EOS
|
||||
|
||||
def self.process dbname, user, pass, host='localhost'
|
||||
FileUtils.mkdir_p '_posts'
|
||||
db = Sequel.mysql dbname, :user => user, :password => pass, :host => host
|
||||
db[SQL].each do |post|
|
||||
next unless post[:state] =~ /Published/
|
||||
|
||||
name = [ sprintf("%.04d", post[:date].year),
|
||||
sprintf("%.02d", post[:date].month),
|
||||
sprintf("%.02d", post[:date].day),
|
||||
post[:slug].strip ].join('-')
|
||||
# Can have more than one text filter in this field, but we just want
|
||||
# the first one for this
|
||||
name += '.' + post[:filter].split(' ')[0]
|
||||
|
||||
File.open("_posts/#{name}", 'w') do |f|
|
||||
f.puts({ 'layout' => 'post',
|
||||
'title' => post[:title].to_s,
|
||||
'typo_id' => post[:id]
|
||||
}.delete_if { |k, v| v.nil? || v == '' }.to_yaml)
|
||||
f.puts '---'
|
||||
f.puts post[:body].delete("\r")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end # module Typo
|
||||
end # module Jekyll
|
||||
55
lib/jekyll/converters/wordpress.rb
Normal file
55
lib/jekyll/converters/wordpress.rb
Normal file
@@ -0,0 +1,55 @@
|
||||
require 'rubygems'
|
||||
require 'sequel'
|
||||
require 'fileutils'
|
||||
|
||||
# NOTE: This converter requires Sequel and the MySQL gems.
|
||||
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
|
||||
# installed, running the following commands should work:
|
||||
# $ sudo gem install sequel
|
||||
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
||||
|
||||
module Jekyll
|
||||
module WordPress
|
||||
|
||||
# Reads a MySQL database via Sequel and creates a post file for each
|
||||
# post in wp_posts that has post_status = 'publish'.
|
||||
# This restriction is made because 'draft' posts are not guaranteed to
|
||||
# have valid dates.
|
||||
QUERY = "select * from wp_posts where post_status = 'publish' and post_type = 'post'"
|
||||
|
||||
def self.process(dbname, user, pass, host = 'localhost')
|
||||
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
|
||||
|
||||
FileUtils.mkdir_p "_posts"
|
||||
|
||||
db[QUERY].each do |post|
|
||||
# Get required fields and construct Jekyll compatible name
|
||||
title = post[:post_title]
|
||||
slug = post[:post_name]
|
||||
date = post[:post_date]
|
||||
content = post[:post_content]
|
||||
|
||||
name = "%02d-%02d-%02d-%s.markdown" % [date.year, date.month, date.day,
|
||||
slug]
|
||||
|
||||
# Get the relevant fields as a hash, delete empty fields and convert
|
||||
# to YAML for the header
|
||||
data = {
|
||||
'layout' => 'post',
|
||||
'title' => title.to_s,
|
||||
'excerpt' => post[:post_excerpt].to_s,
|
||||
'wordpress_id' => post[:ID],
|
||||
'wordpress_url' => post[:guid]
|
||||
}.delete_if { |k,v| v.nil? || v == ''}.to_yaml
|
||||
|
||||
# Write out the data and content to file
|
||||
File.open("_posts/#{name}", "w") do |f|
|
||||
f.puts data
|
||||
f.puts "---"
|
||||
f.puts content
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,249 +1,71 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
require "set"
|
||||
|
||||
# Convertible provides methods for converting a pagelike item
|
||||
# from a certain type of markup into actual content
|
||||
#
|
||||
# Requires
|
||||
# self.site -> Jekyll::Site
|
||||
# self.content
|
||||
# self.content=
|
||||
# self.data=
|
||||
# self.ext=
|
||||
# self.output=
|
||||
# self.name
|
||||
# self.path
|
||||
# self.type -> :page, :post or :draft
|
||||
|
||||
module Jekyll
|
||||
module Convertible
|
||||
# Returns the contents as a String.
|
||||
# Return the contents as a string
|
||||
def to_s
|
||||
content || ""
|
||||
self.content || ''
|
||||
end
|
||||
|
||||
# Whether the file is published or not, as indicated in YAML front-matter
|
||||
def published?
|
||||
!(data.key?("published") && data["published"] == false)
|
||||
end
|
||||
|
||||
# Read the YAML frontmatter.
|
||||
#
|
||||
# base - The String path to the dir containing the file.
|
||||
# name - The String filename of the file.
|
||||
# opts - optional parameter to File.read, default at site configs
|
||||
#
|
||||
# Returns nothing.
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def read_yaml(base, name, opts = {})
|
||||
filename = File.join(base, name)
|
||||
|
||||
begin
|
||||
self.content = File.read(@path || site.in_source_dir(base, name),
|
||||
Utils.merged_file_read_opts(site, opts))
|
||||
if content =~ Document::YAML_FRONT_MATTER_REGEXP
|
||||
self.content = $POSTMATCH
|
||||
self.data = SafeYAML.load(Regexp.last_match(1))
|
||||
end
|
||||
rescue SyntaxError => e
|
||||
Jekyll.logger.warn "YAML Exception reading #{filename}: #{e.message}"
|
||||
rescue => e
|
||||
Jekyll.logger.warn "Error reading file #{filename}: #{e.message}"
|
||||
end
|
||||
|
||||
self.data ||= {}
|
||||
|
||||
validate_data! filename
|
||||
validate_permalink! filename
|
||||
|
||||
self.data
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
def validate_data!(filename)
|
||||
unless self.data.is_a?(Hash)
|
||||
raise Errors::InvalidYAMLFrontMatterError,
|
||||
"Invalid YAML front matter in #{filename}"
|
||||
end
|
||||
end
|
||||
|
||||
def validate_permalink!(filename)
|
||||
if self.data["permalink"] && self.data["permalink"].empty?
|
||||
raise Errors::InvalidPermalinkError, "Invalid permalink in #{filename}"
|
||||
end
|
||||
end
|
||||
|
||||
# Transform the contents based on the content type.
|
||||
#
|
||||
# Returns the transformed contents.
|
||||
def transform
|
||||
_renderer.transform
|
||||
end
|
||||
|
||||
# Determine the extension depending on content_type.
|
||||
#
|
||||
# Returns the String extension for the output file.
|
||||
# e.g. ".html" for an HTML output file.
|
||||
def output_ext
|
||||
_renderer.output_ext
|
||||
end
|
||||
|
||||
# Determine which converter to use based on this convertible's
|
||||
# extension.
|
||||
#
|
||||
# Returns the Converter instance.
|
||||
def converters
|
||||
_renderer.converters
|
||||
end
|
||||
|
||||
# Render Liquid in the content
|
||||
#
|
||||
# content - the raw Liquid content to render
|
||||
# payload - the payload for Liquid
|
||||
# info - the info for Liquid
|
||||
#
|
||||
# Returns the converted content
|
||||
def render_liquid(content, payload, info, path)
|
||||
_renderer.render_liquid(content, payload, info, path)
|
||||
end
|
||||
# rubocop: enable RescueException
|
||||
|
||||
# Convert this Convertible's data to a Hash suitable for use by Liquid.
|
||||
#
|
||||
# Returns the Hash representation of this Convertible.
|
||||
def to_liquid(attrs = nil)
|
||||
further_data = Hash[(attrs || self.class::ATTRIBUTES_FOR_LIQUID).map do |attribute|
|
||||
[attribute, send(attribute)]
|
||||
end]
|
||||
|
||||
defaults = site.frontmatter_defaults.all(relative_path, type)
|
||||
Utils.deep_merge_hashes defaults, Utils.deep_merge_hashes(data, further_data)
|
||||
end
|
||||
|
||||
# The type of a document,
|
||||
# i.e., its classname downcase'd and to_sym'd.
|
||||
#
|
||||
# Returns the type of self.
|
||||
def type
|
||||
if is_a?(Page)
|
||||
:pages
|
||||
end
|
||||
end
|
||||
|
||||
# returns the owner symbol for hook triggering
|
||||
def hook_owner
|
||||
if is_a?(Page)
|
||||
:pages
|
||||
end
|
||||
end
|
||||
|
||||
# Determine whether the document is an asset file.
|
||||
# Asset files include CoffeeScript files and Sass/SCSS files.
|
||||
#
|
||||
# Returns true if the extname belongs to the set of extensions
|
||||
# that asset files use.
|
||||
def asset_file?
|
||||
sass_file? || coffeescript_file?
|
||||
end
|
||||
|
||||
# Determine whether the document is a Sass file.
|
||||
#
|
||||
# Returns true if extname == .sass or .scss, false otherwise.
|
||||
def sass_file?
|
||||
%w(.sass .scss).include?(ext)
|
||||
end
|
||||
|
||||
# Determine whether the document is a CoffeeScript file.
|
||||
#
|
||||
# Returns true if extname == .coffee, false otherwise.
|
||||
def coffeescript_file?
|
||||
".coffee" == ext
|
||||
end
|
||||
|
||||
# Determine whether the file should be rendered with Liquid.
|
||||
#
|
||||
# Always returns true.
|
||||
def render_with_liquid?
|
||||
true
|
||||
end
|
||||
|
||||
# Determine whether the file should be placed into layouts.
|
||||
#
|
||||
# Returns false if the document is an asset file.
|
||||
def place_in_layout?
|
||||
!asset_file?
|
||||
end
|
||||
|
||||
# Checks if the layout specified in the document actually exists
|
||||
#
|
||||
# layout - the layout to check
|
||||
#
|
||||
# Returns true if the layout is invalid, false if otherwise
|
||||
def invalid_layout?(layout)
|
||||
!data["layout"].nil? && layout.nil? && !(self.is_a? Jekyll::Excerpt)
|
||||
end
|
||||
|
||||
# Recursively render layouts
|
||||
#
|
||||
# layouts - a list of the layouts
|
||||
# payload - the payload for Liquid
|
||||
# info - the info for Liquid
|
||||
|
||||
# Read the YAML frontmatter
|
||||
# +base+ is the String path to the dir containing the file
|
||||
# +name+ is the String filename of the file
|
||||
#
|
||||
# Returns nothing
|
||||
def render_all_layouts(layouts, payload, info)
|
||||
_renderer.layouts = layouts
|
||||
self.output = _renderer.place_in_layouts(output, payload, info)
|
||||
ensure
|
||||
@_renderer = nil # this will allow the modifications above to disappear
|
||||
end
|
||||
|
||||
# Add any necessary layouts to this convertible document.
|
||||
#
|
||||
# payload - The site payload Drop or Hash.
|
||||
# layouts - A Hash of {"name" => "layout"}.
|
||||
#
|
||||
# Returns nothing.
|
||||
def do_layout(payload, layouts)
|
||||
self.output = _renderer.tap do |renderer|
|
||||
renderer.layouts = layouts
|
||||
renderer.payload = payload
|
||||
end.run
|
||||
|
||||
Jekyll.logger.debug "Post-Render Hooks:", self.relative_path
|
||||
Jekyll::Hooks.trigger hook_owner, :post_render, self
|
||||
ensure
|
||||
@_renderer = nil # this will allow the modifications above to disappear
|
||||
end
|
||||
|
||||
# Write the generated page file to the destination directory.
|
||||
#
|
||||
# dest - The String path to the destination dir.
|
||||
#
|
||||
# Returns nothing.
|
||||
def write(dest)
|
||||
path = destination(dest)
|
||||
FileUtils.mkdir_p(File.dirname(path))
|
||||
File.write(path, output, :mode => "wb")
|
||||
Jekyll::Hooks.trigger hook_owner, :post_write, self
|
||||
end
|
||||
|
||||
# Accessor for data properties by Liquid.
|
||||
#
|
||||
# property - The String name of the property to retrieve.
|
||||
#
|
||||
# Returns the String value or nil if the property isn't included.
|
||||
def [](property)
|
||||
if self.class::ATTRIBUTES_FOR_LIQUID.include?(property)
|
||||
send(property)
|
||||
else
|
||||
data[property]
|
||||
def read_yaml(base, name)
|
||||
self.content = File.read(File.join(base, name))
|
||||
|
||||
if self.content =~ /^(---\s*\n.*?)\n---\s*\n/m
|
||||
self.content = self.content[($1.size + 5)..-1]
|
||||
|
||||
self.data = YAML.load($1)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def _renderer
|
||||
@_renderer ||= Jekyll::Renderer.new(site, self)
|
||||
|
||||
# Transform the contents based on the file extension.
|
||||
#
|
||||
# Returns nothing
|
||||
def transform
|
||||
case Jekyll.content_type
|
||||
when :textile
|
||||
self.ext = ".html"
|
||||
self.content = RedCloth.new(self.content).to_html
|
||||
when :markdown
|
||||
self.ext = ".html"
|
||||
self.content = Jekyll.markdown_proc.call(self.content)
|
||||
end
|
||||
end
|
||||
|
||||
def determine_content_type
|
||||
case self.ext[1..-1]
|
||||
when /textile/i
|
||||
return :textile
|
||||
when /markdown/i, /mkdn/i, /md/i
|
||||
return :markdown
|
||||
end
|
||||
return :unknown
|
||||
end
|
||||
|
||||
# Add any necessary layouts to this convertible document
|
||||
# +layouts+ is a Hash of {"name" => "layout"}
|
||||
# +site_payload+ is the site payload hash
|
||||
#
|
||||
# Returns nothing
|
||||
def do_layout(payload, layouts)
|
||||
# render and transform content (this becomes the final content of the object)
|
||||
Jekyll.content_type = self.determine_content_type
|
||||
self.content = Liquid::Template.parse(self.content).render(payload, [Jekyll::Filters])
|
||||
self.transform
|
||||
|
||||
# output keeps track of what will finally be written
|
||||
self.output = self.content
|
||||
|
||||
# recursively render layouts
|
||||
layout = layouts[self.data["layout"]]
|
||||
while layout
|
||||
payload = payload.deep_merge({"content" => self.output, "page" => layout.data})
|
||||
self.output = Liquid::Template.parse(layout.content).render(payload, [Jekyll::Filters])
|
||||
|
||||
layout = layouts[layout.data["layout"]]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
22
lib/jekyll/core_ext.rb
Normal file
22
lib/jekyll/core_ext.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
class Hash
|
||||
# Merges self with another hash, recursively.
|
||||
#
|
||||
# This code was lovingly stolen from some random gem:
|
||||
# http://gemjack.com/gems/tartan-0.1.1/classes/Hash.html
|
||||
#
|
||||
# Thanks to whoever made it.
|
||||
def deep_merge(hash)
|
||||
target = dup
|
||||
|
||||
hash.keys.each do |key|
|
||||
if hash[key].is_a? Hash and self[key].is_a? Hash
|
||||
target[key] = target[key].deep_merge(hash[key])
|
||||
next
|
||||
end
|
||||
|
||||
target[key] = hash[key]
|
||||
end
|
||||
|
||||
target
|
||||
end
|
||||
end
|
||||
@@ -1,51 +0,0 @@
|
||||
module Jekyll
|
||||
module Deprecator
|
||||
extend self
|
||||
|
||||
def process(args)
|
||||
arg_is_present? args, "--server", "The --server command has been replaced by the \
|
||||
'serve' subcommand."
|
||||
arg_is_present? args, "--serve", "The --server command has been replaced by the \
|
||||
'serve' subcommand."
|
||||
arg_is_present? args, "--no-server", "To build Jekyll without launching a server, \
|
||||
use the 'build' subcommand."
|
||||
arg_is_present? args, "--auto", "The switch '--auto' has been replaced with \
|
||||
'--watch'."
|
||||
arg_is_present? args, "--no-auto", "To disable auto-replication, simply leave off \
|
||||
the '--watch' switch."
|
||||
arg_is_present? args, "--pygments", "The 'pygments'settings has been removed in \
|
||||
favour of 'highlighter'."
|
||||
arg_is_present? args, "--paginate", "The 'paginate' setting can only be set in \
|
||||
your config files."
|
||||
arg_is_present? args, "--url", "The 'url' setting can only be set in your \
|
||||
config files."
|
||||
no_subcommand(args)
|
||||
end
|
||||
|
||||
def no_subcommand(args)
|
||||
unless args.empty? ||
|
||||
args.first !~ %r(!/^--/!) || %w(--help --version).include?(args.first)
|
||||
deprecation_message "Jekyll now uses subcommands instead of just switches. \
|
||||
Run `jekyll help` to find out more."
|
||||
abort
|
||||
end
|
||||
end
|
||||
|
||||
def arg_is_present?(args, deprecated_argument, message)
|
||||
if args.include?(deprecated_argument)
|
||||
deprecation_message(message)
|
||||
end
|
||||
end
|
||||
|
||||
def deprecation_message(message)
|
||||
Jekyll.logger.error "Deprecation:", message
|
||||
end
|
||||
|
||||
def defaults_deprecate_type(old, current)
|
||||
Jekyll.logger.warn "Defaults:", "The '#{old}' type has become '#{current}'."
|
||||
Jekyll.logger.warn "Defaults:", "Please update your front-matter defaults to use \
|
||||
'type: #{current}'."
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,490 +0,0 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
module Jekyll
|
||||
class Document
|
||||
include Comparable
|
||||
|
||||
attr_reader :path, :site, :extname, :collection
|
||||
attr_accessor :content, :output
|
||||
|
||||
YAML_FRONT_MATTER_REGEXP = %r!\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)!m
|
||||
DATELESS_FILENAME_MATCHER = %r!^(?:.+/)*(.*)(\.[^.]+)$!
|
||||
DATE_FILENAME_MATCHER = %r!^(?:.+/)*(\d+-\d+-\d+)-(.*)(\.[^.]+)$!
|
||||
|
||||
# Create a new Document.
|
||||
#
|
||||
# path - the path to the file
|
||||
# relations - a hash with keys :site and :collection, the values of which
|
||||
# are the Jekyll::Site and Jekyll::Collection to which this
|
||||
# Document belong.
|
||||
#
|
||||
# Returns nothing.
|
||||
def initialize(path, relations = {})
|
||||
@site = relations[:site]
|
||||
@path = path
|
||||
@extname = File.extname(path)
|
||||
@collection = relations[:collection]
|
||||
@has_yaml_header = nil
|
||||
|
||||
if draft?
|
||||
categories_from_path("_drafts")
|
||||
else
|
||||
categories_from_path(collection.relative_directory)
|
||||
end
|
||||
|
||||
data.default_proc = proc do |_, key|
|
||||
site.frontmatter_defaults.find(relative_path, collection.label, key)
|
||||
end
|
||||
|
||||
trigger_hooks(:post_init)
|
||||
end
|
||||
|
||||
# Fetch the Document's data.
|
||||
#
|
||||
# Returns a Hash containing the data. An empty hash is returned if
|
||||
# no data was read.
|
||||
def data
|
||||
@data ||= {}
|
||||
end
|
||||
|
||||
# Merge some data in with this document's data.
|
||||
#
|
||||
# Returns the merged data.
|
||||
def merge_data!(other, source: "YAML front matter")
|
||||
merge_categories!(other)
|
||||
Utils.deep_merge_hashes!(data, other)
|
||||
merge_date!(source)
|
||||
data
|
||||
end
|
||||
|
||||
def date
|
||||
data["date"] ||= (draft? ? source_file_mtime : site.time)
|
||||
end
|
||||
|
||||
def source_file_mtime
|
||||
@source_file_mtime ||= File.mtime(path)
|
||||
end
|
||||
|
||||
# Returns whether the document is a draft. This is only the case if
|
||||
# the document is in the 'posts' collection but in a different
|
||||
# directory than '_posts'.
|
||||
#
|
||||
# Returns whether the document is a draft.
|
||||
def draft?
|
||||
data["draft"] ||= relative_path.index(collection.relative_directory).nil? &&
|
||||
collection.label == "posts"
|
||||
end
|
||||
|
||||
# The path to the document, relative to the site source.
|
||||
#
|
||||
# Returns a String path which represents the relative path
|
||||
# from the site source to this document
|
||||
def relative_path
|
||||
@relative_path ||= Pathutil.new(path).relative_path_from(site.source).to_s
|
||||
end
|
||||
|
||||
# The output extension of the document.
|
||||
#
|
||||
# Returns the output extension
|
||||
def output_ext
|
||||
Jekyll::Renderer.new(site, self).output_ext
|
||||
end
|
||||
|
||||
# The base filename of the document, without the file extname.
|
||||
#
|
||||
# Returns the basename without the file extname.
|
||||
def basename_without_ext
|
||||
@basename_without_ext ||= File.basename(path, ".*")
|
||||
end
|
||||
|
||||
# The base filename of the document.
|
||||
#
|
||||
# Returns the base filename of the document.
|
||||
def basename
|
||||
@basename ||= File.basename(path)
|
||||
end
|
||||
|
||||
# Produces a "cleaned" relative path.
|
||||
# The "cleaned" relative path is the relative path without the extname
|
||||
# and with the collection's directory removed as well.
|
||||
# This method is useful when building the URL of the document.
|
||||
#
|
||||
# Examples:
|
||||
# When relative_path is "_methods/site/generate.md":
|
||||
# cleaned_relative_path
|
||||
# # => "/site/generate"
|
||||
#
|
||||
# Returns the cleaned relative path of the document.
|
||||
def cleaned_relative_path
|
||||
@cleaned_relative_path ||=
|
||||
relative_path[0..-extname.length - 1].sub(collection.relative_directory, "")
|
||||
end
|
||||
|
||||
# Determine whether the document is a YAML file.
|
||||
#
|
||||
# Returns true if the extname is either .yml or .yaml, false otherwise.
|
||||
def yaml_file?
|
||||
%w(.yaml .yml).include?(extname)
|
||||
end
|
||||
|
||||
# Determine whether the document is an asset file.
|
||||
# Asset files include CoffeeScript files and Sass/SCSS files.
|
||||
#
|
||||
# Returns true if the extname belongs to the set of extensions
|
||||
# that asset files use.
|
||||
def asset_file?
|
||||
sass_file? || coffeescript_file?
|
||||
end
|
||||
|
||||
# Determine whether the document is a Sass file.
|
||||
#
|
||||
# Returns true if extname == .sass or .scss, false otherwise.
|
||||
def sass_file?
|
||||
%w(.sass .scss).include?(extname)
|
||||
end
|
||||
|
||||
# Determine whether the document is a CoffeeScript file.
|
||||
#
|
||||
# Returns true if extname == .coffee, false otherwise.
|
||||
def coffeescript_file?
|
||||
".coffee" == extname
|
||||
end
|
||||
|
||||
# Determine whether the file should be rendered with Liquid.
|
||||
#
|
||||
# Returns false if the document is either an asset file or a yaml file,
|
||||
# true otherwise.
|
||||
def render_with_liquid?
|
||||
!(coffeescript_file? || yaml_file?)
|
||||
end
|
||||
|
||||
# Determine whether the file should be placed into layouts.
|
||||
#
|
||||
# Returns false if the document is either an asset file or a yaml file,
|
||||
# true otherwise.
|
||||
def place_in_layout?
|
||||
!(asset_file? || yaml_file?)
|
||||
end
|
||||
|
||||
# The URL template where the document would be accessible.
|
||||
#
|
||||
# Returns the URL template for the document.
|
||||
def url_template
|
||||
collection.url_template
|
||||
end
|
||||
|
||||
# Construct a Hash of key-value pairs which contain a mapping between
|
||||
# a key in the URL template and the corresponding value for this document.
|
||||
#
|
||||
# Returns the Hash of key-value pairs for replacement in the URL.
|
||||
def url_placeholders
|
||||
@url_placeholders ||= Drops::UrlDrop.new(self)
|
||||
end
|
||||
|
||||
# The permalink for this Document.
|
||||
# Permalink is set via the data Hash.
|
||||
#
|
||||
# Returns the permalink or nil if no permalink was set in the data.
|
||||
def permalink
|
||||
data && data.is_a?(Hash) && data["permalink"]
|
||||
end
|
||||
|
||||
# The computed URL for the document. See `Jekyll::URL#to_s` for more details.
|
||||
#
|
||||
# Returns the computed URL for the document.
|
||||
def url
|
||||
@url = URL.new({
|
||||
:template => url_template,
|
||||
:placeholders => url_placeholders,
|
||||
:permalink => permalink
|
||||
}).to_s
|
||||
end
|
||||
|
||||
def [](key)
|
||||
data[key]
|
||||
end
|
||||
|
||||
# The full path to the output file.
|
||||
#
|
||||
# base_directory - the base path of the output directory
|
||||
#
|
||||
# Returns the full path to the output file of this document.
|
||||
def destination(base_directory)
|
||||
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")
|
||||
else
|
||||
path << output_ext unless path.end_with? output_ext
|
||||
end
|
||||
path
|
||||
end
|
||||
|
||||
# Write the generated Document file to the destination directory.
|
||||
#
|
||||
# dest - The String path to the destination dir.
|
||||
#
|
||||
# Returns nothing.
|
||||
def write(dest)
|
||||
path = destination(dest)
|
||||
FileUtils.mkdir_p(File.dirname(path))
|
||||
File.write(path, output, :mode => "wb")
|
||||
|
||||
trigger_hooks(:post_write)
|
||||
end
|
||||
|
||||
# Whether the file is published or not, as indicated in YAML front-matter
|
||||
#
|
||||
# Returns 'false' if the 'published' key is specified in the
|
||||
# YAML front-matter and is 'false'. Otherwise returns 'true'.
|
||||
def published?
|
||||
!(data.key?("published") && data["published"] == false)
|
||||
end
|
||||
|
||||
# Read in the file and assign the content and data based on the file contents.
|
||||
# Merge the frontmatter of the file with the frontmatter default
|
||||
# values
|
||||
#
|
||||
# Returns nothing.
|
||||
def read(opts = {})
|
||||
Jekyll.logger.debug "Reading:", relative_path
|
||||
|
||||
if yaml_file?
|
||||
@data = SafeYAML.load_file(path)
|
||||
else
|
||||
begin
|
||||
merge_defaults
|
||||
read_content(opts)
|
||||
read_post_data
|
||||
rescue SyntaxError => e
|
||||
Jekyll.logger.error "Error:", "YAML Exception reading #{path}: #{e.message}"
|
||||
rescue => e
|
||||
raise e if e.is_a? Jekyll::Errors::FatalException
|
||||
Jekyll.logger.error "Error:", "could not read file #{path}: #{e.message}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Create a Liquid-understandable version of this Document.
|
||||
#
|
||||
# Returns a Hash representing this Document's data.
|
||||
def to_liquid
|
||||
@to_liquid ||= Drops::DocumentDrop.new(self)
|
||||
end
|
||||
|
||||
# The inspect string for this document.
|
||||
# Includes the relative path and the collection label.
|
||||
#
|
||||
# Returns the inspect string for this document.
|
||||
def inspect
|
||||
"#<Jekyll::Document #{relative_path} collection=#{collection.label}>"
|
||||
end
|
||||
|
||||
# The string representation for this document.
|
||||
#
|
||||
# Returns the content of the document
|
||||
def to_s
|
||||
output || content || "NO CONTENT"
|
||||
end
|
||||
|
||||
# Compare this document against another document.
|
||||
# Comparison is a comparison between the 2 paths of the documents.
|
||||
#
|
||||
# Returns -1, 0, +1 or nil depending on whether this doc's path is less than,
|
||||
# equal or greater than the other doc's path. See String#<=> for more details.
|
||||
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
|
||||
end
|
||||
|
||||
# Determine whether this document should be written.
|
||||
# Based on the Collection to which it belongs.
|
||||
#
|
||||
# True if the document has a collection and if that collection's #write?
|
||||
# method returns true, otherwise false.
|
||||
def write?
|
||||
collection && collection.write?
|
||||
end
|
||||
|
||||
# The Document excerpt_separator, from the YAML Front-Matter or site
|
||||
# default excerpt_separator value
|
||||
#
|
||||
# Returns the document excerpt_separator
|
||||
def excerpt_separator
|
||||
(data["excerpt_separator"] || site.config["excerpt_separator"]).to_s
|
||||
end
|
||||
|
||||
# Whether to generate an excerpt
|
||||
#
|
||||
# Returns true if the excerpt separator is configured.
|
||||
def generate_excerpt?
|
||||
!excerpt_separator.empty?
|
||||
end
|
||||
|
||||
def next_doc
|
||||
pos = collection.docs.index { |post| post.equal?(self) }
|
||||
if pos && pos < collection.docs.length - 1
|
||||
collection.docs[pos + 1]
|
||||
end
|
||||
end
|
||||
|
||||
def previous_doc
|
||||
pos = collection.docs.index { |post| post.equal?(self) }
|
||||
if pos && pos > 0
|
||||
collection.docs[pos - 1]
|
||||
end
|
||||
end
|
||||
|
||||
def trigger_hooks(hook_name, *args)
|
||||
Jekyll::Hooks.trigger collection.label.to_sym, hook_name, self, *args if collection
|
||||
Jekyll::Hooks.trigger :documents, hook_name, self, *args
|
||||
end
|
||||
|
||||
def id
|
||||
@id ||= File.join(File.dirname(url), (data["slug"] || basename_without_ext).to_s)
|
||||
end
|
||||
|
||||
# Calculate related posts.
|
||||
#
|
||||
# Returns an Array of related Posts.
|
||||
def related_posts
|
||||
Jekyll::RelatedPosts.new(self).build
|
||||
end
|
||||
|
||||
# Override of normal respond_to? to match method_missing's logic for
|
||||
# looking in @data.
|
||||
def respond_to?(method, include_private = false)
|
||||
data.key?(method.to_s) || super
|
||||
end
|
||||
|
||||
# Override of method_missing to check in @data for the key.
|
||||
def method_missing(method, *args, &blck)
|
||||
if data.key?(method.to_s)
|
||||
Jekyll::Deprecator.deprecation_message "Document##{method} is now a key "\
|
||||
"in the #data hash."
|
||||
Jekyll::Deprecator.deprecation_message "Called by #{caller.first}."
|
||||
data[method.to_s]
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def respond_to_missing?(method, *)
|
||||
data.key?(method.to_s) || super
|
||||
end
|
||||
|
||||
private
|
||||
def merge_categories!(other)
|
||||
if other.key?("categories") && !other["categories"].nil?
|
||||
if other["categories"].is_a?(String)
|
||||
other["categories"] = other["categories"].split(%r!\s+!).map(&:strip)
|
||||
end
|
||||
other["categories"] = (data["categories"] || []) | other["categories"]
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def merge_date!(source)
|
||||
if data.key?("date") && !data["date"].is_a?(Time)
|
||||
data["date"] = Utils.parse_date(
|
||||
data["date"].to_s,
|
||||
"Document '#{relative_path}' does not have a valid date in the #{source}."
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def merge_defaults
|
||||
defaults = @site.frontmatter_defaults.all(
|
||||
relative_path,
|
||||
collection.label.to_sym
|
||||
)
|
||||
merge_data!(defaults, :source => "front matter defaults") unless defaults.empty?
|
||||
end
|
||||
|
||||
private
|
||||
def read_content(opts)
|
||||
self.content = File.read(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))
|
||||
merge_data!(data_file, :source => "YAML front matter") if data_file
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def read_post_data
|
||||
populate_title
|
||||
populate_categories
|
||||
populate_tags
|
||||
generate_excerpt
|
||||
end
|
||||
|
||||
private
|
||||
def populate_title
|
||||
if relative_path =~ DATE_FILENAME_MATCHER
|
||||
date, slug, ext = Regexp.last_match.captures
|
||||
modify_date(date)
|
||||
elsif relative_path =~ DATELESS_FILENAME_MATCHER
|
||||
slug, ext = Regexp.last_match.captures
|
||||
end
|
||||
|
||||
# Try to ensure the user gets a title.
|
||||
data["title"] ||= Utils.titleize_slug(slug)
|
||||
# Only overwrite slug & ext if they aren't specified.
|
||||
data["slug"] ||= slug
|
||||
data["ext"] ||= ext
|
||||
end
|
||||
|
||||
private
|
||||
def modify_date(date)
|
||||
if !data["date"] || data["date"].to_i == site.time.to_i
|
||||
merge_data!({ "date" => date }, :source => "filename")
|
||||
end
|
||||
end
|
||||
|
||||
# Add superdirectories of the special_dir to categories.
|
||||
# In the case of es/_posts, 'es' is added as a category.
|
||||
# In the case of _posts/es, 'es' is NOT added as a category.
|
||||
#
|
||||
# Returns nothing.
|
||||
private
|
||||
def categories_from_path(special_dir)
|
||||
superdirs = relative_path.sub(%r!#{special_dir}(.*)!, "")
|
||||
.split(File::SEPARATOR)
|
||||
.reject do |c|
|
||||
c.empty? || c == special_dir || c == basename
|
||||
end
|
||||
merge_data!({ "categories" => superdirs }, :source => "file path")
|
||||
end
|
||||
|
||||
private
|
||||
def populate_categories
|
||||
merge_data!({
|
||||
"categories" => (
|
||||
Array(data["categories"]) + Utils.pluralized_array_from_hash(
|
||||
data,
|
||||
"category",
|
||||
"categories"
|
||||
)
|
||||
).map(&:to_s).flatten.uniq
|
||||
})
|
||||
end
|
||||
|
||||
private
|
||||
def populate_tags
|
||||
merge_data!({
|
||||
"tags" => Utils.pluralized_array_from_hash(data, "tag", "tags").flatten
|
||||
})
|
||||
end
|
||||
|
||||
private
|
||||
def generate_excerpt
|
||||
if generate_excerpt?
|
||||
data["excerpt"] ||= Jekyll::Excerpt.new(self)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,22 +0,0 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
module Jekyll
|
||||
module Drops
|
||||
class CollectionDrop < Drop
|
||||
extend Forwardable
|
||||
|
||||
mutable false
|
||||
|
||||
def_delegator :@obj, :write?, :output
|
||||
def_delegators :@obj, :label, :docs, :files, :directory,
|
||||
:relative_directory
|
||||
|
||||
def to_s
|
||||
docs.to_s
|
||||
end
|
||||
|
||||
private
|
||||
def_delegator :@obj, :metadata, :fallback_data
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,69 +0,0 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
module Jekyll
|
||||
module Drops
|
||||
class DocumentDrop < Drop
|
||||
extend Forwardable
|
||||
|
||||
NESTED_OBJECT_FIELD_BLACKLIST = %w(
|
||||
content output excerpt next previous
|
||||
).freeze
|
||||
|
||||
mutable false
|
||||
|
||||
def_delegator :@obj, :relative_path, :path
|
||||
def_delegators :@obj, :id, :output, :content, :to_s, :relative_path, :url
|
||||
|
||||
def collection
|
||||
@obj.collection.label
|
||||
end
|
||||
|
||||
def excerpt
|
||||
fallback_data["excerpt"].to_s
|
||||
end
|
||||
|
||||
def <=>(other)
|
||||
return nil unless other.is_a? DocumentDrop
|
||||
cmp = self["date"] <=> other["date"]
|
||||
cmp = self["path"] <=> other["path"] if cmp.nil? || cmp.zero?
|
||||
cmp
|
||||
end
|
||||
|
||||
def previous
|
||||
@obj.previous_doc.to_liquid
|
||||
end
|
||||
|
||||
def next
|
||||
@obj.next_doc.to_liquid
|
||||
end
|
||||
|
||||
# Generate a Hash for use in generating JSON.
|
||||
# This is useful if fields need to be cleared before the JSON can generate.
|
||||
#
|
||||
# state - the JSON::State object which determines the state of current processing.
|
||||
#
|
||||
# Returns a Hash ready for JSON generation.
|
||||
def hash_for_json(state = nil)
|
||||
to_h.tap do |hash|
|
||||
if state && state.depth >= 2
|
||||
hash["previous"] = collapse_document(hash["previous"]) if hash["previous"]
|
||||
hash["next"] = collapse_document(hash["next"]) if hash["next"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Generate a Hash which breaks the recursive chain.
|
||||
# Certain fields which are normally available are omitted.
|
||||
#
|
||||
# Returns a Hash with only non-recursive fields present.
|
||||
def collapse_document(doc)
|
||||
doc.keys.each_with_object({}) do |(key, _), result|
|
||||
result[key] = doc[key] unless NESTED_OBJECT_FIELD_BLACKLIST.include?(key)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def_delegator :@obj, :data, :fallback_data
|
||||
end
|
||||
end
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user