From cfaa248c722700d845831968221a2c7c26990bde Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 15 May 2020 23:32:54 -0600 Subject: [PATCH 01/11] Update SiteController, add legacy profile/webfinger redirect --- app/Http/Controllers/SiteController.php | 24 ++++++++++++++++++++++++ routes/web.php | 1 + 2 files changed, 25 insertions(+) diff --git a/app/Http/Controllers/SiteController.php b/app/Http/Controllers/SiteController.php index 6e58999e5..f6344f371 100644 --- a/app/Http/Controllers/SiteController.php +++ b/app/Http/Controllers/SiteController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use Illuminate\Support\Str; use App, Auth, Cache, View; use App\Util\Lexer\PrettyNumber; use App\{Follower, Page, Profile, Status, User, UserFilter}; @@ -129,4 +130,27 @@ class SiteController extends Controller $following = $user != null ? FollowerService::follows($user->profile_id, $profile->id) : false; return view('site.intents.follow', compact('profile', 'user', 'following')); } + + public function legacyProfileRedirect(Request $request, $username) + { + $username = Str::contains($username, '@') ? '@' . $username : $username; + if(str_contains($username, '@')) { + $profile = Profile::whereUsername($username) + ->firstOrFail(); + + if($profile->domain == null) { + $url = "/$profile->username"; + } else { + $url = "/i/web/profile/_/{$profile->id}"; + } + + } else { + $profile = Profile::whereUsername($username) + ->whereNull('domain') + ->firstOrFail(); + $url = "/$profile->username"; + } + + return redirect($url); + } } diff --git a/routes/web.php b/routes/web.php index 2799d10e7..5ecc43681 100644 --- a/routes/web.php +++ b/routes/web.php @@ -428,5 +428,6 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact Route::get('p/{username}/{id}.json', 'StatusController@showObject'); Route::get('p/{username}/{id}', 'StatusController@show'); Route::get('{username}/embed', 'ProfileController@embed'); + Route::get('@{username}', 'SiteController@legacyProfileRedirect'); Route::get('{username}', 'ProfileController@show'); }); From 87668d809a09e3a6209a0d47c3662c644e22392b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 17 May 2020 19:33:43 -0600 Subject: [PATCH 02/11] Update ProfileDirectory --- resources/assets/js/app.js | 2 +- .../assets/js/components/ProfileDirectory.vue | 16 ---------------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index fcfa03e21..836857e22 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -73,7 +73,7 @@ window.App.util = { timeAgo: (function(ts) { let date = Date.parse(ts); let seconds = Math.floor((new Date() - date) / 1000); - let interval = Math.floor(seconds / 31536000); + let interval = Math.floor(seconds / 63072000); if (interval >= 1) { return interval + "y"; } diff --git a/resources/assets/js/components/ProfileDirectory.vue b/resources/assets/js/components/ProfileDirectory.vue index b17d03f30..4f64b0c9e 100644 --- a/resources/assets/js/components/ProfileDirectory.vue +++ b/resources/assets/js/components/ProfileDirectory.vue @@ -16,9 +16,6 @@ {{prettyCount(profile.statuses_count)}} POSTS - - {{postsPerDay(profile)}} POSTS/DAY - {{prettyCount(profile.followers_count)}} FOLLOWERS @@ -105,19 +102,6 @@ thumbUrl(p) { return p.media_attachments[0].url; - }, - - postsPerDay(profile) { - let created = profile.created_at; - let now = Date.now(); - let diff = Math.abs(created, now) - let day = 1000 * 60 * 60 * 24; - let days = Math.round(diff / day); - - let statuses = profile.statuses_count; - - let perDay = this.prettyCount(Math.floor(statuses / days)); - return perDay; } } } From 1e135bba4056f2ea578039e8e4712a56aae707ad Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 17 May 2020 19:34:11 -0600 Subject: [PATCH 03/11] Update compiled assets --- public/js/app.js | Bin 7168 -> 7168 bytes public/js/profile-directory.js | Bin 3908 -> 3651 bytes public/mix-manifest.json | Bin 1939 -> 1939 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index 3a52f6073f340680b67f81155bc73591b5b23a3a..8df5b1e63c66e154522b5d5dde9b772b492b69af 100644 GIT binary patch delta 18 ZcmZp$Xt3BYftS_H*udOq^Hkn!J^(n!1(N^( delta 18 ZcmZp$Xt3BYftS_T(A3y$^Hkn!J^(no1(N^( diff --git a/public/js/profile-directory.js b/public/js/profile-directory.js index 6e920b96b055dc6b029cabac67fd9d13b71cf1f1..c4ce28f29302e0ce6f919c8bd773894660b1cd9b 100644 GIT binary patch delta 171 zcmX>icUWe^M8^D$lXRFAYHM{8ZHqOOyggF1l{9toZ2gn6Qj<$G67>=_HS%>dCO2@2 zZti2|Wn|3XJcs2p)8w=4-HiE@BRMpH0!*B0z>lvTde)T4`Q#NoIbYhGuo*WDPzY#>B~?e0PQN VYc(~2?um{zwA3+(jg8f`1^{%ZHh2I4 delta 366 zcmYL_!Ab&A6owfSrOZtfw1|*d*u8Watt>JdB61N#DCnZFL5|}!jhHKQ&lniSJ8n`D@kSu WRZYInK{&aa)oN>bmUSG57QO+L6nWtQ diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 61b9e62c055359a7eea07319133f3884a542ab47..04c57d3935a8cecb6cd5e8f154411f8fd9f9265c 100644 GIT binary patch delta 58 zcmbQtKbe1nETgc2xuuDzS)x%&s)<>$i2;x>-fX~V%OYZCXqcF0W@c$*WSE#@k(6p| MU}mwokyVHZ0JQxMrT_o{ delta 58 zcmbQtKbe1nETgcoSyFOxqM@m2YI2IDsimQTh3RGkMq3sUb3-$OBm;vK%cRtlL_;%^ NG{dCi&5f)=OaRTJ4~hT) From 84e92980bd5b80c6093aba3692f994453ef01a01 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 17 May 2020 19:57:00 -0600 Subject: [PATCH 04/11] Update ComposeModal --- resources/assets/js/components/ComposeModal.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/assets/js/components/ComposeModal.vue b/resources/assets/js/components/ComposeModal.vue index 37a633045..ab54a93df 100644 --- a/resources/assets/js/components/ComposeModal.vue +++ b/resources/assets/js/components/ComposeModal.vue @@ -1,6 +1,6 @@