smeagol 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/.index +82 -0
  3. data/HISTORY.md +14 -0
  4. data/lib/smeagol.rb +2 -1
  5. data/lib/smeagol/app.rb +1 -1
  6. data/lib/smeagol/gollum/file.rb +1 -1
  7. data/lib/smeagol/wiki.rb +1 -0
  8. data/vendor/grit/lib/grit.rb +75 -0
  9. data/vendor/grit/lib/grit/actor.rb +52 -0
  10. data/vendor/grit/lib/grit/blame.rb +70 -0
  11. data/vendor/grit/lib/grit/blob.rb +126 -0
  12. data/vendor/grit/lib/grit/commit.rb +313 -0
  13. data/vendor/grit/lib/grit/commit_stats.rb +128 -0
  14. data/vendor/grit/lib/grit/config.rb +44 -0
  15. data/vendor/grit/lib/grit/diff.rb +79 -0
  16. data/vendor/grit/lib/grit/errors.rb +10 -0
  17. data/vendor/grit/lib/grit/git-ruby.rb +262 -0
  18. data/vendor/grit/lib/grit/git-ruby/commit_db.rb +52 -0
  19. data/vendor/grit/lib/grit/git-ruby/git_object.rb +353 -0
  20. data/vendor/grit/lib/grit/git-ruby/internal/file_window.rb +58 -0
  21. data/vendor/grit/lib/grit/git-ruby/internal/loose.rb +137 -0
  22. data/vendor/grit/lib/grit/git-ruby/internal/pack.rb +397 -0
  23. data/vendor/grit/lib/grit/git-ruby/internal/raw_object.rb +44 -0
  24. data/vendor/grit/lib/grit/git-ruby/repository.rb +775 -0
  25. data/vendor/grit/lib/grit/git.rb +501 -0
  26. data/vendor/grit/lib/grit/index.rb +222 -0
  27. data/vendor/grit/lib/grit/lazy.rb +35 -0
  28. data/vendor/grit/lib/grit/merge.rb +45 -0
  29. data/vendor/grit/lib/grit/ref.rb +78 -0
  30. data/vendor/grit/lib/grit/repo.rb +709 -0
  31. data/vendor/grit/lib/grit/ruby1.9.rb +7 -0
  32. data/vendor/grit/lib/grit/status.rb +153 -0
  33. data/vendor/grit/lib/grit/submodule.rb +88 -0
  34. data/vendor/grit/lib/grit/tag.rb +102 -0
  35. data/vendor/grit/lib/grit/tree.rb +125 -0
  36. metadata +125 -56
  37. data/.ruby +0 -80
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 51e6f36277b0f6f7d5261c251f6bbb475587bd9f
4
+ data.tar.gz: 3443d535ff9bced5c866c31fe816a2a0715b99a5
5
+ SHA512:
6
+ metadata.gz: 192b9a278897314cc70fc3d4c03559c21edf8665f5dafd0a97cd391be8797a0357c7521c0522547171f0b0eb49557590c056a05bf61d3fd3fe8567b4d2f357a0
7
+ data.tar.gz: f5193495ba0067f9e3da33b79a12125a3f616e6406edb0d8a12ce808672cee5cf36fa1db7ff49f095ec70e8630757e6f564f42510c0e9ecfa587e51d4b9d8b81
data/.index ADDED
@@ -0,0 +1,82 @@
1
+ ---
2
+ revision: 2013
3
+ type: ruby
4
+ sources:
5
+ - var
6
+ authors:
7
+ - name: Ben Johnson
8
+ email: benbjohnson@yahoo.com
9
+ - name: Thomas Sawyer
10
+ email: transfire@gmail.com
11
+ organizations: []
12
+ requirements:
13
+ - version: 1.5+
14
+ name: rack
15
+ - version: 2.5+
16
+ name: gollum
17
+ - version: 2.5+
18
+ name: grit
19
+ - version: 1.4+
20
+ name: sinatra
21
+ - version: 0.5+
22
+ name: rubypython
23
+ - groups:
24
+ - development
25
+ - test
26
+ development: true
27
+ name: citron
28
+ - groups:
29
+ - develpoment
30
+ - test
31
+ development: true
32
+ name: ae
33
+ - groups:
34
+ - development
35
+ - test
36
+ development: true
37
+ name: rack-test
38
+ - groups:
39
+ - development
40
+ - doc
41
+ development: true
42
+ name: rdiscount
43
+ conflicts: []
44
+ alternatives: []
45
+ resources:
46
+ - type: home
47
+ uri: http://rubyworks.github.com/smeagol
48
+ label: Homepage
49
+ - type: code
50
+ uri: http://github.com/rubyworks/smeagol
51
+ label: Source Code
52
+ - type: docs
53
+ uri: http://rubydoc.info/gems/smeagol/frames
54
+ label: Documentation
55
+ - type: mail
56
+ uri: http://groups.google.com/groups/rubyworks-mailinglist
57
+ label: Mailing List
58
+ repositories:
59
+ - name: upstream
60
+ scm: git
61
+ uri: git://github.com/rubyworks/smeagol.git
62
+ categories: []
63
+ copyrights:
64
+ - holder: Ben Johnson
65
+ year: '2010'
66
+ - holder: Rubyworks
67
+ year: '2011'
68
+ license: BSD-2-Clause
69
+ customs: []
70
+ paths:
71
+ lib:
72
+ - lib
73
+ name: smeagol
74
+ title: Semagol
75
+ summary: Wiki Cum Website
76
+ created: '2010-08-16'
77
+ description: |-
78
+ Smeagol is a customizable read-only Gollum wiki server.
79
+ Smeagol makes it possible to maintain a standalone website,
80
+ but update it through the Gollum wiki interface, e.g. via GitHub.
81
+ version: 0.6.1
82
+ date: '2013-08-08'
data/HISTORY.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # RELEASE HISTORY
2
2
 
3
+ ## v0.6.1 / 2013-08-01
4
+
5
+ This release of Smeagol is a minor point release to update its dependencies.
6
+ The Grit dependency in particular had become a problem when running under
7
+ Ruby 2.0. To fix we had to vendor the `styx/grit` fork and bundle it with
8
+ the gem. In the future we might migrate the backend to Rugged (volunteers
9
+ welcome!)
10
+
11
+ Changes:
12
+
13
+ * Vendor styx/grit in place of grit gem.
14
+ * Set default_options in Gollum::Wiki subclass.
15
+
16
+
3
17
  ## v0.6.0 / 2012-07-30
4
18
 
5
19
  Version 0.6 is a major refactoring of the code base. While most previous
@@ -38,7 +38,8 @@ module Smeagol
38
38
 
39
39
  end
40
40
 
41
- require 'gollum'
41
+ #require 'gollum'
42
+ require 'gollum-lib'
42
43
  require 'rack/file'
43
44
  require 'mustache'
44
45
  require 'tmpdir'
@@ -50,7 +50,7 @@ module Smeagol
50
50
 
51
51
  # All other resources go through Gollum.
52
52
  get '/*' do
53
- wiki = Smeagol::Wiki.new(repository.path, {:base_path => mount_path})
53
+ wiki = Smeagol::Wiki.new(repository.path, :base_path => mount_path)
54
54
  cache = Smeagol::Cache.new(wiki)
55
55
  ctrl = Smeagol::Controller.new(wiki) # settings)
56
56
 
@@ -24,7 +24,7 @@ module Gollum
24
24
  attr_accessor :version
25
25
 
26
26
  # Recent addition to Gollum.
27
- alias filename name unless method_defined?(:filename)
27
+ #alias filename name unless method_defined?(:filename)
28
28
 
29
29
  # Public: The title will be constructed from the
30
30
  # filename by stripping the extension and replacing any dashes with
@@ -13,6 +13,7 @@ module Smeagol
13
13
  self.default_committer_name = 'Anonymous'
14
14
  self.default_committer_email = 'anon@anon.com'
15
15
  self.default_ws_subs = ['_','-']
16
+ self.default_options = {}
16
17
 
17
18
  # Public: The Smeagol wiki settings. These can be found in the _settings.yml
18
19
  # file at the root of the repository.
@@ -0,0 +1,75 @@
1
+ $:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
2
+
3
+ # core
4
+ require 'fileutils'
5
+ require 'time'
6
+
7
+ # stdlib
8
+ require 'timeout'
9
+ require 'logger'
10
+ require 'digest/sha1'
11
+
12
+ # third party
13
+
14
+ begin
15
+ require 'mime/types'
16
+ require 'rubygems'
17
+ rescue LoadError
18
+ require 'rubygems'
19
+ begin
20
+ gem "mime-types", ">=0"
21
+ require 'mime/types'
22
+ rescue Gem::LoadError => e
23
+ puts "WARNING: Gem LoadError: #{e.message}"
24
+ end
25
+ end
26
+
27
+ # ruby 1.9 compatibility
28
+ require 'grit/ruby1.9'
29
+
30
+ # internal requires
31
+ require 'grit/lazy'
32
+ require 'grit/errors'
33
+ require 'grit/git-ruby'
34
+ require 'grit/git' unless defined? Grit::Git
35
+ require 'grit/ref'
36
+ require 'grit/tag'
37
+ require 'grit/commit'
38
+ require 'grit/commit_stats'
39
+ require 'grit/tree'
40
+ require 'grit/blob'
41
+ require 'grit/actor'
42
+ require 'grit/diff'
43
+ require 'grit/config'
44
+ require 'grit/repo'
45
+ require 'grit/index'
46
+ require 'grit/status'
47
+ require 'grit/submodule'
48
+ require 'grit/blame'
49
+ require 'grit/merge'
50
+
51
+ module Grit
52
+ VERSION = '2.5.0'
53
+
54
+ class << self
55
+ # Set +debug+ to true to log all git calls and responses
56
+ attr_accessor :debug
57
+ attr_accessor :use_git_ruby
58
+ attr_accessor :no_quote
59
+
60
+ # The standard +logger+ for debugging git calls - this defaults to a plain STDOUT logger
61
+ attr_accessor :logger
62
+ def log(str)
63
+ logger.debug { str }
64
+ end
65
+ end
66
+ self.debug = false
67
+ self.use_git_ruby = true
68
+ self.no_quote = false
69
+
70
+ @logger ||= ::Logger.new(STDOUT)
71
+
72
+ def self.version
73
+ VERSION
74
+ end
75
+ end
@@ -0,0 +1,52 @@
1
+ module Grit
2
+
3
+ class Actor
4
+ attr_reader :name
5
+ attr_reader :email
6
+
7
+ def initialize(name, email)
8
+ @name = name
9
+ @email = email
10
+ end
11
+ alias_method :to_s, :name
12
+
13
+ # Create an Actor from a string.
14
+ #
15
+ # str - The String in this format: 'John Doe <jdoe@example.com>'
16
+ #
17
+ # Returns Git::Actor.
18
+ def self.from_string(str)
19
+ case str
20
+ when /<.+>/
21
+ m, name, email = *str.match(/(.*) <(.+?)>/)
22
+ return self.new(name, email)
23
+ else
24
+ return self.new(str, nil)
25
+ end
26
+ end
27
+
28
+ # Outputs an actor string for Git commits.
29
+ #
30
+ # actor = Actor.new('bob', 'bob@email.com')
31
+ # actor.output(time) # => "bob <bob@email.com> UNIX_TIME +0700"
32
+ #
33
+ # time - The Time the commit was authored or committed.
34
+ #
35
+ # Returns a String.
36
+ def output(time)
37
+ offset = time.utc_offset / 60
38
+ "%s <%s> %d %+.2d%.2d" % [
39
+ @name,
40
+ @email || "null",
41
+ time.to_i,
42
+ offset / 60,
43
+ offset.abs % 60]
44
+ end
45
+
46
+ # Pretty object inspection
47
+ def inspect
48
+ %Q{#<Grit::Actor "#{@name} <#{@email}>">}
49
+ end
50
+ end # Actor
51
+
52
+ end # Grit
@@ -0,0 +1,70 @@
1
+ module Grit
2
+
3
+ class Blame
4
+
5
+ attr_reader :lines
6
+
7
+ def initialize(repo, file, commit, lines=nil)
8
+ @repo = repo
9
+ @file = file
10
+ @commit = commit
11
+ if lines.nil?
12
+ @lines = []
13
+ load_blame
14
+ else
15
+ @lines = lines
16
+ end
17
+ end
18
+
19
+ def load_blame
20
+ output = @repo.git.blame({'p' => true}, @commit, '--', @file)
21
+ process_raw_blame(output)
22
+ end
23
+
24
+ def process_raw_blame(output)
25
+ lines, final = [], []
26
+ info, commits = {}, {}
27
+
28
+ # process the output
29
+ output.split("\n").each do |line|
30
+ if line[0, 1] == "\t"
31
+ lines << line[1, line.size]
32
+ elsif m = /^(\w{40}) (\d+) (\d+)/.match(line)
33
+ commit_id, old_lineno, lineno = m[1], m[2].to_i, m[3].to_i
34
+ commits[commit_id] = nil if !commits.key?(commit_id)
35
+ info[lineno] = [commit_id, old_lineno]
36
+ end
37
+ end
38
+
39
+ # load all commits in single call
40
+ @repo.batch(*commits.keys).each do |commit|
41
+ commits[commit.id] = commit
42
+ end
43
+
44
+ # get it together
45
+ info.sort.each do |lineno, (commit_id, old_lineno)|
46
+ commit = commits[commit_id]
47
+ final << BlameLine.new(lineno, old_lineno, commit, lines[lineno - 1])
48
+ end
49
+
50
+ @lines = final
51
+ end
52
+
53
+ # Pretty object inspection
54
+ def inspect
55
+ %Q{#<Grit::Blame "#{@file} <#{@commit}>">}
56
+ end
57
+
58
+ class BlameLine
59
+ attr_accessor :lineno, :oldlineno, :commit, :line
60
+ def initialize(lineno, oldlineno, commit, line)
61
+ @lineno = lineno
62
+ @oldlineno = oldlineno
63
+ @commit = commit
64
+ @line = line
65
+ end
66
+ end
67
+
68
+ end # Blame
69
+
70
+ end # Grit
@@ -0,0 +1,126 @@
1
+ module Grit
2
+
3
+ class Blob
4
+ DEFAULT_MIME_TYPE = "text/plain"
5
+
6
+ attr_reader :id
7
+ attr_reader :mode
8
+ attr_reader :name
9
+
10
+ # Create an unbaked Blob containing just the specified attributes
11
+ # +repo+ is the Repo
12
+ # +atts+ is a Hash of instance variable data
13
+ #
14
+ # Returns Grit::Blob (unbaked)
15
+ def self.create(repo, atts)
16
+ self.allocate.create_initialize(repo, atts)
17
+ end
18
+
19
+ # Initializer for Blob.create
20
+ # +repo+ is the Repo
21
+ # +atts+ is a Hash of instance variable data
22
+ #
23
+ # Returns Grit::Blob (unbaked)
24
+ def create_initialize(repo, atts)
25
+ @repo = repo
26
+ atts.each do |k, v|
27
+ instance_variable_set("@#{k}".to_sym, v)
28
+ end
29
+ self
30
+ end
31
+
32
+ # The size of this blob in bytes
33
+ #
34
+ # Returns Integer
35
+ def size
36
+ @size ||= @repo.git.cat_file({:s => true}, id).chomp.to_i
37
+ end
38
+
39
+ # The binary contents of this blob.
40
+ #
41
+ # Returns String
42
+ def data
43
+ @data ||= @repo.git.cat_file({:p => true}, id)
44
+ end
45
+
46
+ # The mime type of this file (based on the filename)
47
+ #
48
+ # Returns String
49
+ def mime_type
50
+ guesses = MIME::Types.type_for(self.name) rescue []
51
+ guesses.first ? guesses.first.simplified : DEFAULT_MIME_TYPE
52
+ end
53
+
54
+ # The blame information for the given file at the given commit
55
+ #
56
+ # Returns Array: [Grit::Commit, Array: [<line>]]
57
+ def self.blame(repo, commit, file)
58
+ data = repo.git.blame({:p => true}, commit, '--', file)
59
+
60
+ commits = {}
61
+ blames = []
62
+ info = nil
63
+
64
+ data.split("\n").each do |line|
65
+ parts = line.split(/\s+/, 2)
66
+ case parts.first
67
+ when /^[0-9A-Fa-f]{40}$/
68
+ case line
69
+ when /^([0-9A-Fa-f]{40}) (\d+) (\d+) (\d+)$/
70
+ _, id, origin_line, final_line, group_lines = *line.match(/^([0-9A-Fa-f]{40}) (\d+) (\d+) (\d+)$/)
71
+ info = {:id => id}
72
+ blames << [nil, []]
73
+ when /^([0-9A-Fa-f]{40}) (\d+) (\d+)$/
74
+ _, id, origin_line, final_line = *line.match(/^([0-9A-Fa-f]{40}) (\d+) (\d+)$/)
75
+ info = {:id => id}
76
+ end
77
+ when /^(author|committer)/
78
+ case parts.first
79
+ when /^(.+)-mail$/
80
+ info["#{$1}_email".intern] = parts.last
81
+ when /^(.+)-time$/
82
+ info["#{$1}_date".intern] = Time.at(parts.last.to_i)
83
+ when /^(author|committer)$/
84
+ info[$1.intern] = parts.last
85
+ end
86
+ when /^filename/
87
+ info[:filename] = parts.last
88
+ when /^summary/
89
+ info[:summary] = parts.last
90
+ when ''
91
+ c = commits[info[:id]]
92
+ unless c
93
+ c = Commit.create(repo, :id => info[:id],
94
+ :author => Actor.from_string(info[:author] + ' ' + info[:author_email]),
95
+ :authored_date => info[:author_date],
96
+ :committer => Actor.from_string(info[:committer] + ' ' + info[:committer_email]),
97
+ :committed_date => info[:committer_date],
98
+ :message => info[:summary])
99
+ commits[info[:id]] = c
100
+ end
101
+ _, text = *line.match(/^\t(.*)$/)
102
+ blames.last[0] = c
103
+ blames.last[1] << text
104
+ info = nil
105
+ end
106
+ end
107
+
108
+ blames
109
+ end
110
+
111
+ def basename
112
+ File.basename(name)
113
+ end
114
+
115
+ # Pretty object inspection
116
+ def inspect
117
+ %Q{#<Grit::Blob "#{@id}">}
118
+ end
119
+
120
+ # Compares blobs by name
121
+ def <=>(other)
122
+ name <=> other.name
123
+ end
124
+ end # Blob
125
+
126
+ end # Grit