libdolt 0.6.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.
Files changed (68) hide show
  1. data/Gemfile +3 -0
  2. data/Gemfile.lock +56 -0
  3. data/Rakefile +10 -0
  4. data/Readme.md +99 -0
  5. data/lib/libdolt/async/when.rb +128 -0
  6. data/lib/libdolt/disk_repo_resolver.rb +39 -0
  7. data/lib/libdolt/git/blame.rb +112 -0
  8. data/lib/libdolt/git/commit.rb +73 -0
  9. data/lib/libdolt/git/repository.rb +139 -0
  10. data/lib/libdolt/git/submodule.rb +35 -0
  11. data/lib/libdolt/git/tree.rb +42 -0
  12. data/lib/libdolt/repo_actions.rb +95 -0
  13. data/lib/libdolt/version.rb +21 -0
  14. data/lib/libdolt/view/binary_blob_embedder.rb +41 -0
  15. data/lib/libdolt/view/blame.rb +57 -0
  16. data/lib/libdolt/view/blob.rb +97 -0
  17. data/lib/libdolt/view/breadcrumb.rb +47 -0
  18. data/lib/libdolt/view/commit.rb +27 -0
  19. data/lib/libdolt/view/gravatar.rb +29 -0
  20. data/lib/libdolt/view/markup.rb +44 -0
  21. data/lib/libdolt/view/multi_repository.rb +27 -0
  22. data/lib/libdolt/view/object.rb +44 -0
  23. data/lib/libdolt/view/single_repository.rb +27 -0
  24. data/lib/libdolt/view/smart_blob_renderer.rb +33 -0
  25. data/lib/libdolt/view/syntax_highlight.rb +40 -0
  26. data/lib/libdolt/view/tab_width.rb +30 -0
  27. data/lib/libdolt/view/tree.rb +100 -0
  28. data/lib/libdolt/view.rb +23 -0
  29. data/lib/libdolt.rb +29 -0
  30. data/libdolt.gemspec +35 -0
  31. data/test/libdolt/async/when_test.rb +112 -0
  32. data/test/libdolt/git/blame_test.rb +128 -0
  33. data/test/libdolt/git/commit_test.rb +89 -0
  34. data/test/libdolt/git/repository_test.rb +186 -0
  35. data/test/libdolt/repo_actions_test.rb +236 -0
  36. data/test/libdolt/templates/blame_test.rb +54 -0
  37. data/test/libdolt/templates/blob_test.rb +116 -0
  38. data/test/libdolt/templates/commits_test.rb +59 -0
  39. data/test/libdolt/templates/raw_test.rb +39 -0
  40. data/test/libdolt/templates/refs_test.rb +36 -0
  41. data/test/libdolt/templates/tree_history_test.rb +91 -0
  42. data/test/libdolt/templates/tree_test.rb +63 -0
  43. data/test/libdolt/view/binary_blob_embedder_test.rb +49 -0
  44. data/test/libdolt/view/blame_test.rb +122 -0
  45. data/test/libdolt/view/blob_test.rb +116 -0
  46. data/test/libdolt/view/breadcrumb_test.rb +46 -0
  47. data/test/libdolt/view/commit_test.rb +31 -0
  48. data/test/libdolt/view/gravatar_test.rb +30 -0
  49. data/test/libdolt/view/markup_test.rb +70 -0
  50. data/test/libdolt/view/multi_repository_test.rb +35 -0
  51. data/test/libdolt/view/object_test.rb +83 -0
  52. data/test/libdolt/view/single_repository_test.rb +30 -0
  53. data/test/libdolt/view/smart_blob_renderer_test.rb +38 -0
  54. data/test/libdolt/view/syntax_highlight_test.rb +80 -0
  55. data/test/libdolt/view/tab_width_test.rb +40 -0
  56. data/test/libdolt/view/tree_test.rb +196 -0
  57. data/test/test_helper.rb +50 -0
  58. data/views/500.erb +22 -0
  59. data/views/blame.erb +42 -0
  60. data/views/blob.erb +31 -0
  61. data/views/commits.erb +26 -0
  62. data/views/index.erb +25 -0
  63. data/views/layout.erb +45 -0
  64. data/views/raw.erb +19 -0
  65. data/views/refs.erb +22 -0
  66. data/views/tree.erb +50 -0
  67. data/views/tree_history.erb +19 -0
  68. metadata +326 -0
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ #--
3
+ # Copyright (C) 2012 Gitorious AS
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ #++
18
+ require "test_helper"
19
+ require "libdolt/view/multi_repository"
20
+
21
+ describe Dolt::View::MultiRepository do
22
+ include Dolt::Html
23
+ include Dolt::View::MultiRepository
24
+
25
+ describe "#repo_url" do
26
+ it "returns url prefixed with repository" do
27
+ assert_equal "/gitorious/some/url", repo_url("gitorious", "/some/url")
28
+ end
29
+
30
+ it "returns url prefixed with repository name containing slashes" do
31
+ url = repo_url("gitorious/mainline", "/some/url")
32
+ assert_equal "/gitorious/mainline/some/url", url
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,83 @@
1
+ # encoding: utf-8
2
+ #--
3
+ # Copyright (C) 2012 Gitorious AS
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ #++
18
+ require "test_helper"
19
+ require "libdolt/view/single_repository"
20
+ require "libdolt/view/multi_repository"
21
+ require "libdolt/view/object"
22
+
23
+ describe Dolt::View::Object do
24
+ include Dolt::View::Object
25
+
26
+ describe "single repo mode" do
27
+ include Dolt::View::SingleRepository
28
+
29
+ it "returns blob url" do
30
+ object = { :type => "blob", :name => "Gemfile" }
31
+ url = object_url("myrepo", "master", "", object)
32
+ assert_equal "/blob/master:Gemfile", url
33
+ end
34
+
35
+ it "returns tree url" do
36
+ object = { :type => "tree", :name => "models" }
37
+ url = object_url("myrepo", "master", "app", object)
38
+ assert_equal "/tree/master:app/models", url
39
+ end
40
+
41
+ it "returns blob url in directory" do
42
+ object = { :type => "blob", :name => "Gemfile" }
43
+ url = object_url("myrepo", "master", "lib/mything", object)
44
+ assert_equal "/blob/master:lib/mything/Gemfile", url
45
+ end
46
+ end
47
+
48
+ describe "multi repo mode" do
49
+ include Dolt::View::MultiRepository
50
+
51
+ it "returns blob url" do
52
+ object = { :type => "blob", :name => "Gemfile" }
53
+ url = object_url("myrepo", "master", "", object)
54
+ assert_equal "/myrepo/blob/master:Gemfile", url
55
+ end
56
+
57
+ it "returns blob url in directory" do
58
+ object = { :type => "blob", :name => "Gemfile" }
59
+ url = object_url("myrepo", "master", "lib/mything", object)
60
+ assert_equal "/myrepo/blob/master:lib/mything/Gemfile", url
61
+ end
62
+ end
63
+
64
+ describe "#object_icon_class" do
65
+ it "returns blob icon type" do
66
+ assert_equal "icon-file", object_icon_class({ :type => :blob })
67
+ end
68
+
69
+ it "returns tree icon type" do
70
+ assert_equal "icon-folder-close", object_icon_class({ :type => :tree })
71
+ end
72
+
73
+ it "returns submodule icon type" do
74
+ assert_equal "icon-hdd", object_icon_class({ :type => :submodule })
75
+ end
76
+ end
77
+
78
+ it "links submodule object to submodule" do
79
+ url = "git://gitorious.org/gitorious/ui3.git"
80
+ object = { :type => :submodule, :url => url }
81
+ assert_equal url, object_url("gitorious", "master", "vendor", object)
82
+ end
83
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+ #--
3
+ # Copyright (C) 2012 Gitorious AS
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ #++
18
+ require "test_helper"
19
+ require "libdolt/view/single_repository"
20
+
21
+ describe Dolt::View::SingleRepository do
22
+ include Dolt::Html
23
+ include Dolt::View::SingleRepository
24
+
25
+ describe "#repo_url" do
26
+ it "returns url unmodified" do
27
+ assert_equal "/some/url", repo_url("gitorious", "/some/url")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+ #--
3
+ # Copyright (C) 2012 Gitorious AS
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ #++
18
+ require "test_helper"
19
+ require "libdolt/view/smart_blob_renderer"
20
+
21
+ describe Dolt::View::SmartBlobRenderer do
22
+ include Dolt::View::Blob
23
+ include Dolt::View::SmartBlobRenderer
24
+
25
+ describe "#format_text_blob" do
26
+ it "highlights a Ruby file" do
27
+ html = format_text_blob("file.rb", "class File\n attr_reader :path\nend")
28
+
29
+ assert_match "<span class=\"k\">class</span>", html
30
+ assert_match "<span class=\"nc\">File</span>", html
31
+ end
32
+
33
+ it "wraps markup in .gts-markup" do
34
+ html = render_markup("file.md", "# Hey")
35
+ assert_match "<div class=\"gts-markup\">", html
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,80 @@
1
+ # encoding: utf-8
2
+ #--
3
+ # Copyright (C) 2012 Gitorious AS
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ #++
18
+ require "test_helper"
19
+ require "makeup/syntax_highlighter"
20
+ require "libdolt/view/single_repository"
21
+ require "libdolt/view/multi_repository"
22
+ require "libdolt/view/blob"
23
+ require "libdolt/view/syntax_highlight"
24
+
25
+ describe Dolt::View::Blob do
26
+ include Dolt::View::Blob
27
+ include Dolt::View::SyntaxHighlight
28
+
29
+ describe "#highlight" do
30
+ it "highlights a Ruby file" do
31
+ html = highlight("file.rb", "class File\n attr_reader :path\nend")
32
+
33
+ assert_match "<span class=\"k\">class</span>", html
34
+ assert_match "<span class=\"nc\">File</span>", html
35
+ end
36
+
37
+ it "highlights a YAML file" do
38
+ html = highlight("file.yml", "something:\n is: true")
39
+
40
+ assert_match "<span class=\"l-Scalar-Plain\">something</span>", html
41
+ assert_match "<span class=\"p-Indicator\">:", html
42
+ end
43
+
44
+ it "highlights an .htm file" do
45
+ html = highlight("file.htm", "<h1>Hey</h1>")
46
+
47
+ assert_match "<span class=\"nt\">&lt;h1&gt;</span>", html
48
+ assert_match "Hey<span class=\"nt\">&lt;/h1&gt;</span>", html
49
+ end
50
+
51
+ it "highlights file with custom suffix" do
52
+ Makeup::SyntaxHighlighter.add_lexer_alias("derp", "rb")
53
+ html = highlight("file.derp", "class File")
54
+
55
+ assert_match "<span class=\"k\">class</span>", html
56
+ assert_match "<span class=\"nc\">File</span>", html
57
+ end
58
+
59
+ it "skips highlighting if lexer is missing" do
60
+ html = highlight("file.trololol", "Yeah yeah yeah")
61
+
62
+ assert_equal "Yeah yeah yeah", html
63
+ end
64
+ end
65
+
66
+ describe "#format_blob" do
67
+ it "highlights a Ruby file with line nums" do
68
+ html = format_blob("file.rb", "class File\n attr_reader :path\nend")
69
+
70
+ assert_match "<li class=\"L1\">", html
71
+ assert_match "<span class=\"k\">class</span>", html
72
+ end
73
+
74
+ it "includes lexer as class name" do
75
+ html = format_blob("file.rb", "class File\n attr_reader :path\nend")
76
+
77
+ assert_match "rb", html
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+ #--
3
+ # Copyright (C) 2012 Gitorious AS
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ #++
18
+ require "test_helper"
19
+ require "libdolt/view/tab_width"
20
+
21
+ describe Dolt::View::TabWidth do
22
+ include Dolt::View::Blob
23
+ include Dolt::View::TabWidth
24
+
25
+ describe "#format_whitespace" do
26
+ it "limits width of whitespace" do
27
+ Dolt::View::TabWidth.tab_width = 4
28
+ html = format_whitespace("class File\n\tattr_reader :path\nend")
29
+
30
+ assert_match(/ attr_reader/, html)
31
+ end
32
+
33
+ it "uses wide tabs in formatted blobs" do
34
+ Dolt::View::TabWidth.tab_width = 12
35
+ html = format_text_blob("file.rb", "class File\n\tattr_reader :path\nend")
36
+
37
+ assert_match(/ attr_reader/, html)
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,196 @@
1
+ # encoding: utf-8
2
+ #--
3
+ # Copyright (C) 2012 Gitorious AS
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ #++
18
+ require "test_helper"
19
+ require "libdolt/view/single_repository"
20
+ require "libdolt/view/object"
21
+ require "libdolt/view/tree"
22
+ require "ostruct"
23
+
24
+ describe Dolt::View::Tree do
25
+ include Dolt::Html
26
+ include Dolt::View::SingleRepository
27
+ include Dolt::View::Object
28
+ include Dolt::View::Tree
29
+
30
+ describe "#tree_entries" do
31
+ before do
32
+ async = { :name => "async", :type => :tree }
33
+ disk_repo_resolver = { :type => :blob, :name => "disk_repo_resolver.rb" }
34
+ git = { :type => :tree, :name => "git" }
35
+ repo_actions = { :type => :blob, :name => "repo_actions.rb" }
36
+ sinatra = { :type => :tree, :name => "sinatra" }
37
+ version = { :type => :blob, :name => "version.rb" }
38
+ view_rb = { :type => :blob, :name => "view.rb" }
39
+ view = { :type => :tree, :name => "view" }
40
+ @tree = OpenStruct.new({ :entries => [async, disk_repo_resolver, git,
41
+ repo_actions, sinatra, version,
42
+ view_rb, view] })
43
+ end
44
+
45
+ it "groups tree by type, dirs first" do
46
+ entries = tree_entries(@tree)
47
+
48
+ assert_equal :tree, entries[0][:type]
49
+ assert_equal :tree, entries[1][:type]
50
+ assert_equal :tree, entries[2][:type]
51
+ assert_equal :tree, entries[3][:type]
52
+ assert_equal :blob, entries[4][:type]
53
+ assert_equal :blob, entries[5][:type]
54
+ assert_equal :blob, entries[6][:type]
55
+ assert_equal :blob, entries[7][:type]
56
+ end
57
+
58
+ it "sorts by name" do
59
+ entries = tree_entries(@tree)
60
+
61
+ assert_equal "async", entries[0][:name]
62
+ assert_equal "git", entries[1][:name]
63
+ assert_equal "sinatra", entries[2][:name]
64
+ assert_equal "view", entries[3][:name]
65
+ assert_equal "disk_repo_resolver.rb", entries[4][:name]
66
+ assert_equal "repo_actions.rb", entries[5][:name]
67
+ assert_equal "version.rb", entries[6][:name]
68
+ assert_equal "view.rb", entries[7][:name]
69
+ end
70
+
71
+ it "lumps submodules in with directories" do
72
+ async = { :name => "async", :type => :tree }
73
+ disk_repo_resolver = { :type => :blob, :name => "disk_repo_resolver.rb" }
74
+ git = { :type => :submodule, :name => "git" }
75
+ tree = OpenStruct.new({ :entries => [async, disk_repo_resolver, git] })
76
+ entries = tree_entries(tree)
77
+
78
+ assert_equal :tree, entries[0][:type]
79
+ assert_equal :submodule, entries[1][:type]
80
+ assert_equal :blob, entries[2][:type]
81
+ end
82
+ end
83
+
84
+ describe "#partition_path" do
85
+ it "partitions root into double array" do
86
+ parts = partition_path("")
87
+ assert_equal [[""]], parts
88
+
89
+ parts = partition_path("/")
90
+ assert_equal [[""]], parts
91
+
92
+ parts = partition_path("./")
93
+ assert_equal [[""]], parts
94
+ end
95
+
96
+ it "partitions single directory" do
97
+ parts = partition_path("lib")
98
+ assert_equal [["", "lib"]], parts
99
+ end
100
+
101
+ it "partitions two directories" do
102
+ parts = partition_path("lib/dolt")
103
+ assert_equal [["", "lib"], ["dolt"]], parts
104
+ end
105
+
106
+ it "partitions multiple directories" do
107
+ parts = partition_path("lib/dolt/git/help")
108
+ assert_equal [["", "lib"], ["dolt"], ["git"], ["help"]], parts
109
+ end
110
+
111
+ it "ignore trailing slash" do
112
+ parts = partition_path("lib/dolt/")
113
+ assert_equal [["", "lib"], ["dolt"]], parts
114
+ end
115
+
116
+ it "chunks up leading path" do
117
+ parts = partition_path("lib/dolt/very/deep", 3)
118
+ assert_equal [["", "lib", "dolt"], ["very"], ["deep"]], parts
119
+ end
120
+
121
+ it "partitions short path with maxdepth" do
122
+ parts = partition_path("lib", 3)
123
+ assert_equal [["", "lib"]], parts
124
+ end
125
+ end
126
+
127
+ describe "#accumulate_path" do
128
+ it "accumulates partitioned path" do
129
+ parts = accumulate_path(partition_path("lib/dolt/very/deep", 3))
130
+ assert_equal [["", "lib", "lib/dolt"], ["lib/dolt/very"], ["lib/dolt/very/deep"]], parts
131
+ end
132
+ end
133
+
134
+ describe "#tree_context" do
135
+ def context(path, maxdepth = nil)
136
+ tree_context("gitorious", "master", accumulate_path(partition_path(path, maxdepth)))
137
+ end
138
+
139
+ it "renders root as empty string" do
140
+ assert_equal "", context("")
141
+ assert_equal "", context("/")
142
+ assert_equal "", context("./")
143
+ end
144
+
145
+ it "renders single path item as table row" do
146
+ assert_equal 1, select(context("lib"), "tr").length
147
+ assert_equal 1, select(context("./lib"), "tr").length
148
+ end
149
+
150
+ it "includes link to root in single table row" do
151
+ assert_equal 2, select(context("lib"), "a").length
152
+ end
153
+
154
+ it "renders single path item in cell" do
155
+ assert_equal 1, select(context("lib"), "td").length
156
+ end
157
+
158
+ it "renders single path item as link" do
159
+ # Two, because there's always a link to the root directory
160
+ assert_equal 2, select(context("lib"), "a").length
161
+ assert_match /lib/, select(context("lib"), "a")[1]
162
+ end
163
+
164
+ it "renders single path item with open folder icon" do
165
+ assert_match /icon-folder-open/, select(context("lib"), "i").first
166
+ end
167
+
168
+ it "renders two path items as two table rows" do
169
+ assert_equal 2, select(context("lib/dolt"), "tr").length
170
+ end
171
+
172
+ it "renders two path items with colspan in first row" do
173
+ assert_match /colspan="6"/, select(context("lib/dolt"), "tr").first
174
+ assert_match /colspan="5"/, select(context("lib/dolt"), "tr")[1]
175
+ tr = select(context("lib/dolt"), "tr")[1]
176
+ assert_equal 2, select(tr, "td").length
177
+ end
178
+
179
+ it "renders condensed first entry with slashes" do
180
+ links = select(context("src/phorkie/Database/Adapter", 3), "a")
181
+
182
+ assert_equal "<a href=\"/tree/master:\"><i class=\"icon icon-folder-open\"></i> /</a>", links.first
183
+ assert_equal "<a href=\"/tree/master:src\"> src</a>", links[1]
184
+ assert_equal "<a href=\"/tree/master:src/phorkie\">/ phorkie</a>", links[2]
185
+ end
186
+
187
+ it "renders long condensed first entry with slashes" do
188
+ links = select(context("src/phorkie/Database/Adapter/Elasticsearch", 3), "a")
189
+
190
+ assert_equal "<a href=\"/tree/master:\"><i class=\"icon icon-folder-open\"></i> /</a>", links.first
191
+ assert_equal "<a href=\"/tree/master:src\"> src</a>", links[1]
192
+ assert_equal "<a href=\"/tree/master:src/phorkie\">/ phorkie</a>", links[2]
193
+ assert_equal "<a href=\"/tree/master:src/phorkie/Database\">/ Database</a>", links[3]
194
+ end
195
+ end
196
+ end
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+ #--
3
+ # Copyright (C) 2012 Gitorious AS
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ #++
18
+ require "bundler/setup"
19
+ require "minitest/autorun"
20
+ require "em/minitest/spec"
21
+ require "eventmachine"
22
+ require "libdolt/view"
23
+ require "tiltout"
24
+
25
+ Bundler.require(:default, :test)
26
+
27
+ module Dolt
28
+ module Html
29
+ def select(html, tag_name)
30
+ html.scan(/<#{tag_name}[^>]*>.*?<\/#{tag_name}>/m)
31
+ end
32
+ end
33
+
34
+ module ViewTest
35
+ def prepare_renderer(options = {}, helpers = nil)
36
+ root = File.join(File.dirname(__FILE__), "..", "views")
37
+ renderer = Tiltout.new(root, options)
38
+ renderer.helper(helpers || [Dolt::View::MultiRepository,
39
+ Dolt::View::Object,
40
+ Dolt::View::Blob,
41
+ Dolt::View::Tree,
42
+ Dolt::View::Blame,
43
+ Dolt::View::SyntaxHighlight,
44
+ Dolt::View::Commit,
45
+ Dolt::View::Gravatar,
46
+ Dolt::View::Breadcrumb])
47
+ renderer
48
+ end
49
+ end
50
+ end
data/views/500.erb ADDED
@@ -0,0 +1,22 @@
1
+ <%#
2
+ # encoding: utf-8
3
+ #--
4
+ # Copyright (C) 2012 Gitorious AS
5
+ #
6
+ # This program is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Affero General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Affero General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Affero General Public License
17
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+ %>
20
+ <h1><%= @title = "An error occurred" %></h1>
21
+ <h2><%= error.respond_to?(:message) ? error.message : error %></h2>
22
+ <p><a href="<%= tree_url(repository, ref, "") %>">Go back</a></p>
data/views/blame.erb ADDED
@@ -0,0 +1,42 @@
1
+ <%#
2
+ # encoding: utf-8
3
+ #--
4
+ # Copyright (C) 2012 Gitorious AS
5
+ #
6
+ # This program is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Affero General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Affero General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Affero General Public License
17
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+ %>
20
+ <% @title = "Blame #{path} in #{repository}:master" %>
21
+
22
+ <div class="gts-file gts-browser">
23
+ <div id="gts-ref-selector-ph"></div>
24
+ <ul class="pull-right gts-blob-view">
25
+ <li><a href="<%= blob_url(repository, ref, path) %>">Blob content</a></li>
26
+ <li class="active">Blame</li>
27
+ <li><a href="<%= history_url(repository, ref, path) %>">History</a></li>
28
+ <li><a href="<%= raw_url(repository, ref, path) %>">Raw blob</a></li>
29
+ </ul>
30
+ <%= breadcrumb(repository, ref, path) %>
31
+ <table class="gts-code-listing">
32
+ <% annotations = blame_annotations(blame) %>
33
+ <% lines = blame_lines(path, blame) %>
34
+ <% annotations.length.times do |i| %>
35
+ <tr>
36
+ <%= blame_annotation_cell(annotations[i]) %>
37
+ <td class="linenum L<%= i + 1 %>"><%= i + 1 %></td>
38
+ <%= blame_code_cell(lines[i]) %>
39
+ </tr>
40
+ <% end %>
41
+ </table>
42
+ </div>
data/views/blob.erb ADDED
@@ -0,0 +1,31 @@
1
+ <%#
2
+ # encoding: utf-8
3
+ #--
4
+ # Copyright (C) 2012 Gitorious AS
5
+ #
6
+ # This program is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Affero General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Affero General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Affero General Public License
17
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+ %>
20
+ <% @title = "#{path} in #{repository}:master" %>
21
+ <div class="gts-file gts-browser">
22
+ <div id="gts-ref-selector-ph"></div>
23
+ <ul class="pull-right gts-blob-view">
24
+ <li class="active">Blob content</li>
25
+ <li><a href="<%= blame_url(repository, ref, path) %>">Blame</a></li>
26
+ <li><a href="<%= history_url(repository, ref, path) %>">History</a></li>
27
+ <li><a href="<%= raw_url(repository, ref, path) %>">Raw blob</a></li>
28
+ </ul>
29
+ <%= breadcrumb(repository, ref, path) %>
30
+ <%= format_blob(path, blob.content, repository, ref) %>
31
+ </div>