middleman-navtree 0.1.5 → 0.1.6

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTNlZGZmMWRhZTRhNTJjMDQxNzhlNDRkMjI5Y2Q2OTE3NTQwZWM1MQ==
4
+ NDQyNWI2MjdhYTkxYzFhODMxYzNlOGEyZGY2N2E3MjM3MjNkNTBjMg==
5
5
  data.tar.gz: !binary |-
6
- MTQxY2VmODA1NTA0MmZhNjY5NGYwNjQ3ZjU4YzE5MWJmZmFiMjEyZg==
6
+ NjhlNTU4NDgzYTE0MzU4YThmOTRmNzAxNjk4ZmVlMzU5ZjVkMjk5NQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjFmYzk3NjBhMGE1NWUwNjdiMWZkNDZhYzQ4OTMxOGZhODdmYjJhOTdjZGU1
10
- ZmUwODFlNDFlZjFhZWUxNWJkMzYxODM1MGFjNTBlY2I0NGE0Zjg3ODhhM2E1
11
- ODQwNGVmMWU0MmIyOTYzMWVmMDJlMmJkNWY3MDZjMjdlNzg4MDM=
9
+ ZDc2NTJjNmIyYjVhMTU0NWFiZmVlODUwNmE3YzU0MjNmNDlkYWQ5ZGRmY2Uw
10
+ ZjM2YThjNjM2ZmVhNDAxNjNlZWY3Zjk2MWUyZDk0OGJlMGE2NzIwM2Q3OWVj
11
+ ZjZjMTdlNzYwMTVmMWJhZTU2YzAzODYwZTNhYzE3MGY4NGFhMWE=
12
12
  data.tar.gz: !binary |-
13
- N2JjZTQwNzI3NjMxZTBiOTJlOGRhYTA0Njc3YzhmYjUwYTRmMTRlZGU1ZGZh
14
- NWEwN2FiMWJmNTRlZjJlOTA3YjgxN2Q3ZTkxNTNhZWNhOWYxZmIyZTFkNjYx
15
- MWI3Yzc4YTBiMzA1MjEzYTM2OGQwZDA5MTkxNmJjMWU5NmFkNmE=
13
+ NDI1M2JhNzk0YmI4YjcwMDk3MDE1YzFiOTU2Yjg4YWEzYWE5ZDAwYTZlM2I0
14
+ M2VjYjM3ZWRjMTRiMTEwMGJiNGMyZDE2MjVkODkwYjY1YjY0NWE5ZDYxZDc2
15
+ YmFjOTgwYjIxNTgzOThjNTllNjBiYWRhMjgyNzY2NjQ0ZjE2Y2Y=
@@ -56,10 +56,8 @@ module Middleman
56
56
  end
57
57
 
58
58
 
59
- # Method for storing the directory structure in a hash.
60
- # @todo: the order of the data is defined by the order in the hash, and technically, ruby hashes
61
- # are unordered. This may be more robust if I defined an ordered hash type similar to
62
- # this one in Rails: http://apidock.com/rails/ActiveSupport/OrderedHash
59
+ # Method for storing the directory structure in an ordered hash. See more on
60
+ # ordered hashes at https://www.igvita.com/2009/02/04/ruby-19-internals-ordered-hash/
63
61
  def scan_directory(path, options, name=nil)
64
62
  data = {}
65
63
  Dir.foreach(path) do |filename|
@@ -98,7 +96,8 @@ module Middleman
98
96
  end
99
97
  end
100
98
 
101
- return data
99
+ # Return this level's data as a hash sorted by keys.
100
+ return Hash[data.sort]
102
101
  end
103
102
 
104
103
  # Method for appending promoted files to the front of our source tree.
@@ -86,10 +86,7 @@ module Middleman
86
86
  end
87
87
 
88
88
  # Method to flatten the source tree, for use in pagination methods.
89
- # Note, I could do this with a lot less code using Glob. I should refactor
90
- # in the future. See http://stackoverflow.com/a/2370823/1154642.
91
89
  def flatten_source_tree(value, k = [], level = 0, flat_tree = [])
92
-
93
90
  if value.is_a?(String)
94
91
  # This is a child item (a file).
95
92
  flat_tree.push(sitemap.extensionless_path(value))
@@ -116,8 +113,13 @@ module Middleman
116
113
  end
117
114
 
118
115
  # Format Directory name for display in navtree.
116
+ # Example Name: 1%20-%20sink-or_swim
119
117
  def format_directory_name(dir_name)
120
- dir_name.gsub(/-/, ' ').gsub(/_/, ' ').gsub('%20', ' ').titleize
118
+ dir_name.gsub!('%20', ' ') #=> 1 - sink-or_swim
119
+ dir_name.gsub!(/(?!\s)-(?!\s)/, ' ') #=> 1 - sink or_swim
120
+ dir_name.gsub!(/_/, ' ') #=> 1 - sink or swim
121
+ # @todo: Find a way for titleize to not blow away ' - ' formatting.
122
+ dir_name.titleize! #=> 1 Sink or Swim
121
123
  end
122
124
 
123
125
  # Utility helper for getting the page title for display in the navtree.
@@ -129,12 +131,12 @@ module Middleman
129
131
  def discover_title(page = current_page)
130
132
  if page.data.title
131
133
  return page.data.title # Frontmatter title
132
- elsif page.url == '/'
133
- return extensions[:navtree].options[:home_title]
134
134
  elsif match = page.render({:layout => false}).match(/<h.+>(.*?)<\/h1>/)
135
135
  return match[1] # H1 title
136
+ elsif page.url == '/'
137
+ return extensions[:navtree].options[:home_title]
136
138
  else
137
- filename = page.url.split(/\//).last.titleize.gsub('%20', ' ')
139
+ filename = page.url.split(/\//).last.gsub('%20', ' ').titleize
138
140
  return filename.chomp(File.extname(filename))
139
141
  end
140
142
  end
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module NavTree
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "middleman-navtree"
6
- s.version = "0.1.5"
6
+ s.version = "0.1.6"
7
7
  s.licenses = ['MIT']
8
8
  s.date = Date.today.to_s
9
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-navtree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Braun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-10 00:00:00.000000000 Z
11
+ date: 2014-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core