twim 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.markdown +43 -0
- data/Rakefile +7 -0
- data/bin/twim +3 -0
- data/lib/twim.rb +39 -0
- data/lib/twim.vim +38 -0
- data/twim.gemspec +23 -0
- metadata +73 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/
|
data/README.markdown
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# twim
|
2
|
+
|
3
|
+
`twim` lets you post status updates to your Twitter from Vim.
|
4
|
+
|
5
|
+
# Installation
|
6
|
+
|
7
|
+
gem install twim
|
8
|
+
|
9
|
+
# Setup
|
10
|
+
|
11
|
+
Before using twim, you must first get a Twitter API key and authorize
|
12
|
+
the `twurl` command (note that this is a different command from `twim`)
|
13
|
+
to access your Twitter account. Type
|
14
|
+
|
15
|
+
twurl -T
|
16
|
+
|
17
|
+
for instructions.
|
18
|
+
|
19
|
+
|
20
|
+
# Usage
|
21
|
+
|
22
|
+
twim
|
23
|
+
|
24
|
+
This will invoke vim, where you can compose your tweet. Look at the Vim status
|
25
|
+
line to see how many characters you have left before reaching the character
|
26
|
+
limit.
|
27
|
+
|
28
|
+
If you paste or type in a long URL, `twim` can convert it into a TinyURL. Just
|
29
|
+
put the cursor somewhere on the URL and type `<Leader>,` (the leader key
|
30
|
+
followed by a comma). Note that this feature assumes you have `curl` install on
|
31
|
+
your system.
|
32
|
+
|
33
|
+
# About
|
34
|
+
|
35
|
+
Twim is really just a convenience wrapper around the awesome [twurl][twurl]
|
36
|
+
program.
|
37
|
+
|
38
|
+
[twurl]:https://github.com/marcel/twurl
|
39
|
+
|
40
|
+
My name is Daniel Choi. I'm a big fan of Vim and the command line. You can
|
41
|
+
follow me on Twitter at <http://twitter.com/danchoi>.
|
42
|
+
|
43
|
+
|
data/Rakefile
ADDED
data/bin/twim
ADDED
data/lib/twim.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'twurl'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
class Twim
|
6
|
+
class << self
|
7
|
+
def run
|
8
|
+
options = Twurl::CLI.parse_options ["/1/statuses/update.xml"]
|
9
|
+
vimscript = File.expand_path '../twim.vim', __FILE__
|
10
|
+
f = Tempfile.new('twitter-msg')
|
11
|
+
msg = begin
|
12
|
+
system "vim -S %s %s" % [vimscript, f.path]
|
13
|
+
f.read
|
14
|
+
ensure
|
15
|
+
f.close
|
16
|
+
end
|
17
|
+
msg = msg.strip.gsub(/\s+/, ' ')
|
18
|
+
if msg.empty?
|
19
|
+
puts "No tweet to post."
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
puts "Posting update (%s characters):" % msg.length
|
23
|
+
puts msg
|
24
|
+
options.data['status'] = msg
|
25
|
+
Twurl::CLI.dispatch options
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
if __FILE__ == $0
|
31
|
+
if Twurl::OAuthClient.rcfile.empty?
|
32
|
+
puts '-' * 70
|
33
|
+
puts "You must first get an API key and authorize twurl to use it."
|
34
|
+
puts "Type twurl -T for instructions."
|
35
|
+
puts '-' * 70
|
36
|
+
exit 1
|
37
|
+
end
|
38
|
+
Twim.run
|
39
|
+
end
|
data/lib/twim.vim
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
function! CountChars()
|
2
|
+
let lnum = 1
|
3
|
+
let n = 0
|
4
|
+
while lnum <= line("$")
|
5
|
+
let n = n + len(getline(lnum))
|
6
|
+
if lnum < line("$")
|
7
|
+
let n = n + 1 " because wordwrap eliminates a space
|
8
|
+
endif
|
9
|
+
let lnum = lnum + 1
|
10
|
+
endwhile
|
11
|
+
return n
|
12
|
+
endfunction
|
13
|
+
|
14
|
+
function! TwimStatusLine()
|
15
|
+
let filled = CountChars()
|
16
|
+
let remaining = 130 - filled
|
17
|
+
let line = "%<Number of characters: " . filled . " Remaining: " . remaining . " %r%=%-14.(%l,%c%V%)\ %P"
|
18
|
+
return line
|
19
|
+
endfunc
|
20
|
+
|
21
|
+
function! TinyUrl()
|
22
|
+
let url = shellescape(expand("<cWORD>"))
|
23
|
+
let cmd = "curl -s http://tinyurl.com/api-create.php?url=" . url
|
24
|
+
echom "Converting URL to TinyURL..."
|
25
|
+
let tinyurl = system(cmd)
|
26
|
+
" this works fine except at beginning of line, but ok
|
27
|
+
exec "normal caW " . tinyurl
|
28
|
+
endfunc
|
29
|
+
|
30
|
+
|
31
|
+
set textwidth=72
|
32
|
+
setlocal statusline=%!TwimStatusLine()
|
33
|
+
|
34
|
+
noremap <silent> <buffer> <leader>, <Esc>:call TinyUrl()<CR>
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
data/twim.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "twim"
|
5
|
+
s.version = '0.0.1'
|
6
|
+
s.platform = Gem::Platform::RUBY
|
7
|
+
s.required_ruby_version = '>= 1.9.0'
|
8
|
+
|
9
|
+
s.authors = ["Daniel Choi"]
|
10
|
+
s.email = ["dhchoi@gmail.com"]
|
11
|
+
s.homepage = "https://github.com/danchoi/twim"
|
12
|
+
s.summary = %q{tail your Twitter timeslines}
|
13
|
+
s.description = %q{tail your Twitter timeslines}
|
14
|
+
|
15
|
+
s.rubyforge_project = "twim"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency 'twurl', '>= 0.6.3'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: twim
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Daniel Choi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-05-05 00:00:00 -04:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: twurl
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.6.3
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
description: tail your Twitter timeslines
|
28
|
+
email:
|
29
|
+
- dhchoi@gmail.com
|
30
|
+
executables:
|
31
|
+
- twim
|
32
|
+
extensions: []
|
33
|
+
|
34
|
+
extra_rdoc_files: []
|
35
|
+
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- README.markdown
|
39
|
+
- Rakefile
|
40
|
+
- bin/twim
|
41
|
+
- lib/twim.rb
|
42
|
+
- lib/twim.vim
|
43
|
+
- twim.gemspec
|
44
|
+
has_rdoc: true
|
45
|
+
homepage: https://github.com/danchoi/twim
|
46
|
+
licenses: []
|
47
|
+
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 1.9.0
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project: twim
|
68
|
+
rubygems_version: 1.6.1
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: tail your Twitter timeslines
|
72
|
+
test_files: []
|
73
|
+
|