-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2039b5b
commit d9229a2
Showing
21 changed files
with
176 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Setup a Test Umbraco Instance | ||
|
||
1. Install a _specific version_ of `Umbraco.Templates` | ||
2. Scaffold a new project based on these templates. | ||
|
||
> The example below references the current LTS version of Umbraco, version 10. | ||
``` | ||
dotnet new install Umbraco.Templates::10.0.0 | ||
dotnet new umbraco --name Umbraco_10 | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
By default, static assets are made available in the following path: | ||
|
||
``` | ||
/_content/_NAMESPACE_/_PATH_/_FILE_ | ||
``` | ||
|
||
By setting the following value in your `.csproj`, you can ensure that the path above matches the path in your project: | ||
|
||
``` | ||
<StaticWebAssetBasePath>/</StaticWebAssetBasePath> | ||
``` |
5 changes: 0 additions & 5 deletions
5
Humble.Umbraco.Packages/Humble.RCL/wwwroot/App_Plugins/Humble/package.manifest
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
Humble.Umbraco.Packages/Humble.RCL/wwwroot/App_Plugins/Humble/test.cshtml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
alert("RCL is working!"); |
12 changes: 12 additions & 0 deletions
12
Humble.Umbraco.Packages/Humble.Umbraco.UI/TagHelpers/HelloWorldTagHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Microsoft.AspNetCore.Razor.TagHelpers; | ||
|
||
namespace Humble.Umbraco.UI.TagHelpers; | ||
|
||
public class HelloWorldTagHelper : TagHelper | ||
{ | ||
public override void Process(TagHelperContext context, TagHelperOutput output) | ||
{ | ||
output.TagName = "p"; | ||
output.Content.SetContent("Hello, World!"); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
Humble.Umbraco.Packages/Humble.Umbraco.UI/TagHelpers/ParserTagHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System.Reflection; | ||
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Razor.TagHelpers; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Umbraco.Cms.Core.Models.PublishedContent; | ||
using Umbraco.Cms.Core.Strings; | ||
using Umbraco.Cms.Core.Web; | ||
using Umbraco.Cms.Web.Common; | ||
using Umbraco.Extensions; | ||
|
||
namespace Humble.Umbraco.UI.TagHelpers; | ||
|
||
[HtmlTargetElement("humble-parser", TagStructure = TagStructure.NormalOrSelfClosing)] | ||
public class HumbleParserTagHelper : TagHelper | ||
{ | ||
private readonly IUmbracoContextAccessor _umbracoContextAccessor; | ||
private readonly UmbracoHelper _umbracoHelper; | ||
|
||
public HumbleParserTagHelper(IUmbracoContextAccessor umbracoContextAccessor, UmbracoHelper umbracoHelper) | ||
{ | ||
_umbracoContextAccessor = umbracoContextAccessor; | ||
_umbracoHelper = umbracoHelper; | ||
} | ||
|
||
public IHtmlEncodedString Content { get; set; } | ||
|
||
public override void Process(TagHelperContext context, TagHelperOutput output) | ||
{ | ||
output.TagName = null; | ||
var umbracoContext = _umbracoContextAccessor.GetRequiredUmbracoContext(); | ||
var contentService = umbracoContext.Content; | ||
|
||
if (contentService == null) | ||
{ | ||
return; | ||
} | ||
|
||
IPublishedContent content = _umbracoHelper.AssignedContentItem; // Set this based on your requirements | ||
|
||
var replacePattern = new Regex(@"{{([a-zA-Z]+)}}", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); | ||
var newContents = Content.ToString(); | ||
|
||
var matches = replacePattern.Matches(newContents); | ||
|
||
foreach (Match match in matches) | ||
{ | ||
string key = match.Groups[1].Value; | ||
var typeProperty = content.GetType().GetProperty(key, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public); | ||
|
||
if (typeProperty != null) | ||
{ | ||
newContents = newContents.Replace(match.Value, typeProperty.GetValue(content, null).ToString()); | ||
continue; | ||
} | ||
|
||
var contentProperty = content.GetProperty(key); | ||
if (contentProperty == null) continue; | ||
|
||
var value = contentProperty.GetValue(); | ||
if (value == null) continue; | ||
|
||
newContents = newContents.Replace(match.Value, value.ToString()); | ||
} | ||
|
||
output.Content.SetHtmlContent(newContents); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
Humble.Umbraco.Packages/Humble.Umbraco.UI/TagHelpers/ParserTagHelper.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
``` | ||
<humble-parser | ||
content="@yourHtmlEncodedString" /> | ||
``` |
38 changes: 38 additions & 0 deletions
38
Humble.Umbraco.Packages/Humble.Umbraco.UI/TagHelpers/PictureTagHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Razor.TagHelpers; | ||
using Umbraco.Cms.Core.Models; | ||
using Umbraco.Extensions; | ||
|
||
namespace Humble.Umbraco.UI.TagHelpers; | ||
|
||
[HtmlTargetElement("humble-picture", TagStructure = TagStructure.NormalOrSelfClosing)] | ||
public class PictureTagHelper : TagHelper | ||
{ | ||
public List<MediaWithCrops> MediaWithCropsList { get; set; } | ||
|
||
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) | ||
{ | ||
var content = await output.GetChildContentAsync(); | ||
var mediaSources = new List<string>(); | ||
|
||
foreach (var mediaWithCrops in MediaWithCropsList) | ||
{ | ||
// Determine which breakpoint to use based on the width of the image | ||
string breakpoint = "s"; | ||
|
||
// Get the URL for the specific breakpoint from the LocalCrops | ||
var cropData = mediaWithCrops.LocalCrops.GetCrop(breakpoint); | ||
var mediaUrl = mediaWithCrops.Url(); | ||
|
||
// Create a <source> element for each media source | ||
var mediaSource = $"<source media='(min-width: {cropData?.Width}px)' srcset='{mediaUrl}'>"; | ||
mediaSources.Add(mediaSource); | ||
} | ||
|
||
// Generate the <picture> element | ||
var pictureElement = $"<picture>{string.Join("", mediaSources)}</picture>"; | ||
output.TagName = null; | ||
output.Content.SetHtmlContent(pictureElement); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
Humble.Umbraco.Packages/Humble.Umbraco.UI/TagHelpers/PictureTagHelper.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
``` | ||
<humble-picture | ||
media-with-crops-list="@Model.MediaWithCropsList" /> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters