Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	public/build/manifest.json
  • Loading branch information
ilestis committed Aug 12, 2023
2 parents 66fe29e + 9132ddc commit 9bda8dc
Show file tree
Hide file tree
Showing 32 changed files with 114 additions and 60 deletions.
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function schedule(Schedule $schedule): void
$schedule->command(CleanupEntityLogs::class)->dailyAt('03:30');
$schedule->command(AnonymiseUserLogs::class)->dailyAt('03:50');
$schedule->command(CleanupTrashed::class)->dailyAt('02:15');
//$schedule->command(CleanupUsers::class)->dailyAt('01:50');
$schedule->command(CleanupUsers::class)->dailyAt('01:50');
}

/**
Expand Down
6 changes: 4 additions & 2 deletions app/Http/Controllers/Entity/AttributeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public function index(Entity $entity)
'entity',
'model',
'marketplaceTemplate',
'template'
'template',
'campaign'
));
}

Expand Down Expand Up @@ -115,7 +116,8 @@ public function dashboard(Entity $entity)
'entity',
'model',
'marketplaceTemplate',
'template'
'template',
'campaign'
));
}

Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/Entity/StoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function more(Entity $entity)
return view('entities.components.posts')
->with('entity', $entity)
->with('model', $entity->child)
->with('more', true)
->with('campaign', $campaign)
->with('pinnedPosts', $posts);
}
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Resources/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Resources;

use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str;

class Entity extends EntityChild
Expand All @@ -24,6 +25,7 @@ public function toArray($request)
$url = $model->url();
$lang = request()->header('kanka-locale', auth()->user()->locale ?? 'en');
$url = Str::replaceFirst('campaign/', $lang . '/campaign/', $url);
$apiViewUrl = 'campaigns.' . $model->pluralType() . '.show';

return [
'id' => $model->child->id,
Expand All @@ -49,7 +51,7 @@ public function toArray($request)

'urls' => [
'view' => $url,
'api' => route('campaigns.' . $model->pluralType() . '.show', [$model->campaign_id, $model->entity_id]),
'api' => Route::has($apiViewUrl) ? route($apiViewUrl, [$model->campaign_id, $model->entity_id]) : null,
]
];
}
Expand Down
1 change: 1 addition & 0 deletions app/Mail/Purge/FirstWarning.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function envelope(): Envelope
return new Envelope(
from: new Address('[email protected]', 'Kanka'),
subject: __('emails/purge/first.title', ['amount' => config('purge.users.first.limit')]),
tags: ['purge', 'first']
);
}

Expand Down
3 changes: 3 additions & 0 deletions app/Mail/Purge/SecondWarning.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
Expand Down Expand Up @@ -37,7 +38,9 @@ public function __construct(User $user, mixed $campaigns)
public function envelope(): Envelope
{
return new Envelope(
from: new Address('[email protected]', 'Kanka'),
subject: __('emails/purge/second.title', ['amount' => config('purge.users.second.limit')]),
tags: ['purge', 'second']
);
}

Expand Down
5 changes: 4 additions & 1 deletion app/Models/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ public function adminCount(): int
*/
public function userIsMember(User $user = null): bool
{
return CampaignCache::members()->where('user_id', $user ?? auth()->user()->id)->count() == 1;
if (empty($user)) {
$user = auth()->user();
}
return CampaignCache::members()->where('user_id', $user->id)->count() == 1;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion app/Models/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ public function allCharacters()
};

$table = new Character();
return Character::whereIn($table->getTable() . '.location_id', $locationIds)->with('location');
return Character::whereIn($table->getTable() . '.location_id', $locationIds)
->with('location')
->has('entity');
}

/**
Expand Down
8 changes: 8 additions & 0 deletions app/Models/TimelineElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,12 @@ public function mentions()
{
return $this->hasMany('App\Models\EntityMention', 'timeline_element_id', 'id');
}

public function visible(): bool
{
if (empty($this->entity_id)) {
return true;
}
return !empty($this->entity->child);
}
}
3 changes: 3 additions & 0 deletions app/Models/TimelineEra.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ public function positionOptions($position = null, bool $new = false): array
$elements = $this->orderedElements;
$hasFirst = false;
foreach ($elements as $element) {
if (!$element->visible()) {
continue;
}
if (!$hasFirst) {
$hasFirst = true;
$options[1] = __('posts.position.first');
Expand Down
10 changes: 5 additions & 5 deletions app/Services/AttributeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,11 @@ public function templateList(): array
}

// Kanka templates - deprecated as of 1.30
/*$key = __('attributes/templates.list.kanka');
foreach (config('attribute-templates.templates') as $code => $class) {
$template = new $class();
$templates[$key][$code] = $template->name();
}*/
// $key = __('attributes/templates.list.kanka');
// foreach (config('attribute-templates.templates') as $code => $class) {
// $template = new $class();
// $templates[$key][$code] = $template->name();
// }

// If the campaign isn't boosted, or the marketplace isn't enable, end here
if (!$this->campaign->boosted() || !config('marketplace.enabled')) {
Expand Down
2 changes: 1 addition & 1 deletion app/Services/Logs/ApiLogService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ApiLogService

public function log()
{
if (!env('DB_LOGS_DATABASE', false)) {
if (!config('logging.api')) {
return;
}

Expand Down
21 changes: 21 additions & 0 deletions app/Services/MentionsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,30 @@ protected function extractAndReplace()
// Clean up weird ` chars that break the js
$this->text = str_replace('`', '\'', $this->text);

$this->fixGalleryUrls();

return $this->text;
}

/**
* The gallery injects images as a thumbnail, instead of the final URL.
* Meaning that when we switched from images.kanka.io to th.kanka.io,
* all the gallery images in text were broken.
* @return $this
*/
protected function fixGalleryUrls(): self
{
if (empty(config('thumbor.key'))) {
return $this;
}
$this->text = Str::replace(
'https://images.kanka.io/user/',
config('thumbor.url'),
$this->text
);
return $this;
}

/**
* @return string
*/
Expand Down
5 changes: 4 additions & 1 deletion app/Services/Subscription/SubscriptionEndService.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ public function run(bool $dispatch = true): int

$this->logs[] = 'Sofort';
$subscriptions = Subscription::with(['user', 'user.boosts', 'user.boosts.campaign'])
->where('stripe_id', 'like', 'sofort_%')
->where(function ($sub) {
$sub->where('stripe_id', 'like', 'sofort_%')
->orWhere('stripe_id', 'like', 'giropay_%');
})
->where('stripe_status', 'active')
->whereDate('ends_at', '<', Carbon::today()->toDateString())
->get();
Expand Down
2 changes: 1 addition & 1 deletion app/Services/SubscriptionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public function sourceCharge(array $payload)
'green'
)
);
} catch(Exception $e) {
} catch (Exception $e) {
$this->user->notify(
new Header(
'subscriptions.charge_fail',
Expand Down
2 changes: 2 additions & 0 deletions config/logging.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,6 @@
'level' => 'debug',
],
],

'api' => env('DB_LOGS_DATABASE'),
];
4 changes: 2 additions & 2 deletions database/migrations/2023_06_10_220139_create_api_logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
public function up(): void
{
if (!env('DB_LOGS_DATABASE', false)) {
if (!config('logging.api')) {
return;
}
Schema::connection('logs')->create('api_logs', function (Blueprint $table) {
Expand All @@ -29,7 +29,7 @@ public function up(): void
*/
public function down(): void
{
if (!env('DB_LOGS_DATABASE', false)) {
if (!config('logging.api')) {
return;
}
Schema::connection('logs')->dropIfExists('api_logs');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
*/
public function up(): void
{
if (!config('logging.api')) {
return;
}
Schema::connection('logs')->create('user_logs', function (Blueprint $table) {
$table->id();
$table->integer('user_id')->unsigned();
Expand All @@ -27,6 +30,9 @@ public function up(): void
*/
public function down(): void
{
if (!config('logging.api')) {
return;
}
Schema::dropIfExists('user_logs');
}
};
2 changes: 1 addition & 1 deletion lang/en/settings/appearance.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
'advanced-mentions' => 'When editing texts, control if mentions are rendered as the entity\'s name, or as the advanced mention.',
'campaign-order' => 'Change the order in which campaigns are listed in the campaign switcher.',
'date-format' => 'When available, control the format in which to display real world dates.',
'default-nested' => 'Control how lists which support nesting to be displayed by default.',
'default-nested' => 'Control how lists which support nesting are displayed by default.',
'editor' => 'Using the legacy text editor (TinyMCE) doesn\'t support mentions on mobile devices, campaign galleries or other advanced features.',
'entity-explore' => 'Control the way in which entity lists are displayed on campaigns.',
'new-entity-workflow' => 'Control which interface you are taken to after creating a new entity.',
Expand Down
1 change: 1 addition & 0 deletions public/build/assets/app-56f9e212.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/build/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,4 @@
"isEntry": true,
"src": "resources/sass/vendor.scss"
}
}
}
6 changes: 3 additions & 3 deletions resources/js/post-layouts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ $(document).ready(function () {
function initPostLayoutsForm() {
let selector = $('#post-layout-selector');
if (selector.length === 0) {
return false;
return;
}
selector.change(function (e) {
e.preventDefault();
let selected = $(this).find(":selected").val();

if (selected == '') {
if (selected === '') {
$('#field-entry').show();
$('#field-location').show();
$('#field-display').show();
$('#post-layout-subform').hide();

$('#post-layout-subform').hide();
} else {
$('#field-entry').hide();
$('#field-location').hide();
Expand Down
7 changes: 5 additions & 2 deletions resources/js/utility/formError.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ window.formErrorHandler = function(err, form) {
foundAllErrors = false;
logs.push(errors[i][0]);
}

window.showToast(errors[i][0], 'toast-error');
});

// If not all error fields could be found, show a generic error message on top of the form.
Expand All @@ -49,7 +51,7 @@ window.formErrorHandler = function(err, form) {
}

// No tabs? Try no further
if ($(this).find('.tab-content').length === 0) {
if ($(form).find('.tab-content').length === 0) {
return;
}

Expand All @@ -60,10 +62,11 @@ window.formErrorHandler = function(err, form) {
if (!firstItemDom[0]) {
return;
}
firstItemDom[0].scrollIntoView({ behavior: 'smooth' });
$('.tab-content .active').removeClass('active');
$('.nav-tabs li.active').removeClass('active');
let firstPane = $('[name="' + firstItem + '"').closest('.tab-pane');
firstPane.addClass('active');
$('a[href="#' + firstPane.attr('id') + '"]').closest('li').addClass('active');

firstItemDom[0].scrollIntoView({ behavior: 'smooth' });
}
26 changes: 8 additions & 18 deletions resources/views/cruds/forms/attributes/_buttons.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</ul>
</div>
@if (isset($entity) && $entity->attributes()->where('is_hidden', '1')->get()->has('0'))
<button type="button" class="btn2 btn-ghost" data-toggle="modal" data-target="#hidden-attributes">
<button type="button" class="btn2 btn-ghost" data-toggle="dialog" data-target="hidden-attributes">
<i class="fa-solid fa-eye-slash" aria-hidden="true"></i>
{{ __('entities/attributes.actions.show_hidden') }}
</button>
Expand Down Expand Up @@ -83,23 +83,13 @@
@section('modals')
@parent
@if (isset($entity) && $entity->attributes()->where('is_hidden', '1')->get()->has('0'))
<div class="modal fade" id="hidden-attributes" tabindex="-1" role="dialog" aria-labelledby="clickConfirmLabel">
<div class="modal-dialog" role="document">
<div class="modal-content bg-base-100 rounded-2xl text-center">
<div class="modal-body">
<x-dialog.close />
<h4 class="modal-title md-5" id="clickModalLabel">{{ __('entities/attributes.show.hidden') }}</h4>
<p class="mt-5">
@foreach ($entity->attributes()->ordered()->get() as $attribute)
@if ($attribute->is_hidden)
@include('cruds.forms.attributes._hidden_attribute')
@endif
@endforeach
</p>
</div>
</div>
</div>
</div>
<x-dialog id="hidden-attributes" :title="__('entities/attributes.show.hidden')" :full="true">
@foreach ($entity->attributes()->ordered()->get() as $attribute)
@if ($attribute->is_hidden)
@include('cruds.forms.attributes._hidden_attribute')
@endif
@endforeach
</x-dialog>
@endif
<x-dialog id="attributes-delete-all-confirm" :title="__('crud.delete_modal.title')">
<p>
Expand Down
20 changes: 9 additions & 11 deletions resources/views/cruds/forms/attributes/_hidden_attribute.blade.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<div class="field-hidden-attribute">
<div class="row attribute_row">
<div class="col-xs-12 col-sm-4">
<dt>{{ $attribute->name }}</dt>
</div>
@if ($attribute->isCheckbox())
<i class="@if($attribute->value == 1)fa-solid fa-check-square @else fa-solid fa-square @endif mr-2 fa-2x" data-tab="{{ __('entities/attributes.visibility.tab') }}" data-entry="{{ __('entities/attributes.visibility.entry') }}" title="@if($attribute->isPinned()) {{ __('entities/attributes.visibility.entry') }} @else {{ __('entities/attributes.visibility.tab') }} @endif"></i>
@else
{{ $attribute->value }}
@endif
</div>
<div class="field-hidden-attribute w-full grid grid-cols-2">
<span>{{ $attribute->name }}</span>
<span>
@if ($attribute->isCheckbox())
<i class="@if($attribute->value == 1)fa-solid fa-check-square @else fa-solid fa-square @endif mr-2 fa-2x" data-tab="{{ __('entities/attributes.visibility.tab') }}" data-entry="{{ __('entities/attributes.visibility.entry') }}" title="@if($attribute->isPinned()) {{ __('entities/attributes.visibility.entry') }} @else {{ __('entities/attributes.visibility.tab') }} @endif"></i>
@else
{{ $attribute->value }}
@endif
</span>
</div>
Loading

0 comments on commit 9bda8dc

Please sign in to comment.