1
0

Tweet.st 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. Widget subclass: #Tweet
  2. instanceVariableNames: 'json'
  3. category: 'Examples'!
  4. !Tweet methodsFor: 'not yet classified'!
  5. renderOn: tr
  6. | tdUser tdMessage img a pMessage pDate |
  7. tdUser := HTMLCanvas new td.
  8. tdUser element id: 'user'.
  9. tdMessage := HTMLCanvas new td.
  10. tdMessage element id: 'messageBox'.
  11. tr append: tdUser.
  12. tr append: tdMessage.
  13. img := HTMLCanvas new img src: (json at: 'profile_image_url') .
  14. img element title: (json at: 'from_user').
  15. img element longDesc: ('http://twitter.com/', (json at: 'from_user')).
  16. a := HTMLCanvas new a href: ('http://twitter.com/', (json at: 'from_user')).
  17. a append: img.
  18. tdUser append: a.
  19. pMessage := HTMLCanvas new p.
  20. pMessage element id: 'message'.
  21. pMessage append: (json at: 'text').
  22. tdMessage append: pMessage.
  23. pDate := HTMLCanvas new p.
  24. pDate element id: 'date'.
  25. pDate append: (json at: 'created_at').
  26. tdMessage append: pDate.
  27. !
  28. json
  29. ^json
  30. !
  31. json: aJson
  32. json := aJson
  33. ! !
  34. !Tweet class methodsFor: 'not yet classified'!
  35. openAt: tr with: aJson
  36. | tweet |
  37. tweet := self new.
  38. tweet json: aJson.
  39. tweet renderOn: tr.
  40. ^tr
  41. ! !