diff options
| author | hukl <hukl@eight.local> | 2009-02-07 15:50:40 +0100 |
|---|---|---|
| committer | hukl <hukl@eight.local> | 2009-02-07 15:50:40 +0100 |
| commit | 36a2f1f3c085dd81171cf7d8220770d4ff921ab3 (patch) | |
| tree | 5ded15331b192bf428af4c94d46d1abb28ef0690 /lib/update_importer.rb | |
| parent | ce9645d0092d42c7bf8781378181ffbd4ff3d088 (diff) | |
added globalize2 plugin as well as some modifications
which use the new translation facilities.
backend mostly.
Diffstat (limited to 'lib/update_importer.rb')
| -rw-r--r-- | lib/update_importer.rb | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/lib/update_importer.rb b/lib/update_importer.rb index f09564e..0aa0dcc 100644 --- a/lib/update_importer.rb +++ b/lib/update_importer.rb | |||
| @@ -31,15 +31,17 @@ class UpdateImporter | |||
| 31 | next if dir =~ /index\.xml/ | 31 | next if dir =~ /index\.xml/ |
| 32 | chaospage = REXML::Document.new(File.new(dir)) | 32 | chaospage = REXML::Document.new(File.new(dir)) |
| 33 | 33 | ||
| 34 | puts dir | ||
| 34 | lang = case dir | 35 | lang = case dir |
| 35 | when /\.de$/ then "de" | 36 | when /\.de$/ then :de |
| 36 | when /\.en$/ then "en" | 37 | when /\.en$/ then :en |
| 37 | else "de" | 38 | else |
| 39 | :de | ||
| 38 | end | 40 | end |
| 39 | 41 | ||
| 40 | tmp_dir = dir.sub(@path, "").split(/\//).last | 42 | tmp_dir = dir.sub(@path, "").split(/\//).last |
| 41 | chaos_id = tmp_dir.split(/\./)[0] | 43 | chaos_id = tmp_dir.split(/\./)[0] |
| 42 | 44 | ||
| 43 | create_node_and_page( chaospage.root, lang, chaos_id ) | 45 | create_node_and_page( chaospage.root, lang, chaos_id ) |
| 44 | end | 46 | end |
| 45 | end | 47 | end |
| @@ -53,17 +55,16 @@ class UpdateImporter | |||
| 53 | parent_node.move_to_child_of @updates | 55 | parent_node.move_to_child_of @updates |
| 54 | end | 56 | end |
| 55 | 57 | ||
| 56 | # puts "#{chaos_id} >>> #{lang} >>> #{date.year}" | ||
| 57 | 58 | ||
| 58 | unless node = Node.find_by_unique_name(unique_name) | 59 | unless node = Node.find_by_unique_name(unique_name) |
| 59 | node = Node.create :slug => chaos_id | 60 | node = Node.create :slug => chaos_id |
| 60 | node.move_to_child_of parent_node | 61 | node.move_to_child_of parent_node |
| 61 | end | 62 | end |
| 62 | 63 | ||
| 63 | create_node_for_page chaospage, node, date | 64 | create_node_for_page chaospage, node, date, lang |
| 64 | end | 65 | end |
| 65 | 66 | ||
| 66 | def create_node_for_page chaospage, node, date | 67 | def create_node_for_page chaospage, node, date, lang |
| 67 | 68 | ||
| 68 | xhtml = convert_chaospage_to_xhtml(chaospage) | 69 | xhtml = convert_chaospage_to_xhtml(chaospage) |
| 69 | 70 | ||
| @@ -77,12 +78,27 @@ class UpdateImporter | |||
| 77 | end | 78 | end |
| 78 | 79 | ||
| 79 | if node.pages.empty? | 80 | if node.pages.empty? |
| 81 | |||
| 82 | I18n.locale = lang | ||
| 83 | |||
| 80 | page = node.pages.create!( | 84 | page = node.pages.create!( |
| 81 | :title => xhtml.elements['title'].get_text.to_s, | 85 | :title => xhtml.elements['title'].get_text.to_s, |
| 82 | :abstract => xhtml.elements['abstract'].get_text.to_s, | 86 | :abstract => xhtml.elements['abstract'].get_text.to_s, |
| 83 | :body => body, | 87 | :body => body, |
| 84 | :published_at => date | 88 | :published_at => date |
| 85 | ) | 89 | ) |
| 90 | else | ||
| 91 | page = node.pages.first | ||
| 92 | |||
| 93 | I18n.locale = lang | ||
| 94 | |||
| 95 | page.update_attributes( | ||
| 96 | :title => xhtml.elements['title'].get_text.to_s, | ||
| 97 | :abstract => xhtml.elements['abstract'].get_text.to_s, | ||
| 98 | :body => body | ||
| 99 | ) | ||
| 100 | |||
| 101 | page.save | ||
| 86 | end | 102 | end |
| 87 | 103 | ||
| 88 | page.tag_list.add("update") if page | 104 | page.tag_list.add("update") if page |
