Add detect url-rewrite.
Add some SEO feature
This commit is contained in:
parent
640419ff02
commit
f8fc38877a
6 changed files with 41 additions and 11 deletions
14
.htaccess
14
.htaccess
|
@ -1,4 +1,18 @@
|
|||
Options -Indexes
|
||||
|
||||
<ifModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteCond $1 !^(css)
|
||||
RewriteRule ^([^/]*)/([^/]*)$ /?dir=$1&file=$2 [L]
|
||||
AddType text/css .css
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_headers.c>
|
||||
Header always set X-FRAME-OPTIONS "DENY"
|
||||
Header set Content-Security-Policy "script-src 'self'"
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_expires.c>
|
||||
ExpiresActive On
|
||||
ExpiresDefault "access plus 1 day"
|
||||
</IfModule>
|
|
@ -67,9 +67,10 @@ function listFile($dir)
|
|||
* @author Knah Tsaeb <Knah-Tsaeb_mynovi@knah-tsaeb.org>
|
||||
* @global
|
||||
* @param string $getDir Default: null
|
||||
* @param bool $urlRewrite Default: false
|
||||
* @return string
|
||||
*/
|
||||
function makeMenu($getDir = null)
|
||||
function makeMenu($getDir = null, $urlRewrite = false)
|
||||
{
|
||||
$dirList = listDir();
|
||||
$menu = '';
|
||||
|
@ -77,7 +78,7 @@ function makeMenu($getDir = null)
|
|||
if ($getDir === $dir) {
|
||||
$expand = 'open';
|
||||
} else {
|
||||
$expand = 'close';
|
||||
$expand = '';
|
||||
}
|
||||
$menu .= '
|
||||
<details ' . $expand . '>
|
||||
|
@ -85,7 +86,11 @@ function makeMenu($getDir = null)
|
|||
<ul>';
|
||||
|
||||
foreach ($files as $value) {
|
||||
if($urlRewrite === true){
|
||||
$menu .= '<li><a href="/' . urlencode($dir) . '/' . urlencode($value) . '">' . $value . '</a></li>';
|
||||
} else {
|
||||
$menu .= '<li><a href="?dir=' . urlencode($dir) . '&file=' . urlencode($value) . '">' . $value . '</a></li>';
|
||||
}
|
||||
}
|
||||
$menu .= '
|
||||
</ul>
|
||||
|
|
|
@ -2,6 +2,13 @@
|
|||
require 'vendor/autoload.php';
|
||||
require 'apps/apps.php';
|
||||
|
||||
if (in_array ("mod_rewrite", apache_get_modules()))
|
||||
{
|
||||
$urlRewrite = true;
|
||||
} else {
|
||||
$urlRewrite = false;
|
||||
}
|
||||
|
||||
$dir = $_GET['dir'] ?? '';
|
||||
$file = $_GET['file'] ?? '';
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<aside class="menu">
|
||||
<nav role="navigation">
|
||||
<nav>
|
||||
<h1>MyNoVi</h1>
|
||||
<p>
|
||||
<?php echo makeMenu($dir); ?>
|
||||
</p>
|
||||
<?php echo makeMenu($dir, $urlRewrite); ?>
|
||||
</nav>
|
||||
</aside>
|
|
@ -20,11 +20,15 @@
|
|||
<meta name="msapplication-TileColor" content="#da532c">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
|
||||
<meta name="description" content="MyNoVi is personal note viewer.">
|
||||
|
||||
<meta property="og:image" content="https://mynovi.knah-tsaeb.org/android-chrome-192x192.png" />
|
||||
<meta property="og:image:type" content="image/png" />
|
||||
<meta property="og:image:width" content="192" />
|
||||
<meta property="og:image:height" content="192" />
|
||||
<meta property="og:image:alt" content="Logo" />
|
||||
<meta property="og:title" content="MyNoVi" />
|
||||
<meta property="og:description" content="MyNoVi is personal note viewer." />
|
||||
|
||||
</head>
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<aside class="toc">
|
||||
<?php echo $toc;?>
|
||||
|
||||
</aside>
|
||||
<main role="main" class="main">
|
||||
|
||||
<main class="main">
|
||||
<?php echo $body;?>
|
||||
</main>
|
Loading…
Reference in a new issue