From 9afacc45acd3040240112e47805a076e6a0da7c1 Mon Sep 17 00:00:00 2001 From: Manuel Rojas Date: Mon, 23 Oct 2023 07:02:28 -0600 Subject: [PATCH 1/4] Adding twitter fixes --- .../html/dot-seo-meta-tags.service.spec.ts | 86 ++++++++++++++++++- .../html/dot-seo-meta-tags.service.ts | 22 +++-- .../dot-results-seo-tool.component.ts | 2 +- 3 files changed, 101 insertions(+), 9 deletions(-) diff --git a/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/content/services/html/dot-seo-meta-tags.service.spec.ts b/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/content/services/html/dot-seo-meta-tags.service.spec.ts index 9d15b6b4f024..52948c8a20f2 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/content/services/html/dot-seo-meta-tags.service.spec.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/content/services/html/dot-seo-meta-tags.service.spec.ts @@ -117,7 +117,9 @@ describe('DotSetMetaTagsService', () => { 'seo.rules.og-description.description.not.found': 'og:description meta tag, and Meta Description not found!', 'seo.rules.twitter-card-description.description.not.found': - 'twitter:description meta tag not found! Showing Description instead.' + 'twitter:description meta tag, and Meta Description not found!', + 'seo.rules.twitter-card-title.title.not.found': + 'twitter:title meta tag not found, and HTML Title not found!' }) }, DotUploadService @@ -616,4 +618,86 @@ describe('DotSetMetaTagsService', () => { done(); }); }); + + it('should found twitter:description meta tag not found! Showing Description instead.', (done) => { + const doc: Document = document.implementation.createDocument( + 'http://www.w3.org/1999/xhtml', + 'html', + null + ); + + const head = doc.createElement('head'); + doc.documentElement.appendChild(head); + + const metaDesc = document.createElement('meta'); + metaDesc.name = 'description'; + metaDesc.content = + 'Get down to Costa Rica this winter for some of the best surfing int he world. Large winter swell is pushing across the Pacific.'; + head.appendChild(metaDesc); + + service.getMetaTagsResults(doc).subscribe((value) => { + expect(value[8].items[0].message).toEqual( + 'twitter:description meta tag not found! Showing Description instead.' + ); + done(); + }); + }); + + it('should found twitter:description meta tag', (done) => { + const doc: Document = document.implementation.createDocument( + 'http://www.w3.org/1999/xhtml', + 'html', + null + ); + + const head = doc.createElement('head'); + doc.documentElement.appendChild(head); + + service.getMetaTagsResults(doc).subscribe((value) => { + expect(value[8].items[0].message).toEqual( + 'twitter:description meta tag, and Meta Description not found!' + ); + done(); + }); + }); + + it('should found twitter:title meta tag not found and HTML Title not found!', (done) => { + const doc: Document = document.implementation.createDocument( + 'http://www.w3.org/1999/xhtml', + 'html', + null + ); + + const head = doc.createElement('head'); + doc.documentElement.appendChild(head); + + service.getMetaTagsResults(doc).subscribe((value) => { + expect(value[7].items[0].message).toEqual( + 'twitter:title meta tag not found, and HTML Title not found!' + ); + done(); + }); + }); + + it('should found twitter:title meta tag, Showing HTML Title instead.', (done) => { + const doc: Document = document.implementation.createDocument( + 'http://www.w3.org/1999/xhtml', + 'html', + null + ); + + const head = doc.createElement('head'); + doc.documentElement.appendChild(head); + + const title = document.createElement('title'); + title.innerText = 'Costa Rica Special Offer'; + head.appendChild(title); + + service.getMetaTagsResults(doc).subscribe((value) => { + expect(value[7].items[0].message).toEqual( + 'twitter:title meta tag not found! Showing HTML Title instead.' + ); + done(); + }); + }); }); diff --git a/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/content/services/html/dot-seo-meta-tags.service.ts b/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/content/services/html/dot-seo-meta-tags.service.ts index 1162f327fe44..6a729eed4238 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/content/services/html/dot-seo-meta-tags.service.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/content/services/html/dot-seo-meta-tags.service.ts @@ -548,11 +548,13 @@ export class DotSeoMetaTagsService { const result: SeoRulesResult[] = []; const titleCardElements = metaTagsObject['twitterTitleElements']; const titleCard = metaTagsObject['twitter:title']; - const title = metaTagsObject['og:title']; - const titleElements = metaTagsObject['titleOgElements']; + const titleOg = metaTagsObject['og:title']; + const titleOgElements = metaTagsObject['titleOgElements']; + const title = metaTagsObject['title']; + const titleElements = metaTagsObject['titleElements']; if ( - title && + (title || titleOg) && this.dotSeoMetaTagsUtilService.areAllFalsyOrEmpty([titleCard, titleCardElements]) ) { result.push( @@ -567,7 +569,9 @@ export class DotSeoMetaTagsService { title, titleCard, titleElements, - titleCardElements + titleCardElements, + titleOgElements, + titleOg ]) ) { result.push( @@ -631,11 +635,13 @@ export class DotSeoMetaTagsService { const result: SeoRulesResult[] = []; const twitterDescriptionElements = metaTagsObject['twitterDescriptionElements']; const twitterDescription = metaTagsObject['twitter:description']; - const ogDescriptionElements = metaTagsObject['ogDescriptionElements']; + const ogDescriptionElements = metaTagsObject['descriptionOgElements']; const ogDescription = metaTagsObject['og:description']; + const descriptionElements = metaTagsObject['descriptionElements']; + const description = metaTagsObject['description']; if ( - ogDescription && + (description || ogDescription) && this.dotSeoMetaTagsUtilService.areAllFalsyOrEmpty([ twitterDescription, twitterDescriptionElements @@ -653,7 +659,9 @@ export class DotSeoMetaTagsService { twitterDescription, twitterDescriptionElements, ogDescriptionElements, - ogDescriptionElements + descriptionElements, + ogDescription, + description ]) ) { result.push( diff --git a/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/seo/components/dot-results-seo-tool/dot-results-seo-tool.component.ts b/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/seo/components/dot-results-seo-tool/dot-results-seo-tool.component.ts index a851a1a6876f..1fc7eaa4c995 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/seo/components/dot-results-seo-tool/dot-results-seo-tool.component.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/seo/components/dot-results-seo-tool/dot-results-seo-tool.component.ts @@ -94,7 +94,7 @@ export class DotResultsSeoToolComponent implements OnInit, OnChanges { const twitterTitle = twitterTitleProperties .map((property) => - this.seoOGTags[property]?.slice(0, SEO_LIMITS.MAX_TWITTER_DESCRIPTION_LENGTH) + this.seoOGTags[property]?.slice(0, SEO_LIMITS.MAX_TWITTER_TITLE_LENGTH) ) .find((value) => value !== undefined); From 9f0d01ceef3e6a12f5d37959e75dcccbf9c55a11 Mon Sep 17 00:00:00 2001 From: Manuel Rojas Date: Mon, 23 Oct 2023 07:43:39 -0600 Subject: [PATCH 2/4] #26193 Adding disabled for tab buttons --- .../dot-tab-buttons/dot-tab-buttons.component.html | 1 + .../dot-tab-buttons/dot-tab-buttons.component.scss | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/core-web/libs/ui/src/lib/dot-tab-buttons/dot-tab-buttons.component.html b/core-web/libs/ui/src/lib/dot-tab-buttons/dot-tab-buttons.component.html index 318941454d09..cf794af58662 100644 --- a/core-web/libs/ui/src/lib/dot-tab-buttons/dot-tab-buttons.component.html +++ b/core-web/libs/ui/src/lib/dot-tab-buttons/dot-tab-buttons.component.html @@ -19,6 +19,7 @@