diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..da380e0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# secret credentials +/load.php diff --git a/include/functions.php b/include/functions.php new file mode 100644 index 0000000..a85ce36 --- /dev/null +++ b/include/functions.php @@ -0,0 +1,46 @@ +. + +/** + * Stupid way to set a cookie + * + * @param string $key + * @param string $value + * @param int $hours + */ +function my_set_cookie( $key, $value, $hours = 24 ) { + setcookie( $key, $value, time()+60*60*$hours, ROOT . _, DOMAIN, true, true ); +} + +/** + * Stupid way to unset a cookie + * + * @param string $key + */ +function my_unset_cookie( $key ) { + setcookie( $key, '1', 1, ROOT . _, DOMAIN, true, true ); +} + +/** + * Require a certain page from the template directory + * + * @param $name string page name (to be sanitized) + * @param $args mixed arguments to be passed to the page scope + */ +function template( $template_name, $template_args = [] ) { + extract( $template_args, EXTR_SKIP ); + return require ABSPATH . "/template/$template_name.php"; +} diff --git a/load-example.php b/load-example.php new file mode 100644 index 0000000..d07e094 --- /dev/null +++ b/load-example.php @@ -0,0 +1,41 @@ +. + +/* + * Please save this file as 'load.php' + */ + +// OAUTH stuff +// See [[mw:Extension:OAuth]] +define( 'OAUTH_CONSUMER_KEY', x'insert-here-key' ); +define( 'OAUTH_CONSUMER_SECRET', 'insert-here-secret' ); + +// suckless-php information +define( 'ABSPATH', __DIR__ ); +define( 'ROOT', '/cronos' ); + +// composer require mediawiki/oauthclient +require '/my/path/to/oauthclient-php-vendor/autoload.php'; + +// load the boz-mw framework +// https://gitpull.it/source/boz-mw/ +require '/my/path/to/boz-mw/autoload.php'; + +// load the suckless-php framework +// https://gitpull.it/source/suckless-php/ +require '/my/path/to/suckless-php/load.php'; + +// at this point your load-post.php file will be automagically required diff --git a/load-post.php b/load-post.php new file mode 100644 index 0000000..5875e7e --- /dev/null +++ b/load-post.php @@ -0,0 +1,30 @@ +. + +// this file is called after the suckless-php/load.php file + +// require some dummy functions +require ABSPATH . '/include/functions.php'; + +// MaterializeCSS +// https://materializecss.com/ +register_js( 'materialize', 'static/materialize/js/materialize.min.js', 'footer' ); +register_css( 'materialize', 'static/materialize/css/materialize.min.css' ); + +// register JavaScript files +register_js( 'cronos', 'static/cronos.js', 'footer', [ + 'materialize', +] ); diff --git a/template/footer.php b/template/footer.php new file mode 100644 index 0000000..2862e1c --- /dev/null +++ b/template/footer.php @@ -0,0 +1,30 @@ +. + +?> +
+ + + + + +