dolt 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dolt (0.4.3)
4
+ dolt (0.5.0)
5
5
  async_sinatra (~> 1.0)
6
6
  builder (~> 3.1)
7
7
  em_pessimistic (~> 0.1)
data/bin/dolt CHANGED
@@ -66,6 +66,14 @@ view.helper(Dolt::View::BinaryBlobEmbedder)
66
66
  # Render supported formats as markup, syntax highlight the rest
67
67
  view.helper(Dolt::View::SmartBlobRenderer)
68
68
 
69
+ module MaxDepth
70
+ def maxdepth
71
+ 3
72
+ end
73
+ end
74
+
75
+ view.helper(MaxDepth)
76
+
69
77
  Sinatra::Base.set(:public_folder, File.join(base, "vendor/ui"))
70
78
  server = create_app(ARGV[0], view)
71
79
  Thin::Server.start("0.0.0.0", 3000, server)
@@ -17,5 +17,5 @@
17
17
  #++
18
18
 
19
19
  module Dolt
20
- VERSION = "0.4.3"
20
+ VERSION = "0.5.0"
21
21
  end
@@ -26,7 +26,7 @@ module Dolt
26
26
  url = repo_url(repository, "/tree/#{ref}")
27
27
  <<-HTML
28
28
  <ul class="breadcrumb">
29
- <li><a href="#{url}:"><i class="icon icon-file"></i></a></li>
29
+ <li><a href="#{url}:"><i class="icon icon-file"></i> /</a></li>
30
30
  #{dir_html}<li class="active">#{filename}</li>
31
31
  </ul>
32
32
  HTML
@@ -45,6 +45,8 @@ module Dolt
45
45
 
46
46
  def self.lexer(suffix, code = nil)
47
47
  return @@lexer_aliases[suffix] if @@lexer_aliases[suffix]
48
+ lexer = Pygments::Lexer.find_by_extname(".#{suffix}")
49
+ return lexer.aliases.first || lexer.name if lexer
48
50
  shebang_language(shebang(code)) || suffix
49
51
  end
50
52
 
@@ -79,12 +81,10 @@ module Dolt
79
81
  end
80
82
  end
81
83
 
82
- Dolt::View::SyntaxHighlight.add_lexer_alias("yml", "yaml")
84
+ Dolt::View::SyntaxHighlight.add_lexer_alias("txt", "text")
83
85
  Dolt::View::SyntaxHighlight.add_lexer_alias("ru", "rb")
84
86
  Dolt::View::SyntaxHighlight.add_lexer_alias("Rakefile", "rb")
85
87
  Dolt::View::SyntaxHighlight.add_lexer_alias("Gemfile", "rb")
86
88
  Dolt::View::SyntaxHighlight.add_lexer_alias("Gemfile.lock", "yaml")
87
- Dolt::View::SyntaxHighlight.add_lexer_alias("gemspec", "rb")
88
- Dolt::View::SyntaxHighlight.add_lexer_alias("htm", "html")
89
89
 
90
90
  Dolt::View::SyntaxHighlight.add_lexer_shebang(/\bruby\b/, "rb")
@@ -28,8 +28,7 @@ module Dolt
28
28
  sort(tree.entries.select { |e| e[:type] == :blob })
29
29
  end
30
30
 
31
- def tree_context(repo, ref, path, maxdepth = nil)
32
- levels = accumulate_path(partition_path(path, maxdepth))
31
+ def tree_context(repo, ref, levels)
33
32
  return "" if levels.length == 1 && levels[0].length == 1
34
33
  total = 4 + levels.length
35
34
  colspan = total
@@ -56,7 +55,7 @@ module Dolt
56
55
  file = path == "" ? "/" : File.basename(path)
57
56
  url = object_url(repo, ref, dir, { :type => :tree, :name => file })
58
57
  html = "<a href=\"#{url}\">#{extra} #{file}</a>"
59
- extra = ""
58
+ extra = extra == "" || extra == "/" ? "/" : ""
60
59
  html
61
60
  end).join(" ")
62
61
  end
@@ -67,7 +66,8 @@ module Dolt
67
66
  return result if path == ""
68
67
  parts = path.split("/")
69
68
  maxdepth ||= parts.length
70
- (parts.length - maxdepth + 1).times { result[0] << parts.shift }
69
+ fill_first = [parts.length, [1, parts.length - maxdepth + 1].max].min
70
+ fill_first.times { result[0] << parts.shift }
71
71
  result << [parts.shift] while parts.length > 0
72
72
  result
73
73
  end
@@ -83,12 +83,12 @@ module Dolt
83
83
  end
84
84
  end
85
85
 
86
- def tree_table_padding_width(path)
87
- path.split("/").length
86
+ def tree_table_padding_width(partitioned)
87
+ partitioned.length == 1 ? partitioned[0].length - 1 : partitioned.length
88
88
  end
89
89
 
90
- def tree_table_padding_td(path)
91
- "<td></td>" * tree_table_padding_width(path)
90
+ def tree_table_padding_td(partitioned)
91
+ "<td></td>" * tree_table_padding_width(partitioned)
92
92
  end
93
93
 
94
94
  private
@@ -50,12 +50,12 @@ describe Dolt::Git::Repository do
50
50
 
51
51
  describe "#tree" do
52
52
  it "includes submodule data for trees" do
53
- @repository.tree("master", "vendor").callback do |tree|
53
+ @repository.tree("3dc532f", "vendor").callback do |tree|
54
54
  assert_equal({
55
55
  :type => :submodule,
56
56
  :filemode => 57344,
57
57
  :name => "ui",
58
- :oid => "2b05baa5a2e626cb1a4c4b30299c1db5490979b7",
58
+ :oid => "d167e3e1c17a27e4cf459dd380670801b0659659",
59
59
  :url => "git://gitorious.org/gitorious/ui3.git"
60
60
  }, tree.entries.first)
61
61
  done!
@@ -49,4 +49,17 @@ describe "tree template" do
49
49
  assert_match /<table class="table table-striped gts-tree-explorer"/, markup
50
50
  assert_match /data-gts-tree-history="/, markup
51
51
  end
52
+
53
+ it "renders context for non-empty tree" do
54
+ tree = Tree.new([
55
+ { :type => :tree, :name => "lib" },
56
+ { :type => :submodule, :name => "ui", :url => "git://git.git" },
57
+ { :type => :blob, :name => "file.txt" }
58
+ ])
59
+
60
+ markup = render("app/models", tree)
61
+
62
+ assert_match /icon-folder-open/, markup
63
+ assert_match /tree\/master:app"/, markup
64
+ end
52
65
  end
@@ -56,7 +56,7 @@ describe Dolt::View::Blob do
56
56
  end
57
57
 
58
58
  it "skips highlighting if lexer is missing" do
59
- html = highlight("file.txt", "Yeah yeah yeah")
59
+ html = highlight("file.trololol", "Yeah yeah yeah")
60
60
 
61
61
  assert_equal "Yeah yeah yeah", html
62
62
  end
@@ -120,6 +120,11 @@ describe Dolt::View::Tree do
120
120
  parts = partition_path("lib/dolt/very/deep", 3)
121
121
  assert_equal [["", "lib", "dolt"], ["very"], ["deep"]], parts
122
122
  end
123
+
124
+ it "partitions short path with maxdepth" do
125
+ parts = partition_path("lib", 3)
126
+ assert_equal [["", "lib"]], parts
127
+ end
123
128
  end
124
129
 
125
130
  describe "#accumulate_path" do
@@ -130,8 +135,8 @@ describe Dolt::View::Tree do
130
135
  end
131
136
 
132
137
  describe "#tree_context" do
133
- def context(path)
134
- tree_context("gitorious", "master", path)
138
+ def context(path, maxdepth = nil)
139
+ tree_context("gitorious", "master", accumulate_path(partition_path(path, maxdepth)))
135
140
  end
136
141
 
137
142
  it "renders root as empty string" do
@@ -173,5 +178,22 @@ describe Dolt::View::Tree do
173
178
  tr = select(context("lib/dolt"), "tr")[1]
174
179
  assert_equal 2, select(tr, "td").length
175
180
  end
181
+
182
+ it "renders condensed first entry with slashes" do
183
+ links = select(context("src/phorkie/Database/Adapter", 3), "a")
184
+
185
+ assert_equal "<a href=\"/tree/master:\"><i class=\"icon icon-folder-open\"></i> /</a>", links.first
186
+ assert_equal "<a href=\"/tree/master:src\"> src</a>", links[1]
187
+ assert_equal "<a href=\"/tree/master:src/phorkie\">/ phorkie</a>", links[2]
188
+ end
189
+
190
+ it "renders long condensed first entry with slashes" do
191
+ links = select(context("src/phorkie/Database/Adapter/Elasticsearch", 3), "a")
192
+
193
+ assert_equal "<a href=\"/tree/master:\"><i class=\"icon icon-folder-open\"></i> /</a>", links.first
194
+ assert_equal "<a href=\"/tree/master:src\"> src</a>", links[1]
195
+ assert_equal "<a href=\"/tree/master:src/phorkie\">/ phorkie</a>", links[2]
196
+ assert_equal "<a href=\"/tree/master:src/phorkie/Database\">/ Database</a>", links[3]
197
+ end
176
198
  end
177
199
  end
@@ -17,21 +17,24 @@
17
17
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
19
  %>
20
- <% @title = "#{path == '' ? './' : path} in #{ref}" %>
20
+ <%
21
+ @title = "#{path == '' ? './' : path} in #{ref}"
22
+ levels = accumulate_path(partition_path(path, respond_to?(:maxdepth) ? maxdepth : nil))
23
+ %>
21
24
  <div id="gts-ref-selector-ph"></div>
22
25
  <table class="table table-striped gts-tree-explorer" data-gts-tree-history="<%= tree_history_url(repository, ref, path) %>">
23
26
  <thead>
24
27
  <tr>
25
- <th colspan="<%= tree_table_padding_width("/#{path}") %>">File</th>
28
+ <th colspan="<%= tree_table_padding_width(levels) + 1 %>">File</th>
26
29
  <th class="gts-col-changed">Changed</th>
27
30
  <th class="gts-col-commit" colspan="2">Last commit</th>
28
31
  </tr>
29
32
  </thead>
30
33
  <tbody>
31
- <%= tree_context(repository, ref, path) %>
34
+ <%= tree_context(repository, ref, levels) %>
32
35
  <% tree_entries(tree).each do |object| %>
33
36
  <tr>
34
- <%= tree_table_padding_td(path) %>
37
+ <%= tree_table_padding_td(levels) %>
35
38
  <td class="gts-name">
36
39
  <a href="<%= object_url(repository, ref, path, object) %>">
37
40
  <i class="icon <%= object_icon_class(object) %>"></i>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dolt
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
9
- - 3
10
- version: 0.4.3
8
+ - 5
9
+ - 0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Christian Johansen