Browse Source

Added ability to create vaults.

Added preventing viewing of Paste if it was password protected.
Added download increments for each item.
Added checking for paste expiration.
Added not showing upload if it was encrypted client side.
tags/2.0.6
Teknikode 3 years ago
parent
commit
efc7f7dae6

+ 1
- 1
Teknik/App_Start/BundleConfig.cs View File

@@ -16,7 +16,7 @@ namespace Teknik
// Set if we are using Cdn
bundles.UseCdn = config.UseCdn;

BundleTable.EnableOptimizations = true;
BundleTable.EnableOptimizations = false;
#if !DEBUG
BundleTable.EnableOptimizations = true;
#endif

+ 183
- 6
Teknik/Areas/Vault/Controllers/VaultController.cs View File

@@ -1,11 +1,16 @@
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Teknik.Areas.Paste;
using Teknik.Areas.Users.Models;
using Teknik.Areas.Users.Utility;
using Teknik.Areas.Vault.Models;
using Teknik.Areas.Vault.ViewModels;
using Teknik.Attributes;
using Teknik.Configuration;
using Teknik.Controllers;
using Teknik.Models;
using Teknik.Utilities;
@@ -17,18 +22,14 @@ namespace Teknik.Areas.Vault.Controllers
{
private TeknikEntities db = new TeknikEntities();

[AllowAnonymous]
public ActionResult Create()
{
return View();
}

[AllowAnonymous]
public ActionResult ViewVault(string id)
{
Models.Vault foundVault = db.Vaults.Where(v => v.Url == id).FirstOrDefault();
if (foundVault != null)
{
ViewBag.Title = foundVault.Title + " - Vault";

VaultViewModel model = new VaultViewModel();

model.Url = foundVault.Url;
@@ -36,11 +37,187 @@ namespace Teknik.Areas.Vault.Controllers
model.Description = foundVault.Description;
model.DateCreated = foundVault.DateCreated;
model.DateEdited = foundVault.DateEdited;

if (foundVault.Items.Any())
{
foreach (VaultItem item in foundVault.Items)
{
if (item.GetType().BaseType == typeof(UploadItem))
{
UploadItem upload = (UploadItem)item;
// Increment Views
upload.Upload.Downloads += 1;
db.Entry(upload.Upload).State = EntityState.Modified;
db.SaveChanges();
}
else if (item.GetType().BaseType == typeof(PasteItem))
{
PasteItem paste = (PasteItem)item;
// Increment Views
paste.Paste.Views += 1;
db.Entry(paste.Paste).State = EntityState.Modified;
db.SaveChanges();

// Check Expiration
if (PasteHelper.CheckExpiration(paste.Paste))
{
db.Pastes.Remove(paste.Paste);
db.SaveChanges();
break;
}
}

model.Items.Add(item);
}
}
model.Items = foundVault.Items.ToList();

return View(model);
}
return Redirect(Url.SubRouteUrl("error", "Error.Http404"));
}

[HttpGet]
[AllowAnonymous]
public ActionResult NewVault()
{
ViewBag.Title = "Create Vault";
NewVaultViewModel model = new NewVaultViewModel();
return View(model);
}

public ActionResult NewVaultFromUploads(List<string> urls)
{
ViewBag.Title = "Create Vault";
NewVaultViewModel model = new NewVaultViewModel();

foreach (string url in urls)
{
if (IsValidItem("Upload", url))
{
NewVaultItemViewModel item = new NewVaultItemViewModel();
item.url = url;
model.items.Add(item);
}
}

return View("~/Areas/Vault/Views/Vault/NewVault.cshtml", model);
}

[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult CreateVault(NewVaultViewModel model)
{
if (model != null)
{
if (!string.IsNullOrEmpty(model.title))
{
Vault.Models.Vault newVault = db.Vaults.Create();
// Create a new ID
string url = StringHelper.RandomString(Config.VaultConfig.UrlLength);
while (db.Vaults.Where(v => v.Url == url).FirstOrDefault() != null)
{
url = StringHelper.RandomString(Config.VaultConfig.UrlLength);
}
newVault.Url = url;
newVault.DateCreated = DateTime.Now;
newVault.Title = model.title;
newVault.Description = model.description;
if (User.Identity.IsAuthenticated)
{
User user = UserHelper.GetUser(db, User.Identity.Name);
if (user != null)
{
newVault.UserId = user.UserId;
}
}

// Add/Verify items
if (model.items.Any())
{
foreach (NewVaultItemViewModel item in model.items)
{
if (IsValidItem(item.type, item.url))
{
switch (item.type.ToLower())
{
case "upload":
UploadItem newUpload = new UploadItem();
newUpload.DateAdded = DateTime.Now;
newUpload.Title = item.title;
newUpload.Description = item.description;
newUpload.UploadId = db.Uploads.Where(u => u.Url == item.url).FirstOrDefault().UploadId;
newVault.Items.Add(newUpload);
break;
case "paste":
PasteItem newPaste = new PasteItem();
newPaste.DateAdded = DateTime.Now;
newPaste.Title = item.title;
newPaste.Description = item.description;
newPaste.PasteId = db.Pastes.Where(p => p.Url == item.url).FirstOrDefault().PasteId;
newVault.Items.Add(newPaste);
break;
default:
return Json(new { error = new { message = "You have an invalid item type: " + item.type } });
}
}
else
{
return Json(new { error = new { message = "You have an invalid item URL: " + item.url } });
}
}
}

// Add and save the new vault
db.Vaults.Add(newVault);
db.SaveChanges();
return Json(new { result = new { url = Url.SubRouteUrl("v", "Vault.ViewVault", new { id = url }) } });
}
return Json(new { error = new { message = "You must supply a Title" } });
}
return Json(new { error = new { message = "Invalid Parameters" } });
}

[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult ValidateItem(string type, string url)
{
if (IsValidItem(type, url))
{
return Json(new { result = new { valid = true } });
}
else
{
return Json(new { error = new { message = "Invalid URL Id for this Item" } });
}
}

private bool IsValidItem(string type, string url)
{
bool valid = false;
if (!string.IsNullOrEmpty(type) && !string.IsNullOrEmpty(url))
{
switch (type.ToLower())
{
case "upload":
Upload.Models.Upload foundUpload = db.Uploads.Where(u => u.Url == url).FirstOrDefault();
if (foundUpload != null)
{
valid = true;
}
break;
case "paste":
Paste.Models.Paste foundPaste = db.Pastes.Where(p => p.Url == url).FirstOrDefault();
if (foundPaste != null)
{
valid = true;
}
break;
}
}
return valid;
}
}
}

+ 145
- 0
Teknik/Areas/Vault/Scripts/Vault.js View File

@@ -0,0 +1,145 @@
$(document).ready(function () {
$('#newItem').on('show.bs.modal', function (e) {
var newDiv = $('#newItem');
newDiv.find("#item_title").val("");
newDiv.find("#item_description").val("");
newDiv.find("#item_type").val("Upload");
newDiv.find("#item_url").val("");

newDiv.find('#item_error').hide();
newDiv.find("#item_error_msg").html('');
});

$('#editItem').on('show.bs.modal', function (e) {
var itemID = $(e.relatedTarget).attr("id");
var itemDiv = $('#vault-item-' + itemID);
var title = itemDiv.find("#item-title").text();
var description = itemDiv.find("#item-description").text();

var editDiv = $('#editItem');
editDiv.find('#item_id').val(itemID);
editDiv.find("#item_title").val(title);
editDiv.find("#item_description").val(description);

editDiv.find('#item_error').hide();
editDiv.find("#item_error_msg").html('');
});

$("#new_item_submit").click(function () {
var newDiv = $('#newItem');
var title = newDiv.find("#item_title").val();
var description = newDiv.find("#item_description").val();
var type = newDiv.find('#item_type').val();
var url = newDiv.find('#item_url').val();

// First Validation
if (title == null || title == '') {
newDiv.find("#item_error").show();
newDiv.find("#item_error_msg").html('You must supply a Title');
return false;
}
$.ajax({
type: "POST",
url: validateItemURL,
data: AddAntiForgeryToken({ type: type, url: url }),
success: function (response) {
if (response.result) {
itemCount++;

// Add a new item to the main page
var itemDiv = $('#item-template').clone();
itemDiv.attr('id', 'vault-item-' + itemCount);
itemDiv.addClass('vault-item');
itemDiv.find('#item-title').html(title);
itemDiv.find('#item-description').html(description);
itemDiv.find('#item-type').html(type);
itemDiv.find('#item-url').html(url);

if (description == null || description == '') {
itemDiv.find('.panel-footer').hide();
}

itemDiv.find('#edit-item').attr('id', itemCount);

itemDiv.find('#remove-item').click(function () {
itemDiv.remove();
});

$('#vault-items').append(itemDiv);

$('#newItem').modal('hide');
}
else {
newDiv.find("#item_error").show();
newDiv.find("#item_error_msg").html(response.error.message);
}
}
});
return false;
});

$("#edit_item_submit").click(function () {
var itemDiv = $('#editItem');
var id = itemDiv.find('#item_id').val();
var title = itemDiv.find("#item_title").val();
var description = itemDiv.find("#item_description").val();

// First Validation
if (title == null || title == '') {
itemDiv.find("#item_error").show();
itemDiv.find("#item_error_msg").html('You must supply a Title');
return false;
}

var origDiv = $('#vault-item-' + id);
origDiv.find('#item-title').html(title);
origDiv.find('#item-description').html(description);

if (description == null || description == '') {
origDiv.find('.panel-footer').hide();
}
else {
origDiv.find('.panel-footer').show();
}

$('#editItem').modal('hide');
return false;
});

$("#submit").click(function () {
var title = $("#title").val();
var description = $("#description").val();
var items = [];

$(".vault-item").each(function () {
var itemTitle = $(this).find("#item-title").text();
var itemDescription = $(this).find("#item-description").text();
var itemType = $(this).find('#item-type').text();
var itemUrl = $(this).find('#item-url').text();
var item = { title: itemTitle, description: itemDescription, type: itemType, url: itemUrl };
items.push(item);
});

// First Validation
if (title == null || title == '') {
$("#top_msg").css('display', 'inline', 'important');
$("#top_msg").html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>You must supply a Title</div>');
return false;
}
$.ajax({
type: "POST",
url: createVaultURL,
data: AddAntiForgeryToken({ title: title, description: description, items: items }),
success: function (response) {
if (response.result) {
window.location = response.result.url;
}
else {
$("#top_msg").css('display', 'inline', 'important');
$("#top_msg").html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>' + response.error.message + '</div>');
}
}
});
return false;
});
});

+ 12
- 2
Teknik/Areas/Vault/VaultAreaRegistration.cs View File

@@ -20,11 +20,11 @@ namespace Teknik.Areas.Vault
{
Config config = Config.Load();
context.MapSubdomainRoute(
"Vault.Create",
"Vault.NewVault",
new List<string>() { "vault", "v" }, // Subdomains
new List<string>() { config.Host }, // domains
"",
new { controller = "Vault", action = "Create" },
new { controller = "Vault", action = "NewVault" },
new[] { typeof(Controllers.VaultController).Namespace }
);

@@ -37,12 +37,22 @@ namespace Teknik.Areas.Vault
new[] { typeof(Controllers.VaultController).Namespace }
);

context.MapSubdomainRoute(
"Vault.Action",
new List<string>() { "vault", "v" }, // Subdomains
new List<string>() { config.Host }, // domains
"Action/{controller}/{action}",
new { controller = "Vault", action = "NewVault" },
new[] { typeof(Controllers.VaultController).Namespace }
);

// Register style bundles
BundleTable.Bundles.Add(new CdnStyleBundle("~/Content/vault", config.CdnHost).Include(
"~/Areas/Vault/Content/Vault.css"));

// Register Script Bundle
BundleTable.Bundles.Add(new CdnScriptBundle("~/bundles/vault", config.CdnHost).Include(
"~/Scripts/jquery.blockUI.js",
"~/Areas/Vault/Scripts/Vault.js"));
}
}

+ 0
- 23
Teknik/Areas/Vault/ViewModels/CreateVaultViewModel.cs View File

@@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Teknik.Areas.Vault.Models;
using Teknik.ViewModels;

namespace Teknik.Areas.Vault.ViewModels
{
public class CreateVaultViewModel : ViewModelBase
{
public string Title { get; set; }
public string Description { get; set; }
public List<VaultItem> Items { get; set; }

public CreateVaultViewModel()
{
Title = string.Empty;
Description = string.Empty;
Items = new List<VaultItem>();
}
}
}

+ 24
- 0
Teknik/Areas/Vault/ViewModels/NewVaultItemViewModel.cs View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Teknik.ViewModels;

namespace Teknik.Areas.Vault.ViewModels
{
public class NewVaultItemViewModel : ViewModelBase
{
public string title { get; set; }
public string description { get; set; }
public string type { get; set; }
public string url { get; set; }

public NewVaultItemViewModel()
{
title = string.Empty;
description = string.Empty;
type = "Upload";
url = string.Empty;
}
}
}

+ 23
- 0
Teknik/Areas/Vault/ViewModels/NewVaultViewModel.cs View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Teknik.Areas.Vault.Models;
using Teknik.ViewModels;

namespace Teknik.Areas.Vault.ViewModels
{
public class NewVaultViewModel : ViewModelBase
{
public string title { get; set; }
public string description { get; set; }
public List<NewVaultItemViewModel> items { get; set; }

public NewVaultViewModel()
{
title = string.Empty;
description = string.Empty;
items = new List<NewVaultItemViewModel>();
}
}
}

+ 0
- 3
Teknik/Areas/Vault/Views/Vault/Create.cshtml View File

@@ -1,3 +0,0 @@
@model Teknik.Areas.Vault.ViewModels.CreateVaultViewModel



+ 226
- 0
Teknik/Areas/Vault/Views/Vault/NewVault.cshtml View File

@@ -0,0 +1,226 @@
@model Teknik.Areas.Vault.ViewModels.NewVaultViewModel

@using Teknik.Utilities
@using Teknik.Areas.Vault.ViewModels

@Styles.Render("~/Content/vault")

<script type="text/javascript">

var validateItemURL = '@Url.SubRouteUrl("vault", "Vault.Action", new { action = "ValidateItem" })';
var createVaultURL = '@Url.SubRouteUrl("vault", "Vault.Action", new { action = "CreateVault" })';


var itemCount = @Model.items.Count();

</script>

<div class="container">
@if (Model.Error)
{
<div class="row">
<div class="col-sm-10 col-sm-offset-1 text-center">
<div class="alert alert-danger" role="alert">@Model.ErrorMessage</div>
</div>
</div>
}

<div class="modal fade" id="newItem" tabindex="-1" role="dialog" aria-labelledby="newItemLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form class="form" action="##" method="post" id="addItem" enctype="multipart/form-data">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
<h4 class="modal-title" id="newItemLabel">Add an Item</h4>
</div>
<div class="modal-body">
<div class="row" id="item_error" style="display: none;">
<div class="col-sm-10 col-sm-offset-1 text-center">
<div class="alert alert-danger" role="alert" id="item_error_msg"></div>
</div>
</div>
<div class="row">
<div class="form-group col-sm-12">
<label for="item_title"><h4>Title</h4></label>
<input class="form-control" name="item_title" id="item_title" placeholder="Descriptive Title" title="enter a title for the item." type="text" />
</div>
</div>
<div class="row">
<div class="form-group col-sm-12">
<label for="item_description"><h4>Description</h4></label>
<textarea class="form-control wmd-input" name="item_description" id="item_description" placeholder="Optional" title="enter what the item is about." rows="5"></textarea>
</div>
</div>
<div class="row">
<div class="form-group col-sm-12">
<label for="item_type"><h4>Type</h4></label>
<select class="form-control" name="item_type" id="item_type">
<option>Upload</option>
<option>Paste</option>
</select>
</div>
</div>
<div class="row">
<div class="form-group col-sm-12">
<label for="item_url"><h4>URL Id</h4></label>
<input class="form-control" name="item_url" id="item_url" placeholder="XXXXX" title="enter the url id for the item" type="text" />
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="new_item_submit">Add</button>
</div>
</form>
</div>
</div>
</div>

<div class="modal fade" id="editItem" tabindex="-1" role="dialog" aria-labelledby="editItemLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form class="form" action="##" method="post" id="editItemForm" enctype="multipart/form-data">
<input type="hidden" value="" id="item_id"/>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
<h4 class="modal-title" id="editItemLabel">Edit Item</h4>
</div>
<div class="modal-body">
<div class="row" id="item_error" style="display: none;">
<div class="col-sm-10 col-sm-offset-1 text-center">
<div class="alert alert-danger" role="alert" id="item_error_msg"></div>
</div>
</div>
<div class="row">
<div class="form-group col-sm-12">
<label for="item_title"><h4>Title</h4></label>
<input class="form-control" name="item_title" id="item_title" placeholder="Descriptive Title" title="enter a title for the item." type="text" />
</div>
</div>
<div class="row">
<div class="form-group col-sm-12">
<label for="item_description"><h4>Description</h4></label>
<textarea class="form-control wmd-input" name="item_description" id="item_description" placeholder="Optional" title="enter what the item is about." rows="5"></textarea>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="edit_item_submit">Save</button>
</div>
</form>
</div>
</div>
</div>

<div class="row">
<div class="col-sm-10 col-sm-offset-1 text-center">
<h2>Create a New Vault</h2>
</div>
</div>
<form class="form" action="@Url.SubRouteUrl("vault", "Vault.Action", new { action = "CreateVault" })" method="post" id="newVaultForm">
<div class="row">
<div class="form-group col-sm-10 col-sm-offset-1">
<label for="title"><h4>Title</h4></label>
<input class="form-control" name="title" id="title" placeholder="Collection of items" title="enter a title for your vault." type="text" />
</div>
</div>
<div class="row">
<div class="form-group col-sm-10 col-sm-offset-1">
<label for="article"><h4>Description</h4></label>
<textarea class="form-control" name="description" id="description" placeholder="This is a cool collection of uploads and pastes" title="enter the description for this vault" rows="5"></textarea>
</div>
</div>
<div class="row">
<div class="form-group col-sm-8 col-sm-offset-2">
<button type="button" class="btn btn-primary pull-right" id="add-item" data-toggle="modal" data-target="#newItem">Add Item</button>
</div>
<div class="form-group col-sm-2">
<button type="submit" class="btn btn-primary pull-right" id="submit">Save Vault</button>
</div>
</div>
<br />
<div class="container" id="vault-items">
@if (Model.items.Any())
{
int index = 0;
foreach (NewVaultItemViewModel item in Model.items)
{
<div class="row vault-item" id="vault-item-@index">
<div class="col-sm-8 col-sm-offset-2">
<div class="panel panel-default">
<div class="panel-heading">
<div class="row">
<div class="col-sm-8 text-left">
<h4><b id="item-title">@item.title</b></h4>
</div>
<div class="col-sm-4">
<div class="btn-group pull-right" role="group">
<button type="button" class="btn btn-default" id="edit-item" data-toggle="modal" data-target="#editItem">Edit</button>
<button type="button" class="btn btn-danger" id="remove-item">Remove</button>
</div>
</div>
</div>
</div>
<div class="panel-body">
<div class="row">
<div class="col-sm-10 col-sm-offset-1 text-left">
<dl class="dl-horizontal">
<dt>Type</dt>
<dd id="item-type">@item.type</dd>
<dt>Url</dt>
<dd id="item-url">@item.url</dd>
</dl>
</div>
</div>
</div>
<div class="panel-footer" @((string.IsNullOrEmpty(item.description)) ? "style=\"display: none\"" : string.Empty)>
<p id="item-description">@item.description</p>
</div>
</div>
</div>
</div>
}
}
</div>
</form>
</div>

<div id="templates" style="display: none">
<div class="row" id="item-template">
<div class="col-sm-8 col-sm-offset-2">
<div class="panel panel-default">
<div class="panel-heading">
<div class="row">
<div class="col-sm-8 text-left">
<h4><b id="item-title"></b></h4>
</div>
<div class="col-sm-4">
<div class="btn-group pull-right" role="group">
<button type="button" class="btn btn-default" id="edit-item" data-toggle="modal" data-target="#editItem">Edit</button>
<button type="button" class="btn btn-danger" id="remove-item">Remove</button>
</div>
</div>
</div>
</div>
<div class="panel-body">
<div class="row">
<div class="col-sm-10 col-sm-offset-1 text-left">
<dl class="dl-horizontal">
<dt>Type</dt>
<dd id="item-type"></dd>
<dt>Url</dt>
<dd id="item-url"></dd>
</dl>
</div>
</div>
</div>
<div class="panel-footer">
<p id="item-description"></p>
</div>
</div>
</div>
</div>
</div>

@Scripts.Render("~/bundles/vault")

+ 26
- 6
Teknik/Areas/Vault/Views/Vault/ViewVault.cshtml View File

@@ -12,12 +12,21 @@
<h2><b>@((string.IsNullOrEmpty(Model.Title)) ? "Untitled" : Model.Title)</b> <small>Created on <time datetime="@Model.DateCreated.ToString("s")">@Model.DateCreated.ToString("dddd, MMMM d, yyyy") at @Model.DateCreated.ToString("h:mm:ss tt")</time></small></h2>
</div>
</div>
@if (!string.IsNullOrEmpty(Model.Description))
{
<hr />
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<p>@Model.Description</p>
</div>
</div>
}
<br />

@foreach (VaultItem item in Model.Items)
{
Type itemType = item.GetType();
if (itemType == typeof(PasteItem))
if (itemType.BaseType == typeof(PasteItem))
{
PasteItem paste = (PasteItem)item;

@@ -46,7 +55,16 @@
</div>
<br />
<div class="row paste-item">
<div class="col-sm-12 paste-content">@Html.Raw(paste.Paste.Content)</div>
<div class="col-sm-12 paste-content">
@if (!string.IsNullOrEmpty(paste.Paste.HashedPassword))
{
<p class="text-center">Password Required</p>
}
else
{
Html.Raw(paste.Paste.Content);
}
</div>
</div>
</div>
@if (!string.IsNullOrEmpty(paste.Description))
@@ -57,10 +75,12 @@
}
</div>
}
else if (itemType == typeof(UploadItem))
else if (itemType.BaseType == typeof(UploadItem))
{
UploadItem upload = (UploadItem)item;

bool needsKey = (string.IsNullOrEmpty(upload.Upload.Key) && !string.IsNullOrEmpty(upload.Upload.IV));

<div class="panel panel-default">
<div class="panel-heading">
<div class="row">
@@ -70,13 +90,13 @@
</div>
</div>
<div class="panel-body">
@if (upload.Upload.ContentType.StartsWith("image"))
@if (upload.Upload.ContentType.StartsWith("image") && !needsKey)
{
<a href="@Url.SubRouteUrl("u", "Upload.Download", new { file = upload.Upload.Url })" target="_blank">
<img src="@Url.SubRouteUrl("u", "Upload.Download", new { file = upload.Upload.Url })" class="img-thumbnail center-block" />
</a>
}
else if (upload.Upload.ContentType.StartsWith("audio"))
else if (upload.Upload.ContentType.StartsWith("audio") && !needsKey)
{
<div class="text-center">
<audio preload="none" controls>
@@ -84,7 +104,7 @@
</audio>
</div>
}
else if (upload.Upload.ContentType.StartsWith("video"))
else if (upload.Upload.ContentType.StartsWith("video") && !needsKey)
{
<div class="text-center">
<video preload="none" controls>

BIN
Teknik/Scripts/_references.js View File


+ 4
- 3
Teknik/Teknik.csproj View File

@@ -242,7 +242,8 @@
<Compile Include="Areas\User\Models\TrustedDevice.cs" />
<Compile Include="Areas\User\ViewModels\AuthTokenViewModel.cs" />
<Compile Include="Areas\User\ViewModels\TwoFactorViewModel.cs" />
<Compile Include="Areas\Vault\ViewModels\CreateVaultViewModel.cs" />
<Compile Include="Areas\Vault\ViewModels\NewVaultViewModel.cs" />
<Compile Include="Areas\Vault\ViewModels\NewVaultItemViewModel.cs" />
<Compile Include="Attributes\TeknikAuthorizeAttribute.cs" />
<Compile Include="Filters\CORSActionFilter.cs" />
<Compile Include="Models\TransferTypes.cs" />
@@ -341,6 +342,7 @@
<Content Include="Areas\Shortener\Scripts\Shortener.js" />
<Content Include="Areas\Upload\Scripts\Download.js" />
<Content Include="Areas\Vault\Content\Vault.css" />
<Content Include="Areas\Vault\Scripts\Vault.js" />
<Content Include="Content\audioplayer.css" />
<Content Include="Content\Bootstra.386\bootstrap-theme.css" />
<Content Include="Content\Bootstra.386\bootstrap.css" />
@@ -574,7 +576,7 @@
<Content Include="Areas\User\Views\User\AuthToken.cshtml" />
<Content Include="Areas\Error\Views\Error\Http401.cshtml" />
<Content Include="Areas\Transparency\Views\_ViewStart.cshtml" />
<Content Include="Areas\Vault\Views\Vault\Create.cshtml" />
<Content Include="Areas\Vault\Views\Vault\NewVault.cshtml" />
<None Include="Properties\PublishProfiles\Teknik Dev.pubxml" />
<None Include="Properties\PublishProfiles\Teknik Production.pubxml" />
<None Include="Scripts\jquery-2.1.4.intellisense.js" />
@@ -674,7 +676,6 @@
<Folder Include="Areas\Upload\Views\Shared\" />
<Folder Include="Areas\User\Repositories\" />
<Folder Include="Areas\User\Views\Shared\" />
<Folder Include="Areas\Vault\Scripts\" />
<Folder Include="Areas\Vault\Views\Shared\" />
</ItemGroup>
<ItemGroup>

+ 5
- 0
Utilities/Configuration/Config.cs View File

@@ -39,6 +39,7 @@ namespace Teknik.Configuration
private PodcastConfig _PodcastConfig;
private StreamConfig _StreamConfig;
private ShortenerConfig _ShortenerConfig;
private VaultConfig _VaultConfig;
private TransparencyConfig _TransparencyConfig;
private DatabaseConfig _DatabaseConfig;
private LoggingConfig _LoggingConfig;
@@ -93,6 +94,9 @@ namespace Teknik.Configuration
// Shortener Configuration
public ShortenerConfig ShortenerConfig { get { return _ShortenerConfig; } set { _ShortenerConfig = value; } }

// Shortener Configuration
public VaultConfig VaultConfig { get { return _VaultConfig; } set { _VaultConfig = value; } }

// Shortener Configuration
public TransparencyConfig TransparencyConfig { get { return _TransparencyConfig; } set { _TransparencyConfig = value; } }

@@ -141,6 +145,7 @@ namespace Teknik.Configuration
PodcastConfig = new PodcastConfig();
StreamConfig = new StreamConfig();
ShortenerConfig = new ShortenerConfig();
VaultConfig = new VaultConfig();
TransparencyConfig = new TransparencyConfig();
DatabaseConfig = new DatabaseConfig();
LoggingConfig = new LoggingConfig();

+ 1
- 0
Utilities/Configuration/Configuration.csproj View File

@@ -59,6 +59,7 @@
<Compile Include="PiwikConfig.cs" />
<Compile Include="PodcastConfig.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="VaultConfig.cs" />
<Compile Include="ShortenerConfig.cs" />
<Compile Include="StreamConfig.cs" />
<Compile Include="TransparencyConfig.cs" />

+ 2
- 0
Utilities/Configuration/ShortenerConfig.cs View File

@@ -7,12 +7,14 @@ namespace Teknik.Configuration
{
public class ShortenerConfig
{
public bool Enabled { get; set; }
public string ShortenerHost { get; set; }

public int UrlLength { get; set; }

public ShortenerConfig()
{
Enabled = true;
ShortenerHost = string.Empty;
UrlLength = 4;
}

+ 20
- 0
Utilities/Configuration/VaultConfig.cs View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Teknik.Configuration
{
public class VaultConfig
{
public bool Enabled { get; set; }

public int UrlLength { get; set; }

public VaultConfig()
{
Enabled = true;
UrlLength = 5;
}
}
}

Loading…
Cancel
Save