mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 00:34:50 +00:00
commit
08dd3bf66a
5 changed files with 120 additions and 32 deletions
|
@ -87,6 +87,8 @@
|
|||
- Updated LikeService, fix likedBy method. ([a5e64da6](https://github.com/pixelfed/pixelfed/commit/a5e64da6))
|
||||
- Updated PublicApiController, increase public timeline to 6 months from 3. ([8a736432](https://github.com/pixelfed/pixelfed/commit/8a736432))
|
||||
- Updated LikeService, show like count to status owner. ([4408e2ef](https://github.com/pixelfed/pixelfed/commit/4408e2ef))
|
||||
- Updated admin settings, add rules. ([a4efbb75](https://github.com/pixelfed/pixelfed/commit/a4efbb75))
|
||||
- Updated LikeService, fix authentication bug. ([c9abd70e](https://github.com/pixelfed/pixelfed/commit/c9abd70e))
|
||||
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||
|
||||
## [v0.10.10 (2021-01-28)](https://github.com/pixelfed/pixelfed/compare/v0.10.9...v0.10.10)
|
||||
|
|
|
@ -19,6 +19,7 @@ trait AdminSettingsController
|
|||
$short_description = ConfigCacheService::get('app.short_description');
|
||||
$description = ConfigCacheService::get('app.description');
|
||||
$types = explode(',', ConfigCacheService::get('pixelfed.media_types'));
|
||||
$rules = ConfigCacheService::get('app.rules') ? json_decode(ConfigCacheService::get('app.rules'), true) : null;
|
||||
$jpeg = in_array('image/jpg', $types) ? true : in_array('image/jpeg', $types);
|
||||
$png = in_array('image/png', $types);
|
||||
$gif = in_array('image/gif', $types);
|
||||
|
@ -31,7 +32,8 @@ trait AdminSettingsController
|
|||
'jpeg',
|
||||
'png',
|
||||
'gif',
|
||||
'mp4'
|
||||
'mp4',
|
||||
'rules'
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -50,6 +52,19 @@ trait AdminSettingsController
|
|||
'type_mp4' => 'nullable',
|
||||
]);
|
||||
|
||||
if($request->filled('rule_delete')) {
|
||||
$index = (int) $request->input('rule_delete');
|
||||
$rules = ConfigCacheService::get('app.rules');
|
||||
$json = json_decode($rules, true);
|
||||
if(!$rules || empty($json)) {
|
||||
return;
|
||||
}
|
||||
unset($json[$index]);
|
||||
$json = json_encode(array_values($json));
|
||||
ConfigCacheService::put('app.rules', $json);
|
||||
return 200;
|
||||
}
|
||||
|
||||
$media_types = explode(',', config_cache('pixelfed.media_types'));
|
||||
$media_types_original = $media_types;
|
||||
|
||||
|
@ -115,6 +130,18 @@ trait AdminSettingsController
|
|||
}
|
||||
}
|
||||
|
||||
if($request->filled('new_rule')) {
|
||||
$rules = ConfigCacheService::get('app.rules');
|
||||
$val = $request->input('new_rule');
|
||||
if(!$rules) {
|
||||
ConfigCacheService::put('app.rules', json_encode([$val]));
|
||||
} else {
|
||||
$json = json_decode($rules, true);
|
||||
$json[] = $val;
|
||||
ConfigCacheService::put('app.rules', json_encode(array_values($json)));
|
||||
}
|
||||
}
|
||||
|
||||
Cache::forget('api:site:configuration:_v0.2');
|
||||
|
||||
return redirect('/i/admin/settings');
|
||||
|
|
|
@ -957,37 +957,49 @@ class ApiV1Controller extends Controller
|
|||
*/
|
||||
public function instance(Request $request)
|
||||
{
|
||||
$res = [
|
||||
'approval_required' => false,
|
||||
'contact_account' => null,
|
||||
'description' => config_cache('app.description'),
|
||||
'email' => config('instance.email'),
|
||||
'invites_enabled' => false,
|
||||
'rules' => [],
|
||||
'short_description' => 'Pixelfed - Photo sharing for everyone',
|
||||
'languages' => ['en'],
|
||||
'max_toot_chars' => (int) config('pixelfed.max_caption_length'),
|
||||
'registrations' => config_cache('pixelfed.open_registration'),
|
||||
'stats' => [
|
||||
'user_count' => 0,
|
||||
'status_count' => 0,
|
||||
'domain_count' => 0
|
||||
],
|
||||
'thumbnail' => config('app.url') . '/img/pixelfed-icon-color.png',
|
||||
'title' => config_cache('app.name'),
|
||||
'uri' => config('pixelfed.domain.app'),
|
||||
'urls' => [],
|
||||
'version' => '2.7.2 (compatible; Pixelfed ' . config('pixelfed.version') . ')',
|
||||
'environment' => [
|
||||
'max_photo_size' => (int) config_cache('pixelfed.max_photo_size'),
|
||||
'max_avatar_size' => (int) config('pixelfed.max_avatar_size'),
|
||||
'max_caption_length' => (int) config('pixelfed.max_caption_length'),
|
||||
'max_bio_length' => (int) config('pixelfed.max_bio_length'),
|
||||
'max_album_length' => (int) config_cache('pixelfed.max_album_length'),
|
||||
'mobile_apis' => config_cache('pixelfed.oauth_enabled')
|
||||
$res = Cache::remember('api:v1:instance-data', now()->addMinutes(15), function () {
|
||||
$rules = config_cache('app.rules') ? collect(json_decode(config_cache('app.rules'), true))
|
||||
->map(function($rule, $key) {
|
||||
$id = $key + 1;
|
||||
return [
|
||||
'id' => "{$id}",
|
||||
'text' => $rule
|
||||
];
|
||||
})
|
||||
->toArray() : [];
|
||||
$res = [
|
||||
'approval_required' => false,
|
||||
'contact_account' => null,
|
||||
'description' => config_cache('app.description'),
|
||||
'email' => config('instance.email'),
|
||||
'invites_enabled' => false,
|
||||
'rules' => $rules,
|
||||
'short_description' => 'Pixelfed - Photo sharing for everyone',
|
||||
'languages' => ['en'],
|
||||
'max_toot_chars' => (int) config('pixelfed.max_caption_length'),
|
||||
'registrations' => config_cache('pixelfed.open_registration'),
|
||||
'stats' => [
|
||||
'user_count' => 0,
|
||||
'status_count' => 0,
|
||||
'domain_count' => 0
|
||||
],
|
||||
'thumbnail' => config('app.url') . '/img/pixelfed-icon-color.png',
|
||||
'title' => config_cache('app.name'),
|
||||
'uri' => config('pixelfed.domain.app'),
|
||||
'urls' => [],
|
||||
'version' => '2.7.2 (compatible; Pixelfed ' . config('pixelfed.version') . ')',
|
||||
'environment' => [
|
||||
'max_photo_size' => (int) config_cache('pixelfed.max_photo_size'),
|
||||
'max_avatar_size' => (int) config('pixelfed.max_avatar_size'),
|
||||
'max_caption_length' => (int) config('pixelfed.max_caption_length'),
|
||||
'max_bio_length' => (int) config('pixelfed.max_bio_length'),
|
||||
'max_album_length' => (int) config_cache('pixelfed.max_album_length'),
|
||||
'mobile_apis' => config_cache('pixelfed.oauth_enabled')
|
||||
|
||||
]
|
||||
];
|
||||
]
|
||||
];
|
||||
return $res;
|
||||
});
|
||||
return response()->json($res);
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ class LikeService {
|
|||
'others' => $status->likes_count >= 5,
|
||||
];
|
||||
|
||||
if(request()->user()->profile_id == $status->profile_id) {
|
||||
if(request()->user() && request()->user()->profile_id == $status->profile_id) {
|
||||
$res['total_count'] = $status->likes_count;
|
||||
$res['total_count_pretty'] = number_format($res['total_count']);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
<li class="nav-item border-none">
|
||||
<a class="nav-link font-weight-bold px-4" id="users-tab" data-toggle="tab" href="#users" role="tab" aria-controls="users">Users</a>
|
||||
</li>
|
||||
<li class="nav-item border-none">
|
||||
<a class="nav-link font-weight-bold px-4" id="rules-tab" data-toggle="tab" href="#rules" role="tab" aria-controls="rules">Rules</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link font-weight-bold px-4" id="advanced-tab" data-toggle="tab" href="#advanced" role="tab" aria-controls="advanced">Advanced</a>
|
||||
</li>
|
||||
|
@ -151,6 +154,35 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane" id="rules" role="tabpanel" aria-labelledby="rules-tab">
|
||||
<div class="border-top">
|
||||
<p class="lead mt-3 py-3 text-center">Add rules that explain what is acceptable use.</p>
|
||||
</div>
|
||||
<div class="ml-n4 mr-n2 p-3 bg-light border-top border-bottom">
|
||||
<p class="font-weight-bold text-muted">Active Rules</p>
|
||||
<ol class="font-weight-bold">
|
||||
@if($rules)
|
||||
@foreach($rules as $rule)
|
||||
<li class="mb-4">
|
||||
<p class="mb-0">
|
||||
{{$rule}}
|
||||
</p>
|
||||
<p>
|
||||
<button type="button" class="btn btn-outline-danger btn-sm py-0 rule-delete" data-index="{{$loop->index}}">Delete</button>
|
||||
</p>
|
||||
</li>
|
||||
@endforeach
|
||||
@endif
|
||||
</ol>
|
||||
</div>
|
||||
<div class="form-group mb-0">
|
||||
<div class="ml-n4 mr-n2 p-3 bg-light border-top border-bottom">
|
||||
<label class="font-weight-bold text-muted">Add Rule</label>
|
||||
<input class="form-control" name="new_rule" placeholder="Add a new rule, we recommend being descriptive but keeping it short"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane" id="advanced" role="tabpanel" aria-labelledby="advanced-tab">
|
||||
<div class="form-group mb-0">
|
||||
<div class="ml-n4 mr-n2 p-3 bg-light border-top border-bottom">
|
||||
|
@ -181,3 +213,18 @@
|
|||
</div>
|
||||
@endif
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
$('.rule-delete').on('click', function(e) {
|
||||
if(window.confirm('Are you sure you want to delete this rule?')) {
|
||||
let idx = e.target.dataset.index;
|
||||
axios.post(window.location.href, {
|
||||
'rule_delete': idx
|
||||
}).then(res => {
|
||||
$('.rule-delete[data-index="'+idx+'"]').parents().eq(1).remove();
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
|
Loading…
Reference in a new issue