summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-03-31 23:46:02 +0200
committerhukl <contact@smyck.org>2009-03-31 23:46:02 +0200
commitebbad4011bc5652966bd25d8455da208c7f9ab7f (patch)
tree0f2a0ce52dee37a2feeebf5f17944a3507d3716e /lib
parent54d31710a4976163d74e4040cd6c2ad8c055c43d (diff)
mini fixes
Diffstat (limited to 'lib')
-rw-r--r--lib/chaos_importer.rb23
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/chaos_importer.rb b/lib/chaos_importer.rb
index 3a307a3..657f1f0 100644
--- a/lib/chaos_importer.rb
+++ b/lib/chaos_importer.rb
@@ -42,7 +42,7 @@ class ChaosImporter
42 options[:locale] = lang_from_path( path ) 42 options[:locale] = lang_from_path( path )
43 options[:date] = options[:xml].at("//date").content.to_date 43 options[:date] = options[:xml].at("//date").content.to_date
44 options[:slug] = chaos_id 44 options[:slug] = chaos_id
45 options[:unique_name] = "updates/#{options[:date]}/#{options[:slug]}" 45 options[:unique_name] = "updates/#{options[:date].year}/#{options[:slug]}"
46 xml = ChaosXml.new options 46 xml = ChaosXml.new options
47 47
48 yield xml 48 yield xml
@@ -68,7 +68,7 @@ class ChaosImporter
68 add_event_to_node node, update.xml if page.tag_list.include?("event") 68 add_event_to_node node, update.xml if page.tag_list.include?("event")
69 page.user = author 69 page.user = author
70 page.save 70 page.save
71 puts node.unique_name 71 # puts node.unique_name
72 end 72 end
73 73
74 Node.all.each {|node| node.publish_draft!} 74 Node.all.each {|node| node.publish_draft!}
@@ -88,8 +88,8 @@ class ChaosImporter
88 end 88 end
89 89
90 def find_or_create_author update 90 def find_or_create_author update
91 login = update.xml.at("//author").content rescue "webmaster" 91 # login = update.xml.at("//author").content rescue "webmaster"
92 puts login 92 # puts login
93 93
94 # password = Digest::SHA1.hexdigest("#{Time.now+rand(100).days}") 94 # password = Digest::SHA1.hexdigest("#{Time.now+rand(100).days}")
95 # unless author = User.find_by_login(login) 95 # unless author = User.find_by_login(login)
@@ -101,13 +101,12 @@ class ChaosImporter
101 # ) 101 # )
102 # end 102 # end
103 103
104 # author 104 # author
105
106
107 end 105 end
108 106
109 def find_or_create_node update 107 def find_or_create_node update
110 year = update.date.year 108 year = update.date.year
109
111 110
112 unique_name_array = update.unique_name.split("/") 111 unique_name_array = update.unique_name.split("/")
113 112
@@ -116,6 +115,8 @@ class ChaosImporter
116 @years[year].move_to_child_of @updates 115 @years[year].move_to_child_of @updates
117 end 116 end
118 117
118 puts update.unique_name
119
119 unless node = Node.find_by_unique_name(update.unique_name) 120 unless node = Node.find_by_unique_name(update.unique_name)
120 node = Node.create :slug => update.slug 121 node = Node.create :slug => update.slug
121 node.move_to_child_of @years[year] 122 node.move_to_child_of @years[year]
@@ -127,12 +128,18 @@ class ChaosImporter
127 def fill_draft_with_content draft, html, lang 128 def fill_draft_with_content draft, html, lang
128 I18n.locale = lang 129 I18n.locale = lang
129 130
131 draft.reload
132
130 options = { 133 options = {
131 :title => html.xpath("//title")[0].content, 134 :title => html.xpath("//title")[0].content,
132 :abstract => html.xpath("//abstract")[0].content, 135 :abstract => html.xpath("//abstract")[0].content,
133 :body => extract_body(html) 136 :body => extract_body(html)
134 } 137 }
135 138
139 if draft.node.slug == "wahlcomputer-hessen"
140 puts "#{I18n.locale} >>> #{lang} >>> #{options[:title]}"
141 end
142
136 draft.update_attributes options 143 draft.update_attributes options
137 draft 144 draft
138 end 145 end
@@ -278,7 +285,7 @@ class ChaosImporter
278 def convert_to_html chaospage 285 def convert_to_html chaospage
279 286
280 chaospage.xpath('//paragraph').each {|sub| sub.name = "p"} 287 chaospage.xpath('//paragraph').each {|sub| sub.name = "p"}
281 chaospage.xpath('//quote').each {|sub| sub.name = "blockquote" } 288 chaospage.xpath('//quote').each {|sub| sub.name = "em" }
282 chaospage.xpath('//subtitle').each {|sub| sub.name = "h3" } 289 chaospage.xpath('//subtitle').each {|sub| sub.name = "h3" }
283 chaospage.xpath('//strong').each {|sub| sub.name = "em" } 290 chaospage.xpath('//strong').each {|sub| sub.name = "em" }
284 chaospage.xpath('//stronger').each {|sub| sub.name = "strong" } 291 chaospage.xpath('//stronger').each {|sub| sub.name = "strong" }