Skip to content
This repository

Updated readme formatting #73

Merged
merged 1 commit into from over 1 year ago

2 participants

Philip Arndt Eduardo Casanova
Philip Arndt
Philip Arndt Updated readme formatting
* Markdown blocks use GitHub Flavored Markdown per http://github.github.com/github-flavored-markdown/
* Fixed indentation of ruby code blocks that didn't require it
57ef4c2
Eduardo Casanova Roendal merged commit 2b91330 into from August 10, 2012
Eduardo Casanova Roendal closed this August 10, 2012
Eduardo Casanova
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 09, 2012
Philip Arndt Updated readme formatting
* Markdown blocks use GitHub Flavored Markdown per http://github.github.com/github-flavored-markdown/
* Fixed indentation of ruby code blocks that didn't require it
57ef4c2
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 85 additions and 76 deletions. Show diff stats Hide diff stats

  1. 161  README.md
161  README.md
Source Rendered
@@ -34,27 +34,27 @@ Installation
34 34
 
35 35
 Add to your Gemfile:
36 36
 
37  
-````
38  
-gem ‘mailboxer’
39  
-````
  37
+```ruby
  38
+gem 'mailboxer'
  39
+```
40 40
 
41 41
 Then run:
42 42
 
43  
-````
  43
+```sh
44 44
 $ bundle update
45  
-````
  45
+```
46 46
 
47 47
 Run install script:
48 48
 
49  
-````
  49
+```sh
50 50
 $ rails g mailboxer:install
51  
-````
  51
+```
52 52
 
53 53
 And don't forget to migrate you database:
54 54
 
55  
-````
  55
+```sh
56 56
 $ rake db:migrate
57  
-````
  57
+```
58 58
 
59 59
 ## Requirements & Settings
60 60
 
@@ -62,7 +62,7 @@ $ rake db:migrate
62 62
 
63 63
 We are now adding support for sending emails when a Notification or a Message is sent to one o more recipients. You should modify mailboxer initializer (/config/initializer/mailboxer.rb) to edit this settings.
64 64
 
65  
-````ruby
  65
+```ruby
66 66
 Mailboxer.setup do |config|
67 67
   #Configures if you applications uses or no the email sending for Notifications and Messages
68 68
   config.uses_emails = true  
@@ -70,30 +70,30 @@ Mailboxer.setup do |config|
70 70
   config.default_from = "no-reply@dit.upm.es"
71 71
   ...
72 72
 end
73  
-````
  73
+```
74 74
 
75 75
 You can change the way in which emails are delivered by specifying a custom implementation for notification and message mailer 
76 76
 
77  
-````ruby
  77
+```ruby
78 78
 Mailboxer.setup do |config|
79 79
   config.notification_mailer = CustomNotificationMailer
80 80
   config.message_mailer = CustomMessageMailer
81 81
   ...
82 82
 end
83  
-````
  83
+```
84 84
 
85 85
 ### User identities
86 86
 
87 87
 Users must have an identity defined by a `name` and an `email`. We must assure that Messageable models have some specific methods. These methods are:
88 88
 
89  
-````ruby
  89
+```ruby
90 90
 #Returning any kind of identification you want for the model
91 91
 def name
92 92
   return "You should add method :name in your Messageable model"
93 93
 end
94  
-````
  94
+```
95 95
 
96  
-````ruby
  96
+```ruby
97 97
 #Returning the email address of the model if an email should be sent for this object (Message or Notification).
98 98
 #If no mail has to be sent, return nil.
99 99
 def mailboxer_email(object)
@@ -103,11 +103,11 @@ def mailboxer_email(object)
103 103
   #if false
104 104
   #return nil
105 105
 end
106  
-````
  106
+```
107 107
 
108 108
 These names are explicit enough to avoid colliding with other methods, but as long as you need to change them you can do it by using mailboxer initializer (/config/initializer/mailboxer.rb). Just add or uncomment the following lines:
109 109
 
110  
-````ruby
  110
+```ruby
111 111
 Mailboxer.setup do |config|
112 112
   # ...
113 113
   #Configures the methods needed by mailboxer
@@ -115,14 +115,14 @@ Mailboxer.setup do |config|
115 115
   config.name_method = :name
116 116
   # ...
117 117
 end
118  
-````
  118
+```
119 119
 
120 120
 You may change whatever you want or need. For example:
121 121
 
122  
-````ruby
  122
+```ruby
123 123
 config.email_method = :notifications_email
124 124
 config.name_method = :display_name
125  
-````
  125
+```
126 126
 
127 127
 Will use the method `notification_email(object)` instead of `mailboxer_email(object)` and `display_name` for `name`.
128 128
 
@@ -132,80 +132,87 @@ Using default or custom method names, if your model doesn't implement them, Mail
132 132
 
133 133
 In your model:
134 134
 
135  
-````ruby
  135
+```ruby
136 136
 class User < ActiveRecord::Base
137 137
   acts_as_messageable
138 138
 end
139  
-````
  139
+```
140 140
 
141 141
 You are not limited to User model. You can use Mailboxer in any other model and use it in serveral different models. If you have ducks and cylons in your application and you want to interchange messages as if they where the same, just use act_as_messageable in each one and you will be able to send duck-duck, duck-cylon, cylon-duck and cylon-cylon messages. Of course, you can extend it for as many clases as you need.
142 142
 
143 143
 Example:
144 144
 
145  
-````ruby
  145
+```ruby
146 146
 class Duck < ActiveRecord::Base
147 147
   acts_as_messageable
148 148
 end
149  
-````
  149
+```
150 150
 
151  
-````ruby
  151
+```ruby
152 152
 class Cylon < ActiveRecord::Base
153 153
   acts_as_messageable
154 154
 end
155  
-````
  155
+```
156 156
 
157 157
 ## Mailboxer API
158 158
 
159 159
 ### How can I send a message?
160 160
 
161  
-````ruby
162  
-  #alfa wants to send a message to beta
163  
-  alfa.send_message(beta, "Body", "subject")
164  
-````
  161
+```ruby
  162
+#alfa wants to send a message to beta
  163
+alfa.send_message(beta, "Body", "subject")
  164
+```
165 165
 
166 166
 ### How can I reply a message?
167 167
 
168  
-````ruby
169  
-  #alfa wants to reply to all in a conversation
170  
-  #using a receipt
171  
-  alfa.reply_to_all(receipt, "Reply body")
172  
-  #using a conversation
173  
-  alfa.reply_to_conversation(conversation, "Reply body")
174  
-````
  168
+```ruby
  169
+#alfa wants to reply to all in a conversation
  170
+#using a receipt
  171
+alfa.reply_to_all(receipt, "Reply body")
175 172
 
176  
-````ruby
177  
-  #alfa wants to reply to the sender of a message (and ONLY the sender)
178  
-  #using a receipt
179  
-  alfa.reply_to_sender(receipt, "Reply body")
180  
-````
  173
+#using a conversation
  174
+alfa.reply_to_conversation(conversation, "Reply body")
  175
+```
  176
+
  177
+```ruby
  178
+#alfa wants to reply to the sender of a message (and ONLY the sender)
  179
+#using a receipt
  180
+alfa.reply_to_sender(receipt, "Reply body")
  181
+```
181 182
 
182 183
 ### How can I retrieve my conversations?
183 184
 
184  
-````ruby
185  
-  #alfa wants to retrieve all his conversations
186  
-  alfa.mailbox.conversations
187  
-  #A wants to retrieve his inbox
188  
-  alfa.mailbox.inbox
189  
-  #A wants to retrieve his sent conversations
190  
-  alfa.mailbox.sentbox
191  
-  #alfa wants to retrieve his trashed conversations
192  
-  alfa.mailbox.trash
193  
-````
  185
+```ruby
  186
+#alfa wants to retrieve all his conversations
  187
+alfa.mailbox.conversations
  188
+
  189
+#A wants to retrieve his inbox
  190
+alfa.mailbox.inbox
  191
+
  192
+#A wants to retrieve his sent conversations
  193
+alfa.mailbox.sentbox
  194
+
  195
+#alfa wants to retrieve his trashed conversations
  196
+alfa.mailbox.trash
  197
+```
194 198
 
195 199
 ### How can I paginate conversations?
196 200
 
197 201
 You can use Kaminari to paginate the conversations as normal. Please, make sure you use the last version as mailboxer uses `select('DISTINCT conversations.*')` which was not respected before Kaminari 0.12.4 according to its changelog. Working corretly on Kaminari 0.13.0.
198 202
 
199  
-````ruby
200  
-  #Paginating all conversations using :page parameter and 9 per page
201  
-  conversations = alfa.mailbox.conversations.page(params[:page]).per(9)
202  
-  #Paginating received conversations using :page parameter and 9 per page
203  
-  conversations = alfa.mailbox.inbox.page(params[:page]).per(9)
204  
-  #Paginating sent conversations using :page parameter and 9 per page
205  
-  conversations = alfa.mailbox.sentbox.page(params[:page]).per(9)
206  
-  #Paginating trashed conversations using :page parameter and 9 per page
207  
-  conversations = alfa.mailbox.trash.page(params[:page]).per(9) 
208  
-````
  203
+```ruby
  204
+#Paginating all conversations using :page parameter and 9 per page
  205
+conversations = alfa.mailbox.conversations.page(params[:page]).per(9)
  206
+
  207
+#Paginating received conversations using :page parameter and 9 per page
  208
+conversations = alfa.mailbox.inbox.page(params[:page]).per(9)
  209
+  
  210
+#Paginating sent conversations using :page parameter and 9 per page
  211
+conversations = alfa.mailbox.sentbox.page(params[:page]).per(9)
  212
+
  213
+#Paginating trashed conversations using :page parameter and 9 per page
  214
+conversations = alfa.mailbox.trash.page(params[:page]).per(9) 
  215
+```
209 216
 
210 217
 ### How can I read the messages of a conversation?
211 218
 
@@ -213,19 +220,21 @@ As a messageable, what you receive receipts wich are linked with the message its
213 220
 
214 221
 This is done this way because receipts save the information about the relation between messageable and the messages: is it read?, is it trashed?, etc.
215 222
 
216  
-````ruby
217  
-  #alfa gets the last conversation (chronologically, the first in the inbox)
218  
-  conversation = alfa.mailbox.inbox.first
219  
-  #alfa gets it receipts chronologically ordered.
220  
-  receipts = conversation.receipts_for alfa
221  
-  #using the receipts (i.e. in the view)
222  
-  receipts.each do |receipt|
223  
-    ...
224  
-    message = receipt.message
225  
-    read = receipt.is_unread? #or message.is_unread?(alfa)
226  
-    ...
227  
-  end
228  
-````
  223
+```ruby
  224
+#alfa gets the last conversation (chronologically, the first in the inbox)
  225
+conversation = alfa.mailbox.inbox.first
  226
+
  227
+#alfa gets it receipts chronologically ordered.
  228
+receipts = conversation.receipts_for alfa
  229
+
  230
+#using the receipts (i.e. in the view)
  231
+receipts.each do |receipt|
  232
+  ...
  233
+  message = receipt.message
  234
+  read = receipt.is_unread? #or message.is_unread?(alfa)
  235
+  ...
  236
+end
  237
+```
229 238
 
230 239
 You can take a look at the full documentation of Mailboxer in [rubydoc.info](http://rubydoc.info/gems/mailboxer/frames).
231 240
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.