From bbd8f83b7fda6da867510a71a50314c4555dcb92 Mon Sep 17 00:00:00 2001 From: hukl Date: Thu, 5 Mar 2009 21:57:29 +0100 Subject: added begin rescue as too much can go wrong --- app/models/page.rb | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/app/models/page.rb b/app/models/page.rb index a4817a3..709fa4f 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -123,24 +123,28 @@ class Page < ActiveRecord::Base private def rewrite_links_in_body - if self.body - 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://'))]") - - locales = I18n.available_locales.reject {|l| l == :root} - - links.each do |link| - unless locales.include? link[:href].slice(1,2).to_sym - link[:href] = link[:href].sub(/^\//, "/#{I18n.locale}/") + begin + if self.body + 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://'))]") + + locales = I18n.available_locales.reject {|l| l == :root} + + links.each do |link| + unless locales.include? link[:href].slice(1,2).to_sym + link[:href] = link[:href].sub(/^\//, "/#{I18n.locale}/") + end end + + tmp_body = xml_doc.to_s.gsub(/(\n\|\<\/div\>\n)/, "") + tmp_body.gsub!("", "") + + self.body = tmp_body end - - tmp_body = xml_doc.to_s.gsub(/(\n\|\<\/div\>\n)/, "") - tmp_body.gsub!("", "") - - self.body = tmp_body + rescue + nil end end -- cgit v1.3 From 0b25143176eaf35b6760a64f673aca38883a350f Mon Sep 17 00:00:00 2001 From: hukl Date: Thu, 5 Mar 2009 22:33:22 +0100 Subject: another option for tinymce --- app/views/layouts/admin.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 840c37c..bede781 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -20,7 +20,8 @@ theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", extended_valid_elements : "aggregate[tags|limit|order_by|order_direction|partial]", - relative_urls : false + relative_urls : false, + entity_encoding : "raw" }); -- cgit v1.3 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(+) 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(-) 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 From 4f4a4dc245de2a94efef813ec9ff70eb549b7607 Mon Sep 17 00:00:00 2001 From: hukl Date: Fri, 6 Mar 2009 00:16:59 +0100 Subject: added de locale file --- config/locales/de.yml | 119 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 1 deletion(-) diff --git a/config/locales/de.yml b/config/locales/de.yml index 3ddfada..f6bb1b7 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -1,2 +1,119 @@ +# German translations for Ruby on Rails +# by Clemens Kofler (clemens@railway.at) + de: - hello: "Hello World" \ No newline at end of file + date: + formats: + default: "%d.%m.%Y" + short: "%e. %b" + long: "%e. %B %Y" + only_day: "%e" + + day_names: [Sonntag, Montag, Dienstag, Mittwoch, Donnerstag, Freitag, Samstag] + abbr_day_names: [So, Mo, Di, Mi, Do, Fr, Sa] + month_names: [~, Januar, Februar, März, April, Mai, Juni, Juli, August, September, Oktober, November, Dezember] + abbr_month_names: [~, Jan, Feb, Mär, Apr, Mai, Jun, Jul, Aug, Sep, Okt, Nov, Dez] + order: [ :day, :month, :year ] + + time: + formats: + default: "%A, %e. %B %Y, %H:%M Uhr" + short: "%e. %B, %H:%M Uhr" + long: "%A, %e. %B %Y, %H:%M Uhr" + time: "%H:%M" + + am: "vormittags" + pm: "nachmittags" + + datetime: + distance_in_words: + half_a_minute: 'eine halbe Minute' + less_than_x_seconds: + zero: 'weniger als 1 Sekunde' + one: 'weniger als 1 Sekunde' + other: 'weniger als {{count}} Sekunden' + x_seconds: + one: '1 Sekunde' + other: '{{count}} Sekunden' + less_than_x_minutes: + zero: 'weniger als 1 Minute' + one: 'weniger als eine Minute' + other: 'weniger als {{count}} Minuten' + x_minutes: + one: '1 Minute' + other: '{{count}} Minuten' + about_x_hours: + one: 'etwa 1 Stunde' + other: 'etwa {{count}} Stunden' + x_days: + one: '1 Tag' + other: '{{count}} Tage' + about_x_months: + one: 'etwa 1 Monat' + other: 'etwa {{count}} Monate' + x_months: + one: '1 Monat' + other: '{{count}} Monate' + about_x_years: + one: 'etwa 1 Jahr' + other: 'etwa {{count}} Jahre' + over_x_years: + one: 'mehr als 1 Jahr' + other: 'mehr als {{count}} Jahre' + + number: + format: + precision: 2 + separator: ',' + delimiter: '.' + currency: + format: + unit: '€' + format: '%n%u' + separator: + delimiter: + precision: + percentage: + format: + delimiter: "" + precision: + format: + delimiter: "" + human: + format: + delimiter: "" + precision: 1 + + support: + array: + sentence_connector: "und" + skip_last_comma: true + + activerecord: + errors: + template: + header: + one: "Konnte dieses {{model}} Objekt nicht speichern: 1 Fehler." + other: "Konnte dieses {{model}} Objekt nicht speichern: {{count}} Fehler." + body: "Bitte überprüfen Sie die folgenden Felder:" + + messages: + inclusion: "ist kein gültiger Wert" + exclusion: "ist nicht verfügbar" + invalid: "ist nicht gültig" + confirmation: "stimmt nicht mit der Bestätigung überein" + accepted: "muss akzeptiert werden" + empty: "muss ausgefüllt werden" + blank: "muss ausgefüllt werden" + too_long: "ist zu lang (nicht mehr als {{count}} Zeichen)" + too_short: "ist zu kurz (nicht weniger als {{count}} Zeichen)" + wrong_length: "hat die falsche Länge (muss genau {{count}} Zeichen haben)" + taken: "ist bereits vergeben" + not_a_number: "ist keine Zahl" + greater_than: "muss größer als {{count}} sein" + greater_than_or_equal_to: "muss größer oder gleich {{count}} sein" + equal_to: "muss genau {{count}} sein" + less_than: "muss kleiner als {{count}} sein" + less_than_or_equal_to: "muss kleiner oder gleich {{count}} sein" + odd: "muss ungerade sein" + even: "muss gerade sein" \ No newline at end of file -- cgit v1.3 From f97526891872710b49e7ea0e486eb854a233302f Mon Sep 17 00:00:00 2001 From: hukl Date: Fri, 6 Mar 2009 00:56:00 +0100 Subject: didn't work out yet --- config/environment.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/environment.rb b/config/environment.rb index a3fcfa3..20b38b6 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -20,12 +20,12 @@ Rails::Initializer.run do |config| # config.gem "sqlite3-ruby", :lib => "sqlite3" # config.gem "aws-s3", :lib => "aws/s3" - config.gem "rake", :version => ">= 0.8.3" - config.gem "rack", :version => ">= 0.9.1" - config.gem "mongrel", :version => ">= 1.1.5" - config.gem "libxml-ruby", :lib => 'xml' - config.gem "vpim" - config.gem "spicycode-rcov", :lib => 'rcov', :souce => "http://gems.github.com" + # config.gem "rake", :version => ">= 0.8.3" + # config.gem "rack", :version => ">= 0.9.1" + # config.gem "mongrel", :version => ">= 1.1.5" + # config.gem "libxml-ruby", :lib => 'xml' + # config.gem "vpim" + # config.gem "spicycode-rcov", :lib => 'rcov', :souce => "http://gems.github.com" # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named -- cgit v1.3 From 3d62eef0723e39c8454035dc1e5ed6a214b20e8b Mon Sep 17 00:00:00 2001 From: hukl Date: Fri, 6 Mar 2009 01:02:11 +0100 Subject: now we need that again --- app/models/page.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/page.rb b/app/models/page.rb index c2e8176..a27ccfc 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -1,3 +1,5 @@ +require 'xml' + class Page < ActiveRecord::Base PUBLIC_TEMPLATE_PATH = File.join(%w(custom page_templates public)) -- cgit v1.3 From 00fe407be045a5b6cf8269965c0fd35a44094741 Mon Sep 17 00:00:00 2001 From: hukl Date: Sun, 8 Mar 2009 22:31:00 +0100 Subject: added date selector for published_at. Also removed the part that reset the published_at attribute to Time.now. Some cleanups --- app/models/node.rb | 5 +---- app/models/page.rb | 25 ++++++------------------- app/views/nodes/edit.html.erb | 5 +++++ 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/app/models/node.rb b/app/models/node.rb index 7f2bca6..d2db4ba 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -59,7 +59,6 @@ class Node < ActiveRecord::Base def create_new_draft user empty_page = self.pages.new empty_page.user = user - empty_page.clone_attributes_from self.head self.draft = empty_page @@ -70,11 +69,9 @@ class Node < ActiveRecord::Base def publish_draft! if self.draft self.head = self.draft + self.head.save! self.draft = nil self.save! - - self.head.published_at = Time.now - self.head.save! else nil end diff --git a/app/models/page.rb b/app/models/page.rb index a27ccfc..ae2f998 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -19,7 +19,7 @@ class Page < ActiveRecord::Base before_save :rewrite_links_in_body # Security - attr_accessible :title, :abstract, :body, :template_name + attr_accessible :title, :abstract, :body, :template_name, :published_at # Class Methods @@ -59,24 +59,6 @@ class Page < ActiveRecord::Base end # Instance Methods - - def clone_attributes_from page - return nil unless page - - self.tag_list = page.tag_list.join(", ") - - locale_before = I18n.locale - - I18n.available_locales.each do |l| - next if l == :root - I18n.locale = l - self.title = page.title - self.abstract = page.abstract - self.body = page.body - end - - I18n.locale = locale_before - end def public_template_path File.join(PUBLIC_TEMPLATE_PATH, template_name) @@ -106,8 +88,13 @@ class Page < ActiveRecord::Base def clone_attributes_from page return nil unless page + # Clone untranslated attributes + self.tag_list = page.tag_list.join(", ") self.template_name = page.template_name + self.published_at = page.published_at + + # Clone translated attributes locale_before = I18n.locale diff --git a/app/views/nodes/edit.html.erb b/app/views/nodes/edit.html.erb index 929bbf6..d230f5c 100644 --- a/app/views/nodes/edit.html.erb +++ b/app/views/nodes/edit.html.erb @@ -13,6 +13,11 @@ <%= f.error_messages %> <% fields_for @draft do |d| %> + +

+ <%= d.label :published_at %>
+ <%= d.datetime_select :published_at %> +

<%= d.label :template_name %> <%= d.select :template_name, custom_page_templates %> -- cgit v1.3 From 1236567886d4f81cb6d3d4d8017a543c27a66e12 Mon Sep 17 00:00:00 2001 From: hukl Date: Sun, 8 Mar 2009 22:47:45 +0100 Subject: enhanced the link_to_path helper and fixed the menu links --- app/helpers/link_helper.rb | 13 ++++++++----- app/views/layouts/application.html.erb | 6 +++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/helpers/link_helper.rb b/app/helpers/link_helper.rb index 68586c1..33d8a06 100644 --- a/app/helpers/link_helper.rb +++ b/app/helpers/link_helper.rb @@ -1,11 +1,14 @@ module LinkHelper - def link_to_path path - url_for( + def link_to_path title, path + params[:locale] ||= I18n.locale + + link_to( + title, :controller => :content, - :action => :render_page, - :language => I18n.locale, - :page_path => path + :action => :render_page, + :locale => params[:locale], + :page_path => path ) end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index be7e044..1446e14 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -25,19 +25,19 @@