Class: WebController

Inherits:
Ramaze::Controller
  • Object
show all
Defined in:
lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb

Instance Method Summary collapse

Instance Method Details

#avatar(jid) ⇒ Object



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb', line 128

def avatar(jid)
  trait :engine => :None

  vcard = $vcards.get_until(jid)
  if vcard.kind_of? Jabber::Vcard::IqVcard
    if vcard['PHOTO/TYPE'] and vcard.photo_binval
      response['Content-Type'] = vcard['PHOTO/TYPE']
      response.body = vcard.photo_binval
    else
      response['Status'] = 404
    end
  else
      response['Status'] = 404
  end

  throw :respond
end

#indexObject



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb', line 108

def index
  "<?xml version='1.0' encoding='UTF-8'?>" +
    "<items xmlns:jabber='jabber:client' jabber:to='#{Jabber::JID.new(JID).strip}'>" +
    $jid_items.collect do |jid,item_orig|
      item = item_orig.deep_clone
      item.attributes['jabber:from'] = jid.to_s
      vcard = $vcards.get_until(jid)
      if vcard.kind_of? Jabber::Vcard::IqVcard
        item.attributes['jabber:from-name'] = vcard['NICKNAME'] || vcard['FN'] || jid.node
        item.attributes['jabber:has-avatar'] = (vcard['PHOTO/TYPE'] and
                                                vcard['PHOTO/BINVAL']) ? 'true' : 'false'
      else
        item.attributes['jabber:from-name'] = jid.node
        item.attributes['jabber:has-avatar'] = 'false'
      end
      item
    end.join +
    "</items>"
end