vmail 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. data/.gitignore +3 -0
  2. data/NOTES +7 -2
  3. data/README.markdown +310 -72
  4. data/lib/vmail.rb +8 -0
  5. data/lib/vmail.vim +53 -21
  6. data/lib/vmail/imap_client.rb +19 -4
  7. data/lib/vmail/message_formatter.rb +32 -11
  8. data/lib/vmail/options.rb +14 -13
  9. data/lib/vmail/version.rb +1 -1
  10. data/test/fixtures/rfc_part.eml +306 -0
  11. data/test/message_formatter_test.rb +12 -1
  12. data/vmail.gemspec +3 -3
  13. data/website/.gitignore +1 -0
  14. data/website/bottom.markdown +20 -0
  15. data/website/gen.rb +22 -0
  16. data/website/images-vmail/1-small.png +0 -0
  17. data/website/images-vmail/1.png +0 -0
  18. data/website/images-vmail/attach-small.png +0 -0
  19. data/website/images-vmail/attach.png +0 -0
  20. data/website/images-vmail/autocomplete-small.png +0 -0
  21. data/website/images-vmail/autocomplete.png +0 -0
  22. data/website/lightbox2/css/lightbox.css +27 -0
  23. data/website/lightbox2/images/bullet.gif +0 -0
  24. data/website/lightbox2/images/close.gif +0 -0
  25. data/website/lightbox2/images/closelabel.gif +0 -0
  26. data/website/lightbox2/images/donate-button.gif +0 -0
  27. data/website/lightbox2/images/download-icon.gif +0 -0
  28. data/website/lightbox2/images/image-1.jpg +0 -0
  29. data/website/lightbox2/images/loading.gif +0 -0
  30. data/website/lightbox2/images/nextlabel.gif +0 -0
  31. data/website/lightbox2/images/prevlabel.gif +0 -0
  32. data/website/lightbox2/images/thumb-1.jpg +0 -0
  33. data/website/lightbox2/index.html +63 -0
  34. data/website/lightbox2/js/builder.js +136 -0
  35. data/website/lightbox2/js/effects.js +1122 -0
  36. data/website/lightbox2/js/lightbox.js +498 -0
  37. data/website/lightbox2/js/prototype.js +4221 -0
  38. data/website/lightbox2/js/scriptaculous.js +58 -0
  39. data/website/stylesheets-vmail/960.css +1 -0
  40. data/website/stylesheets-vmail/reset.css +1 -0
  41. data/website/stylesheets-vmail/site.css +59 -0
  42. data/website/stylesheets-vmail/syntax-colors.css +33 -0
  43. data/website/stylesheets-vmail/text.css +1 -0
  44. data/website/top.markdown +9 -0
  45. data/website/vmail-template.html +50 -0
  46. data/website/vmail.html +438 -0
  47. metadata +48 -10
  48. data/gmail.vim +0 -180
  49. data/wrapper.rb +0 -8
data/.gitignore CHANGED
@@ -1,4 +1,7 @@
1
+ .DS_Store
1
2
  *swp
2
3
  login.yml
3
4
  gmail.yml
4
5
  *.log
6
+ pkg/
7
+ .rvmrc
data/NOTES CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  interesting. the UID don't seem to be globally unique. two different
3
2
  messages in 2 different mailboxes can have same UID
4
3
 
@@ -492,10 +491,16 @@ DONE
492
491
  - .vmailrc is a yaml file, first in current dir, then check home, can
493
492
  also use command line opts
494
493
  - fix tests
494
+ - open_href is an improved way to open http hrefs
495
+ - VMAIL_URL_OPENER=elinks
496
+ - digg, reddit, etc buttons
497
+ - note dependence on lynx on startup
495
498
 
496
499
  NEXT:
497
500
  - help doc: just return readme file, or a vim version of it (vim filetype later)
498
- - note dependence on lynx in README
501
+ - width 780 px
502
+ - try turning starred item color into some existing syn color group -
503
+ like comments
499
504
 
500
505
  later:
501
506
  - mvim - starred messages not syntax colored
@@ -1,106 +1,344 @@
1
1
  # vmail
2
2
 
3
- This project provides a Vim interface to Gmail.
3
+ vmail is a Vim interface to Gmail. Here are some screenshots:
4
4
 
5
- This is an alpha version. To run it, you need vim or macvim.
5
+ Why vmail? Because every minute you spend fumbling around in a web browser is a
6
+ minute you're not experiencing the Zen of using a real text editor and staying
7
+ close to the Unix command line.
8
+
9
+ ## Prerequisites
6
10
 
7
- You also need ruby (1.9.2 recommended but not required) and rubygems.
11
+ * a Gmail account
12
+ * a relatively recent version of Vim (vmail is developed against Vim 7.3)
13
+ * Ruby (vmail is developed using Ruby 1.9.2)
14
+ * RubyGems (if Ruby version is older than 1.9)
15
+ * the `lynx` text-only-mode web browser is required to view HTML mail parts in vmail
8
16
 
9
- Once you have those prerequisites, you can install vmail with `gem install
10
- vmail`.
17
+ The current version of vmail assumes a Unix environment. I'll try to make later versions accommodate Windows.
11
18
 
12
- To use this alpha version, you need to put a gmail.yml file in your home
13
- directory.
19
+ ## Installation
14
20
 
15
- The format of the yaml file is as follows:
21
+ gem install vmail
22
+
23
+ ## Configuration file
24
+
25
+ To run vmail, create a yaml file called `.vmailrc` and save it either in the
26
+ current directory (the directory from which you launch vmail) or in your home
27
+ directory.
28
+
29
+ The `.vmailrc` file should look something like this. Substitute your own values.
16
30
 
17
31
  username: dhchoi@gmail.com
18
- password: mypassword
32
+ password: password
19
33
  name: Daniel Choi
20
34
  signature: |
21
35
  --
22
- Sent via vmail. http://danielchoi.com
36
+ Sent via vmail. http://danielchoi.com/software/vmail.html
37
+
38
+ This file should be formatted in [YAML syntax][1].
39
+
40
+ [1]:http://www.yaml.org/spec/1.2/spec.html
41
+
42
+ You can omit the password key-value pair if you'd rather not have the password
43
+ saved in the file. In that case, you'll prompted for the password each time you
44
+ start vmail.
45
+
46
+ ## Contacts autocompletion
47
+
48
+ vmail uses vim autocompletion to help you auto-complete email addresses.
49
+ To use this feature, generate a `vmail-contacts.txt` file in the current or
50
+ home directory. This is a simple list of your email contacts.
51
+ Invoking vmail with the `-g` option generates this file for you by
52
+ collecting all the recipients and cc's from your last 500 sent
53
+ emails. You can adjust this number by using `-g` with a number argument.
54
+
55
+ After vmail generates this file for you, you can edit it however and whenever
56
+ you want, as long as there is one address per line.
57
+
58
+ ## Starting vmail
59
+
60
+ Once you've created the configuration file and (optionally) the contacts file,
61
+ you can start vmail with
62
+
63
+ vmail
64
+
65
+ This opens the vmail/vim interface and shows you the last 100 messages in your
66
+ Gmail inbox.
67
+
68
+ You can have vmail show messages from any other mailbox (a.k.a. label) on
69
+ startup by passing in the mailbox name as an argument:
70
+
71
+ vmail starred
72
+
73
+ You can also pass in search parameters:
74
+
75
+ vmail important from barackobama@whitehouse.gov
76
+
77
+ On startup, vmail loads 100 messages by default. You can increase or decrease
78
+ this number by passing in a number after the mailbox name:
79
+
80
+ vmail inbox 700 subject unix
81
+
82
+ ## Viewing messages
83
+
84
+ The first screen vmail shows you is a list of messages. You can view a message
85
+ by moving the cursor line to it and pressing ENTER. This will split the screen
86
+ and show the message content in the bottom pane.
87
+
88
+ To full-screen the message, press SPACE when the cursor is the message window.
89
+ To go back to the split view, press ENTER.
90
+
91
+ You can full-screen the list window by pressing SPACE while the cursor is in it.
92
+
93
+ In the split view, you can jump between the two panes by just pressing ENTER
94
+ from either window.
95
+
96
+ vmail loads a certain number messages at a time, starting with the most recent.
97
+ If there are more messages that vmail hasn't loaded, you'll see a line at the
98
+ top of the list that looks something like this:
99
+
100
+ > Load 100 more messages. 156 remaining.
101
+
102
+ Put the cursor on this line and press ENTER to load more of these messages.
103
+
104
+ Unread messages are marked with a `[+]` symbol.
105
+
106
+ To view the raw RFC822 version of a message, type `,R` while viewing the message.
107
+
108
+ ## Starring, deleting, archiving, marking spam
109
+
110
+ To star a message, put the cursor on it and type `,*` or alternatively `s`.
111
+ Starring a message copies it to the `starred` mailbox. Starred messages are
112
+ marked with a `[*]` symbol and color-highlighted.
113
+
114
+ To delete a message, put the cursor on it and type `,#` or alternatively `,d`.
115
+ Deleting a message puts it in the `trash` mailbox. Deleting a message from the
116
+ `trash` mailbox deletes it permanently.
117
+
118
+ To archive a message, put the cursor on it and type `,e`. Archiving a message
119
+ moves it to the `all` mailbox.
120
+
121
+ To mark a message spam, put the cursor on it and type `,!`. This moves the
122
+ message to to the `spam` mailbox.
123
+
124
+ You can use range selections in the message list when you star, delete, mark as
125
+ spam, or archive. Use `<C-v>` to start marking a range of lines (the vertical
126
+ position of the cursor doesn't matter). Then type any of the above commands to
127
+ perform an action on all the messages you selected.
128
+
129
+ ## Switching mailboxes, moving messages, copying messages to another mailbox
130
+
131
+ To switch mailboxes, type `,m`. You'll see an autocomplete window appear at the top.
132
+ The standard vim autocomplete keystrokes apply:
133
+
134
+ * `C-p` and `C-n` move you up and down the match list
135
+ * `C-e` closes the match list and lets you continue typing
136
+ * `C-u`: when the match list is active, cycles forward through the match list and what you've typed so far; when the match list is inactive, erases what you've typed.
137
+ * `C-x C-u` finds matches for what you've typed so far (when the match list window is closed)
138
+ * `C-y` selects the highlighted match without triggering ENTER
139
+ * ENTER selects the highlighted match from the match list
140
+
141
+ Tip: start typing the first 1-3 characters of the mailbox name, then press
142
+ `C-u` or `C-p` until you highlight the right match, and finally press ENTER to
143
+ select.
144
+
145
+ To move a message to another mailbox, put the cursor on the message in the
146
+ message list, and type `,b`. You'll be prompted to select the target mailbox.
147
+
148
+ To copy a message to another mailbox, put the cursor on the message in the
149
+ message list, and type `,B`. You'll be prompted to select the target mailbox.
150
+
151
+ ## Composing messages
152
+
153
+ To start writing a new a email message, type `,c`.
154
+
155
+ To reply to a message, type `,r`.
156
+
157
+ To reply-all to a message, type `,a`.
158
+
159
+ To forward a message, type `,f`.
160
+
161
+ All these command open a message composition window. At the top, you will see
162
+ mail headers like this:
163
+
164
+ from: Daniel Choi <dhchoi@gmail.com>
165
+ to:
166
+ subject:
167
+
168
+ The `from:` field will be pre-filled from your `.vmailrc` configuration.
169
+ You're responsible for fill in the `to:` and the `subject:` fields.
170
+ You can add a `cc:` and `bcc:` field if you want.
171
+
172
+
173
+ When you fill in the recipient addresses, you can use vim autocompletion if you
174
+ generated a `vmail-contacts.txt` file. Start typing a name or email address, then press `C-x C-u`
175
+ to invoke autocompletion.
176
+
177
+ Tip: Use `C-y` instead of ENTER to select a match. This will prevent you from
178
+ creating a blank line in the middle of the email headers.
179
+
180
+ Make sure your email addresses are separated by commas and that they all
181
+ ultimately appear on the **same, unbroken line** for each field. Vim will
182
+ probably break long lines automatically as you type them, so for now (pending a
183
+ future enhancement), you'll have to rejoin the lines if breaks get inserted.
184
+
185
+ After you fill in the headers, write your message. Make sure there is a
186
+ blank line between the headers and the body of your message.
187
+
188
+ When you're done writing, send the message by typing `,vs` in normal mode.
189
+
190
+ You can save the message as a draft in your draft mailbox by typing `,vd` in
191
+ normal mode.
192
+
193
+ At any point, you can quit the composition window by typing `q` in normal mode.
194
+
195
+ ## Attachments
196
+
197
+ The current version of vmail can handle attachments to a certain extent.
198
+
199
+ When you're viewing a message with attachments, you'll see something like this
200
+ at the top of the message window:
201
+
202
+ INBOX 2113 4 kb
203
+ - image/png; name=canada.png
204
+ - image/gif; name=arrow_right.gif
205
+ ---------------------------------------
206
+ from: Daniel Choi <dhchoi@gmail.com>
207
+ date: Sun, Dec 12 08:39 AM -05:00 2010
208
+ to: Daniel Choi <dhchoi@gmail.com>
209
+ subject: attachment test
210
+
211
+ see attached
212
+
213
+ To download these attachments to a local directory, type `,A`. You'll be
214
+ prompted for a directory path. Then vmail will save all the attachments in the
215
+ message to this directory.
216
+
217
+ To send attachments, add something like this to your new message in the message
218
+ composition window:
219
+
220
+ from: Daniel Choi <dhchoi@gmail.com>
221
+ to: barackobama@whitehouse.gov
222
+ subject: look at this!
223
+
224
+ attach:
225
+ - images/middle-east-map.png
226
+ - images/policypaper.pdf
227
+ - docs/
228
+
229
+ I think you'll find this stuff interesting.
230
+
231
+
232
+ The `attach:` block is a YAML list. The items are paths (either relative or
233
+ absolute) to the files you want to attach to your message. Note that you can
234
+ also specify a directory, in which case vmail attaches every file it finds in
235
+ that directory.
236
+
237
+ One thing vmail doesn't do yet is let you forward a message with all its
238
+ attachments intact. This feature will be implemented in the near future.
239
+
240
+ ## Printing messages to a file
241
+
242
+ `,vp` from the message list prints (appends) the text content of all the selected
243
+ messages to a file.
244
+
245
+ ## Invoking your web browser
246
+
247
+ When you're reading a message, `,o` opens the first hyperlink in the document
248
+ on or after the cursor in your normal web browser.
249
+
250
+ When you're reading a message with an html mail part, `,h` saves that part to a
251
+ local file (`vmail-htmlpart.html`) and opens it in your normal web browser.
252
+
253
+ By default, the command vmail uses to open your web browser is `open`. In OS X,
254
+ this opens URLs and HTML files in the default web browser. You can change the
255
+ browser vmail invokes by setting the VMAIL_BROWSER environmental variable
256
+ before you start vmail, e.g.:
257
+
258
+ export VMAIL_BROWSER='elinks'
259
+
260
+ ## Search queries
261
+
262
+ vmail can generate a message list by performing an IMAP search on the current mailbox.
263
+ From the message list window, type `,s`. This will prompt you for a search query.
264
+ The search query is an optional number specifying the number of messages to return,
265
+ followed by a valid IMAP search query.
266
+
267
+ Here are some example search queries.
268
+
269
+ # the default
270
+ 100 all
271
+
272
+ # all messages from thematrix.com domain
273
+ from thematrix.com
274
+
275
+ # all messages from this person
276
+ from barackobama@whitehouse.gov
277
+
278
+ # subject field search; use double quotes to enclose multiple words
279
+ subject "unix philosophy"
23
280
 
24
- Start the program by typing `vmail` on your command line. If you want to use the Macvim
25
- version, `export VMAIL_VIM=mvim` first.
281
+ # example of date range and multiple conditions
282
+ before 30-Nov-2010 since 1-Nov-2010 from prx.org
26
283
 
27
- There is no real documentation as of yet, but here are the raw vimscript mappings
284
+ Tip: When you're entering your search query, `<C-u>` clears the query line.
28
285
 
286
+ Power-Tip: `<C-f>` opens a mini-editor that contains the current query plus a history of
287
+ previous vmail search queries. You can edit any line in this mini-editor and
288
+ press ENTER to perform the query on that line.
29
289
 
30
- ## From Message List Window:
290
+ ## Using vmail with MacVim
31
291
 
32
- inoremap <silent> <buffer> <esc> <Esc>:q<cr>
33
- inoremap <silent> <buffer> <esc> <Esc>:q<cr>
34
- noremap <silent> <buffer> <cr> :call <SID>show_message()<CR>
35
- noremap <silent> <buffer> q :qal!<cr>
36
- noremap <silent> <buffer> s :call <SID>toggle_star()<CR>
37
- noremap <silent> <buffer> <leader>d :call <SID>delete_messages("Deleted")<CR>
38
- noremap <silent> <buffer> <leader>! :call <SID>delete_messages("[Gmail]/Spam")<CR>
39
- noremap <silent> <buffer> u :call <SID>update()<CR>
40
- noremap <silent> <buffer> <Leader>s :call <SID>search_window()<CR>
41
- noremap <silent> <buffer> <Leader>m :call <SID>mailbox_window()<CR>
42
- noremap <silent> <buffer> <Leader>v :call <SID>move_to_mailbox()<CR>
43
- noremap <silent> <buffer> <Leader>c :call <SID>compose_message()<CR>
44
- noremap <silent> <buffer> <Leader>r :call <SID>show_message()<cr>:call <SID>compose_reply(0)<CR>
45
- " reply all
46
- noremap <silent> <buffer> <Leader>a :call <SID>show_message()<cr>:call <SID>compose_reply(1)<CR>
292
+ vmail uses standard Vim by default, but vmail also works with MacVim, but not
293
+ perfectly. In particular, there seems to be a bug in MacVim that prevents
294
+ vmail's status line activity messages from appearing properly. Nonetheless,
295
+ most of vmail is functional in MacVim.
47
296
 
297
+ To use MacVim as your vmail Vim engine, `export VMAIL_VIM=mvim` before startin
298
+ vmail.
48
299
 
49
- ## From Message Window:
300
+ Note that when vmail uses MacVim, the terminal window in which you invoke vmail
301
+ will show vmail's logging output while MacVim is running. To quit vmail in
302
+ MacVim mode, you will have to press CTRL-c in this window to stop the vmail
303
+ process.
50
304
 
51
- noremap <silent> <buffer> <cr> :call <SID>focus_list_window()<CR>
52
- noremap <silent> <buffer> <Leader>q :call <SID>focus_list_window()<CR>
53
- nnoremap <silent> <buffer> q :close<cr>
54
- noremap <silent> <buffer> q <Leader>q
55
- noremap <silent> <buffer> <Leader>r :call <SID>compose_reply(0)<CR>
56
- noremap <silent> <buffer> <Leader>a :call <SID>compose_reply(1)<CR>
57
- noremap <silent> <buffer> <Leader>R :call <SID>show_raw()<cr>
58
- noremap <silent> <buffer> <Leader>f :call <SID>compose_forward()<CR><cr>
59
- noremap <silent> <buffer> <leader>j :call <SID>show_next_message()<CR>
60
- noremap <silent> <buffer> <leader>k :call <SID>show_previous_message()<CR>
61
- noremap <silent> <buffer> <Leader>c :call <SID>compose_message()<CR>
62
- noremap <silent> <buffer> <Leader>h :call <SID>open_html_part()<CR><cr>
63
- nnoremap <silent> <buffer> <leader>d :call <SID>focus_list_window()<cr>:call <SID>delete_messages("Deleted")<cr>
64
- nnoremap <silent> <buffer> s :call <SID>focus_list_window()<cr>:call <SID>toggle_star()<cr>
65
- nnoremap <silent> <buffer> <Leader>m :call <SID>focus_list_window()<cr>:call <SID>mailbox_window()<CR>
66
- nnoremap <silent> <buffer> <Leader>A :call <SID>save_attachments()<cr>
305
+ ## vmail file byproducts
67
306
 
307
+ vmail generates a few file byproducts when it is running. It generates a
308
+ temporary `vmailbuffer.txt` file in the current directory to hold the message
309
+ list. This should get deleted automatically when vmail quits.
68
310
 
69
- ## From Message Compose Window
311
+ vmail also creates a `vmail-htmlpart.html` file in the current directory if you
312
+ open an HTML mail part from vmail.
70
313
 
71
- noremap <silent> <buffer> <Leader>d :call <SID>deliver_message()<CR>
72
- nnoremap <silent> <buffer> q :call <SID>cancel_compose()<cr>
73
- nnoremap <silent> <buffer> <leader>q :call <SID>cancel_compose()<cr>
74
- nnoremap <silent> <buffer> <Leader>s :call <SID>save_draft()<CR>
314
+ Finally, vmail logs output to a `vmail.log` file which it creates in the
315
+ current directory. You can tail this file in a separate terminal window to see
316
+ what's going on behind the scenes as you use vmail.
75
317
 
76
- Other:
318
+ ## Is my gmail password secure?
77
319
 
78
- nnoremap <silent> <buffer> <Space> :call <SID>toggle_fullscreen()<cr>
320
+ In short, yes. vmail uses TLS ([Transport Layer Security][1]) to perform IMAP
321
+ and SMTP authentication. So vmail transmits your password securely over the
322
+ network.
79
323
 
324
+ [1]:http://en.wikipedia.org/wiki/Transport_Layer_Security
80
325
 
326
+ You can also be sure that the vmail code doesn't do anything nefarious with your
327
+ Gmail password because vmail is open source. Anyone can inspect the source code
328
+ of the copy fo vmail that runs on your computer and inspect the code at the
329
+ [github repository][1] and at [rubygems.org][2] (where the vmail gem is
330
+ downloaded from).
81
331
 
82
- ## Open Source License
332
+ [1]:https://github.com/danchoi/vmail
333
+ [2]:https://rubygems.org/gems/vmail
83
334
 
84
- The source code for vmail is governed by the MIT License, which reads as
85
- follows:
335
+ ## Bug reports, feature requests
86
336
 
87
- Copyright (c) 2010 Daniel Choi
337
+ Please file bug reports and features requests in the [vmail github issue tracker][1].
88
338
 
89
- Permission is hereby granted, free of charge, to any person obtaining a copy
90
- of this software and associated documentation files (the "Software"), to
91
- deal in the Software without restriction, including without limitation the
92
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
93
- sell copies of the Software, and to permit persons to whom the Software is
94
- furnished to do so, subject to the following conditions:
339
+ [1]:https://github.com/danchoi/vmail/issues
95
340
 
96
- The above copyright notice and this permission notice shall be included in
97
- all copies or substantial portions of the Software.
341
+ ## How to contact the developer
98
342
 
99
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
100
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
101
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
102
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
103
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
104
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
105
- IN THE SOFTWARE.
343
+ My name is Daniel Choi. I am based in Cambridge, MA, and you can email me at dhchoi@gmail.com.
106
344
 
@@ -5,8 +5,16 @@ module Vmail
5
5
  extend self
6
6
 
7
7
  def start
8
+
8
9
  vim = ENV['VMAIL_VIM'] || 'vim'
9
10
 
11
+ ENV['VMAIL_BROWSER'] ||= 'open'
12
+
13
+ # check for lynx
14
+ if `which lynx` == ''
15
+ puts "You need to install lynx on your system in order to see html-only messages"
16
+ sleep 3
17
+ end
10
18
  opts = Vmail::Options.new(ARGV)
11
19
  opts.config
12
20