diff --git a/app/models/site_setting.rb b/app/models/site_setting.rb index 527aadac84e..ecaf743b5c6 100644 --- a/app/models/site_setting.rb +++ b/app/models/site_setting.rb @@ -69,9 +69,6 @@ class SiteSetting < ActiveRecord::Base setting(:access_password) setting(:queue_jobs, !Rails.env.test?) setting(:crawl_images, !Rails.env.test?) - setting(:enable_imgur, false) - setting(:imgur_client_id, '') - setting(:imgur_endpoint, "https://api.imgur.com/3/image.json") setting(:max_image_width, 690) client_setting(:category_featured_topics, 6) setting(:topics_per_page, 30) diff --git a/app/models/upload.rb b/app/models/upload.rb index de7226a5334..ebcde0bc6ec 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -1,6 +1,5 @@ require 'digest/sha1' require 'image_sizer' -require 'imgur' require 's3' require 'local_store' @@ -39,7 +38,6 @@ class Upload < ActiveRecord::Base end def self.store_file(file, image_info, upload_id) - return Imgur.store_file(file, image_info, upload_id) if SiteSetting.enable_imgur? return S3.store_file(file, image_info, upload_id) if SiteSetting.enable_s3_uploads? return LocalStore.store_file(file, image_info, upload_id) end diff --git a/config/locales/server.cs.yml b/config/locales/server.cs.yml index 440f8d95dfd..8b51fb26856 100644 --- a/config/locales/server.cs.yml +++ b/config/locales/server.cs.yml @@ -462,10 +462,6 @@ cs: queue_jobs: "Zařazovat úlohy do fronty v sidekiq, není-li nastaveno, jsou úlohy vyřizovány okamžitě" crawl_images: "Povolit získávání obrázků z webů třetích stran" ninja_edit_window: "Jak rychle smíte udělat změnu, aniž by se uložila jako nová verze" - enable_imgur: "Používat imgur pro ukládání obrázků, nehostovat obrázky lokálně" - imgur_client_id: "Přístupový klíč 'client ID' pro imgur.com - vyžadováno pro upload obrázků" - imgur_client_secret: "Přístupový klíč 'client secret' pro imgur.com - vyžadováno pro upload obrázků" - imgur_endpoint: "Koncový bod pro upload obrázků na imgur.com" max_image_width: "Maximální šířka obrázku v příspěvku" category_featured_topics: "Počet témat zobrazených v seznamu kategorií" add_rel_nofollow_to_user_content: "Přidávat 'rel nofollow' do uživatelského obsahu, mimo interních odkazů (včetně nadřazené domény) změna tohoto nastavení vyžaduje přegenerování všech MarkDownových textů" diff --git a/config/locales/server.da.yml b/config/locales/server.da.yml index 04d482a9677..bcccfc3cdd0 100644 --- a/config/locales/server.da.yml +++ b/config/locales/server.da.yml @@ -310,9 +310,6 @@ da: queue_jobs: "Queue various jobs in sidekiq, if false queues are inline" crawl_images: "Enable retrieving images from third party sources to insert width and height dimensions" ninja_edit_window: "Number of seconds after posting where edits do not create a new version" - enable_imgur: "Enable imgur api for uploading, don't host files locally" - imgur_api_key: "Your imgur.com api key, required for image upload to function" - imgur_endpoint: "End point for uploading imgur.com images" max_image_width: "Maximum allowed width of images in a post" category_featured_topics: "Number of topics displayed per category in the /categories page" add_rel_nofollow_to_user_content: "Add rel nofollow to all submitted user content, except for internal links (including parent domains) changing this requires you update all your baked markdown" diff --git a/config/locales/server.de.yml b/config/locales/server.de.yml index 6d7692c5f7b..624e916f9df 100644 --- a/config/locales/server.de.yml +++ b/config/locales/server.de.yml @@ -443,10 +443,6 @@ de: queue_jobs: "Benutze die Sidekiq-Queue, falls falsche Queues inline sind." crawl_images: "Lade Bilder von Dritten herunter, um ihre Höhe und Breite zu bestimmen." ninja_edit_window: "Sekunden nach Empfang eines Beitrag, in denen Bearbeitungen nicht als neue Version gelten." - enable_imgur: "Aktiviere die Imgur API zum Hochladen, so dass Dateien nicht lokal gehostet werden." - imgur_client_id: "Deine imgur.com Client-ID. Wird benötigt, um Bilder hochzuladen." - imgur_client_secret: "Dein imgur.com Geheimniss. Wird zur Zeit für das Hochladen der Bilder nicht benötigt, könnte aber in Zukunft benötigt werden." - imgur_endpoint: "Endknoten für das Hochladen von imgur.com-Bildern." max_image_width: "Maximalbreite von Bildern in einem Beitrag." category_featured_topics: "Zahl der angezeigten Themen je Kategorie auf der Kategorieseite /categories." add_rel_nofollow_to_user_content: "Füge mit Ausnahme interner Links allen nutzergenerierten Inhalten 'rel nofollow' hinzu (inkludiert übergeordnete Domains). Die Änderung dieser Einstellung erfordert, dass Du sämtliche Markdown-Beiträge aktualisierst." diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 537902f47aa..ac60017d8aa 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -447,10 +447,6 @@ en: queue_jobs: "Queue various jobs in sidekiq, if false queues are inline" crawl_images: "Enable retrieving images from third party sources to insert width and height dimensions" ninja_edit_window: "Number of seconds after posting where edits do not create a new version" - enable_imgur: "Enable imgur api for uploading, don't host files locally" - imgur_client_id: "Your imgur.com client ID, required for image upload to function" - imgur_client_secret: "Your imgur.com client secret. Not currently required for image upload to function, but may be at some point." - imgur_endpoint: "End point for uploading imgur.com images" max_image_width: "Maximum allowed width of images in a post" category_featured_topics: "Number of topics displayed per category in the /categories page" add_rel_nofollow_to_user_content: "Add rel nofollow to all submitted user content, except for internal links (including parent domains) changing this requires you update all your baked markdown (rake posts:rebake)" diff --git a/config/locales/server.es.yml b/config/locales/server.es.yml index db21ab92d1a..c22826d8b13 100644 --- a/config/locales/server.es.yml +++ b/config/locales/server.es.yml @@ -298,9 +298,6 @@ es: queue_jobs: "Encolar varios trabajos en sidekiq, si es falso las colas serán en linea" crawl_images: "Activar obtener imágenes de origines third party para insertar las dimensiones de ancho y alto" ninja_edit_window: "Número de segundos after postear donde las ediciones no causan una nueva versión" - enable_imgur: "Activar imgur api para subidas, no almacenes ficheros localmente" - imgur_api_key: "Tu imgur.com api key, requerida para la función de subida de imágenes" - imgur_endpoint: "End point para la subida de imagenes de imgur.com" max_image_width: "Máximo ancho permitido en las imágenes de un post" category_featured_topics: "Número de topics mostrados por categoría en la página /categories" add_rel_nofollow_to_user_content: "Añadir rel nofollow a todo el contenido subido por usuarios, exceptuando los links internos (incluyendo dominios padres) changing this requires you update all your baked markdown" diff --git a/config/locales/server.fr.yml b/config/locales/server.fr.yml index a0b96e3e7d8..ddd907807e2 100644 --- a/config/locales/server.fr.yml +++ b/config/locales/server.fr.yml @@ -442,10 +442,6 @@ fr: queue_jobs: "mettre les différents jobs en attente sur différentes queues, si false les queues sont en file" crawl_images: "permettre la récupération des images provenant de sources tierces" ninja_edit_window: "temps d'édition avant de sauvegarder une nouvelle version, en secondes." - enable_imgur: "utiliser l'envoi des images avec l'API imgur, ne pas stocker les fichiers localement" - imgur_client_id: "Votre ID client imgur.com. Requis pour que l'envoi d'images fonctionne." - imgur_client_secret: "Votre secret imgur.com. Pas nécessaire pour que l'envoi d'image fonctionne, mais pourrais le devenir." - imgur_endpoint: "point d'arrêt pour le chargement d'images sur imgur.com" max_image_width: "largeur maximale des images d'un message" category_featured_topics: "nombre de discussions affichées dans la liste par catégories" add_rel_nofollow_to_user_content: "Ajouter rel nofollow à tous les contenus des utilisateurs, sauf les liens internes (incluant les domaines parents) Modifier ceci requiert une mise à jour de tout votre markdown (rake posts:rebake)" diff --git a/config/locales/server.id.yml b/config/locales/server.id.yml index 36b829ef890..ad35c4ceeef 100644 --- a/config/locales/server.id.yml +++ b/config/locales/server.id.yml @@ -313,9 +313,6 @@ id: queue_jobs: "Queue various jobs in sidekiq, if false queues are inline" crawl_images: "Enable retrieving images from third party sources to insert width and height dimensions" ninja_edit_window: "Number of seconds after posting where edits do not create a new version" - enable_imgur: "Enable imgur api for uploading, don't host files locally" - imgur_api_key: "Your imgur.com api key, required for image upload to function" - imgur_endpoint: "End point for uploading imgur.com images" max_image_width: "Maximum allowed width of images in a post" category_featured_topics: "Number of topics displayed per category in the /categories page" add_rel_nofollow_to_user_content: "Add rel nofollow to all submitted user content, except for internal links (including parent domains) changing this requires you update all your baked markdown" diff --git a/config/locales/server.it.yml b/config/locales/server.it.yml index f5436335ce1..f03c6af8c3e 100644 --- a/config/locales/server.it.yml +++ b/config/locales/server.it.yml @@ -429,10 +429,6 @@ it: queue_jobs: "Metti in coda diversi job in sidekiq, se false le code sono inline" crawl_images: "Abilita la ricezione di immagini da sorgenti terze parti" ninja_edit_window: "Numero di secondi trascorsi affinché una modifica del post appena inviato, non venga considerata come nuova revisione" - enable_imgur: "Utilizza le api imgur per l'upload, non salvare file in locale" - imgur_client_id: "Your imgur.com client ID, required for image upload to function" - imgur_client_secret: "Your imgur.com client secret. Not currently required for image upload to function, but may be at some point." - imgur_endpoint: "End point per l'upload di immagini su img.ur" max_image_width: "Larghezza massima delle immagini in un post" category_featured_topics: "Numero di topic mostrati per categoira nella pagina /categories" add_rel_nofollow_to_user_content: "Aggiungi l'attributo rel nofollow a tutti i contenuti degli utenti, tranne per i link interni (compresi i domini di livello superiore). Modificare questa opzione comporta l'aggiornamento di tutto il contenuto markdown salvato" diff --git a/config/locales/server.nl.yml b/config/locales/server.nl.yml index c7d0c2e8215..f9e7e5deb0c 100644 --- a/config/locales/server.nl.yml +++ b/config/locales/server.nl.yml @@ -445,10 +445,6 @@ nl: queue_jobs: "Zet verschillende taken in een queue binnen sidekiq, bij 'false' worden taken ineens uitgevoerd" crawl_images: Zet het ophalen van afbeeldingen van externe bronnen aan ninja_edit_window: "Hoe snel je een aanpassing kan maken zonder dat er een nieuwe versie wordt opgeslagen, in seconden." - enable_imgur: "Gebruik de imgur API voor uploads en sla afbeeldingen niet lokaal op" - imgur_client_id: "Je imgur.com client ID, nodig om afbeeldingen te kunnen uploaden naar imgur" - imgur_client_secret: "Je imgur.com client secret. Is nog niet nodig voor het uploaden van afbeeldingen, maar dat zou in de toekomst kunnen veranderen." - imgur_endpoint: "End point voor het uploaden van imgur.com-afbeeldingen" max_image_width: Maximale breedte voor een afbeelding in een bericht category_featured_topics: Aantal topics dat wordt weergegeven in de categorielijst add_rel_nofollow_to_user_content: "Voeg 'rel nofollow' toe aan alle leden-content behalve voor interne links (inclusief parent domeinen). NB: Als je dit verandert, moet je ook alle 'baked markdown' updaten" diff --git a/config/locales/server.pseudo.yml b/config/locales/server.pseudo.yml index 950b8b092c8..7b9c989ad25 100644 --- a/config/locales/server.pseudo.yml +++ b/config/locales/server.pseudo.yml @@ -491,12 +491,6 @@ pseudo: ŵíďťĥ áɳď ĥéíǧĥť ďíɱéɳšíóɳš ]]' ninja_edit_window: '[[ Ѝůɱƀéř óƒ šéčóɳďš áƒťéř ƿóšťíɳǧ ŵĥéřé éďíťš ďó ɳóť čřéáťé á ɳéŵ νéřšíóɳ ]]' - enable_imgur: '[[ Éɳáƀłé íɱǧůř áƿí ƒóř ůƿłóáďíɳǧ, ďóɳ''ť ĥóšť ƒíłéš łóčáłłý ]]' - imgur_client_id: '[[ Ýóůř íɱǧůř.čóɱ čłíéɳť ÍĎ, řéƣůířéď ƒóř íɱáǧé ůƿłóáď ťó ƒůɳčťíóɳ - ]]' - imgur_client_secret: '[[ Ýóůř íɱǧůř.čóɱ čłíéɳť šéčřéť. Ѝóť čůřřéɳťłý řéƣůířéď - ƒóř íɱáǧé ůƿłóáď ťó ƒůɳčťíóɳ, ƀůť ɱáý ƀé áť šóɱé ƿóíɳť. ]]' - imgur_endpoint: '[[ Éɳď ƿóíɳť ƒóř ůƿłóáďíɳǧ íɱǧůř.čóɱ íɱáǧéš ]]' max_image_width: '[[ Ϻáхíɱůɱ áłłóŵéď ŵíďťĥ óƒ íɱáǧéš íɳ á ƿóšť ]]' category_featured_topics: '[[ Ѝůɱƀéř óƒ ťóƿíčš ďíšƿłáýéď ƿéř čáťéǧóřý íɳ ťĥé /čáťéǧóříéš ƿáǧé ]]' diff --git a/config/locales/server.pt.yml b/config/locales/server.pt.yml index 3f77f5002d0..2c2e353be8c 100644 --- a/config/locales/server.pt.yml +++ b/config/locales/server.pt.yml @@ -250,9 +250,6 @@ pt: queue_jobs: "'queue' vários 'jobs' no sidekiq, if false queues are inline" crawl_images: "permitir mostrar imagens de sites terceiros" ninja_edit_window: "quão rápido é possivél fazer uma alteração sem guardar uma nova versão, em segundos." - enable_imgur: "permitir imgur api para uploading, não guardar ficheiros localmente" - imgur_api_key: "chave para imgur.com api - necessária para image upload" - imgur_endpoint: "end point para uploading imgur.com images" max_image_width: "máxima largura para uma imagem num post" category_featured_topics: "numero de tópicos mostrados na lista de categorias" popup_delay: "Espaço de tempo em ms antes dos popus aparecer no ecrã" diff --git a/config/locales/server.sv.yml b/config/locales/server.sv.yml index a68031c42a3..79b28621200 100644 --- a/config/locales/server.sv.yml +++ b/config/locales/server.sv.yml @@ -352,9 +352,6 @@ sv: queue_jobs: "Köa diverse jobb i sidekiq, om urkryssat så körs köer infogat" crawl_images: "Aktivera hämtning av bilder från tredjepartskällor för att infoga bredd och höjd" ninja_edit_window: "Antal sekunder efter ett inlägg när en ändring inte skapar en ny version" - enable_imgur: "Aktivera imgur.coms API för uppladdning, sparar inte filer lokalt" - imgur_api_key: "Din API-nyckel för imgur.com, krävs för att bilduppladdningen ska funka" - imgur_endpoint: "Ändpunkt för uppladdning av bilder till imgur.com" max_image_width: "Maxbredd för bilder i ett inlägg" category_featured_topics: "Antal visade trådar per kategori på sidan /categories" add_rel_nofollow_to_user_content: "Lägg till rel nofollow på allt användargenererat innehåll, förutom interna länkar (inkluderat förälderdomäner) så kräver en ändring av detta att du uppdaterar all bakad markdown" diff --git a/config/locales/server.zh_CN.yml b/config/locales/server.zh_CN.yml index c72f7d4dda2..ad9f70410b1 100644 --- a/config/locales/server.zh_CN.yml +++ b/config/locales/server.zh_CN.yml @@ -443,10 +443,6 @@ zh_CN: queue_jobs: "如果失败队列在排队,使用 Sidekiq 消息引擎对不同的工作排队" crawl_images: "允许从第三方获取图片来插入宽、高数值" ninja_edit_window: "在多少秒钟之内,对帖子的多次编辑不生成新版本" - enable_imgur: "启用 Imgur API 来上传文件,不在本地(站点服务器)保存文件" - imgur_client_id: "你的imgur.com的客户端ID,以便图片上传能正常工作。" - imgur_client_secret: "你的imgur.com的客户端secret。 目前图片上传功能并不需要这项信息,但是将来的某天可能需要。" - imgur_endpoint: "上传图片到 imgur.com 的终点" max_image_width: "帖子中图片允许的最大宽度" category_featured_topics: "在分类 /categories 页面每个分类显示的主题数目" add_rel_nofollow_to_user_content: "添加 rel nofollow 标签到所有提交的用户信息(以防止搜索引擎搜集),除了内部链接(包括父域名)。修改此设置将要求你更新所有已有的 markdown 标签内容" diff --git a/config/locales/server.zh_TW.yml b/config/locales/server.zh_TW.yml index d2cce05e6fd..a2de07316db 100644 --- a/config/locales/server.zh_TW.yml +++ b/config/locales/server.zh_TW.yml @@ -429,10 +429,6 @@ zh_TW: queue_jobs: "如果失敗隊列在排隊,使用 Sidekiq 消息引擎對不同的工作排隊" crawl_images: "允許從第三方獲取圖片來插入寬、高數值" ninja_edit_window: "在多少秒鍾之內,對帖子的多次編輯不生成新版本" - enable_imgur: "啓用 Imgur API 來上傳文件,不在本地(站點服務器)保存文件" - imgur_client_id: "你的imgur.com的客戶端ID,以便圖片上傳能正常工作。" - imgur_client_secret: "你的imgur.com的客戶端secret。 目前圖片上傳功能並不需要這項信息,但是將來的某天可能需要。" - imgur_endpoint: "上傳圖片到 imgur.com 的終點" max_image_width: "帖子中圖片允許的最大寬度" category_featured_topics: "在分類 /categories 頁面每個分類顯示的主題數目" add_rel_nofollow_to_user_content: "添加 rel nofollow 標簽到所有提交的用戶信息(以防止搜索引擎搜集),除了內部鏈接(包括父域名)。修改此設置將要求你更新所有已有的 markdown 標簽內容" diff --git a/lib/cooked_post_processor.rb b/lib/cooked_post_processor.rb index 8391712900f..3c348a12870 100644 --- a/lib/cooked_post_processor.rb +++ b/lib/cooked_post_processor.rb @@ -93,7 +93,7 @@ class CookedPostProcessor # 7. Optimise images should be a seperate site setting. # supports only local uploads - return src if SiteSetting.enable_imgur? || SiteSetting.enable_s3_uploads? + return src if SiteSetting.enable_s3_uploads? width, height = img["width"].to_i, img["height"].to_i diff --git a/lib/imgur.rb b/lib/imgur.rb deleted file mode 100644 index 68dc91b6d30..00000000000 --- a/lib/imgur.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'rest_client' - -module Imgur - - def self.store_file(file, image_info, upload_id) - raise Discourse::SiteSettingMissing.new("imgur_endpoint") if SiteSetting.imgur_endpoint.blank? - raise Discourse::SiteSettingMissing.new("imgur_client_id") if SiteSetting.imgur_client_id.blank? - - @imgur_loaded = require 'imgur' unless @imgur_loaded - - blob = file.read - - response = RestClient.post( - SiteSetting.imgur_endpoint, - { image: Base64.encode64(blob) }, - { 'Authorization' => "Client-ID #{SiteSetting.imgur_client_id}" } - ) - - json = JSON.parse(response.body)['data'] rescue nil - - return nil if json.blank? - return json['link'] - end - -end diff --git a/spec/components/imgur_spec.rb b/spec/components/imgur_spec.rb deleted file mode 100644 index 0b8bada2cd8..00000000000 --- a/spec/components/imgur_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'spec_helper' -require 'imgur' - -describe Imgur do - - describe "store_file" do - - let(:file) { Rails.root.join('app', 'assets', 'images', 'logo.png') } - let(:image_info) { FastImage.new(file) } - let(:params) { [SiteSetting.imgur_endpoint, { image: Base64.encode64(file.read) }, { 'Authorization' => "Client-ID #{SiteSetting.imgur_client_id}" }] } - - before(:each) do - SiteSetting.stubs(:imgur_endpoint).returns("imgur_endpoint") - SiteSetting.stubs(:imgur_client_id).returns("imgur_client_id") - end - - it 'returns the url of the Imgur upload if successful' do - json = { - data: { - id: 'fake', - link: 'http://imgur.com/fake.png', - deletehash: 'a3kaoad30' - }, - success: true, - status: 200 - }.to_json - - response = mock - response.expects(:body).returns(json) - RestClient.expects(:post).with(*params).returns(response) - - Imgur.store_file(file, image_info, 1).should == 'http://imgur.com/fake.png' - end - - it 'returns nil if the request fails' do - json = { - success: false, - status: 400 - }.to_json - - response = mock - response.expects(:body).returns(json) - RestClient.expects(:post).with(*params).returns(response) - - Imgur.store_file(file, image_info, 1).should be_nil - end - - end - -end diff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rb index b91436323aa..2e53f69fdf4 100644 --- a/spec/models/upload_spec.rb +++ b/spec/models/upload_spec.rb @@ -37,16 +37,6 @@ describe Upload do end end - context "imgur" do - before(:each) do - SiteSetting.stubs(:enable_imgur?).returns(true) - Imgur.stubs(:store_file).returns(url) - end - - it_behaves_like "upload" - - end - context "s3" do before(:each) do SiteSetting.stubs(:enable_s3_uploads?).returns(true)