lib/ayadn/action.rb in ayadn-1.2.7 vs lib/ayadn/action.rb in ayadn-1.2.8
- old
+ new
@@ -437,16 +437,42 @@
end
def search(words, options)
begin
doing(options)
- stream = @api.get_search(words, options)
+ stream = if options[:users]
+ @api.search_users words, options
+ elsif options[:annotations]
+ @api.search_annotations words, options
+ elsif options[:channels]
+ splitted = splitter_all words
+ @api.search_channels splitted.join(','), options
+ elsif options[:messages]
+ words = words.split(',')
+ channel_id = get_channel_id_from_alias(words[0])
+ words.shift
+ splitted = splitter_all words.join(' ')
+ @api.search_messages channel_id, splitted.join(','), options
+ else
+ splitted = splitter_all words
+ @api.get_search splitted.join(','), options
+ end
no_data('search') if stream['data'].empty?
- if options[:extract]
- view_all_search_links(stream, words)
+ if options[:users]
+ stream['data'].sort_by! {|obj| obj['counts']['followers']}
+ stream['data'].each do |obj|
+ puts "----------\n\n\n"
+ @view.show_userinfos(obj, nil)
+ end
+ elsif options[:channels]
+ @view.show_channels stream, options
else
- render_view(stream, options)
+ if options[:extract]
+ view_all_search_links(stream, words)
+ else
+ render_view(stream, options)
+ end
end
rescue => e
Errors.global_error("action/search", [words, options], e)
ensure
Databases.close_all
@@ -901,9 +927,13 @@
Databases.close_all
end
end
private
+
+ def splitter_all words
+ [words].collect {|w| w.split(' ')}
+ end
def get_original_id(post_id, resp)
if resp['data']['repost_of']
puts Status.redirecting
id = resp['data']['repost_of']['id']