The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ViewVault.cshtml 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. @model Teknik.Areas.Vault.ViewModels.VaultViewModel
  2. @using Teknik.Areas.Vault.Models;
  3. @using Teknik.Utilities
  4. @using Teknik.Pygments
  5. @Styles.Render("~/Content/vault")
  6. <div class="container">
  7. <div class="row text-center">
  8. <div class="col-sm-12 text-center">
  9. <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>
  10. </div>
  11. </div>
  12. <br />
  13. @foreach (VaultItem item in Model.Items)
  14. {
  15. Type itemType = item.GetType();
  16. if (itemType == typeof(PasteItem))
  17. {
  18. PasteItem paste = (PasteItem)item;
  19. // Transform content into HTML
  20. if (!Highlighter.Lexers.ToList().Exists(l => l.Aliases.Contains(paste.Paste.Syntax)))
  21. {
  22. paste.Paste.Syntax = "text";
  23. }
  24. Highlighter highlighter = new Highlighter();
  25. // Add a space in front of the content due to bug with pygment (No idea why yet)
  26. paste.Paste.Content = highlighter.HighlightToHtml(" " + paste.Paste.Content, paste.Paste.Syntax, Model.Config.PasteConfig.SyntaxVisualStyle, generateInlineStyles: true, fragment: true);
  27. <div class="panel panel-default">
  28. <div class="panel-heading text-left">
  29. <h4><b><a href="@Url.SubRouteUrl("p", "Paste.View", new { file = paste.Paste.Url })" target="_blank">@((string.IsNullOrEmpty(paste.Title)) ? "Paste" : paste.Title)</a></b> <small>Pasted on <time datetime="@paste.Paste.DatePosted.ToString("s")">@paste.Paste.DatePosted.ToString("dddd, MMMM d, yyyy") at @paste.Paste.DatePosted.ToString("h:mm:ss tt")</time> - Format: <b id="syntaxLanguage">@paste.Paste.Syntax</b></small></h4>
  30. </div>
  31. <div class="panel-body">
  32. <div class="row">
  33. <div class="col-sm-12 pull-left">
  34. <div class="btn-group" role="group">
  35. <a role="button" class="btn btn-default" href="@Url.SubRouteUrl("p", "Paste.Simple", new { url = paste.Paste.Url })">Simple</a>
  36. <a role="button" class="btn btn-default" href="@Url.SubRouteUrl("p", "Paste.Raw", new { url = paste.Paste.Url })">Raw</a>
  37. <a role="button" class="btn btn-default" href="@Url.SubRouteUrl("p", "Paste.Download", new { url = paste.Paste.Url })">Download</a>
  38. </div>
  39. </div>
  40. </div>
  41. <br />
  42. <div class="row paste-item">
  43. <div class="col-sm-12 paste-content">@Html.Raw(paste.Paste.Content)</div>
  44. </div>
  45. </div>
  46. @if (!string.IsNullOrEmpty(paste.Description))
  47. {
  48. <div class="panel-footer">
  49. <p>@paste.Description</p>
  50. </div>
  51. }
  52. </div>
  53. }
  54. else if (itemType == typeof(UploadItem))
  55. {
  56. UploadItem upload = (UploadItem)item;
  57. <div class="panel panel-default">
  58. <div class="panel-heading">
  59. <div class="row">
  60. <div class="col-sm-12 text-left">
  61. <h4><b><a href="@Url.SubRouteUrl("u", "Upload.Download", new { file = upload.Upload.Url })" target="_blank">@((string.IsNullOrEmpty(upload.Title)) ? "Upload" : upload.Title)</a></b> <small>Uploaded on <time datetime="@upload.Upload.DateUploaded.ToString("s")">@upload.Upload.DateUploaded.ToString("dddd, MMMM d, yyyy") at @upload.Upload.DateUploaded.ToString("h:mm:ss tt")</time></small></h4>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="panel-body">
  66. @if (upload.Upload.ContentType.StartsWith("image"))
  67. {
  68. <a href="@Url.SubRouteUrl("u", "Upload.Download", new { file = upload.Upload.Url })" target="_blank">
  69. <img src="@Url.SubRouteUrl("u", "Upload.Download", new { file = upload.Upload.Url })" class="img-thumbnail center-block" />
  70. </a>
  71. }
  72. else if (upload.Upload.ContentType.StartsWith("audio"))
  73. {
  74. <div class="text-center">
  75. <audio preload="none" controls>
  76. <source src="@Url.SubRouteUrl("u", "Upload.Download", new { file = upload.Upload.Url })" type="@upload.Upload.ContentType" />
  77. </audio>
  78. </div>
  79. }
  80. else if (upload.Upload.ContentType.StartsWith("video"))
  81. {
  82. <div class="text-center">
  83. <video preload="none" controls>
  84. <source src="@Url.SubRouteUrl("u", "Upload.Download", new { file = upload.Upload.Url })" type="@upload.Upload.ContentType" />
  85. </video>
  86. </div>
  87. }
  88. else
  89. {
  90. <div class="row">
  91. <div class="col-sm-4 text-center">
  92. <label for="size">Size</label>
  93. <p id="size">@StringHelper.GetBytesReadable(upload.Upload.ContentLength)</p>
  94. </div>
  95. <div class="col-sm-4 text-center">
  96. <label for="type">Type</label>
  97. <p id="type">@upload.Upload.ContentType</p>
  98. </div>
  99. <div class="col-sm-4 text-center">
  100. <label for="dateUploaded">Date Uploaded</label>
  101. <p id="dateUploaded"><time datetime="@upload.Upload.DateUploaded.ToString("s")">@upload.Upload.DateUploaded.ToString("MMMM dd, yyyy")</time></p>
  102. </div>
  103. </div>
  104. }
  105. </div>
  106. @if (!string.IsNullOrEmpty(upload.Description))
  107. {
  108. <div class="panel-footer">
  109. <p>@upload.Description</p>
  110. </div>
  111. }
  112. </div>
  113. }
  114. else
  115. {
  116. // Nothing to see here folks. :)
  117. }
  118. }
  119. </div>