Class: NoticeSys::StatusListView

Inherits:
Object
  • Object
show all
Defined in:
lib/noticesys.rb

Instance Method Summary collapse

Constructor Details

#initialize(basepath, css_url, static_urlbase, weblet) ⇒ StatusListView



342
343
344
345
346
347
348
# File 'lib/noticesys.rb', line 342

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

Instance Method Details

#render(username) ⇒ Object



350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
# File 'lib/noticesys.rb', line 350

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