Commit f5bf5ebb authored by Eugen Rochko's avatar Eugen Rochko Committed by GitHub

Replace sprockets/browserify with Webpack (#2617)

* Replace browserify with webpack

* Add react-intl-translations-manager

* Do not minify in development, add offline-plugin for ServiceWorker background cache updates

* Adjust tests and dependencies

* Fix production deployments

* Fix tests

* More optimizations

* Improve travis cache for npm stuff

* Re-run travis

* Add back support for custom.scss as before

* Remove offline-plugin and babili

* Fix issue with Immutable.List().unshift(...values) not working as expected

* Make travis load schema instead of running all migrations in sequence

* Fix missing React import in WarningContainer. Optimize rendering performance by using ImmutablePureComponent instead of
React.PureComponent. ImmutablePureComponent uses Immutable.is() to compare props. Replace dynamic callback bindings in
<UI />

* Add react definitions to places that use JSX

* Add Procfile.dev for running rails, webpack and streaming API at the same time
parent 26bc5915
{
"presets": ["es2015", "react"],
"presets": [
"es2015",
"react",
[
"env",
{
"loose": true,
"modules": false
}
]
],
"plugins": [
"transform-react-jsx-source",
"transform-react-jsx-self",
"transform-decorators-legacy",
"transform-object-rest-spread"
"transform-object-rest-spread",
[
"react-intl",
{
"messagesDir": "./build/messages"
}
]
]
}
procfile: Procfile.dev
......@@ -22,7 +22,7 @@ public/assets
.env
.env.production
node_modules/
neo4j/
build/
# Ignore Vagrant files
.vagrant/
......@@ -43,3 +43,5 @@ redis
# Ignore vim files
*~
*.swp
/public/packs
/node_modules
plugins:
postcss-smart-import: {}
precss: {}
autoprefixer: {}
language: ruby
cache:
bundler: true
yarn: true
directories:
- node_modules
yarn: false
dist: trusty
sudo: false
......@@ -42,7 +40,8 @@ install:
- yarn install
before_script:
- bundle exec rails db:create db:migrate
- bundle exec rails db:create db:schema:load
- bundle exec rails assets:precompile
script:
- bundle exec rspec
......
......@@ -10,8 +10,6 @@ EXPOSE 3000 4000
WORKDIR /mastodon
COPY Gemfile Gemfile.lock package.json yarn.lock /mastodon/
RUN echo "@edge https://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \
&& BUILD_DEPS=" \
postgresql-dev \
......@@ -23,6 +21,7 @@ RUN echo "@edge https://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/reposit
$BUILD_DEPS \
nodejs@edge \
nodejs-npm@edge \
git \
libpq \
libxml2 \
libxslt \
......@@ -31,14 +30,14 @@ RUN echo "@edge https://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/reposit
imagemagick@edge \
ca-certificates \
&& npm install -g npm@3 && npm install -g yarn \
&& bundle install --deployment --without test development \
&& yarn --ignore-optional \
&& yarn cache clean \
&& npm -g cache clean \
&& update-ca-certificates \
&& apk del $BUILD_DEPS \
&& rm -rf /tmp/* /var/cache/apk/*
COPY Gemfile Gemfile.lock package.json yarn.lock /mastodon/
RUN bundle install --deployment --without test development \
&& yarn --ignore-optional --pure-lockfile
COPY . /mastodon
VOLUME /mastodon/public/system /mastodon/public/assets
VOLUME /mastodon/public/system /mastodon/public/assets /mastodon/public/packs
......@@ -5,22 +5,19 @@ ruby '>= 2.3.0', '< 2.5.0'
gem 'pkg-config'
gem 'puma'
gem 'rails', '~> 5.0.2'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'jquery-rails'
gem 'puma'
gem 'hamlit-rails'
gem 'pg'
gem 'pghero'
gem 'dotenv-rails'
gem 'font-awesome-rails'
gem 'best_in_place', '~> 3.0.1'
gem 'aws-sdk', '>= 2.0'
gem 'paperclip', '~> 5.1'
gem 'paperclip-av-transcoder'
gem 'aws-sdk', '>= 2.0'
gem 'addressable'
gem 'devise'
......@@ -58,18 +55,18 @@ gem 'sprockets-rails', require: 'sprockets/railtie'
gem 'statsd-instrument'
gem 'twitter-text'
gem 'tzinfo-data'
gem 'webpacker', '~>1.2'
gem 'whatlanguage'
# For some reason the view specs start failing without this
gem 'react-rails'
gem 'browserify-rails'
gem 'autoprefixer-rails'
group :development, :test do
gem 'rspec-rails'
gem 'pry-rails'
gem 'fuubar'
gem 'fabrication'
gem 'fuubar'
gem 'i18n-tasks', '~> 0.9.6'
gem 'pry-rails'
gem 'rspec-rails'
end
group :test do
......@@ -83,24 +80,23 @@ group :test do
end
group :development do
gem 'rubocop', '0.46.0', require: false
gem 'active_record_query_trace'
gem 'annotate'
gem 'better_errors'
gem 'binding_of_caller'
gem 'bullet'
gem 'letter_opener'
gem 'letter_opener_web'
gem 'bullet'
gem 'active_record_query_trace'
gem 'annotate'
gem 'rubocop', '0.46.0', require: false
gem 'capistrano', '3.8.0'
gem 'capistrano-rails'
gem 'capistrano-rbenv'
gem 'capistrano-yarn'
gem 'capistrano-faster-assets', '~> 1.0'
end
group :production do
gem 'lograge'
gem 'rails_12factor'
gem 'redis-rails'
gem 'lograge'
end
......@@ -43,15 +43,13 @@ GEM
public_suffix (~> 2.0, >= 2.0.2)
airbrussh (1.2.0)
sshkit (>= 1.6.1, != 1.7.0)
annotate (2.7.1)
activerecord (>= 3.2, < 6.0)
rake (>= 10.4, < 12.0)
annotate (2.6.5)
activerecord (>= 2.3.0)
rake (>= 0.8.7)
arel (7.1.4)
ast (2.3.0)
attr_encrypted (3.0.3)
encryptor (~> 3.0.0)
autoprefixer-rails (6.7.7.2)
execjs
av (0.9.0)
cocaine (~> 0.5.3)
aws-sdk (2.9.12)
......@@ -76,10 +74,6 @@ GEM
rack (>= 0.9.0)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
browserify-rails (4.1.0)
addressable (>= 2.4.0)
railties (>= 4.0.0, < 5.1)
sprockets (>= 3.6.0)
builder (3.2.3)
bullet (5.5.1)
activesupport (>= 3.0.0)
......@@ -92,8 +86,6 @@ GEM
capistrano-bundler (1.2.0)
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-faster-assets (1.0.2)
capistrano (>= 3.1)
capistrano-rails (1.2.3)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
......@@ -161,8 +153,6 @@ GEM
faker (1.7.3)
i18n (~> 0.5)
fast_blank (1.0.0)
font-awesome-rails (4.7.0.1)
railties (>= 3.2, < 5.1)
fuubar (2.2.0)
rspec-core (~> 3.0)
ruby-progressbar (~> 1.4)
......@@ -210,10 +200,6 @@ GEM
rainbow (~> 2.2)
terminal-table (>= 1.5.1)
jmespath (1.3.1)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.1.0)
kaminari (1.0.1)
activesupport (>= 4.1.0)
......@@ -257,6 +243,7 @@ GEM
mimemagic (0.3.2)
mini_portile2 (2.1.0)
minitest (5.10.1)
multi_json (1.12.1)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (4.1.0)
......@@ -348,8 +335,8 @@ GEM
thor (>= 0.18.1, < 2.0)
rainbow (2.2.2)
rake
rake (11.3.0)
react-rails (1.11.0)
rake (12.0.0)
react-rails (2.1.0)
babel-transpiler (>= 0.7.0)
connection_pool
execjs
......@@ -410,13 +397,6 @@ GEM
crass (~> 1.0.2)
nokogiri (>= 1.4.4)
nokogumbo (~> 1.4.1)
sass (3.4.23)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sidekiq (4.2.10)
concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0)
......@@ -473,6 +453,10 @@ GEM
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
webpacker (1.2)
activesupport (>= 4.2)
multi_json (~> 1.2)
railties (>= 4.2)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
......@@ -487,15 +471,12 @@ DEPENDENCIES
active_record_query_trace
addressable
annotate
autoprefixer-rails
aws-sdk (>= 2.0)
best_in_place (~> 3.0.1)
better_errors
binding_of_caller
browserify-rails
bullet
capistrano (= 3.8.0)
capistrano-faster-assets (~> 1.0)
capistrano-rails
capistrano-rbenv
capistrano-yarn
......@@ -507,7 +488,6 @@ DEPENDENCIES
fabrication
faker
fast_blank
font-awesome-rails
fuubar
goldfinger
hamlit-rails
......@@ -517,7 +497,6 @@ DEPENDENCIES
http_accept_language
httplog
i18n-tasks (~> 0.9.6)
jquery-rails
kaminari
letter_opener
letter_opener_web
......@@ -554,7 +533,6 @@ DEPENDENCIES
rubocop (= 0.46.0)
ruby-oembed
sanitize
sass-rails (~> 5.0)
sidekiq
sidekiq-unique-jobs
simple-navigation
......@@ -566,6 +544,7 @@ DEPENDENCIES
tzinfo-data
uglifier (>= 1.3.0)
webmock
webpacker (~> 1.2)
whatlanguage
RUBY VERSION
......
web: bundle exec rails s -p 3000
stream: yarn run start
webpack: ./bin/webpack-dev-server
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery2
//= require jquery_ujs
//= require components
//= require jquery2
//= require jquery_ujs
//= require extras
//= require best_in_place
//= require local_time
$(function () {
$(".best_in_place").best_in_place();
});
//= require_self
//= require react_ujs
window.React = require('react');
window.ReactDOM = require('react-dom');
window.Perf = require('react-addons-perf');
if (!window.Intl) {
require('intl');
require('intl/locale-data/jsonp/en.js');
}
//= require_tree ./components
window.Mastodon = require('./components/containers/mastodon');
import { FormattedMessage } from 'react-intl';
import DisplayName from '../../../components/display_name';
import ImmutablePropTypes from 'react-immutable-proptypes';
const AutosuggestStatus = ({ status }) => (
<div className='autosuggest-status'>
<FormattedMessage id='search.status_by' defaultMessage='Status by {name}' values={{ name: <strong>@{status.getIn(['account', 'acct'])}</strong> }} />
</div>
);
AutosuggestStatus.propTypes = {
status: ImmutablePropTypes.map.isRequired
};
export default AutosuggestStatus;
const hu = {
"column_back_button.label": "Vissza",
"lightbox.close": "Bezárás",
"loading_indicator.label": "Betöltés...",
"status.mention": "Említés",
"status.delete": "Törlés",
"status.reply": "Válasz",
"status.reblog": "Reblog",
"status.favourite": "Kedvenc",
"status.reblogged_by": "{name} reblogolta",
"status.sensitive_warning": "Érzékeny tartalom",
"status.sensitive_toggle": "Katt a megtekintéshez",
"video_player.toggle_sound": "Hang kapcsolása",
"account.mention": "Említés",
"account.edit_profile": "Profil szerkesztése",
"account.unblock": "Blokkolás levétele",
"account.unfollow": "Követés abbahagyása",
"account.block": "Blokkolás",
"account.follow": "Követés",
"account.posts": "Posts",
"account.follows": "Követve",
"account.followers": "Követők",
"account.follows_you": "Követnek téged",
"getting_started.heading": "Első lépések",
"getting_started.about_addressing": "Követhetsz embereket felhasználónevük és a doménjük ismeretében, amennyiben megadod ezt az e-mail-szerű címet az oldalsáv tetején lévő rubrikában.",
"getting_started.about_shortcuts": "Ha a célzott személy azonos doménen tartózkodik, a felhasználónév elegendő. Ugyanez érvényes mikor személyeket említesz az állapotokban.",
"getting_started.about_developer": "A projekt fejlesztője követhető, mint Gargron@mastodon.social",
"column.home": "Kezdőlap",
"column.mentions": "Említések",
"column.public": "Nyilvános",
"column.notifications": "Értesítések",
"tabs_bar.compose": "Összeállítás",
"tabs_bar.home": "Kezdőlap",
"tabs_bar.mentions": "Említések",
"tabs_bar.public": "Nyilvános",
"tabs_bar.notifications": "Notifications",
"compose_form.placeholder": "Mire gondolsz?",
"compose_form.publish": "Tülk!",
"compose_form.sensitive": "Tartalom érzékenynek jelölése",
"compose_form.unlisted": "Listázatlan mód",
"navigation_bar.edit_profile": "Profil szerkesztése",
"navigation_bar.preferences": "Beállítások",
"navigation_bar.public_timeline": "Nyilvános időfolyam",
"navigation_bar.logout": "Kijelentkezés",
"reply_indicator.cancel": "Mégsem",
"search.placeholder": "Keresés",
"search.account": "Fiók",
"search.hashtag": "Hashtag",
"upload_button.label": "Média hozzáadása",
"upload_form.undo": "Mégsem",
"notification.follow": "{name} követ téged",
"notification.favourite": "{name} kedvencnek jelölte az állapotod",
"notification.reblog": "{name} reblogolta az állapotod",
"notification.mention": "{name} megemlített"
};
export default hu;
import ar from './ar';
import en from './en';
import de from './de';
import es from './es';
import fa from './fa';
import he from './he';
import hr from './hr';
import hu from './hu';
import io from './io';
import it from './it';
import fr from './fr';
import nl from './nl';
import no from './no';
import oc from './oc';
import pt from './pt';
import pt_br from './pt-br';
import uk from './uk';
import fi from './fi';
import eo from './eo';
import ru from './ru';
import ja from './ja';
import zh_hk from './zh-hk';
import zh_cn from './zh-cn';
import bg from './bg';
import id from './id';
const locales = {
ar,
en,
de,
es,
fa,
he,
hr,
hu,
io,
it,
fr,
nl,
no,
oc,
pt,
'pt-BR': pt_br,
uk,
fi,
eo,
ru,
ja,
'zh-HK': zh_hk,
'zh-CN': zh_cn,
bg,
id,
};
export default function getMessagesForLocale (locale) {
return locales[locale];
};
const uk = {
"column_back_button.label": "Назад",
"lightbox.close": "Закрити",
"loading_indicator.label": "Завантаження...",
"status.mention": "Згадати",
"status.delete": "Видалити",
"status.reply": "Відповісти",
"status.reblog": "Передмухнути",
"status.favourite": "Подобається",
"status.reblogged_by": "{name} передмухнув(-ла)",
"status.sensitive_warning": "Непристойний зміст",
"status.sensitive_toggle": "Натисніть, щоб подивитися",
"video_player.toggle_sound": "Увімкнути/вимкнути звук",
"account.mention": "Згадати",
"account.edit_profile": "Налаштування профілю",
"account.unblock": "Розблокувати",
"account.unfollow": "Відписатися",
"account.block": "Заблокувати",
"account.follow": "Підписатися",
"account.posts": "Пости",
"account.follows": "Підписки",
"account.followers": "Підписники",
"account.follows_you": "Підписаний",
"getting_started.heading": "Ласкаво просимо",
"getting_started.about_addressing": "Ви можете підписуватись на людей, якщо ви знаєте їх ім'я користувача чи домен, шляхом введення email-подібної адреси у верхньому рядку бокової панелі.",
"getting_started.about_shortcuts": "Якщо користувач, якого ви шукаєте, знаходиться на тому ж домені, що й ви, можна просто ввести ім'я користувача. Це правило стосується й згадування людей у статусах.",
"getting_started.about_developer": "Розробник проекту знаходиться за адресою Gargron@mastodon.social",
"column.home": "Головна",
"column.mentions": "Згадування",
"column.public": "Стіна",
"column.notifications": "Сповіщення",
"tabs_bar.compose": "Написати",
"tabs_bar.home": "Головна",
"tabs_bar.mentions": "Згадування",
"tabs_bar.public": "Стіна",
"tabs_bar.notifications": "Сповіщення",
"compose_form.placeholder": "Що у Вас на думці?",
"compose_form.publish": "Дмухнути",
"compose_form.sensitive": "Непристойний зміст",
"compose_form.unlisted": "Таємний режим",
"navigation_bar.edit_profile": "Редагувати профіль",
"navigation_bar.preferences": "Налаштування",
"navigation_bar.public_timeline": "Публічна стіна",
"navigation_bar.logout": "Вийти",
"reply_indicator.cancel": "Відмінити",
"search.placeholder": "Пошук",
"search.account": "Аккаунт",
"search.hashtag": "Хештеґ",
"upload_button.label": "Додати медіа",
"upload_form.undo": "Відмінити",
"notification.follow": "{name} підписався(-лась) на Вас",
"notification.favourite": "{name} сподобався ваш допис",
"notification.reblog": "{name} передмухнув(-ла) Ваш статус",
"notification.mention": "{name} згадав(-ла) Вас"
};
export default uk;
@font-face {
font-family: 'Montserrat';
src: local('Montserrat');