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
16
.htaccess
16
.htaccess
|
@ -1,4 +1,18 @@
|
||||||
|
Options -Indexes
|
||||||
|
|
||||||
|
<ifModule mod_rewrite.c>
|
||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
RewriteCond $1 !^(css)
|
RewriteCond $1 !^(css)
|
||||||
RewriteRule ^([^/]*)/([^/]*)$ /?dir=$1&file=$2 [L]
|
RewriteRule ^([^/]*)/([^/]*)$ /?dir=$1&file=$2 [L]
|
||||||
AddType text/css .css
|
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>
|
* @author Knah Tsaeb <Knah-Tsaeb_mynovi@knah-tsaeb.org>
|
||||||
* @global
|
* @global
|
||||||
* @param string $getDir Default: null
|
* @param string $getDir Default: null
|
||||||
|
* @param bool $urlRewrite Default: false
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function makeMenu($getDir = null)
|
function makeMenu($getDir = null, $urlRewrite = false)
|
||||||
{
|
{
|
||||||
$dirList = listDir();
|
$dirList = listDir();
|
||||||
$menu = '';
|
$menu = '';
|
||||||
|
@ -77,7 +78,7 @@ function makeMenu($getDir = null)
|
||||||
if ($getDir === $dir) {
|
if ($getDir === $dir) {
|
||||||
$expand = 'open';
|
$expand = 'open';
|
||||||
} else {
|
} else {
|
||||||
$expand = 'close';
|
$expand = '';
|
||||||
}
|
}
|
||||||
$menu .= '
|
$menu .= '
|
||||||
<details ' . $expand . '>
|
<details ' . $expand . '>
|
||||||
|
@ -85,7 +86,11 @@ function makeMenu($getDir = null)
|
||||||
<ul>';
|
<ul>';
|
||||||
|
|
||||||
foreach ($files as $value) {
|
foreach ($files as $value) {
|
||||||
$menu .= '<li><a href="/' . urlencode($dir) . '/' . urlencode($value) . '">' . $value . '</a></li>';
|
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 .= '
|
$menu .= '
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -2,6 +2,13 @@
|
||||||
require 'vendor/autoload.php';
|
require 'vendor/autoload.php';
|
||||||
require 'apps/apps.php';
|
require 'apps/apps.php';
|
||||||
|
|
||||||
|
if (in_array ("mod_rewrite", apache_get_modules()))
|
||||||
|
{
|
||||||
|
$urlRewrite = true;
|
||||||
|
} else {
|
||||||
|
$urlRewrite = false;
|
||||||
|
}
|
||||||
|
|
||||||
$dir = $_GET['dir'] ?? '';
|
$dir = $_GET['dir'] ?? '';
|
||||||
$file = $_GET['file'] ?? '';
|
$file = $_GET['file'] ?? '';
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
<aside class="menu">
|
<aside class="menu">
|
||||||
<nav role="navigation">
|
<nav>
|
||||||
<h1>MyNoVi</h1>
|
<h1>MyNoVi</h1>
|
||||||
<p>
|
<?php echo makeMenu($dir, $urlRewrite); ?>
|
||||||
<?php echo makeMenu($dir); ?>
|
|
||||||
</p>
|
|
||||||
</nav>
|
</nav>
|
||||||
</aside>
|
</aside>
|
||||||
|
|
|
@ -20,12 +20,16 @@
|
||||||
<meta name="msapplication-TileColor" content="#da532c">
|
<meta name="msapplication-TileColor" content="#da532c">
|
||||||
<meta name="theme-color" content="#ffffff">
|
<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" content="https://mynovi.knah-tsaeb.org/android-chrome-192x192.png" />
|
||||||
<meta property="og:image:type" content="image/png" />
|
<meta property="og:image:type" content="image/png" />
|
||||||
<meta property="og:image:width" content="192" />
|
<meta property="og:image:width" content="192" />
|
||||||
<meta property="og:image:height" content="192" />
|
<meta property="og:image:height" content="192" />
|
||||||
<meta property="og:image:alt" content="Logo" />
|
<meta property="og:image:alt" content="Logo" />
|
||||||
|
<meta property="og:title" content="MyNoVi" />
|
||||||
|
<meta property="og:description" content="MyNoVi is personal note viewer." />
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<aside class="toc">
|
<aside class="toc">
|
||||||
<?php echo $toc;?>
|
<?php echo $toc;?>
|
||||||
|
|
||||||
</aside>
|
</aside>
|
||||||
<main role="main" class="main">
|
|
||||||
|
<main class="main">
|
||||||
<?php echo $body;?>
|
<?php echo $body;?>
|
||||||
</main>
|
</main>
|
Loading…
Reference in a new issue