Minor, but important improvements

This commit is contained in:
Belle Aerni 2023-04-01 19:30:12 -07:00
parent 0663fbc604
commit 8e018600a5
5 changed files with 11 additions and 14 deletions

View File

@ -30,19 +30,19 @@ class AntPages
$pageFunctionalPath = '/';
}
if(str_ends_with($pageFunctionalPath, 'index')){
if (str_ends_with($pageFunctionalPath, 'index')) {
$pageFunctionalPath = substr($pageFunctionalPath, 0, -5);
}
$currentPage = array(
'pageTitle' => $pageHeader['title'],
'fullPagePath' => $page,
'functionalPagePath' => $pageFunctionalPath,
'functionalPagePath' => ($pageFunctionalPath == DIRECTORY_SEPARATOR) ? DIRECTORY_SEPARATOR : rtrim($pageFunctionalPath, DIRECTORY_SEPARATOR),
'showInNav' => true,
);
// Move the index page to the first item in the page list, so it appears as the first item in the navbar.
if ($pageFunctionalPath === '/') {
// Move the index page to the first item in the page list, so it appears as the first item in the navbar.
if ($pageFunctionalPath == DIRECTORY_SEPARATOR) {
array_unshift($pageList, $currentPage);
} else {
$pageList[] = $currentPage;
@ -79,16 +79,11 @@ class AntPages
}
}
$currentPage = strtolower($currentPage);
if (str_ends_with($currentPage, '/')) {
$currentPage .= 'index.md';
}
$baseURL = AntConfig::currentConfig('baseURL');
foreach ($pages as $key => $page) {
$url = "//" . AntTools::repairURL($baseURL . $page['functionalPagePath']);
$pages[$key]['url'] = $url;
$pages[$key]['active'] = $currentPage === strtolower($page['functionalPagePath']);
$pages[$key]['active'] = $currentPage == $page['functionalPagePath'];
//Remove pages that are hidden from the nav from the array before sending it to twig.
if (!(bool)$page['showInNav']) {

View File

@ -18,6 +18,6 @@ class AntTwigFilters extends AbstractExtension
public function absUrl(string $relative): string
{
return '//' . AntTools::repairURL(AntConfig::currentConfig('baseURL') . '/' . $relative);
return '://' . AntTools::repairURL(AntConfig::currentConfig('baseURL') . '/' . trim($relative));
}
}

View File

@ -13,6 +13,8 @@ class RobotstxtPlugin extends AntPlugin
$robotstxt = 'User-agent: *' . "\n";
$robotstxt.= 'Disallow: /plugin/' . "\n";
$robotstxt.= 'Disallow: /admin/' . "\n";
$robotstxt.= 'Disallow: /profile/' . "\n";
$robotstxt.= 'Sitemap: ' . $protocol . '://' . AntTools::repairURL($baseURL . '/sitemap.xml' . "\n");
header("Content-Type: text/plain");
echo $robotstxt;

View File

@ -15,7 +15,7 @@ class SitemapPlugin extends AntPlugin
$pages = AntPages::getPages();
if (extension_loaded('dom')) {
$domDocument = new DOMDocument();
$domDocument = new DOMDocument('1.0', 'UTF-8');
$domDocument->formatOutput = true;
$domElement = $domDocument->createElement('urlset');
@ -47,7 +47,7 @@ class SitemapPlugin extends AntPlugin
die("AntCMS is unable to generate a sitemap without having the DOM extension loadded in PHP.");
}
}
public function getName(): string
{
return 'Sitemap';

View File

@ -1 +1 @@
class TinyZoom{constructor(e){let t=document.querySelectorAll(e);t.forEach(e=>{e.style.cursor="pointer",e.addEventListener("click",()=>{this.makeFullscreen(e)}),e.addEventListener("touchstart",t=>{t.preventDefault(),this.makeFullscreen(e)})})}makeFullscreen(e){let t=document.createElement("div");t.classList.add("fullscreen-image");let i=document.createElement("canvas"),n=i.getContext("2d");i.width=e.width,i.height=e.height,n.drawImage(e,0,0,e.width,e.height);var l=Math.max(document.documentElement.clientWidth||0,window.innerWidth||0),a=Math.max(document.documentElement.clientHeight||0,window.innerHeight||0);if(l>0)var d=e.width>l?l/e.width*.75:1;if(a>0)var r=e.height>a?a/e.height*.75:1;t.appendChild(i),document.body.appendChild(t),t.addEventListener("click",e=>{e.target===t&&t.remove()}),t.addEventListener("wheel",e=>{e.target===t&&e.preventDefault()});let s,h,o,c=1;function m(t){c*=t,i.style.transform=`scale(${c})`,n.clearRect(0,0,i.width,i.height),n.drawImage(e,0,0,e.width,e.height)}i.style.position="absolute",i.style.left=l/2-e.width/2+"px",i.style.top=a/2-e.height/2+"px",i.style.cursor="move",i.addEventListener("wheel",e=>{e.preventDefault();let t=e.deltaY>0?.9:1.1;m(t)}),i.addEventListener("mousedown",e=>{s=e.pageX-i.offsetLeft,h=e.pageY-i.offsetTop,o=!0}),i.addEventListener("mousemove",e=>{if(o){let t=e.pageX-s,n=e.pageY-h;i.style.left=`${t}px`,i.style.top=`${n}px`}}),i.addEventListener("mouseup",()=>{o=!1}),i.addEventListener("dblclick",e=>{m(e.shiftKey?.5:2)});var v=Math.min(1,d,r);1!=v&&m(v)}}window.addEventListener("load",()=>{new TinyZoom(".TinyZoom")});
class TinyZoom{constructor(e){let t=document.querySelectorAll(e);t.forEach(e=>{e.style.cursor="pointer",e.addEventListener("click",()=>{this.makeFullscreen(e)}),e.addEventListener("touchstart",t=>{t.preventDefault(),this.makeFullscreen(e)})})}makeFullscreen(e){let t=document.createElement("div");t.classList.add("fullscreen-image");let i=document.createElement("canvas"),n=i.getContext("2d"),l,a,d,s=window.devicePixelRatio||1;screen.orientation.type.startsWith("portrait"),i.style.maxWidth="85%",i.style.maxHeight="85%",i.width=e.width*s,i.height=e.height*s,n.scale(s,s),n.drawImage(e,0,0,e.width,e.height);var r=Math.max(document.documentElement.clientWidth||0,window.innerWidth||0),h=Math.max(document.documentElement.clientHeight||0,window.innerHeight||0),o=1.1*e.width>r?r/e.width*.9:1,c=1.1*e.height>h?h/e.height*.9:1;function m(t){s*=t,i.style.transform=`scale(${s})`,n.clearRect(0,0,i.width,i.height),n.drawImage(e,0,0,e.width,e.height)}t.appendChild(i),document.body.appendChild(t),t.addEventListener("click",e=>{e.target===t&&t.remove()}),t.addEventListener("wheel",e=>{e.target===t&&e.preventDefault()}),i.style.position="fixed",i.style.left=r/2-e.width/2+"px",i.style.top=h/2-e.height/2+"px",i.style.cursor="move",i.addEventListener("wheel",e=>{e.preventDefault();let t=e.deltaY>0?.9:1.1;m(t)}),i.addEventListener("mousedown",e=>{l=e.pageX-i.offsetLeft,a=e.pageY-i.offsetTop,d=!0}),i.addEventListener("mousemove",e=>{if(d){let t=e.pageX-l,n=e.pageY-a;i.style.left=`${t}px`,i.style.top=`${n}px`}}),i.addEventListener("mouseup",()=>{d=!1}),i.addEventListener("dblclick",e=>{m(e.shiftKey?.5:2)});var p=Math.min(1,o,c);1!=p&&(s=p,i.style.left=r/2-e.width*s/2+"px",i.style.top=h/2-e.height*s/2+"px",m(1))}}window.addEventListener("load",()=>{new TinyZoom(".TinyZoom")});