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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
require 'csv'
namespace :cccms do
desc "Setup everythin"
task :setup_environment => [
:create_admin_user,
:import_authors,
:import_updates,
:create_home_page
] do |t|
end
desc "Create admin:foobar user:password"
task :create_admin_user => :environment do |t|
User.create!(
:login => 'admin',
:email => 'admin@cccms.de',
:password => 'foobar',
:password_confirmation => 'foobar'
)
end
desc "Import the authors"
task :import_authors => :environment do |t|
importer = AuthorsImporter.new("#{RAILS_ROOT}/db/authors.csv")
importer.import_authors
end
desc "Import the old XML Files"
task :import_updates => :environment do |t|
i = ChaosImporter.new("#{RAILS_ROOT}/db/updates")
i.import_updates
end
desc "Create Home Page"
task :create_home_page => :environment do |t|
n = Node.create :slug => 'home'
n.move_to_child_of Node.root
d = n.draft
d.title = "Startseite"
d.abstract = "Wilkommen auf der Seite des CCC"
d.body = "Hier gibts content"
d.save
n.publish_draft!
end
desc "Convert Entities to real charactes"
task :convert_entities => :environment do |t|
Page.all.each do |page|
if page.body && page.body != ""
puts ">> #{page.id} -- #{page.node.unique_name if page.node}"
tmp_body = page.body.dup
tmp_body.gsub!(/ä/, "ä")
tmp_body.gsub!(/ö/, "ö")
tmp_body.gsub!(/ü/, "ü")
tmp_body.gsub!(/Ä/, "ä")
tmp_body.gsub!(/Ö/, "ö")
tmp_body.gsub!(/Ü/, "ü")
tmp_body.gsub!(/ß/, "ß")
tmp_body.gsub!(/ /, " ")
tmp_body.gsub!(/–/, "–")
tmp_body.gsub!(/µ/, "µ")
tmp_body.gsub!(/³/, "³")
tmp_body.gsub!(/é/, "é")
tmp_body.gsub!(/§/, "§")
tmp_body.gsub!(/“/, "“")
tmp_body.gsub!(/”/, "”")
tmp_body.gsub!(/„/, "„")
page.body = tmp_body
page.save
end
end
end
end
|