Skip to content

Commit

Permalink
Merge pull request #372 from mvdicarlo/develop
Browse files Browse the repository at this point in the history
v3.1.49
  • Loading branch information
mvdicarlo authored Oct 15, 2024
2 parents aa78633 + 725da5e commit d02ecf2
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 12 deletions.
2 changes: 1 addition & 1 deletion electron-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postybirb-plus",
"version": "3.1.48",
"version": "3.1.49",
"description": "(ClientServer) PostyBirb is an application that helps artists post art and other multimedia to multiple websites more quickly.",
"main": "dist/main.js",
"author": "Michael DiCarlo",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export class DeviantArt extends Website {
];
private readonly MAX_TAGS = 30;

private titleLimit = 50;

async checkLoginStatus(data: UserAccountEntity): Promise<LoginResponse> {
const status: LoginResponse = { loggedIn: false, username: null };
const res = await HttpExperimental.get<string>(this.BASE_URL, { partition: data._id });
Expand Down Expand Up @@ -180,9 +182,9 @@ export class DeviantArt extends Website {
this.checkCancelled(cancellationToken);
const mature =
data.options.isMature ||
data.options.rating === SubmissionRating.ADULT ||
data.options.rating === SubmissionRating.MATURE ||
data.options.rating === SubmissionRating.EXTREME;
data.rating === SubmissionRating.ADULT ||
data.rating === SubmissionRating.MATURE ||
data.rating === SubmissionRating.EXTREME;

const updateBody: any = {
allow_comments: data.options.disableComments ? false : true,
Expand Down Expand Up @@ -347,7 +349,6 @@ export class DeviantArt extends Website {
return this.createPostResponse({ source: publish.body.deviation.url });
}

private titleLimit = 50;
private htmlToEditorRawDescription(description: string) {
description = description.replace(
'<br /><br /><p><a href="http://www.postybirb.com">Posted using PostyBirb</a></p>',
Expand All @@ -357,16 +358,21 @@ export class DeviantArt extends Website {
description.replace(/`/g, '&#96;') || '<div></div>',
this.extensions,
);
this.logger.debug({ document }, 'Html to raw editor');
return JSON.stringify({
version: 1,
document,
});
}

private invalidTitleMessage(title: string) {
// Taken from api error message
return `'${title}' is not an valid title. Deviation title can only contain A-Z, a-z, 0-9, space and the following characters: _$!?:.,' +-=~\`@#%^*[]()/{}\\|`;
}

private truncateTitle(title: string) {
const newTitle = title.substring(0, this.titleLimit);
return { title: newTitle, exceedsLimit: newTitle !== title };
const isValid = /^[A-Za-z0-9\s_$!?:.,'+\-=~`@#%^*\[\]()\/\{\}\\|]*$/g.test(title);
return { title: newTitle, exceedsLimit: newTitle !== title, isValid };
}

validateFileSubmission(
Expand All @@ -378,12 +384,15 @@ export class DeviantArt extends Website {
const warnings: string[] = [];
const isAutoscaling: boolean = submissionPart.data.autoScale;

const { title, exceedsLimit } = this.truncateTitle(
const { title, exceedsLimit, isValid } = this.truncateTitle(
submissionPart.data.title || defaultPart.data.title || submission.title,
);
if (exceedsLimit) {
warnings.push(`Title will be truncated to ${this.titleLimit} characters: ${title}`);
}
if (!isValid) {
problems.push(this.invalidTitleMessage(title));
}

if (submissionPart.data.folders && submissionPart.data.folders.length) {
const folders: Folder[] = _.get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ export class Newgrounds extends Website {
[key]: value,
},
});
console.log(key, value, contentUpdateRes.body);
}

if (!this.checkIsSaved(contentUpdateRes.body)) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postybirb-plus",
"version": "3.1.48",
"version": "3.1.49",
"description": "PostyBirb is an application that helps artists post art and other multimedia to multiple websites more quickly..",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postybirb-plus-ui",
"version": "3.1.48",
"version": "3.1.49",
"license": "BSD-3-Clause",
"private": true,
"Author": "Michael DiCarlo",
Expand Down
19 changes: 18 additions & 1 deletion ui/src/websites/e621/e621.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Form, Input } from 'antd';
import _ from 'lodash';
import { e621FileOptions, FileSubmission, SubmissionPart } from 'postybirb-commons';
import { e621FileOptions, FileSubmission, SubmissionPart, SubmissionRating } from 'postybirb-commons';
import React from 'react';
import { SubmissionSectionProps } from '../../views/submissions/submission-forms/interfaces/submission-section.interface';
import GenericFileSubmissionSection from '../generic/GenericFileSubmissionSection';
Expand All @@ -26,6 +26,23 @@ export class e621 extends WebsiteImpl {
show: true,
searchProvider: e621TagSearchProvider
}}
ratingOptions={{
show: true,
ratings: [
{
value: SubmissionRating.GENERAL,
name: 'Safe'
},
{
value: SubmissionRating.MATURE,
name: 'Questionable'
},
{
value: SubmissionRating.ADULT,
name: 'Explicit'
}
]
}}
key={props.part.accountId}
{...props}
/>
Expand Down

0 comments on commit d02ecf2

Please sign in to comment.