Skip to content

v2 #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

v2 #22

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
478 changes: 478 additions & 0 deletions Novicell.Umbraco.OEmbed.Web/.gitignore

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions Novicell.Umbraco.OEmbed.Web/Composer/AdvanceOEmbedComposer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Novicell.OEmbed.Web.Manifest;
using Umbraco.Cms.Core.Composing;

namespace Novicell.OEmbed.Web.Composer
{
public class AdvanceOEmbedComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.ManifestFilters().Append<AdvanceOEmbedManifestFilter>();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Umbraco.Cms.Core.Manifest;

namespace Novicell.OEmbed.Web.Manifest
{
/// <inheritdoc />
public class AdvanceOEmbedManifestFilter : IManifestFilter
{
/// <inheritdoc />
public void Filter(List<PackageManifest> manifests)
{
manifests.Add(new PackageManifest
{
PackageName = Novicell.OEmbed.Core.Constants.Package.Alias,
BundleOptions = BundleOptions.Independent,
Scripts = new[]
{
Core.Constants.Package.PluginFolder + "Scripts/Controller/OEmbed.Controller.js"
},
Stylesheets = new[]
{
Core.Constants.Package.PluginFolder + "Styles/OEmbed.css"
},
Version = Novicell.OEmbed.Core.Constants.Package.Version
});
}
}
}
34 changes: 34 additions & 0 deletions Novicell.Umbraco.OEmbed.Web/Novicell.OEmbed.Web.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Umbraco.Cms" Version="10.1.0" />
</ItemGroup>

<ItemGroup>
<!-- Opt-in to app-local ICU to ensure consistent globalization APIs across different platforms -->
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" />
<ProjectReference Include="..\Novicell.Umbraco.OEmbed\Novicell.OEmbed.Core.csproj" />
<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" Condition="$(RuntimeIdentifier.StartsWith('linux')) or $(RuntimeIdentifier.StartsWith('win')) or ('$(RuntimeIdentifier)' == '' and !$([MSBuild]::IsOSPlatform('osx')))" />
</ItemGroup>

<ItemGroup>
<Folder Include="wwwroot\App_Plugins\Lang\" />
</ItemGroup>

<PropertyGroup>
<!-- Razor files are needed for the backoffice to work correctly -->
<CopyRazorGenerateFilesToPublishDirectory>true</CopyRazorGenerateFilesToPublishDirectory>
</PropertyGroup>

<PropertyGroup>
<!-- Remove RazorCompileOnBuild and RazorCompileOnPublish when not using ModelsMode InMemoryAuto -->
<RazorCompileOnBuild>false</RazorCompileOnBuild>
<RazorCompileOnPublish>false</RazorCompileOnPublish>
</PropertyGroup>

</Project>
19 changes: 19 additions & 0 deletions Novicell.Umbraco.OEmbed.Web/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Novicell.OEmbed.Web
{
public class Program
{
public static void Main(string[] args)
=> CreateHostBuilder(args)
.Build()
.Run();

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureUmbracoDefaults()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStaticWebAssets();
webBuilder.UseStartup<Startup>();
});
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:6278",
"sslPort": 44348
"applicationUrl": "http://localhost:61969",
"sslPort": 44393
}
},
"profiles": {
Expand All @@ -15,12 +16,14 @@
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Umbraco.Web.UI.NetCore": {
"Umbraco.Web.UI": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:44393;http://localhost:61969",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:44348;http://localhost:6278"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.Services;

namespace Novicell.OEmbed.Web.PropertyEditors
{
/// <summary>
/// Represents a AdvanceOEmbed property editor.
/// </summary>
[DataEditor(
alias: Novicell.OEmbed.Core.Constants.Package.Alias,
name: Novicell.OEmbed.Core.Constants.Package.Name,
view: Novicell.OEmbed.Core.Constants.Package.PluginFolder + "ombed.propertyeditor.html",
Group = Umbraco.Cms.Core.Constants.PropertyEditors.Groups.Media,
Icon = "icon-picture",
ValueType = ValueTypes.Json)]
public class AdvanceOEmbedPrropertyEditor: DataEditor
{
/// <summary>
/// Initializes a new instance of the <see cref="AdvanceOEmbedPrropertyEditor"/> class.
/// </summary>
public AdvanceOEmbedPrropertyEditor(IDataValueEditorFactory dataValueEditorFactory)
: base(dataValueEditorFactory)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Extensions;

namespace Novicell.Umbraco.OEmbed.Website
namespace Novicell.OEmbed.Web
{
public class Startup
{
private readonly IWebHostEnvironment _env;
private readonly IConfiguration _config;

/// <summary>
/// Initializes a new instance of the <see cref="Startup"/> class.
/// Initializes a new instance of the <see cref="Startup" /> class.
/// </summary>
/// <param name="webHostEnvironment">The Web Host Environment</param>
/// <param name="config">The Configuration</param>
/// <param name="webHostEnvironment">The web hosting environment.</param>
/// <param name="config">The configuration.</param>
/// <remarks>
/// Only a few services are possible to be injected here https://github.com/dotnet/aspnetcore/issues/9337
/// Only a few services are possible to be injected here https://github.com/dotnet/aspnetcore/issues/9337.
/// </remarks>
public Startup(IWebHostEnvironment webHostEnvironment, IConfiguration config)
{
Expand All @@ -29,24 +20,27 @@ public Startup(IWebHostEnvironment webHostEnvironment, IConfiguration config)
}

/// <summary>
/// Configures the services
/// Configures the services.
/// </summary>
/// <param name="services">The services.</param>
/// <remarks>
/// This method gets called by the runtime. Use this method to add services to the container.
/// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
/// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940.
/// </remarks>
public void ConfigureServices(IServiceCollection services)
{
services.AddUmbraco(_env, _config)
.AddBackOffice()
.AddBackOffice()
.AddWebsite()
.AddComposers()
.Build();
}

/// <summary>
/// Configures the application
/// Configures the application.
/// </summary>
/// <param name="app">The application builder.</param>
/// <param name="env">The web hosting environment.</param>
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
@using Umbraco.Cms.Web.Common.PublishedModels;
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.Site>
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.Frontpage>
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
@{
Layout = null;
var home = Model.Descendant<Home>();
this.Context.Response.Redirect(home.Url());
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockListModel>
@{
if (!Model.Any()) { return; }
if (Model?.Any() != true) { return; }
}
<div class="umb-block-list">
@foreach (var block in Model)
{
if (block?.ContentUdi == null) { continue; }
var data = block.Content;
@Html.Partial("BlockList/Components/" + data.ContentType.Alias, block)

@await Html.PartialAsync("blocklist/Components/" + data.ContentType.Alias, block)
}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,31 @@
Razor helpers located at the bottom of this file
*@

@if (Model != null && Model.GetType() == typeof(JObject) && Model.sections != null)
@if (Model is JObject && Model?.sections is not null)
{
var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1;

<div class="umb-grid">
@if (oneColumn)
{
foreach (var section in Model.sections) {
foreach (var section in Model.sections)
{
<div class="grid-section">
@foreach (var row in section.rows)
{
renderRow(row);
}
</div>
}
}else {
}
else
{
<div class="row clearfix">
@foreach (var s in Model.sections) {
@foreach (var sec in Model.sections)
{
<div class="grid-section">
<div class="col-md-@s.grid column">
@foreach (var row in s.rows)
<div class="col-md-@sec.grid column">
@foreach (var row in sec.rows)
{
renderRow(row);
}
Expand All @@ -39,38 +43,46 @@
</div>
}

@functions {
private void renderRow(dynamic row)
@functions{

private async Task renderRow(dynamic row)
{
<div @RenderElementAttributes(row)>
<div class="row clearfix">
@foreach ( var area in row.areas ) {
@foreach (var area in row.areas)
{
<div class="col-md-@area.grid column">
<div @RenderElementAttributes(area)>
@foreach (var control in area.controls) {
if (control !=null && control.editor != null && control.editor.view != null ) {
<text>@Html.Partial("grid/editors/base", (object)control)</text>
@foreach (var control in area.controls)
{
if (control?.editor?.view != null)
{
<text>@await Html.PartialAsync("grid/editors/base", (object)control)</text>
}
}
</div>
</div>}
</div>
}
</div>
</div>
}
}

@functions {
@functions{

public static HtmlString RenderElementAttributes(dynamic contentItem)
{
var attrs = new List<string>();
JObject cfg = contentItem.config;

if(cfg != null)
if (cfg != null)
{
foreach (JProperty property in cfg.Properties())
{
var propertyValue = HttpUtility.HtmlAttributeEncode(property.Value.ToString());
attrs.Add(property.Name + "=\"" + propertyValue + "\"");
}
}

JObject style = contentItem.styles;

Expand Down
Loading