mirror of https://github.com/Squidex/squidex.git
53 changed files with 743 additions and 147 deletions
@ -0,0 +1,44 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Microsoft.AspNetCore.Http; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
|
|||
namespace Squidex.Areas.IdentityServer.Views |
|||
{ |
|||
public static class Extensions |
|||
{ |
|||
public static string RootContentUrl(this IUrlHelper urlHelper, string contentPath) |
|||
{ |
|||
if (string.IsNullOrEmpty(contentPath)) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
if (contentPath[0] == '~') |
|||
{ |
|||
var segment = new PathString(contentPath.Substring(1)); |
|||
|
|||
var applicationPath = urlHelper.ActionContext.HttpContext.Request.PathBase; |
|||
|
|||
if (applicationPath.HasValue) |
|||
{ |
|||
var indexOfLastPart = applicationPath.Value.LastIndexOf('/'); |
|||
|
|||
if (indexOfLastPart >= 0) |
|||
{ |
|||
applicationPath = applicationPath.Value.Substring(0, indexOfLastPart); |
|||
} |
|||
} |
|||
|
|||
return applicationPath.Add(segment).Value; |
|||
} |
|||
|
|||
return contentPath; |
|||
} |
|||
} |
|||
} |
|||
@ -1,3 +1,4 @@ |
|||
@using Microsoft.AspNetCore.Identity |
|||
@using Squidex.Areas.IdentityServer.Views; |
|||
|
|||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
|||
|
|||
@ -0,0 +1,31 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Migrate_01; |
|||
using Squidex.Infrastructure.Log; |
|||
|
|||
namespace Squidex.Config.Startup |
|||
{ |
|||
public sealed class RebuilderHost : SafeHostedService |
|||
{ |
|||
private readonly RebuildRunner rebuildRunner; |
|||
|
|||
public RebuilderHost(IApplicationLifetime lifetime, ISemanticLog log, RebuildRunner rebuildRunner) |
|||
: base(lifetime, log) |
|||
{ |
|||
this.rebuildRunner = rebuildRunner; |
|||
} |
|||
|
|||
protected override Task StartAsync(ISemanticLog log, CancellationToken ct) |
|||
{ |
|||
return rebuildRunner.RunAsync(ct); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using Microsoft.AspNetCore.Mvc.Filters; |
|||
using Microsoft.AspNetCore.Mvc.Internal; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Options; |
|||
using Squidex.Domain.Apps.Entities.Assets; |
|||
|
|||
namespace Squidex.Pipeline |
|||
{ |
|||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] |
|||
public sealed class AssetRequestSizeLimitAttribute : Attribute, IFilterFactory, IOrderedFilter |
|||
{ |
|||
public int Order { get; set; } = 900; |
|||
|
|||
public bool IsReusable => true; |
|||
|
|||
public IFilterMetadata CreateInstance(IServiceProvider serviceProvider) |
|||
{ |
|||
var assetOptions = serviceProvider.GetService<IOptions<AssetOptions>>(); |
|||
|
|||
if (assetOptions?.Value.MaxSize > 0) |
|||
{ |
|||
var filter = serviceProvider.GetRequiredService<RequestSizeLimitFilter>(); |
|||
|
|||
filter.Bytes = assetOptions.Value.MaxSize; |
|||
|
|||
return filter; |
|||
} |
|||
else |
|||
{ |
|||
var filter = serviceProvider.GetRequiredService<DisableRequestSizeLimitFilter>(); |
|||
|
|||
return filter; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
<input class="form-control" type="text" #input |
|||
[style.background]="snapshot.value" |
|||
[style.color]="snapshot.foreground" |
|||
[placeholder]="placeholder" |
|||
[ngModel]="snapshot.value" |
|||
(ngModelChange)="writeValue($event)" |
|||
(focus)="modal.show()" (blur)="blur()" /> |
|||
|
|||
<div *sqxModalView="modal" [sqxModalTarget]="input" position="bottom-left"> |
|||
<div [style.background]="snapshot.value" |
|||
[cpToggle]="true" |
|||
[cpDialogDisplay]="'inline'" |
|||
[cpCancelButton]="false" |
|||
[colorPicker]="snapshot.value" |
|||
(colorPickerChange)="writeValue($event)"> |
|||
</div> |
|||
</div> |
|||
@ -0,0 +1,18 @@ |
|||
@import '_mixins'; |
|||
@import '_vars'; |
|||
|
|||
:host /deep/ { |
|||
.color-picker { |
|||
& { |
|||
border-color: $color-border; |
|||
} |
|||
|
|||
.hex-text { |
|||
.box { |
|||
input { |
|||
border-color: $color-input; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,59 @@ |
|||
/* |
|||
* Squidex Headless CMS |
|||
* |
|||
* @license |
|||
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
|||
*/ |
|||
|
|||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, forwardRef, Input } from '@angular/core'; |
|||
import { NG_VALUE_ACCESSOR } from '@angular/forms'; |
|||
|
|||
import { |
|||
MathHelper, |
|||
ModalModel, |
|||
StatefulControlComponent |
|||
} from '@app/framework/internal'; |
|||
|
|||
export const SQX_COLOR_PICKER_CONTROL_VALUE_ACCESSOR: any = { |
|||
provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => ColorPickerComponent), multi: true |
|||
}; |
|||
|
|||
interface State { |
|||
value?: string; |
|||
|
|||
foreground: string; |
|||
} |
|||
|
|||
@Component({ |
|||
selector: 'sqx-color-picker', |
|||
styleUrls: ['./color-picker.component.scss'], |
|||
templateUrl: './color-picker.component.html', |
|||
providers: [SQX_COLOR_PICKER_CONTROL_VALUE_ACCESSOR], |
|||
changeDetection: ChangeDetectionStrategy.OnPush |
|||
}) |
|||
export class ColorPickerComponent extends StatefulControlComponent<State, string> { |
|||
@Input() |
|||
public placeholder = ''; |
|||
|
|||
public modal = new ModalModel(); |
|||
|
|||
constructor(changeDetector: ChangeDetectorRef) { |
|||
super(changeDetector, { foreground: 'black' }); |
|||
} |
|||
|
|||
public writeValue(obj: any) { |
|||
let foreground = 'black'; |
|||
|
|||
if (MathHelper.toLuminance(MathHelper.parseColor(obj)!) < .5) { |
|||
foreground = 'white'; |
|||
} |
|||
|
|||
this.next(s => ({ ...s, value: obj, foreground })); |
|||
|
|||
this.callChange(obj); |
|||
} |
|||
|
|||
public blur() { |
|||
this.callTouched(); |
|||
} |
|||
} |
|||
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 19 KiB |
@ -0,0 +1,22 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
namespace Migrate_01 |
|||
{ |
|||
public sealed class RebuildOptions |
|||
{ |
|||
public bool Apps { get; set; } |
|||
|
|||
public bool Assets { get; set; } |
|||
|
|||
public bool Contents { get; set; } |
|||
|
|||
public bool Rules { get; set; } |
|||
|
|||
public bool Schemas { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,57 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.Options; |
|||
using Squidex.Infrastructure; |
|||
|
|||
namespace Migrate_01 |
|||
{ |
|||
public sealed class RebuildRunner |
|||
{ |
|||
private readonly Rebuilder rebuilder; |
|||
private readonly RebuildOptions rebuildOptions; |
|||
|
|||
public RebuildRunner(Rebuilder rebuilder, IOptions<RebuildOptions> rebuildOptions) |
|||
{ |
|||
Guard.NotNull(rebuilder, nameof(rebuilder)); |
|||
Guard.NotNull(rebuildOptions, nameof(rebuildOptions)); |
|||
|
|||
this.rebuilder = rebuilder; |
|||
this.rebuildOptions = rebuildOptions.Value; |
|||
} |
|||
|
|||
public async Task RunAsync(CancellationToken ct) |
|||
{ |
|||
if (rebuildOptions.Apps) |
|||
{ |
|||
await rebuilder.RebuildAppsAsync(ct); |
|||
} |
|||
|
|||
if (rebuildOptions.Schemas) |
|||
{ |
|||
await rebuilder.RebuildSchemasAsync(ct); |
|||
} |
|||
|
|||
if (rebuildOptions.Rules) |
|||
{ |
|||
await rebuilder.RebuildRulesAsync(ct); |
|||
} |
|||
|
|||
if (rebuildOptions.Assets) |
|||
{ |
|||
await rebuilder.RebuildAssetsAsync(ct); |
|||
} |
|||
|
|||
if (rebuildOptions.Contents) |
|||
{ |
|||
await rebuilder.RebuildContentAsync(ct); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue