lib/ayadn/view.rb in ayadn-1.2.8 vs lib/ayadn/view.rb in ayadn-1.2.9

- old
+ new

@@ -21,12 +21,11 @@ #puts stream.to_json jj stream end def show_simple_post(post, options) - view = build_stream_without_index(post, options, {}) - puts view + puts build_stream_without_index(post, options, {}) end def show_posted(resp) show_simple_post([resp['data']], {}) end @@ -266,19 +265,25 @@ def clear_screen puts "\e[H\e[2J" end + def page msg + clear_screen + puts msg + puts "\n" + end + + def big_separator + "----------\n\n\n" + end + private def get_broadcast_alias_from_id(event_id) al = Databases.get_alias_from_id(event_id) - unless al.nil? - al - else - event_id - end + al.nil? ? event_id : al end def filter_nicerank posts, options if options[:filter] == true # only if this option is true in Action (only global for now) unless Settings.options[:nicerank].nil? #in case config file not initialized @@ -303,14 +308,11 @@ return posts end def build_stream_with_index(data, options, niceranks) #expects an array @view = "" - posts = @workers.build_posts(data.reverse, niceranks) - - posts = filter_nicerank(posts, options) - + posts = filter_nicerank(@workers.build_posts(data.reverse, niceranks), options) posts.each do |id,content| count = "%03d" % content[:count] if content[:username] == Settings.config[:identity][:username] @view << count.color(Settings.options[:colors][:index]).inverse elsif content[:mentions].include?(Settings.config[:identity][:username]) && options[:in_mentions].nil? @@ -324,13 +326,10 @@ return posts, @view end def build_stream_without_index(data, options, niceranks) #expects an array @view = "" - posts = @workers.build_posts(data.reverse, niceranks) - - posts = filter_nicerank(posts, options) - + posts = filter_nicerank(@workers.build_posts(data.reverse, niceranks), options) posts.each do |id,content| if content[:username] == Settings.config[:identity][:username] @view << content[:id].to_s.color(Settings.options[:colors][:id]).inverse + " " elsif content[:mentions].include?(Settings.config[:identity][:username]) && options[:in_mentions].nil? @view << content[:id].to_s.color(Settings.options[:colors][:mentions]).inverse + " "