diff --git a/bootstrap.php b/bootstrap.php
index 087bf3c..308395c 100644
--- a/bootstrap.php
+++ b/bootstrap.php
@@ -3,6 +3,7 @@
require __DIR__ .'/vendor/autoload.php';
use APnutI\APnutI;
+use Monolog\Logger;
session_start();
$config = include(__DIR__.'/config.php');
@@ -12,5 +13,8 @@ $api = new APnutI(
$config['permission_scopes'],
$config['app_name'],
$config['callback_url'],
- __DIR__.'/'.$config['log_file']
+ __DIR__.'/'.$config['log_file'],
+ $config['log_level']
);
+
+require_once __DIR__ . '/globals.php';
diff --git a/composer.lock b/composer.lock
index 7709379..488b069 100644
--- a/composer.lock
+++ b/composer.lock
@@ -12,7 +12,7 @@
"dist": {
"type": "path",
"url": "../APnutI",
- "reference": "99eee326abe217a901fbc6f8415e70f64bcb5959"
+ "reference": "c2434cfedcd88d729408ebfffc868d064260cbf1"
},
"require": {
"ext-curl": "*",
diff --git a/config.php.default b/config.php.default
index 61eeaf1..c84b85c 100644
--- a/config.php.default
+++ b/config.php.default
@@ -4,6 +4,7 @@ return [
'client_id' => '',
'client_secret' => '',
'log_file' => '../../logs/Dragonpolls.log', // Relative to index.php
+ 'log_level' => 'INFO',
'app_name' => 'Playground',
'callback_url' => 'http://localhost/auth_callback.php',
'permission_scopes' => 'basic' //comma seperated string
diff --git a/globals.php b/globals.php
new file mode 100644
index 0000000..402fb6f
--- /dev/null
+++ b/globals.php
@@ -0,0 +1,50 @@
+console.log('.json_encode($obj).');';
+}
+
+function get_page_header(
+ ?string $page_title = null,
+ bool $include_app_name = true,
+ array $scripts = []
+): string {
+ global $api;
+ $greeting = '';
+ $logout_link = '';
+ if ($api->isAuthenticated(false, true)) {
+ $u = $api->getAuthorizedUser();
+ $greeting = 'Welcome, ' . ($u->name ?? '@'.$u->username);
+ $logout_link = 'Logout';
+ } else {
+ $greeting = 'Login with pnut';
+ }
+ $title = '';
+ if ($include_app_name) {
+ $title = $api->app_name;
+ }
+ if (!empty($page_title)) {
+ $title .= $include_app_name ? ' > ' : '';
+ $title .= $page_title;
+ }
+ $script_str = '';
+ foreach ($scripts as $script) {
+ //$script_str .= '';
+ $script_str .= '