Changeset 1236

Show
Ignore:
Timestamp:
07/23/08 21:28:58 (6 months ago)
Author:
alban
Message:

Ajoute les methods liquid theme.url_for_assets/admin_link_tags et content.url_for_playlist. Refactore l'acces à l'ActionView?. Refs #6

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/app/models/content.rb

    r1230 r1236  
    33class Content < ActiveRecord::Base 
    44 
    5   liquid_methods :name, :episode, :duration 
     5  liquid_methods :name, :episode, :duration, :has_duration? 
    66 
    77  validates_presence_of :name, :message => "Pas de nom défini" 
     
    111111 
    112112  def url_for 
    113     @context.registers[:action_view].url_for_content(@object) 
     113    view.url_for_content(@object) 
     114  end 
     115 
     116  def url_for_playlist 
     117    view.url_for_content(@object, :mode => :playlist) 
    114118  end 
    115119 
    116120  def embedded_player 
    117     @context.registers[:action_view].tag(:embed, 
     121    view.tag(:embed, 
    118122      :src => "/flash/mediaplayer.swf", :type => "application/x-shockwave-flash", 
    119123      :pluginspage => "http://www.macromedia.com/go/getflashplayer", :height => "20", :width => "385", 
  • trunk/app/models/episode.rb

    r1230 r1236  
    2828 
    2929  def url_for 
    30     @context.registers[:action_view].url_for_episode(@object) 
     30    view.url_for_episode(@object) 
    3131  end 
    3232 
  • trunk/app/models/show.rb

    r1230 r1236  
    4545 
    4646  def url_for 
    47     @context.registers[:action_view].url_for_show(@object) 
     47    view.url_for_show(@object) 
    4848  end 
    4949 
    5050  def url_for_podcast 
    51     @context.registers[:action_view].url_for_podcast(@object) 
     51    view.url_for_podcast(@object) 
    5252  end 
    5353 
  • trunk/app/models/template.rb

    r1228 r1236  
    11class Template < ActiveRecord::Base 
     2 
     3  liquid_methods :slug 
     4 
    25end 
     6 
     7class Template::LiquidDropClass 
     8 
     9  def url_for_assets 
     10    "/templates/#{@object.slug}" 
     11  end 
     12 
     13  def admin_link_tag 
     14    account_link = if view.logged_in? 
     15      view.link_to("Mon compte", :controller => "account", :action => "index") 
     16    else 
     17      view.link_to("S'identifier", :controller => "account", :action => "login") 
     18    end 
     19 
     20    "#{account_link} - hébergé par <a href='http://www.bonnes-ondes.fr'>Bonnes Ondes</a>" 
     21  end 
     22 
     23end 
  • trunk/config/initializers/liquid_filters.rb

    r1232 r1236  
    66 
    77Liquid::Template.register_filter(TextFilter) 
     8 
     9class Liquid::Drop 
     10 
     11  protected 
     12 
     13  def view 
     14    @context.registers[:action_view] 
     15  end 
     16 
     17end