Jump to content

tanepiper

Member
  • Posts

    3
  • Joined

  • Last visited

Posts posted by tanepiper

  1. Thanks to Dave earlier, I got my script working.

     

    However I've been debugging a problem for a while and haven't been able to come up with a solution.

     

    The issues seems to be with my script that any spaces seem to kill the script and default back to Google/Amazon/Wiki search.

     

    To test it wasn't my code, I've done the following example lines:

     

    $filter = preg_split("/\s/", trim("web 1"));

    $filter = preg_split("/\s/", trim(str_replace('-', ' ', "{query}")));

     

    In the first case, I run the PHP script from the command line and it works fine.  In the second one, when I need to put a space in I instead do a dash (so I can do'web-1' or '1-web') and in both cases it works fine.  But try 'web 1' in Alfred, and it breaks after I do 'web' then space.

     

    I was just exploding on the space as well in previous versions, but had no luck getting this to work.

     

    Any ideas?

     

    (Oh I should say this is a PHP script)

  2. Thanks very much - the if statement might need fixed as it's returning all results - but other than that it's working as I expected (you had $name twice in the strpos)

     

    Awesome job :)

     

    edit:

     

    here is my updated code:

     

    require_once('workflows.php');
    $w = new Workflows();
    
    $data = array(
      'Web 1 Production Site' => 'http://www1.production',
      'Web 2 Production Site' => 'http://www2.production',
      'Web 1 Staging Site' => 'http://www1.staging',
      'Web 2 Staging Site' => 'http://www2.staging',
    );
    
    $filter = "{query}";
    
    foreach( $data as $name => $site ):
      if ( $filter && ( strpos( strtolower( $site ), strtolower( $filter ) ) !== false || strpos( strtolower( $name ), strtolower( $filter ) ) !== false ) ):
        $w->result( 'saved.site', $site, $name, $site, 'icon.png', 'yes', $name );
      endif;
    endforeach;
    
    echo $w->toxml();
    
  3. Hi there,

     

    I've been trying to get a workflow that's sort of like text expansion working, but with a specific task of storing URLs for our internal sites.

     

    For example, I don't want to have to maintain a giant list of inputs and outputs to clipboard for this - I'd rather have something like:

     

    Input: ,fa <space> <keywords>

     

    In the array would be:

     

    $data = array(

      'Production Server 1' => 'http://www1.production'

      'Production Server 2' => 'http://www2.production'

      'Staging Server 1' => 'http://www1.staging'

      'Staging Server 2' => 'http://www2.staging'

    );

     

    So for example I'd like to start typing `,fa pro` and have it return the two production servers to the list as their names, and when selecting one have the URL from the data be sent to clipboard.

     

    I had a working version but nothing would get returned to Alfred to let me select - I would have to either type out the whole string (e.g. 'Production Server 1'), or have short codes (i.e. instead of Production Server 1 have ps1).

     

    Any help on this would be much appreciated!

×
×
  • Create New...