-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First working draft, yet without meta data
- Loading branch information
1 parent
935f7ab
commit 3d1a9e3
Showing
10 changed files
with
164 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using GenHTTP.Api.Content; | ||
using GenHTTP.Api.Content.IO; | ||
using GenHTTP.Api.Infrastructure; | ||
using GenHTTP.Modules.AutoLayout.Scanning; | ||
using System.Collections.Generic; | ||
|
||
namespace GenHTTP.Modules.AutoLayout.Provider | ||
{ | ||
|
||
public class AutoLayoutHandlerBuilder : IHandlerBuilder<AutoLayoutHandlerBuilder> | ||
{ | ||
private readonly List<IConcernBuilder> _Concerns = new(); | ||
|
||
private IResourceTree? _Tree; | ||
|
||
private HandlerRegistryBuilder? _Registry; | ||
|
||
private string[]? _Index; | ||
|
||
#region Functionality | ||
|
||
public AutoLayoutHandlerBuilder Tree(IResourceTree tree) | ||
{ | ||
_Tree = tree; | ||
return this; | ||
} | ||
|
||
public AutoLayoutHandlerBuilder Registry(HandlerRegistryBuilder registry) | ||
{ | ||
_Registry = registry; | ||
return this; | ||
} | ||
|
||
public AutoLayoutHandlerBuilder Index(params string[] index) | ||
{ | ||
_Index = index; | ||
return this; | ||
} | ||
|
||
public AutoLayoutHandlerBuilder Add(IConcernBuilder concern) | ||
{ | ||
_Concerns.Add(concern); | ||
return this; | ||
} | ||
|
||
public IHandler Build(IHandler parent) | ||
{ | ||
var tree = _Tree ?? throw new BuilderMissingPropertyException("tree"); | ||
|
||
var registry = _Registry ?? Resolvers.Default(); | ||
|
||
var index = _Index ?? new[] { "Index" }; | ||
|
||
return Concerns.Chain(parent, _Concerns, (p) => new AutoLayoutHandler(p, tree, registry.Build(), index)); | ||
} | ||
|
||
#endregion | ||
|
||
} | ||
|
||
} |
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,30 @@ | ||
using System.Threading.Tasks; | ||
|
||
using GenHTTP.Api.Content; | ||
using GenHTTP.Api.Content.IO; | ||
using GenHTTP.Api.Protocol; | ||
|
||
using GenHTTP.Modules.Basics; | ||
using GenHTTP.Modules.Placeholders; | ||
|
||
namespace GenHTTP.Modules.AutoLayout.Provider | ||
{ | ||
|
||
public class PlainProvider : IResourceHandlerProvider | ||
{ | ||
|
||
public bool Supports(IResource resource) | ||
{ | ||
var type = (resource.ContentType?.KnownType ?? resource.Name?.GuessContentType()); | ||
|
||
return (type == ContentType.TextPlain) || (type == ContentType.TextHtml); | ||
} | ||
|
||
public ValueTask<IHandlerBuilder> GetHandlerAsync(IResource resource) | ||
{ | ||
return new(Page.From(resource)); | ||
} | ||
|
||
} | ||
|
||
} |
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,16 @@ | ||
using GenHTTP.Api.Content.IO; | ||
using GenHTTP.Api.Infrastructure; | ||
using GenHTTP.Modules.AutoLayout.Provider; | ||
|
||
namespace GenHTTP.Modules.AutoLayout | ||
{ | ||
public static class TreeLayout | ||
{ | ||
|
||
public static AutoLayoutHandlerBuilder From(IResourceTree tree) => new AutoLayoutHandlerBuilder().Tree(tree); | ||
|
||
public static AutoLayoutHandlerBuilder From(IBuilder<IResourceTree> tree) => new AutoLayoutHandlerBuilder().Tree(tree.Build()); | ||
|
||
} | ||
|
||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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