@using OurUmbraco.Forum.Extensions
@model OurUmbraco.Community.Models.TweetsModel

@if (Model.ShowAdminOverView == false)
{
    foreach (var tweet in Model.Tweets)
    {
        <a href="@tweet.Url" class="forum-thread">

            <div class="avatar">
                <img src="@tweet.CreatedBy.ProfileImageUrl400x400.Replace("http://", "https://")" />
            </div>

            <div class="meta">
                <div class="forum-thread-text">
                    <h3>@tweet.Text</h3>
                    <p>@tweet.CreatedAt.ConvertToRelativeTime() by @@@tweet.CreatedBy.UserIdentifier.ScreenName (@tweet.CreatedBy.Name)</p>
                </div>
            </div>
        </a>
    }
}
else
{
    foreach (var tweet in Model.Tweets)
    {
        var twitterHandle = tweet.CreatedBy.UserIdentifier.ScreenName;

        <img src="@tweet.CreatedBy.ProfileImageUrl400x400.Replace("http://", "https://")" /><br />
        <h3>@tweet.Text</h3>
        <p>@tweet.CreatedAt.ConvertToRelativeTime() by <a href="https://twitter.com/@twitterHandle/with_replies" target="_blank">@@@twitterHandle (@tweet.CreatedBy.Name)</a></p><br />
        <a href="@tweet.Url" target="_blank">@tweet.Url</a><br />
        
        using (Html.BeginForm("MarkAsSpam", "TwitterSearch"))
        {
            @Html.AntiForgeryToken()

            <input type="hidden" name="TwitterHandle" value="@twitterHandle" />
            <input type="submit" value="Mark as spam" />
        }

        <hr />
    }
}

@if (Model.Tweets.Any() == false)
{
    <h2>Could not load recent tweets.</h2>
}
