Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 86
- Log:
Initial import of I2, an Instiki clone.
- Author:
- adh
- Date:
- Mon Oct 16 10:40:36 +0100 2006
- Size:
- 1055 Bytes
1 | desc "Import .textile pages in app_dir/import (from Instiki textile export)" |
2 | task :instiki_import => :environment do |
3 | book = Book.find(ENV["BOOK_ID"] || 1) |
4 | import_author = Author.create :name => "Instiki Importer", :ip => "127.0.0.1" |
5 | |
6 | FileList["#{ENV["IMPORT_DIR"] || "import"}/*.textile"].each do |m| |
7 | name = File.basename(m,'.textile') |
8 | title = "#{convert_wiki_words(name).gsub(/\[/,'').gsub(/\]/,'')}" |
9 | puts "Importing #{m} as #{title}..." |
10 | |
11 | content = File.read(m) |
12 | |
13 | if content.strip.empty? |
14 | puts "Skipped empty!" |
15 | next |
16 | end |
17 | |
18 | Book.transaction do |
19 | page = book.find_or_create_page(:title => title) |
20 | version = page.versions.build(:body => convert_wiki_words(content)) |
21 | version.author = import_author |
22 | version.save |
23 | end |
24 | end |
25 | end |
26 | |
27 | def convert_wiki_words(str) |
28 | str = str.gsub(/(^|[^\\\S])((?:[[:upper:]][[:lower:]]+)([[:upper:]]+)(?:[[:upper:]]*[[:lower:]]*)+)/) do |
29 | "#{$1}[[#{$2}]]" |
30 | end |
31 | # convert [[[[Bla blah]]|some text]] |
32 | str.gsub(/\[\[\[\[/,'[[').gsub(/\]\]\|/,'|') |
33 | end |