Skip to content

Commit 5584d12

Browse files
committed
Bug Fixes
1 parent f8f30e0 commit 5584d12

File tree

4 files changed

+419
-90
lines changed

4 files changed

+419
-90
lines changed

MetaMomentum/Client/src/property-editors/meta-momentum/meta-momentum.element.ts

Lines changed: 85 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,63 @@ export default class MetaMomentumPropertyEditorUIElement extends UmbLitElement i
7676

7777
constructor() {
7878
super();
79-
80-
79+
80+
8181
this.consumeContext(UMB_DOCUMENT_WORKSPACE_CONTEXT, (_instance) => {
8282

8383
this.workspaceContext = _instance;
84-
84+
85+
//this.value has been loaded, so we can do any migration or initialisation required here
86+
87+
if (!this.value) {
88+
this.value = {
89+
title: "",
90+
description: "",
91+
noIndex: false,
92+
shareTitle: "",
93+
shareDescription: "",
94+
shareImage: undefined,
95+
default: {
96+
title: "",
97+
description: "",
98+
},
99+
share: {
100+
title: "",
101+
description: "",
102+
image: undefined,
103+
},
104+
};
105+
106+
}
107+
108+
109+
// Migrate old image format if needed
110+
111+
if (this.value.share?.image) {
112+
let testOldImgFormat: any = this.value.share.image as any;
113+
if (testOldImgFormat?.key) {
114+
var share = {
115+
116+
...this.value.share,
117+
...{ image: testOldImgFormat.key }
118+
};
119+
this.value = { ...this.value, ...{ share: share } };
120+
121+
}
122+
}
123+
124+
125+
85126
this.initValue();
86-
127+
87128
this.initNodeUrl();
88129

89130

90-
//;
91-
// this.workspaceContext.urls?.subscribe((data) => {
92-
// debugger;
93-
// var previousNodeUrl = data;
94-
// });
131+
//;
132+
// this.workspaceContext.urls?.subscribe((data) => {
133+
// debugger;
134+
// var previousNodeUrl = data;
135+
// });
95136

96137

97138

@@ -106,6 +147,7 @@ export default class MetaMomentumPropertyEditorUIElement extends UmbLitElement i
106147

107148
const imageFields = [...(this.#config?.fallbackImageFields ?? [])];
108149

150+
if (!context) return; //for some reason the context is undefined sometimes
109151
// Keep track of the name field separately
110152
this.observe(context.name, (name) => {
111153
console.log("Setting fallbackValue: name to " + name);
@@ -169,7 +211,7 @@ export default class MetaMomentumPropertyEditorUIElement extends UmbLitElement i
169211

170212
});
171213

172-
214+
173215

174216
});
175217

@@ -180,7 +222,7 @@ export default class MetaMomentumPropertyEditorUIElement extends UmbLitElement i
180222
});
181223

182224

183-
225+
184226

185227

186228
}
@@ -191,30 +233,27 @@ export default class MetaMomentumPropertyEditorUIElement extends UmbLitElement i
191233
initValue() {
192234

193235

194-
if (!this.value) {
195-
this.value = {
196-
title: "",
197-
description: "",
198-
noIndex: false,
199-
shareTitle: "",
200-
shareDescription: "",
201-
shareImage: undefined,
202-
default: {
203-
title: "",
204-
description: "",
205-
},
206-
share: {
207-
title: "",
208-
description: "",
209-
image: undefined,
210-
},
211-
};
236+
//if (!this.value) {
237+
// this.value = {
238+
// title: "",
239+
// description: "",
240+
// noIndex: false,
241+
// shareTitle: "",
242+
// shareDescription: "",
243+
// shareImage: undefined,
244+
// default: {
245+
// title: "",
246+
// description: "",
247+
// },
248+
// share: {
249+
// title: "",
250+
// description: "",
251+
// image: undefined,
252+
// },
253+
// };
212254

213-
}
255+
//}
214256

215-
// This is for backwards compatibility. Previous versions stored the media as a UDI string, and we now just use the guid
216-
//TODO: come back and check backwards compatibility
217-
//this.value = { ...this.value, ...{shareImage: this.value.shareImage?.convertUdiToGuid() } };
218257

219258

220259
//this.#updateShareImageUrls();
@@ -226,12 +265,12 @@ export default class MetaMomentumPropertyEditorUIElement extends UmbLitElement i
226265
// Updates the preview values based on the current value and fallback values
227266
#updatePreviewValues() {
228267
this.initValue();
229-
let title = this.#getFallbackStringValue(this.#config?.fallbackTitleFields, this.value.default?.title);
230-
let description = this.#getFallbackStringValue(this.#config?.fallbackDescriptionFields, this.value.default.description);
268+
let title = this.#getFallbackStringValue(this.#config?.fallbackTitleFields, this.value?.default?.title);
269+
let description = this.#getFallbackStringValue(this.#config?.fallbackDescriptionFields, this.value?.default?.description);
231270

232271

233-
let shareTitle = this.#getFallbackStringValue(this.#config?.fallbackTitleFields, this.value.share.title, this.value.default.title);
234-
let shareDescription = this.#getFallbackStringValue(this.#config?.fallbackDescriptionFields, this.value.share.description, this.value.default.description);
272+
let shareTitle = this.#getFallbackStringValue(this.#config?.fallbackTitleFields, this.value?.share?.title, this.value?.default?.title);
273+
let shareDescription = this.#getFallbackStringValue(this.#config?.fallbackDescriptionFields, this.value?.share?.description, this.value?.default?.description);
235274

236275
this.value = { ...this.value, ...{ title: title, description: description, shareTitle: shareTitle, shareDescription: shareDescription } };
237276
}
@@ -241,11 +280,12 @@ export default class MetaMomentumPropertyEditorUIElement extends UmbLitElement i
241280
let result: string = "";
242281
this.initValue();
243282

244-
if (customValue !== undefined && customValue !== "") {
283+
if (customValue) {
245284
return customValue;
246-
} else if (customFallbackValue !== null && customFallbackValue !== "") {
285+
} else if (customFallbackValue) {
247286
return customFallbackValue;
248287
} else {
288+
//fallback to external fields
249289
for (let i = 0; i < (fieldAliases?.length ?? 0); i++) {
250290

251291
let field = fieldAliases![i];
@@ -359,8 +399,8 @@ export default class MetaMomentumPropertyEditorUIElement extends UmbLitElement i
359399

360400
var share = { ...this.value.share, ...{ image: newShareImageValue } };
361401
this.value = { ...this.value, ...{ share: share } };
362-
363-
402+
403+
364404

365405
await this.#updateShareImage();
366406
//Notify Umbraco that the value has changed to do IsDirty Check
@@ -383,7 +423,7 @@ export default class MetaMomentumPropertyEditorUIElement extends UmbLitElement i
383423
// [this.value.share!.image!], 0, 0
384424
//);
385425

386-
426+
387427

388428
//if (value?.share?.image !== undefined && value.share.image !== null) {
389429
// this.value = {
@@ -414,12 +454,14 @@ export default class MetaMomentumPropertyEditorUIElement extends UmbLitElement i
414454

415455
const unique = this.value?.shareImage !== undefined ? this.value?.shareImage : undefined;
416456

417-
418457
console.log(unique)
419458
if (unique == undefined || unique == "") {
420459
return;
421460
}
422461

462+
463+
464+
423465
let imageData = (
424466
await this.imagingRepository.requestThumbnailUrls(
425467
[unique],

MetaMomentum/MetaMomentum.csproj

Lines changed: 82 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,84 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
2-
<PropertyGroup>
3-
<TargetFramework>net9.0</TargetFramework>
4-
<Nullable>enable</Nullable>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<StaticWebAssetBasePath>/</StaticWebAssetBasePath>
7-
<Version>3.0.0.3-alpha</Version>
8-
</PropertyGroup>
9-
10-
<PropertyGroup>
11-
<PackageId>MetaMomentum</PackageId>
12-
<Product>MetaMomentum</Product>
13-
<Title>MetaMomentum</Title>
14-
</PropertyGroup>
15-
16-
17-
<ItemGroup>
18-
<PackageReference Include="Umbraco.Cms.Web.Website" Version="14.3.4" />
19-
<PackageReference Include="Umbraco.Cms.Web.Common" Version="14.3.4" />
20-
<PackageReference Include="Umbraco.Cms.Api.Common" Version="14.3.4" />
21-
<PackageReference Include="Umbraco.Cms.Api.Management" Version="14.3.4" />
22-
</ItemGroup>
23-
24-
<ItemGroup>
25-
<!-- Dont include the client folder as part of packaging nuget build -->
26-
<Compile Remove="Composers\**" />
27-
<Compile Remove="Controllers\**" />
28-
<Content Remove="Client\**" />
29-
<Content Remove="Composers\**" />
30-
<Content Remove="Controllers\**" />
31-
<EmbeddedResource Remove="Composers\**" />
32-
<EmbeddedResource Remove="Controllers\**" />
33-
<None Remove="Composers\**" />
34-
<None Remove="Controllers\**" />
35-
<Compile Remove="Constants.cs" />
36-
37-
<!-- However make the Umbraco-package.json included for dotnet pack or nuget package and visible to the solution -->
38-
<None Include="Client\public\umbraco-package.json" Pack="false" />
39-
</ItemGroup>
40-
41-
<ItemGroup>
42-
<Folder Include="wwwroot\App_Plugins\" />
43-
<Folder Include="wwwroot\App_Plugins\MetaMomentum\" />
44-
</ItemGroup>
45-
2+
<PropertyGroup>
3+
<TargetFramework>net9.0</TargetFramework>
4+
<Nullable>enable</Nullable>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<StaticWebAssetBasePath>/</StaticWebAssetBasePath>
7+
</PropertyGroup>
8+
9+
<PropertyGroup>
10+
<Version>3.0.0.3-beta</Version>
11+
<PackageId>MetaMomentum</PackageId>
12+
<Title>MetaMomentum</Title>
13+
<Description>Creates a Meta DataType for Umbraco to 14 to manage Search Engine results, Open Graph and Twitter Cards</Description>
14+
<Company>Digital Momentum</Company>
15+
<Product>MetaMomentum for Umbraco to 14+</Product>
16+
<Authors>David Sheiles</Authors>
17+
<Copyright>Copyright © 2020-2025</Copyright>
18+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
19+
<PackageProjectUrl>https://github.com/DigitalMomentum/MetaMomentum</PackageProjectUrl>
20+
<PackageIcon>MetaMomentum-logo.png</PackageIcon>
21+
<PackageIconUrl>https://user-images.githubusercontent.com/12960162/114866380-d1c98680-9e36-11eb-92d4-a78c1dbf5def.png</PackageIconUrl>
22+
<RepositoryUrl>https://github.com/DigitalMomentum/MetaMomentum</RepositoryUrl>
23+
<RepositoryType>git</RepositoryType>
24+
<PackageTags>Umbraco seo twitter opengraph Umbraco14 Umbraco15 Umbraco16 Datatype PropertyEditor dotnetcore dotnet8 umbraco-marketplace</PackageTags>
25+
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
26+
<PackageReadmeFile>readme.nuget.md</PackageReadmeFile>
27+
<Nullable>disable</Nullable>
28+
<PackageReleaseNotes>
29+
- Upgraded to support Umbraco 14 - 16
30+
- Moved from Angular JS to Web Components for the backoffice UI
31+
- Moved from HTML views to TagHelpers for rendering meta tags
32+
- performance improvements and bug fixes
33+
</PackageReleaseNotes>
34+
35+
</PropertyGroup>
36+
37+
38+
39+
40+
<ItemGroup>
41+
<PackageReference Include="Umbraco.Cms.Web.Website" Version="14.3.4" />
42+
<PackageReference Include="Umbraco.Cms.Web.Common" Version="14.3.4" />
43+
<PackageReference Include="Umbraco.Cms.Api.Common" Version="14.3.4" />
44+
<PackageReference Include="Umbraco.Cms.Api.Management" Version="14.3.4" />
45+
</ItemGroup>
46+
47+
48+
<ItemGroup>
49+
50+
<None Include="..\GithubFiles\Logo\MetaMomentum-logo.png">
51+
<Pack>True</Pack>
52+
<PackagePath>\</PackagePath>
53+
</None>
54+
<None Include="..\readme.nuget.md">
55+
<Pack>True</Pack>
56+
<PackagePath>\</PackagePath>
57+
</None>
58+
</ItemGroup>
59+
60+
61+
62+
<ItemGroup>
63+
<!-- Dont include the client folder as part of packaging nuget build -->
64+
<Compile Remove="Composers\**" />
65+
<Compile Remove="Controllers\**" />
66+
<Content Remove="Client\**" />
67+
<Content Remove="Composers\**" />
68+
<Content Remove="Controllers\**" />
69+
<EmbeddedResource Remove="Composers\**" />
70+
<EmbeddedResource Remove="Controllers\**" />
71+
<None Remove="Composers\**" />
72+
<None Remove="Controllers\**" />
73+
<Compile Remove="Constants.cs" />
74+
75+
<!-- However make the Umbraco-package.json included for dotnet pack or nuget package and visible to the solution -->
76+
<None Include="Client\public\umbraco-package.json" Pack="false" />
77+
</ItemGroup>
78+
79+
<ItemGroup>
80+
<Folder Include="wwwroot\App_Plugins\" />
81+
<Folder Include="wwwroot\App_Plugins\MetaMomentum\" />
82+
</ItemGroup>
83+
4684
</Project>

Readme.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ The easiest way to use MetaMomentum is though the help of Tag Helpers.
8787
In your _ViewImports.cshtml file add the following line:
8888
```c#
8989
@addTagHelper *, MetaMomentum
90+
@using MetaMomentum.Models
9091
```
9192

9293
Then in your header you can add the following tag helper to do the heavy lifting and add all the meta tags for you:
@@ -184,11 +185,11 @@ Attributes:
184185
##### V2.2:
185186
- Update UI to use the new Umbraco UI Library
186187
- RTE / Html fallbacks now strip the HTML tags
187-
- Bug Fixes and performance inprovements
188+
- Bug Fixes and performance improvements
188189
-
189190
##### V2.1.1:
190-
- Bugfix: Umbraco displays "Discard Changes?" when changing bewteen social previews
191-
- Featue: Allow hiding the "No Index" toggle via settings
191+
- Bugfix: Umbraco displays "Discard Changes?" when changing between social previews
192+
- Feature: Allow hiding the "No Index" toggle via settings
192193

193194
##### V2.1:
194195
- Split Compiled DLL into separate MetaMomentum.Core project

0 commit comments

Comments
 (0)