middleman-journal 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f3f9fab1125aa632be10f920de866873d65ffa6179fcead198e733b4a603c1b
4
- data.tar.gz: 7abcf5a50b3646124ee97ca5cf46ee91baa356a4e3f10adf1a8d62bf5973c291
3
+ metadata.gz: ce32e8f12dfa9f920707fde800c305f3f4798c0702513bca845b33aac4d17e9e
4
+ data.tar.gz: a6672c771679b7b595ea18eccb410bd04740114ed1872a8599b6ef767f29d92b
5
5
  SHA512:
6
- metadata.gz: 93b9f718a3afbb9232467a470f3f48bb394b5ee66afd90c192120c46ff9aa8169dd1ca903525420da073f776c027f2d873ec4ef6b917574f91d21e2f5aeaab7a
7
- data.tar.gz: d832a5bfbefdf211c1957b9a10ba96a43b00b44fe8d876c883e34351ae080dd3bdcbf3c8c3e1a2389b8b8fb748043df41dcf5db17150ea34af160cf3552cc2d2
6
+ metadata.gz: 6f735442b9e6d3da74cab59145c2f760d4e5c879440bb6e6ec6e94b3515bff900f2223ed3716c9c0f9bb999d602628498fba6778ce83b81dcaa037df49ccb810
7
+ data.tar.gz: a749ac2a7f815b987efbacff0ad4d082cb3024762acd55aa1704560de87ae3172a154980cd12ec539e95d68e3a7bfc333c094ebf1a15ffa98239a34b7ca1da7e
data/Gemfile CHANGED
@@ -12,7 +12,7 @@ group :development do
12
12
  end
13
13
 
14
14
  group :test do
15
- gem 'cucumber'
16
15
  gem 'aruba'
16
+ gem 'cucumber'
17
17
  gem 'rspec'
18
18
  end
data/Rakefile CHANGED
@@ -11,15 +11,15 @@ end
11
11
 
12
12
  require 'rake/clean'
13
13
 
14
- task test: [ :spec ]
14
+ task test: [:spec]
15
15
 
16
16
  require 'rspec/core/rake_task'
17
17
 
18
- desc "Run RSpec"
18
+ desc 'Run RSpec'
19
19
 
20
- RSpec::Core::RakeTask.new do | spec |
20
+ RSpec::Core::RakeTask.new do |spec|
21
21
  spec.pattern = 'spec/**/*_spec.rb'
22
- spec.rspec_opts = [ '--color', '--format documentation' ]
22
+ spec.rspec_opts = ['--color', '--format documentation']
23
23
  end
24
24
 
25
25
  task default: :test
@@ -1,9 +1,9 @@
1
- require "middleman-core"
2
- require "middleman-journal/version"
3
- require "middleman-journal/extension"
4
- require "middleman-journal/commands/entry"
1
+ require 'middleman-core'
2
+ require 'middleman-journal/version'
5
3
 
6
4
  Middleman::Extensions.register :journal do
5
+ require 'middleman-journal/extension'
6
+ require 'middleman-journal/commands/entry'
7
7
 
8
- JournalExtension
8
+ JournalExtension
9
9
  end
@@ -2,18 +2,16 @@ require 'middleman-core/cli'
2
2
  require 'date'
3
3
 
4
4
  module Middleman
5
-
6
5
  module Cli
7
-
8
6
  ##
9
7
  # This class provides an "entry" command for the middleman CLI.
10
8
  #
11
9
  # @usage bundle exec middleman entry --help
12
10
  # @usage bundle exec middleman entry
11
+ # @usage bundle exec middleman entry [BULLET]
13
12
  #
14
13
  ##
15
14
  class Entry < ::Thor::Group
16
-
17
15
  include Thor::Actions
18
16
 
19
17
  check_unknown_options!
@@ -21,41 +19,42 @@ module Middleman
21
19
  # Template files are relative to this file
22
20
  # @return [String]
23
21
  def self.source_root
24
- File.dirname( __FILE__ )
22
+ File.dirname(__FILE__)
25
23
  end
26
24
 
27
25
  def entry
26
+ @date = Time.now
27
+ @title = @date.strftime('%F')
28
+ @slug = @date.strftime('%F')
28
29
 
29
- @date = Time.now
30
- @title = @date.strftime('%F')
31
- @slug = @date.strftime('%F')
30
+ template template_path, destination_path
31
+ end
32
32
 
33
- app = ::Middleman::Application.new do
34
- config[ :mode ] = :config
35
- config[ :disable_sitemap ] = true
36
- config[ :watcher_disable ] = true
37
- config[ :exit_before_ready ] = true
38
- end
33
+ private
39
34
 
40
- absolute_entry_path = File.join(app.source_dir, 'journal', "#{@title}.html.markdown")
35
+ def template_path
36
+ File.expand_path('entry.tt', File.dirname(__FILE__))
37
+ end
41
38
 
42
- if File.exists?(absolute_entry_path)
43
- throw "An entry for #{@title} already exists: #{absolute_entry_path}"
39
+ def destination_path
40
+ app = ::Middleman::Application.new do
41
+ config[:mode] = :config
42
+ config[:disable_sitemap] = true
43
+ config[:watcher_disable] = true
44
+ config[:exit_before_ready] = true
44
45
  end
45
46
 
46
- entry_template = File.expand_path('entry.tt', File.dirname(__FILE__))
47
+ path = File.join(app.source_dir, 'journal', "#{@title}.html.markdown")
47
48
 
48
- template entry_template, absolute_entry_path
49
+ if File.exist?(path)
50
+ throw "An entry for #{@title} already exists: #{path}"
51
+ end
49
52
 
53
+ path
50
54
  end
51
55
 
52
- protected
53
-
54
56
  # Add to CLI
55
- Base.register( self, 'entry', 'entry', 'Add a new entry to the journal' )
56
-
57
- end
58
-
59
- end
60
-
57
+ Base.register(self, 'entry', 'entry', 'Add a new entry to the journal')
58
+ end
59
+ end
61
60
  end
@@ -1,9 +1,22 @@
1
1
  require 'date'
2
+ require 'middleman-journal/journal_data'
3
+ require 'middleman-journal/journal_entry'
4
+ require 'middleman-journal/helpers'
2
5
 
3
6
  class JournalExtension < Middleman::Extension
4
- option :date, Date.today.to_s, 'Unique ID for journal entry'
7
+ option :date, nil, 'Unique ID for journal entry'
5
8
 
6
- def initialize(app, options_hash={}, &block)
9
+ # @return [JournalData] journal data for this journal, which has all
10
+ # information about the journal entries
11
+ attr_reader :data
12
+
13
+ def initialize(app, options_hash = {}, &block)
7
14
  super
8
15
  end
16
+
17
+ def after_configuration
18
+ options = {}
19
+ @data = Middleman::Journal::JournalData.new(@app, self, options)
20
+ @app.sitemap.register_resource_list_manipulator(:journal_entries, @data)
21
+ end
9
22
  end
@@ -0,0 +1,9 @@
1
+ module Middleman
2
+ module Blog
3
+ module Helpers
4
+ def journal
5
+ app.extensions[:journal].data
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,26 @@
1
+ module Middleman
2
+ module Journal
3
+ class JournalData
4
+ def initialize(app, controller, options)
5
+ @app = app
6
+ @options = options
7
+ @controller = controller
8
+
9
+ @_entries = []
10
+ end
11
+
12
+ def entries
13
+ @_entries
14
+ end
15
+
16
+ def manipulate_resource_list(resources)
17
+ resources.each do |resource|
18
+ if resource.path =~ %r/journal\/\d{4}-\d{2}-\d{2}\.html/
19
+ resource.extend JournalEntry
20
+ @_entries << resource
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,17 @@
1
+ module Middleman
2
+ module Journal
3
+ module JournalEntry
4
+ def self.extended(base)
5
+ base.class.send(:attr_accessor, :journal_controller)
6
+ end
7
+
8
+ def title
9
+ data['date']
10
+ end
11
+
12
+ def date
13
+ data['date']
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,7 +1,5 @@
1
1
  module Middleman
2
-
3
- module Journal
4
- VERSION = '0.0.1'
5
- end
6
-
2
+ module Journal
3
+ VERSION = '0.0.2'.freeze
4
+ end
7
5
  end
@@ -1,27 +1,23 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "middleman-journal/version"
1
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
2
+ require 'middleman-journal/version'
4
3
 
5
4
  Gem::Specification.new do |s|
6
- s.name = "middleman-journal"
5
+ s.name = 'middleman-journal'
7
6
  s.version = Middleman::Journal::VERSION
8
7
  s.platform = Gem::Platform::RUBY
9
8
  s.authors = ['Mauro Morales']
10
- s.email = ["mauro@mrls.xyz"]
11
- s.homepage = "http://github.com/mrls/middleman-journal"
12
- s.summary = %q{Middleman Journal Engine Extension}
13
- s.description = %q{Middleman Journal Engine Extension}
14
- s.license = "MIT"
9
+ s.email = ['mauro@mrls.xyz']
10
+ s.homepage = 'http://github.com/mrls/middleman-journal'
11
+ s.summary = 'Middleman Journal Engine Extension'
12
+ s.description = 'Middleman Journal Engine Extension'
13
+ s.license = 'MIT'
15
14
 
16
15
  s.files = `git ls-files`.split("\n")
17
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
- s.require_paths = ["lib"]
20
- s.required_ruby_version = '>= 2.0.0'
21
-
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
18
+ s.require_paths = ['lib']
19
+ s.required_ruby_version = '>= 2.1.0'
20
+
22
21
  # The version of middleman-core your extension depends on
23
- s.add_runtime_dependency("middleman-core", [">= 4.2.1"])
24
-
25
- # Additional dependencies
26
- # s.add_runtime_dependency("gem-name", "gem-version")
22
+ s.add_runtime_dependency('middleman-core', ['>= 4.2.1'])
27
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-journal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mauro Morales
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-10 00:00:00.000000000 Z
11
+ date: 2018-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core
@@ -41,6 +41,9 @@ files:
41
41
  - lib/middleman-journal/commands/entry.rb
42
42
  - lib/middleman-journal/commands/entry.tt
43
43
  - lib/middleman-journal/extension.rb
44
+ - lib/middleman-journal/helpers.rb
45
+ - lib/middleman-journal/journal_data.rb
46
+ - lib/middleman-journal/journal_entry.rb
44
47
  - lib/middleman-journal/version.rb
45
48
  - middleman-journal.gemspec
46
49
  homepage: http://github.com/mrls/middleman-journal
@@ -55,7 +58,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
55
58
  requirements:
56
59
  - - ">="
57
60
  - !ruby/object:Gem::Version
58
- version: 2.0.0
61
+ version: 2.1.0
59
62
  required_rubygems_version: !ruby/object:Gem::Requirement
60
63
  requirements:
61
64
  - - ">="