cloudapp-cli 1.0.0.beta.1 → 1.0.0.beta.2
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.
- data/Gemfile.lock +1 -1
- data/bin/cloudapp +77 -19
- data/cloudapp-cli.gemspec +2 -2
- data/lib/cloudapp/cli.rb +1 -1
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/bin/cloudapp
CHANGED
@@ -42,12 +42,14 @@ def draw_drops_window(drops)
|
|
42
42
|
# selection indicator.
|
43
43
|
width = drops.map {|drop| drop.name.size }.max + 3
|
44
44
|
height = drops.size * 3
|
45
|
+
col = (COLS() - width) / 2 - 1
|
46
|
+
row = (LINES() - height) / 2 - 1
|
45
47
|
|
46
|
-
wrap = newwin height + 2, width + 2,
|
48
|
+
wrap = newwin height + 2, width + 2, row, col
|
47
49
|
box wrap, 0, 0
|
48
50
|
wrefresh wrap
|
49
51
|
|
50
|
-
win =
|
52
|
+
win = derwin wrap, height, width, 1, 1
|
51
53
|
|
52
54
|
drops.each do |drop|
|
53
55
|
drop_lines(drop).each do |line|
|
@@ -59,6 +61,11 @@ def draw_drops_window(drops)
|
|
59
61
|
end
|
60
62
|
wrefresh win
|
61
63
|
|
64
|
+
# Enabling the keypad allows the use of the arrow keys. I don't know why. With
|
65
|
+
# the keypad either enabled or disabled the the would-be arrow keys on some
|
66
|
+
# keyboard keypads don't work as arrow keys (8=up, 2=down, etc).
|
67
|
+
keypad win, true
|
68
|
+
|
62
69
|
[ win, wrap ]
|
63
70
|
end
|
64
71
|
|
@@ -100,52 +107,99 @@ end
|
|
100
107
|
def popup_window(parent, text)
|
101
108
|
text_width = text.lines.map{ |x| x.size }.max
|
102
109
|
text_height = text.lines.to_a.size
|
103
|
-
rows, cols = getmaxyx
|
110
|
+
rows, cols = !parent.nil? ? getmaxyx(parent) : [ LINES(), COLS() ]
|
104
111
|
width = text_width + 4
|
105
112
|
height = text_height + 4
|
106
|
-
col = (cols - width) / 2
|
107
|
-
row = (rows - height) / 2
|
113
|
+
col = (cols - width) / 2
|
114
|
+
row = (rows - height) / 2
|
108
115
|
|
109
|
-
|
110
|
-
|
116
|
+
if parent
|
117
|
+
frame = derwin parent, height, width, row, col
|
118
|
+
else
|
119
|
+
frame = newwin height, width, row, col
|
120
|
+
end
|
111
121
|
|
112
|
-
frame
|
122
|
+
werase frame
|
113
123
|
box frame, 0, 0
|
114
124
|
|
115
125
|
win = derwin frame, text_height, text_width, 2, 2
|
116
126
|
wmove win, 0, 0
|
117
127
|
waddstr win, text
|
118
128
|
|
119
|
-
wrefresh space
|
120
129
|
wrefresh frame
|
121
130
|
wrefresh win
|
122
131
|
|
123
|
-
|
124
|
-
|
125
|
-
|
132
|
+
if block_given?
|
133
|
+
yield
|
134
|
+
else
|
135
|
+
ch = wgetch win
|
136
|
+
log 'popup', ch
|
137
|
+
flushinp
|
138
|
+
ungetch ch
|
139
|
+
end
|
126
140
|
|
127
141
|
delwin win
|
128
142
|
delwin frame
|
129
|
-
delwin space
|
130
143
|
end
|
131
144
|
|
145
|
+
def show_help(win)
|
146
|
+
help = <<-HELP.chomp
|
147
|
+
j/k = Move down/up
|
148
|
+
d/p = Next/previous page
|
149
|
+
|
150
|
+
c = Copy share link
|
151
|
+
C = Copy embed link
|
152
|
+
D = Copy download link
|
153
|
+
t = Copy thumbnail link
|
154
|
+
HELP
|
155
|
+
popup_window win, help
|
156
|
+
ch = wgetch win
|
157
|
+
log 'show_help', ch
|
158
|
+
ungetch ch unless ch == ??.ord
|
159
|
+
end
|
132
160
|
|
133
|
-
drops = account.drops(limit: 5)
|
134
161
|
|
135
162
|
begin
|
136
163
|
initscr
|
137
164
|
noecho
|
165
|
+
curs_set 0
|
138
166
|
|
139
|
-
|
167
|
+
drops = nil
|
168
|
+
popup_window nil, 'Loading...' do
|
169
|
+
drops = account.drops limit: 10
|
170
|
+
end
|
171
|
+
|
172
|
+
win, wrap = draw_drops_window drops
|
140
173
|
selected_drop = select_drop win, 0, drops
|
141
174
|
|
142
|
-
while
|
175
|
+
while c = wgetch(win)
|
176
|
+
log 'wgetch', c
|
143
177
|
case c
|
144
|
-
when ?
|
178
|
+
when ?q.ord
|
179
|
+
break
|
180
|
+
when ??.ord
|
181
|
+
show_help win
|
182
|
+
|
183
|
+
when ?j.ord, KEY_DOWN
|
145
184
|
selected_drop += 1
|
146
|
-
when ?k.ord
|
185
|
+
when ?k.ord, KEY_UP
|
147
186
|
selected_drop -= 1
|
148
187
|
|
188
|
+
when ?d.ord
|
189
|
+
next unless drops.link('next') { nil }
|
190
|
+
popup_window win, 'Loading...' do
|
191
|
+
drops = account.drops href: drops.link('next').href
|
192
|
+
end
|
193
|
+
wclear wrap
|
194
|
+
wrefresh wrap
|
195
|
+
when ?p.ord
|
196
|
+
next unless drops.link('previous') { nil }
|
197
|
+
popup_window win, 'Loading...' do
|
198
|
+
drops = account.drops href: drops.link('previous').href
|
199
|
+
end
|
200
|
+
wclear wrap
|
201
|
+
wrefresh wrap
|
202
|
+
|
149
203
|
when ?c.ord, KEY_RETURN
|
150
204
|
link = drops[selected_drop].share_url
|
151
205
|
copy link
|
@@ -162,14 +216,18 @@ begin
|
|
162
216
|
link = drops[selected_drop].thumbnail_url
|
163
217
|
copy link
|
164
218
|
popup_window win, 'Copied thumbnail link.'
|
219
|
+
else
|
220
|
+
log 'unknown key', c
|
165
221
|
end
|
166
222
|
|
167
223
|
delwin win
|
168
|
-
|
224
|
+
delwin wrap
|
225
|
+
win, wrap = draw_drops_window drops
|
169
226
|
selected_drop = select_drop win, selected_drop, drops
|
170
227
|
end
|
171
228
|
|
172
229
|
delwin win
|
230
|
+
delwin wrap
|
173
231
|
|
174
232
|
rescue => e
|
175
233
|
endwin
|
data/cloudapp-cli.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'cloudapp-cli'
|
16
|
-
s.version = '1.0.0.beta.
|
17
|
-
s.date = '2012-08-
|
16
|
+
s.version = '1.0.0.beta.2'
|
17
|
+
s.date = '2012-08-18'
|
18
18
|
s.rubyforge_project = 'cloudapp-cli'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
data/lib/cloudapp/cli.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudapp-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.beta.
|
4
|
+
version: 1.0.0.beta.2
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cloudapp
|