1
0
Fork 0

Merge pull request #2711 from pixelfed/staging

New License formats
This commit is contained in:
daniel 2021-03-31 22:29:27 -06:00 committed by GitHub
commit d07d236c14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 287 additions and 47 deletions

View File

@ -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))
@ -403,7 +404,7 @@
- Updated CollectionController, increase limit from 18 to 50. ([c2826fd3](https://github.com/pixelfed/pixelfed/c2826fd3))
## Deprecated
## [v0.10.6 (2019-09-30)](https://github.com/pixelfed/pixelfed/compare/v0.10.5...v0.10.6)
@ -468,7 +469,7 @@
- Run ```php artisan passport:keys```
- Add ```OAUTH_ENABLED=true``` to .env
- Run ```php artisan config:cache```
## [v0.10.5 (2019-09-24)](https://github.com/pixelfed/pixelfed/compare/v0.10.4...v0.10.5)
@ -479,8 +480,8 @@
- Fixed cache bug in privacy and terms pages [#1712](https://github.com/pixelfed/pixelfed/commit/fe522da8db7a8b0d7c18d405abcb885f8678f35c)
### Changed
## [v0.10.4 (2019-09-24)](https://github.com/pixelfed/pixelfed/compare/v0.10.3...v0.10.4)
### Added
@ -511,17 +512,17 @@
## Deprecated
- Remove deprecated profile following/followers [#1697](https://github.com/pixelfed/pixelfed/pull/1697)
- Remove old comment permalink [05f6598](https://github.com/pixelfed/pixelfed/pull/1708/commits/05f659896d903e1ff41dba810f125d721fa057e7)
## [v0.10.3 (2019-09-08)](https://github.com/pixelfed/pixelfed/compare/v0.10.2...v0.10.3)
### Added
- Append ```.json``` to local status urls to view ActivityPub object [#1666](https://github.com/pixelfed/pixelfed/pull/1666)
### Fixed
- Reverted ```strict``` Same-Site Cookies to ```null``` to fix 2FA/session expiry [#1667](https://github.com/pixelfed/pixelfed/pull/1667)
- Fixed AP errors by storing ActivityPub object id and url [#1668](https://github.com/pixelfed/pixelfed/pull/1668) [#1683](https://github.com/pixelfed/pixelfed/pull/1683)
- Fixed content warnings that had filter applied [#1669](https://github.com/pixelfed/pixelfed/pull/1669)
- Reverted ```strict``` Same-Site Cookies to ```null``` to fix 2FA/session expiry [#1667](https://github.com/pixelfed/pixelfed/pull/1667)
- Fixed AP errors by storing ActivityPub object id and url [#1668](https://github.com/pixelfed/pixelfed/pull/1668) [#1683](https://github.com/pixelfed/pixelfed/pull/1683)
- Fixed content warnings that had filter applied [#1669](https://github.com/pixelfed/pixelfed/pull/1669)
### Changed
- Japanese Translations [#1673](https://github.com/pixelfed/pixelfed/pull/1673)
@ -531,7 +532,7 @@
### Deprecated
- Personalized Discover has been deprecated due to low use [#1670](https://github.com/pixelfed/pixelfed/pull/1670)
## [v0.10.2 (2019-09-06)](https://github.com/pixelfed/pixelfed/compare/v0.10.1...v0.10.2)
@ -551,7 +552,7 @@
- Loops! Discover short videos
- Preliminary support for profile PropertyValue metadata
- Preliminary support for Direct Messages
- Places! Run the artisan task `import:cities`
- Places! Run the artisan task `import:cities`
- Emails are now validated and banned email domains are disallowed at signup. Artisan task `email:bancheck` will validate existing users.
- .env vars `REDIS_SCHEME` and `REDIS_PATH` allow for using Redis over a Unix socket instead of TCP [#1602](https://github.com/pixelfed/pixelfed/pull/1602)
- .env var `IMAGE_DRIVER` allows using imagick instead of gd
@ -574,7 +575,7 @@
- Sample nginx.conf in contrib/ now uses HTTPS instead of HTTP. Docs updated to reference this file
- Updated register form
- Allow users to edit email after registrations
## [v0.10.0 (2019-07-17)](https://github.com/pixelfed/pixelfed/compare/v0.9.6...v0.10.0)
@ -595,7 +596,7 @@
### Fixed
- Hashtag post count off-by-one [#1485](https://github.com/pixelfed/pixelfed/pull/1485)
## [v0.9.5 (2019-07-10)](https://github.com/pixelfed/pixelfed/compare/v0.9.4...v0.9.5)
@ -631,8 +632,8 @@
### Removed
- Remove Classic Compose UI [#1434](https://github.com/pixelfed/pixelfed/pull/1434), [72bffd1](https://github.com/pixelfed/pixelfed/commit/72bffd1) [a2640af](https://github.com/pixelfed/pixelfed/commit/a2640af)
-
-
## [v0.9.4 (2019-06-03)](https://github.com/pixelfed/pixelfed/compare/v0.9.0...v0.9.4)
@ -672,7 +673,7 @@ php artisan config:cache
### Removed
- Google Recaptcha is no longer supported (#1231)
- Lightbox has been deprecated in favor of double-tap-to-like; it will return as a dedicated button in the future (#1277)
## [v0.9.0 (2019-04-17)](https://github.com/pixelfed/pixelfed/compare/v0.8.6...v0.9.0)
@ -698,7 +699,7 @@ php artisan config:cache
### Removed
- Removed identicons due to SVG compatibility issues with federation. New users will instead be assigned a default avatar.
## [v0.8.6 (2019-04-06)](https://github.com/pixelfed/pixelfed/compare/v0.8.5...v0.8.6)

View File

@ -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) {

View File

@ -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']
];
}
}

View File

@ -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(),

View File

@ -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,

123
app/Util/Media/License.php Normal file
View File

@ -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

2
public/js/rempos.js vendored

File diff suppressed because one or more lines are too long

2
public/js/status.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -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"
}

View File

@ -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>

View File

@ -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">&commat;{{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>