Skip to content

Commit a39d7fc

Browse files
authored
Merge pull request #3 from CompostInTraining/merge-upstream
2 parents 4735754 + 6f293b0 commit a39d7fc

File tree

8 files changed

+39
-10
lines changed

8 files changed

+39
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Serve all the stuff in `public` behind an nginx or whatever you want! See the in
4040

4141
### Docker (definitely the easiest way)
4242

43-
The Docker container is based on Nginx, and serves over port 3000. Just deploy it and listen on that port, preferably with a reverse proxy at some point (Traefik? Caddy? Another Nginx perhaps?) handling https.
43+
The Docker container is based on Nginx, and serves over port 80. Just deploy it and listen on that port, preferably with a reverse proxy at some point (Traefik? Caddy? Another Nginx perhaps?) handling https.
4444

4545
## Testing locally, linting, etc
4646

app/javascript/flavours/glitch/actions/server.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,18 @@ export const fetchServer = () => (dispatch, getState) => {
2121

2222
dispatch(fetchServerRequest());
2323

24-
api(getState)
25-
.get('/api/v2/instance').then(({ data }) => {
24+
try {
25+
api(getState)
26+
.get('/api/v2/instance').then({ data })
2627
if (data.contact.account) dispatch(importFetchedAccount(data.contact.account));
2728
dispatch(fetchServerSuccess(data));
29+
} catch (e) {
30+
api(getState)
31+
.get('/api/v1/instance').then(({ data }) => {
32+
if (data.contact.account) dispatch(importFetchedAccount(data.contact.account));
33+
dispatch(fetchServerSuccess(data));
2834
}).catch(err => dispatch(fetchServerFail(err)));
35+
}
2936
};
3037

3138
const fetchServerRequest = () => ({

app/javascript/flavours/glitch/features/ui/components/focal_point_modal.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { Tesseract as fetchTesseract } from 'flavours/glitch/features/ui/util/as
2626
import Video, { getPointerPosition } from 'flavours/glitch/features/video';
2727
import { me } from 'flavours/glitch/initial_state';
2828
import { assetHost } from 'flavours/glitch/utils/config';
29+
import { maxMediaDescChars } from 'flavours/glitch/initial_state';
2930

3031
import { changeUploadCompose, uploadThumbnail, onChangeMediaDescription, onChangeMediaFocus } from '../../../actions/compose';
3132

@@ -367,10 +368,10 @@ class FocalPointModal extends ImmutablePureComponent {
367368

368369
<div className='setting-text__toolbar'>
369370
<button disabled={detecting || media.get('type') !== 'image' || is_changing_upload} className='link-button' onClick={this.handleTextDetection}><FormattedMessage id='upload_modal.detect_text' defaultMessage='Detect text from picture' /></button>
370-
<CharacterCounter max={1500} text={detecting ? '' : description} />
371+
<CharacterCounter max={maxMediaDescChars} text={detecting ? '' : description} />
371372
</div>
372373

373-
<Button disabled={!dirty || detecting || isUploadingThumbnail || length(description) > 1500 || is_changing_upload} text={intl.formatMessage(is_changing_upload ? messages.applying : messages.apply)} onClick={this.handleSubmit} />
374+
<Button disabled={!dirty || detecting || isUploadingThumbnail || length(description) > maxMediaDescChars || is_changing_upload} text={intl.formatMessage(is_changing_upload ? messages.applying : messages.apply)} onClick={this.handleSubmit} />
374375
</div>
375376

376377
<div className='focal-point-modal__content'>

app/javascript/flavours/glitch/initial_state.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export const hasMultiColumnPath = initialPath === '/'
104104
* @property {object} local_settings
105105
* @property {number} max_toot_chars
106106
* @property {number} max_media_attachments
107+
* @property {number} max_media_desc_chars
107108
* @property {number} poll_limits
108109
*/
109110

@@ -167,6 +168,7 @@ export const sso_redirect = getMeta('sso_redirect');
167168
// Glitch-soc-specific settings
168169
export const maxChars = (initialState && initialState.max_toot_chars) || 500;
169170
export const maxMediaAttachments = (initialState && initialState.max_media_attachments) || 4;
171+
export const maxMediaDescChars = (initialState && initialState.max_media_desc_chars) || 1500;
170172
export const favouriteModal = getMeta('favourite_modal');
171173
export const pollLimits = (initialState && initialState.poll_limits);
172174
export const defaultContentType = getMeta('default_content_type');

app/javascript/mastodon/actions/server.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@ export const fetchServer = () => (dispatch, getState) => {
1717

1818
dispatch(fetchServerRequest());
1919

20-
api(getState)
21-
.get('/api/v2/instance').then(({ data }) => {
20+
try {
21+
api(getState)
22+
.get('/api/v2/instance').then({ data });
2223
if (data.contact.account) dispatch(importFetchedAccount(data.contact.account));
2324
dispatch(fetchServerSuccess(data));
25+
} catch (e) {
26+
api(getState)
27+
.get('/api/v1/instance').then(({ data }) => {
28+
if (data.contact.account) dispatch(importFetchedAccount(data.contact.account));
29+
dispatch(fetchServerSuccess(data));
2430
}).catch(err => dispatch(fetchServerFail(err)));
31+
}
2532
};
2633

2734
const fetchServerRequest = () => ({

app/javascript/mastodon/features/ui/components/focal_point_modal.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import UploadProgress from 'mastodon/features/compose/components/upload_progress
2525
import { Tesseract as fetchTesseract } from 'mastodon/features/ui/util/async-components';
2626
import { me } from 'mastodon/initial_state';
2727
import { assetHost } from 'mastodon/utils/config';
28+
import { maxMediaDescChars } from 'mastodon/initial_state';
2829

2930
import { changeUploadCompose, uploadThumbnail, onChangeMediaDescription, onChangeMediaFocus } from '../../../actions/compose';
3031
import Video, { getPointerPosition } from '../../video';
@@ -374,12 +375,12 @@ class FocalPointModal extends ImmutablePureComponent {
374375
>
375376
<FormattedMessage id='upload_modal.detect_text' defaultMessage='Detect text from picture' />
376377
</button>
377-
<CharacterCounter max={1500} text={detecting ? '' : description} />
378+
<CharacterCounter max={maxMediaDescChars} text={detecting ? '' : description} />
378379
</div>
379380

380381
<Button
381382
type='submit'
382-
disabled={!dirty || detecting || isUploadingThumbnail || length(description) > 1500 || is_changing_upload}
383+
disabled={!dirty || detecting || isUploadingThumbnail || length(description) > maxMediaDescChars || is_changing_upload}
383384
text={intl.formatMessage(is_changing_upload ? messages.applying : messages.apply)}
384385
/>
385386
</form>

app/javascript/mastodon/initial_state.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
* @property {boolean=} critical_updates_pending
9191
* @property {InitialStateMeta} meta
9292
* @property {number} max_toot_chars
93+
* @property {number} max_media_desc_chars
9394
*/
9495

9596
const element = document.getElementById('initial-state');
@@ -149,5 +150,6 @@ export const sso_redirect = getMeta('sso_redirect');
149150

150151
// Glitch-soc-specific settings
151152
export const maxChars = (initialState && initialState.max_toot_chars) || 500;
153+
export const maxMediaDescChars = (initialState && initialState.max_media_desc_chars) || 1500;
152154

153155
export default initialState;

public/verify-state.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@ async function loadState() {
2323
}
2424

2525
const apiUrl = `${protocol}${domain}/api`;
26-
const instance = await fetch(`${apiUrl}/v1/instance`).then(async p => await p.json());
26+
let instance
27+
try {
28+
instance = await fetch(`${apiUrl}/v2/instance`).then(async p => await p.json());
29+
if (!instance.configuration) {
30+
throw new Error('Instance API v2 unavaialble');
31+
}
32+
} catch (e) {
33+
instance = await fetch(`${apiUrl}/v1/instance`).then(async p => await p.json());
34+
}
2735
const options = {headers: {Authorization: `Bearer ${access_token}`}};
2836
const credentials = await fetch(`${apiUrl}/v1/accounts/verify_credentials`, options).then(async p => await p.json());
2937
const state = {
@@ -93,6 +101,7 @@ async function loadState() {
93101
},
94102
"max_toot_chars": instance.configuration.statuses.max_characters,
95103
"max_media_attachments": instance.configuration.statuses.max_media_attachments,
104+
"max_media_desc_chars": instance.configuration.media_attachments.description_limit,
96105
"poll_limits": {
97106
"max_expiration": instance.configuration.polls.max_expiration,
98107
"max_option_chars": instance.configuration.polls.max_characters_per_option,

0 commit comments

Comments
 (0)