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.

ViewProfile.cshtml 16KB

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