1.0.5-rc20-alpha9 : ansi2html helper
This commit is contained in:
parent
46a33ba374
commit
2d98f51412
9 changed files with 99 additions and 12 deletions
|
|
@ -1,6 +1,9 @@
|
|||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
|
|
@ -20,6 +23,32 @@ namespace Yavsc.Controllers
|
|||
_context = context;
|
||||
}
|
||||
|
||||
[Route("~/Git/sources/{*path}")]
|
||||
public IActionResult Sources (string path)
|
||||
{
|
||||
if (path == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
/*
|
||||
GitRepositoryReference gitRepositoryReference = await _context.GitRepositoryReference.SingleAsync(m => m.Path == path);
|
||||
if (gitRepositoryReference == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
*/
|
||||
var info = Startup.GitOptions.FileProvider.GetFileInfo(path);
|
||||
if (!info.Exists)
|
||||
return HttpNotFound();
|
||||
var stream = info.CreateReadStream();
|
||||
if (path.EndsWith(".log")) return File(stream,"text/html");
|
||||
if (path.EndsWith(".html")) return File(stream,"text/html");
|
||||
if (path.EndsWith(".cshtml")) return File(stream,"text/razor-csharp");
|
||||
if (path.EndsWith(".cs")) return File(stream,"text/csharp");
|
||||
return File(stream,"application/octet-stream");
|
||||
}
|
||||
|
||||
// GET: Git
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
|
|
@ -50,6 +79,7 @@ namespace Yavsc.Controllers
|
|||
return View();
|
||||
}
|
||||
|
||||
|
||||
// POST: Git/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using Microsoft.AspNet.FileProviders;
|
|||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.StaticFiles;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Yavsc.Abstract.FileSystem;
|
||||
using Yavsc.ViewModels.Auth;
|
||||
|
||||
|
|
@ -30,8 +31,6 @@ namespace Yavsc
|
|||
FileProvider = new PhysicalFileProvider(AbstractFileSystemHelpers.UserFilesDirName),
|
||||
RequestPath = new PathString(Constants.UserFilesPath),
|
||||
EnableDirectoryBrowsing = env.IsDevelopment(),
|
||||
|
||||
|
||||
};
|
||||
UserFilesOptions.EnableDefaultFiles=true;
|
||||
UserFilesOptions.StaticFileOptions.ServeUnknownFileTypes=true;
|
||||
|
|
@ -58,13 +57,16 @@ namespace Yavsc
|
|||
var gitdirinfo = new DirectoryInfo(Startup.SiteSetup.GitRepository);
|
||||
GitDirName = gitdirinfo.FullName;
|
||||
if (!gitdirinfo.Exists) gitdirinfo.Create();
|
||||
|
||||
GitOptions = new FileServerOptions()
|
||||
{
|
||||
FileProvider = new PhysicalFileProvider(GitDirName),
|
||||
RequestPath = new PathString(Constants.GitPath),
|
||||
EnableDirectoryBrowsing = env.IsDevelopment()
|
||||
EnableDirectoryBrowsing = env.IsDevelopment(),
|
||||
};
|
||||
GitOptions.DefaultFilesOptions.DefaultFileNames.Add("index.md");
|
||||
GitOptions.StaticFileOptions.ServeUnknownFileTypes = true;
|
||||
logger.LogInformation( $"{GitDirName}");
|
||||
GitOptions.StaticFileOptions.OnPrepareResponse+= OnPrepareGitRepoResponse;
|
||||
|
||||
app.UseFileServer(UserFilesOptions);
|
||||
|
||||
|
|
@ -73,5 +75,14 @@ namespace Yavsc
|
|||
app.UseFileServer(GitOptions);
|
||||
app.UseStaticFiles();
|
||||
}
|
||||
|
||||
static void OnPrepareGitRepoResponse(StaticFileResponseContext context)
|
||||
{
|
||||
|
||||
if (context.File.Name.EndsWith(".ansi.log"))
|
||||
{
|
||||
context.Context.Response.Redirect("/Git"+context.Context.Request.Path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,10 @@
|
|||
<dependencies>
|
||||
<dependency id="Yavsc.Abstract" version="$version$"></dependency>
|
||||
<dependency id="Yavsc.Server" version="$version$"></dependency>
|
||||
</dependencies>
|
||||
<dependency id="Microsoft.Extensions.Logging" version="1.0.0-rc1-final" />
|
||||
<dependency id="Microsoft.Extensions.Configuration.Abstractions" version="1.0.0-rc1-final" />
|
||||
<dependency id="Microsoft.Extensions.Options" version="0.0.1-alpha" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="bin/$config$/dnx451/Yavsc.dll" target="lib/portable-net45+win8+wp8+wpa81+Xamarin.Mac+MonoAndroid10+MonoTouch10+Xamarin.iOS10" />
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@
|
|||
"emitEntryPoint": true,
|
||||
"outputName": "Yavsc",
|
||||
"compile": {
|
||||
"include": "*.cs",
|
||||
"exclude": [
|
||||
"wwwroot",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"contrib"
|
||||
]
|
||||
],
|
||||
"include": "*.cs"
|
||||
},
|
||||
"embed": [
|
||||
"Resources/**/*.resx"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue