jekyll-luna-filters 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/License +11 -0
- data/Readme.md +11 -0
- data/lib/luna/filters.rb +92 -0
- data/lib/luna/filters/version.rb +5 -0
- data/lib/luna/jekyll/luna/filters.rb +1 -0
- metadata +63 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 988924604b765cef2a120c23d4bab6dbbd100539
|
4
|
+
data.tar.gz: 4ccbbf91401d54db2aab20de123fd1a8c765cb39
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1a5cab4ebc971bf09e0fb4d81834e927d7cfb46cac717845b9b9b4e1aecff58eadd7fccf2faba36d867ebbb7d85d688b5e06910f9e42fc942e1b788e1aa5d4c5
|
7
|
+
data.tar.gz: 60e411340a1324576f2f973ee2e7f0717296cb79e6bf7c204630a85a857c2db34ffbd39e5278fb556d48c8d06e0201844030cbf7a3720d987148dfdf728cf13c
|
data/License
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Copyright 2013-2014 Jordon Bedwell.
|
2
|
+
Apache License.
|
3
|
+
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
5
|
+
this file except in compliance with the License. You may obtain a copy of the
|
6
|
+
License at: http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
|
8
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
9
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
11
|
+
specific language governing permissions and limitations under the License.
|
data/Readme.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
## Luna Filters for Jekyll
|
2
|
+
|
3
|
+
Luna Filters for Jekyll are a set of basic filters used by Luna for Jekyll,
|
4
|
+
they provide some basic functions such as date formatting, pretty urls,
|
5
|
+
truncation and others for you to use in your liquid template.
|
6
|
+
|
7
|
+
## Installing
|
8
|
+
|
9
|
+
```
|
10
|
+
gem install jekyll-luna-filters
|
11
|
+
```
|
data/lib/luna/filters.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
module Luna
|
2
|
+
module Filters
|
3
|
+
TAG_ANCHOR = %Q{<a class="tag" href="%s">%s</a>}
|
4
|
+
NO_CAPS = %W(and but or of for nor a an the)
|
5
|
+
TIME_METHODS = {
|
6
|
+
:iso8601_date => "%Y/%m/%0d",
|
7
|
+
:iso_8601_date => :iso8601_date,
|
8
|
+
:pretty_date => "%B %0d, %Y",
|
9
|
+
}
|
10
|
+
|
11
|
+
TIME_METHODS.each do |k, v|
|
12
|
+
if v.is_a?(Symbol)
|
13
|
+
alias_method k, v
|
14
|
+
else
|
15
|
+
define_method k do |i|
|
16
|
+
i.strftime(v)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def pretty_url(out)
|
22
|
+
out.gsub(/(index)?\.html/, "").gsub(/\/$/, "")
|
23
|
+
end
|
24
|
+
|
25
|
+
# -------------------------------------------------------------------------
|
26
|
+
|
27
|
+
def pretty_tag_links(tags, site = @context.registers[:site])
|
28
|
+
path = site.config["tags"]["path"]
|
29
|
+
|
30
|
+
to_sentence(
|
31
|
+
tags.map do |t|
|
32
|
+
TAG_ANCHOR % [pretty_url(path.sub(":tag", t)), t]
|
33
|
+
end
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
# -------------------------------------------------------------------------
|
38
|
+
|
39
|
+
def strip_end_punctuation(input)
|
40
|
+
# There could be some missing out.
|
41
|
+
input.gsub(/(\.|!|\?|\?!|!\?)$/, "")
|
42
|
+
end
|
43
|
+
|
44
|
+
# -------------------------------------------------------------------------
|
45
|
+
|
46
|
+
def titlecase(input)
|
47
|
+
input.split(/\b/).map do |w|
|
48
|
+
if w =~ /\A[A-Z]/ || w.length < 2 then w else
|
49
|
+
NO_CAPS.include?(w.downcase) ? w.downcase : w.capitalize
|
50
|
+
end
|
51
|
+
end.join
|
52
|
+
end
|
53
|
+
|
54
|
+
# -------------------------------------------------------------------------
|
55
|
+
|
56
|
+
def truncate(out, length)
|
57
|
+
if out.respond_to?(:truncate)
|
58
|
+
then out[0...length] + "\s…"
|
59
|
+
else
|
60
|
+
out.truncate(length + 3, {
|
61
|
+
:separator => "\s",
|
62
|
+
:ommission => "…"
|
63
|
+
})
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# -------------------------------------------------------------------------
|
68
|
+
|
69
|
+
def canonical(url)
|
70
|
+
# Because canonical urls should be pretty.
|
71
|
+
pretty_url(url).gsub(%r!/page(/\d+|\d+)/$!, "/")
|
72
|
+
end
|
73
|
+
|
74
|
+
# -------------------------------------------------------------------------
|
75
|
+
# This is hijacked from Rails and edited, thank Rails :)
|
76
|
+
# -------------------------------------------------------------------------
|
77
|
+
|
78
|
+
def to_sentence(ary)
|
79
|
+
return unless ary.is_a?(Array)
|
80
|
+
|
81
|
+
case ary.size
|
82
|
+
when 1 then ary.to_s
|
83
|
+
when 2 then "#{ary[0]}, #{ary[1]}"
|
84
|
+
when 0 then ""
|
85
|
+
else
|
86
|
+
"#{ary[0...-1].join(", ")} and #{ary[-1]}"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
Liquid::Template.register_filter(Luna::Filters)
|
@@ -0,0 +1 @@
|
|
1
|
+
require "luna/filters"
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-luna-filters
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jordon Bedwell
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.4'
|
27
|
+
description: A set of filters for Jekyll.
|
28
|
+
email:
|
29
|
+
- envygeeks@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- License
|
35
|
+
- Readme.md
|
36
|
+
- lib/luna/filters.rb
|
37
|
+
- lib/luna/filters/version.rb
|
38
|
+
- lib/luna/jekyll/luna/filters.rb
|
39
|
+
homepage: http://github.com/envygeeks/jekyll-luna-filters/
|
40
|
+
licenses:
|
41
|
+
- Apache 2.0
|
42
|
+
metadata: {}
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
requirements: []
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 2.2.2
|
60
|
+
signing_key:
|
61
|
+
specification_version: 4
|
62
|
+
summary: A set of filters for Jekyll.
|
63
|
+
test_files: []
|