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 6e58999e..f6344f37 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 2799d10e..5ecc4368 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 fcfa03e2..836857e2 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 b17d03f3..4f64b0c9 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 | 2 +- public/js/profile-directory.js | 2 +- public/mix-manifest.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index 3a52f607..8df5b1e6 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{"+lRy":function(e,t){},0:function(e,t,n){n("JO1w"),n("+lRy"),n("xWuY"),n("YfGV"),e.exports=n("RvBz")},"8oxB":function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function l(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:l}catch(e){r=l}}();var c,f=[],u=!1,s=-1;function d(){u&&c&&(u=!1,c.length?f=c.concat(f):s=-1,f.length&&p())}function p(){if(!u){var e=a(d);u=!0;for(var t=f.length;t;){for(c=f,f=[];++s1)for(var n=1;n5&&n.startsWith("https://")){var r=new URL(n);r.host!==window.location.host&&"/i/redirect"!==r.pathname&&e.setAttribute("href","/i/redirect?url="+encodeURIComponent(n))}}))},window.App.boot=function(){new Vue({el:"#content"})},window.App.util={compose:{post:function(){var e=window.location.pathname;["/","/timeline/public"].includes(e)?$("#composeModal").modal("show"):window.location.href="/?a=co"},circle:function(){console.log("Unsupported method.")},collection:function(){console.log("Unsupported method.")},loop:function(){console.log("Unsupported method.")},story:function(){console.log("Unsupported method.")}},time:function(){return new Date},version:1,format:{count:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-GB",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"compact";return e<1?0:new Intl.NumberFormat(t,{notation:n,compactDisplay:"short"}).format(e)},timeAgo:function(e){var t=Date.parse(e),n=Math.floor((new Date-t)/1e3),r=Math.floor(n/31536e3);return r>=1?r+"y":(r=Math.floor(n/604800))>=1?r+"w":(r=Math.floor(n/86400))>=1?r+"d":(r=Math.floor(n/3600))>=1?r+"h":(r=Math.floor(n/60))>=1?r+"m":Math.floor(n)+"s"}},filters:[["1977","filter-1977"],["Aden","filter-aden"],["Amaro","filter-amaro"],["Ashby","filter-ashby"],["Brannan","filter-brannan"],["Brooklyn","filter-brooklyn"],["Charmes","filter-charmes"],["Clarendon","filter-clarendon"],["Crema","filter-crema"],["Dogpatch","filter-dogpatch"],["Earlybird","filter-earlybird"],["Gingham","filter-gingham"],["Ginza","filter-ginza"],["Hefe","filter-hefe"],["Helena","filter-helena"],["Hudson","filter-hudson"],["Inkwell","filter-inkwell"],["Kelvin","filter-kelvin"],["Kuno","filter-juno"],["Lark","filter-lark"],["Lo-Fi","filter-lofi"],["Ludwig","filter-ludwig"],["Maven","filter-maven"],["Mayfair","filter-mayfair"],["Moon","filter-moon"],["Nashville","filter-nashville"],["Perpetua","filter-perpetua"],["Poprocket","filter-poprocket"],["Reyes","filter-reyes"],["Rise","filter-rise"],["Sierra","filter-sierra"],["Skyline","filter-skyline"],["Slumber","filter-slumber"],["Stinson","filter-stinson"],["Sutro","filter-sutro"],["Toaster","filter-toaster"],["Valencia","filter-valencia"],["Vesper","filter-vesper"],["Walden","filter-walden"],["Willow","filter-willow"],["X-Pro II","filter-xpro-ii"]],emoji:["๐Ÿ˜‚","๐Ÿ’ฏ","โค๏ธ","๐Ÿ™Œ","๐Ÿ‘","๐Ÿ‘Œ","๐Ÿ˜","๐Ÿ˜ฏ","๐Ÿ˜ข","๐Ÿ˜…","๐Ÿ˜","๐Ÿ™‚","๐Ÿ˜Ž","๐Ÿ˜€","๐Ÿคฃ","๐Ÿ˜ƒ","๐Ÿ˜„","๐Ÿ˜†","๐Ÿ˜‰","๐Ÿ˜Š","๐Ÿ˜‹","๐Ÿ˜˜","๐Ÿ˜—","๐Ÿ˜™","๐Ÿ˜š","๐Ÿค—","๐Ÿคฉ","๐Ÿค”","๐Ÿคจ","๐Ÿ˜","๐Ÿ˜‘","๐Ÿ˜ถ","๐Ÿ™„","๐Ÿ˜","๐Ÿ˜ฃ","๐Ÿ˜ฅ","๐Ÿ˜ฎ","๐Ÿค","๐Ÿ˜ช","๐Ÿ˜ซ","๐Ÿ˜ด","๐Ÿ˜Œ","๐Ÿ˜›","๐Ÿ˜œ","๐Ÿ˜","๐Ÿคค","๐Ÿ˜’","๐Ÿ˜“","๐Ÿ˜”","๐Ÿ˜•","๐Ÿ™ƒ","๐Ÿค‘","๐Ÿ˜ฒ","๐Ÿ™","๐Ÿ˜–","๐Ÿ˜ž","๐Ÿ˜Ÿ","๐Ÿ˜ค","๐Ÿ˜ญ","๐Ÿ˜ฆ","๐Ÿ˜ง","๐Ÿ˜จ","๐Ÿ˜ฉ","๐Ÿคฏ","๐Ÿ˜ฌ","๐Ÿ˜ฐ","๐Ÿ˜ฑ","๐Ÿ˜ณ","๐Ÿคช","๐Ÿ˜ต","๐Ÿ˜ก","๐Ÿ˜ ","๐Ÿคฌ","๐Ÿ˜ท","๐Ÿค’","๐Ÿค•","๐Ÿคข","๐Ÿคฎ","๐Ÿคง","๐Ÿ˜‡","๐Ÿค ","๐Ÿคก","๐Ÿคฅ","๐Ÿคซ","๐Ÿคญ","๐Ÿง","๐Ÿค“","๐Ÿ˜ˆ","๐Ÿ‘ฟ","๐Ÿ‘น","๐Ÿ‘บ","๐Ÿ’€","๐Ÿ‘ป","๐Ÿ‘ฝ","๐Ÿค–","๐Ÿ’ฉ","๐Ÿ˜บ","๐Ÿ˜ธ","๐Ÿ˜น","๐Ÿ˜ป","๐Ÿ˜ผ","๐Ÿ˜ฝ","๐Ÿ™€","๐Ÿ˜ฟ","๐Ÿ˜พ","๐Ÿคฒ","๐Ÿ‘","๐Ÿค","๐Ÿ‘","๐Ÿ‘Ž","๐Ÿ‘Š","โœŠ","๐Ÿค›","๐Ÿคœ","๐Ÿคž","โœŒ๏ธ","๐ŸคŸ","๐Ÿค˜","๐Ÿ‘ˆ","๐Ÿ‘‰","๐Ÿ‘†","๐Ÿ‘‡","โ˜๏ธ","โœ‹","๐Ÿคš","๐Ÿ–","๐Ÿ––","๐Ÿ‘‹","๐Ÿค™","๐Ÿ’ช","๐Ÿ–•","โœ๏ธ","๐Ÿ™","๐Ÿ’","๐Ÿ’„","๐Ÿ’‹","๐Ÿ‘„","๐Ÿ‘…","๐Ÿ‘‚","๐Ÿ‘ƒ","๐Ÿ‘ฃ","๐Ÿ‘","๐Ÿ‘€","๐Ÿง ","๐Ÿ—ฃ","๐Ÿ‘ค","๐Ÿ‘ฅ"],embed:{post:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"full",o=e+"/embed?";return o+=t?"caption=true&":"caption=false&",o+=n?"likes=true&":"likes=false&",'