update application and repository views to set <meta> description to improve search results

This commit is contained in:
Alec Merdler 2017-07-13 10:12:46 -04:00
parent 21ecc2eadd
commit a9c2ea608d
7 changed files with 65 additions and 52 deletions

View file

@ -16,21 +16,21 @@ provideRun.$inject = [
'MetaService',
];
export function provideRun($rootScope: QuayRunScope,
Restangular: any,
PlanService: any,
restangular: any,
planService: any,
$http: ng.IHttpService,
CookieService: any,
Features: any,
cookieService: any,
features: any,
$anchorScroll: ng.IAnchorScrollService,
MetaService: any): void {
metaService: any): void {
const defaultTitle: string = INJECTED_CONFIG['REGISTRY_TITLE'] || 'Quay Container Registry';
// Handle session security.
Restangular.setDefaultRequestParams(['post', 'put', 'remove', 'delete'],
restangular.setDefaultRequestParams(['post', 'put', 'remove', 'delete'],
{'_csrf_token': (<any>window).__token || ''});
// Handle session expiration.
Restangular.setErrorInterceptor(function(response) {
restangular.setErrorInterceptor(function(response) {
if (response !== undefined && response.status == 503) {
(<any>$('#cannotContactService')).modal({});
return false;
@ -59,20 +59,20 @@ export function provideRun($rootScope: QuayRunScope,
});
// Check if we need to redirect based on a previously chosen plan.
const result: boolean = PlanService.handleNotedPlan();
const result: boolean = planService.handleNotedPlan();
// Check to see if we need to show a redirection page.
const redirectUrl: string = CookieService.get('quay.redirectAfterLoad');
CookieService.clear('quay.redirectAfterLoad');
const redirectUrl: string = cookieService.get('quay.redirectAfterLoad');
cookieService.clear('quay.redirectAfterLoad');
if (!result && redirectUrl && redirectUrl.indexOf((<any>window).location.href) == 0) {
(<any>window).location = redirectUrl;
return;
}
$rootScope.$watch('description', function(description: string) {
$rootScope.$watch('description', (description: string) => {
if (!description) {
description = `Hosted private docker repositories. Includes full user management and history.
description = `Hosted private Docker repositories. Includes full user management and history.
Free for public repositories.`;
}
@ -82,18 +82,7 @@ export function provideRun($rootScope: QuayRunScope,
$('#descriptionTag').attr('content', description);
});
// Listen for scope changes and update the title and description accordingly.
$rootScope.$watch(function() {
const title: string = MetaService.getTitle($rootScope.currentPage) || defaultTitle;
$rootScope.title = title;
const description: string = MetaService.getDescription($rootScope.currentPage) || '';
if ($rootScope.description != description) {
$rootScope.description = description;
}
});
$rootScope.$on('$routeChangeSuccess', function(event, current, previous) {
$rootScope.$on('$routeChangeSuccess', (event, current, previous) => {
$rootScope.current = current.$$route;
$rootScope.currentPage = current;
$rootScope.pageClass = '';
@ -102,7 +91,7 @@ export function provideRun($rootScope: QuayRunScope,
var pageClass: string | Function = current.$$route.pageClass || '';
if (typeof pageClass != 'string') {
pageClass = pageClass(Features);
pageClass = pageClass(features);
}
$rootScope.pageClass = pageClass;
@ -112,6 +101,16 @@ export function provideRun($rootScope: QuayRunScope,
$anchorScroll();
});
// Listen for route changes and update the title and description accordingly.
$rootScope.$on('$routeChangeSuccess', async(event, current, previous) => {
$rootScope.title = metaService.getTitle(current) || defaultTitle;
const description = await metaService.getDescription(current);
if ($rootScope.description != description) {
$rootScope.description = description;
}
});
var initallyChecked: boolean = false;
(<any>window).__isLoading = function() {
if (!initallyChecked) {