Jump to content

Search list of URLs and open in browser


Recommended Posts

Hey there!

 

I work in customer support, and I'm trying to create a workflow that will make it easy to search for and open support docs in my browser.

 

I know I could use a custom searches for each one, but since there are over 400 potential support docs that would make entering them take a long time, and it would also be difficult to share it with other members of my team.

 

What I'd like to do is create a workflow with a keyword that would allow me to fuzzy-search the list of support articles, and open the URL in my browser. I've exported a list of all of the support docs in a tab-delimited text file that looks something like this:

 

I know basically, that I need to a script filter that would search the first column, and output an XML item for each line that matches. Then I can forward that to an "Open URL" action in my workflow.

 

I'm not really a coder (though I have a basic understanding of PHP), so would anyone be able to provide an example of how this might be done? Or is there a better way to approach it?

 

Thanks!

Link to comment

Hey there!

 

I work in customer support, and I'm trying to create a workflow that will make it easy to search for and open support docs in my browser.

 

I know I could use a custom searches for each one, but since there are over 400 potential support docs that would make entering them take a long time, and it would also be difficult to share it with other members of my team.

 

What I'd like to do is create a workflow with a keyword that would allow me to fuzzy-search the list of support articles, and open the URL in my browser. I've exported a list of all of the support docs in a tab-delimited text file that looks something like this:

 

 

I know basically, that I need to a script filter that would search the first column, and output an XML item for each line that matches. Then I can forward that to an "Open URL" action in my workflow.

 

I'm not really a coder (though I have a basic understanding of PHP), so would anyone be able to provide an example of how this might be done? Or is there a better way to approach it?

 

Thanks!

 

I could probably help you with this. If you'd like, send me the file of the urls and I'll put together a workflow for you to be able to search them and display the results. You can send it david at alfredapp com

Link to comment

Hey there!

 

I work in customer support, and I'm trying to create a workflow that will make it easy to search for and open support docs in my browser.

 

I know I could use a custom searches for each one, but since there are over 400 potential support docs that would make entering them take a long time, and it would also be difficult to share it with other members of my team.

 

What I'd like to do is create a workflow with a keyword that would allow me to fuzzy-search the list of support articles, and open the URL in my browser. I've exported a list of all of the support docs in a tab-delimited text file that looks something like this:

 

 

I know basically, that I need to a script filter that would search the first column, and output an XML item for each line that matches. Then I can forward that to an "Open URL" action in my workflow.

 

I'm not really a coder (though I have a basic understanding of PHP), so would anyone be able to provide an example of how this might be done? Or is there a better way to approach it?

 

Thanks!

 

Hi Andy,

 

Could you please fill in your Powerpack email address if you'd like help with workflows? As this is a Powerpack-related feature, I just need to confirm you're indeed a Powerpack user :)

 

David will then able to lend a hand as he kindly offered.

 

Cheers,

Vero

Link to comment

Hi Andy,

 

Could you please fill in your Powerpack email address if you'd like help with workflows? As this is a Powerpack-related feature, I just need to confirm you're indeed a Powerpack user :)

 

David will then able to lend a hand as he kindly offered.

 

Cheers,

Vero

 

Whoops! Thought I had already. I've added it to my profile.

Link to comment

If you have a basic understanding of PHP, then you could use my Alphred PHP library (documentation) and put this together fairly quickly.

 

Basically, you'd create a Script Filter that would be PHP, and then you'd import the TSV file into an array and then use the filter functionality with that and the typed query. After that, you'd just throw the remaining results through a foreach loop and populate them with the script filter functionality. Just make sure you match the URL to the arg, and then you connect it to the open URL action, and you're done.

 

Here's some untested code for the script filter:

// You might need to uncomment the next line
// ini_set( 'auto_detect_line_endings', true);

// require Alphred library
require_once( __DIR__ . '/Alphred.phar' );
// create an alphred object
$alphred = new Alphred([ 'error_on_empty' => true ]);

// Read the TSV file called "urls.tsv" into the $data array
$count = 0;
if ( FALSE !== ( $handle = fopen( __DIR__ . '/urls.tsv', 'r' ) ) ) {
	// I'm using a tab as the third argument, which is the separator
  while ( FALSE !== ( $row = fgetcsv( $handle, 0, '	' ) ) ) :
		$data[ $count ]['title'] = $row[0];
		$data[ $count ]['url']   = $row[1];
    $count++;
  endwhile;
  fclose( $handle );
}

// {query} will be set via Alfred
$query = "{query}";

$data = $alphred->filter( $data, $query, 'title' );

foreach ( $data as $d ) :
	$alphred->add_result([
		'title' => $d['title'],
		'arg'   => $d['url'],
		'autocomplete' => $d['title'],
		'valid' => true
	]);
endforeach;

$alphred->to_xml();
Link to comment

Whoops! Thought I had already. I've added it to my profile.

 

If you haven't already attempted Shawn's suggestion.. Download a workflow here.

 

I didn't know what you wanted to name this or what you wanted the keyword to be so I just picked something. Try this out and let me know what you think. We can work on the details later.

Link to comment

If you haven't already attempted Shawn's suggestion.. Download a workflow here.

 

I didn't know what you wanted to name this or what you wanted the keyword to be so I just picked something. Try this out and let me know what you think. We can work on the details later.

 

David, that workflow is exactly what I was looking to do. Thanks so much! I'll keep playing around with it, but it seems to work perfectly!

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...