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 17KB

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