From c5fe379bc02b18a6b84e10a5e24a99f6e5ce39d8 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 25 Mar 2017 12:24:54 -0400 Subject: [PATCH] Skin repo skin creator --- Project-Unite/Controllers/SkinsController.cs | 12 +++++- Project-Unite/Models/Skin.cs | 4 ++ Project-Unite/Project-Unite.csproj | 1 + Project-Unite/Views/Skins/PostSkin.cshtml | 42 ++++++++++++++++++++ 4 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 Project-Unite/Views/Skins/PostSkin.cshtml diff --git a/Project-Unite/Controllers/SkinsController.cs b/Project-Unite/Controllers/SkinsController.cs index 0b6b732..d451c5e 100644 --- a/Project-Unite/Controllers/SkinsController.cs +++ b/Project-Unite/Controllers/SkinsController.cs @@ -51,8 +51,16 @@ namespace Project_Unite.Controllers skin.FullDescription = model.LongDescription; skin.UserId = User.Identity.GetUserId(); skin.VersionId = ""; - skin.DownloadUrl = Path.Combine("~/Uploads", model.SkinFile.FileName); - model.SkinFile.SaveAs(Path.Combine(Server.MapPath("~/Uploads"), model.SkinFile.FileName)); + string repoFolder = $"~/Uploads/{ACL.UserNameRaw(skin.UserId)}/SkinFiles"; + string screenshotFolder = $"~/Uploads/{ACL.UserNameRaw(skin.UserId)}/Screenshots"; + skin.DownloadUrl = Path.Combine(repoFolder, model.SkinFile.FileName); + model.SkinFile.SaveAs(Path.Combine(Server.MapPath(repoFolder), model.SkinFile.FileName)); + + if (model.ScreenshotFile != null && model.ScreenshotFile.ContentLength > 0) + { + skin.ScreenshotUrl = Path.Combine(screenshotFolder, model.ScreenshotFile.FileName); + model.ScreenshotFile.SaveAs(Path.Combine(Server.MapPath(screenshotFolder), model.ScreenshotFile.FileName)); + } db.Skins.Add(skin); db.SaveChanges(); return RedirectToAction("ViewSkin", new { id = skin.Name }); diff --git a/Project-Unite/Models/Skin.cs b/Project-Unite/Models/Skin.cs index 5144ccd..b860518 100644 --- a/Project-Unite/Models/Skin.cs +++ b/Project-Unite/Models/Skin.cs @@ -68,5 +68,9 @@ namespace Project_Unite.Models [Required] [DataType(DataType.Upload)] public HttpPostedFileBase SkinFile { get; set; } + + [DataType(DataType.Upload)] + public HttpPostedFileBase ScreenshotFile { get; set; } + } } \ No newline at end of file diff --git a/Project-Unite/Project-Unite.csproj b/Project-Unite/Project-Unite.csproj index a891dc7..09c07a5 100644 --- a/Project-Unite/Project-Unite.csproj +++ b/Project-Unite/Project-Unite.csproj @@ -524,6 +524,7 @@ + diff --git a/Project-Unite/Views/Skins/PostSkin.cshtml b/Project-Unite/Views/Skins/PostSkin.cshtml new file mode 100644 index 0000000..840d3ac --- /dev/null +++ b/Project-Unite/Views/Skins/PostSkin.cshtml @@ -0,0 +1,42 @@ +@model Project_Unite.Models.CreateSkinViewModel +@{ + ViewBag.Title = "Create skin - Skin Repository"; +} + +

Create a skin

+ +

Want to post your skin to the repository? Alright, just fill out this form and we'll do everything for you.

+ +@using (Html.BeginForm()) +{ +
+ @Html.ValidationSummary() +
+ @Html.AntiForgeryToken() + + + + + + + + + + + + + + + + + + + + + + + + + +
Title:@Html.TextBoxFor(Model=>Model.Title, new{@class="form-control"})
Short description:
This is a short summary of your skin that displays on the index page. Keep it under 500 characters.
@Html.TextBoxFor(Model => Model.ShortDescription, new { @class = "form-control" })
Long description:
This is a longer description for your skin. You can use Markdown to style it - use this to add notes, extra screenshots, etc, for your skin. It is displayed in the "view skin" page.
@Html.TextBoxFor(Model => Model.Title, new { @class = "form-control" })
Skin file:
This is the actual skin - you can upload it to the repository and we'll host it for you. Skins are exported by the Skin Loader into
My Documents\ShiftOS_Shared\skins
.
@Html.EditorFor(Model=>Model.SkinFile, new { @class = "form-control" })
Screenshot:
Here you can upload a main screenshot to show on the repo index and view skin pages. This isn't required, but is recommended so that users can see what your skin looks like before applying it.
@Html.EditorFor(Model => Model.ScreenshotFile, new { @class = "form-control" })
+} \ No newline at end of file