mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-14 16:28:59 +00:00
MORE FRONTENDS (EASY MODE) WIN!!!
This commit is contained in:
@@ -9,6 +9,7 @@ class HomeController < ApplicationController
|
|||||||
@web_settings = Web::Setting.find_by(user: current_user)&.data || {}
|
@web_settings = Web::Setting.find_by(user: current_user)&.data || {}
|
||||||
@admin = Account.find_local(Setting.site_contact_username)
|
@admin = Account.find_local(Setting.site_contact_username)
|
||||||
@streaming_api_base_url = Rails.configuration.x.streaming_api_base_url
|
@streaming_api_base_url = Rails.configuration.x.streaming_api_base_url
|
||||||
|
@frontend = (params[:frontend] and Rails.root.join('app', 'javascript', 'packs', 'frontends', '#{params[:frontend]}.js')) ? params[:frontend] : 'mastodon'
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
0
app/javascript/modules/.keep
Normal file
0
app/javascript/modules/.keep
Normal file
@@ -1,2 +1,3 @@
|
|||||||
import { start } from 'rails-ujs';
|
import { start } from 'rails-ujs';
|
||||||
|
require('../mastodon/locales');
|
||||||
start();
|
start();
|
||||||
|
|||||||
6
app/javascript/packs/frontends/mastodon.js
Normal file
6
app/javascript/packs/frontends/mastodon.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import main from '../../mastodon/main';
|
||||||
|
import loadPolyfills from '../../mastodon/load_polyfills';
|
||||||
|
|
||||||
|
loadPolyfills().then(main).catch(e => {
|
||||||
|
console.error(e);
|
||||||
|
});
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
- content_for :header_tags do
|
- content_for :header_tags do
|
||||||
%script#initial-state{ type: 'application/json' }!= json_escape(render(file: 'home/initial_state', formats: :json))
|
%script#initial-state{ type: 'application/json' }!= json_escape(render(file: 'home/initial_state', formats: :json))
|
||||||
|
|
||||||
= javascript_pack_tag 'application', integrity: true, crossorigin: 'anonymous'
|
= javascript_pack_tag "frontends/#{@frontend}", integrity: true, crossorigin: 'anonymous'
|
||||||
|
= stylesheet_pack_tag "frontends/#{@frontend}", integrity: true, media: 'all'
|
||||||
|
|
||||||
|
%script{ type: 'text/html' }!=@frontendp
|
||||||
|
|
||||||
.app-holder#mastodon{ data: { props: Oj.dump(default_props) } }
|
.app-holder#mastodon{ data: { props: Oj.dump(default_props) } }
|
||||||
%noscript
|
%noscript
|
||||||
|
|||||||
@@ -18,11 +18,13 @@
|
|||||||
= ' - '
|
= ' - '
|
||||||
= title
|
= title
|
||||||
|
|
||||||
= stylesheet_pack_tag 'application', media: 'all'
|
|
||||||
= javascript_pack_tag 'common', integrity: true, crossorigin: 'anonymous'
|
= javascript_pack_tag 'common', integrity: true, crossorigin: 'anonymous'
|
||||||
= javascript_pack_tag "locale_#{I18n.locale}", integrity: true, crossorigin: 'anonymous'
|
= javascript_pack_tag "locale_#{I18n.locale}", integrity: true, crossorigin: 'anonymous'
|
||||||
= csrf_meta_tags
|
= csrf_meta_tags
|
||||||
|
|
||||||
|
- if controller_name != 'home'
|
||||||
|
= stylesheet_pack_tag 'application', integrity: true, media: 'all'
|
||||||
|
|
||||||
= yield :header_tags
|
= yield :header_tags
|
||||||
|
|
||||||
- body_classes ||= @body_classes
|
- body_classes ||= @body_classes
|
||||||
|
|||||||
@@ -51,18 +51,7 @@ module.exports = {
|
|||||||
}),
|
}),
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
new webpack.optimize.CommonsChunkPlugin({
|
||||||
name: 'common',
|
name: 'common',
|
||||||
minChunks: (module, count) => {
|
minChunks: Infinity
|
||||||
const reactIntlPathRegexp = new RegExp(`node_modules\\${sep}react-intl`);
|
|
||||||
|
|
||||||
if (module.resource && reactIntlPathRegexp.test(module.resource)) {
|
|
||||||
// skip react-intl because it's useless to put in the common chunk,
|
|
||||||
// e.g. because "shared" modules between zh-TW and zh-CN will never
|
|
||||||
// be loaded together
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count >= 2;
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user