jekyll-compose 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/jekyll/commands/draft.rb +53 -0
- data/lib/jekyll/commands/post.rb +56 -0
- data/lib/jekyll/commands/publish.rb +42 -0
- data/lib/jekyll/compose/version.rb +1 -1
- metadata +33 -9
- data/.gitignore +0 -17
- data/Gemfile +0 -4
- data/History.markdown +0 -5
- data/LICENSE.txt +0 -22
- data/README.md +0 -29
- data/Rakefile +0 -1
- data/jekyll-compose.gemspec +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8dc9be859858bf16c82b9e73a3466fd1a7d405d
|
4
|
+
data.tar.gz: 03e9bbe08affa67d68ff96076af2d6fbee2a3f91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 159bca1e89f742aabced58ecb2c40d2ced95fa18c80c0c23b27672a84a5d0a5ba282f31ad62c4a022469a2d39ef93c54b3b0f080174b72828405bd75f8f10349
|
7
|
+
data.tar.gz: aee319a385c768187ac90eaef97d44263aa8ff9825f45d44550944a329da35a2860060697304972bddbe4510d57b0a5be72fc1cc3964e1a2401516673bf0616c
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Commands
|
3
|
+
class Draft < Command
|
4
|
+
def self.init_with_program(prog)
|
5
|
+
prog.command(:draft) do |c|
|
6
|
+
c.syntax 'draft NAME'
|
7
|
+
c.description 'Creates a new draft post with the given NAME'
|
8
|
+
|
9
|
+
c.option 'type', '-t TYPE', '--type TYPE', 'Specify the content type'
|
10
|
+
c.option 'layout', '-l LAYOUT', '--layout LAYOUT', 'Specify the post layout'
|
11
|
+
c.option 'force', '-f', '--force', 'Overwrite a draft if it already exists'
|
12
|
+
|
13
|
+
c.action do |args, options|
|
14
|
+
Jekyll::Commands::Draft.process(args, options)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.process(args, options = {})
|
20
|
+
raise ArgumentError.new('You must specify a name.') if args.empty?
|
21
|
+
|
22
|
+
type = options["type"].nil? ? "markdown" : options["type"]
|
23
|
+
layout = options["layout"].nil? ? "post" : options["layout"]
|
24
|
+
|
25
|
+
title = args.shift
|
26
|
+
name = title.gsub(' ', '-').downcase
|
27
|
+
|
28
|
+
draft_path = draft_name(name, type)
|
29
|
+
|
30
|
+
raise ArgumentError.new("A draft already exists at ./#{draft_path}") if File.exist?(draft_path) and !options["force"]
|
31
|
+
|
32
|
+
File.open(draft_path, "w") do |f|
|
33
|
+
f.puts(front_matter(layout, title))
|
34
|
+
end
|
35
|
+
|
36
|
+
puts "New draft created at ./#{draft_path}.\n"
|
37
|
+
end
|
38
|
+
# Internal: Gets the filename of the draft to be created
|
39
|
+
#
|
40
|
+
# Returns the filename of the draft, as a String
|
41
|
+
def self.draft_name(name, ext='markdown')
|
42
|
+
"_drafts/#{name}.#{ext}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.front_matter(layout, title)
|
46
|
+
"---
|
47
|
+
layout: #{layout}
|
48
|
+
title: #{title}
|
49
|
+
---"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Commands
|
3
|
+
class Post < Command
|
4
|
+
def self.init_with_program(prog)
|
5
|
+
prog.command(:post) do |c|
|
6
|
+
c.syntax 'post NAME'
|
7
|
+
c.description 'Creates a new post with the given NAME'
|
8
|
+
|
9
|
+
c.option 'type', '-t TYPE', '--type TYPE', 'Specify the content type'
|
10
|
+
c.option 'layout', '-t LAYOUT', '--layout LAYOUT', 'Specify the post layout'
|
11
|
+
c.option 'date', '-d DATE', '--date DATE', 'Specify the post date'
|
12
|
+
c.option 'force', '-f', '--force', 'Overwrite a post if it already exists'
|
13
|
+
|
14
|
+
c.action do |args, options|
|
15
|
+
Jekyll::Commands::Post.process(args, options)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.process(args, options = {})
|
21
|
+
raise ArgumentError.new('You must specify a name.') if args.empty?
|
22
|
+
|
23
|
+
type = options["type"].nil? ? "markdown" : options["type"]
|
24
|
+
layout = options["layout"].nil? ? "post" : options["layout"]
|
25
|
+
|
26
|
+
date = options["date"].nil? ? Time.now : DateTime.parse(options["date"])
|
27
|
+
|
28
|
+
title = args.shift
|
29
|
+
name = title.gsub(' ', '-').downcase
|
30
|
+
|
31
|
+
post_path = file_name(name, type, date)
|
32
|
+
|
33
|
+
raise ArgumentError.new("A post already exists at ./#{post_path}") if File.exist?(post_path) and !options["force"]
|
34
|
+
|
35
|
+
File.open(post_path, "w") do |f|
|
36
|
+
f.puts(front_matter(layout, title))
|
37
|
+
end
|
38
|
+
|
39
|
+
puts "New post created at ./#{post_path}.\n"
|
40
|
+
end
|
41
|
+
# Internal: Gets the filename of the draft to be created
|
42
|
+
#
|
43
|
+
# Returns the filename of the draft, as a String
|
44
|
+
def self.file_name(name, ext, date)
|
45
|
+
"_posts/#{date.strftime('%Y-%m-%d')}-#{name}.#{ext}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.front_matter(layout, title)
|
49
|
+
"---
|
50
|
+
layout: #{layout}
|
51
|
+
title: #{title}
|
52
|
+
---"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Commands
|
3
|
+
class Publish < Command
|
4
|
+
def self.init_with_program(prog)
|
5
|
+
prog.command(:publish) do |c|
|
6
|
+
c.syntax 'publish NAME'
|
7
|
+
c.description 'Moves a draft into the _posts directory and sets the date'
|
8
|
+
|
9
|
+
c.option 'date', '-d DATE', '--date DATE', 'Specify the post date'
|
10
|
+
|
11
|
+
c.action do |args, options|
|
12
|
+
Jekyll::Commands::Publish.process(args, options)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.process(args, options = {})
|
18
|
+
raise ArgumentError.new('You must specify a name.') if args.empty?
|
19
|
+
|
20
|
+
date = options["date"].nil? ? Date.today : Date.parse(options["date"])
|
21
|
+
file = args.shift
|
22
|
+
|
23
|
+
post_path = post_name(date, file)
|
24
|
+
FileUtils.mv(draft_name(file), post_path)
|
25
|
+
|
26
|
+
puts "Draft #{file} was published to ./#{post_path}"
|
27
|
+
end
|
28
|
+
|
29
|
+
# Internal: Gets the filename of the post to be created
|
30
|
+
#
|
31
|
+
# Returns the filename of the post, as a String
|
32
|
+
def self.post_name(date, name)
|
33
|
+
"_posts/#{date.strftime('%Y-%m-%d')}-#{name}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.draft_name(name)
|
37
|
+
"_drafts/#{name}"
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-compose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Parker Moore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -26,6 +26,34 @@ dependencies:
|
|
26
26
|
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: jekyll
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: shoulda
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
30
58
|
requirements:
|
31
59
|
- - ">="
|
@@ -45,13 +73,9 @@ executables: []
|
|
45
73
|
extensions: []
|
46
74
|
extra_rdoc_files: []
|
47
75
|
files:
|
48
|
-
-
|
49
|
-
-
|
50
|
-
-
|
51
|
-
- LICENSE.txt
|
52
|
-
- README.md
|
53
|
-
- Rakefile
|
54
|
-
- jekyll-compose.gemspec
|
76
|
+
- lib/jekyll/commands/draft.rb
|
77
|
+
- lib/jekyll/commands/post.rb
|
78
|
+
- lib/jekyll/commands/publish.rb
|
55
79
|
- lib/jekyll/compose.rb
|
56
80
|
- lib/jekyll/compose/version.rb
|
57
81
|
homepage: https://github.com/jekyll/jekyll-compose
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/History.markdown
DELETED
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2014 Parker Moore
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# Jekyll::Compose
|
2
|
-
|
3
|
-
Streamline your writing in Jekyll with these commands.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'jekyll-compose'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install jekyll-compose
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
Usage instructions go here.
|
22
|
-
|
23
|
-
## Contributing
|
24
|
-
|
25
|
-
1. Fork it ( http://github.com/<my-github-username>/jekyll-compose/fork )
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
data/Rakefile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
data/jekyll-compose.gemspec
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'jekyll/compose/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "jekyll-compose"
|
8
|
-
spec.version = Jekyll::Compose::VERSION
|
9
|
-
spec.authors = ["Parker Moore"]
|
10
|
-
spec.email = ["parkrmoore@gmail.com"]
|
11
|
-
spec.summary = %q{Streamline your writing in Jekyll with these commands.}
|
12
|
-
spec.description = %q{Streamline your writing in Jekyll with these commands.}
|
13
|
-
spec.homepage = "https://github.com/jekyll/jekyll-compose"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
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.5"
|
22
|
-
spec.add_development_dependency "rake"
|
23
|
-
end
|