The next generation of the Teknik Services. Written in ASP.NET. Fork for blog tags.
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

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