Skip to content
Snippets Groups Projects
Commit 8346aa61 authored by Leo Liang's avatar Leo Liang
Browse files

Add variable `page.last_modified_at`; add site recent updates include file.

parent 4bb08d97
Branches
No related tags found
No related merge requests found
LICENSE 0 → 100644
The MIT License (MIT)
Copyright (c) 2015 Leo Liang
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.
\ No newline at end of file
# Jekyll Revision History Plugin # Jekyll Revision History Plugin
Adds recent revision history to each page on Jekyll/Octopress site. Page/post revision history for Jekyll/Octopress site.
Git is the only revision control system currently supported. Git is the only revision control system currently supported.
This plugin adds a page variable `page.revisions`, which is a list of recent revisions of the post or page. Each revision contains attributes `date`, `author` and `message`. A page variable `page.last_modified_at` is added as well, which equals to `page.revisions[0].date`.
This plugin adds a page variable `page.revisions`, which is a list of recent revisions of the post or page. Each revision contains attributes `date`, `author` and `message`. The sample template file `revision.html` shows how to use the variable. The sample template file `revision.html` and `recent_updated.html` shows how to use the variable.
## Installation ## Usage
Put `revision.rb` in `/_plugins/` (for Jekyll) or `/plugins/` (for Octopress) directory. Put `revision.rb` in `/_plugins/` (for Jekyll) or `/plugins/` (for Octopress) directory.
Put `revision.html` in `/_include` (for Jekyll) or `/source/_include` (for Octopress) directory. Include it somewhere in your layout file: Put `revision.html` and `recent_updated.html` in `/_include` (for Jekyll) or `/source/_include` (for Octopress) directory.
### Revision History
Include `revision.html` somewhere in your layout file:
{% include revision.html %} {% include revision.html %}
You may modify `revision.html` to get the presentation you want. It lists the revision history of the current post/page. You may modify `revision.html` to get the presentation you want.
### Recent Updates
Include `recent_updated.html` somewhere in your layout file:
{% include recent_updated.html %}
It lists 10 most recent updated pages and posts in your site. You may modify `recent_updated.html` to get the presentation you want.
## Configuration ## Configuration
......
...@@ -11,6 +11,7 @@ module Jekyll ...@@ -11,6 +11,7 @@ module Jekyll
%w(posts pages docs_to_write).each do |type| %w(posts pages docs_to_write).each do |type|
site.send(type).each do |item| site.send(type).each do |item|
item.data['revisions'] = GitLogger.new(site.source, item.path, site.config['revision']).revisions item.data['revisions'] = GitLogger.new(site.source, item.path, site.config['revision']).revisions
item.data['last_modified_at'] = item.data['revisions'][0]['date']
end end
end end
end end
......
<ul>
{% assign recentPages = site.pages | sort: 'last_modified_at' | reverse %}
{% for page in recentPages limit:10 %}
<li>
<a href="{{ page.url }}">{{ page.title }}</a>
</li>
{% endfor %}
</ul>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment