Module: Howlr::Views::HTML

Defined in:
lib/howlr/views.rb

Instance Method Summary collapse

Instance Method Details

#messageObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/howlr/views.rb', line 28

def message
  html do
    h1 "Message #{@message.id}"
      
      dl do
        dt {'id'}
        dd @message.id
        
        dt {'recipient(s)'} 
        dd @message.recipients.collect{|r| r.to_s}.join(", ")
        
        dt {'from'}
        dd {@message.from}
        
        dt {'subject'}
        dd {@message.subject}
        
        dt {'body'}
        dd {@message.body}
        
        dt {'sent successfully?'}
        dd {@message.sent}
        
        unless @message.delivery_errors.empty?
          dt {'delivery errors'}
          dd {@message.delivery_errors.join("<br/>")}
        end
      end
  end
end

#message_listObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/howlr/views.rb', line 59

def message_list
  html do
    h1 "Messages Sent"
    dl do
      dt 'Number of messages sent out since last server reboot:'
      dd @messages.size
    end
    table do
      thead do
        th 'id'
        th 'subject'
        th 'to'
        th 'from'
        th 'sent successfully?'
      end
      @messages.each do |m|
        tr(:id => "message-#{m.id}") do
          td {a(:href => R(Howlr::Controllers::Messages, m.id)){m.id}}
          td m.subject
          td m.recipients.collect{|r| r.to_s}.join(", ")
          td m.from
          td m.sent
        end
      end
    end
  end
end

#new_messageObject



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/howlr/views.rb', line 87

def new_message
  html do
    form :method => 'post', :action => '/messages' do
      h1 "New Message"
      
      dl do
        dt {label 'recipient(s)'} 
        dd {input :type => 'text', :name => 'recipients', :size => 40}
        
        dt {label 'from'}
        dd {input :type => 'text', :name => 'from', :size => 40}
        
        dt {label 'subject'}
        dd {input :type => 'text', :name => 'subject', :size => 40}
        
        dt {label 'body'}
        
        dd {
          @builder.instance_eval { @indent = 0 }
          textarea(:name => 'body', :cols => 40, :rows => 3)
          @builder.instance_eval { @indent = 2 }
        }
      end
      
      h3 "Callback (optional)"
      dl do
        dt {label 'url'} 
        dd {input :type => 'text', :name => 'callback_url', :size => 40}
        
        dt {label 'method'}
        dd {select(:name => 'callback_method'){['get','post','put','delete'].each{|method| option(:value => method){method}}}}
        
        dt {label 'username'}
        dd {input :type => 'text', :name => 'callback_username', :size => 40}
        
        dt {label 'password'}
        dd {input :type => 'password', :name => 'callback_password', :size => 40}
      end
      
      button(:type => 'submit') {"submit"}
    end
  end
end