ayadn 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/CHANGELOG.md +232 -0
- data/CONTRIBUTORS.md +5 -0
- data/LICENSE.md +14 -0
- data/README.md +489 -0
- data/bin/ayadn +358 -0
- data/config.yml +35 -0
- data/lib/ayadn/adn_files.rb +84 -0
- data/lib/ayadn/api.rb +302 -0
- data/lib/ayadn/authorize.rb +29 -0
- data/lib/ayadn/client-http.rb +226 -0
- data/lib/ayadn/colors.rb +62 -0
- data/lib/ayadn/debug.rb +36 -0
- data/lib/ayadn/endpoints.rb +154 -0
- data/lib/ayadn/extend.rb +23 -0
- data/lib/ayadn/files.rb +184 -0
- data/lib/ayadn/get-api.rb +43 -0
- data/lib/ayadn/help.rb +149 -0
- data/lib/ayadn/list.rb +89 -0
- data/lib/ayadn/main.rb +536 -0
- data/lib/ayadn/pinboard.rb +37 -0
- data/lib/ayadn/post.rb +212 -0
- data/lib/ayadn/requires.rb +12 -0
- data/lib/ayadn/skip.rb +27 -0
- data/lib/ayadn/status.rb +166 -0
- data/lib/ayadn/tools.rb +204 -0
- data/lib/ayadn/user-stream.rb +91 -0
- data/lib/ayadn/view-channels.rb +119 -0
- data/lib/ayadn/view-interactions.rb +57 -0
- data/lib/ayadn/view-object.rb +193 -0
- data/lib/ayadn/view.rb +270 -0
- data/lib/ayadn.rb +24 -0
- data/lib/experiments.rb +109 -0
- metadata +110 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
require 'net/http'
|
4
|
+
require 'openssl'
|
5
|
+
|
6
|
+
class AyaDN
|
7
|
+
|
8
|
+
# EXPERIMENT!!!
|
9
|
+
|
10
|
+
def ayadn_userstream
|
11
|
+
# first create with curl -i -H 'Authorization: BEARER xxx' "https://stream-channel.app.net/stream/user?auto_delete=1&include_annotations=1&include_html=0"
|
12
|
+
# it stays open and returns a stream_id in the headers
|
13
|
+
# TODO: replace curl with a good connection system: HTTP or Rest-Client
|
14
|
+
|
15
|
+
puts "1. Create user stream\n".cyan
|
16
|
+
puts "2. Connect to user stream\n".cyan
|
17
|
+
puts "\n\nYour choice? \n\n".brown
|
18
|
+
case STDIN.getch
|
19
|
+
when "1"
|
20
|
+
command = "sleep 1; curl -i -H 'Authorization: BEARER #{@token}' 'https://stream-channel.app.net/stream/user?auto_delete=1&include_annotations=1&include_html=0'"
|
21
|
+
pid = Process.spawn(command)
|
22
|
+
Process.detach(pid)
|
23
|
+
exit
|
24
|
+
when "2"
|
25
|
+
puts "Paste stream id: "
|
26
|
+
stream_id = STDIN.gets.chomp
|
27
|
+
else
|
28
|
+
puts $status.errorSyntax
|
29
|
+
end
|
30
|
+
last_page_id = nil
|
31
|
+
start = Time.now
|
32
|
+
$files.makedir($tools.ayadn_configuration[:data_path] + "/.temp/")
|
33
|
+
f = File.new($tools.ayadn_configuration[:data_path] + "/.temp/#{stream_id}", "w")
|
34
|
+
f.puts(stream_id)
|
35
|
+
f.close
|
36
|
+
@url = "https://alpha-api.app.net/stream/0/posts/stream/global?connection_id=#{stream_id}&since_id=#{last_page_id}&include_deleted=0"
|
37
|
+
uri = URI.parse(@url)
|
38
|
+
https = Net::HTTP.new(uri.host,uri.port)
|
39
|
+
https.use_ssl = true
|
40
|
+
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
41
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
42
|
+
request["Authorization"] = "Bearer #{@token}"
|
43
|
+
request["Content-Type"] = "application/json"
|
44
|
+
response = https.request(request)
|
45
|
+
@hash = JSON.parse(response.body)
|
46
|
+
stream, last_page_id = completeStream
|
47
|
+
displayScrollStream(stream)
|
48
|
+
number_of_connections = 1
|
49
|
+
total_size = 0
|
50
|
+
loop do
|
51
|
+
begin
|
52
|
+
@url = "https://alpha-api.app.net/stream/0/posts/stream/global?connection_id=#{stream_id}&since_id=#{last_page_id}&include_deleted=0"
|
53
|
+
uri = URI.parse(@url)
|
54
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
55
|
+
request["Authorization"] = "Bearer #{@token}"
|
56
|
+
request["Content-Type"] = "application/json"
|
57
|
+
before_request_id = last_page_id
|
58
|
+
response = https.request(request)
|
59
|
+
chunk_size = response['Content-Length']
|
60
|
+
@hash = JSON.parse(response.body)
|
61
|
+
stream, last_page_id = completeStream
|
62
|
+
displayScrollStream(stream)
|
63
|
+
last_page_id = before_request_id if last_page_id == nil
|
64
|
+
number_of_connections += 1
|
65
|
+
# puts "\nData chunks: \t#{number_of_connections}".magenta
|
66
|
+
# puts "Chunk size: \t#{chunk_size.to_i.to_filesize}".magenta
|
67
|
+
total_size += chunk_size.to_i
|
68
|
+
# puts "Total size: \t#{total_size.to_filesize}".magenta
|
69
|
+
# finish = Time.now
|
70
|
+
# elapsed = finish.to_f - start.to_f
|
71
|
+
# mins, secs = elapsed.divmod 60.0
|
72
|
+
# puts "Total time:\t".magenta + "%3d:%04.2f".magenta%[mins.to_i, secs]
|
73
|
+
# req_sec = number_of_connections.to_f/secs
|
74
|
+
# puts "Req/sec: \t#{req_sec.round(2)}".magenta
|
75
|
+
rescue Exception => e
|
76
|
+
puts "\n\n"
|
77
|
+
puts e.inspect
|
78
|
+
finish = Time.now
|
79
|
+
elapsed = finish.to_f - start.to_f
|
80
|
+
mins, secs = elapsed.divmod 60.0
|
81
|
+
puts "\n\nData chunks: #{number_of_connections}\n"
|
82
|
+
puts "Total size: #{total_size.to_filesize}"
|
83
|
+
puts "Elapsed time (min:secs.msecs): "
|
84
|
+
puts("%3d:%04.2f"%[mins.to_i, secs])
|
85
|
+
req_sec = number_of_connections.to_f/secs.to_f
|
86
|
+
puts "Req/sec: #{req_sec.round(2)}\n\n"
|
87
|
+
exit
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
class AyaDN
|
4
|
+
class View
|
5
|
+
def build_pm_channels_infos
|
6
|
+
#meta = @hash['meta']
|
7
|
+
#unread_messages = meta['unread_counts']['net.app.core.pm']
|
8
|
+
the_channels = ""
|
9
|
+
channels_list = []
|
10
|
+
puts "\nGetting users infos, please wait a few seconds... (could take a while the first time if you have a lot of channels activated)\n".cyan
|
11
|
+
@hash['data'].each do |item|
|
12
|
+
channel_id = item['id']
|
13
|
+
channel_type = item['type']
|
14
|
+
if channel_type == "net.app.core.pm"
|
15
|
+
channels_list.push(channel_id)
|
16
|
+
total_messages = item['counts']['messages']
|
17
|
+
#owner = "@" + item['owner']['username']
|
18
|
+
#readers = item['readers']['user_ids']
|
19
|
+
#you_write = item['writers']['you']
|
20
|
+
#you_read = item['readers']['you']
|
21
|
+
the_writers = []
|
22
|
+
item['writers']['user_ids'].each do |writer|
|
23
|
+
if writer != nil
|
24
|
+
known_user = $files.users_read(writer)
|
25
|
+
if known_user
|
26
|
+
handle = "@" + known_user
|
27
|
+
puts "\n#{writer} already known: #{handle}. Skipping the username search".green
|
28
|
+
else
|
29
|
+
puts "\nFetching username of user ##{writer}".green
|
30
|
+
user = AyaDN::API.new(@token).getUserInfos(writer)
|
31
|
+
username = user['data']['username']
|
32
|
+
handle = "@" + username
|
33
|
+
$files.users_write(writer, username)
|
34
|
+
end
|
35
|
+
$files.save_channel_id(channel_id, handle)
|
36
|
+
the_writers.push(handle)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
the_channels << "\nChannel ID: ".cyan + "#{channel_id}\n".brown
|
40
|
+
#the_channels << "Creator: ".cyan + owner.magenta + "\n"
|
41
|
+
#the_channels << "Channels type: ".cyan + "#{channel_type}\n".brown
|
42
|
+
the_channels << "Interlocutor(s): ".cyan + the_writers.join(", ").magenta + "\n"
|
43
|
+
the_channels << "Messages: ".cyan + total_messages.to_s.green + "\n"
|
44
|
+
if item['recent_message']
|
45
|
+
if item['recent_message']['text']
|
46
|
+
message_date = objectDate(item['recent_message']).join(" ")
|
47
|
+
the_channels << "Last message by @#{item['recent_message']['user']['username']} (#{message_date}): \n".cyan + item['recent_message']['text'] + "\n"
|
48
|
+
# id, text, username, message_date
|
49
|
+
params = {
|
50
|
+
id: channel_id,
|
51
|
+
text: item['recent_message']['text'],
|
52
|
+
username: item['recent_message']['user']['username'],
|
53
|
+
message_date: message_date
|
54
|
+
}
|
55
|
+
$files.save_channel_message(params)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
the_channels << "\n"
|
61
|
+
return the_channels, channels_list
|
62
|
+
end
|
63
|
+
def build_channels_infos
|
64
|
+
the_channels = ""
|
65
|
+
channels_list = []
|
66
|
+
@hash['data'].each do |item|
|
67
|
+
channel_id = item['id']
|
68
|
+
channel_type = item['type']
|
69
|
+
if channel_type != "net.app.core.pm"
|
70
|
+
channels_list.push(channel_id)
|
71
|
+
case channel_type
|
72
|
+
when "net.app.ohai.journal"
|
73
|
+
$files.save_channel_id(channel_id, "Ohai Journal")
|
74
|
+
the_channels << "\nChannel ID: ".cyan + "#{channel_id}\n".brown + " -> " + "your Ohai Journal channel\n".green
|
75
|
+
when "net.paste-app.clips"
|
76
|
+
$files.save_channel_id(channel_id, "Paste-App Clips")
|
77
|
+
the_channels << "\nChannel ID: ".cyan + "#{channel_id}\n".brown + " -> " + "your Paste-App Clips channel\n".green
|
78
|
+
when "net.app.core.broadcast"
|
79
|
+
item['annotations'].each do |anno|
|
80
|
+
if anno['type'] == "net.app.core.broadcast.metadata"
|
81
|
+
broadcast_name = anno['value']['title']
|
82
|
+
$files.save_channel_id(channel_id, "#{broadcast_name} [Broadcast]")
|
83
|
+
the_channels << "\nChannel ID: ".cyan + "#{channel_id}\n".brown + " -> " + "Broadcast channel: #{broadcast_name}\n".green
|
84
|
+
end
|
85
|
+
end
|
86
|
+
when "net.patter-app.room"
|
87
|
+
item['annotations'].each do |anno|
|
88
|
+
if anno['type'] == "net.patter-app.settings"
|
89
|
+
patter_room_name = anno['value']['name']
|
90
|
+
$files.save_channel_id(channel_id, "#{patter_room_name} [Patter-App Room]")
|
91
|
+
the_channels << "\nChannel ID: ".cyan + "#{channel_id}\n".brown + " -> " + "Patter-App Room: #{patter_room_name}\n".green
|
92
|
+
next
|
93
|
+
end
|
94
|
+
end
|
95
|
+
else
|
96
|
+
$files.save_channel_id(channel_id, channel_type)
|
97
|
+
the_channels << "\nChannel ID: ".cyan + "#{channel_id}\n".brown + " -> " + "#{channel_type}\n"
|
98
|
+
end
|
99
|
+
if item['recent_message']
|
100
|
+
if item['recent_message']['text']
|
101
|
+
message_date = objectDate(item['recent_message']).join(" ")
|
102
|
+
the_channels << "Last message by @#{item['recent_message']['user']['username']} (#{message_date}): \n".cyan + item['recent_message']['text'] + "\n"
|
103
|
+
# id, text, username, message_date
|
104
|
+
params = {
|
105
|
+
id: channel_id,
|
106
|
+
text: item['recent_message']['text'],
|
107
|
+
username: item['recent_message']['user']['username'],
|
108
|
+
message_date: message_date
|
109
|
+
}
|
110
|
+
$files.save_channel_message(params)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
the_channels << "\n"
|
116
|
+
return the_channels, channels_list
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
class AyaDN
|
4
|
+
class View
|
5
|
+
def buildInteractions(hash)
|
6
|
+
inter_string = ""
|
7
|
+
hash.each do |item|
|
8
|
+
action = item['action']
|
9
|
+
created_day = item['event_date'][0...10]
|
10
|
+
created_hour = item['event_date'][11...19]
|
11
|
+
objects_names, users_list, post_ids, post_text = [], [], [], [] # not the same as var1 = var2 = []
|
12
|
+
item['objects'].each do |o|
|
13
|
+
case action
|
14
|
+
when "follow", "unfollow", "mute", "unmute"
|
15
|
+
objects_names.push("@" + o['username'])
|
16
|
+
when "star", "unstar", "repost", "unrepost", "reply"
|
17
|
+
post_ids.push(o['id'])
|
18
|
+
#text = o['text']
|
19
|
+
post_info = buildPostInfo(o, false)
|
20
|
+
post_text.push(post_info.chomp("\n\n"))
|
21
|
+
#post_text << text
|
22
|
+
end
|
23
|
+
end
|
24
|
+
item['users'].each do |u|
|
25
|
+
if u != nil
|
26
|
+
users_list.push("@" + u['username'])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
joined_users_list = users_list.join(", ")
|
30
|
+
joined_post_text = post_text.join(" ")
|
31
|
+
inter_string << "-----\n\n".blue
|
32
|
+
inter_string << "Date: ".green + "#{created_day} #{created_hour}\n".cyan
|
33
|
+
case action
|
34
|
+
when "follow", "unfollow"
|
35
|
+
inter_string << "#{joined_users_list} ".green + "#{action}ed ".magenta + "you\n".brown
|
36
|
+
when "mute", "unmute"
|
37
|
+
inter_string << "#{joined_users_list} ".green + "#{action}d ".magenta + "#{objects_names.join(", ")}\n".brown
|
38
|
+
when "repost", "unrepost"
|
39
|
+
inter_string << "#{joined_users_list} ".green + "#{action}ed:\n".magenta
|
40
|
+
inter_string << joined_post_text
|
41
|
+
when "star", "unstar"
|
42
|
+
inter_string << "#{joined_users_list} ".green + "#{action}red:\n".magenta
|
43
|
+
inter_string << joined_post_text
|
44
|
+
when "reply"
|
45
|
+
inter_string << "#{joined_users_list} ".green + "#{action}ed to:\n".magenta
|
46
|
+
inter_string << joined_post_text
|
47
|
+
when "welcome"
|
48
|
+
inter_string << "App.net ".green + "welcomed ".magenta + "you.\n".green
|
49
|
+
else
|
50
|
+
inter_string << "Unknown data.\n".red
|
51
|
+
end
|
52
|
+
inter_string << "\n"
|
53
|
+
end
|
54
|
+
return inter_string
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,193 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
class AyaDN
|
4
|
+
class View
|
5
|
+
def create_content_string(item, annotations, me_mentioned)
|
6
|
+
if item['user']
|
7
|
+
user_name, user_real_name, user_handle = objectNames(item['user']).values_at(:user_name, :user_real_name, :user_handle)
|
8
|
+
else
|
9
|
+
user_name, user_real_name, user_handle = ""
|
10
|
+
end
|
11
|
+
created_day, created_hour = objectDate(item)
|
12
|
+
view_params = {
|
13
|
+
id: item['id'],
|
14
|
+
created_day: created_day,
|
15
|
+
created_hour: created_hour,
|
16
|
+
user_name: user_name,
|
17
|
+
user_handle: user_handle,
|
18
|
+
user_real_name: user_real_name,
|
19
|
+
text: coloredText(item),
|
20
|
+
links: objectLinks(item),
|
21
|
+
annotations: annotations,
|
22
|
+
me_mentioned: me_mentioned,
|
23
|
+
num_replies: item['num_replies'],
|
24
|
+
reply_to: item['reply_to']
|
25
|
+
}
|
26
|
+
if item['repost_of'] != nil
|
27
|
+
view_params.merge!({repost_of: item['repost_of'], num_reposts: item['repost_of']['num_reposts']})
|
28
|
+
end
|
29
|
+
object_view(view_params)
|
30
|
+
end
|
31
|
+
def skip_hashtags(item, saved_tags)
|
32
|
+
skipped_hashtags_encountered = false
|
33
|
+
for post_tag in item['entities']['hashtags'] do
|
34
|
+
case post_tag['name']
|
35
|
+
when *saved_tags
|
36
|
+
skipped_hashtags_encountered = true
|
37
|
+
next
|
38
|
+
end
|
39
|
+
end
|
40
|
+
return skipped_hashtags_encountered
|
41
|
+
end
|
42
|
+
def coloredText(item)
|
43
|
+
obj_text = item['text']
|
44
|
+
obj_text != nil ? (colored_post = $tools.colorize(obj_text)) : (colored_post = "\n--Post deleted--".red)
|
45
|
+
end
|
46
|
+
def objectDate(item)
|
47
|
+
created_at = item['created_at']
|
48
|
+
return created_at[0...10], created_at[11...19]
|
49
|
+
end
|
50
|
+
def objectLinks(item)
|
51
|
+
links = item['entities']['links']
|
52
|
+
links_string = ""
|
53
|
+
if !links.empty?
|
54
|
+
links_string << "\n" if item['annotations'] == nil
|
55
|
+
for link in links do
|
56
|
+
links_string << "Link: ".cyan + link['url'].brown + "\n"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
return links_string
|
60
|
+
end
|
61
|
+
def objectSource(item)
|
62
|
+
{name: item['source']['name'], link: item['source']['link']}
|
63
|
+
end
|
64
|
+
def objectNames(item)
|
65
|
+
user_id = item['id']
|
66
|
+
user_name = item['username']
|
67
|
+
$files.users_write(user_id, user_name) if $files.users_read(user_id) == nil
|
68
|
+
user_handle = "@" + user_name
|
69
|
+
{user_name: user_name, user_real_name: item['name'], user_handle: user_handle}
|
70
|
+
end
|
71
|
+
def checkins_annotations(item)
|
72
|
+
anno_string = ""
|
73
|
+
annotations_list = item['annotations']
|
74
|
+
xxx = 0
|
75
|
+
if annotations_list != nil
|
76
|
+
annotations_list.each do
|
77
|
+
annotation_type = annotations_list[xxx]['type']
|
78
|
+
annotation_value = annotations_list[xxx]['value']
|
79
|
+
if annotation_type == "net.app.core.checkin" or annotation_type == "net.app.ohai.location"
|
80
|
+
checkins_name = annotation_value['name']
|
81
|
+
if checkins_name.nil?
|
82
|
+
checkins_name = ""
|
83
|
+
end
|
84
|
+
checkins_address = annotation_value['address']
|
85
|
+
checkins_locality = annotation_value['locality']
|
86
|
+
checkins_region = annotation_value['region']
|
87
|
+
checkins_postcode = annotation_value['postcode']
|
88
|
+
checkins_country_code = annotation_value['country_code']
|
89
|
+
anno_string << "\n" + ("." * (checkins_name.length + 6))
|
90
|
+
anno_string << ("\nName: ".cyan + checkins_name.upcase.reddish)
|
91
|
+
anno_string << ("\nAddress: ".cyan + checkins_address.green) unless checkins_address.nil?
|
92
|
+
anno_string << ("\nLocality: ".cyan + checkins_locality.green) unless checkins_locality.nil?
|
93
|
+
anno_string << (" (#{checkins_postcode})".green) unless checkins_postcode.nil?
|
94
|
+
anno_string << ("\nState/Region: ".cyan + checkins_region.green) unless checkins_region.nil?
|
95
|
+
anno_string << (" (#{checkins_country_code})".upcase.green) unless checkins_country_code.nil?
|
96
|
+
unless @source_name_and_link[:name].nil? or $tools.config['timeline']['show_client']
|
97
|
+
anno_string << "\nPosted with: ".cyan + "#{@source_name_and_link[:name]} [#{@source_name_and_link[:link]}]".green + " "
|
98
|
+
end
|
99
|
+
#anno_string += "\n"
|
100
|
+
end
|
101
|
+
if annotation_type == "net.app.core.oembed"
|
102
|
+
@same_link = false
|
103
|
+
photo_link = annotation_value['embeddable_url']
|
104
|
+
if photo_link != nil
|
105
|
+
photo_link_parsed = URI.parse(photo_link)
|
106
|
+
photo_link_to_compare = photo_link_parsed.host + photo_link_parsed.path
|
107
|
+
item['entities']['links'].each do |link|
|
108
|
+
in_entities_parsed = URI.parse(link['url'])
|
109
|
+
in_entities_to_compare = in_entities_parsed.host + in_entities_parsed.path
|
110
|
+
@same_link = true if in_entities_to_compare == photo_link_to_compare
|
111
|
+
end
|
112
|
+
anno_string << ("\nLink: ".cyan + photo_link.brown) if @same_link == false
|
113
|
+
end
|
114
|
+
end
|
115
|
+
xxx += 1
|
116
|
+
end
|
117
|
+
return anno_string
|
118
|
+
end
|
119
|
+
end
|
120
|
+
def object_view(params)
|
121
|
+
if params[:me_mentioned]
|
122
|
+
obj_view = "\n" + params[:id].to_s.red.reverse_color.ljust(14)
|
123
|
+
else
|
124
|
+
if params[:user_name] == $tools.config['identity']['prefix']
|
125
|
+
obj_view = "\n" + params[:id].to_s.green.reverse_color.ljust(14)
|
126
|
+
else
|
127
|
+
obj_view = "\n" + params[:id].to_s.cyan.ljust(14)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
obj_view << ' '
|
131
|
+
obj_view << params[:user_handle].green if params[:user_handle]
|
132
|
+
obj_view << ' '
|
133
|
+
obj_view << "[#{params[:user_real_name]}]".magenta if params[:user_real_name]
|
134
|
+
obj_view << ' '
|
135
|
+
obj_view << params[:created_day].cyan + ' ' + params[:created_hour].cyan
|
136
|
+
obj_view << ' '
|
137
|
+
obj_view << "[#{@source_name_and_link[:name]}]".cyan if $tools.config['timeline']['show_client']
|
138
|
+
if params[:repost_of] && $tools.config['timeline']['show_reposters']
|
139
|
+
obj_view << " [x#{params[:num_reposts]}]".blue
|
140
|
+
end
|
141
|
+
if $tools.config['timeline']['show_symbols']
|
142
|
+
obj_view << " <".blue if params[:reply_to] != nil
|
143
|
+
obj_view << " >".blue if params[:num_replies] > 0
|
144
|
+
end
|
145
|
+
obj_view << "\n"
|
146
|
+
obj_view << params[:text]
|
147
|
+
obj_view << (params[:annotations] + "\n") if params[:annotations] != nil
|
148
|
+
obj_view << params[:links] + "\n"
|
149
|
+
obj_view
|
150
|
+
end
|
151
|
+
def file_view(params)
|
152
|
+
file_elements = "\nName: ".cyan + params[:name].green
|
153
|
+
file_elements << "\nKind: ".cyan + params[:kind].pink
|
154
|
+
file_elements << "\nSize: ".cyan + params[:file_size_converted].reddish unless params[:file_size] == nil
|
155
|
+
file_elements << "\nDate: ".cyan + params[:created_day].green + " " + params[:created_hour].green
|
156
|
+
file_elements << "\nSource: ".cyan + params[:source_name].brown + " - #{params[:source_link]}".brown
|
157
|
+
end
|
158
|
+
def filesDetails(item)
|
159
|
+
created_day, created_hour = objectDate(item)
|
160
|
+
file_size = item['size']
|
161
|
+
file_size_converted = file_size.to_filesize unless file_size == nil
|
162
|
+
{
|
163
|
+
name: item['name'],
|
164
|
+
file_token: item['file_token'],
|
165
|
+
source_name: item['source']['name'],
|
166
|
+
source_link: item['source']['link'],
|
167
|
+
kind: item['kind'],
|
168
|
+
id: item['id'],
|
169
|
+
file_size: file_size,
|
170
|
+
file_size_converted: file_size_converted,
|
171
|
+
file_is_public: item['public'],
|
172
|
+
file_url: item['url_permanent'],
|
173
|
+
created_day: created_day,
|
174
|
+
created_hour: created_hour
|
175
|
+
}
|
176
|
+
end
|
177
|
+
def derivedFilesDetails(derived_files)
|
178
|
+
if derived_files != nil
|
179
|
+
if derived_files['image_thumb_960r'] != nil
|
180
|
+
#file_derived_bigthumb_name = derived_files['image_thumb_960r']['name']
|
181
|
+
file_derived_bigthumb_url = derived_files['image_thumb_960r']['url']
|
182
|
+
end
|
183
|
+
if derived_files['image_thumb_200s'] != nil
|
184
|
+
#file_derived_smallthumb_name = derived_files['image_thumb_200s']['name']
|
185
|
+
file_derived_smallthumb_url = derived_files['image_thumb_200s']['url']
|
186
|
+
end
|
187
|
+
list_string += "\nBig thumbnail: ".cyan + file_derived_bigthumb_url unless file_derived_bigthumb_url == nil
|
188
|
+
list_string += "\nSmall thumbnail: ".cyan + file_derived_smallthumb_url unless file_derived_smallthumb_url == nil
|
189
|
+
end
|
190
|
+
return list_string
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|