Skip to content

Commit

Permalink
Merge pull request #15 from tomatophp/develop
Browse files Browse the repository at this point in the history
add sponsering feature
  • Loading branch information
3x1io authored Mar 26, 2024
2 parents 0e13687 + 892144e commit dab9514
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 8 deletions.
13 changes: 13 additions & 0 deletions Modules/CircleXO/App/Http/Controllers/CircleXOController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ public function verify(Account $account)
return redirect()->back();
}



public function sponsoring($username)
{
$account = Account::where('username', $username)->first();
if($account && $account->meta('sponsoring_message') && $account->meta('sponsoring_link')){
return view('circle-xo::sponsoring', compact('account'));
}
else {
abort(404);
}
}

public function contact($username)
{
$account = Account::where('username', $username)->first();
Expand Down
10 changes: 10 additions & 0 deletions Modules/CircleXO/App/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public function index(Request $request)
return view('circle-xo::profile.index', compact('listing'));
}

public function sponsoring()
{
return view('circle-xo::profile.edit.sponsoring');
}

public function socialAccounts()
{
return view('circle-xo::profile.edit.social-accounts');
Expand Down Expand Up @@ -273,6 +278,11 @@ public function updateMeta(Request $request)
$account->meta('social', $request->get('social'));
}

if($request->has('sponsoring_link') || $request->has('sponsoring_message')){
$account->meta('sponsoring_message', $request->get('sponsoring_message'));
$account->meta('sponsoring_link', $request->get('sponsoring_link'));
}

Toast::success('Profile updated successfully')->autoDismiss(2);
return redirect()->back();

Expand Down
2 changes: 1 addition & 1 deletion Modules/CircleXO/App/View/Components/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class Button extends Component
{
public array $primaryClass = ['bg-main-600 hover:bg-main-400', 'text-zinc-800', 'border', 'border-zinc-700'];
public array $primaryClass = ['bg-main-600 hover:bg-main-400', 'text-zinc-700', 'border', 'border-zinc-700'];
public array $secondaryClass = ['bg-second-600 hover:bg-second-400', 'text-white' , 'border', 'border-zinc-700'];
public array $theadClass = ['bg-thead-600 hover:bg-thead-400', 'text-white' , 'border', 'border-zinc-700'];
public array $successClass = ['bg-success-600', 'text-white'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,16 @@
</div>
</div>
<div class="flex justify-center md:justify-end gap-4 mt-8 mx-16">
<x-circle-xo-button modal href="{{route('profile.qr')}}" size="sm" success>
<i class="bx bx-qr"></i>
</x-circle-xo-button>
<x-tomato-admin-tooltip :text="__('QR Generator')">
<x-splade-link modal href="{{route('profile.qr')}}" class="bg-success-600 text-white rounded-md shadow-md font-bold text-sm px-4 py-2">
<i class="bx bx-qr"></i>
</x-splade-link>
</x-tomato-admin-tooltip>
<x-tomato-admin-tooltip :text="__('Sponsoring')">
<x-splade-link modal href="{{route('profile.sponsoring.show')}}" class="bg-danger-600 text-white rounded-md shadow-md font-bold text-sm px-4 py-2">
<i class="bx bxs-heart"></i>
</x-splade-link>
</x-tomato-admin-tooltip>
<x-tomato-admin-tooltip :text="__('Settings')">
<x-tomato-admin-dropdown>
<x-slot:button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@
<x-circle-xo-button href="{{route('profile.actions.unfollow', $account->username)}}" danger confirm-danger :label="__('UnFollow')" size="sm"/>
@endif
@endif
@if($account->meta('sponsoring_link'))
<x-tomato-admin-tooltip :text="__('Sponsoring')">
<x-splade-link href="{{ route('home.sponsoring', $account->username) }}" class="bg-danger-600 text-white rounded-md shadow-md font-bold text-sm px-4 py-2">
<i class="bx bxs-heart text-white"></i>
</x-splade-link>
</x-tomato-admin-tooltip>
@endif
</div>
<div class="justify-center md:justify-start gap-4 my-8 mx-16 flex lg:hidden">
<x-circle-xo-social-links :account="$account"/>
Expand Down
4 changes: 2 additions & 2 deletions Modules/CircleXO/resources/views/post.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div class="mx-8 text-center lg:mx-16">
<h1 class="text-4xl">{{ $post->title }}</h1>
</div>
<div class="mt-8">
<x-tomato-markdown-viewer :content="$post->body" />
<div class="mt-8 mx-8 lg:mx-16">
<x-tomato-markdown-viewer style="background-color: rgb(39 39 42 / var(--tw-bg-opacity)) !important;" :content="$post->body" />
</div>
</x-circle-xo-public-profile-layout>
14 changes: 14 additions & 0 deletions Modules/CircleXO/resources/views/profile/edit/sponsoring.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<x-splade-modal>
<x-slot:title>
{{ __('Sponsoring Link') }}
</x-slot>
<x-splade-form :default="[
'sponsoring_link' => auth('accounts')->user()->meta('sponsoring_link'),
'sponsoring_message' => auth('accounts')->user()->meta('sponsoring_message'),
]" class="flex flex-col gap-4" method="POST" action="{{route('profile.meta.update')}}">
<x-splade-input name="sponsoring_link" :label="__('Sponsoring Link')" />
<x-tomato-markdown-editor name="sponsoring_message" :label="__('Sponsoring Message')" />

<x-splade-submit spinner :label="__('Save')" class="bg-main-600 border-main-400 text-zinc-900" />
</x-splade-form>
</x-splade-modal>
38 changes: 38 additions & 0 deletions Modules/CircleXO/resources/views/sponsoring.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@php
SEO::openGraphType('WebPage');
SEO::openGraphSiteName('Sponsoring '. $account->username .' | '. setting('site_name'));
SEO::openGraphTitle('Sponsoring '. $account->username .' | '. setting('site_name'));
SEO::openGraphUrl(url()->current());
SEO::openGraphImage($account->avatar ?? setting('site_profile'));
SEO::metaByProperty('og:description',setting('site_description'));
SEO::twitterCard('summary_large_image');
SEO::twitterTitle('Sponsoring '. $account->username .' | '. setting('site_name'));
SEO::twitterDescription(setting('site_description'));
SEO::twitterImage($account->avatar ?? setting('site_profile'));
SEO::canonical(url()->current());
@endphp
@seoTitle('Sponsoring '. $account->username .' | '. setting('site_name'))
@seoDescription(setting('site_description'))
@seoKeywords(setting('site_keywords'))

<x-circle-xo-public-profile-layout :account="$account">
<div class="bg-zinc-800 border border-zinc-700 mx-16 my-4 rounded-lg shadow-sm">
<div class="flex flex-col gap-4">
<div class="mx-4">
<x-tomato-markdown-viewer style="background-color: rgb(39 39 42 / var(--tw-bg-opacity)) !important;" :content="$account->meta('sponsoring_message')" />
</div>
<a class="mx-8 mb-6 bg-danger-600 hover:bg-danger-400 text-white border border-zinc-700 rounded-md shadow-md font-bold text-sm px-4 py-2" href="{{$account->meta('sponsoring_link')}}" target="_blank" >
<div class="flex justify-center gap-2">
<div class="flex flex-col justify-center items-center">
<i class="bx bxs-heart"></i>
</div>
<div>
{{ __('Buy me a Coffee') }}
</div>
</div>
</a>
</div>
</div>
</x-circle-xo-public-profile-layout>
2 changes: 2 additions & 0 deletions Modules/CircleXO/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
Route::get('/edit/cover', [ProfileController::class, 'cover'])->name('cover.show');
Route::get('/edit/info', [ProfileController::class, 'info'])->name('info.show');
Route::post('/edit/info', [ProfileController::class, 'updateInfo'])->name('info.update');
Route::get('/edit/sponsoring', [ProfileController::class, 'sponsoring'])->name('sponsoring.show');
Route::get('/edit/social', [ProfileController::class, 'social'])->name('social.show');
Route::post('/edit/social', [ProfileController::class, 'socialStore'])->name('social.store');
Route::get('/edit/social/{network}', [ProfileController::class, 'socialEdit'])->name('social.edit');
Expand Down Expand Up @@ -98,6 +99,7 @@

Route::middleware(['splade'])->group(function (){
Route::get('/{username}', [CircleXOController::class, 'profile'])->name('profile');
Route::get('/{username}/sponsoring', [CircleXOController::class, 'sponsoring'])->name('home.sponsoring');
Route::get('/{username}/contact', [CircleXOController::class, 'contact'])->name('home.contact');
Route::post('/{username}/contact', [CircleXOController::class, 'send'])->name('home.contact.send');
Route::get('/{username}/posts/{post}', [CircleXOController::class, 'post'])->name('home.posts');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<label>
<span class="block mb-1 text-zinc-700 font-sans dark:text-white">{{$label ?? ''}}</span>
</label>
<MdEditor {{ $attributes->only(['v-if', 'v-show', 'class'])->class(['hidden' => $isHidden()]) }}
<MdEditor previewTheme="github" theme="dark" {{ $attributes->only(['v-if', 'v-show', 'class'])->class(['hidden' => $isHidden()]) }}
v-model="{{ $vueModel() }}" language="en-US" :preview="@js($preview)" :toolbars="[
'bold',
'underline',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="font-main">
<MdPreview editorId="preview-only" modelValue="{{$content}}" language="en-US" class="font-main" />
<MdPreview editorId="preview-only" modelValue="{{$content}}" language="en-US" {{ $attributes }} previewTheme="github" theme="dark" />
</div>

0 comments on commit dab9514

Please sign in to comment.