dolt 0.5.1 → 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 (71) hide show
  1. data/Gemfile.lock +21 -18
  2. data/Readme.md +3 -5
  3. data/bin/dolt +3 -6
  4. data/dolt.gemspec +5 -16
  5. data/lib/dolt/sinatra/multi_repo_browser.rb +3 -3
  6. data/lib/dolt/sinatra/single_repo_browser.rb +3 -3
  7. data/test/test_helper.rb +5 -3
  8. data/vendor/ui/css/gitorious.css +5 -0
  9. metadata +23 -239
  10. data/lib/dolt/async/when.rb +0 -128
  11. data/lib/dolt/disk_repo_resolver.rb +0 -39
  12. data/lib/dolt/git/blame.rb +0 -112
  13. data/lib/dolt/git/commit.rb +0 -73
  14. data/lib/dolt/git/repository.rb +0 -139
  15. data/lib/dolt/git/submodule.rb +0 -35
  16. data/lib/dolt/git/tree.rb +0 -42
  17. data/lib/dolt/repo_actions.rb +0 -91
  18. data/lib/dolt/template_renderer.rb +0 -67
  19. data/lib/dolt/version.rb +0 -21
  20. data/lib/dolt/view.rb +0 -23
  21. data/lib/dolt/view/binary_blob_embedder.rb +0 -41
  22. data/lib/dolt/view/blame.rb +0 -57
  23. data/lib/dolt/view/blob.rb +0 -97
  24. data/lib/dolt/view/breadcrumb.rb +0 -47
  25. data/lib/dolt/view/commit.rb +0 -27
  26. data/lib/dolt/view/gravatar.rb +0 -29
  27. data/lib/dolt/view/markup.rb +0 -107
  28. data/lib/dolt/view/multi_repository.rb +0 -27
  29. data/lib/dolt/view/object.rb +0 -44
  30. data/lib/dolt/view/single_repository.rb +0 -27
  31. data/lib/dolt/view/smart_blob_renderer.rb +0 -33
  32. data/lib/dolt/view/syntax_highlight.rb +0 -90
  33. data/lib/dolt/view/tab_width.rb +0 -30
  34. data/lib/dolt/view/tree.rb +0 -100
  35. data/test/dolt/async/when_test.rb +0 -112
  36. data/test/dolt/git/blame_test.rb +0 -128
  37. data/test/dolt/git/commit_test.rb +0 -89
  38. data/test/dolt/git/repository_test.rb +0 -186
  39. data/test/dolt/repo_actions_test.rb +0 -236
  40. data/test/dolt/template_renderer_test.rb +0 -122
  41. data/test/dolt/templates/blame_test.rb +0 -56
  42. data/test/dolt/templates/blob_test.rb +0 -118
  43. data/test/dolt/templates/commits_test.rb +0 -61
  44. data/test/dolt/templates/raw_test.rb +0 -41
  45. data/test/dolt/templates/refs_test.rb +0 -38
  46. data/test/dolt/templates/tree_history_test.rb +0 -93
  47. data/test/dolt/templates/tree_test.rb +0 -65
  48. data/test/dolt/view/binary_blob_embedder_test.rb +0 -49
  49. data/test/dolt/view/blame_test.rb +0 -122
  50. data/test/dolt/view/blob_test.rb +0 -116
  51. data/test/dolt/view/breadcrumb_test.rb +0 -46
  52. data/test/dolt/view/commit_test.rb +0 -31
  53. data/test/dolt/view/gravatar_test.rb +0 -30
  54. data/test/dolt/view/markup_test.rb +0 -94
  55. data/test/dolt/view/multi_repository_test.rb +0 -35
  56. data/test/dolt/view/object_test.rb +0 -83
  57. data/test/dolt/view/single_repository_test.rb +0 -30
  58. data/test/dolt/view/smart_blob_renderer_test.rb +0 -38
  59. data/test/dolt/view/syntax_highlight_test.rb +0 -108
  60. data/test/dolt/view/tab_width_test.rb +0 -40
  61. data/test/dolt/view/tree_test.rb +0 -199
  62. data/views/500.erb +0 -22
  63. data/views/blame.erb +0 -42
  64. data/views/blob.erb +0 -31
  65. data/views/commits.erb +0 -26
  66. data/views/index.erb +0 -25
  67. data/views/layout.erb +0 -45
  68. data/views/raw.erb +0 -19
  69. data/views/refs.erb +0 -22
  70. data/views/tree.erb +0 -50
  71. data/views/tree_history.erb +0 -19
@@ -1,35 +0,0 @@
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
-
19
- module Dolt
20
- module Git
21
- class Submodule
22
- def self.parse_config(config)
23
- config.split("\n").inject([]) do |modules, line|
24
- if line =~ /\[submodule ".*"\]/
25
- modules << {}
26
- else
27
- _, key, val = *line.match(/\s([^\s]+) = ([^\s]+)/)
28
- modules.last[key.to_sym] = val
29
- end
30
- modules
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,42 +0,0 @@
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
-
19
- module Dolt
20
- module Git
21
- class Tree
22
- attr_reader :oid, :entries
23
- include Enumerable
24
-
25
- def initialize(oid, entries)
26
- @oid = oid
27
- @entries = entries
28
- end
29
-
30
- def each(&block)
31
- entries.each(&block)
32
- end
33
-
34
- # From Rugged::Tree
35
- def inspect
36
- data = "#<Dolt::Git::Tree:#{object_id} {oid: #{oid}}>\n"
37
- self.each { |e| data << " <\"#{e[:name]}\" #{e[:oid]}>\n" }
38
- data
39
- end
40
- end
41
- end
42
- end
@@ -1,91 +0,0 @@
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
- require "eventmachine"
20
-
21
- module Dolt
22
- class RepoActions
23
- def initialize(repo_resolver)
24
- @repo_resolver = repo_resolver
25
- end
26
-
27
- def blob(repo, ref, path, &block)
28
- repo_action(repo, ref, path, :blob, :rev_parse, "#{ref}:#{path}", &block)
29
- end
30
-
31
- def tree(repo, ref, path, &block)
32
- repo_action(repo, ref, path, :tree, :tree, ref, path, &block)
33
- end
34
-
35
- def blame(repo, ref, path, &block)
36
- repo_action(repo, ref, path, :blame, :blame, ref, path, &block)
37
- end
38
-
39
- def history(repo, ref, path, count, &block)
40
- repo_action(repo, ref, path, :commits, :log, ref, path, count, &block)
41
- end
42
-
43
- def refs(repo, &block)
44
- repository = repo_resolver.resolve(repo)
45
- d = repository.refs
46
- d.callback do |refs|
47
- names = refs.map(&:name)
48
- block.call(nil, {
49
- :repository => repo,
50
- :tags => stripped_ref_names(names, :tags),
51
- :heads => stripped_ref_names(names, :heads)
52
- })
53
- end
54
- d.errback { |err| block.call(err, nil) }
55
- end
56
-
57
- def tree_history(repo, ref, path, count, &block)
58
- repo_action(repo, ref, path, :tree, :tree_history, ref, path, count, &block)
59
- end
60
-
61
- def repositories
62
- repo_resolver.all
63
- end
64
-
65
- private
66
- def repo_resolver; @repo_resolver; end
67
-
68
- def repo_action(repo, ref, path, data, method, *args, &block)
69
- repository = repo_resolver.resolve(repo)
70
- d = repository.send(method, *args)
71
- d.callback do |result|
72
- block.call(nil, tpl_data(repo, ref, path, { data => result }))
73
- end
74
- d.errback { |err| block.call(err, nil) }
75
- end
76
-
77
- def tpl_data(repo, ref, path, locals = {})
78
- {
79
- :repository => repo,
80
- :path => path,
81
- :ref => ref
82
- }.merge(locals)
83
- end
84
-
85
- def stripped_ref_names(names, type)
86
- names.select { |n| n =~ /#{type}/ }.map do |n|
87
- n.sub(/^refs\/#{type}\//, "")
88
- end
89
- end
90
- end
91
- end
@@ -1,67 +0,0 @@
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 "tilt"
19
- require "json"
20
-
21
- # Need consistent Time formatting in JSON
22
- require "time"
23
- class Time; def to_json(*args); "\"#{iso8601}\""; end; end
24
-
25
- module Dolt
26
- class TemplateRenderer
27
- def initialize(template_root, opt = {})
28
- @template_root = template_root
29
- @cache = {} if !opt.key?(:cache) || opt[:cache]
30
- @layout = opt[:layout]
31
- @type = opt[:type] || "erb"
32
- @context_class = Class.new
33
- end
34
-
35
- def helper(helper)
36
- helper = [helper] unless Array === helper
37
- helper.each { |h| @context_class.send(:include, h) }
38
- end
39
-
40
- def render(template, locals = {}, options = {})
41
- context = context_class.new
42
- content = load(template).render(context, locals)
43
- layout_tpl = options.key?(:layout) ? options[:layout] : layout
44
-
45
- if !layout_tpl.nil?
46
- content = load(layout_tpl).render(context, locals) { content }
47
- end
48
-
49
- content
50
- end
51
-
52
- private
53
- def load(name)
54
- file_name = File.join(template_root, "#{name}.#{type}")
55
- return cache[file_name] if cache && cache[file_name]
56
- template = Tilt.new(file_name)
57
- cache[file_name] = template if cache
58
- template
59
- end
60
-
61
- def template_root; @template_root; end
62
- def cache; @cache; end
63
- def layout; @layout; end
64
- def type; @type; end
65
- def context_class; @context_class; end
66
- end
67
- end
@@ -1,21 +0,0 @@
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
-
19
- module Dolt
20
- VERSION = "0.5.1"
21
- end
@@ -1,23 +0,0 @@
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
-
19
- dir = File.join(File.dirname(__FILE__), "view")
20
-
21
- Dir.entries(dir).select { |f| f =~ /\.rb$/ }.map do |file|
22
- require(File.join(dir, file))
23
- end
@@ -1,41 +0,0 @@
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 "mime/types"
19
-
20
- module Dolt
21
- module View
22
- module BinaryBlobEmbedder
23
- def image?(path, content)
24
- MIME::Types.type_for(path).any? { |mt| mt.media_type == "image" }
25
- end
26
-
27
- def format_binary_blob(path, content, repository, ref)
28
- if !image?(path, content)
29
- return link_binary_blob(path, content, repository, ref)
30
- end
31
-
32
- url = raw_url(repository, ref, path)
33
- <<-HTML
34
- <p class="prettyprint">
35
- <a href="#{url}"><img src="#{url}" alt="#{path}"></a>
36
- </p>
37
- HTML
38
- end
39
- end
40
- end
41
- end
@@ -1,57 +0,0 @@
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
-
19
- module Dolt
20
- module View
21
- module Blame
22
- def blame_annotations(blame)
23
- blame.chunks.inject([]) do |blames, chunk|
24
- blames << chunk
25
- (chunk[:lines].length - 1).times { blames << nil }
26
- blames
27
- end
28
- end
29
-
30
- def blame_lines(path, blame)
31
- lines = blame.chunks.inject([]) do |lines, chunk|
32
- lines.concat(chunk[:lines])
33
- end
34
-
35
- return lines unless respond_to?(:highlight)
36
- highlight(path, lines.join("\n")).split("\n")
37
- end
38
-
39
- def blame_annotation_cell(annotation)
40
- class_name = "gts-blame-annotation" + (annotation.nil? ? "" : " gts-annotated")
41
- return "<td class=\"#{class_name}\"></td>" if annotation.nil?
42
-
43
- <<-HTML
44
- <td class="#{class_name}">
45
- <span class="gts-sha">#{annotation[:oid][0..7]}</span>
46
- #{annotation[:committer][:time].strftime("%Y-%m-%d")}
47
- #{annotation[:committer][:name]}
48
- </td>
49
- HTML
50
- end
51
-
52
- def blame_code_cell(line)
53
- "<td class=\"gts-code\"><code>#{line}</code></td>"
54
- end
55
- end
56
- end
57
- end
@@ -1,97 +0,0 @@
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 "htmlentities"
19
-
20
- module Dolt
21
- module View
22
- module Blob
23
- def binary?(content)
24
- !content[0...(content.length-1)].index("\000").nil?
25
- end
26
-
27
- def entityfy(content)
28
- @coder ||= HTMLEntities.new
29
- @coder.encode(content)
30
- end
31
-
32
- def format_blob(path, content, repo = nil, ref = nil)
33
- return format_binary_blob(path, content, repo, ref) if binary?(content)
34
- format_text_blob(path, content, repo, ref)
35
- end
36
-
37
- def format_binary_blob(path, content, repository = nil, ref = nil)
38
- link_binary_blob(path, content, repository, ref)
39
- end
40
-
41
- def link_binary_blob(path, content, repository = nil, ref = nil)
42
- <<-HTML
43
- <p class="prettyprint">
44
- The content you're attempting to browse appears to be binary.
45
- <a href="#{raw_url(repository, ref, path)}">Download #{File.basename(path)}</a>.
46
- </p>
47
- HTML
48
- end
49
-
50
- def format_text_blob(path, content, repository = nil, ref = nil)
51
- multiline(entityfy(content))
52
- end
53
-
54
- def blob_url(repository, ref, path)
55
- repo_url(repository, "/blob/#{ref}:#{path}")
56
- end
57
-
58
- def blame_url(repository, ref, path)
59
- repo_url(repository, "/blame/#{ref}:#{path}")
60
- end
61
-
62
- def history_url(repository, ref, path)
63
- repo_url(repository, "/history/#{ref}:#{path}")
64
- end
65
-
66
- def raw_url(repository, ref, path)
67
- repo_url(repository, "/raw/#{ref}:#{path}")
68
- end
69
-
70
- def tree_history_url(repository, ref, path)
71
- repo_url(repository, "/tree_history/#{ref}:#{path}")
72
- end
73
-
74
- def format_whitespace(text)
75
- text
76
- end
77
-
78
- def multiline(blob, options = {})
79
- class_names = options[:class_names] || []
80
- class_names << "prettyprint" << "linenums"
81
-
82
- num = 0
83
- lines = blob.split("\n").inject("") do |html, line|
84
- num += 1
85
- # Empty elements causes annoying rendering artefacts
86
- # Forcing one space on each line affects copy-paste negatively
87
- # TODO: Don't force one space, find CSS fix
88
- line = format_whitespace(line).sub(/^$/, " ")
89
- "#{html}<li class=\"L#{num}\"><span class=\"line\">#{line}</span></li>"
90
- end
91
-
92
- "<pre class=\"#{class_names.join(' ')}\">" +
93
- "<ol class=\"linenums\">#{lines}</ol></pre>"
94
- end
95
- end
96
- end
97
- end