Changeset 1637

Show
Ignore:
Timestamp:
02/18/08 09:59:36 (3 months ago)
Author:
pdcawley
Message:

Got rid of some explicit &block arguments and replaced a call to send_file when caching with a redirect.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/app/controllers/articles_controller.rb

    r1614 r1637  
    2222    @articles = this_blog.requested_articles(params) 
    2323 
    24     # Build page title, should probably be moved elsewhere 
    25     if params[:year] 
    26       date = Time.mktime(params[:year], params[:month], params[:day]) 
    27       if params[:month] 
    28         if params[:day] 
    29           @page_title = "Archives for " + date.strftime("%A %d %B %Y") 
    30         else 
    31           @page_title = "Archives for " + date.strftime("%B %Y") 
    32         end 
    33       else 
    34         @page_title = "Archives for " + date.strftime("%Y") 
    35       end 
    36     end 
    37     if params[:page] 
    38       @page_title = 'Older posts,' if @page_title.blank? 
    39       @page_title << " page " << params[:page] 
    40     end 
     24    @page_title = index_title 
    4125 
    4226    respond_to do |format| 
     
    145129    render :action => 'index' 
    146130  end 
     131 
     132  def index_title 
     133    returning('') do |page_title| 
     134      page_title << formatted_date_selector('Archives for ') 
     135 
     136      if params[:page] 
     137        page_title << 'Older posts' if page_title.blank? 
     138        page_title << ", page " << params[:page] 
     139      end 
     140    end 
     141  end 
     142 
     143  def formatted_date_selector(prefix = '') 
     144    return '' unless params[:year] 
     145    format = prefix 
     146    format << '%A %d ' if params[:day] 
     147    format << '%B ' if params[:month] 
     148    format << '%Y' if params[:year] 
     149 
     150    return(Time.mktime(*params.values_at(:year, :month, :day)).strftime(format)) 
     151  end 
    147152end 
  • trunk/app/controllers/theme_controller.rb

    r1626 r1637  
    3939      FileUtils.ln("#{dst}.#{$$}", dst) rescue nil 
    4040      FileUtils.rm("#{dst}.#{$$}", :force => true) 
     41      redirect_to(:ts => Time.now.to_i) 
     42    else 
     43      send_file(src, :type => mime, :disposition => 'inline', :stream => true) 
    4144    end 
    42  
    43     send_file(src, :type => mime, :disposition => 'inline', :stream => true) 
    4445  end 
    4546 
  • trunk/app/helpers/application_helper.rb

    r1587 r1637  
    165165  def feed_title 
    166166    return @feed_title if @feed_title 
    167     returning(this_blog.blog_name.dup) do |title| 
    168       if @page_title 
    169         title << " : #{@page_title}" 
    170       end 
    171     end 
     167    return @page_title \ 
     168      ? "#{this_blog.blog_name} : #{@page_title}" \ 
     169      : this_blog.blog_name 
    172170  end 
    173171 
  • trunk/app/models/content.rb

    r1602 r1637  
    3737  @@html_map       = Hash.new 
    3838 
    39   def initialize(*args, &block) 
    40     super(*args, &block) 
     39  def initialize(*args) 
     40    if block_given? 
     41      super(*args) { |instance| yield(instance) } 
     42    else 
     43      super(*args) 
     44    end 
    4145    set_default_blog 
    4246  end 
  • trunk/app/models/sidebar.rb

    r1251 r1637  
    189189  end 
    190190 
    191   def initialize(*args, &block) 
    192     super(*args, &block) 
     191  def initialize(*args) 
     192    if block_given? 
     193      super(*args) { |instance| yield instance } 
     194    else 
     195      super(*args) 
     196    end 
    193197    self.class.fields.each do |field| 
    194198      unless config.has_key?(field.key) 
  • trunk/lib/sidebars/plugin.rb

    r1245 r1637  
    217217    def set_config 
    218218      @sidebar.config ||= {} 
    219       @sidebar.config = self.class.default_config.dup.merge(@sidebar.config) 
    220       @sidebar.config ||= (self.class.default_config) 
     219      @sidebar.config.reverse_merge!(self.class.default_config) 
    221220    end 
    222221 
     
    235234      logger.info "\n\nProcessing #{controller_class_name}\##{action_name} (for #{request_origin})" 
    236235    end 
    237  
    238236  end 
    239237end 
  • trunk/lib/stateful.rb

    r1438 r1637  
    1818 
    1919 
    20     def method_missing(predicate, *args, &block
     20    def method_missing(predicate, *args
    2121      if predicate.to_s.last == '?' 
    2222        self.class.to_s.demodulize.underscore == predicate.to_s.chop 
    2323      else 
    24         super(predicate, *args, &block) 
     24        if block_given? 
     25          super(predicate, *args) { |*block_args| yield(*block_args) } 
     26        else 
     27          super(predicate, *args) 
     28        end 
    2529      end 
    2630    end