ayadn 1.6.0 → 1.7.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1dbd05e3a853fb34403880501ca7fd4191ae74c
4
- data.tar.gz: 5e2cd526b19ff009e127028a33fba5a21d8ea941
3
+ metadata.gz: 378ae34a1b17ea7a5b489e31a4f29900ca2e0e4d
4
+ data.tar.gz: f4156ace495c8386f163ab656c177fc3db99d130
5
5
  SHA512:
6
- metadata.gz: 7c5b81ff93034553556e78699c67c17ebf552b6c07d311686ff48c762476d1083cfb1fd209488db58f4e13f3962524376988566b08ec9df95b11f0d12c6e3a4c
7
- data.tar.gz: 6037b01600859172ec938f5c384a87660d5cbc8dd0e1b6dfbd456405597f50dd6dfdcb961a4059b25fffe9cdfc0af5d71b0023de3344834a0f8f49152b08772b
6
+ metadata.gz: c76c035e1c8b84d265326e39cad4e2b9519de784c68b35ad30c793d12b11b2e487eaca7347be6c3c03381817ed255d3f4a692bbc5f67d65a6212558a257ef4c1
7
+ data.tar.gz: aafcac122e8d86609a94bf8be2f6b8783224798254d20841192d6d060b6caa1c5138fa2b83c024475de043ced1ae6e31db54664695adee0ad255a0814f181e1d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # 1.7.0 - 'Private Investigations'
2
+
3
+ - New: embed a Youtube video in a normal post with option `-Y`
4
+ - New: embed a Vimeo video in a normal post with option `-V`
5
+ - New: embed a movie poster in a normal post with option `-M`
6
+ - New: force view blacklisted/muted/blocked user's posts with option `-f`
7
+ - New: the cursor is hidden when the scroll spinning wheel is displayed
8
+ - Change: option to embed an image in a post is now `-E` (previously -e)
9
+ - Fixed: bookmark title; also fixed the previous fix...
10
+ - Fixed: value displayed when setting NiceRank
11
+ - Refactored a few classes and methods
12
+
1
13
  # 1.6.0 - 'Beetlejuice'
2
14
 
3
15
  - New command: 'movie'. Create a post from a movie title (with link + movie poster). Customisable hashtag (default: '#nowwatching').
data/doc/05-streams.md CHANGED
@@ -95,6 +95,23 @@ Extracts all links from posts.
95
95
 
96
96
  `ayadn -was -e ericd`
97
97
 
98
+ ### FORCE
99
+
100
+ Force view blacklisted/muted/blocked user's posts with `-f` option.
101
+
102
+ `ayadn -gl -f`
103
+
104
+ `ayadn -gl -s -f`
105
+
106
+ Differences will occur due to ADN policy:
107
+
108
+ - Global stream: temporarily disables you user token (so your muted/blocked preferences don't apply), the NiceRank filter, and the Blacklist databases
109
+
110
+ - User's posts and Post infos: temporarily disables you user token and the Blacklist databases
111
+
112
+ - Other streams, search, tags: temporarily disables the Blacklist databases
113
+
114
+
98
115
  # GLOBAL
99
116
 
100
117
  Display the 'Global stream'.
data/doc/06-post.md CHANGED
@@ -94,16 +94,51 @@ If you've already created an [alias](#alias) for the channel, you can post to it
94
94
 
95
95
  You can embed one or several pictures in a post (with `post`, `write`, `reply` and `pm`).
96
96
 
97
- Just add the `-e` (or `--embed`) option **at the end** of the command line, followed by one or several file paths separated by spaces.
97
+ Just add the `-E` (or `--embed`) option **at the end** of the command line, followed by one or several file paths separated by spaces.
98
98
 
99
99
  Accepted file formats are `jpg`, `png` and `gif`.
100
100
 
101
101
  Examples:
102
102
 
103
103
  ```
104
- ayadn -P Meet my cat -e lolcat.jpg
105
- ayadn -P "@ericd Hey, meet my pets" -e ~/lolcat.jpg ./doge.jpeg
106
- ayadn -W -e ~/lolcat.png
107
- ayadn -R 23362460 -e "Desktop/dancing lolcat.gif"
108
- ayadn pm @ericd -e /users/dad/lol\'cat.JPG /users/mom/my\ doge.PNG
104
+ ayadn -P Meet my cat -E lolcat.jpg
105
+ ayadn -P "@ericd Hey, meet my pets" -E ~/lolcat.jpg ./doge.jpeg
106
+ ayadn -W -E ~/lolcat.png
107
+ ayadn -R 23362460 -E "Desktop/dancing lolcat.gif"
108
+ ayadn pm @ericd -E /users/dad/lol\'cat.JPG /users/mom/my\ doge.PNG
109
109
  ```
110
+
111
+ # EMBED VIDEOS
112
+
113
+ You can embed a video hosted online in a post. Currently works with Youtube and Vimeo only.
114
+
115
+ Add the `-Y` option for Youtube or `-V` for Vimeo **at the end** of the command line, followed by the video URL.
116
+
117
+ Examples:
118
+
119
+ ```
120
+ ayadn -P wave function -Y https://www.youtube.com/watch?v=Ei8CFin00PY
121
+ ayadn -P Elixir -V http://vimeo.com/103927232
122
+ ayadn -W -Y https://www.youtube.com/watch?v=Ei8CFin00PY
123
+ ayadn -R 23362460 -Y https://www.youtube.com/watch?v=Ei8CFin00PY
124
+ ayadn pm @ericd -Y https://www.youtube.com/watch?v=Ei8CFin00PY
125
+ ```
126
+
127
+ Unfortunately, very few App.net clients treat video embedding properly. So I would advise to include the video URL in the text body anyway, for better compatibility.
128
+
129
+ # EMBED MOVIE POSTER
130
+
131
+ You can embed a movie poster in a normal post with option `-M`.
132
+
133
+ This is compatible with other options, eg embedding other images.
134
+
135
+ Warning: contrary to the `movie` command, this option doesn't check with the user if the movie is valid. The poster is retrieved from IMDb and is automatically embedded in the post.
136
+
137
+ Examples:
138
+
139
+ ```
140
+ ayadn -P "I'll be back" -M terminator
141
+ ayadn -W -M truman show -E ~/Pics/my_face.jpg
142
+ ayadn -R 23362460 -M the dark knight
143
+ ```
144
+
data/lib/ayadn/action.rb CHANGED
@@ -19,51 +19,16 @@ module Ayadn
19
19
  at_exit { Databases.close_all }
20
20
  end
21
21
 
22
- def unified(options)
23
- begin
24
- @stream.unified(options)
25
- rescue => e
26
- Errors.global_error({error: e, caller: caller, data: [options]})
27
- end
28
- end
29
-
30
- def checkins(options)
31
- begin
32
- @stream.checkins(options)
33
- rescue => e
34
- Errors.global_error({error: e, caller: caller, data: [options]})
35
- end
36
- end
37
-
38
- def global(settings)
39
- begin
40
- @stream.global(settings)
41
- rescue => e
42
- Errors.global_error({error: e, caller: caller, data: [settings]})
43
- end
44
- end
45
-
46
- def trending(options)
47
- begin
48
- @stream.trending(options)
49
- rescue => e
50
- Errors.global_error({error: e, caller: caller, data: [options]})
51
- end
52
- end
53
-
54
- def photos(options)
55
- begin
56
- @stream.photos(options)
57
- rescue => e
58
- Errors.global_error({error: e, caller: caller, data: [options]})
59
- end
60
- end
61
-
62
- def conversations(options)
63
- begin
64
- @stream.conversations(options)
65
- rescue => e
66
- Errors.global_error({error: e, caller: caller, data: [options]})
22
+ def method_missing(meth, options)
23
+ case meth.to_s
24
+ when 'unified', 'checkins', 'global', 'trending', 'photos', 'conversations', 'interactions'
25
+ begin
26
+ @stream.send(meth.to_sym, options)
27
+ rescue => e
28
+ Errors.global_error({error: e, caller: caller, data: [meth, options]})
29
+ end
30
+ else
31
+ super
67
32
  end
68
33
  end
69
34
 
@@ -83,14 +48,6 @@ module Ayadn
83
48
  end
84
49
  end
85
50
 
86
- def interactions(options)
87
- begin
88
- @stream.interactions(options)
89
- rescue => e
90
- Errors.global_error({error: e, caller: caller, data: [options]})
91
- end
92
- end
93
-
94
51
  def whatstarred(username, options)
95
52
  begin
96
53
  @stream.whatstarred(username, options)
@@ -381,6 +338,7 @@ module Ayadn
381
338
 
382
339
  def postinfo(post_id, options)
383
340
  begin
341
+ Settings.options[:force] = true if options[:force]
384
342
  Check.bad_post_id(post_id)
385
343
  @view.downloading(options)
386
344
  if options[:raw]
@@ -501,19 +459,13 @@ module Ayadn
501
459
  begin
502
460
  writer = Post.new
503
461
  @view.clear_screen
504
- if options['embed']
505
- embed = options['embed']
506
- text = args.join(" ")
507
- puts Status.uploading(embed)
508
- resp = writer.send_embedded(text, FileOps.make_paths(embed))
509
- else
510
- puts Status.posting
511
- resp = writer.post(args)
462
+ puts Status.posting
463
+ if options[:poster] # Returns the same options hash + poster embed
464
+ settings = options.dup
465
+ options = NowWatching.new.get_poster(settings[:poster], settings)
512
466
  end
513
- FileOps.save_post(resp) if Settings.options[:backup][:auto_save_sent_posts]
514
- @view.clear_screen
515
- puts Status.yourpost
516
- @view.show_posted(resp)
467
+ resp = writer.post({options: options, text: args.join(" ")})
468
+ save_and_view(resp)
517
469
  rescue => e
518
470
  Errors.global_error({error: e, caller: caller, data: [args, options]})
519
471
  end
@@ -521,26 +473,20 @@ module Ayadn
521
473
 
522
474
  def write(options)
523
475
  begin
524
- files = FileOps.make_paths(options['embed']) if options['embed']
525
476
  writer = Post.new
526
477
  puts Status.writing
527
478
  puts Status.post
528
479
  lines_array = writer.compose
529
480
  writer.check_post_length(lines_array)
530
481
  text = lines_array.join("\n")
531
- if options['embed']
532
- @view.clear_screen
533
- puts Status.uploading(options['embed'])
534
- resp = writer.send_embedded(text, files)
535
- else
536
- resp = writer.send_post(text)
537
- end
538
482
  @view.clear_screen
539
483
  puts Status.posting
540
- FileOps.save_post(resp) if Settings.options[:backup][:auto_save_sent_posts]
541
- @view.clear_screen
542
- puts Status.yourpost
543
- @view.show_posted(resp)
484
+ if options[:poster]
485
+ settings = options.dup
486
+ options = NowWatching.new.get_poster(settings[:poster], settings)
487
+ end
488
+ resp = writer.post({options: options, text: text})
489
+ save_and_view(resp)
544
490
  rescue => e
545
491
  Errors.global_error({error: e, caller: caller, data: [text, options]})
546
492
  end
@@ -548,23 +494,21 @@ module Ayadn
548
494
 
549
495
  def pmess(username, options = {})
550
496
  begin
551
- files = FileOps.make_paths(options['embed']) if options['embed']
552
497
  Check.no_username(username)
553
498
  username = [@workers.add_arobase(username)]
554
- messenger = Post.new
499
+ writer = Post.new
555
500
  puts Status.message_from(username)
556
501
  puts Status.message
557
- lines_array = messenger.compose
558
- messenger.check_message_length(lines_array)
502
+ lines_array = writer.compose
503
+ writer.check_message_length(lines_array)
559
504
  text = lines_array.join("\n")
560
505
  @view.clear_screen
561
- if options['embed']
562
- puts Status.uploading(options['embed'])
563
- resp = messenger.send_pm_embedded(username, text, files)
564
- else
565
- puts Status.posting
566
- resp = messenger.send_pm(username, text)
506
+ puts Status.posting
507
+ if options[:poster]
508
+ settings = options.dup
509
+ options = NowWatching.new.get_poster(settings[:poster], settings)
567
510
  end
511
+ resp = writer.pm({options: options, text: text, username: username})
568
512
  FileOps.save_message(resp) if Settings.options[:backup][:auto_save_sent_messages]
569
513
  @view.clear_screen
570
514
  puts Status.yourmessage(username[0])
@@ -574,29 +518,8 @@ module Ayadn
574
518
  end
575
519
  end
576
520
 
577
- def send_to_channel(channel_id)
578
- begin
579
- channel_id = @workers.get_channel_id_from_alias(channel_id)
580
- messenger = Post.new
581
- puts Status.writing
582
- puts Status.post
583
- lines_array = messenger.compose
584
- messenger.check_message_length(lines_array)
585
- @view.clear_screen
586
- puts Status.posting
587
- resp = messenger.send_message(channel_id, lines_array.join("\n"))
588
- FileOps.save_message(resp) if Settings.options[:backup][:auto_save_sent_messages]
589
- @view.clear_screen
590
- puts Status.yourpost
591
- @view.show_posted(resp)
592
- rescue => e
593
- Errors.global_error({error: e, caller: caller, data: [channel_id]})
594
- end
595
- end
596
-
597
521
  def reply(post_id, options = {})
598
522
  begin
599
- files = FileOps.make_paths(options['embed']) if options['embed']
600
523
  post_id = @workers.get_real_post_id(post_id)
601
524
  puts Status.replying_to(post_id)
602
525
  replied_to = @api.get_details(post_id)
@@ -608,36 +531,49 @@ module Ayadn
608
531
  Check.no_post(replied_to, post_id)
609
532
  end
610
533
  end
611
- poster = Post.new
534
+ # ----
535
+ writer = Post.new
612
536
  puts Status.writing
613
537
  puts Status.reply
614
- lines_array = poster.compose
615
- poster.check_post_length(lines_array)
538
+ lines_array = writer.compose
539
+ writer.check_post_length(lines_array)
616
540
  @view.clear_screen
617
- reply = poster.reply(lines_array.join("\n"), @workers.build_posts([replied_to['data']]))
618
- if options['embed']
619
- puts Status.uploading(options['embed'])
620
- resp = poster.send_reply_embedded(reply, post_id, files)
621
- else
622
- puts Status.posting
623
- resp = poster.send_reply(reply, post_id)
541
+ text = lines_array.join("\n")
542
+ replied_to = @workers.build_posts([replied_to['data']])
543
+ if options[:poster]
544
+ settings = options.dup
545
+ options = NowWatching.new.get_poster(settings[:poster], settings)
624
546
  end
625
- FileOps.save_post(resp) if Settings.options[:backup][:auto_save_sent_posts]
626
- @view.clear_screen
627
- puts Status.done
628
-
547
+ resp = writer.reply({options: options, text: text, id: post_id, reply_to: replied_to})
548
+ # ----
629
549
  options = options.dup
630
550
  unless resp['data']['reply_to'].nil?
631
551
  options[:reply_to] = resp['data']['reply_to'].to_i
632
552
  end
633
553
  options[:post_id] = resp['data']['id'].to_i
634
-
635
554
  @view.render(@api.get_convo(post_id), options)
636
555
  rescue => e
637
556
  Errors.global_error({error: e, caller: caller, data: [post_id, options]})
638
557
  end
639
558
  end
640
559
 
560
+ def send_to_channel(channel_id)
561
+ begin
562
+ channel_id = @workers.get_channel_id_from_alias(channel_id)
563
+ writer = Post.new
564
+ puts Status.writing
565
+ puts Status.post
566
+ lines_array = writer.compose
567
+ writer.check_message_length(lines_array)
568
+ @view.clear_screen
569
+ puts Status.posting
570
+ resp = writer.message({id: channel_id, text: lines_array.join("\n")})
571
+ save_and_view(resp)
572
+ rescue => e
573
+ Errors.global_error({error: e, caller: caller, data: [channel_id]})
574
+ end
575
+ end
576
+
641
577
  def nowplaying(options = {})
642
578
  np = NowPlaying.new(@api, @view, @workers)
643
579
  options['lastfm'] ? np.lastfm(options) : np.itunes(options)
@@ -693,5 +629,14 @@ module Ayadn
693
629
  end
694
630
  end
695
631
 
632
+ private
633
+
634
+ def save_and_view(resp)
635
+ FileOps.save_post(resp) if Settings.options[:backup][:auto_save_sent_posts]
636
+ @view.clear_screen
637
+ puts Status.yourpost
638
+ @view.show_posted(resp)
639
+ end
640
+
696
641
  end
697
642
  end
@@ -0,0 +1,191 @@
1
+ # encoding: utf-8
2
+
3
+ module Ayadn
4
+
5
+ class Annotations
6
+
7
+ attr_accessor :content
8
+
9
+ def initialize(dic)
10
+ dic[:options] = {} if dic[:options].nil?
11
+ @content = base()
12
+ @content += files(dic) if dic[:options][:embed]
13
+ @content += youtube(dic) if dic[:options][:youtube]
14
+ @content += vimeo(dic) if dic[:options][:vimeo]
15
+ @content += nowplaying(dic) if dic[:options][:nowplaying]
16
+ @content += movie(dic) if dic[:options][:movie]
17
+ @content += tvshow(dic) if dic[:options][:tvshow]
18
+ end
19
+
20
+ def base
21
+ [
22
+ {
23
+ "type" => "com.ayadn.user",
24
+ "value" => {
25
+ "+net.app.core.user" => {
26
+ "user_id" => "#{Settings.config[:identity][:handle]}",
27
+ "format" => "basic"
28
+ }
29
+ }
30
+ },
31
+ {
32
+ "type" => "com.ayadn.client",
33
+ "value" => {
34
+ "url" => "http://ayadn-app.net",
35
+ "author" => {
36
+ "name" => "Eric Dejonckheere",
37
+ "username" => "ericd",
38
+ "id" => "69904",
39
+ "email" => "eric@aya.io"
40
+ },
41
+ "version" => "#{Settings.config[:version]}"
42
+ }
43
+ }
44
+ ]
45
+ end
46
+
47
+ def files(dic)
48
+ files = FileOps.make_paths(dic[:options][:embed])
49
+ data = FileOps.upload_files(files)
50
+ data.map do |obj|
51
+ {
52
+ "type" => "net.app.core.oembed",
53
+ "value" => {
54
+ "+net.app.core.file" => {
55
+ "file_id" => obj['data']['id'],
56
+ "file_token" => obj['data']['file_token'],
57
+ "format" => "oembed"
58
+ }
59
+ }
60
+ }
61
+ end
62
+ end
63
+
64
+ def youtube(dic)
65
+ dic['link'] = dic[:options][:youtube][0]
66
+ req_url = "http://www.youtube.com/oembed?url=#{dic['link']}&format=json"
67
+ dic.merge!(JSON.parse(CNX.download(req_url)))
68
+ [{
69
+ "type" => "net.app.core.oembed",
70
+ "value" => {
71
+ "version" => "1.0",
72
+ "type" => "video",
73
+ "provider_name" => "YouTube",
74
+ "provider_url" => "http://youtube.com/",
75
+ "width" => dic['width'],
76
+ "height" => dic['height'],
77
+ "title" => dic['title'],
78
+ "author_name" => dic['author_name'],
79
+ "author_url" => dic['author_url'],
80
+ "embeddable_url" => dic['link'],
81
+ "html" => dic['html'],
82
+ "thumbnail_url" => dic['thumbnail_url'],
83
+ "thumbnail_height" => dic['thumbnail_height'],
84
+ "thumbnail_width" => dic['thumbnail_width']
85
+ }
86
+ },
87
+ {
88
+ "type" => "com.ayadn.youtube",
89
+ "value" => {
90
+ "title" => dic['title'],
91
+ "link" => dic['link']
92
+ }
93
+ }]
94
+ end
95
+
96
+ def vimeo(dic)
97
+ dic[:link] = dic[:options][:vimeo][0]
98
+ req_url = "http://vimeo.com/api/oembed.json?url=#{dic[:link]}"
99
+ dic.merge!(JSON.parse(CNX.download(req_url)))
100
+ [{
101
+ "type" => "net.app.core.oembed",
102
+ "value" => {
103
+ "version" => "1.0",
104
+ "type" => "video",
105
+ "provider_name" => "Vimeo",
106
+ "provider_url" => "http://vimeo.com/",
107
+ "width" => dic['width'],
108
+ "height" => dic['height'],
109
+ "title" => dic['title'],
110
+ "author_name" => dic['author_name'],
111
+ "author_url" => dic['author_url'],
112
+ "embeddable_url" => dic[:link],
113
+ "html" => dic['html'],
114
+ "thumbnail_url" => dic['thumbnail_url'],
115
+ "thumbnail_height" => dic['thumbnail_height'],
116
+ "thumbnail_width" => dic['thumbnail_width']
117
+ }
118
+ },
119
+ {
120
+ "type" => "com.ayadn.vimeo",
121
+ "value" => {
122
+ "title" => dic['title'],
123
+ "link" => dic[:link]
124
+ }
125
+ }]
126
+ end
127
+
128
+ def movie(dic)
129
+ [{
130
+ "type" => "com.ayadn.movie",
131
+ "value" => {
132
+ "title" => dic[:title],
133
+ "source" => dic[:source]
134
+ }
135
+ }]
136
+ end
137
+
138
+ def tvshow(dic)
139
+ [{
140
+ "type" => "com.ayadn.tvshow",
141
+ "value" => {
142
+ "title" => dic[:title],
143
+ "source" => dic[:source]
144
+ }
145
+ }]
146
+ end
147
+
148
+ def nowplaying_silent(dic)
149
+ [{
150
+ "type" => "com.ayadn.nowplaying",
151
+ "value" => {
152
+ "status" => "no-url",
153
+ "source" => dic[:source]
154
+ }
155
+ }]
156
+ end
157
+
158
+ def nowplaying(dic)
159
+ return nowplaying_silent(dic) if dic[:options][:no_url]
160
+ [{
161
+ "type" => "com.ayadn.nowplaying",
162
+ "value" => {
163
+ "title" => dic[:title],
164
+ "artist" => dic[:artist],
165
+ "artwork" => dic[:artwork],
166
+ "link" => dic[:link],
167
+ "source" => dic[:source]
168
+ }
169
+ },
170
+ {
171
+ "type" => "net.app.core.oembed",
172
+ "value" => {
173
+ "version" => "1.0",
174
+ "type" => "photo",
175
+ "width" => dic[:width],
176
+ "height" => dic[:height],
177
+ "title" => dic[:title],
178
+ "url" => dic[:artwork],
179
+ "embeddable_url" => dic[:artwork],
180
+ "provider_url" => "https://itunes.apple.com",
181
+ "provider_name" => "iTunes",
182
+ "thumbnail_url" => dic[:artwork_thumb],
183
+ "thumbnail_width" => dic[:width_thumb],
184
+ "thumbnail_height" => dic[:height_thumb]
185
+ }
186
+ }]
187
+ end
188
+
189
+ end
190
+
191
+ end