-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.php
executable file
·102 lines (88 loc) · 2.88 KB
/
app.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
98
99
100
101
102
<?php
require __DIR__.'/vendor/autoload.php';
session_cache_limiter(false);
session_start();
$mode = 'local';
if (array_key_exists('MODE', $_SERVER)) {
$mode = $_SERVER['MODE'];
} else {
if (file_exists(__DIR__.'/env.live')) {
$mode = 'live';
} elseif (file_exists(__DIR__.'/env.local')) {
$mode = 'local';
}
}
// Prepare app
$app = new \Slim\Slim();
$app->setName('JIRA Attachments Gallery');
$app->config('debug', true);
$app->config('mode', $mode);
$app->config('view', new \Slim\Views\Twig());
$app->config('templates.path', realpath('views'));
$env = $app->environment();
$app->add(new \Slim\Middleware\SessionCookie(array(
'expires' => '20 minutes',
'path' => '/',
'domain' => null,
'secure' => false,
'httponly' => false,
'name' => 'slim_session',
'secret' => 'CHANGE_ME',
'cipher' => MCRYPT_RIJNDAEL_256,
'cipher_mode' => MCRYPT_MODE_CBC
)));
$app->flashKeep();
$logWriter = null;
// if live mode
$app->configureMode('live', function () use ($app, $env) {
$env['URLBASE'] = 'http://tupilabs.com/jira-attachments';
$env['URLIMG'] = '/img/';
$env['URLFULLIMG'] = $env['URLBASE'] . $env['URLIMG'];
$env['URLCSS'] = '/css/';
$env['URLJS'] = '/js/';
$env['GATRACKER'] = 'UA-????';
$app->config('debug', false);
$logWriter = new \Slim\Extras\Log\DateTimeFileWriter(array('path' => __DIR__.'/logs'));
});
// if local mode
$app->configureMode('local', function () use ($app, $env) {
$env['URLBASE'] = 'http://127.0.0.1';
$env['URLIMG'] = '/img/';
$env['URLFULLIMG'] = $env['URLBASE'] . $env['URLIMG'];
$env['URLCSS'] = '/css/';
$env['URLJS'] = '/js/';
//$env['GATRACKER'] = '';
$app->config('debug', true);
$out = array();
exec(sprintf("php %s/bundle.php", __DIR__), $out);
if (count($out) > 1) {
printf('<div><pre><code>%s</code></pre></div>', implode(PHP_EOL, $out));
}
$logWriter = new \Slim\Extras\Log\DateTimeFileWriter(array('path' => __DIR__.'/logs'));
});
#$app->getLog()->setWriter($logWriter);
$log = new \Monolog\Logger('jira-attachments');
$log->pushHandler(new \Monolog\Handler\StreamHandler('logs/jira-attachments.log', \Psr\Log\LogLevel::DEBUG));
$app->log = $log;
// Create monolog logger and store logger in container as singleton
// (Singleton resources retrieve the same log resource definition each time)
// $app->container->singleton('log', function () {
// $log = new \Monolog\Logger('jira-attachments');
// $log->pushHandler(new \Monolog\Handler\StreamHandler('logs/jira-attachments.log', \Psr\Log\LogLevel::DEBUG));
// return $log;
// });
// Prepare view
// $app->view(new \Slim\Views\Twig());
// $app->view->parserOptions = array(
// 'debug' => true,
// 'charset' => 'utf-8',
// 'cache' => realpath('templates/cache'),
// 'auto_reload' => true,
// 'strict_variables' => false,
// 'autoescape' => true
// );
$app->view->parserExtensions = array(new \Slim\Views\TwigExtension());
// Define routes
require __DIR__.'/routes.php';
// Run app
$app->run();