This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
75 changed files
with
73 additions
and
105 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
55 changes: 9 additions & 46 deletions
55
src/Umbraco.Docs.Preview.App/Extensions/UmbracoDocsApplicationBuilderExtensions.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 |
---|---|---|
@@ -1,61 +1,24 @@ | ||
using System.IO; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.FileProviders; | ||
using Microsoft.Extensions.Logging; | ||
using Umbraco.Docs.Preview.App.MiscellaneousOurStuff; | ||
using Umbraco.Docs.Preview.App.Models; | ||
using Microsoft.Extensions.Options; | ||
using Umbraco.Docs.Preview.App.Options; | ||
|
||
namespace Umbraco.Docs.Preview.App.Extensions | ||
{ | ||
public static class UmbracoDocsApplicationBuilderExtensions | ||
{ | ||
public static IApplicationBuilder UseUmbracoDocsImageFileProviders(this IApplicationBuilder app) | ||
{ | ||
var serviceProvider = app.ApplicationServices; | ||
var settings = app.ApplicationServices.GetRequiredService<IOptions<UmbracoDocsOptions>>(); | ||
|
||
var tree = serviceProvider.GetRequiredService<DocumentationUpdater>().BuildSitemap(); | ||
|
||
var log = serviceProvider | ||
.GetRequiredService<ILoggerFactory>() | ||
.CreateLogger(typeof(UmbracoDocsApplicationBuilderExtensions)); | ||
|
||
var total = AddImageFileProviders(tree, app, log); | ||
log.LogInformation("Found {count} image directories for UmbracoDocs", total); | ||
|
||
log.LogWarning("Images from new documentation sub directories will not be served without a restart"); | ||
|
||
return app; | ||
} | ||
|
||
private static int AddImageFileProviders(UmbracoDocsTreeNode node, IApplicationBuilder app, ILogger log) | ||
{ | ||
var counter = 0; | ||
var path = Path.Combine(node.PhysicalPath, "images"); | ||
|
||
var requestPath = $"/documentation/{node.Path}/images" | ||
.Replace("//", "/"); // Hack for root UmbracoDocs folder | ||
|
||
if (Directory.Exists(path)) | ||
app.UseStaticFiles(new StaticFileOptions | ||
{ | ||
log.LogDebug("Adding file provider for {path}", path); | ||
|
||
app.UseStaticFiles(new StaticFileOptions | ||
{ | ||
FileProvider = new PhysicalFileProvider(path), | ||
RequestPath = requestPath | ||
}); | ||
|
||
++counter; | ||
} | ||
FileProvider = new PhysicalFileProvider(settings.Value.UmbracoDocsRootFolder), | ||
RequestPath = "/documentation" | ||
}); | ||
|
||
// Could add these to a composite? | ||
foreach (var child in node.Directories) | ||
{ | ||
counter += AddImageFileProviders(child, app, log); | ||
} | ||
|
||
return counter; | ||
return app; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,48 +1,71 @@ | ||
using System; | ||
using System.CommandLine; | ||
using System.CommandLine.Invocation; | ||
using System.IO; | ||
using System.Reflection; | ||
using Lamar.Microsoft.DependencyInjection; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Umbraco.Docs.Preview.App.Options; | ||
|
||
namespace Umbraco.Docs.Preview.App | ||
{ | ||
public class Program | ||
{ | ||
public static int Main(string[] args) | ||
{ | ||
var directory = Directory.GetCurrentDirectory(); | ||
if (!File.Exists(Path.Combine(directory, "index.md"))) | ||
var rootCommand = new RootCommand | ||
{ | ||
Console.Error.WriteLine("Fatal Error: current directory doesn't appear to be the UmbracoDocs repo."); | ||
return -1; | ||
} | ||
|
||
CreateHostBuilder(args) | ||
.Build() | ||
.Run(); | ||
new Argument | ||
{ | ||
Name = "path", | ||
Arity = new ArgumentArity(0, 1), | ||
Description = "Path to UmbracoDocs repository." | ||
} | ||
}; | ||
rootCommand.Name = "umbracodocs"; | ||
rootCommand.Description = "Run UmbracoDocs preview server"; | ||
rootCommand.Handler = CommandHandler.Create<string>(RunServer); | ||
|
||
return 0; | ||
return rootCommand.Invoke(args); | ||
} | ||
|
||
public static IHostBuilder CreateHostBuilder(string[] args) | ||
private static int RunServer(string path = null) | ||
{ | ||
// dotnet tools configure cwd as you would expect, but Host.CreateDefaultBuilder isn't expecting that | ||
// to be miles away from appsettings.json and wwwroot etc. | ||
// So more config, less convention for ContentRoot | ||
var applicationFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); | ||
path ??= Directory.GetCurrentDirectory(); | ||
|
||
var docsAbsolutePath = Path.GetFullPath(path); | ||
|
||
|
||
if (!File.Exists(Path.Combine(docsAbsolutePath!, "index.md"))) | ||
{ | ||
Console.Error.WriteLine("Fatal Error: current directory doesn't appear to be the UmbracoDocs repo."); | ||
return -1; | ||
} | ||
|
||
return Host.CreateDefaultBuilder(args) | ||
.UseContentRoot(applicationFolder) | ||
Host.CreateDefaultBuilder(new[] { path }) | ||
#if !DEBUG | ||
// dotnet tools configures cwd as you would expect, but Host.CreateDefaultBuilder isn't expecting that | ||
// to be miles away from appsettings.json and wwwroot etc. | ||
// So more prefer configuration over convention for ContentRoot (unless debugging). | ||
.UseContentRoot(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)) | ||
#endif | ||
.UseLamar() | ||
.UseConsoleLifetime() | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
#if !DEBUG | ||
webBuilder.UseEnvironment("Production"); | ||
#endif | ||
webBuilder.ConfigureServices(services => | ||
{ | ||
services.Configure<UmbracoDocsOptions>(cfg => cfg.UmbracoDocsRootFolder = docsAbsolutePath); | ||
}); | ||
webBuilder.UseStartup<Startup>(); | ||
}); | ||
|
||
}) | ||
.Build() | ||
.Run(); | ||
|
||
return 0; | ||
} | ||
} | ||
} |
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
Binary file removed
BIN
-2.55 MB
src/Umbraco.Docs.Preview.App/wwwroot/assets/css/fonts/icomoon/icomoon.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-17.6 KB
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/925px-Unknown_person.jpg
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-1000 Bytes
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/app-icons/Icon.png
Binary file not shown.
Binary file removed
BIN
-7.3 KB
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/app-icons/acme-tile-large.png
Binary file not shown.
Binary file removed
BIN
-3.91 KB
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/app-icons/acme-tile-medium.png
Binary file not shown.
Binary file removed
BIN
-2.37 KB
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/app-icons/acme-tile-small.png
Binary file not shown.
Binary file removed
BIN
-4.21 KB
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/app-icons/acme-tile-wide.png
Binary file not shown.
12 changes: 0 additions & 12 deletions
12
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/app-icons/browserconfig.xml
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-2.67 KB
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/app-icons/favicon.png
Binary file not shown.
Binary file removed
BIN
-1.85 KB
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/app-icons/icon-60.png
Binary file not shown.
Binary file removed
BIN
-2.67 KB
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/app-icons/icon-72.png
Binary file not shown.
Binary file removed
BIN
-2.67 KB
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/app-icons/icon-76.png
Binary file not shown.
Binary file removed
BIN
-3.45 KB
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/app-icons/tile.png
Binary file not shown.
Binary file removed
BIN
-2.67 KB
...Umbraco.Docs.Preview.App/wwwroot/assets/images/app-icons/touch-icon-192x192.png
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion
1
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/checkmark.svg
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion
1
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/copylink.svg
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file removed
BIN
-52.3 KB
...Preview.App/wwwroot/assets/images/documentation/Grid-layout-NO-SIDEBAR-rows.jpg
Binary file not shown.
Binary file removed
BIN
-52.2 KB
...braco.Docs.Preview.App/wwwroot/assets/images/documentation/Grid-layout-rows.jpg
Binary file not shown.
Binary file removed
BIN
-13.2 KB
....Docs.Preview.App/wwwroot/assets/images/documentation/Grid-layout-scenarios.jpg
Binary file not shown.
Binary file removed
BIN
-33.1 KB
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/documentation/cells.png
Binary file not shown.
Binary file removed
BIN
-88 Bytes
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/documentation/dirty-shade.png
Diff not rendered.
Binary file removed
BIN
-196 KB
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/documentation/editor.png
Diff not rendered.
Binary file removed
BIN
-15.8 KB
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/documentation/layouts.png
Diff not rendered.
Binary file removed
BIN
-152 Bytes
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/documentation/para.png
Diff not rendered.
Binary file removed
BIN
-20.2 KB
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/documentation/rows.png
Diff not rendered.
Binary file removed
BIN
-10.2 KB
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/documentation/settings.png
Diff not rendered.
Diff not rendered.
Binary file removed
BIN
-478 KB
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/download-bg-color-alt.png
Diff not rendered.
Binary file removed
BIN
-504 KB
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/download-bg-color.png
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
1 change: 0 additions & 1 deletion
1
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/highfive.svg
Diff not rendered.
Binary file removed
BIN
-491 Bytes
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/icon-add-on.png
Diff not rendered.
1 change: 0 additions & 1 deletion
1
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/icon-add-on.svg
Diff not rendered.
Binary file removed
BIN
-477 Bytes
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/icon-extending.png
Diff not rendered.
1 change: 0 additions & 1 deletion
1
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/icon-extending.svg
Diff not rendered.
Binary file removed
BIN
-412 Bytes
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/icon-getting-started.png
Diff not rendered.
1 change: 0 additions & 1 deletion
1
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/icon-getting-started.svg
Diff not rendered.
Binary file removed
BIN
-1.22 KB
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/icon-implementation.png
Diff not rendered.
1 change: 0 additions & 1 deletion
1
src/Umbraco.Docs.Preview.App/wwwroot/assets/images/icon-implementation.svg
Diff not rendered.
Oops, something went wrong.