<commit_before>﻿
@using Bagombo.Models.ViewModels.Home
@using System.Text;

@model BlogPostViewModel

@{
  ViewData["Title"] = Model.Title;
  Layout = "_Layout";
}

<div class="container">
  <div class="row">
    <div class="col-md-9">
      <div class="container">
        <div class="row mb-3">
          <div class="col-12">
            <div class="card">
              <div class="card-body">
                <h2>@Model.Title</h2>
                <hr />
                <p>
                  @Html.Raw(Model.Content)
                </p>
              </div>
              <div class="card-footer">
                @Model.ModifiedAt
              </div>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-12">
            @foreach (var comment in Model.Comments)
            {
              <div class="card p-2 mb-2">
                <div class="container">
                  <div class="row">
                    <div class="col-md-1 pt-3">
                      @{ 
                        var md5 = System.Security.Cryptography.MD5.Create();
                        byte[] hash = md5.ComputeHash(Encoding.Default.GetBytes(comment.Email));
                        var sb = new StringBuilder();
                        for (var i = 0; i < hash.Length; i++)
                        {
                          sb.Append(hash[i].ToString("x2"));

                        }
                        <img src="https://www.gravatar.com/avatar/@sb.ToString()?s=50&d=robohash" />
                      }
                    </div>
                    <div class="col-md-11">
                      <span>Name: @comment.Name</span> <br />
                      <span>Email: @comment.Email</span> <br />
                      <span>Website: <a href="@comment.WebSite">@comment.WebSite</a> </span> <br />
                      <span>Comment: @comment.Text</span> <br />
                      @if (User.IsInRole("Admins"))
                      {
                        <a asp-action="DeleteComment" asp-route-Id="@comment.Id" asp-route-BlogPostId=@Model.Id>Delete Comment</a> <br />
                      }
                    </div>
                  </div>
                </div>
              </div>
            }
            <div class="card">
              <div class="card-header">
                Add Comment:
              </div>
              <div class="card-body p-3">
                <div asp-validation-summary="All" class="text-danger"></div>
                <form asp-action="AddComment" method="post">
                  <input asp-for="Id" type="hidden" />
                  <div class="form-group">
                    <label name="Name">Name:</label>
                    <input class="form-control" name="Name" />
                  </div>
                  <div class="form-group">
                    <label for="Email">Email (for gravitar): </label>
                    <input class="form-control" name="Email" />
                  </div>
                  <div class="form-group">
                    <label for="Website">Website:</label>
                    <input class="form-control" name="Website" />
                  </div>
                  <div class="form-group">
                    <label for="Text">Comment:</label>
                    <textarea class="form-control" name="Text"></textarea>
                  </div>
                  <div class="form-group">
                    <button type="submit" class="btn btn-primary">Submit</button>
                  </div><commit_msg>update comments<commit_after>﻿
@using Bagombo.Models.ViewModels.Home
@using System.Text;
@using CommonMark;

@model BlogPostViewModel

@{
  ViewData["Title"] = Model.Title;
  Layout = "_Layout";
}

<div class="container">
  <div class="row">
    <div class="col-md-9">
      <div class="container">
        <div class="row mb-3">
          <div class="col-12">
            <div class="card">
              <div class="card-body">
                <h2>@Model.Title</h2>
                <hr />
                <p>
                  @Html.Raw(Model.Content)
                </p>
              </div>
              <div class="card-footer">
                @Model.ModifiedAt
              </div>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-12">
            @if(Model.Comments.Count() > 0)
            {
              <h3>Comments:</h3>

            }
            @foreach (var comment in Model.Comments)
            {
              <div class="card p-2 mb-2">
                <div class="container">
                  <div class="row">
                    <div class="col-md-1 pt-2">
                      @{ 
                        var email = comment.Email ?? comment.Name;
                        var md5 = System.Security.Cryptography.MD5.Create();
                        byte[] hash = md5.ComputeHash(Encoding.Default.GetBytes(email));
                        var sb = new StringBuilder();
                        for (var i = 0; i < hash.Length; i++)
                        {
                          sb.Append(hash[i].ToString("x2"));

                        }
                        <img src="https://www.gravatar.com/avatar/@sb.ToString()?s=50&d=robohash" />
                      }
                    </div>
                    <div class="col-md-11">
                      <span><a href="@comment.WebSite"> @comment.Name </a> </span> <br />
                      <span>@Html.Raw(CommonMarkConverter.Convert(comment.Text))</span>
                      <span><i>@comment.Added</i></span>
                      @if (User.IsInRole("Admins"))
                      {
                        <a asp-action="DeleteComment" asp-route-Id="@comment.Id" asp-route-BlogPostId=@Model.Id>Delete Comment</a> <br />
                      }
                    </div>
                  </div>
                </div>
              </div>
            }
            <div class="card">
              <div class="card-header">
                Add Comment:
              </div>
              <div class="card-body p-3">
                <div asp-validation-summary="All" class="text-danger"></div>
                <form asp-action="AddComment" method="post">
                  <input asp-for="Id" type="hidden" />
                  <div class="form-group">
                    <label name="Name">Name:</label>
                    <input class="form-control" name="Name" />
                  </div>
                  <div class="form-group">
                    <label for="Email">Email (for gravitar): </label>
                    <input class="form-control" name="Email" />
                  </div>
                  <div class="form-group">
                    <label for="Website">Website:</label>
                    <input class="form-control" name="Website" />
                  </div>
                  <div class="form-group">
                    <label for="Text">Comment (supports markdown):</label>
                    <textarea class="form-control" name="Text"></textarea>
                  </div>
                  <div class="form-group">
                    <button type="submit" class="btn btn-primary">Submit</button>
                  </div>
{'fraction_non_alphanumeric': 0.14757709251101322, 'fraction_numerical': 0.006470264317180617, 'mean_word_length': 1.1292497069167644, 'pattern_counts': {'":': 0, '<': 168, '<?xml version=': 0, '>': 167, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1772569', 'n_tokens_mistral': 2002, 'n_tokens_neox': 1852, 'n_words': 347}