middleman-postdated 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2292d4fe5eb50ada72c0a9df6bfb748dd90d8218
4
+ data.tar.gz: d528df8af06638b04e389fbdc1f0e272445418d5
5
+ SHA512:
6
+ metadata.gz: 1592b91f13e775a27d28b9cb402f3950281778d86b6b520e93c6e865478402fb2bb9713126e3a0177ce92ff3675a03f707a8333ff8a0d4d05a1706ca393c0ce2
7
+ data.tar.gz: c732fa325597e76c1dbc77e1806070f4cc65448cf5a942e9586dea19de54b6f498e6252b2de0e1c4404522e8e69e0eb8adbfe86c8d3a958c66614b24bdfbebdd
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ # Ignore bundler lock file
2
+ /Gemfile.lock
3
+
4
+ # Ignore pkg folder
5
+ /pkg
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in plaintext.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Caius Durling
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # middleman-postdated
2
+
3
+ Reads resource date from filename, instead of frontmatter.
4
+
5
+ Handy when you have blog-like dated posts/resources and want them named on disk for the day they were published (`2015-01-01-first-thing`, `2015-02-03-other-thing`, etc), but can't be bothered to duplicate that information in the frontmatter of the resource as well.
6
+
7
+ This extension is currently very opinionated, but if you align with those opinions it'll be useful:
8
+
9
+ * Files are named `yyyy-mm-dd-title`
10
+ * Frontmatter dates take precedence over filename dates
11
+ * Time element of filename date is `10:00:00`
12
+ * All resources should be amended if they pass the previous criteria
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,32 @@
1
+ require "middleman-postdated/version"
2
+ require "middleman-core"
3
+
4
+ module Middleman
5
+ class PostdatedExtension < Extension
6
+
7
+ # Run after frontmatter
8
+ self.resource_list_manipulator_priority = 21
9
+
10
+ # A Sitemap Manipulator
11
+ def manipulate_resource_list(resources)
12
+ resources.map(&method(:postdate))
13
+ end
14
+
15
+ private
16
+
17
+ def postdate(resource)
18
+ # If it already has a date, we ignore it
19
+ return resource if resource.data[:date]
20
+
21
+ # Attempt to grab date from filename, and give up if we can't
22
+ datestring = resource.path[%r{(?:^|/)(\d{4}-\d{2}-\d{2})-}, 1]
23
+ return resource unless datestring
24
+
25
+ date = Date.parse(datestring, "yyyy-mm-dd")
26
+ # Add it to the :page metadata specifically
27
+ resource.add_metadata :page => {:date => Time.utc(date.year, date.month, date.day, 10, 0, 0)}
28
+
29
+ resource
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,5 @@
1
+ module Middleman
2
+ module Postdated
3
+ VERSION = "0.5.0"
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ require "middleman-core"
2
+ require "middleman-postdated/extension"
3
+
4
+ Middleman::Extensions.register(:postdated) { Middleman::PostdatedExtension }
@@ -0,0 +1,21 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "middleman-postdated/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "middleman-postdated"
6
+ s.version = Middleman::Postdated::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Caius Durling"]
9
+ s.email = %w(dev@caius.name)
10
+ s.summary = %{Sets missing resource dates from filenames}
11
+ s.description = %{Reads the filename of your site resources which don't have dates set, and sets them according to filename.}
12
+
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
+ s.require_paths = ["lib"]
17
+
18
+ s.add_runtime_dependency "middleman-core", "~> 4.1"
19
+
20
+ s.add_development_dependency "rake"
21
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman-postdated
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - Caius Durling
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: middleman-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Reads the filename of your site resources which don't have dates set,
42
+ and sets them according to filename.
43
+ email:
44
+ - dev@caius.name
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE
52
+ - README.md
53
+ - Rakefile
54
+ - lib/middleman-postdated.rb
55
+ - lib/middleman-postdated/extension.rb
56
+ - lib/middleman-postdated/version.rb
57
+ - middleman-postdated.gemspec
58
+ homepage:
59
+ licenses: []
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.6.4
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Sets missing resource dates from filenames
81
+ test_files: []