Merge tootsuite/master at 3023725936

This commit is contained in:
Surinna Curtis
2017-11-16 01:21:16 -06:00
230 changed files with 8548 additions and 567 deletions

View File

@ -9,6 +9,7 @@ Bundler.require(*Rails.groups)
require_relative '../app/lib/exceptions'
require_relative '../lib/paperclip/gif_transcoder'
require_relative '../lib/paperclip/video_transcoder'
require_relative '../lib/paperclip/audio_transcoder'
require_relative '../lib/mastodon/snowflake'
require_relative '../lib/mastodon/version'
@ -70,12 +71,17 @@ module Mastodon
config.active_job.queue_adapter = :sidekiq
#config.middleware.insert_before 0, Rack::Cors, debug: true, logger: (-> { Rails.logger }) do
config.middleware.insert_before 0, Rack::Cors do
allow do
origins '*'
resource '/@:username', headers: :any, methods: [:get], credentials: false
resource '/api/*', headers: :any, methods: [:post, :put, :delete, :get, :patch, :options], credentials: false, expose: ['Link', 'X-RateLimit-Reset', 'X-RateLimit-Limit', 'X-RateLimit-Remaining', 'X-Request-Id']
resource '/oauth/token', headers: :any, methods: [:post], credentials: false
resource '/assets/*', headers: :any, methods: [:get, :head, :options]
resource '/stylesheets/*', headers: :any, methods: [:get, :head, :options]
resource '/javascripts/*', headers: :any, methods: [:get, :head, :options]
resource '/packs/*', headers: :any, methods: [:get, :head, :options]
end
end

View File

@ -91,9 +91,14 @@ Rails.application.configure do
config.action_mailer.delivery_method = ENV.fetch('SMTP_DELIVERY_METHOD', 'smtp').to_sym
config.action_dispatch.default_headers = {
'Server' => 'Mastodon',
'X-Frame-Options' => 'DENY',
'X-Content-Type-Options' => 'nosniff',
'X-XSS-Protection' => '1; mode=block',
'Server' => 'Mastodon',
'X-Frame-Options' => 'DENY',
'X-Content-Type-Options' => 'nosniff',
'X-XSS-Protection' => '1; mode=block',
'Content-Security-Policy' => "frame-ancestors 'none'; object-src 'none'; script-src 'self' https://dev-static.glitch.social 'unsafe-inline'; base-uri 'none';" ,
'Referrer-Policy' => 'no-referrer, strict-origin-when-cross-origin',
'Strict-Transport-Security' => 'max-age=63072000; includeSubDomains; preload',
'X-Clacks-Overhead' => 'GNU Natalie Nguyen'
}
end

View File

@ -393,6 +393,14 @@ en:
muting: Muting list
upload: Upload
in_memoriam_html: In Memoriam.
keyword_mutes:
add_keyword: Add keyword
edit: Edit
edit_keyword: Edit keyword
keyword: Keyword
match_whole_word: Match whole word
remove: Remove
remove_all: Remove all
landing_strip_html: "<strong>%{name}</strong> is a user on %{link_to_root_path}. You can follow them or interact with them if you have an account anywhere in the fediverse."
landing_strip_signup_html: If you don't, you can <a href="%{sign_up_path}">sign up here</a>.
media_attachments:
@ -511,6 +519,7 @@ en:
export: Data export
followers: Authorized followers
import: Import
keyword_mutes: Muted keywords
notifications: Notifications
preferences: Preferences
settings: Settings

View File

@ -7,6 +7,7 @@ SimpleNavigation::Configuration.run do |navigation|
primary.item :settings, safe_join([fa_icon('cog fw'), t('settings.settings')]), settings_profile_url do |settings|
settings.item :profile, safe_join([fa_icon('user fw'), t('settings.edit_profile')]), settings_profile_url
settings.item :preferences, safe_join([fa_icon('sliders fw'), t('settings.preferences')]), settings_preferences_url
settings.item :keyword_mutes, safe_join([fa_icon('volume-off fw'), t('settings.keyword_mutes')]), settings_keyword_mutes_url
settings.item :notifications, safe_join([fa_icon('bell fw'), t('settings.notifications')]), settings_notifications_url
settings.item :password, safe_join([fa_icon('lock fw'), t('auth.change_password')]), edit_user_registration_url, highlights_on: %r{/auth/edit|/settings/delete}
settings.item :two_factor_authentication, safe_join([fa_icon('mobile fw'), t('settings.two_factor_authentication')]), settings_two_factor_authentication_url, highlights_on: %r{/settings/two_factor_authentication}

View File

@ -66,6 +66,13 @@ Rails.application.routes.draw do
namespace :settings do
resource :profile, only: [:show, :update]
resources :keyword_mutes do
collection do
delete :destroy_all
end
end
resource :preferences, only: [:show, :update]
resource :notifications, only: [:show, :update]
resource :import, only: [:show, :create]
@ -203,6 +210,7 @@ Rails.application.routes.draw do
end
namespace :timelines do
resource :direct, only: :show, controller: :direct
resource :home, only: :show, controller: :home
resource :public, only: :show, controller: :public
resources :tag, only: :show
@ -216,7 +224,11 @@ Rails.application.routes.draw do
resources :follows, only: [:create]
resources :media, only: [:create, :update]
resources :blocks, only: [:index]
resources :mutes, only: [:index]
resources :mutes, only: [:index] do
collection do
get 'details'
end
end
resources :favourites, only: [:index]
resources :reports, only: [:index, :create]
@ -236,10 +248,11 @@ Rails.application.routes.draw do
end
end
resources :notifications, only: [:index, :show] do
resources :notifications, only: [:index, :show, :destroy] do
collection do
post :clear
post :dismiss
delete :destroy_multiple
end
end

View File

@ -7,7 +7,7 @@
# For more information, see docs/Running-Mastodon/Administration-guide.md
#
defaults: &defaults
site_title: Mastodon
site_title: 'dev.glitch.social'
site_description: ''
site_extended_description: ''
site_terms: ''
@ -16,7 +16,7 @@ defaults: &defaults
open_registrations: true
closed_registrations_message: ''
open_deletion: true
timeline_preview: true
timeline_preview: false
default_sensitive: false
unfollow_modal: false
boost_modal: false

View File

@ -1 +0,0 @@
default: styles/application.scss

View File

@ -1,16 +1,27 @@
// Common configuration for webpacker loaded from config/webpacker.yml
const { join, resolve } = require('path');
const { dirname, join, resolve } = require('path');
const { env } = require('process');
const { safeLoad } = require('js-yaml');
const { readFileSync } = require('fs');
const glob = require('glob');
const configPath = resolve('config', 'webpacker.yml');
const loadersDir = join(__dirname, 'loaders');
const settings = safeLoad(readFileSync(configPath), 'utf8')[env.NODE_ENV];
const themeFiles = glob.sync('app/javascript/themes/*/theme.yml');
const themes = {};
const themePath = resolve('config', 'themes.yml');
const themes = safeLoad(readFileSync(themePath), 'utf8');
for (let i = 0; i < themeFiles.length; i++) {
const themeFile = themeFiles[i];
const data = safeLoad(readFileSync(themeFile), 'utf8');
if (!data.pack_directory) {
data.pack_directory = dirname(themeFile);
}
if (data.name && data.pack) {
themes[data.name] = data;
}
}
function removeOuterSlashes(string) {
return string.replace(/^\/*/, '').replace(/\/*$/, '');

View File

@ -34,6 +34,23 @@ locales.forEach(locale => {
].filter(filename => fs.existsSync(path.join(outPath, filename)))
.map(filename => filename.replace(/..\/..\/node_modules\//, ''))[0];
let glitchInject = `
const mergedMessages = messages;
`;
const glitchPath = `../../app/javascript/glitch/locales/${locale}.json`;
if (fs.existsSync(path.join(outPath, glitchPath))) {
glitchInject = `
import glitchMessages from ${JSON.stringify(glitchPath)};
let mergedMessages = messages;
Object.keys(glitchMessages).forEach(function (key) {
mergedMessages[key] = glitchMessages[key];
});
`;
}
const localeContent = `//
// locale_${locale}.js
// automatically generated by generateLocalePacks.js
@ -41,7 +58,8 @@ locales.forEach(locale => {
import messages from '../../app/javascript/mastodon/locales/${locale}.json';
import localeData from ${JSON.stringify(localeDataPath)};
import { setLocale } from '../../app/javascript/mastodon/locales';
setLocale({messages, localeData});
${glitchInject}
setLocale({messages: mergedMessages, localeData: localeData});
`;
fs.writeFileSync(localePath, localeContent, 'utf8');
outPaths.push(localePath);

View File

@ -7,7 +7,8 @@ module.exports = {
exclude: /node_modules/,
loader: 'babel-loader',
options: {
forceEnv: env,
forceEnv: process.env.NODE_ENV || 'development',
sourceRoot: 'app/javascript',
cacheDirectory: env === 'development' ? false : resolve(__dirname, '..', '..', '..', 'tmp', 'cache', 'babel-loader'),
},
};

View File

@ -9,7 +9,7 @@ module.exports = {
{ loader: 'css-loader', options: { minimize: env.NODE_ENV === 'production' } },
{ loader: 'postcss-loader', options: { sourceMap: true } },
'resolve-url-loader',
'sass-loader',
{ loader: 'sass-loader', options: { includePaths: ['app/javascript'] } },
],
}),
};

View File

@ -1,7 +1,7 @@
// Note: You must restart bin/webpack-dev-server for changes to take effect
const webpack = require('webpack');
const { basename, dirname, join, relative, resolve, sep } = require('path');
const { basename, dirname, join, relative, resolve } = require('path');
const { sync } = require('glob');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
@ -26,10 +26,13 @@ module.exports = {
localMap[basename(entry, extname(entry, extname(entry)))] = resolve(entry);
return localMap;
}, {}),
Object.keys(themes).reduce((themePaths, name) => {
themePaths[name] = resolve(join(settings.source_path, themes[name]));
return themePaths;
}, {})
Object.keys(themes).reduce(
(themePaths, name) => {
const themeData = themes[name];
themePaths[`themes/${name}`] = resolve(themeData.pack_directory, themeData.pack);
return themePaths;
}, {}
)
),
output: {
@ -52,25 +55,17 @@ module.exports = {
resource.request = resource.request.replace(/^history/, 'history/es');
}
),
new ExtractTextPlugin(env.NODE_ENV === 'production' ? '[name]-[contenthash].css' : '[name].css'),
new ExtractTextPlugin({
filename: env.NODE_ENV === 'production' ? '[name]-[contenthash].css' : '[name].css',
allChunks: true,
}),
new ManifestPlugin({
publicPath: output.publicPath,
writeToFileEmit: true,
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'common',
minChunks: (module, count) => {
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;
},
minChunks: Infinity, // It doesn't make sense to use common chunks with multiple frontend support.
}),
],