jekyll-timeago 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ pkg
2
+ .rvmrc
3
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ Jekyll-Timeago
2
+ ==============
3
+ Custom and simple implementation of `timeago` date filter.
4
+
5
+ ## Installation
6
+ Add this gem to your Gemfile and run bundle:
7
+ ```
8
+ gem 'jekyll-timeago'
9
+ ```
10
+ To enable the extension add the following statement to a file in your plugin directory (_plugins/ext.rb):
11
+ ```
12
+ require 'jekyll/timeago'
13
+ ```
14
+ You can copy this [file](https://github.com/markets/jekyll-timeago/blob/master/lib/jekyll/timeago.rb) directly in your plugin directory (_plugins/) as well :)
15
+
16
+ ## Usage
17
+ ```
18
+ <span>{{ page.date | timeago }}</span>
19
+ <h2>{{ page.title }}</h2>
20
+
21
+ <div class="post">
22
+ {{ content }}
23
+ </div>
24
+ ```
25
+
26
+ ## License
27
+ Copyright (c) 2013 Marc Anguera. Unscoped Associations is released under the [MIT](http://opensource.org/licenses/MIT) License.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jekyll/timeago/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jekyll-timeago"
8
+ spec.version = Jekyll::Timeago::VERSION
9
+ spec.authors = ["markets"]
10
+ spec.email = ["srmarc.ai@gmail.com"]
11
+ spec.description = %q{Custom timeago filter for Jekyll}
12
+ spec.summary = %q{Custom timeago filter for Jekyll}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,32 @@
1
+ require "jekyll/timeago/version"
2
+
3
+ module Jekyll
4
+ module Timeago
5
+ def timeago(input)
6
+ time_ago_to_now(input)
7
+ end
8
+
9
+ private
10
+
11
+ def time_ago_to_now(date)
12
+ days_passed = (Date.today - Date.parse(date.to_s)).to_i
13
+
14
+ case days_passed
15
+ when 0
16
+ 'today'
17
+ when 1
18
+ 'yesterday'
19
+ when 2 .. 7
20
+ "#{days_passed} days ago"
21
+ when 8 .. 31
22
+ "#{days_passed/7} weeks ago"
23
+ when 32 .. 365
24
+ "#{days_passed/31} months ago"
25
+ else
26
+ "#{days_passed/365} years ago"
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ Liquid::Template.register_filter(Jekyll::Timeago)
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module Timeago
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-timeago
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - markets
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Custom timeago filter for Jekyll
47
+ email:
48
+ - srmarc.ai@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - README.md
56
+ - Rakefile
57
+ - jekyll-timeago.gemspec
58
+ - lib/jekyll/timeago.rb
59
+ - lib/jekyll/timeago/version.rb
60
+ homepage: ''
61
+ licenses:
62
+ - MIT
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ segments:
74
+ - 0
75
+ hash: 381834157
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ segments:
83
+ - 0
84
+ hash: 381834157
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 1.8.24
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Custom timeago filter for Jekyll
91
+ test_files: []