1
0
Fork 0

Merge pull request #1171 from pixelfed/frontend-ui-refactor

Frontend ui refactor
This commit is contained in:
daniel 2019-04-21 23:46:14 -06:00 committed by GitHub
commit 36929de8da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 60 additions and 22 deletions

View File

@ -67,6 +67,6 @@ class UserDelete extends Command
$profile->save(); $profile->save();
$user->save(); $user->save();
DeleteAccountPipeline::dispatchNow($user); DeleteAccountPipeline::dispatch($user)->onQueue('high');
} }
} }

View File

@ -6,7 +6,7 @@ use App\AccountLog;
use App\Following; use App\Following;
use App\Report; use App\Report;
use App\UserFilter; use App\UserFilter;
use Auth, DB, Cache, Purify; use Auth, Cookie, DB, Cache, Purify;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Controllers\Settings\{ use App\Http\Controllers\Settings\{
@ -176,7 +176,7 @@ class SettingsController extends Controller
$profile->save(); $profile->save();
Cache::forget('profiles:private'); Cache::forget('profiles:private');
Auth::logout(); Auth::logout();
DeleteAccountPipeline::dispatch($user); DeleteAccountPipeline::dispatch($user)->onQueue('high');
return redirect('/'); return redirect('/');
} }
@ -192,5 +192,22 @@ class SettingsController extends Controller
$reports = Report::whereProfileId($profile->id)->orderByDesc('created_at')->paginate(10); $reports = Report::whereProfileId($profile->id)->orderByDesc('created_at')->paginate(10);
return view('settings.reports', compact('reports')); return view('settings.reports', compact('reports'));
} }
public function metroDarkMode(Request $request)
{
$this->validate($request, [
'mode' => 'required|string|in:light,dark'
]);
$mode = $request->input('mode');
if($mode == 'dark') {
$cookie = Cookie::make('dark-mode', true, 43800);
} else {
$cookie = Cookie::forget('dark-mode');
}
return response()->json([200])->cookie($cookie);
}
} }

View File

@ -8,6 +8,7 @@ use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Foundation\Bus\Dispatchable;
use DB; use DB;
use Illuminate\Support\Str;
use App\{ use App\{
AccountLog, AccountLog,
Activity, Activity,
@ -74,11 +75,15 @@ class DeleteAccountPipeline implements ShouldQueue
$avatar = $user->profile->avatar; $avatar = $user->profile->avatar;
if(is_file($avatar->media_path)) { if(is_file($avatar->media_path)) {
unlink($avatar->media_path); if($avatar->media_path != 'public/avatars/default.png') {
unlink($avatar->media_path);
}
} }
if(is_file($avatar->thumb_path)) { if(is_file($avatar->thumb_path)) {
unlink($avatar->thumb_path); if($avatar->thumb_path != 'public/avatars/default.png') {
unlink($avatar->thumb_path);
}
} }
$avatar->forceDelete(); $avatar->forceDelete();
} }

View File

@ -23,7 +23,7 @@ return [
| This value is the version of your PixelFed instance. | This value is the version of your PixelFed instance.
| |
*/ */
'version' => '0.9.0', 'version' => '0.9.1',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

File diff suppressed because one or more lines are too long

View File

@ -11,5 +11,5 @@
"/js/profile.js": "/js/profile.js?id=bf431aa6387f69c6a91d", "/js/profile.js": "/js/profile.js?id=bf431aa6387f69c6a91d",
"/js/search.js": "/js/search.js?id=0d3d080dc05f4f49b204", "/js/search.js": "/js/search.js?id=0d3d080dc05f4f49b204",
"/js/status.js": "/js/status.js?id=0b11c2129b9ebdb0eddf", "/js/status.js": "/js/status.js?id=0b11c2129b9ebdb0eddf",
"/js/timeline.js": "/js/timeline.js?id=85cde79f1c4bd2eeb6e5" "/js/timeline.js": "/js/timeline.js?id=a55e77b5ab5237de0aaf"
} }

View File

@ -374,6 +374,10 @@
}, },
mounted() { mounted() {
if($('link[data-stylesheet="dark"]').length != 0) {
this.modes.dark = true;
}
this.$nextTick(function () { this.$nextTick(function () {
$('[data-toggle="tooltip"]').tooltip() $('[data-toggle="tooltip"]').tooltip()
}); });
@ -810,17 +814,23 @@
modeDarkToggle() { modeDarkToggle() {
// todo: more graceful stylesheet change // todo: more graceful stylesheet change
if(this.modes.dark == true) { if(this.modes.dark == true) {
this.modes.dark = false; axios.post('/i/metro/dark-mode', {
$('link[data-stylesheet=dark]').remove(); mode: 'light'
}).then(res => {
$('link[data-stylesheet=dark]')
.attr('data-stylesheet', 'light')
.attr('href', '/css/app.css?v=' + Date.now());
this.modes.dark = false;
});
} else { } else {
this.modes.dark = true; axios.post('/i/metro/dark-mode', {
let head = document.head; mode: 'dark'
let link = document.createElement("link"); }).then(res => {
link.type = "text/css"; $('link[data-stylesheet=light]')
link.rel = "stylesheet"; .attr('data-stylesheet', 'dark')
link.href = "/css/appdark.css"; .attr('href', '/css/appdark.css?v=' + Date.now());
link.setAttribute('data-stylesheet','dark'); this.modes.dark = true;
head.appendChild(link); });
} }
window.ls.set('pixelfed-classicui-settings', this.modes); window.ls.set('pixelfed-classicui-settings', this.modes);
}, },

View File

@ -24,7 +24,11 @@
<link rel="shortcut icon" type="image/png" href="/img/favicon.png?v=2"> <link rel="shortcut icon" type="image/png" href="/img/favicon.png?v=2">
<link rel="apple-touch-icon" type="image/png" href="/img/favicon.png?v=2"> <link rel="apple-touch-icon" type="image/png" href="/img/favicon.png?v=2">
<link rel="canonical" href="{{request()->url()}}"> <link rel="canonical" href="{{request()->url()}}">
@if(request()->cookie('dark-mode'))
<link href="{{ mix('css/appdark.css') }}" rel="stylesheet" data-stylesheet="dark">
@else
<link href="{{ mix('css/app.css') }}" rel="stylesheet" data-stylesheet="light"> <link href="{{ mix('css/app.css') }}" rel="stylesheet" data-stylesheet="light">
@endif
@stack('styles') @stack('styles')
</head> </head>

View File

@ -134,6 +134,8 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
Route::get('results', 'SearchController@results'); Route::get('results', 'SearchController@results');
Route::post('visibility', 'StatusController@toggleVisibility'); Route::post('visibility', 'StatusController@toggleVisibility');
Route::post('metro/dark-mode', 'SettingsController@metroDarkMode');
Route::group(['prefix' => 'report'], function () { Route::group(['prefix' => 'report'], function () {
Route::get('/', 'ReportController@showForm')->name('report.form'); Route::get('/', 'ReportController@showForm')->name('report.form');
Route::post('/', 'ReportController@formStore'); Route::post('/', 'ReportController@formStore');
@ -222,10 +224,10 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
}); });
Route::get('applications', 'SettingsController@applications')->name('settings.applications')->middleware('dangerzone'); Route::get('applications', 'SettingsController@applications')->name('settings.applications')->middleware('dangerzone');
Route::get('data-export', 'SettingsController@dataExport')->name('settings.dataexport'); Route::get('data-export', 'SettingsController@dataExport')->name('settings.dataexport')->middleware('dangerzone');
Route::post('data-export/following', 'SettingsController@exportFollowing'); Route::post('data-export/following', 'SettingsController@exportFollowing')->middleware('dangerzone');
Route::post('data-export/followers', 'SettingsController@exportFollowers'); Route::post('data-export/followers', 'SettingsController@exportFollowers')->middleware('dangerzone');
Route::post('data-export/mute-block-list', 'SettingsController@exportMuteBlockList'); Route::post('data-export/mute-block-list', 'SettingsController@exportMuteBlockList')->middleware('dangerzone');
Route::get('developers', 'SettingsController@developers')->name('settings.developers')->middleware('dangerzone'); Route::get('developers', 'SettingsController@developers')->name('settings.developers')->middleware('dangerzone');
}); });