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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. @model Teknik.Areas.Users.ViewModels.ProfileViewModel
  2. @using Teknik.Utilities.Cryptography
  3. @using Teknik.Areas.Users.Utility
  4. <div class="container">
  5. @if (!Model.Error)
  6. {
  7. bool OwnProfile = (Model.Username == User.Identity.Name || User.IsInRole("Admin")) && User.Identity.IsAuthenticated;
  8. string gitHost = Config.GitConfig.Host;
  9. string gitFullUrl = string.Empty;
  10. if (!string.IsNullOrEmpty(gitHost))
  11. {
  12. Uri gitUrl = new Uri(gitHost);
  13. gitUrl = new Uri(gitUrl, Model.Username);
  14. gitFullUrl = gitUrl.ToString();
  15. }
  16. string pgpFingerprint = pgpFingerprint = string.Empty;
  17. string pgpFingerprint64 = string.Empty;
  18. if (!string.IsNullOrEmpty(Model.IdentityUserInfo.PGPPublicKey))
  19. {
  20. pgpFingerprint = PGP.GetFingerprint(Model.IdentityUserInfo.PGPPublicKey);
  21. pgpFingerprint64 = PGP.GetFingerprint64(Model.IdentityUserInfo.PGPPublicKey);
  22. }
  23. <div class="row text-center">
  24. <div class="col-sm-4 @(string.IsNullOrEmpty(Model.UserSettings.About) ? "col-sm-offset-4" : "")"><h1>@Model.Username</h1></div>
  25. </div>
  26. if (User.IsInRole("Admin"))
  27. {
  28. <div class="row text-center">
  29. <div class="col-sm-3"><a href="@Url.SubRouteUrl("admin", "Admin.UserInfo", new { username = Model.Username })">edit</a></div>
  30. </div>
  31. }
  32. <div class="modal fade" id="pgpSignature" tabindex="-1" role="dialog" aria-labelledby="pgpSignatureLabel" aria-hidden="true">
  33. <div class="modal-dialog">
  34. <div class="modal-content">
  35. <div class="modal-header">
  36. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span></button>
  37. <h4 class="modal-title" id="newPostLabel">@(Model.Username)'s Public Key</h4>
  38. </div>
  39. <div class="modal-body">
  40. <div class="row">
  41. <div class="col-sm-2">
  42. Fingerprint:
  43. </div>
  44. <div class="col-sm-10 text-right">
  45. @pgpFingerprint.AddStringAtInterval(4, " ")
  46. </div>
  47. </div>
  48. <div class="row">
  49. <div class="col-sm-2">
  50. 64-bit:
  51. </div>
  52. <div class="col-sm-10 text-right">
  53. @pgpFingerprint64.AddStringAtInterval(4, " ")
  54. </div>
  55. </div>
  56. <div class="row">
  57. <div class="col-sm-2">
  58. Raw:
  59. </div>
  60. <div class="col-sm-10 text-right">
  61. <a href="@Url.SubRouteUrl("user", "User.PGPKey", new { username = Model.Username })" target="_blank">@Url.SubRouteUrl("user", "User.PGPKey", new { username = Model.Username })</a>
  62. </div>
  63. </div>
  64. <br />
  65. <div class="row">
  66. <div class="col-sm-12">
  67. <textarea class="form-control wmd-input" name="pgpKeyBlock" id="pgpKeyBlock" title="Public Key" rows="10" readonly>@Model.IdentityUserInfo.PGPPublicKey</textarea>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. <div class="row">
  75. <!-- Left Info Box -->
  76. <div class="col-sm-4 @(string.IsNullOrEmpty(Model.UserSettings.About) ? "col-sm-offset-4" : "")"><!--left col-->
  77. <ul class="list-group">
  78. <li class="list-group-item text-right"><span class="pull-left"><strong>Joined</strong></span> <time datetime="@Model.IdentityUserInfo.CreationDate?.ToString("s")">@Model.IdentityUserInfo.CreationDate?.ToString("MMMM dd, yyyy")</time></li>
  79. @if (OwnProfile)
  80. {
  81. <li class="list-group-item text-right"><span class="pull-left"><strong>Last Seen</strong></span> <time datetime="@Model.IdentityUserInfo.LastSeen?.ToString("s")">@Model.IdentityUserInfo.LastSeen?.ToString("dd/MM/yyyy hh:mm tt")</time></li>
  82. }
  83. @if (OwnProfile)
  84. {
  85. <li class="list-group-item text-right"><span class="pull-left"><strong>Account Type</strong></span> @Model.IdentityUserInfo.AccountType</li>
  86. }
  87. @if (User.IsInRole("Admin"))
  88. {
  89. <li class="list-group-item text-right"><span class="pull-left"><strong>Account Status</strong></span> @Model.IdentityUserInfo.AccountStatus</li>
  90. }
  91. @if (!string.IsNullOrEmpty(pgpFingerprint))
  92. {
  93. <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>
  94. }
  95. @if (!string.IsNullOrEmpty(Model.Email) && Config.EmailConfig.Enabled && UserHelper.UserEmailEnabled(Config, Model.Email))
  96. {
  97. <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 {Config.EmailConfig.Domain}"))</li>
  98. }
  99. <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>
  100. @if (!string.IsNullOrEmpty(gitFullUrl))
  101. {
  102. <li class="list-group-item text-right"><span class="pull-left"><strong>Git</strong></span> <a href="@gitFullUrl">Public Repos</a></li>
  103. }
  104. </ul>
  105. @if (!string.IsNullOrEmpty(Model.UserSettings.Website))
  106. {
  107. <div class="panel panel-default">
  108. <div class="panel-heading">Website <i class="fa fa-link fa-1x"></i></div>
  109. <div class="panel-body"><a href="@Model.UserSettings.Website" id="website">@Model.UserSettings.Website</a></div>
  110. </div>
  111. }
  112. @if (!string.IsNullOrEmpty(Model.UserSettings.Quote))
  113. {
  114. <div class="panel panel-default">
  115. <div class="panel-heading">Quote <i class="fa fa-quote-right fa-1x"></i></div>
  116. <div class="panel-body" id="quote">@Model.UserSettings.Quote</div>
  117. </div>
  118. }
  119. </div><!--/col-3-->
  120. @if (!string.IsNullOrEmpty(Model.UserSettings.About))
  121. {
  122. <!-- Right Content Area -->
  123. <div class="col-sm-8">
  124. @if (OwnProfile)
  125. {
  126. <div class="col-sm-12" id="markdown_body">@Html.Markdown(Model.UserSettings.About)</div>
  127. }
  128. else
  129. {
  130. @Html.Markdown(Model.UserSettings.About)
  131. }
  132. </div><!--/col-9-->
  133. }
  134. </div><!--/row-->
  135. }
  136. else
  137. {
  138. <div class="row">
  139. <div class="col-sm-12 text-center">
  140. <h2>@Model.ErrorMessage</h2>
  141. </div>
  142. </div>
  143. }
  144. </div>
  145. <bundle src="js/user.profile.min.js" append-version="true"></bundle>