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 @@ <Content Include="Views\Admin\CreateUser.cshtml" /> <Content Include="Views\Skins\ViewSkin.cshtml" /> <Content Include="Views\Skins\Index.cshtml" /> + <Content Include="Views\Skins\PostSkin.cshtml" /> </ItemGroup> <ItemGroup> <Folder Include="App_Data\" /> 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"; +} + +<h2>Create a skin</h2> + +<p>Want to post your skin to the repository? Alright, just fill out this form and we'll do everything for you.</p> + +@using (Html.BeginForm()) +{ + <div class="panel panel-danger"> + @Html.ValidationSummary() + </div> + @Html.AntiForgeryToken() + <table class="table"> + <tr style="width:35%;"> + <td><strong>Title:</strong></td> + <td>@Html.TextBoxFor(Model=>Model.Title, new{@class="form-control"})</td> + </tr> + <tr> + <td><strong>Short description:</strong><br/>This is a short summary of your skin that displays on the index page. Keep it under 500 characters.</td> + <td>@Html.TextBoxFor(Model => Model.ShortDescription, new { @class = "form-control" })</td> + </tr> + <tr> + <td><strong>Long description:</strong><br/>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.</td> + <td>@Html.TextBoxFor(Model => Model.Title, new { @class = "form-control" })</td> + </tr> + <tr> + <td><strong>Skin file:</strong><br/>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 <pre>My Documents\ShiftOS_Shared\skins</pre>.</td> + <td>@Html.EditorFor(Model=>Model.SkinFile, new { @class = "form-control" })</td> + </tr> + <tr> + <td><strong>Screenshot:</strong><br />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.</td> + <td>@Html.EditorFor(Model => Model.ScreenshotFile, new { @class = "form-control" })</td> + </tr> + <tr> + <td></td> + <td><input type="submit" value="Post!" class="btn btn-primary" /></td> + </tr> + </table> +} \ No newline at end of file