Jump to content

rogan

Member
  • Posts

    2
  • Joined

  • Last visited

Everything posted by rogan

  1. Updated! But I also solved my own problem, I thought this was somethign that alfred would handle but I just built it into ruby for other peoples use, i'm now using: require 'json' require 'net/http' require "rexml/document" jsonUrl = 'JSON url' resp = Net::HTTP.get_response(URI.parse(jsonUrl)) data = resp.body result = JSON.parse(data) document = REXML::Element.new("items") results = Hash.new(); result['data'].each { |x| x['properties'].each { |y , i| searchName = y['name'].downcase if searchName.include? "{query}" results[y['name']] = y['id'] new_item = REXML::Element.new('item') new_item.add_attributes({ 'uid' => 'test', 'arg' => y['id'], 'valid' => 'no', 'autocomplete' => y['name'] }) REXML::Element.new("title", new_item).text = y['name'] document << new_item end } } puts document.to_s if anyone knows of a way to make this faster however.. I'd be very greatful
  2. require 'json' require 'net/http' require "rexml/document" jsonUrl = 'jsonFile' resp = Net::HTTP.get_response(URI.parse(jsonUrl)) data = resp.body result = JSON.parse(data) document = REXML::Element.new("items") result['data'].each { |x| x['properties'].each { |y| new_item = REXML::Element.new('item') new_item.add_attributes({ 'uid' => 'test', 'arg' => y['id'], 'valid' => 'no', 'autocomplete' => y['name'] }) REXML::Element.new("title", new_item).text = y['name'] document << new_item } } puts document.to_s So I have this script filter that loads in a JSON file and the result you select sends off an ID to open a webpage using that ID. It is fired by typing 'dashboard search_item_here' The results all load into alfred fine, however it just loads all my results in and you have to select them manually with the up/down arrows (theres over 100 results). I want it to filter the results taking the 'search_item_here' text but I'm totally lost on how to do that? What am i missing? Thanks all
×
×
  • Create New...