diff --git a/package.json b/package.json index 350ed70..c6c1dc4 100644 --- a/package.json +++ b/package.json @@ -2,17 +2,17 @@ "name": "lexiconga-lite", "version": "1.0.0", "description": "A light-as-possible rewrite of Lexiconga", - "main": "index.html", + "main": "template-index.html", "repository": "https://cybre.tech/Alamantus/lexiconga-lite.git", "author": "Robbie Antenesse ", "license": "UNLICENCED", "scripts": { "start": "concurrently \"npm run watch-js\" \"npm run watch-php\" \"npm run copy-files\"", - "watch-js": "parcel watch index.html offline.html template-view.html template-passwordreset.html --no-hmr --public-url ./", + "watch-js": "parcel watch template-index.html offline.html template-view.html template-passwordreset.html --no-hmr --public-url ./", "watch-php": "cpx \"src/php/**/{*,.*}\" dist -v -w", "copy-files": "cpx \"node_modules/upup/dist/upup.sw.min.js\" dist -v", - "bundle": "parcel build index.html offline.html template-view.html template-passwordreset.html && npm run copy-files && cpx \"src/php/**/{*,.*}\" dist", - "serve-frontend-only": "parcel index.html", + "bundle": "parcel build template-index.html offline.html template-view.html template-passwordreset.html && npm run copy-files && cpx \"src/php/**/{*,.*}\" dist", + "serve-frontend-only": "parcel template-index.html", "clear": "npm run clear-dist && npm run clear-cache", "clear-dist": "rimraf dist/*", "clear-cache": "rimraf .cache/*" diff --git a/src/php/.htaccess b/src/php/.htaccess index 973cfb6..1840d1c 100644 --- a/src/php/.htaccess +++ b/src/php/.htaccess @@ -8,6 +8,8 @@ RewriteRule ^view/([0-9]+)/?$ router.php?view=dictionary&dict=$1 [NC,L] RewriteRule ^([0-9]+)/?$ router.php?view=dictionary&dict=$1 [NC,L] # Handle dictionary ids. +RewriteRule ^/?(index.html)?$ router.php [NC,L] # Handle dictionary ids. + #RewriteRule ^issues/?$ https://github.com/Alamantus/Lexiconga/issues [R=301,L] # Shorten issues url. #RewriteRule ^updates/?$ https://github.com/Alamantus/Lexiconga/releases [R=301,L] # Shorten updates url. \ No newline at end of file diff --git a/src/php/announcements.json b/src/php/announcements.json new file mode 100644 index 0000000..eef6582 --- /dev/null +++ b/src/php/announcements.json @@ -0,0 +1,7 @@ +[ + { + "header": "Test", + "body": "

Test

", + "expire": "January 1, 2020" + } +] \ No newline at end of file diff --git a/src/php/router.php b/src/php/router.php index 5a26fe1..9f0c774 100644 --- a/src/php/router.php +++ b/src/php/router.php @@ -66,4 +66,24 @@ switch ($view) { } break; } + + default: { + $html = file_get_contents(realpath(dirname(__FILE__) . '/./template-index.html')); + $announcements = file_get_contents(realpath(dirname(__FILE__) . '/./announcements.json')); + $announcements = json_decode($announcements, true); + $announcements_html = ''; + foreach ($announcements as $announcement) { + $expire = strtotime($announcement['expire']); + if (time() < $expire) { + $announcements_html .= '
+ ×︎ +

' . $announcement['header'] . '

+ ' . $announcement['body'] . ' +
'; + } + } + $html = str_replace('{{announcements}}', $announcements_html, $html); + return Response::html($html); + break; + } } \ No newline at end of file diff --git a/index.html b/template-index.html similarity index 99% rename from index.html rename to template-index.html index 10e93b9..2d399b9 100644 --- a/index.html +++ b/template-index.html @@ -121,6 +121,7 @@
+ {{announcements}}

Dictionary Name