class NoticeSys::StatusListView

Public Class Methods

new(basepath, css_url, static_urlbase, weblet) click to toggle source
# File lib/noticesys.rb, line 337
def initialize(basepath, css_url, static_urlbase, weblet)
  
  @basepath, @css_url, @static_urlbase = basepath,  css_url, static_urlbase
  @w = weblet
  @card = CardView.new(@w)
  
end

Public Instance Methods

render(username) click to toggle source
# File lib/noticesys.rb, line 345
def render(username)      

  s = ''
  
  dx = Dynarex.new(File.join(@basepath, 'u', username, 'feed.xml'))
  
  s += @w.render 'user/ptop', binding
  
  notices = dx.all.map do |rx|
  
    card2 = ''
    rawcard = rx.to_h[:card]                
    
    card2 = if rawcard and rawcard.length > 10 then
    
      card = JSON.parse(rawcard, symbolize_names: true)             
      
      if card.is_a? Hash then            
        @card.render(dx, rx, card)
      end
      
    else
      ''
    end      
  
    t2 = Time.at rx.id.to_s[0..9].to_i
    relative_time = Unichron.new(t2).elapsed
    
    d = t2.strftime("%I:%M%p %b %d %Y")
    
    description = if rx.description.length > 1 then
      doc = Rexle.new "<node>%s</node>" % rx.description.gsub(/<\/?p>/,'')                    
      doc.root.xpath('img|div').each(&:delete)
      "<p>%s</p>" % doc.root.xml
    else
      ''
    end

    utitle, uimage, ubio = dx.title, dx.image, dx.bio
    @w.render :notice, binding
    
  end

  s += notices.join      
  s += @w.render 'user/rsslink', binding                  
  @w.render :user, binding
  
end