From c84694079a4124c624415c9695463a068edf6191 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Sun, 22 Mar 2020 16:38:15 -0400 Subject: [PATCH] added design account --- .../Models/TwitterUser.cs | 2 ++ src/BirdsiteLive.Twitter/TwitterService.cs | 10 ++++-- .../Controllers/UserController.cs | 1 + .../Controllers/WellKnownController.cs | 4 ++- src/BirdsiteLive/Views/Shared/_Layout.cshtml | 1 + src/BirdsiteLive/Views/User/Index.cshtml | 16 ++++++--- src/BirdsiteLive/wwwroot/css/birdsite.css | 35 +++++++++++++++++++ 7 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 src/BirdsiteLive/wwwroot/css/birdsite.css diff --git a/src/BirdsiteLive.Twitter/Models/TwitterUser.cs b/src/BirdsiteLive.Twitter/Models/TwitterUser.cs index 82988a3..1050486 100644 --- a/src/BirdsiteLive.Twitter/Models/TwitterUser.cs +++ b/src/BirdsiteLive.Twitter/Models/TwitterUser.cs @@ -7,5 +7,7 @@ public string Url { get; set; } public string ProfileImageUrl { get; set; } public string ProfileBackgroundImageUrl { get; set; } + public string Acct { get; set; } + public string ProfileBannerURL { get; set; } } } \ No newline at end of file diff --git a/src/BirdsiteLive.Twitter/TwitterService.cs b/src/BirdsiteLive.Twitter/TwitterService.cs index 0a6a533..f4f3eca 100644 --- a/src/BirdsiteLive.Twitter/TwitterService.cs +++ b/src/BirdsiteLive.Twitter/TwitterService.cs @@ -24,16 +24,20 @@ namespace BirdsiteLive.Twitter public TwitterUser GetUser(string username) { - Auth.SetUserCredentials(_settings.ConsumerKey, _settings.ConsumerSecret, _settings.AccessToken, _settings.AccessTokenSecret); + //Auth.SetUserCredentials(_settings.ConsumerKey, _settings.ConsumerSecret, _settings.AccessToken, _settings.AccessTokenSecret); + Auth.SetApplicationOnlyCredentials(_settings.ConsumerKey, _settings.ConsumerSecret, true); var user = User.GetUserFromScreenName(username); + if (user == null) return null; return new TwitterUser { + Acct = username, Name = user.Name, Description = user.Description, Url = user.Url, - ProfileImageUrl = user.ProfileImageUrl, - ProfileBackgroundImageUrl = user.ProfileBackgroundImageUrl + ProfileImageUrl = user.ProfileImageUrlFullSize, + ProfileBackgroundImageUrl = user.ProfileBackgroundImageUrlHttps, + ProfileBannerURL = user.ProfileBannerURL }; } } diff --git a/src/BirdsiteLive/Controllers/UserController.cs b/src/BirdsiteLive/Controllers/UserController.cs index bd6c440..d5d15fb 100644 --- a/src/BirdsiteLive/Controllers/UserController.cs +++ b/src/BirdsiteLive/Controllers/UserController.cs @@ -24,6 +24,7 @@ namespace BirdsiteLive.Controllers public IActionResult Index(string id) { var user = _twitterService.GetUser(id); + if (user == null) return NotFound(); var r = Request.Headers["Accept"].First(); diff --git a/src/BirdsiteLive/Controllers/WellKnownController.cs b/src/BirdsiteLive/Controllers/WellKnownController.cs index 247b450..9a0ceed 100644 --- a/src/BirdsiteLive/Controllers/WellKnownController.cs +++ b/src/BirdsiteLive/Controllers/WellKnownController.cs @@ -51,7 +51,9 @@ namespace BirdsiteLive.Controllers if (!string.IsNullOrWhiteSpace(domain) && domain != _settings.Domain) return NotFound(); - //TODO: check if twitter user exists + var user = _twitterService.GetUser(name); + if (user == null) + return NotFound(); var result = new WebFingerResult() { diff --git a/src/BirdsiteLive/Views/Shared/_Layout.cshtml b/src/BirdsiteLive/Views/Shared/_Layout.cshtml index 39c24bc..426caa2 100644 --- a/src/BirdsiteLive/Views/Shared/_Layout.cshtml +++ b/src/BirdsiteLive/Views/Shared/_Layout.cshtml @@ -6,6 +6,7 @@ @ViewData["Title"] - BirdsiteLive +
diff --git a/src/BirdsiteLive/Views/User/Index.cshtml b/src/BirdsiteLive/Views/User/Index.cshtml index 8c3dd2f..d375d83 100644 --- a/src/BirdsiteLive/Views/User/Index.cshtml +++ b/src/BirdsiteLive/Views/User/Index.cshtml @@ -1,10 +1,18 @@ - +@model BirdsiteLive.Twitter.Models.TwitterUser @{ ViewData["Title"] = "User"; } -

User

+
+
+ -@ViewData.Model.Name +

@ViewData.Model.Name

+

@@@ViewData.Model.Acct

-@ViewData.Model.Description + +
+ @ViewData.Model.Description +
+
+
diff --git a/src/BirdsiteLive/wwwroot/css/birdsite.css b/src/BirdsiteLive/wwwroot/css/birdsite.css new file mode 100644 index 0000000..88803d3 --- /dev/null +++ b/src/BirdsiteLive/wwwroot/css/birdsite.css @@ -0,0 +1,35 @@ +.profile { + border: 1px #dddddd solid; + border-radius: 5px; + background-repeat: no-repeat; + /*background-attachment: fixed;*/ + background-position: center; +} + + .profile h1 { + font-size: 32px; + margin-left: 120px; + padding-top: 8px; + } + + .profile h2 { + font-size: 20px; + margin-left: 120px; + } + +.sub-profile { + padding: 20px; + background-color: rgba(255, 255, 255, 0.7); +} + +.avatar { + float: left; + width: 100px; + border-radius: 50%; +} + +.description { + margin-top: 40px; + margin-left: 20px; + font-weight: bold; +} \ No newline at end of file