jekylljournal 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +5 -0
- data/bin/jekylljournal +10 -29
- data/features/yaml_frontmatter.feature +12 -0
- data/jekylljournal.gemspec +1 -0
- data/lib/jekylljournal.rb +1 -0
- data/lib/jekylljournal/journalhandler.rb +66 -0
- data/lib/jekylljournal/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a44abe75dfa7920dce9b4666ab647e2ed0a0948a
|
4
|
+
data.tar.gz: c0520e4ef5b764a402918a62a8c5de7273b169ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80b49507ed639b3cc5f23d025230031701c9a790dc8e1f137c2caa1bb366c7d17e1c75d5f8f5ea2ac7607212fe8696c793c11850e03ad6bcc29b93fa42ddb098
|
7
|
+
data.tar.gz: 7a7f8d27caf9f670a64721e469252fe7cfa894a1782625f0e15dae50578110f0591e5f43ddbab5b37ec05765a660e317422d64ac067092a90accf2f1691f33b1
|
data/README.rdoc
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
A super awesome way of writing daily blog posts with Jekyll.
|
4
4
|
|
5
|
+
{<img src="https://badge.fury.io/rb/jekylljournal.svg" alt="Gem Version" />}[https://badge.fury.io/rb/jekylljournal]
|
6
|
+
{<img src="https://codeclimate.com/github/lorentrogers/jekylljournal/badges/gpa.svg" />}[https://codeclimate.com/github/lorentrogers/jekylljournal]
|
7
|
+
{<img src="https://codeclimate.com/github/lorentrogers/jekylljournal/badges/coverage.svg" />}[https://codeclimate.com/github/lorentrogers/jekylljournal/coverage]
|
8
|
+
{<img src="https://gemnasium.com/lorentrogers/jekylljournal.svg" alt="Dependency Status" />}[https://gemnasium.com/lorentrogers/jekylljournal]
|
9
|
+
|
5
10
|
It's based on this proof of concept, built with bash:
|
6
11
|
https://github.com/lorentrogers/Journal.sh
|
7
12
|
|
data/bin/jekylljournal
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'gli'
|
3
3
|
require 'yaml'
|
4
4
|
require 'date'
|
5
|
+
require './lib/jekylljournal'
|
5
6
|
|
6
7
|
include GLI::App
|
7
8
|
|
@@ -14,21 +15,14 @@ arguments :strict
|
|
14
15
|
desc 'Opens a post for the blog'
|
15
16
|
command :open do |c|
|
16
17
|
c.action do |global_options,options,args|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
frontmatter = <<eol
|
21
|
-
---
|
22
|
-
layout: post
|
23
|
-
title: #{today}
|
24
|
-
---
|
25
|
-
|
26
|
-
eol
|
27
|
-
|
28
|
-
File.write file_name, frontmatter unless File.file? file_name
|
18
|
+
@journal_handler.open
|
19
|
+
end
|
20
|
+
end
|
29
21
|
|
30
|
-
|
31
|
-
|
22
|
+
desc 'Adds all posts to git and commits them'
|
23
|
+
command :save do |c|
|
24
|
+
c.action do
|
25
|
+
@journal_handler.save
|
32
26
|
end
|
33
27
|
end
|
34
28
|
|
@@ -40,21 +34,8 @@ pre do |global,command,options,args|
|
|
40
34
|
# chosen command
|
41
35
|
# Use skips_pre before a command to skip this block
|
42
36
|
# on that command only
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
CONFIG_FILE = File.join(ENV['HOME'],'.jekylljournal.yaml')
|
47
|
-
if File.exists? CONFIG_FILE
|
48
|
-
config_options = YAML.load_file(CONFIG_FILE)
|
49
|
-
if !config_options
|
50
|
-
puts 'Config file empty, please see the readme.'
|
51
|
-
else
|
52
|
-
@options.merge!(config_options)
|
53
|
-
end
|
54
|
-
else
|
55
|
-
puts 'Config file not found, please create one.'
|
56
|
-
end
|
57
|
-
|
37
|
+
@journal_handler = Journalhandler.new
|
38
|
+
return false unless @journal_handler
|
58
39
|
true
|
59
40
|
end
|
60
41
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Feature: Prepend yaml to posts
|
2
|
+
|
3
|
+
Posts should have yaml frontmatter prepended to them.
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given a valid dotfile exists
|
7
|
+
|
8
|
+
Scenario: Create a new post with default yaml
|
9
|
+
Given the blog post for today does not exist
|
10
|
+
When I run `jekylljournal`
|
11
|
+
Then it should create the post for today
|
12
|
+
And the file should have the default yaml frontmatter
|
data/jekylljournal.gemspec
CHANGED
@@ -8,6 +8,7 @@ spec = Gem::Specification.new do |s|
|
|
8
8
|
s.homepage = 'http://www.lorentrogers.com'
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
10
|
s.summary = 'A super awesome way of writing daily blog posts with Jekyll.'
|
11
|
+
s.license = 'GPL-3.0'
|
11
12
|
s.files = `git ls-files`.split("
|
12
13
|
")
|
13
14
|
s.require_paths << 'lib'
|
data/lib/jekylljournal.rb
CHANGED
@@ -0,0 +1,66 @@
|
|
1
|
+
# This class is used to handle Jekyll Journals.
|
2
|
+
# It is generally called from the command line wrapper.
|
3
|
+
class Journalhandler
|
4
|
+
|
5
|
+
# Loads the config dotfile from the default directory and sets the
|
6
|
+
# application options
|
7
|
+
def initialize
|
8
|
+
@options = { }
|
9
|
+
|
10
|
+
config_file = File.join(ENV['HOME'],'.jekylljournal.yaml')
|
11
|
+
if File.exists? config_file
|
12
|
+
config_options = YAML.load_file(config_file)
|
13
|
+
if !config_options
|
14
|
+
puts 'Config file empty, please see the readme.'
|
15
|
+
else
|
16
|
+
@options.merge!(config_options)
|
17
|
+
end
|
18
|
+
else
|
19
|
+
puts 'Config file not found, please create one.'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Opens today's post if it exists, otherwise
|
24
|
+
# it creates a new post, populates it with
|
25
|
+
# the default yaml frontmatter, then opens
|
26
|
+
# this newly created file.
|
27
|
+
def open
|
28
|
+
today = Date.today.strftime '%Y-%m-%d'
|
29
|
+
file_name = "#{@options[:blog_location]}/_posts/#{today}-#{today}.md"
|
30
|
+
# create the file if it doesn't exist
|
31
|
+
frontmatter = <<eol
|
32
|
+
---
|
33
|
+
layout: post
|
34
|
+
title: #{today}
|
35
|
+
---
|
36
|
+
|
37
|
+
eol
|
38
|
+
|
39
|
+
File.write file_name, frontmatter unless File.file? file_name
|
40
|
+
|
41
|
+
puts "Opening #{file_name}"
|
42
|
+
system 'vim', file_name
|
43
|
+
end
|
44
|
+
|
45
|
+
# Adds and commits all new posts and assets to git, then
|
46
|
+
# pushes to the default repositories.
|
47
|
+
# TODO
|
48
|
+
def save
|
49
|
+
puts 'Saving...'
|
50
|
+
run_git_cmd 'add _posts/*'
|
51
|
+
run_git_cmd 'add assets/*'
|
52
|
+
# TODO: this should use more flexible values.
|
53
|
+
# Date format should be a dotfile option
|
54
|
+
# Message format should be a dotfile option
|
55
|
+
run_git_cmd "commit -m \"Save: #{Date.today.strftime '%Y-%m-%d'}\""
|
56
|
+
run_git_cmd 'push'
|
57
|
+
puts 'done.'
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def run_git_cmd cmd
|
63
|
+
location = @options[:blog_location]
|
64
|
+
`git --git-dir=#{location}/.git --work-tree=#{location} #{cmd}`
|
65
|
+
end
|
66
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekylljournal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Loren Rogers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -92,11 +92,13 @@ files:
|
|
92
92
|
- jekylljournal.gemspec
|
93
93
|
- jekylljournal.rdoc
|
94
94
|
- lib/jekylljournal.rb
|
95
|
+
- lib/jekylljournal/journalhandler.rb
|
95
96
|
- lib/jekylljournal/version.rb
|
96
97
|
- test/default_test.rb
|
97
98
|
- test/test_helper.rb
|
98
99
|
homepage: http://www.lorentrogers.com
|
99
|
-
licenses:
|
100
|
+
licenses:
|
101
|
+
- GPL-3.0
|
100
102
|
metadata: {}
|
101
103
|
post_install_message:
|
102
104
|
rdoc_options:
|