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

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