lib/ayadn/view.rb in ayadn-1.5.1 vs lib/ayadn/view.rb in ayadn-1.6.0

- old
+ new

@@ -15,10 +15,17 @@ def show_posts(data, options, niceranks = {}) resp = build_stream_without_index(data, options, niceranks) puts resp unless resp == "" end + def if_raw what, options + if options[:raw] + show_raw(what, options) + exit + end + end + def show_raw(stream, options = {}) #puts stream.to_json jj stream end @@ -257,11 +264,11 @@ view << "#{ann[0]['value']['url']}".color(Settings.options[:colors][:link]) view << "\n" end unless ch.recent_message.nil? unless ch.recent_message['text'].nil? - view << "Most recent message (#{Workers.new.parsed_time(ch.recent_message['created_at'])}): ".color(:cyan) + view << "Most recent message (#{@workers.parsed_time(ch.recent_message['created_at'])}): ".color(:cyan) view << "\n" view << "---\n#{ch.recent_message['text']}\n---" end end if ch.type == "net.paste-app.clips" @@ -274,17 +281,95 @@ end view << "\nYour account is currently linked to #{bucket.length} channels.\n\n".color(:green) unless options[:channels] puts view end + def render(stream, options = {}, niceranks = {}) + unless options[:raw] + get(stream['data'], options, niceranks) + else + show_raw(stream) + end + end + + def get(stream, options = {}, niceranks = {}) + clear_screen() + if options[:index] + show_posts_with_index(stream, options, niceranks) + else + show_posts(stream, options, niceranks) + end + end + + def get_simple_view(stream) + clear_screen() + show_simple_stream(stream) + end + def clear_screen puts "\e[H\e[2J" end def page msg clear_screen puts msg puts "\n" + end + + def winsize + IO.console.winsize + end + + def show_links(links) + links.each {|l| puts "#{l}\n".color(Settings.options[:colors][:link])} + end + + def all_hashtag_links(stream, hashtag) + clear_screen() + puts "Links from posts containing hashtag '##{hashtag}': \n".color(:cyan) + show_links(@workers.links_from_posts(stream)) + end + + def all_search_links(stream, words) + clear_screen() + puts "Links from posts containing word(s) '#{words}': \n".color(:cyan) + show_links(@workers.links_from_posts(stream)) + end + + def all_stars_links(stream) + clear_screen() + puts "Links from your starred posts: \n".color(:cyan) + show_links(@workers.links_from_posts(stream)) + end + + def infos(stream, token) + clear_screen() + show_userinfos(stream, token, true) + end + + def downloading(options = {}) + unless options[:raw] + clear_screen() + print Status.downloading + end + end + + def list(what, list, target) + clear_screen() + case what + when :whoreposted + show_list_reposted(list, target) + when :whostarred + show_list_starred(list, target) + when :followings + show_list_followings(list, target) + when :followers + show_list_followers(list, target) + when :muted + show_list_muted(list) + when :blocked + show_list_blocked(list) + end end def big_separator "----------\n\n\n" end