20 changed files with 272 additions and 76 deletions
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Web; |
||||
using Teknik.ViewModels; |
||||
|
||||
namespace Teknik.Areas.Profile.ViewModels |
||||
{ |
||||
public class ProfileViewModel : ViewModelBase |
||||
{ |
||||
} |
||||
} |
@ -1 +1 @@
@@ -1 +1 @@
|
||||
@using Teknik.Models |
||||
@model Teknik.Areas.Profile.ViewModels.ProfileViewModel |
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Web; |
||||
using System.Web.Mvc; |
||||
using Teknik.Areas.Upload.ViewModels; |
||||
using Teknik.Controllers; |
||||
|
||||
namespace Teknik.Areas.Upload.Controllers |
||||
{ |
||||
public class UploadController : DefaultController |
||||
{ |
||||
// GET: Upload/Upload
|
||||
[HttpGet] |
||||
[AllowAnonymous] |
||||
public ActionResult Index() |
||||
{ |
||||
return View(new UploadViewModel()); |
||||
} |
||||
// GET: Upload/Upload
|
||||
[HttpGet] |
||||
[AllowAnonymous] |
||||
public ActionResult Download(string url) |
||||
{ |
||||
return View(new UploadViewModel()); |
||||
} |
||||
|
||||
[HttpPost] |
||||
[AllowAnonymous] |
||||
[ValidateAntiForgeryToken] |
||||
public ActionResult Upload(string uploadID) |
||||
{ |
||||
return Json(new { result = "tempURL.png" }); |
||||
} |
||||
|
||||
[HttpPost] |
||||
[AllowAnonymous] |
||||
[ValidateAntiForgeryToken] |
||||
public ActionResult Delete(string url, string deleteKey) |
||||
{ |
||||
return Json(new { result = true }); |
||||
} |
||||
|
||||
[HttpPost] |
||||
[AllowAnonymous] |
||||
[ValidateAntiForgeryToken] |
||||
public ActionResult GenerateDeleteKey(string uploadID) |
||||
{ |
||||
return Json(new { result = "temp-delete-key" }); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
@model Teknik.Areas.Upload.ViewModels.UploadViewModel |
||||
|
||||
<script> |
||||
var generateDeleteKeyURL = '@Url.Action("GenerateDeleteKey", "Upload", new { area = "Upload" })'; |
||||
var uploadURL = '@Url.Action("Download", "Upload", new { area = "Upload", url = string.Empty })'; |
||||
var maxUploadSize = @(Model.Config.UploadConfig.MaxUploadSize / 100000); |
||||
</script> |
||||
|
||||
@Styles.Render("~/Content/upload") |
||||
|
||||
<div class="container"> |
||||
<div class="row text-center"> |
||||
<form action="@Url.Action("Upload", "Upload", new { area = "Upload" })" class="dropzone" id="TeknikUpload" name="TeknikUpload"> |
||||
@Html.AntiForgeryToken() |
||||
<div class="dz-message text-center" id="upload_message"> |
||||
<div class="row"> |
||||
<div class="col-sm-12"> |
||||
<h1>Drop your files here</h1> |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-sm-12"> |
||||
<h2>Or just click here</h2> |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-sm-12"> |
||||
<h3>Your Choice</h3> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div class="fallback text-center"> |
||||
<div class="row"> |
||||
<div class="col-sm-12"> |
||||
<input name="file" type="file" class="form-control" multiple /> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</form> |
||||
</div> |
||||
<br /> |
||||
<div class="progress"> |
||||
<div class="progress-bar progress-bar-success" id="progressBar" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 0%">0%</div> |
||||
</div> |
||||
<div class="container" id="upload-links"> |
||||
</div> |
||||
<br /> |
||||
<div class="well text-center">Each file is encrypted on upload using an AES-256-CBC cipher. If you wish to view the file decrypted, you must use the direct Teknik link.</div> |
||||
<div class="text-center"> |
||||
Useful Tools: <a href="http://git.teknik.io/Teknikode/Tools/src/master/Upload">Upload Scripts and Utilities</a> | <a href="https://github.com/jschx/poomf">Poomf Uploader</a> |
||||
<br /> |
||||
<br /> |
||||
You can now upload your screenshots automatically using <a href="https://github.com/KittyKatt/screenFetch">Screenfetch</a>! |
||||
</div> |
||||
</div> |
||||
|
||||
@Scripts.Render("~/bundles/upload") |
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Web; |
||||
using System.Web.Mvc; |
||||
|
||||
namespace Teknik |
||||
{ |
||||
public static class UrlExtensions |
||||
{ |
||||
/// <summary>
|
||||
/// Generates a full URL given the specified sub domain.
|
||||
/// If the subdomain is not 'dev', the Controller will be removed
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="sub"></param>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="controller"></param>
|
||||
/// <param name="routeValues"></param>
|
||||
/// <returns></returns>
|
||||
public static string SubAction(this UrlHelper url, string sub, string action, string controller, object routeValues) |
||||
{ |
||||
Uri requestUrl = url.RequestContext.HttpContext.Request.Url; |
||||
string host = url.RequestContext.HttpContext.Request.Url.Authority; |
||||
|
||||
string firstSub = string.Empty; |
||||
string paramSub = string.Empty; |
||||
string domain = host; |
||||
string rightUrl = string.Empty; |
||||
|
||||
// get current subdomain
|
||||
string curSub = string.Empty; |
||||
var split = host.Split('.'); // split the host by '.'
|
||||
if (split.Count() > 2) |
||||
{ |
||||
curSub = split[0]; |
||||
int index = host.IndexOf('.') + 1; |
||||
if (index >= 0 && index < host.Length) |
||||
domain = host.Substring(index, (host.Length - index)); |
||||
} |
||||
|
||||
// Grab the sub from parameters if it exists
|
||||
string subParam = url.RequestContext.HttpContext.Request.Params["sub"]; // A subdomain specified as a query parameter takes precedence over the hostname.
|
||||
|
||||
// If the param is not being used, we will use the curSub
|
||||
if (string.IsNullOrEmpty(subParam)) |
||||
{ |
||||
// If we are in dev, we need to keep it in dev
|
||||
firstSub = (curSub == "dev") ? "dev" : sub; |
||||
} |
||||
else |
||||
{ |
||||
// sub within param will always be on the dev subdomain
|
||||
firstSub = (string.IsNullOrEmpty(curSub)) ? string.Empty : "dev"; |
||||
} |
||||
rightUrl = url.Action(action, controller, routeValues); |
||||
|
||||
domain = (string.IsNullOrEmpty(firstSub)) ? domain : firstSub + "." + domain; |
||||
|
||||
string absoluteAction = string.Format("{0}://{1}{2}", url.RequestContext.HttpContext.Request.Url.Scheme, domain, rightUrl); |
||||
|
||||
return absoluteAction; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Dynamic; |
||||
using System.Linq; |
||||
using System.Web; |
||||
|
||||
namespace Teknik |
||||
{ |
||||
public static class Utility |
||||
{ |
||||
public static dynamic Merge(object item1, object item2) |
||||
{ |
||||
if (item1 == null || item2 == null) |
||||
return item1 ?? item2 ?? new ExpandoObject(); |
||||
|
||||
dynamic expando = new ExpandoObject(); |
||||
var result = expando as IDictionary<string, object>; |
||||
foreach (System.Reflection.PropertyInfo fi in item1.GetType().GetProperties()) |
||||
{ |
||||
result[fi.Name] = fi.GetValue(item1, null); |
||||
} |
||||
foreach (System.Reflection.PropertyInfo fi in item2.GetType().GetProperties()) |
||||
{ |
||||
result[fi.Name] = fi.GetValue(item2, null); |
||||
} |
||||
return result; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue