forked from mirror/pixelfed
commit
d07d236c14
|
@ -3,6 +3,7 @@
|
|||
## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.10.10...dev)
|
||||
### Added
|
||||
- Autocomplete Support (hashtags + mentions) ([de514f7d](https://github.com/pixelfed/pixelfed/commit/de514f7d))
|
||||
- Creative Commons Licenses ([552e950](https://github.com/pixelfed/pixelfed/commit/552e950))
|
||||
|
||||
### Updated
|
||||
- Updated AdminController, fix variable name in updateSpam method. ([6edaf940](https://github.com/pixelfed/pixelfed/commit/6edaf940))
|
||||
|
|
|
@ -45,6 +45,7 @@ use App\Services\ServiceService;
|
|||
use Illuminate\Support\Str;
|
||||
use App\Util\Lexer\Autolink;
|
||||
use App\Util\Lexer\Extractor;
|
||||
use App\Util\Media\License;
|
||||
|
||||
class ComposeController extends Controller
|
||||
{
|
||||
|
@ -407,6 +408,7 @@ class ComposeController extends Controller
|
|||
'place' => 'nullable',
|
||||
'comments_disabled' => 'nullable',
|
||||
'tagged' => 'nullable',
|
||||
'license' => 'nullable|integer|min:1|max:16'
|
||||
// 'optimize_media' => 'nullable'
|
||||
]);
|
||||
|
||||
|
@ -439,6 +441,8 @@ class ComposeController extends Controller
|
|||
|
||||
abort_if($limitReached == true, 429);
|
||||
|
||||
$license = in_array($request->input('license'), License::keys()) ? $request->input('license') : null;
|
||||
|
||||
$visibility = $request->input('visibility');
|
||||
$medias = $request->input('media');
|
||||
$attachments = [];
|
||||
|
@ -458,7 +462,7 @@ class ComposeController extends Controller
|
|||
abort(403, 'Invalid media id');
|
||||
}
|
||||
$m->filter_class = in_array($media['filter_class'], Filter::classes()) ? $media['filter_class'] : null;
|
||||
$m->license = $media['license'];
|
||||
$m->license = $license;
|
||||
$m->caption = isset($media['alt']) ? strip_tags($media['alt']) : null;
|
||||
$m->order = isset($media['cursor']) && is_int($media['cursor']) ? (int) $media['cursor'] : $k;
|
||||
// if($optimize_media == false) {
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace App;
|
|||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Util\Media\License;
|
||||
use Storage;
|
||||
|
||||
class Media extends Model
|
||||
|
@ -101,4 +102,25 @@ class Media extends Model
|
|||
return $meta['Model'];
|
||||
}
|
||||
}
|
||||
|
||||
public function getLicense()
|
||||
{
|
||||
$license = $this->license;
|
||||
|
||||
if(!$license || strlen($license) > 2 || $license == 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(!in_array($license, License::keys())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$res = License::get()[$license];
|
||||
|
||||
return [
|
||||
'id' => $res['id'],
|
||||
'title' => $res['title'],
|
||||
'url' => $res['url']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,14 +10,6 @@ class MediaDraftTransformer extends Fractal\TransformerAbstract
|
|||
{
|
||||
public function transform(Media $media)
|
||||
{
|
||||
|
||||
$url = URL::temporarySignedRoute(
|
||||
'temp-media', now()->addHours(1), ['profileId' => $media->profile_id, 'mediaId' => $media->id, 'timestamp' => time()]
|
||||
);
|
||||
|
||||
//$url = $media->thumbnailUrl();
|
||||
//$url = $media->url();
|
||||
|
||||
return [
|
||||
'id' => (string) $media->id,
|
||||
'type' => $media->activityVerb(),
|
||||
|
|
|
@ -15,10 +15,11 @@ class MediaTransformer extends Fractal\TransformerAbstract
|
|||
'url' => $media->url(),
|
||||
'remote_url' => null,
|
||||
'preview_url' => $media->thumbnailUrl(),
|
||||
'optimized_url' => $media->optimized_url,
|
||||
'text_url' => null,
|
||||
'meta' => null,
|
||||
'description' => $media->caption,
|
||||
'license' => $media->license,
|
||||
'license' => $media->getLicense(),
|
||||
'is_nsfw' => $media->is_nsfw,
|
||||
'orientation' => $media->orientation,
|
||||
'filter_name' => $media->filter_name,
|
||||
|
|
|
@ -0,0 +1,123 @@
|
|||
<?php
|
||||
|
||||
namespace App\Util\Media;
|
||||
|
||||
class License {
|
||||
|
||||
public static function get()
|
||||
{
|
||||
return [
|
||||
1 => [
|
||||
"id" => 1,
|
||||
"title" => "All Rights Reserved",
|
||||
"name" => "All Rights Reserved",
|
||||
"description" => "You, the copyright holder, reserve all rights provided by copyright law, such as the right to make copies, distribute your work, perform your work, license, or otherwise exploit your work; no rights are waived under this license.",
|
||||
"terms" => [],
|
||||
"url" => url('/site/kb/licenses')
|
||||
],
|
||||
5 => [
|
||||
"id" => 5,
|
||||
"title" => "Public Domain",
|
||||
"name" => "Public Domain Work",
|
||||
"description" => "Works, or aspects of copyrighted works, which copyright law does not protect.",
|
||||
"terms" => [],
|
||||
"url" => url('/site/kb/licenses')
|
||||
],
|
||||
6 => [
|
||||
"id" => 6,
|
||||
"title" => "Public Domain (CC0)",
|
||||
"name" => "Public Domain Dedication (CC0)",
|
||||
"description" => "You, the copyright holder, waive your interest in your work and place the work as completely as possible in the public domain so others may freely exploit and use the work without restriction under copyright or database law.",
|
||||
"terms" => [],
|
||||
"url" => url('/site/kb/licenses')
|
||||
],
|
||||
11 => [
|
||||
"id" => 11,
|
||||
"title" => "CC BY",
|
||||
"name" => "Attribution",
|
||||
"description" => "This license allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, so long as attribution is given to the creator. The license allows for commercial use.",
|
||||
"terms" => [
|
||||
"Credit must be given to the creator",
|
||||
],
|
||||
"url" => "https://creativecommons.org/licenses/by/4.0/"
|
||||
],
|
||||
12 => [
|
||||
"id" => 12,
|
||||
"title" => "CC BY-SA",
|
||||
"name" => "Attribution-ShareAlike",
|
||||
"description" => "This license allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, so long as attribution is given to the creator. The license allows for commercial use. If you remix, adapt, or build upon the material, you must license the modified material under identical terms.",
|
||||
"terms" => [
|
||||
"Credit must be given to the creator",
|
||||
"Adaptations must be shared under the same terms"
|
||||
],
|
||||
"url" => "https://creativecommons.org/licenses/by-sa/4.0/"
|
||||
],
|
||||
13 => [
|
||||
"id" => 13,
|
||||
"title" => "CC BY-NC",
|
||||
"name" => "Attribution-NonCommercial",
|
||||
"description" => "This license allows reusers to distribute, remix, adapt, and build upon the material in any medium or format for noncommercial purposes only, and only so long as attribution is given to the creator.",
|
||||
"terms" => [
|
||||
"Credit must be given to the creator",
|
||||
"Only noncommercial uses of the work are permitted"
|
||||
],
|
||||
"url" => "https://creativecommons.org/licenses/by-nc/4.0/"
|
||||
],
|
||||
14 => [
|
||||
"id" => 14,
|
||||
"title" => "CC BY-NC-SA",
|
||||
"name" => "Attribution-NonCommercial-ShareAlike",
|
||||
"description" => "This license allows reusers to distribute, remix, adapt, and build upon the material in any medium or format for noncommercial purposes only, and only so long as attribution is given to the creator. If you remix, adapt, or build upon the material, you must license the modified material under identical terms.",
|
||||
"terms" => [
|
||||
"Credit must be given to the creator",
|
||||
"Only noncommercial uses of the work are permitted",
|
||||
"Adaptations must be shared under the same terms"
|
||||
],
|
||||
"url" => "https://creativecommons.org/licenses/by-nc-sa/4.0/"
|
||||
],
|
||||
15 => [
|
||||
"id" => 15,
|
||||
"title" => "CC BY-ND",
|
||||
"name" => "Attribution-NoDerivs",
|
||||
"description" => "This license allows reusers to copy and distribute the material in any medium or format in unadapted form only, and only so long as attribution is given to the creator. The license allows for commercial use.",
|
||||
"terms" => [
|
||||
"Credit must be given to the creator",
|
||||
"No derivatives or adaptations of the work are permitted"
|
||||
],
|
||||
"url" => "https://creativecommons.org/licenses/by-nd/4.0/"
|
||||
],
|
||||
16 => [
|
||||
"id" => 16,
|
||||
"title" => "CC BY-NC-ND",
|
||||
"name" => "Attribution-NonCommercial-NoDerivs",
|
||||
"description" => "This license allows reusers to copy and distribute the material in any medium or format in unadapted form only, for noncommercial purposes only, and only so long as attribution is given to the creator.",
|
||||
"terms" => [
|
||||
"Credit must be given to the creator",
|
||||
"Only noncommercial uses of the work are permitted",
|
||||
"No derivatives or adaptations of the work are permitted"
|
||||
],
|
||||
"url" => "https://creativecommons.org/licenses/by-nc-nd/4.0/"
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public static function keys()
|
||||
{
|
||||
return array_keys(self::get());
|
||||
}
|
||||
|
||||
public static function getId($index)
|
||||
{
|
||||
return self::get()[$index]['id'];
|
||||
}
|
||||
|
||||
public static function names()
|
||||
{
|
||||
return collect(self::get())
|
||||
->map(function($v) {
|
||||
return $v['title'];
|
||||
})
|
||||
->values()
|
||||
->toArray();
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -11,7 +11,7 @@
|
|||
"/js/collectioncompose.js": "/js/collectioncompose.js?id=37ac6f2e9cbcd035704f",
|
||||
"/js/collections.js": "/js/collections.js?id=be6208c4ab7909ad8ebe",
|
||||
"/js/components.js": "/js/components.js?id=56aa48f8042553148a78",
|
||||
"/js/compose.js": "/js/compose.js?id=b3e5045fe62e297a6e5a",
|
||||
"/js/compose.js": "/js/compose.js?id=d629fc34a60b65f031ee",
|
||||
"/js/compose-classic.js": "/js/compose-classic.js?id=ee4ad4759a55261c429c",
|
||||
"/js/developers.js": "/js/developers.js?id=f8efa9cb9101d403d6c2",
|
||||
"/js/direct.js": "/js/direct.js?id=735c52376bc4f3ec102e",
|
||||
|
@ -21,14 +21,14 @@
|
|||
"/js/memoryprofile.js": "/js/memoryprofile.js?id=1dbacb8b611b63cc22f2",
|
||||
"/js/mode-dot.js": "/js/mode-dot.js?id=dd9c87024fbaa8e75ac4",
|
||||
"/js/my2020.js": "/js/my2020.js?id=4a9d534053da8e6467c0",
|
||||
"/js/profile.js": "/js/profile.js?id=acdc921fc2ea7b476a8d",
|
||||
"/js/profile.js": "/js/profile.js?id=f3469b5168a03a23c26d",
|
||||
"/js/profile-directory.js": "/js/profile-directory.js?id=e63d5f2c6f2d5710a8bd",
|
||||
"/js/quill.js": "/js/quill.js?id=4769f11fc9a6c32dde50",
|
||||
"/js/rempos.js": "/js/rempos.js?id=69bf33a25900894c2f50",
|
||||
"/js/rempos.js": "/js/rempos.js?id=52fbe94346b945e11d37",
|
||||
"/js/rempro.js": "/js/rempro.js?id=6cca99808897aaf5acf5",
|
||||
"/js/search.js": "/js/search.js?id=f4319adfd5750db3be3f",
|
||||
"/js/status.js": "/js/status.js?id=cdf850818bac9639396d",
|
||||
"/js/status.js": "/js/status.js?id=311b2e82ad99e438673c",
|
||||
"/js/story-compose.js": "/js/story-compose.js?id=99dc1cd352d71e41843d",
|
||||
"/js/theme-monokai.js": "/js/theme-monokai.js?id=85f0af57479412548223",
|
||||
"/js/timeline.js": "/js/timeline.js?id=65cfce416d234f8e790f"
|
||||
"/js/timeline.js": "/js/timeline.js?id=e9b136c9c89d1be0a80b"
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="page == 'cameraRoll'">
|
||||
<div class="card status-card card-md-rounded-0" style="display:flex;">
|
||||
<div class="card-header d-inline-flex align-items-center justify-content-between bg-white">
|
||||
|
@ -42,6 +43,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
<div class="card status-card card-md-rounded-0 w-100 h-100" style="display:flex;">
|
||||
<div class="card-header d-inline-flex align-items-center justify-content-between bg-white">
|
||||
|
@ -91,8 +93,21 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="card-body p-0 border-top">
|
||||
<div v-if="page == 'licensePicker'" class="w-100 h-100" style="min-height: 280px;">
|
||||
<div class="list-group list-group-flush">
|
||||
<div
|
||||
v-for="(item, index) in availableLicenses"
|
||||
class="list-group-item cursor-pointer"
|
||||
:class="{
|
||||
'text-primary': licenseIndex === index,
|
||||
'font-weight-bold': licenseIndex === index
|
||||
}"
|
||||
@click="toggleLicense(index)">
|
||||
{{item.name}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="page == 'textOptions'" class="w-100 h-100" style="min-height: 280px;">
|
||||
test
|
||||
</div>
|
||||
<div v-if="page == 'addText'" class="w-100 h-100" style="min-height: 280px;">
|
||||
<div class="mt-2">
|
||||
|
@ -315,7 +330,10 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="border-bottom">
|
||||
<p class="px-4 mb-0 py-2 cursor-pointer" @click="showTagCard()">Tag people <span class="ml-2 badge badge-primary">NEW</span></p>
|
||||
<p class="px-4 mb-0 py-2 cursor-pointer" @click="showTagCard()">Tag people</p>
|
||||
</div>
|
||||
<div class="border-bottom">
|
||||
<p class="px-4 mb-0 py-2 cursor-pointer" @click="showLicenseCard()">Add license <span class="ml-2 badge badge-primary">NEW</span></p>
|
||||
</div>
|
||||
<div class="border-bottom">
|
||||
<p class="px-4 mb-0 py-2 cursor-pointer" @click="showLocationCard()" v-if="!place">Add location</p>
|
||||
|
@ -565,11 +583,19 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<label class="font-weight-bold text-muted small">License</label>
|
||||
<input type="text" class="form-control" v-model="media[carouselCursor].license" placeholder="All Rights Reserved (Default license)">
|
||||
<p class="help-text small text-muted mb-0 d-flex justify-content-between">
|
||||
<!-- <input type="text" class="form-control" v-model="media[carouselCursor].license" placeholder="All Rights Reserved (Default license)"> -->
|
||||
<!-- <p class="help-text small text-muted mb-0 d-flex justify-content-between">
|
||||
<span></span>
|
||||
<span>{{media[carouselCursor].license ? media[carouselCursor].license.length : 0}}/140</span>
|
||||
</p>
|
||||
</p> -->
|
||||
<select class="form-control" v-model="licenseIndex">
|
||||
<option
|
||||
v-for="(item, index) in availableLicenses"
|
||||
:value="index"
|
||||
:selected="index === licenseIndex">
|
||||
{{item.name}}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -707,7 +733,8 @@ export default {
|
|||
'editMedia',
|
||||
'cameraRoll',
|
||||
'tagPeopleHelp',
|
||||
'textOptions'
|
||||
'textOptions',
|
||||
'licensePicker'
|
||||
],
|
||||
cameraRollMedia: [],
|
||||
taggedUsernames: [],
|
||||
|
@ -744,7 +771,46 @@ export default {
|
|||
})
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
availableLicenses: [
|
||||
{
|
||||
id: 1,
|
||||
name: "All Rights Reserved"
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: "Public Domain Work"
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: "Public Domain Dedication (CC0)"
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
name: "Attribution"
|
||||
},
|
||||
{
|
||||
id: 12,
|
||||
name: "Attribution-ShareAlike"
|
||||
},
|
||||
{
|
||||
id: 13,
|
||||
name: "Attribution-NonCommercial"
|
||||
},
|
||||
{
|
||||
id: 14,
|
||||
name: "Attribution-NonCommercial-ShareAlike"
|
||||
},
|
||||
{
|
||||
id: 15,
|
||||
name: "Attribution-NoDerivs"
|
||||
},
|
||||
{
|
||||
id: 16,
|
||||
name: "Attribution-NonCommercial-NoDerivs"
|
||||
}
|
||||
],
|
||||
licenseIndex: 0
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -934,7 +1000,8 @@ export default {
|
|||
comments_disabled: this.commentsDisabled,
|
||||
place: this.place,
|
||||
tagged: this.taggedUsernames,
|
||||
optimize_media: this.optimizeMedia
|
||||
optimize_media: this.optimizeMedia,
|
||||
license: this.availableLicenses[this.licenseIndex].id
|
||||
};
|
||||
axios.post('/api/compose/v0/publish', data)
|
||||
.then(res => {
|
||||
|
@ -1026,6 +1093,10 @@ export default {
|
|||
this.showTagCard();
|
||||
break;
|
||||
|
||||
case 'licensePicker':
|
||||
this.page = 3;
|
||||
break;
|
||||
|
||||
default:
|
||||
this.namedPages.indexOf(this.page) != -1 ?
|
||||
this.page = (this.textMode ? 'addText' : 3) :
|
||||
|
@ -1270,7 +1341,18 @@ export default {
|
|||
showTextOptions() {
|
||||
this.page = 'textOptions';
|
||||
this.pageTitle = 'Text Post Options';
|
||||
}
|
||||
},
|
||||
|
||||
showLicenseCard() {
|
||||
this.pageTitle = 'Select a License';
|
||||
this.page = 'licensePicker';
|
||||
},
|
||||
|
||||
toggleLicense(index) {
|
||||
this.licenseIndex = index;
|
||||
this.pageTitle = '';
|
||||
this.page = 3;
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -22,7 +22,7 @@
|
|||
:alt="altText(status)"/>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div :title="status.media_attachments[0].description">
|
||||
<div :title="status.media_attachments[0].description" style="position: relative;">
|
||||
<img class="card-img-top"
|
||||
:src="status.media_attachments[0].url"
|
||||
loading="lazy"
|
||||
|
@ -30,6 +30,21 @@
|
|||
:width="width()"
|
||||
:height="height()"
|
||||
onerror="this.onerror=null;this.src='/storage/no-preview.png'">
|
||||
|
||||
<p
|
||||
v-if="status.media_attachments[0].license"
|
||||
style="
|
||||
margin-bottom: 0;
|
||||
padding: 0 5px;
|
||||
color: #fff;
|
||||
font-size: 10px;
|
||||
text-align: right;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
border-top-left-radius: 5px;
|
||||
background: linear-gradient(0deg, rgba(0,0,0,0.5), rgba(0,0,0,0.5));
|
||||
"><a :href="status.url" class="font-weight-bold text-light">Photo</a> by <a :href="status.account.url" class="font-weight-bold text-light">@{{status.account.username}}</a> licensed under <a :href="status.media_attachments[0].license.url" class="font-weight-bold text-light">{{status.media_attachments[0].license.title}}</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
Loading…
Reference in New Issue