mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-17 19:12:37 -05:00
provide a way to give a default filename to pasted images in the lightbox overlay
This commit is contained in:
parent
a0031f2a0d
commit
72745d257d
17 changed files with 51 additions and 4 deletions
|
@ -1045,6 +1045,7 @@ cs:
|
|||
deleted: 'smazáno'
|
||||
|
||||
upload:
|
||||
pasted_image_filename: ""
|
||||
image:
|
||||
fetch_failure: "Bohužel, nastala chybí při získávání obrázku."
|
||||
unknown_image_type: "Bohužel, soubor, který se snažíte nahrát, zřejmě není obrázek."
|
||||
|
|
|
@ -783,3 +783,6 @@ da:
|
|||
see_more: "Se mere"
|
||||
search_title: "Søg efter dette emne"
|
||||
search_google: "Søg Google"
|
||||
|
||||
upload:
|
||||
pasted_image_filename: ""
|
||||
|
|
|
@ -1005,6 +1005,7 @@ de:
|
|||
deleted: 'gelöscht'
|
||||
|
||||
upload:
|
||||
pasted_image_filename: ""
|
||||
image:
|
||||
fetch_failure: "Entschuldige, beim Laden des Bildes ist ein Fehler aufgetreten."
|
||||
unknown_image_type: "Entschuldige, aber die Datei die Du hochladen möchtest schein kein Bild zu sein."
|
||||
|
|
|
@ -1039,6 +1039,7 @@ en:
|
|||
deleted: 'deleted'
|
||||
|
||||
upload:
|
||||
pasted_image_filename: "Pasted image"
|
||||
image:
|
||||
fetch_failure: "Sorry, there has been an error while fetching the image."
|
||||
unknown_image_type: "Sorry, but the file you tried to upload doesn't appear to be an image."
|
||||
|
|
|
@ -763,3 +763,6 @@ es:
|
|||
see_more: "Ver Más"
|
||||
search_title: "Buscar por este tema"
|
||||
search_google: "Buscar en Google"
|
||||
|
||||
upload:
|
||||
pasted_image_filename: ""
|
||||
|
|
|
@ -944,6 +944,7 @@ fr:
|
|||
deleted: 'supprimmé'
|
||||
|
||||
upload:
|
||||
pasted_image_filename: "Image collée"
|
||||
image:
|
||||
fetch_failure: "Désolé, une erreur s'est produite lorsque nous avons essayé de récupérer l'image."
|
||||
unknown_image_type: "Désolé, mais le fichier que vous essayez d'envoyer ne semble pas être une image."
|
||||
|
|
|
@ -780,3 +780,6 @@ id:
|
|||
see_more: "See More"
|
||||
search_title: "Search for this topic"
|
||||
search_google: "Search Google"
|
||||
|
||||
upload:
|
||||
pasted_image_filename: ""
|
||||
|
|
|
@ -918,6 +918,7 @@ it:
|
|||
deleted: 'cancellato'
|
||||
|
||||
upload:
|
||||
pasted_image_filename: ""
|
||||
image:
|
||||
fetch_failure: "Spiacente, si è verificato un errore nel recupero dell'immagine."
|
||||
unknown_image_type: "Spiacente, ma il file che hai provato a caricare non sembra un'immagine."
|
||||
|
|
|
@ -970,6 +970,7 @@ nl:
|
|||
deleted: 'verwijderd'
|
||||
|
||||
upload:
|
||||
pasted_image_filename: ""
|
||||
image:
|
||||
fetch_failure: "Er ging iets mis bij het opvragen van de afbeelding."
|
||||
unknown_image_type: "Het bestand dat je wil uploaden is geen afbeelding."
|
||||
|
|
|
@ -1075,6 +1075,7 @@ pseudo:
|
|||
áɳď ƿéřɱíťťéď áššíǧɳš. ]]'
|
||||
deleted: '[[ ďéłéťéď ]]'
|
||||
upload:
|
||||
pasted_image_filename: ""
|
||||
image:
|
||||
fetch_failure: '[[ Šóřřý, ťĥéřé ĥáš ƀééɳ áɳ éřřóř ŵĥíłé ƒéťčĥíɳǧ ťĥé íɱáǧé.
|
||||
]]'
|
||||
|
|
|
@ -682,3 +682,6 @@ pt:
|
|||
|
||||
discourse_hub:
|
||||
access_token_problem: "Conta a um admin: Por-favor atualiza as configurações do site para incluir o discourse_org_access_key correto."
|
||||
|
||||
upload:
|
||||
pasted_image_filename: ""
|
||||
|
|
|
@ -1023,6 +1023,7 @@ ru:
|
|||
miscellaneous: 'This Agreement constitutes the entire agreement between %{company_short_name} and you concerning the subject matter hereof, and they may only be modified by a written amendment signed by an authorized executive of %{company_short_name}, or by the posting by %{company_short_name} of a revised version. Except to the extent applicable law, if any, provides otherwise, this Agreement, any access to or use of the Website will be governed by the laws of the state of California, U.S.A., excluding its conflict of law provisions, and the proper venue for any disputes arising out of or relating to any of the same will be the state and federal courts located in San Francisco County, California. Except for claims for injunctive or equitable relief or claims regarding intellectual property rights (which may be brought in any competent court without the posting of a bond), any dispute arising under this Agreement shall be finally settled in accordance with the Comprehensive Arbitration Rules of the Judicial Arbitration and Mediation Service, Inc. (“JAMS”) by three arbitrators appointed in accordance with such Rules. The arbitration shall take place in San Francisco, California, in the English language and the arbitral decision may be enforced in any court. The prevailing party in any action or proceeding to enforce this Agreement shall be entitled to costs and attorneys’ fees. If any part of this Agreement is held invalid or unenforceable, that part will be construed to reflect the parties’ original intent, and the remaining portions will remain in full force and effect. A waiver by either party of any term or condition of this Agreement or any breach thereof, in any one instance, will not waive such term or condition or any subsequent breach thereof. You may assign your rights under this Agreement to any party that consents to, and agrees to be bound by, its terms and conditions; %{company_short_name} may assign its rights under this Agreement without condition. This Agreement will be binding upon and will inure to the benefit of the parties, their successors and permitted assigns.'
|
||||
deleted: удалено
|
||||
upload:
|
||||
pasted_image_filename: ""
|
||||
image:
|
||||
fetch_failure: Извините, во время извлечения изображения произошла ошибка.
|
||||
unknown_image_type: Файл, который вы загружаете, не является изображением.
|
||||
|
|
|
@ -838,3 +838,6 @@ sv:
|
|||
see_more: "See More"
|
||||
search_title: "Search for this topic"
|
||||
search_google: "Search Google"
|
||||
|
||||
upload:
|
||||
pasted_image_filename: ""
|
||||
|
|
|
@ -932,6 +932,7 @@ zh_CN:
|
|||
deleted: '已删除'
|
||||
|
||||
upload:
|
||||
pasted_image_filename: ""
|
||||
image:
|
||||
fetch_failure: "抱歉,获取图片時发生错误。"
|
||||
unknown_image_type: "抱歉,你上传的文件似乎不是一张图片。"
|
||||
|
|
|
@ -918,6 +918,7 @@ zh_TW:
|
|||
deleted: '已刪除'
|
||||
|
||||
upload:
|
||||
pasted_image_filename: ""
|
||||
image:
|
||||
fetch_failure: "抱歉,獲取圖片時發生錯誤。"
|
||||
unknown_image_type: "抱歉,你上傳的文件似乎不是一張圖片。"
|
||||
|
|
|
@ -141,19 +141,23 @@ class CookedPostProcessor
|
|||
meta["class"] = "meta"
|
||||
img.add_next_sibling meta
|
||||
|
||||
filename = upload ? upload.original_filename : File.basename(src)
|
||||
filename = get_filename(upload, src)
|
||||
informations = "#{original_width}x#{original_height}"
|
||||
informations << " | #{number_to_human_size(upload.filesize)}" if upload
|
||||
|
||||
meta.add_child create_span_node("filename", filename)
|
||||
meta.add_child create_span_node("informations", informations)
|
||||
meta.add_child create_span_node("expand")
|
||||
# TODO: download
|
||||
# TODO: views-count
|
||||
|
||||
@dirty = true
|
||||
end
|
||||
|
||||
def get_filename(upload, src)
|
||||
return File.basename(src) unless upload
|
||||
return upload.original_filename unless upload.original_filename == "blob"
|
||||
return I18n.t('upload.pasted_image_filename')
|
||||
end
|
||||
|
||||
def create_span_node(klass, content=nil)
|
||||
span = Nokogiri::XML::Node.new "span", @doc
|
||||
span.content = content if content
|
||||
|
|
|
@ -218,4 +218,22 @@ describe CookedPostProcessor do
|
|||
|
||||
end
|
||||
|
||||
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" })
|
||||
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" })
|
||||
cpp.get_filename(upload, "http://domain.com/image.png").should == I18n.t('upload.pasted_image_filename')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue