public
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
Search Repo:
Message preview
Michael Hartl (author)
Wed May 14 10:50:33 -0700 2008
commit  c096fdf0962c92c188fe0cc64ae1fb555e4e3d0b
tree    1705b17edd07e4b58dfa72b1a2d4d68f9ae6434a
parent  f073e77861aa482fa316ee646b0ff81ef5889b28
...
68
69
70
71
 
72
73
74
75
 
76
77
78
79
...
81
82
83
84
 
85
86
87
 
88
89
90
...
156
157
158
 
 
 
 
 
159
...
68
69
70
 
71
72
73
74
75
76
77
78
79
80
...
82
83
84
 
85
86
87
88
89
90
91
92
...
158
159
160
161
162
163
164
165
166
0
@@ -68,11 +68,12 @@
0
       end
0
       respond_to do |format|
0
         @message = messages.first
0
- if @message.save
0
+ if !preview? and @message.save
0
           messages.each { |m| m.save }
0
           flash[:success] = 'Message sent to everyone!'
0
           format.html { redirect_to messages_url }
0
         else
0
+ @preview = @message.content if preview?
0
           format.html { render :action => "new" }
0
         end
0
       end
0
0
@@ -81,10 +82,11 @@
0
                                                     :recipient => @recipient))
0
     
0
       respond_to do |format|
0
- if @message.save
0
+ if !preview? and @message.save
0
           flash[:success] = 'Message sent!'
0
           format.html { redirect_to messages_url }
0
         else
0
+ @preview = @message.content if preview?
0
           format.html { render :action => "new" }
0
         end
0
       end
0
@@ -156,5 +158,10 @@
0
     def not_current_person(message)
0
       message.sender == current_person ? message.recipient : message.sender
0
     end
0
+
0
+ def preview?
0
+ params["commit"] == "Preview"
0
+ end
0
+
0
 end
...
86
87
88
89
 
90
91
92
93
 
94
95
96
...
86
87
88
 
89
90
91
92
 
93
94
95
96
0
@@ -86,11 +86,11 @@
0
     respond_to do |format|
0
       case params[:type]
0
       when 'info_edit'
0
- if @person.update_attributes(params[:person]) and !preview?
0
+ if !preview? and @person.update_attributes(params[:person])
0
           flash[:success] = 'Profile updated!'
0
           format.html { redirect_to(@person) }
0
         else
0
- @preview = @person.description
0
+ @preview = @person.description if preview?
0
           format.html { render :action => "edit" }
0
         end
0
       when 'password_edit'
...
6
7
8
 
 
 
 
 
9
10
11
...
34
35
36
 
37
38
39
...
6
7
8
9
10
11
12
13
14
15
16
...
39
40
41
42
43
44
45
0
@@ -6,6 +6,11 @@
0
 
0
   <%= error_messages_for :message %>
0
   
0
+ <%- unless @preview.nil? -%>
0
+ <h3>Message preview</h3>
0
+ <%= display @preview %>
0
+ <%- end -%>
0
+
0
   <%= image_link @recipient, :image => :thumbnail %>
0
 
0
   <% form_for(:message,
0
@@ -34,6 +39,7 @@
0
     </div>
0
     <div class="form_row">
0
       <%= f.submit "Send!", :class => "button", :id => "message_submit" %>
0
+ <%= f.submit "Preview", :class => "button", :id => "preview" %>
0
       <%= f.submit "Cancel", :class => "button", :id => "cancel" %>
0
       <%- if current_person?(@recipient) and current_person.admin? -%>
0
         <%= f.submit "Send to all", :class => "button", :id => "all_people" %>

Comments

    No one has commented yet.