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,47 +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 Breadcrumb
22
- def breadcrumb(repository, ref, path)
23
- dirs = path.split("/")
24
- filename = dirs.pop
25
- dir_html = accumulate_dirs(dirs, repository, ref)
26
- url = repo_url(repository, "/tree/#{ref}")
27
- <<-HTML
28
- <ul class="breadcrumb">
29
- <li><a href="#{url}:"><i class="icon icon-file"></i> /</a></li>
30
- #{dir_html}<li class="active">#{filename}</li>
31
- </ul>
32
- HTML
33
- end
34
-
35
- private
36
- def accumulate_dirs(dirs, repository, ref)
37
- accumulated = []
38
- divider = "<span class=\"divider\">/</span>"
39
- dir_html = dirs.inject("") do |html, dir|
40
- accumulated << dir
41
- url = repo_url(repository, "/tree/#{ref}:#{accumulated.join('/')}")
42
- "#{html}<li><a href=\"#{url}\">#{dir}#{divider}</a></li>"
43
- end
44
- end
45
- end
46
- end
47
- end
@@ -1,27 +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 Commit
22
- def commit_oid(oid)
23
- oid[0...7]
24
- end
25
- end
26
- end
27
- end
@@ -1,29 +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 'digest/md5'
19
-
20
- module Dolt
21
- module View
22
- module Gravatar
23
- def gravatar(email)
24
- hashed = Digest::MD5.hexdigest(email.downcase)
25
- "http://www.gravatar.com/avatar/#{hashed}"
26
- end
27
- end
28
- end
29
- end
@@ -1,107 +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 "github/markup"
19
-
20
- module Dolt
21
- module View
22
- module Markup
23
- def render_markup(path, content)
24
- content = highlight_code_blocks(path, content)
25
- markup = GitHub::Markup.render(path, content)
26
- "<div class=\"gts-markup\">#{markup}</div>"
27
- end
28
-
29
- def supported_markup_format?(path)
30
- GitHub::Markup.can_render?(path)
31
- end
32
-
33
- def format_text_blob(path, code, repo = nil, ref = nil)
34
- render_markup(path, code)
35
- end
36
-
37
- def highlight_code_blocks(path, markup)
38
- return markup unless path =~ /\.(md|mkdn?|mdwn|mdown|markdown)$/
39
- can_highlight = respond_to?(:highlight)
40
- CodeBlockParser.parse(markup) do |lexer, code|
41
- code = can_highlight ? highlight(path, code, { :lexer => lexer }) : code
42
- l = can_highlight ? Pygments::Lexer.find(lexer) : nil
43
- "<pre class=\"#{l && l.aliases.first} prettyprint\">#{code}</pre>"
44
- end
45
- end
46
- end
47
-
48
- class CodeBlockParser
49
- attr_reader :lines
50
-
51
- def self.parse(markup, &block)
52
- new(markup).parse(&block)
53
- end
54
-
55
- def initialize(markup)
56
- @lines = markup.split("\n")
57
- @current_code_bock = nil
58
- end
59
-
60
- def parse(&block)
61
- result = []
62
-
63
- while line = @lines.shift
64
- if closes_code_block?(line)
65
- result << block.call(*close_active_code_block)
66
- elsif active_code_block?
67
- append_active_code_block(line)
68
- elsif starts_code_block?(line)
69
- start_code_block(line)
70
- else
71
- result << line
72
- end
73
- end
74
-
75
- result.join("\n")
76
- end
77
-
78
- def active_code_block?
79
- !@current_code_bock.nil?
80
- end
81
-
82
- def starts_code_block?(line)
83
- line.match(/^```.*/)
84
- end
85
-
86
- def closes_code_block?(line)
87
- active_code_block? && line == "```"
88
- end
89
-
90
- def start_code_block(line)
91
- m = line.match(/```([^\s]+)/)
92
- @current_code_bock = [m && m[1], []]
93
- end
94
-
95
- def append_active_code_block(line)
96
- @current_code_bock[1] << line
97
- end
98
-
99
- def close_active_code_block
100
- lexer = @current_code_bock[0]
101
- code = @current_code_bock[1].join("\n")
102
- @current_code_bock = nil
103
- [lexer, code]
104
- end
105
- end
106
- end
107
- end
@@ -1,27 +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 MultiRepository
22
- def repo_url(repository, url)
23
- "/#{repository}#{url}"
24
- end
25
- end
26
- end
27
- end
@@ -1,44 +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 Object
22
- def object_url(repository, ref, path, object)
23
- return object[:url] if object[:type] == :submodule
24
- url = "/#{object[:type]}/#{ref}:#{object_path(path, object)}"
25
- repo_url(repository, url)
26
- end
27
-
28
- def object_path(root, object)
29
- File.join(root, object[:name]).sub(/^\//, "")
30
- end
31
-
32
- def object_icon_class(entry)
33
- case entry[:type]
34
- when :blob
35
- "icon-file"
36
- when :tree
37
- "icon-folder-close"
38
- when :submodule
39
- "icon-hdd"
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,27 +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 SingleRepository
22
- def repo_url(repository, url)
23
- url
24
- end
25
- end
26
- end
27
- end
@@ -1,33 +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 "dolt/view/syntax_highlight"
19
- require "dolt/view/markup"
20
-
21
- module Dolt
22
- module View
23
- module SmartBlobRenderer
24
- include Dolt::View::Markup
25
- include Dolt::View::SyntaxHighlight
26
-
27
- def format_text_blob(path, content, repo = nil, ref = nil, options = {})
28
- return render_markup(path, content) if supported_markup_format?(path)
29
- highlight_multiline(path, content, options)
30
- end
31
- end
32
- end
33
- end
@@ -1,90 +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 "pygments"
19
-
20
- module Dolt
21
- module View
22
- module SyntaxHighlight
23
- def highlight(path, code, opt = {})
24
- options = { :lexer => lexer(path, code) }.merge(opt)
25
- Pygments.highlight(code, highlight_options(options))
26
- rescue MentosError => e
27
- # "MentosError" is what Pyments.rb raises when an unknown lexer is
28
- # attempted used
29
- respond_to?(:entityfy) ? entityfy(code) : code
30
- end
31
-
32
- def highlight_multiline(path, code, options = {})
33
- return highlight(path, code, options) unless respond_to?(:multiline)
34
- lexer = lexer(path, code)
35
- multiline(highlight(path, code, options), :class_names => [lexer])
36
- end
37
-
38
- def format_text_blob(path, code, repo = nil, ref = nil, options = {})
39
- highlight_multiline(path, code, options)
40
- end
41
-
42
- def lexer(path, code = nil)
43
- Dolt::View::SyntaxHighlight.lexer(path.split(".").pop, code)
44
- end
45
-
46
- def self.lexer(suffix, code = nil)
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
50
- shebang_language(shebang(code)) || suffix
51
- end
52
-
53
- def self.shebang(code)
54
- first_line = (code || "").split("\n")[0]
55
- first_line =~ /^#!/ ? first_line : nil
56
- end
57
-
58
- def self.shebang_language(shebang)
59
- shebang = @@lexer_shebangs.find { |s| (shebang || "") =~ s[:pattern] }
60
- shebang && shebang[:lexer]
61
- end
62
-
63
- def self.add_lexer_alias(extension, lexer)
64
- @@lexer_aliases ||= {}
65
- @@lexer_aliases[extension] = lexer
66
- end
67
-
68
- def self.add_lexer_shebang(pattern, lexer)
69
- @@lexer_shebangs ||= []
70
- @@lexer_shebangs << { :pattern => pattern, :lexer => lexer }
71
- end
72
-
73
- private
74
- def highlight_options(options = {})
75
- options[:options] ||= {}
76
- options[:options][:nowrap] = true
77
- options[:options][:encoding] ||= "utf-8"
78
- options
79
- end
80
- end
81
- end
82
- end
83
-
84
- Dolt::View::SyntaxHighlight.add_lexer_alias("txt", "text")
85
- Dolt::View::SyntaxHighlight.add_lexer_alias("ru", "rb")
86
- Dolt::View::SyntaxHighlight.add_lexer_alias("Rakefile", "rb")
87
- Dolt::View::SyntaxHighlight.add_lexer_alias("Gemfile", "rb")
88
- Dolt::View::SyntaxHighlight.add_lexer_alias("Gemfile.lock", "yaml")
89
-
90
- Dolt::View::SyntaxHighlight.add_lexer_shebang(/\bruby\b/, "rb")
@@ -1,30 +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 TabWidth
22
- def self.tab_width; @@tab_width; end
23
- def self.tab_width=(tab_width); @@tab_width = tab_width; end
24
-
25
- def format_whitespace(text)
26
- text.gsub(/\t/, " " * TabWidth.tab_width)
27
- end
28
- end
29
- end
30
- end