lib/ayadn/view.rb in ayadn-2.0.4 vs lib/ayadn/view.rb in ayadn-2.0.5

- old
+ new

@@ -59,12 +59,66 @@ puts @workers.build_users_list(users_list, table) puts "\n" end def show_list_followings(list, target, options = {}) - puts @workers.build_followings_list(list, target, options) - puts "\n" + if options["lastpost"] + clear_screen() + bucket = [] + list.each do |k,v| + bucket << [k, v[0], v[1], v[2], v[3], v[4], v[5]] + end + count = bucket.size + if options[:username] + bucket.sort_by! { |obj| obj[1] } + elsif options[:name] + bucket.sort_by! { |obj| obj[2].downcase } + elsif options[:posts] + bucket.sort_by! { |obj| [obj[5], obj[1]] }.reverse! + elsif options[:date] + bucket.keep_if { |obj| !obj[6].nil? } + bucket.sort_by! { |obj| obj[6]["created_at"] }.reverse! + end + title = if target == "me" + "Last post of users you're following".color(:cyan) + else + "Last post of users ".color(:cyan) + "#{target}".color(:red) + " is following ".color(:cyan) + end + puts "\t#{title}\n\n" + bucket.each.with_index(1) do |obj,index| + username = "@#{obj[1]}" + colored_username = username.color(Settings.options[:colors][:username]) + if obj[6].nil? + @workers.thor.say_status :warning, "user #{colored_username} has no posts, ignored", :red + newline() + next + end + date = @workers.parsed_time(obj[6]["created_at"]) + mentions = @workers.extract_mentions(obj[6]) + hashtags = @workers.extract_hashtags(obj[6]) + text = @workers.colorize_text(obj[6]["text"], mentions, hashtags) + total = "(#{obj[5]} posts)" + name = obj[2].nil? ? "(no name)" : obj[2] + colored_total = total.color(Settings.options[:colors][:link]) + colored_name = name.color(Settings.options[:colors][:name]) + colored_date = date.color(Settings.options[:colors][:date]) + puts "#{colored_username} #{colored_name} #{colored_date} #{colored_total}\n" + newline() + puts text + unless index == count + newline() + puts "----------\n" + newline() + else + puts "\n" + newline() + end + end + else + puts @workers.build_followings_list(list, target, options) + puts "\n" + end end def show_list_followers(list, target, options = {}) puts @workers.build_followers_list(list, target, options) puts "\n" @@ -426,9 +480,13 @@ def big_separator "----------\n\n\n" end private + + def newline + puts "\n" unless Settings.options[:timeline][:compact] == true + end def get_broadcast_alias_from_id(event_id) al = Databases.get_alias_from_id(event_id) if al.nil? || al.empty? return event_id