From c0e5673cc50e912cf6997c4f8109014f408cf233 Mon Sep 17 00:00:00 2001 From: Alexey Verkhovsky Date: Mon, 2 May 2005 01:43:44 +0000 Subject: [PATCH] Fixed an incompatibility with old storages; ticket:133 --- CHANGELOG | 3 +-- app/models/web.rb | 46 ++++++++++++++++++++++++++-------------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f39bcf35..f4d2f867 100755 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,10 +1,9 @@ * 0.10.1: Upgraded Rails to 0.12.0 Upgraded rubyzip to version 0.5.8 - BlueCloth is back (RedCloth didn't do pure Markdown well enough to replace it yet) + BlueCloth is back (RedCloth didn't do pure Markdown well enough) Handling of line breaks in Textile is as in 0.9 (inserts
tag) Fixed HTML export (to enclose the output in tags, include the stylesheet etc) - Some other bug fixes * 0.10.0: diff --git a/app/models/web.rb b/app/models/web.rb index b510f298..16c902bc 100644 --- a/app/models/web.rb +++ b/app/models/web.rb @@ -5,30 +5,45 @@ require 'wiki_words' require 'zip/zip' class Web - attr_accessor :name, :password, :markup, :color, :safe_mode, :pages - attr_accessor :additional_style, :published, :brackets_only, :count_pages, :allow_uploads - attr_accessor :max_upload_size - + attr_accessor :name, :password, :safe_mode, :pages + attr_accessor :additional_style, :allow_uploads, :published attr_reader :address + # there are getters for all these attributes, too + attr_writer :markup, :color, :brackets_only, :count_pages, :max_upload_size + def initialize(parent_wiki, name, address, password = nil) self.address = address @wiki, @name, @password = parent_wiki, name, password - # default values - @markup = :textile - @color = '008B26' - @safe_mode = false + set_compatible_defaults + @pages = {} @allow_uploads = true @additional_style = nil @published = false - @brackets_only = false @count_pages = false @allow_uploads = true - @max_upload_size = 100 end + # Explicitly sets value of some web attributes to defaults, unless they are already set + def set_compatible_defaults + @markup = markup() + @color = color() + @safe_mode = safe_mode() + @brackets_only = brackets_only() + @max_upload_size = max_upload_size() + @wiki = wiki + end + # All below getters know their default values. This is necessary to ensure compatibility with + # 0.9 storages, where they were not defined. + def brackets_only() @brackets_only || false end + def color() @color ||= '008B26' end + def count_pages() @count_pages || false end + def markup() @markup ||= :textile end + def max_upload_size() @max_upload_size || 100; end + def wiki() @wiki ||= WikiService.instance; end + def add_page(page) @pages[page.name] = page end @@ -40,7 +55,7 @@ class Web @address = the_address end - def authors + def authors select.authors end @@ -129,10 +144,6 @@ class Web end end - def max_upload_size - @max_upload_size || 100 - end - # Clears the display cache for all the pages with references to def refresh_pages_with_references(page_name) select.pages_that_reference(page_name).each { |page| @@ -156,11 +167,6 @@ class Web PageSet.new(self, @pages.values, condition) end - # This ensures compatibility with 0.9 storages - def wiki - @wiki ||= WikiService.instance - end - private # Returns an array of all the wiki words in any current revision