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.

Index.cshtml 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. @model Teknik.Areas.Users.ViewModels.ProfileViewModel
  2. @using Teknik.Helpers
  3. @using Teknik.Areas.Paste
  4. @using Teknik.Areas.Upload
  5. <div class="container">
  6. @if (!Model.Error)
  7. {
  8. bool OwnProfile = (Model.Username == User.Identity.Name || User.IsInRole("Admin"));
  9. string gitHost = (string.IsNullOrEmpty(Model.Config.Host)) ? string.Empty : Model.Config.GitConfig.Host;
  10. Uri gitUrl = new Uri(gitHost);
  11. gitUrl = new Uri(gitUrl, Model.Username);
  12. string pgpFingerprint = pgpFingerprint = string.Empty;
  13. string pgpFingerprint64 = string.Empty;
  14. if (!string.IsNullOrEmpty(Model.SecuritySettings.PGPSignature))
  15. {
  16. pgpFingerprint = PGP.GetFingerprint(Model.SecuritySettings.PGPSignature);
  17. pgpFingerprint64 = PGP.GetFingerprint64(Model.SecuritySettings.PGPSignature);
  18. }
  19. <div class="row text-center">
  20. <div class="col-sm-3"><h1>@Model.Username</h1></div>
  21. </div>
  22. <div class="modal fade" id="pgpSignature" tabindex="-1" role="dialog" aria-labelledby="pgpSignatureLabel" aria-hidden="true">
  23. <div class="modal-dialog">
  24. <div class="modal-content">
  25. <div class="modal-header">
  26. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span></button>
  27. <h4 class="modal-title" id="newPostLabel">@(Model.Username)'s Public Key</h4>
  28. </div>
  29. <div class="modal-body">
  30. <div class="row">
  31. <div class="col-sm-2">
  32. Fingerprint:
  33. </div>
  34. <div class="col-sm-10 text-right">
  35. @pgpFingerprint.AddStringAtInterval(4, " ")
  36. </div>
  37. </div>
  38. <div class="row">
  39. <div class="col-sm-2">
  40. 64-bit:
  41. </div>
  42. <div class="col-sm-10 text-right">
  43. @pgpFingerprint64.AddStringAtInterval(4, " ")
  44. </div>
  45. </div>
  46. <div class="row">
  47. <div class="col-sm-2">
  48. Raw:
  49. </div>
  50. <div class="col-sm-10 text-right">
  51. <a href="@Url.SubRouteUrl("user", "User.PGPKey", new { username = Model.Username })" target="_blank">@Url.SubRouteUrl("user", "User.PGPKey", new { username = Model.Username })</a>
  52. </div>
  53. </div>
  54. <br />
  55. <div class="row">
  56. <div class="col-sm-12">
  57. <textarea class="form-control wmd-input" name="pgpKeyBlock" id="pgpKeyBlock" title="Public Key" rows="10" onClick="SelectAll('pgpKeyBlock');" readonly>@Model.SecuritySettings.PGPSignature</textarea>
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. <div class="row">
  65. <!-- Left Info Box -->
  66. <div class="col-sm-3"><!--left col-->
  67. <ul class="list-group">
  68. <li class="list-group-item text-muted">Profile</li>
  69. <li class="list-group-item text-right"><span class="pull-left"><strong>Joined</strong></span> <time datetime="@Model.LastSeen.ToString("o")">@Model.JoinDate.ToString("MMMM dd, yyyy")</time></li>
  70. @if (OwnProfile && User.Identity.IsAuthenticated)
  71. {
  72. <li class="list-group-item text-right"><span class="pull-left"><strong>Last Seen</strong></span> <time datetime="@Model.LastSeen.ToString("o")">@Model.LastSeen.ToString("MMMM dd, yyyy hh:mm tt")</time></li>
  73. }
  74. @if (!string.IsNullOrEmpty(pgpFingerprint))
  75. {
  76. <li class="list-group-item text-right"><span class="pull-left"><strong>Public Key</strong></span> <a href="#" data-toggle="modal" data-target="#pgpSignature">@pgpFingerprint64.AddStringAtInterval(4, " ")</a></li>
  77. }
  78. @if (!string.IsNullOrEmpty(Model.Email))
  79. {
  80. <li class="list-group-item text-right"><span class="pull-left"><strong>Email</strong></span> <a href="mailto:@Model.Email">@Model.Email</a></li>
  81. }
  82. <li class="list-group-item text-right"><span class="pull-left"><strong>Blog</strong></span> <a href="@Url.SubRouteUrl("blog", "Blog.Blog", new { username = Model.Username })" id="blog_title">@(string.IsNullOrEmpty(Model.BlogSettings.Title) ? string.Format("{0}'s Blog", Model.Username) : Model.BlogSettings.Title)</a></li>
  83. <li class="list-group-item text-right"><span class="pull-left"><strong>Git</strong></span> <a href="@gitUrl.ToString()">Public Repos</a></li>
  84. </ul>
  85. @if (!string.IsNullOrEmpty(Model.UserSettings.Website))
  86. {
  87. <div class="panel panel-default">
  88. <div class="panel-heading">Website <i class="fa fa-link fa-1x"></i></div>
  89. <div class="panel-body"><a href="@Model.UserSettings.Website" id="website">@Model.UserSettings.Website</a></div>
  90. </div>
  91. }
  92. @if (!string.IsNullOrEmpty(Model.UserSettings.Quote))
  93. {
  94. <div class="panel panel-default">
  95. <div class="panel-heading">Quote <i class="fa fa-quote-right fa-1x"></i></div>
  96. <div class="panel-body" id="quote">@Model.UserSettings.Quote</div>
  97. </div>
  98. }
  99. </div><!--/col-3-->
  100. <!-- Right Content Area -->
  101. <div class="col-sm-9">
  102. @if (OwnProfile)
  103. {
  104. <ul class="nav nav-tabs" id="myTab">
  105. <li><a href="#about" data-toggle="tab"> About Myself </a></li>
  106. <li><a href="#uploads" data-toggle="tab"> Uploads </a></li>
  107. <li><a href="#pastes" data-toggle="tab"> Pastes </a></li>
  108. <li><a href="#shortenedUrls" data-toggle="tab"> Shotened Urls </a></li>
  109. </ul>
  110. <div class="tab-content">
  111. <div class="tab-pane active" id="about">
  112. <div class="col-sm-12" id="markdown_body">@Html.Markdown(@Model.UserSettings.About)</div>
  113. </div><!--/tab-pane-->
  114. @if (OwnProfile)
  115. {
  116. <div class="tab-pane" id="uploads" style="overflow-y: auto; max-height: 500px;">
  117. @foreach (Teknik.Areas.Upload.Models.Upload upload in Model.Uploads)
  118. {
  119. <div class="panel panel-default">
  120. <div class="panel-heading text-center">
  121. <a href="@Url.SubRouteUrl("upload", "Upload.Download", new { file = upload.Url })">@Url.SubRouteUrl("upload", "Upload.Download", new { file = upload.Url })</a>
  122. </div>
  123. <div class="panel-body">
  124. <div class="col-sm-2 text-center">
  125. <label for="size">Size</label>
  126. <p id="size">@Utility.GetBytesReadable(upload.ContentLength)</p>
  127. </div>
  128. <div class="col-sm-3 text-center">
  129. <label for="type">Type</label>
  130. <p id="type">@upload.ContentType</p>
  131. </div>
  132. <div class="col-sm-3 text-center">
  133. <label for="dateUploaded">Date Uploaded</label>
  134. <p id="dateUploaded"><time datetime="@upload.DateUploaded.ToString("o")">@upload.DateUploaded.ToString("MMMM dd, yyyy")</time></p>
  135. </div>
  136. <div class="col-sm-2 text-center">
  137. <label for="downloads">Downloads</label>
  138. <p id="downloads">@upload.Downloads</p>
  139. </div>
  140. <div class="col-sm-2 text-center">
  141. <label for="deleteKey">Deletion Key</label>
  142. <p id="deleteKey">@upload.DeleteKey</p>
  143. </div>
  144. </div>
  145. </div>
  146. }
  147. </div><!--/tab-pane-->
  148. <div class="tab-pane" id="pastes" style="overflow-y: auto; max-height: 500px;">
  149. @foreach (Teknik.Areas.Paste.Models.Paste paste in Model.Pastes)
  150. {
  151. <div class="panel panel-default">
  152. <div class="panel-heading text-center">
  153. <a href="@Url.SubRouteUrl("paste", "Paste.View", new { url = paste.Url })">@(string.IsNullOrEmpty(paste.Title) ? "Untitled Paste" : paste.Title)</a>
  154. </div>
  155. <div class="panel-body">
  156. <div class="col-sm-2 text-center">
  157. <label for="syntax">Syntax</label>
  158. <p id="syntax">@paste.Syntax</p>
  159. </div>
  160. <div class="col-sm-3 text-center">
  161. <label for="datePosted">Date Posted</label>
  162. <p id="datePosted"><time datetime="@paste.DatePosted.ToString("o")">@paste.DatePosted.ToString("MMMM dd, yyyy")</time></p>
  163. </div>
  164. <div class="col-sm-3 text-center">
  165. <label for="expireDate">Expire Date</label>
  166. @{
  167. string expireDate = "Never";
  168. if (paste.ExpireDate != null)
  169. {
  170. expireDate = "<time datetime=\"" + paste.ExpireDate.Value.ToString("o") + "\">" + paste.ExpireDate.Value.ToString("MMMM dd, yyyy") + "</time>";
  171. }
  172. }
  173. <p id="expireDate">@expireDate</p>
  174. </div>
  175. <div class="col-sm-2 text-center">
  176. <label for="maxViews">Max Views</label>
  177. <p id="maxViews">@paste.MaxViews</p>
  178. </div>
  179. <div class="col-sm-2 text-center">
  180. <label for="views">Views</label>
  181. <p id="views">@paste.Views</p>
  182. </div>
  183. </div>
  184. </div>
  185. }
  186. </div>
  187. <div class="tab-pane" id="shortenedUrls" style="overflow-y: auto; max-height: 500px;">
  188. @foreach (Teknik.Areas.Shortener.Models.ShortenedUrl url in Model.ShortenedUrls)
  189. {
  190. string shortUrl = Url.SubRouteUrl(string.Empty, "Shortener.View", new { url = url.ShortUrl });
  191. if (Model.Config.DevEnvironment)
  192. {
  193. shortUrl = Url.SubRouteUrl("shortened", "Shortener.View", new { url = url.ShortUrl });
  194. }
  195. <div class="panel panel-default">
  196. <div class="panel-heading text-center">
  197. <a href="@url.OriginalUrl">@url.OriginalUrl</a>
  198. </div>
  199. <div class="panel-body">
  200. <div class="col-sm-5 text-center">
  201. <label for="shortUrl">Short Url</label>
  202. <p id="shortUrl"><a href="@shortUrl">@shortUrl</a></p>
  203. </div>
  204. <div class="col-sm-5 text-center">
  205. <label for="dateAdded">Date Added</label>
  206. <p id="dateAdded"><time datetime="@url.DateAdded.ToString("o")">@url.DateAdded.ToString("MMMM dd, yyyy")</time></p>
  207. </div>
  208. <div class="col-sm-2 text-center">
  209. <label for="views">Views</label>
  210. <p id="views">@url.Views</p>
  211. </div>
  212. </div>
  213. </div>
  214. }
  215. </div>
  216. }
  217. </div><!--/tab-content-->
  218. }
  219. else
  220. {
  221. @Html.Markdown(@Model.UserSettings.About)
  222. }
  223. </div><!--/col-9-->
  224. </div><!--/row-->
  225. }
  226. else
  227. {
  228. <div class="row">
  229. <div class="col-sm-12 text-center">
  230. <h2>@Model.ErrorMessage</h2>
  231. </div>
  232. </div>
  233. }
  234. </div>