public
Fork of sr/git-wiki
Description: A wiki engine that uses a Git repository as its data store.
Homepage: http://atonie.org/2008/02/git-wiki
Clone URL: git://github.com/al3x/git-wiki.git
Search Repo:
modified git-wiki to use ruby-git so the writing stuff is in the object 
too
schacon (author)
Wed Mar 05 21:55:04 -0800 2008
commit  7bfdd2d3239f64f95426a8f44a9eb2df5c7725b1
tree    7ea50f7c446227dbd7bb2d35328a70bb3b227500
parent  6ab04c228788e12251323d3535cacb02d47b94eb
...
1
2
3
 
4
5
6
...
9
10
11
12
13
14
15
16
 
17
18
 
19
20
21
 
22
23
24
...
40
41
42
43
 
 
44
45
46
47
48
 
 
 
 
 
 
49
50
51
...
57
58
59
60
 
61
62
63
 
64
65
66
...
1
2
 
3
4
5
6
...
9
10
11
 
12
13
 
 
14
15
 
16
17
18
 
19
20
21
22
...
38
39
40
 
41
42
43
44
45
 
 
46
47
48
49
50
51
52
53
54
...
60
61
62
 
63
64
65
 
66
67
68
69
0
@@ -1,6 +1,6 @@
0
 #!/usr/bin/env ruby
0
 
0
-%w(rubygems sinatra grit bluecloth rubypants haml).each do |dependency|
0
+%w(rubygems sinatra git bluecloth rubypants haml).each do |dependency|
0
   begin
0
     require dependency
0
   rescue LoadError => e
0
@@ -9,16 +9,14 @@
0
 end
0
 
0
 GIT_REPO = ENV['HOME'] + '/wiki'
0
-GIT_DIR = File.join(GIT_REPO, '.git')
0
 HOMEPAGE = 'Home'
0
 
0
-unless File.exists?(GIT_DIR) && File.directory?(GIT_DIR)
0
- FileUtils.mkdir_p(GIT_DIR)
0
+unless File.exists?(GIT_REPO) && File.directory?(GIT_REPO)
0
   puts "Initializing repository in #{GIT_REPO}..."
0
- `git --git-dir #{GIT_DIR} init`
0
+ Git.init(GIT_REPO)
0
 end
0
 
0
-$repo = Grit::Repo.new(GIT_REPO)
0
+$repo = Git.open(GIT_REPO)
0
 
0
 class Page
0
   attr_reader :name
0
@@ -40,12 +38,17 @@ class Page
0
   def body=(content)
0
     File.open(@filename, 'w') { |f| f << content }
0
     message = tracked? ? "Edited #{@name}" : "Created #{@name}"
0
- `cd #{GIT_REPO} && git add #{@name} && git commit -m "#{message}"`
0
+ $repo.add(@name)
0
+ $repo.commit(message)
0
   end
0
 
0
   def tracked?
0
- return false if $repo.commits.empty?
0
- $repo.commits.first.tree.contents.map { |b| b.name }.include?(@name)
0
+ begin
0
+ return false if $repo.log.size == 0
0
+ $repo.log.first.gtree.children.keys.include?(@name)
0
+ rescue
0
+ return false
0
+ end
0
   end
0
 
0
   def to_s
0
@@ -57,10 +60,10 @@ get('/') { redirect '/' + HOMEPAGE }
0
 get('/_stylesheet.css') { Sass::Engine.new(File.read(__FILE__).gsub(/.*__END__/m, '')).render }
0
 
0
 get '/_list' do
0
- if $repo.commits.empty?
0
+ if $repo.log.size == 0
0
     @pages = []
0
   else
0
- @pages = $repo.commits.first.tree.contents.map { |blob| Page.new(blob.name) }
0
+ @pages = $repo.log.first.gtree.children.map { |name, blob| Page.new(name) }
0
   end
0
   
0
   haml(list)

Comments

    No one has commented yet.