Skin repo skin creator

This commit is contained in:
Michael 2017-03-25 12:24:54 -04:00
parent aaebed46d5
commit c5fe379bc0
4 changed files with 57 additions and 2 deletions

View file

@ -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 });

View file

@ -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; }
}
}

View file

@ -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\" />

View file

@ -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>
}