From a18af410830f9afbc963ec9e0252c29cda53a9da Mon Sep 17 00:00:00 2001 From: hukl Date: Thu, 5 Mar 2009 23:06:22 +0100 Subject: get rid of the stupid entities. its the 21st century baby. unicode is widely available already! except for windows --- lib/tasks/development_init.rake | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib') diff --git a/lib/tasks/development_init.rake b/lib/tasks/development_init.rake index 22553fc..d3c8aff 100644 --- a/lib/tasks/development_init.rake +++ b/lib/tasks/development_init.rake @@ -58,4 +58,25 @@ namespace :cccms do n.publish_draft! end + + desc "Convert Entities to real charactes" + task :convert_entities => :environment do |t| + Page.all.each do |page| + if 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!(/–/, "–") + page.body = tmp_body + page.save + end + end + end end \ No newline at end of file -- cgit v1.3 From 3c65fcee68683f32d44ca9c3cab14d248fadea0c Mon Sep 17 00:00:00 2001 From: hukl Date: Thu, 5 Mar 2009 23:32:14 +0100 Subject: more entities translated, refined xpath selector --- app/models/page.rb | 2 +- lib/tasks/development_init.rake | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/app/models/page.rb b/app/models/page.rb index 709fa4f..c2e8176 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -128,7 +128,7 @@ class Page < ActiveRecord::Base tmp_body = "
#{self.body}
" xml_string = XML::Parser.string( tmp_body ) xml_doc = xml_string.parse - links = xml_doc.find("a[not(starts-with(@href, 'http://'))]") + links = xml_doc.find("//a[not(starts-with(@href, 'http://'))]") locales = I18n.available_locales.reject {|l| l == :root} diff --git a/lib/tasks/development_init.rake b/lib/tasks/development_init.rake index d3c8aff..789cdf6 100644 --- a/lib/tasks/development_init.rake +++ b/lib/tasks/development_init.rake @@ -62,7 +62,7 @@ namespace :cccms do desc "Convert Entities to real charactes" task :convert_entities => :environment do |t| Page.all.each do |page| - if page.body + if page.body && page.body != "" puts ">> #{page.id} -- #{page.node.unique_name if page.node}" tmp_body = page.body.dup tmp_body.gsub!(/ä/, "ä") @@ -74,6 +74,13 @@ namespace :cccms do 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 -- cgit v1.3