Cleaner way to get canonical URL
This commit is contained in:
parent
bb7050cf75
commit
ec250b0d05
3 changed files with 32 additions and 4 deletions
|
@ -95,6 +95,7 @@ class FrontController
|
||||||
'class' => 'index',
|
'class' => 'index',
|
||||||
'description' => 'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.',
|
'description' => 'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.',
|
||||||
'domain' => $uri->getScheme().'://'.$uri->getAuthority(),
|
'domain' => $uri->getScheme().'://'.$uri->getAuthority(),
|
||||||
|
'canonical' => $this->getCanonicalUrl($request),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -118,6 +119,7 @@ class FrontController
|
||||||
'title' => 'Supported websites',
|
'title' => 'Supported websites',
|
||||||
'description' => 'List of all supported websites from which Alltube Download '.
|
'description' => 'List of all supported websites from which Alltube Download '.
|
||||||
'can extract video or audio files',
|
'can extract video or audio files',
|
||||||
|
'canonical' => $this->getCanonicalUrl($request),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -139,6 +141,7 @@ class FrontController
|
||||||
'class' => 'password',
|
'class' => 'password',
|
||||||
'title' => 'Password prompt',
|
'title' => 'Password prompt',
|
||||||
'description' => 'You need a password in order to download this video with Alltube Download',
|
'description' => 'You need a password in order to download this video with Alltube Download',
|
||||||
|
'canonical' => $this->getCanonicalUrl($request),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -210,6 +213,7 @@ class FrontController
|
||||||
'description' => 'Download "'.$video->title.'" from '.$video->extractor_key,
|
'description' => 'Download "'.$video->title.'" from '.$video->extractor_key,
|
||||||
'protocol' => $protocol,
|
'protocol' => $protocol,
|
||||||
'config' => $this->config,
|
'config' => $this->config,
|
||||||
|
'canonical' => $this->getCanonicalUrl($request),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -258,6 +262,7 @@ class FrontController
|
||||||
'errors' => $exception->getMessage(),
|
'errors' => $exception->getMessage(),
|
||||||
'class' => 'video',
|
'class' => 'video',
|
||||||
'title' => 'Error',
|
'title' => 'Error',
|
||||||
|
'canonical' => $this->getCanonicalUrl($request),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -366,4 +371,27 @@ class FrontController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the canonical URL of the current page
|
||||||
|
* @param Request $request PSR-7 Request
|
||||||
|
* @return string URL
|
||||||
|
*/
|
||||||
|
private function getCanonicalUrl(Request $request)
|
||||||
|
{
|
||||||
|
$uri = $request->getUri();
|
||||||
|
$return = 'https://alltubedownload.net/';
|
||||||
|
|
||||||
|
$path = $uri->getPath();
|
||||||
|
if ($path != '/') {
|
||||||
|
$return .= $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = $uri->getQuery();
|
||||||
|
if (!empty($query)) {
|
||||||
|
$return .= '?'.$query;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
<link rel="stylesheet" href="{base_url|noscheme}/dist/main.css" />
|
<link rel="stylesheet" href="{base_url|noscheme}/dist/main.css" />
|
||||||
<title>AllTube Download{if isset($title)} - {$title|escape}{/if}</title>
|
<title>AllTube Download{if isset($title)} - {$title|escape}{/if}</title>
|
||||||
<link rel="canonical" href="//{$smarty.server.HTTP_HOST|cat:$smarty.server.REQUEST_URI|replace:{base_url|noscheme}:'http://www.alltubedownload.net'|escape}" />
|
<link rel="canonical" href="{$canonical}" />
|
||||||
<link rel="icon" href="{base_url|noscheme}/img/favicon.png" />
|
<link rel="icon" href="{base_url|noscheme}/img/favicon.png" />
|
||||||
<meta property="og:title" content="AllTube Download{if isset($title)} - {$title|escape}{/if}" />
|
<meta property="og:title" content="AllTube Download{if isset($title)} - {$title|escape}{/if}" />
|
||||||
<meta property="og:image" content="{base_url}/img/logo.png" />
|
<meta property="og:image" content="{base_url}/img/logo.png" />
|
||||||
|
|
0
tests/FrontControllerTest.php
Normal file
0
tests/FrontControllerTest.php
Normal file
Loading…
Add table
Add a link
Reference in a new issue