]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Change how CDN_HOST is passed down to make assets build reproducible
authorThibG <thib@sitedethib.com>
Mon, 12 Oct 2020 23:19:35 +0000 (01:19 +0200)
committerThibaut Girka <thib@sitedethib.com>
Wed, 21 Oct 2020 19:28:47 +0000 (21:28 +0200)
Port 4c45b43cb8a3d902c130729d36d559ec9de23d3e to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
21 files changed:
app/javascript/core/admin.js
app/javascript/core/auth.js
app/javascript/core/common.js
app/javascript/core/embed.js
app/javascript/core/public.js
app/javascript/core/settings.js
app/javascript/core/two_factor_authentication.js
app/javascript/flavours/glitch/components/autosuggest_emoji.js
app/javascript/flavours/glitch/features/emoji_picker/index.js
app/javascript/flavours/glitch/features/getting_started/components/announcements.js
app/javascript/flavours/glitch/features/ui/components/focal_point_modal.js
app/javascript/flavours/glitch/packs/about.js
app/javascript/flavours/glitch/packs/common.js
app/javascript/flavours/glitch/packs/error.js
app/javascript/flavours/glitch/packs/home.js
app/javascript/flavours/glitch/packs/public.js
app/javascript/flavours/glitch/packs/settings.js
app/javascript/flavours/glitch/packs/share.js
app/javascript/flavours/glitch/util/config.js [new file with mode: 0644]
app/javascript/flavours/glitch/util/emoji/index.js
app/javascript/packs/common.js

index b9cc00d649c9cb13146aadf7f6f8c2a1f0de460c..bbc7cfac79d851f27b7f26dc0bff48e692676314 100644 (file)
@@ -1,6 +1,6 @@
 //  This file will be loaded on admin pages, regardless of theme.
 
-import './public-path';
+import 'packs/public-path';
 import { delegate } from '@rails/ujs';
 import ready from '../mastodon/ready';
 
index ca04730a3ae84d1f3fef3c353e45fdd0e37c9c0b..d1d14d99e8df93bf05809518f10098c81304b693 100644 (file)
@@ -1,2 +1,3 @@
+import 'packs/public-path';
 import './settings';
 import './two_factor_authentication';
index 3b038ca40cd4d2f15a25c82721b98e3158c65616..1cee2f6036f08c3c7b9a558f8fd02230e6f02a82 100644 (file)
@@ -1,5 +1,6 @@
 //  This file will be loaded on all pages, regardless of theme.
 
+import 'packs/public-path';
 import 'font-awesome/css/font-awesome.css';
 
 require.context('../images/', true);
index 6146e65929d6e276ffbedf2bf2f25e1456832a28..9083eb7a3ec1d49626aacfa0c219dc0a33cb9cdf 100644 (file)
@@ -1,5 +1,7 @@
 //  This file will be loaded on embed pages, regardless of theme.
 
+import 'packs/public-path';
+
 window.addEventListener('message', e => {
   const data = e.data || {};
 
index 8c26f14045e678e061748d863f5f7032c535f26d..b67fb13e548da6784750a683ff6d6b5a95af576a 100644 (file)
@@ -1,5 +1,6 @@
 //  This file will be loaded on public pages, regardless of theme.
 
+import 'packs/public-path';
 import ready from '../mastodon/ready';
 
 const { delegate } = require('@rails/ujs');
index 9403e339b47eb77e8d769c2c4a3374a3229261fd..d5bb9532c4a3051b71d039033d54958df37f0316 100644 (file)
@@ -1,5 +1,6 @@
 //  This file will be loaded on settings pages, regardless of theme.
 
+import 'packs/public-path';
 import escapeTextContentForBrowser from 'escape-html';
 const { delegate } = require('@rails/ujs');
 import emojify from '../mastodon/features/emoji/emoji';
index dde06be8c19f5ec0caebda7b8e7236f0e42d5565..f076cdf30a989e6f8a637ad4dc8185c9ad562259 100644 (file)
@@ -1,3 +1,4 @@
+import 'packs/public-path';
 import axios from 'axios';
 import * as WebAuthnJSON from '@github/webauthn-json';
 import ready from '../mastodon/ready';
index c8609e48f6739bc714ec3e19a00844607cf87596..d04c1eb687d389ac2888a0e3158a217fb2846698 100644 (file)
@@ -2,7 +2,7 @@ import React from 'react';
 import PropTypes from 'prop-types';
 import unicodeMapping from 'flavours/glitch/util/emoji/emoji_unicode_mapping_light';
 
-const assetHost = process.env.CDN_HOST || '';
+import { assetHost } from 'flavours/glitch/util/config';
 
 export default class AutosuggestEmoji extends React.PureComponent {
 
index d0d9714a8b2274a73c1f8f7b732f8b5f4479b6ce..89219d739c58b269064d6ecde96a013985419591 100644 (file)
@@ -13,6 +13,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
 import detectPassiveEvents from 'detect-passive-events';
 import { buildCustomEmojis, categoriesFromEmojis } from 'flavours/glitch/util/emoji';
 import { useSystemEmojiFont } from 'flavours/glitch/util/initial_state';
+import { assetHost } from 'flavours/glitch/util/config';
 
 const messages = defineMessages({
   emoji: { id: 'emoji_button.label', defaultMessage: 'Insert emoji' },
@@ -105,7 +106,6 @@ const mapDispatchToProps = (dispatch, { onPickEmoji }) => ({
   },
 });
 
-const assetHost = process.env.CDN_HOST || '';
 let EmojiPicker, Emoji; // load asynchronously
 
 const backgroundImageFn = () => `${assetHost}/emoji/sheet_10.png`;
index acaa78fe348134f23d011148df05fdcbc27faba8..cd81d07deb3ca0436335f4ab229df6cb1d0de89e 100644 (file)
@@ -15,6 +15,7 @@ import EmojiPickerDropdown from 'flavours/glitch/features/emoji_picker';
 import AnimatedNumber from 'flavours/glitch/components/animated_number';
 import TransitionMotion from 'react-motion/lib/TransitionMotion';
 import spring from 'react-motion/lib/spring';
+import { assetHost } from 'flavours/glitch/util/config';
 
 const messages = defineMessages({
   close: { id: 'lightbox.close', defaultMessage: 'Close' },
@@ -153,8 +154,6 @@ class Content extends ImmutablePureComponent {
 
 }
 
-const assetHost = process.env.CDN_HOST || '';
-
 class Emoji extends React.PureComponent {
 
   static propTypes = {
index b790b29a0764cbbcc53d33255a5ce874ddb66e9b..5de3e26d513ba9739782e05246f8bbaef8fac157 100644 (file)
@@ -20,6 +20,7 @@ import GIFV from 'flavours/glitch/components/gifv';
 import { me } from 'flavours/glitch/util/initial_state';
 import tesseractCorePath from 'tesseract.js-core/tesseract-core.wasm.js';
 import tesseractWorkerPath from 'tesseract.js/dist/worker.min.js';
+import { assetHost } from 'flavours/glitch/util/config';
 
 const messages = defineMessages({
   close: { id: 'lightbox.close', defaultMessage: 'Close' },
@@ -50,8 +51,6 @@ const removeExtraLineBreaks = str => str.replace(/\n\n/g, '******')
   .replace(/\n/g, ' ')
   .replace(/\*\*\*\*\*\*/g, '\n\n');
 
-const assetHost = process.env.CDN_HOST || '';
-
 class ImageLoader extends React.PureComponent {
 
   static propTypes = {
index bc0a4887bb19b41284bce885b23f91d0eb5bd8f2..2e2cce501cc8c75f81624f7c47f2efe4312cfa91 100644 (file)
@@ -1,3 +1,4 @@
+import 'packs/public-path';
 import loadPolyfills from 'flavours/glitch/util/load_polyfills';
 
 function loaded() {
index 1fedc890a3cfed8707ba1584a6f4633c26890681..7dc34eba93af97bfcbe9f162881aff0659bcdd70 100644 (file)
@@ -1,3 +1,4 @@
+import 'packs/public-path';
 import { start } from '@rails/ujs';
 
 start();
index 81c86c3abb7ca4d1c23d97a9bd9863c6d83e9864..9f692ad379f88b6df2b9dbbd22a7fd2bdd58e837 100644 (file)
@@ -1,3 +1,4 @@
+import 'packs/public-path';
 import ready from 'flavours/glitch/util/ready';
 
 ready(() => {
index b8f7b7d8efdbb6998e4f038ad155d76db2f5e8fd..d06688985448318f3b5f2c1c573fd1d4458bc900 100644 (file)
@@ -1,3 +1,4 @@
+import 'packs/public-path';
 import loadPolyfills from 'flavours/glitch/util/load_polyfills';
 
 loadPolyfills().then(() => {
index b9b588dc6b4930a64df18958bdb99ed6d5121b7f..c74e5c9af144fafc862750d407382f1d14d21cf0 100644 (file)
@@ -1,3 +1,4 @@
+import 'packs/public-path';
 import loadPolyfills from 'flavours/glitch/util/load_polyfills';
 import ready from 'flavours/glitch/util/ready';
 import loadKeyboardExtensions from 'flavours/glitch/util/load_keyboard_extensions';
index 8a9f23505d47d9fed746e27973d87108dcb44b6a..9c4d119c1eebbd22c8822bef134d8585f27e758c 100644 (file)
@@ -1,3 +1,4 @@
+import 'packs/public-path';
 import loadPolyfills from 'flavours/glitch/util/load_polyfills';
 import ready from 'flavours/glitch/util/ready';
 import loadKeyboardExtensions from 'flavours/glitch/util/load_keyboard_extensions';
index 9f2aa2553973e1ed5d55505f5a48c01d03f3613e..f4a97e201544c817e157f589abd1c3398fc72b91 100644 (file)
@@ -1,3 +1,4 @@
+import 'packs/public-path';
 import loadPolyfills from 'flavours/glitch/util/load_polyfills';
 
 function loaded() {
diff --git a/app/javascript/flavours/glitch/util/config.js b/app/javascript/flavours/glitch/util/config.js
new file mode 100644 (file)
index 0000000..c3e2b73
--- /dev/null
@@ -0,0 +1,10 @@
+import ready from './ready';
+
+export let assetHost = '';
+
+ready(() => {
+  const cdnHost = document.querySelector('meta[name=cdn-host]');
+  if (cdnHost) {
+    assetHost = cdnHost.content || '';
+  }
+});
index 233ec25e3a46dc34097f0851e3a74dd81243e452..43ff4661cd883faf498fa9680ef6eb59f4ffba19 100644 (file)
@@ -1,11 +1,10 @@
 import { autoPlayGif, useSystemEmojiFont } from 'flavours/glitch/util/initial_state';
 import unicodeMapping from './emoji_unicode_mapping_light';
+import { assetHost } from 'flavours/glitch/util/config';
 import Trie from 'substring-trie';
 
 const trie = new Trie(Object.keys(unicodeMapping));
 
-const assetHost = process.env.CDN_HOST || '';
-
 // Convert to file names from emojis. (For different variation selector emojis)
 const emojiFilenames = (emojis) => {
   return emojis.map(v => unicodeMapping[v].filename);
index 5d42509c5f4f88635774dec861c60ab7812e93e1..05dff8e49482ca0ac5579f9f976fa9b6594000ed 100644 (file)
@@ -1 +1,2 @@
+import './public-path';
 import 'styles/application.scss';