mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
removed imgur support
This commit is contained in:
parent
82b5f57e40
commit
8a2d635e62
20 changed files with 1 additions and 144 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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ů"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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."
|
||||
|
|
|
@ -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 (<code>rake posts:rebake</code>)"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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 (<code>rake posts:rebake</code>)"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -491,12 +491,6 @@ pseudo:
|
|||
ŵíďťĥ áɳď ĥéíǧĥť ďíɱéɳšíóɳš ]]'
|
||||
ninja_edit_window: '[[ Ѝůɱƀéř óƒ šéčóɳďš áƒťéř ƿóšťíɳǧ ŵĥéřé éďíťš ďó ɳóť čřéáťé
|
||||
á ɳéŵ νéřšíóɳ ]]'
|
||||
enable_imgur: '[[ Éɳáƀłé íɱǧůř áƿí ƒóř ůƿłóáďíɳǧ, ďóɳ''ť ĥóšť ƒíłéš łóčáłłý ]]'
|
||||
imgur_client_id: '[[ Ýóůř íɱǧůř.čóɱ čłíéɳť ÍĎ, řéƣůířéď ƒóř íɱáǧé ůƿłóáď ťó ƒůɳčťíóɳ
|
||||
]]'
|
||||
imgur_client_secret: '[[ Ýóůř íɱǧůř.čóɱ čłíéɳť šéčřéť. Ѝóť čůřřéɳťłý řéƣůířéď
|
||||
ƒóř íɱáǧé ůƿłóáď ťó ƒůɳčťíóɳ, ƀůť ɱáý ƀé áť šóɱé ƿóíɳť. ]]'
|
||||
imgur_endpoint: '[[ Éɳď ƿóíɳť ƒóř ůƿłóáďíɳǧ íɱǧůř.čóɱ íɱáǧéš ]]'
|
||||
max_image_width: '[[ Ϻáхíɱůɱ áłłóŵéď ŵíďťĥ óƒ íɱáǧéš íɳ á ƿóšť ]]'
|
||||
category_featured_topics: '[[ Ѝůɱƀéř óƒ ťóƿíčš ďíšƿłáýéď ƿéř čáťéǧóřý íɳ ťĥé /čáťéǧóříéš
|
||||
ƿáǧé ]]'
|
||||
|
|
|
@ -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ã"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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 标签内容"
|
||||
|
|
|
@ -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 標簽內容"
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
25
lib/imgur.rb
25
lib/imgur.rb
|
@ -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
|
|
@ -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
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue