-
Notifications
You must be signed in to change notification settings - Fork 14
/
config.php
97 lines (81 loc) · 2.89 KB
/
config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
if ( 'cli-server' === php_sapi_name() ) {
$vars = json_decode( file_get_contents( '/tmp/com.packal/config.json' ), true );
foreach( $vars as $var => $val ) {
$$var = $val;
}
$_SERVER['alfred_workflow_data'] = $data_dir;
$_SERVER['alfred_workflow_cache'] = $cache_dir;
$_SERVER['HOME'] = $HOME;
$_SERVER['alfred_version'] = $alfred_version;
$_SERVER['alfred_preferences'] = $alfred_preferences;
}
// These are just here for now...
$bundle = isset( $_SERVER['alfred_workflow_bundleid'] ) ? $_SERVER['alfred_workflow_bundleid'] : 'com.packal';
$home = $_SERVER['HOME'];
function guess_alfred_version() {
if ( isset( $_SERVER['alfred_version'] ) ) {
return floor( floatval( $_SERVER['alfred_version'] ) );
}
if ( file_exists( '/Applications/Alfred 3.app' ) ) {
return 3;
}
if ( file_exists( "{$_SERVER['HOME']}/Applications/Alfred 3.app" ) ) {
return 3;
}
if ( file_exists( '/Applications/Alfred 2.app' ) ) {
return 2;
}
if ( file_exists( "{$_SERVER['HOME']}/Applications/Alfred 2.app" ) ) {
return 2;
}
throw new Exception( 'Cannot guess what version of Alfred to use' );
}
function data() {
global $bundle, $home;
if ( isset( $_SERVER['alfred_workflow_data'] ) ) {
return $_SERVER['alfred_workflow_data'];
}
$v = guess_alfred_version();
return "{$home}/Library/Application Support/Alfred {$v}/Workflow Data/{$bundle}";
}
function cache() {
global $bundle, $home;
if ( isset( $_SERVER['alfred_workflow_cache'] ) ) {
return $_SERVER['alfred_workflow_cache'];
}
$v = guess_alfred_version();
return "{$home}/Library/Caches/com.runningwithcrayons.Alfred-{$v}/Workflow Data/{$bundle}";
}
define( '__DATA__', data() );
define( '__CACHE__', cache() );
define( '__BUNDLE__', $bundle );
define( '__HOME__', $home );
$environments = [
'development' => 'http://localhost:3000', // Local Passenger Server
'dev-staging' => 'http://packal.dev', // Local nginx proxying to Passenger
'staging' => 'https://mellifluously.org', // Staging Server
'production' => 'https://www.packal.org', // Actual Production (not setup yet)
];
// Turns on Development Code (extra logging, etc...)
define( 'DEVELOPMENT_TESTING', true );
define( '__LEGACY__', true );
// The current environment is defined in environment.txt
define( 'BUNDLE', 'com.packal' );
define( 'CACHE', __CACHE__ );
define( 'DATA', __DATA__ );
define( 'ERROR_ICON', '/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/Unsupported.icns' );
if ( ! isset( $_SERVER['alfred_workflow_cache'] ) ) {
$_SERVER['alfred_workflow_cache'] = __CACHE__;
}
if ( ! isset( $_SERVER['alfred_workflow_data'] ) ) {
$_SERVER['alfred_workflow_data'] = __DATA__;
}
if ( ! isset( $_SERVER['alfred_workflow_bundleid'] ) ) {
$_SERVER['alfred_workflow_bundleid'] = $bundle;
}
foreach ( [ __CACHE__, __DATA__ ] as $dir ) :
if ( ! file_exists( $dir ) ) {
mkdir( $dir, 0775, true );
}
endforeach;