This repository has been archived by the owner on Feb 16, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #99 Check the box in the pavlov server settings. Be aware thatthat this feature is not available for rented or im premise roles. Closes #100 You can import bans on every server. Closes #95 Be aware that you need to install https://wkhtmltopdf.org/ to get this function up and running. If you use it in discord you would need to change the url every time you post otherwise it will get cached. like &timeStamp=4466444 and than + 1 every time you send the link.
- Loading branch information
Showing
17 changed files
with
391 additions
and
66 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
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,51 @@ | ||
using System; | ||
|
||
namespace PavlovRconWebserver.Extensions | ||
{ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.Rendering; | ||
using Microsoft.AspNetCore.Mvc.ViewEngines; | ||
using Microsoft.AspNetCore.Mvc.ViewFeatures; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
|
||
namespace CC.Web.Helpers | ||
{ | ||
public static class ControllerExtensions | ||
{ | ||
public static async Task<string> RenderViewAsync<TModel>(this Controller controller, string viewName, TModel model, bool partial = false) | ||
{ | ||
if (string.IsNullOrEmpty(viewName)) | ||
{ | ||
viewName = controller.ControllerContext.ActionDescriptor.ActionName; | ||
} | ||
|
||
controller.ViewData.Model = model; | ||
|
||
using (var writer = new StringWriter()) | ||
{ | ||
IViewEngine viewEngine = controller.HttpContext.RequestServices.GetService(typeof(ICompositeViewEngine)) as ICompositeViewEngine; | ||
ViewEngineResult viewResult = viewEngine.FindView(controller.ControllerContext, viewName, !partial); | ||
|
||
if (viewResult.Success == false) | ||
{ | ||
return $"A view with the name {viewName} could not be found"; | ||
} | ||
|
||
ViewContext viewContext = new ViewContext( | ||
controller.ControllerContext, | ||
viewResult.View, | ||
controller.ViewData, | ||
controller.TempData, | ||
writer, | ||
new HtmlHelperOptions() | ||
); | ||
|
||
await viewResult.View.RenderAsync(viewContext); | ||
|
||
return writer.GetStringBuilder().ToString(); | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.