removed auto_link_images_wider_than setting
This commit is contained in:
parent
88ca51bb00
commit
6251935b1e
|
@ -106,7 +106,6 @@ class SiteSetting < ActiveRecord::Base
|
|||
setting(:max_flags_per_day, 20)
|
||||
setting(:max_edits_per_day, 30)
|
||||
setting(:max_favorites_per_day, 20)
|
||||
setting(:auto_link_images_wider_than, 50)
|
||||
|
||||
setting(:email_time_window_mins, 10)
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class Upload < ActiveRecord::Base
|
|||
def create_thumbnail!
|
||||
return unless SiteSetting.create_thumbnails?
|
||||
return if SiteSetting.enable_s3_uploads?
|
||||
return unless width > SiteSetting.auto_link_images_wider_than
|
||||
return if width < SiteSetting.max_image_width
|
||||
return if has_thumbnail?
|
||||
thumbnail = OptimizedImage.create_for(self, width, height)
|
||||
optimized_images << thumbnail if thumbnail
|
||||
|
|
|
@ -624,7 +624,6 @@ cs:
|
|||
max_mentions_per_post: "Maximální počet zmínek přes @name, které mohou být použity v jednom příspěvku"
|
||||
|
||||
create_thumbnails: "Vytvářet náhledy pro obrázky v lightboxu"
|
||||
auto_link_images_wider_than: "Obrázky širší než tato hodnota v pixelech budou odkazovány do lightboxu"
|
||||
|
||||
email_time_window_mins: "Kolik minut se čeká než se uživateli zašle email, aby měl možnost obsah vidět sám od sebe"
|
||||
flush_timings_secs: "Jak často se vynulují časovací data na serveru, v sekundách"
|
||||
|
|
|
@ -411,8 +411,6 @@ da:
|
|||
basic_requires_read_posts: "How many posts a new user must read before promotion to basic (1) trust level"
|
||||
basic_requires_time_spent_mins: "How many minutes a new user must read posts before promotion to basic (1) trust level"
|
||||
|
||||
auto_link_images_wider_than: "Images wider than this, in pixels, will get auto link and lightbox treatment"
|
||||
|
||||
email_time_window_mins: "How many minutes we wait before sending a user mail, to give them a chance to see it first"
|
||||
flush_timings_secs: "How frequently we flush timing data to the server, in seconds"
|
||||
max_word_length: "The maximum allowed word length, in characters, in a topic title"
|
||||
|
|
|
@ -580,8 +580,6 @@ de:
|
|||
newuser_max_mentions_per_post: "Maximale Zahl der @Namens-Erwähnungen, die neue Benutzer in Beiträgen nutzen dürfen."
|
||||
max_mentions_per_post: "Maximale Zahl der @Namens-Erwähnungen, die man in einem Beitrag nutzen kann."
|
||||
|
||||
auto_link_images_wider_than: "Pixelbreite, ab der Bilder automatisch verlinkt und verkleinert in einer Lightbox dargestellt werden."
|
||||
|
||||
email_time_window_mins: "Minuten Wartezeit, bevor eine Mail an Nutzer verschickt wird, um ihnen die Chance zu geben, eine Neuigkeit zuerst zu sehen."
|
||||
flush_timings_secs: "Sekunden, nach denen Zeiteinstellungen auf den Server übertragen werden."
|
||||
max_word_length: "Maximale Wortlänge in Zeichen in Thementiteln."
|
||||
|
|
|
@ -602,7 +602,6 @@ en:
|
|||
max_mentions_per_post: "Maximum number of @name notifications you can use in a post"
|
||||
|
||||
create_thumbnails: "Create thumbnails for lightboxed images"
|
||||
auto_link_images_wider_than: "Images wider than this, in pixels, will get auto link and lightbox treatment"
|
||||
|
||||
email_time_window_mins: "How many minutes we wait before sending a user mail, to give them a chance to see it first"
|
||||
flush_timings_secs: "How frequently we flush timing data to the server, in seconds"
|
||||
|
|
|
@ -399,8 +399,6 @@ es:
|
|||
basic_requires_read_posts: "Cuantos post debe un usuario leer antes de ser promocionado al nivel básico (1) de confianza"
|
||||
basic_requires_time_spent_mins: "Cuantos minutos un usuario debe leer posts antes de ser promocionado al nivel básico (1) de confianza"
|
||||
|
||||
auto_link_images_wider_than: "Imágenes más amplias que esto, en píxeles, tendrán un tratamiento de lightbox y auto link"
|
||||
|
||||
email_time_window_mins: "Cuantos minutos esperamos antes de enviar un mail a un usuario, para darles la oportunidad de verlo antes"
|
||||
flush_timings_secs: "How frequently we flush timing data to the server, in seconds"
|
||||
max_word_length: "La máxima longitud de palabra permitida, en caracteres en el título de un topic"
|
||||
|
|
|
@ -570,8 +570,6 @@ fr:
|
|||
regular_requires_likes_given: "Combien de j'aime un utilisateur doit donner pour être promu au niveau régulier (2)"
|
||||
regular_requires_topic_reply_count: "Combien de réponses un utilisateur doit donner pour être promu au niveau régulier (2)"
|
||||
|
||||
auto_link_images_wider_than: "Les images en lien automatiques doivent êtres plus larges que préciser"
|
||||
|
||||
email_time_window_mins: "Combien de minutes attendre avant d'envoyer un mail à l'utilisateur, pour lui donner une chance de voir lui-même avant l'envoi."
|
||||
flush_timings_secs: "A quelle fréquence requêter les données de timing au serveur, en secondes."
|
||||
max_word_length: "Le nombre maximum de mots dans un titre de discussion"
|
||||
|
@ -597,7 +595,7 @@ fr:
|
|||
|
||||
newuser_spam_host_threshold: "Limite du nombre de liens vers un même host qu'un nouvel utilisateur peut insérer dans un message avant d'être considérer comme un SPAM."
|
||||
staff_like_weight: "Poids supplémentaire donné aux Likes du staff lors d'une recherche."
|
||||
|
||||
|
||||
reply_by_email_enabled: "Cocher si le forum doit supporter les réponses par email"
|
||||
reply_by_email_address: "Modèle pour la réponse par adresse email par exemple : %{reply_key}@reply.myforum.com"
|
||||
|
||||
|
@ -606,7 +604,7 @@ fr:
|
|||
pop3s_polling_host: "L'hôte utilisé pour le polling pour l'email via POP3S"
|
||||
pop3s_polling_username: "Le nom d'utilisateur pour le polling POPS3 par email"
|
||||
pop3s_polling_password: "Le mot de passe pour le polling POPS3 par email"
|
||||
|
||||
|
||||
minimum_topics_similar: "Combien de topics ont besoin d'exister dans la base de données avant que des topics similaires soit présentés."
|
||||
|
||||
notification_types:
|
||||
|
|
|
@ -411,8 +411,6 @@ id:
|
|||
basic_requires_read_posts: "How many posts a new user must read before promotion to basic (1) trust level"
|
||||
basic_requires_time_spent_mins: "How many minutes a new user must read posts before promotion to basic (1) trust level"
|
||||
|
||||
auto_link_images_wider_than: "Images wider than this, in pixels, will get auto link and lightbox treatment"
|
||||
|
||||
email_time_window_mins: "How many minutes we wait before sending a user mail, to give them a chance to see it first"
|
||||
flush_timings_secs: "How frequently we flush timing data to the server, in seconds"
|
||||
max_word_length: "The maximum allowed word length, in characters, in a topic title"
|
||||
|
|
|
@ -548,8 +548,6 @@ it:
|
|||
newuser_max_mentions_per_post: "Numero massimo di menzioni @name che un nuovo utente può fare in un post"
|
||||
max_mentions_per_post: "Numero massimo di menzioni @name che un utente può fare in un post"
|
||||
|
||||
auto_link_images_wider_than: "Immagini più larghe di questo valore (in pixel) verranno visualizzate tramite lightbox"
|
||||
|
||||
email_time_window_mins: "Quanti minuti prima che una email venga mandata all'utente, per dare la possibilità di controllarla"
|
||||
flush_timings_secs: "Frequenza di aggiornamento dati temporali (su server), in secondi"
|
||||
max_word_length: "Numero massimo di caratteri che compongono una parola del titolo di un topic"
|
||||
|
|
|
@ -574,8 +574,6 @@ nl:
|
|||
newuser_max_mentions_per_post: "Maximum aantal @naam notificaties dat een nieuw lid in een bericht kan gebruiken"
|
||||
max_mentions_per_post: "Maximum aantal @naam notificaties dat je in een bericht kan gebruiken"
|
||||
|
||||
auto_link_images_wider_than: "Afbeeldingen breder dan dit, in pixels, krijgen automatisch een link naar een lightbox"
|
||||
|
||||
email_time_window_mins: "Hoeveel minuten we wachten met het sturen van een e-mail naar een persoon, om ze een kans te geven het eerst op de site te kunnen lezen."
|
||||
flush_timings_secs: "Hoe vaak we timing-data naar de server sturen, in seconden."
|
||||
max_word_length: "De maximumlengte van een woord in een topictitel"
|
||||
|
|
|
@ -657,8 +657,6 @@ pseudo:
|
|||
ůšéř čáɳ ůšé íɳ á ƿóšť ]]'
|
||||
max_mentions_per_post: '[[ Ϻáхíɱůɱ ɳůɱƀéř óƒ @ɳáɱé ɳóťíƒíčáťíóɳš ýóů čáɳ ůšé íɳ
|
||||
á ƿóšť ]]'
|
||||
auto_link_images_wider_than: '[[ Íɱáǧéš ŵíďéř ťĥáɳ ťĥíš, íɳ ƿíхéłš, ŵíłł ǧéť áůťó
|
||||
łíɳǩ áɳď łíǧĥťƀóх ťřéáťɱéɳť ]]'
|
||||
email_time_window_mins: '[[ Ĥóŵ ɱáɳý ɱíɳůťéš ŵé ŵáíť ƀéƒóřé šéɳďíɳǧ á ůšéř ɱáíł,
|
||||
ťó ǧíνé ťĥéɱ á čĥáɳčé ťó šéé íť ƒířšť ]]'
|
||||
flush_timings_secs: '[[ Ĥóŵ ƒřéƣůéɳťłý ŵé ƒłůšĥ ťíɱíɳǧ ďáťá ťó ťĥé šéřνéř, íɳ
|
||||
|
|
|
@ -339,8 +339,6 @@ pt:
|
|||
basic_requires_read_posts: "How many posts a user needs to have read to be promoted to basic level"
|
||||
basic_requires_time_spent_mins: "How many mins a user needs to have spent reading posts to be promoted to basic level"
|
||||
|
||||
auto_link_images_wider_than: "How wide does an image need to be, to be considered for auto link and lightbox treatment"
|
||||
|
||||
email_time_window_mins: "How many minutes we wait before sending a user mail, to give them a chance to see it first."
|
||||
flush_timings_secs: "How frequently we flush timing data to the server, in seconds."
|
||||
|
||||
|
|
|
@ -625,7 +625,6 @@ ru:
|
|||
newuser_max_mentions_per_post: Максимальное число упоминаний по @name , которое новый пользователь может использовать в сообщении
|
||||
max_mentions_per_post: Максимальное число упоминаний по @name , которое новый пользователь может использовать в сообщении
|
||||
create_thumbnails: Создать миниатюры для изображений
|
||||
auto_link_images_wider_than: Изображение, шириной более чем указанное значение в пикселях, получит автоматическую ссылку и обработку lightbox
|
||||
email_time_window_mins: Сколько минут нужно подождать перед отсылкой письма пользователя, чтобы дать ему шанс сперва его увидеть
|
||||
flush_timings_secs: Как часто мы отправляем временные данные на сервер, в секундах
|
||||
max_word_length: Максимальная длина слов в названии темы, в символах
|
||||
|
|
|
@ -468,8 +468,6 @@ sv:
|
|||
newuser_max_mentions_per_post: "Maximum number of @name notifications a new user can use in a post"
|
||||
max_mentions_per_post: "Maximum number of @name notifications you can use in a post"
|
||||
|
||||
auto_link_images_wider_than: "Images wider than this, in pixels, will get auto link and lightbox treatment"
|
||||
|
||||
email_time_window_mins: "How many minutes we wait before sending a user mail, to give them a chance to see it first"
|
||||
flush_timings_secs: "How frequently we flush timing data to the server, in seconds"
|
||||
max_word_length: "The maximum allowed word length, in characters, in a topic title"
|
||||
|
|
|
@ -563,8 +563,6 @@ zh_CN:
|
|||
newuser_max_mentions_per_post: "一个访问者可以在一个帖子里使用 @name 提及的最大数量"
|
||||
max_mentions_per_post: "你可以在一个帖子里使用 @name 提及的最大数量"
|
||||
|
||||
auto_link_images_wider_than: "图片宽度超过此设定像素值的,将被自动附加一个链接并且使用灯箱(lightbox)来展示"
|
||||
|
||||
email_time_window_mins: "等待多少分钟才给用户发送通知电子邮件,好让他们有机会自己来浏览"
|
||||
flush_timings_secs: "刷新时间数据的频率,以秒为单位"
|
||||
max_word_length: "在主题的标题中,允许的词语长度的最大字符数"
|
||||
|
|
|
@ -546,8 +546,6 @@ zh_TW:
|
|||
newuser_max_mentions_per_post: "一個訪問者可以在一個帖子裏使用 @name 提及的最大數量"
|
||||
max_mentions_per_post: "你可以在一個帖子裏使用 @name 提及的最大數量"
|
||||
|
||||
auto_link_images_wider_than: "圖片寬度超過此設定像素值的,將被自動附加一個鏈接並且使用燈箱(lightbox)來展示"
|
||||
|
||||
email_time_window_mins: "等待多少分鍾才給用戶發送通知電子郵件,好讓他們有機會自己來浏覽"
|
||||
flush_timings_secs: "刷新時間數據的頻率,以秒爲單位"
|
||||
max_word_length: "在主題的標題中,允許的詞語長度的最大字符數"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Post processing that we can do after a post has already been cooked. For
|
||||
# example, inserting the onebox content, or image sizes.
|
||||
# Post processing that we can do after a post has already been cooked.
|
||||
# For example, inserting the onebox content, or image sizes.
|
||||
|
||||
require_dependency 'oneboxer'
|
||||
|
||||
|
@ -16,14 +16,13 @@ class CookedPostProcessor
|
|||
end
|
||||
|
||||
def post_process
|
||||
return unless @doc.present?
|
||||
post_process_images
|
||||
post_process_oneboxes
|
||||
end
|
||||
|
||||
def post_process_images
|
||||
images = @doc.css("img") - @doc.css(".onebox-result img")
|
||||
return unless images.present?
|
||||
images = @doc.css("img") - @doc.css(".onebox-result img") - @doc.css(".quote img")
|
||||
return if images.blank?
|
||||
|
||||
images.each do |img|
|
||||
# keep track of the original src
|
||||
|
@ -109,13 +108,13 @@ class CookedPostProcessor
|
|||
|
||||
def convert_to_link!(img, upload=nil)
|
||||
src = img["src"]
|
||||
return unless src.present?
|
||||
|
||||
width, height = img["width"].to_i, img["height"].to_i
|
||||
|
||||
return unless src.present? && width > SiteSetting.auto_link_images_wider_than
|
||||
|
||||
original_width, original_height = get_size(src)
|
||||
|
||||
return unless original_width.to_i > width && original_height.to_i > height
|
||||
return if original_width < SiteSetting.max_image_width
|
||||
|
||||
parent = img.parent
|
||||
while parent
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
require 'spec_helper'
|
||||
|
||||
require 'cooked_post_processor'
|
||||
|
||||
describe CookedPostProcessor do
|
||||
|
@ -42,7 +41,6 @@ describe CookedPostProcessor do
|
|||
@topic = Fabricate(:topic)
|
||||
@post = Fabricate.build(:post_with_image_url, topic: @topic, user: @topic.user)
|
||||
@cpp = CookedPostProcessor.new(@post, image_sizes: {'http://www.forumwarz.com/images/header/logo.png' => {'width' => 111, 'height' => 222}})
|
||||
@cpp.expects(:get_size).returns([111,222])
|
||||
end
|
||||
|
||||
it "doesn't call image_dimensions because it knows the size" do
|
||||
|
@ -134,6 +132,7 @@ describe CookedPostProcessor do
|
|||
let(:processor) { CookedPostProcessor.new(post) }
|
||||
|
||||
before do
|
||||
SiteSetting.stubs(:max_image_width).returns(10)
|
||||
FastImage.stubs(:size).returns([1000, 1000])
|
||||
processor.post_process_images
|
||||
end
|
||||
|
@ -155,13 +154,8 @@ describe CookedPostProcessor do
|
|||
SiteSetting.stubs(:crawl_images?).returns(true)
|
||||
end
|
||||
|
||||
let :post_with_img do
|
||||
Fabricate.build(:post, cooked: '<p><img src="http://hello.com/image.png"></p>')
|
||||
end
|
||||
|
||||
let :cpp_for_post do
|
||||
CookedPostProcessor.new(post_with_img)
|
||||
end
|
||||
let(:post_with_img) { Fabricate.build(:post, cooked: '<p><img src="http://hello.com/image.png"></p>') }
|
||||
let(:cpp_for_post) { CookedPostProcessor.new(post_with_img) }
|
||||
|
||||
it 'convert img tags to links if they are sized down' do
|
||||
cpp_for_post.expects(:get_size).returns([2000,2000]).twice
|
||||
|
@ -177,31 +171,32 @@ describe CookedPostProcessor do
|
|||
|
||||
end
|
||||
|
||||
context 'image_dimensions' do
|
||||
context "image_dimensions" do
|
||||
|
||||
it "returns unless called with a http or https url" do
|
||||
cpp.image_dimensions('/tmp/image.jpg').should be_blank
|
||||
cpp.image_dimensions("/tmp/image.jpg").should be_blank
|
||||
end
|
||||
|
||||
context 'with valid url' do
|
||||
before do
|
||||
@url = 'http://www.forumwarz.com/images/header/logo.png'
|
||||
end
|
||||
context "with valid url" do
|
||||
|
||||
it "doesn't call fastimage if image crawling is disabled" do
|
||||
let(:url) { "http://www.forumwarz.com/images/header/logo.png" }
|
||||
|
||||
it "doesn't call FastImage if image crawling is disabled" do
|
||||
SiteSetting.expects(:crawl_images?).returns(false)
|
||||
FastImage.expects(:size).never
|
||||
cpp.image_dimensions(@url)
|
||||
cpp.image_dimensions(url)
|
||||
end
|
||||
|
||||
it "calls fastimage if image crawling is enabled" do
|
||||
it "calls FastImage if image crawling is enabled" do
|
||||
SiteSetting.expects(:crawl_images?).returns(true)
|
||||
FastImage.expects(:size).with(@url)
|
||||
cpp.image_dimensions(@url)
|
||||
FastImage.expects(:size).with(url)
|
||||
cpp.image_dimensions(url)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'is_valid_image_uri?' do
|
||||
context "is_valid_image_uri?" do
|
||||
|
||||
it "needs the scheme to be either http or https" do
|
||||
cpp.is_valid_image_uri?("http://domain.com").should == true
|
||||
|
@ -212,25 +207,25 @@ describe CookedPostProcessor do
|
|||
cpp.is_valid_image_uri?("/tmp/image.png").should == false
|
||||
end
|
||||
|
||||
it "doesn't throw exception with a bad URI" do
|
||||
it "doesn't throw an exception with a bad URI" do
|
||||
cpp.is_valid_image_uri?("http://do<main.com").should == nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'get_filename' do
|
||||
context "get_filename" do
|
||||
|
||||
it "returns the filename of the src when there is no upload" do
|
||||
cpp.get_filename(nil, "http://domain.com/image.png").should == "image.png"
|
||||
end
|
||||
|
||||
it "returns the original filename of the upload when there is an upload" do
|
||||
upload = Fabricate.build(:upload, { original_filename: "upload.jpg" })
|
||||
upload = build(:upload, { original_filename: "upload.jpg" })
|
||||
cpp.get_filename(upload, "http://domain.com/image.png").should == "upload.jpg"
|
||||
end
|
||||
|
||||
it "returns a generic name for pasted images" do
|
||||
upload = Fabricate.build(:upload, { original_filename: "blob.png" })
|
||||
upload = build(:upload, { original_filename: "blob.png" })
|
||||
cpp.get_filename(upload, "http://domain.com/image.png").should == I18n.t('upload.pasted_image_filename')
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue