-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit af81bee
Showing
19 changed files
with
298 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/spec/fixture/.* | ||
/spec/fixture/_site | ||
/Gemfile.lock | ||
/coverage | ||
/.bundle | ||
/vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
rvm: | ||
- 2.0 | ||
- 2.1 | ||
- 2.2 | ||
notifications: | ||
recipients: | ||
- jordon@envygeeks.io | ||
branches: | ||
only: | ||
- master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
source "https://rubygems.org" | ||
gemspec | ||
|
||
gem "rake" | ||
group :development do | ||
gem "pry" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright 2015 Jordon Bedwell. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[![Build Status](https://travis-ci.org/envygeeks/ruby-jekyll3-post-tags.png?branch=master)](https://travis-ci.org/envygeeks/ruby-jekyll3-post-tags) [![Coverage Status](https://coveralls.io/repos/envygeeks/ruby-jekyll3-post-tags/badge.png?branch=master)](https://coveralls.io/r/envygeeks/ruby-jekyll3-post-tags) [![Code Climate](https://codeclimate.com/github/envygeeks/ruby-jekyll3-post-tags/badges/gpa.svg)](https://codeclimate.com/github/envygeeks/ruby-jekyll3-post-tags) [![Dependency Status](https://gemnasium.com/envygeeks/ruby-jekyll3-post-tags.svg)](https://gemnasium.com/envygeeks/ruby-jekyll3-post-tags) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require "rspec/core/rake_task" | ||
RSpec::Core::RakeTask.new(:spec) | ||
task :default => [:spec] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
$:.unshift(File.expand_path("../lib", __FILE__)) | ||
require "jekyll/post/tags/version" | ||
|
||
Gem::Specification.new do |spec| | ||
spec.description = "Assets using Sprockets 3 for your Jekyll 3" | ||
spec.files = %W(Rakefile Gemfile README.md LICENSE) + Dir["lib/**/*"] | ||
spec.homepage = "http://github.com/envygeeks/ruby-jekyll3-post-tags/" | ||
spec.version = Jekyll::Post::Tags::VERSION | ||
spec.summary = "Post Tags for Jekyll3" | ||
spec.email = ["jordon@envygeeks.io"] | ||
spec.name = "jekyll3-post-tags" | ||
spec.license = "MIT" | ||
spec.has_rdoc = false | ||
spec.require_paths = ["lib"] | ||
spec.authors = ["Jordon Bedwell"] | ||
|
||
spec.add_runtime_dependency("jekyll", "~> 3.0.0.pre.beta7") | ||
spec.add_development_dependency("envygeeks-coveralls", "~> 1.0") | ||
spec.add_development_dependency("luna-rspec-formatters", "~> 3.3") | ||
spec.add_development_dependency("rspec", "~> 3.3") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require "jekyll" | ||
require "jekyll/post" | ||
require_relative "tags/generator" | ||
require_relative "tags/template" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Jekyll | ||
module Tags | ||
class Generator < Jekyll::Generator | ||
priority :low; safe true | ||
|
||
def generate(site) | ||
if site.layouts.has_key?("tag") | ||
then site.tags.keys.each do |t| | ||
site.pages.push( | ||
Post::Tags::Template.new( | ||
site, t | ||
) | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
module Jekyll | ||
class Post | ||
module Tags | ||
class Template < Jekyll::Page | ||
attr_accessor :site, :base, :tag, :dir, :name, :tag_layout | ||
|
||
def initialize(site, tag) | ||
@site = site | ||
@tag = tag | ||
@base = site.source | ||
@dir, @name = tag_path | ||
@tag_layout = "tag.html" | ||
process_tag_template | ||
setup_defaults | ||
end | ||
|
||
def regenerate? | ||
@site.posts.any? do |v| | ||
@site.regenerator.regenerate?(v) | ||
end | ||
end | ||
|
||
def write(*a) | ||
if regenerate? | ||
super | ||
end | ||
end | ||
|
||
def render(*a) | ||
if regenerate? | ||
super | ||
end | ||
end | ||
|
||
private | ||
def process_tag_template | ||
base = File.join(@base, @site.config["layouts"]) | ||
read_yaml(base, @tag_layout) | ||
process(@name) | ||
end | ||
|
||
private | ||
def tag_path | ||
pth = @site.config["tag_permalink"] ||= "tag/:tag" | ||
pth = pth.sub(":tag", @tag).gsub(/\A\//, "").split( | ||
"/" | ||
) | ||
|
||
unless pth[-1] =~ /\.html$/ | ||
pth[-1] = "#{pth[-1]}.html" | ||
end | ||
|
||
[ | ||
pth[0...-1].join("/"), | ||
pth.last | ||
] | ||
end | ||
|
||
private | ||
def setup_defaults | ||
@data["title"] ||= "Tag: #{@tag}" | ||
@data["description"] ||= "Tag: #{@tag}" | ||
@data["tag"] = @tag | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Jekyll | ||
class Post | ||
module Tags | ||
VERSION = "0.0.1" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
--- | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>{{ page.title }}</title> | ||
</head> | ||
<body> | ||
{{ content }} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
layout: default | ||
recent: false | ||
sidebar: "blog" | ||
heading: true | ||
--- | ||
|
||
<ul class="tags"> | ||
{% for post in site.tags[page.tag] %} | ||
<li>{{ page.tag }}</li> | ||
{% endfor %} | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
tags: [hello, world] | ||
--- | ||
|
||
Hello World |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require "rspec/helper" | ||
describe Jekyll::Post::Tags do | ||
before :each do | ||
silence_stdout do | ||
stub_jekyll_site.process | ||
end | ||
end | ||
|
||
let :base do | ||
File.expand_path("../../../../fixture/_site", __FILE__) | ||
end | ||
|
||
it "should generate html pages" do | ||
expect(Pathname.new(File.join(base, "tag/hello.html"))).to exist | ||
expect(Pathname.new(File.join(base, "tag/world.html"))).to exist | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require "rspec" | ||
require "support/simplecov" | ||
require "luna/rspec/formatters/checks" | ||
require "jekyll/post/tags" | ||
require "jekyll" | ||
|
||
Dir[File.expand_path("../../support/*.rb", __FILE__)].each do |v| | ||
require v | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
module Jekyll::RSpecHelpers | ||
def silence_stdout(return_stringio = false) | ||
old_stdout, old_stderr = $stdout, $stderr | ||
$stdout = stdout = StringIO.new | ||
$stderr = stderr = StringIO.new | ||
output = yield | ||
if return_stringio | ||
return [ | ||
$stdout.string, | ||
$stderr.string | ||
] | ||
else | ||
return output | ||
end | ||
ensure | ||
$stdout = old_stdout | ||
$stderr = old_stderr | ||
end | ||
|
||
def capture_stdout(&block) | ||
return silence_stdout( | ||
true, &block | ||
) | ||
end | ||
|
||
def strip_ansi(str) | ||
str.gsub( | ||
/\e\[(?:\d+)(?:;\d+)?m/, "" | ||
) | ||
end | ||
|
||
def stub_jekyll_site(oth_opts = {}) | ||
opts = Jekyll::Utils.deep_merge_hashes( | ||
Jekyll::Configuration::DEFAULTS, { | ||
"full_rebuild" => true, | ||
"source" => File.expand_path("../../fixture", __FILE__), | ||
"destination" => File.expand_path("../../fixture/_site", __FILE__) | ||
} | ||
) | ||
|
||
Jekyll::Site.new( | ||
Jekyll::Utils.deep_merge_hashes( | ||
opts, oth_opts | ||
) | ||
) | ||
end | ||
|
||
def get_stubbed_file(file) | ||
File.read( | ||
File.join( | ||
File.expand_path("../../fixture/_site", __FILE__), file | ||
) | ||
) | ||
end | ||
|
||
class << self | ||
def cleanup_trash | ||
%W(.asset-cache .jekyll-metadata _site _assets/manifest.json).each do |v| | ||
FileUtils.rm_rf( | ||
File.join( | ||
File.expand_path("../../fixture", __FILE__), v | ||
) | ||
) | ||
end | ||
end | ||
end | ||
end | ||
|
||
RSpec.configure do |c| | ||
c.include Jekyll::RSpecHelpers | ||
c.before(:each) { Jekyll::RSpecHelpers.cleanup_trash } | ||
c.after (:each) { Jekyll::RSpecHelpers.cleanup_trash } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require "envygeeks/coveralls" | ||
SimpleCov.start do | ||
add_filter "/spec/" | ||
add_filter "/vendor/" | ||
end |