new Tweet page

This commit is contained in:
Vincent Cloutier 2023-02-04 12:55:00 -05:00
parent 8ad62cb133
commit 9c451c0969
8 changed files with 57 additions and 71 deletions

View file

@ -11,8 +11,6 @@
<ItemGroup>
<PackageReference Include="Lamar.Microsoft.DependencyInjection" Version="5.0.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.3" />
</ItemGroup>
<ItemGroup>

View file

@ -7,7 +7,6 @@ using BirdsiteLive.Domain.Repository;
using BirdsiteLive.Services;
using BirdsiteLive.Statistics.Domain;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Razor.Language.Intermediate;
namespace BirdsiteLive.Component
{

View file

@ -138,28 +138,37 @@ namespace BirdsiteLive.Controllers
public async Task<IActionResult> Tweet(string id, string statusId)
{
var acceptHeaders = Request.Headers["Accept"];
if (!long.TryParse(statusId, out var parsedStatusId))
return NotFound();
var tweet = await _twitterTweetService.GetTweetAsync(parsedStatusId);
if (tweet == null)
return NotFound();
var user = await _twitterUserService.GetUserAsync(id);
var status = _statusService.GetStatus(id, tweet);
if (acceptHeaders.Any())
{
var r = acceptHeaders.First();
if (r.Contains("application/activity+json"))
{
if (!long.TryParse(statusId, out var parsedStatusId))
return NotFound();
var tweet = await _twitterTweetService.GetTweetAsync(parsedStatusId);
if (tweet == null)
return NotFound();
//var user = _twitterService.GetUser(id);
//if (user == null) return NotFound();
var status = _statusService.GetStatus(id, tweet);
var jsonApUser = JsonConvert.SerializeObject(status);
return Content(jsonApUser, "application/activity+json; charset=utf-8");
}
}
return Redirect($"https://twitter.com/{id}/status/{statusId}");
//return Redirect($"https://twitter.com/{id}/status/{statusId}");
var displayTweet = new DisplayTweet
{
Text = status.content,
OgUrl = $"https://twitter.com/{id}/status/{statusId}",
UserProfileImage = user.ProfileImageUrl,
UserName = user.Name,
};
return View(displayTweet);
}
[Route("/users/{id}/inbox")]

View file

@ -0,0 +1,10 @@
namespace BirdsiteLive.Models
{
public class DisplayTweet
{
public string Text { get; set; }
public string OgUrl { get; set; }
public string UserProfileImage { get; set; }
public string UserName { get; set; }
}
}

View file

@ -1,27 +0,0 @@
@using BirdsiteLive.Domain.Repository
@model BirdsiteLive.Controllers.ModerationStatus
@{
ViewData["Title"] = "Blacklisting";
}
<div class="col-12 col-sm-12 col-md-10 col-lg-8 mx-auto">
<h2>Blacklisting</h2>
@if (Model.Followers == ModerationTypeEnum.BlackListing)
{
<p><br />This node is blacklisting some instances and/or Fediverse users.<br /><br /></p>
}
@if (Model.TwitterAccounts == ModerationTypeEnum.BlackListing)
{
<p><br />This node is blacklisting some twitter users.<br /><br /></p>
}
@if (Model.Followers != ModerationTypeEnum.BlackListing && Model.TwitterAccounts != ModerationTypeEnum.BlackListing)
{
<p><br />This node is not using blacklisting.<br /><br /></p>
}
@*<h2>FAQ</h2>
<p>TODO</p>*@
</div>

View file

@ -1,27 +0,0 @@
@using BirdsiteLive.Domain.Repository
@model BirdsiteLive.Controllers.ModerationStatus
@{
ViewData["Title"] = "Whitelisting";
}
<div class="col-12 col-sm-12 col-md-10 col-lg-8 mx-auto">
<h2>Whitelisting</h2>
@if (Model.Followers == ModerationTypeEnum.WhiteListing)
{
<p><br />This node is whitelisting some instances and/or Fediverse users.<br /><br /></p>
}
@if (Model.TwitterAccounts == ModerationTypeEnum.WhiteListing)
{
<p><br />This node is whitelisting some twitter users.<br /><br /></p>
}
@if (Model.Followers != ModerationTypeEnum.WhiteListing && Model.TwitterAccounts != ModerationTypeEnum.WhiteListing)
{
<p><br />This node is not using whitelisting.<br /><br /></p>
}
@*<h2>FAQ</h2>
<p>TODO</p>*@
</div>

View file

@ -6,6 +6,24 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@Configuration.GetSection("Instance")["Name"] - @ViewData["Title"]</title>
@if(ViewData["AlternateLink"] != null)
{
<link href='@ViewData["AlternateLink"]' rel='alternate' type='application/activity+json'>
<meta content='@ViewData["AlternateLink"]' property="og:url" />
}
@if(ViewData["MetaDescription"] != null)
{
<meta content='@ViewData["MetaDescription"]' name='description'>
<meta content='@ViewData["MetaDescription"]' property="og:description" />
}
@if(ViewData["MetaTitle"] != null)
{
<meta content='@ViewData["MetaTitle"]' name='og:title'>
}
@if(ViewData["MetaImage"] != null)
{
<meta content='@ViewData["MetaImage"]' property="og:image" />
}
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" />
<link rel="stylesheet" href="~/css/birdsite.css" />

View file

@ -1,8 +1,14 @@
@{
@using Microsoft.AspNetCore.Http.Extensions
@model DisplayTweet
@{
ViewData["Title"] = "Tweet";
ViewData["AlternateLink"] = Context.Request.GetDisplayUrl();
ViewData["MetaDescription"] = ViewData.Model.Text;
ViewData["MetaImage"] = ViewData.Model.UserProfileImage;
ViewData["MetaTitle"] = ViewData.Model.UserName;
}
<div align="center">
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Embedded tweet <a href="https://twitter.com/TwitterSupport/status/@ViewData.Model">Tweet</a></blockquote>
<blockquote class="twitter-tweet"><p lang="en" dir="ltr"><a href="@ViewData.Model.OgUrl">Tweet</a></blockquote>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</div>