Compare commits

..

5 Commits

Author SHA1 Message Date
Eugen
2e4afccd9d Fix #2108 - Fix gif uploads (#2171)
* Fix #2108 - Fix gif uploads
Add specs for media attachment gifv conversion

* Add ffmpeg to travis

* Make travis install ffmpeg, not libav

* Switch travis to trusty
2017-04-19 23:21:00 +02:00
evilny0
0876a06e45 Updated note about 'none' SMTP authentication method in .env.production.sample (#2167) 2017-04-19 23:16:43 +02:00
Darshak Parikh
43caf1fa5f Add some Spanish translatoins (#2170) 2017-04-19 22:19:41 +02:00
alpaca-tc
2c0d756ad9 Extract error messages to locale file (#2162) 2017-04-19 22:19:32 +02:00
jeroenpraat
f06cba3f60 Dutch language strings: a few important fixes (#2163) 2017-04-19 22:19:19 +02:00
12 changed files with 90 additions and 20 deletions

View File

@@ -36,7 +36,8 @@ OTP_SECRET=
# E-mail configuration
# Note: Mailgun and SparkPost (https://sparkpo.st/smtp) each have good free tiers
# If you want to use an SMTP server without authentication (e.g local Postfix relay)
# then set SMTP_AUTH_METHOD to 'none' and leave SMTP_LOGIN and SMTP_PASSWORD blank
# then set SMTP_AUTH_METHOD to 'none' and *comment* SMTP_LOGIN and SMTP_PASSWORD.
# Leaving them blank is not enough for authentication method 'none'.
SMTP_SERVER=smtp.mailgun.org
SMTP_PORT=587
SMTP_LOGIN=

View File

@@ -1,5 +1,7 @@
language: ruby
cache: bundler
dist: trusty
sudo: required
notifications:
email: false
@@ -24,8 +26,9 @@ bundler_args: --without development production --retry=3 --jobs=3
before_install:
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo add-apt-repository -y ppa:mc3man/trusty-media
- sudo apt-get -qq update
- sudo apt-get -qq install g++-4.8
- sudo apt-get -qq install g++-4.8 ffmpeg
install:
- nvm install
- npm install -g yarn

View File

@@ -35,6 +35,10 @@ const es = {
"column.community": "Historia local",
"column.public": "Historia federada",
"column.notifications": "Notificaciones",
"column.blocks": "Usuarios bloqueados",
"column.favourites": "Favoritos",
"column.follow_requests": "Solicitudes para seguirte",
"column.mutes": "Usuarios silenciados",
"tabs_bar.compose": "Redactar",
"tabs_bar.home": "Inicio",
"tabs_bar.mentions": "Menciones",
@@ -56,6 +60,8 @@ const es = {
"navigation_bar.blocks": "Usuarios bloqueados",
"navigation_bar.info": "Información adicional",
"navigation_bar.logout": "Cerrar sesión",
"navigation_bar.follow_requests": "Solicitudes para seguirte",
"navigation_bar.mutes": "Usuarios silenciados",
"reply_indicator.cancel": "Cancelar",
"search.placeholder": "Buscar",
"search.account": "Cuenta",

View File

@@ -11,28 +11,32 @@ const nl = {
"status.sensitive_warning": "Gevoelige inhoud",
"status.sensitive_toggle": "Klik om te zien",
"video_player.toggle_sound": "Geluid in-/uitschakelen",
"account.mention": "@{name} vermelden",
"account.mention": "Vermeld @{name}",
"account.edit_profile": "Profiel bewerken",
"account.unblock": "@{name} deblokkeren",
"account.unblock": "Deblokkeer @{name}",
"account.unfollow": "Ontvolgen",
"account.block": "@{name} blokkeren",
"account.block": "Blokkeer @{name}",
"account.follow": "Volgen",
"account.posts": "Berichten",
"account.follows": "Volgt",
"account.followers": "Volgers",
"account.follows_you": "Volgt jou",
"account.requested": "Wacht op goedkeuring",
"account.mute": "@{name} negeren",
"account.unmute": "@{name} niet meer negeren",
"account.report": "Report @{name}",
"account.mute": "Negeer @{name}",
"account.unmute": "Negeer @{name} niet meer",
"account.report": "Rapporteer @{name}",
"getting_started.heading": "Beginnen",
"getting_started.about_addressing": "Je kunt mensen volgen als je hun gebruikersnaam en het domein van hun server kent. Voer hiervoor het e-mailachtige adres in het zoekveld in.",
"getting_started.about_shortcuts": "Als de gezochte gebruiker op hetzelfde domein zit als jijzelf, is invoeren van de gebruikersnaam genoeg. Dat geldt ook als je mensen in toots wilt vermelden.",
"getting_started.open_source_notice": "Mastodon is open-sourcesoftware. Je kunt bijdragen of problemen melden op GitHub via {github}. {apps}.",
"getting_started.apps": "Er zijn meerdere apps beschikbaar",
"column.home": "Jouw tijdlijn",
"column.community": "Lokale tijdlijn",
"column.public": "Globale tijdlijn",
"column.notifications": "Meldingen",
"column.favourites": "Favorieten",
"column.blocks": "Geblokkeerde gebruikers",
"column.mutes": "Genegeerde gebruikers",
"tabs_bar.compose": "Schrijven",
"tabs_bar.home": "Jouw tijdlijn",
"tabs_bar.mentions": "Vermeldingen",
@@ -44,7 +48,7 @@ const nl = {
"compose_form.spoiler": "Tekst achter waarschuwing verbergen",
"compose_form.spoiler_placeholder": "Waarschuwingstekst",
"compose_form.private": "Als privé markeren",
"compose_form.privacy_disclaimer": "Jouw privétoot wordt afgeleverd aan de vermelde gebruikers op {domains}. Vertrouw jij {domainsCount, plural, one {that server} andere {those servers}}? Het privé plaatsen van toots werkt alleen op Mastodon-servers. Als {domains} {domainsCount, plural, een {is not a Mastodon instance} andere {are not Mastodon instances}}, dan wordt er niet aangegeven dat de toot besloten is, waardoor het kan worden geboost of op een andere manier zichtbaar wordt gemaakt voor mensen waarvoor het niet was bedoeld.",
"compose_form.privacy_disclaimer": "Jouw privétoot wordt afgeleverd aan de vermelde gebruikers op {domains}. Vertrouw jij {domainsCount, plural, one {die server} other {die servers}}? Het privé plaatsen van toots werkt alleen op Mastodon-servers. Wanneer {domains} {domainsCount, plural, one {geen Mastodon-server is} other {geen Mastodon-servers zijn}}, dan wordt er niet aangegeven dat de toot privé is, waardoor het kan worden geboost of op een andere manier zichtbaar wordt gemaakt voor mensen waarvoor het niet was bedoeld.",
"compose_form.unlisted": "Niet op openbare tijdlijnen tonen",
"navigation_bar.edit_profile": "Profiel bewerken",
"navigation_bar.preferences": "Voorkeuren",
@@ -55,6 +59,7 @@ const nl = {
"navigation_bar.blocks": "Geblokkeerde gebruikers",
"navigation_bar.mutes": "Genegeerde gebruikers",
"navigation_bar.logout": "Afmelden",
"navigation_bar.favourites": "Favorieten",
"reply_indicator.cancel": "Annuleren",
"search.placeholder": "Zoeken",
"search.account": "Account",

View File

@@ -8,7 +8,7 @@ class Account < ApplicationRecord
# Local users
has_one :user, inverse_of: :account
validates :username, presence: true, format: { with: /\A[a-z0-9_]+\z/i, message: 'only letters, numbers and underscores' }, uniqueness: { scope: :domain, case_sensitive: false }, length: { maximum: 30 }, if: 'local?'
validates :username, presence: true, format: { with: /\A[a-z0-9_]+\z/i }, uniqueness: { scope: :domain, case_sensitive: false }, length: { maximum: 30 }, if: 'local?'
validates :username, presence: true, uniqueness: { scope: :domain, case_sensitive: true }, unless: 'local?'
# Avatar upload

View File

@@ -106,13 +106,18 @@ class MediaAttachment < ApplicationRecord
end
def set_type_and_extension
if file.blank?
self.type = :unknown
else
self.type = VIDEO_MIME_TYPES.include?(file_content_type) ? :video : :image
extension = Paperclip::Interpolations.content_type_extension(file, :original)
basename = Paperclip::Interpolations.basename(file, :original)
file.instance_write :file_name, [basename, extension].delete_if(&:empty?).join('.')
end
self.type = VIDEO_MIME_TYPES.include?(file_content_type) ? :video : :image
extension = appropriate_extension
basename = Paperclip::Interpolations.basename(file, :original)
file.instance_write :file_name, [basename, extension].delete_if(&:empty?).join('.')
end
def appropriate_extension
mime_type = MIME::Types[file.content_type]
extensions_for_mime_type = mime_type.empty? ? [] : mime_type.first.extensions
original_extension = Paperclip::Interpolations.extension(file, :original)
extensions_for_mime_type.include?(original_extension) ? original_extension : extensions_for_mime_type.first
end
end

View File

@@ -29,7 +29,7 @@ class Status < ApplicationRecord
validates :uri, uniqueness: true, unless: 'local?'
validates :text, presence: true, unless: 'reblog?'
validates_with StatusLengthValidator
validates :reblog, uniqueness: { scope: :account, message: 'of status already exists' }, if: 'reblog?'
validates :reblog, uniqueness: { scope: :account }, if: 'reblog?'
default_scope { order('id desc') }

View File

@@ -0,0 +1,12 @@
en:
activerecord:
errors:
models:
account:
attributes:
username:
invalid: only letters, numbers and underscores
status:
attributes:
reblog:
taken: of status already exists

View File

@@ -0,0 +1,12 @@
ja:
activerecord:
errors:
models:
account:
attributes:
username:
invalid: アルファベット・数値・アンダーバー(_)で入力してください
status:
attributes:
reblog:
taken: のブーストはすでに存在します

View File

@@ -7,7 +7,11 @@ module Paperclip
def make
num_frames = identify('-format %n :file', file: file.path).to_i
return file unless options[:style] == :original && num_frames > 1
unless options[:style] == :original && num_frames > 1
tmp_file = Paperclip::TempfileFactory.new.generate(attachment.instance.file_file_name)
tmp_file << file.read
return tmp_file
end
final_file = Paperclip::Transcoder.make(file, options, attachment)

BIN
spec/fixtures/files/attachment.gif vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

View File

@@ -1,5 +1,27 @@
require 'rails_helper'
RSpec.describe MediaAttachment, type: :model do
describe 'animated gif conversion' do
let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('avatar.gif')) }
it 'sets type to gifv' do
expect(media.type).to eq 'gifv'
end
it 'converts original file to mp4' do
expect(media.file_content_type).to eq 'video/mp4'
end
end
describe 'non-animated gif non-conversion' do
let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('attachment.gif')) }
it 'sets type to image' do
expect(media.type).to eq 'image'
end
it 'leaves original file as-is' do
expect(media.file_content_type).to eq 'image/gif'
end
end
end