GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Fork of sr/git-wiki
Description: A quick & dirty git-powered Sinatra wiki
Homepage: http://atonie.org/2008/02/git-wiki
Clone URL: git://github.com/willcodeforfoo/git-wiki.git
Import current pages from junebug-wiki SQLite database
Tue Feb 19 15:53:13 -0800 2008
commit  d99d9328a948ed936c0e039e019268f9aaf94209
tree    af2407d2fd725baba8c98b3ffc090147843e06bc
parent  21d098c867eb209aadc6da5f12feb71a8721ee48
...
1
2
 
 
 
3
4
5
 
 
 
6
7
8
9
10
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
...
1
 
2
3
4
5
6
7
8
9
10
11
12
13
14
 
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
0
@@ -1,10 +1,31 @@
0
 #!/usr/bin/env ruby
0
-
0
+require 'rubygems'
0
+require 'sqlite3'
0
+
0
 #
0
 # import/junebug-wiki.rb
0
 # Import a JunebugWiki SQLite dump into a new or existing git-wiki repo
0
+# Warning: Will overwrite pages/files that already exist. Git diff to the rescue
0
+
0
+GIT_REPO = ENV['HOME'] + '/wiki'
0
 
0
 unless ARGV[0] && File.readable?(ARGV[0])
0
   puts "Usage: #{$0} path/to/junebug.db"
0
   exit 1
0
-end
0
\ No newline at end of file
0
+end
0
+
0
+# TODO: Pull in historical pages, too, from junebug_page_versions. Will have to
0
+# figure out how to 'backdate' commits, which must be possible because SVN import
0
+# stuff does it. This will suffice for now.
0
+db = SQLite3::Database.new(ARGV[0])
0
+db.execute("SELECT title, body FROM junebug_pages") do |row|
0
+ title, body = *row
0
+ name = title.gsub(/ /, '_')
0
+
0
+ # write to file
0
+ filename = File.join(GIT_REPO, name)
0
+ File.open(filename, 'w') { |f| f << body }
0
+end
0
+
0
+# Commit our changes to the repository
0
+`cd #{GIT_REPO} && git add . && git commit -m "Import from junebug-wiki.rb"`
0
\ No newline at end of file

Comments

    No one has commented yet.