From 92ac7893d3896ad0dd3075464b46c1af2324f2ac Mon Sep 17 00:00:00 2001 From: Mayhem Date: Fri, 4 Apr 2014 23:33:01 +0200 Subject: [PATCH 1/3] Update deps. --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index e74731b7c..04ec95b96 100644 --- a/package.json +++ b/package.json @@ -22,15 +22,15 @@ }, "devDependencies": { "font-awesome": "~4.0.3", - "grunt": "~0.4.2", + "grunt": "~0.4.4", "grunt-bump": "~0.0.13", "grunt-concurrent": "~0.5.0", "grunt-contrib-clean": "~0.5.0", - "grunt-contrib-coffee": "~0.10.0", + "grunt-contrib-coffee": "~0.10.1", "grunt-contrib-compress": "~0.7.0", - "grunt-contrib-concat": "~0.3.0", + "grunt-contrib-concat": "~0.4.0", "grunt-contrib-copy": "~0.5.0", - "grunt-contrib-watch": "~0.6.0", + "grunt-contrib-watch": "~0.6.1", "grunt-shell": "~0.6.4", "load-grunt-tasks": "~0.4.0" }, From 0bc93400c178c97c1a1c8aac6e0e65ac08de6797 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sat, 5 Apr 2014 00:32:44 +0200 Subject: [PATCH 2/3] .webm #1533 --- CHANGELOG.md | 2 ++ src/Filtering/Filter.coffee | 3 ++- src/General/Build.coffee | 5 +++-- src/General/Post.coffee | 6 ++++-- src/General/Settings.coffee | 1 + src/Images/AutoGIF.coffee | 1 - src/Images/ImageExpand.coffee | 27 ++++++++++++++++++--------- src/Images/ImageHover.coffee | 19 +++++++++++++------ src/Miscellaneous/FileInfo.coffee | 2 +- src/Posting/QR.coffee | 17 ++++------------- 10 files changed, 48 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 898c937b1..637e6eccb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +- Add support for .webm files. + ### 3.19.5 - *2014-04-03* - Fix captcha submission:
diff --git a/src/Filtering/Filter.coffee b/src/Filtering/Filter.coffee index 12dcde4ed..dd3cdbad9 100644 --- a/src/Filtering/Filter.coffee +++ b/src/Filtering/Filter.coffee @@ -146,7 +146,8 @@ Filter = return post.file.name false dimensions: (post) -> - if post.file and post.file.isImage + {file} = post + if file and (file.isImage or file.isVideo) return post.file.dimensions false filesize: (post) -> diff --git a/src/General/Build.coffee b/src/General/Build.coffee index e1bfa9bae..decdc8465 100644 --- a/src/General/Build.coffee +++ b/src/General/Build.coffee @@ -7,8 +7,9 @@ Build = # OPs have a +10 characters threshold. # The file extension is not taken into account. threshold = if isReply then 30 else 40 - if filename.length - 4 > threshold - "#{filename[...threshold - 5]}(...).#{filename[-3..]}" + ext = filename.match(/\.[^.]+$/)[0] + if filename.length - ext.length > threshold + "#{filename[...threshold - 5]}(...)#{ext}" else filename thumbRotate: do -> diff --git a/src/General/Post.coffee b/src/General/Post.coffee index f2db77261..8556d3fe6 100644 --- a/src/General/Post.coffee +++ b/src/General/Post.coffee @@ -113,7 +113,7 @@ class Post parseFile: (that) -> return unless (fileEl = $ '.file', @nodes.post) and thumb = $ 'img[data-md5]', fileEl - # Supports JPG/PNG/GIF/PDF. + # Supports JPG/PNG/GIF/WEBM/PDF. # Flash files are not supported. anchor = thumb.parentNode fileText = fileEl.firstElementChild @@ -144,7 +144,9 @@ class Post # http://www.whatwg.org/specs/web-apps/current-work/#multipart-form-data @file.name = @file.name.replace /%22/g, '"' <% } %> - if @file.isImage = /(jpg|png|gif)$/i.test @file.name + @file.isImage = /(jpg|png|gif)$/i.test @file.name + @file.isVideo = /webm$/i.test @file.name + if @file.isImage or @file.isVideo @file.dimensions = fileText.textContent.match(/\d+x\d+/)[0] cleanup: (root, post) -> diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index 3c934d32b..b6e614267 100644 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -304,6 +304,7 @@ Settings = sizeInBytes: 276 * 1024 dimensions: '1280x720' isImage: true + isVideo: false isSpoiler: true funk = FileInfo.createFunc @value @nextElementSibling.innerHTML = funk FileInfo, data diff --git a/src/Images/AutoGIF.coffee b/src/Images/AutoGIF.coffee index c47a388bb..70acc351c 100644 --- a/src/Images/AutoGIF.coffee +++ b/src/Images/AutoGIF.coffee @@ -32,4 +32,3 @@ AutoGIF = else thumb.src = URL gif.src = URL - diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index 213543a0e..ccc23709a 100644 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -13,7 +13,7 @@ ImageExpand = name: 'Image Expansion' cb: @node node: -> - return unless @file?.isImage + return unless @file and (@file.isImage or @file.isVideo) {thumb} = @file $.on thumb.parentNode, 'click', ImageExpand.cb.toggle if @isClone and $.hasClass thumb, 'expanding' @@ -42,7 +42,7 @@ ImageExpand = for ID, post of g.posts for post in [post].concat post.clones {file} = post - continue unless file and file.isImage and doc.contains post.nodes.root + continue unless file and (file.isImage or file.isVideo) and doc.contains post.nodes.root if ImageExpand.on and !post.isHidden and (!Conf['Expand spoilers'] and file.isSpoiler or Conf['Expand from here'] and Header.getTopOf(file.thumb) < 0) @@ -72,6 +72,7 @@ ImageExpand = $.rmClass post.nodes.root, 'expanded-image' $.rmClass post.file.thumb, 'expanding' post.file.isExpanded = false + post.file.fullImage.pause() if post.file.isVideo expand: (post, src) -> # Do not expand images of hidden/filtered replies, or already expanded pictures. @@ -80,21 +81,29 @@ ImageExpand = $.addClass thumb, 'expanding' if post.file.fullImage # Expand already-loaded/ing picture. - $.asap (-> post.file.fullImage.naturalHeight), -> + $.asap (-> post.file.isVideo or post.file.fullImage.naturalHeight), -> ImageExpand.completeExpand post return - post.file.fullImage = img = $.el 'img', - className: 'full-image' - src: src or post.file.URL - $.on img, 'error', ImageExpand.error - $.asap (-> post.file.fullImage.naturalHeight), -> + file = if post.file.isImage + $.el 'img', + className: 'full-image' + src: src or post.file.URL + else + $.el 'video', + className: 'full-image' + src: src or post.file.URL + loop: true + post.file.fullImage = file + $.on file, 'error', ImageExpand.error + $.asap (-> post.file.isVideo or post.file.fullImage.naturalHeight), -> ImageExpand.completeExpand post - $.after thumb, img + $.after thumb, file completeExpand: (post) -> {thumb} = post.file return unless $.hasClass thumb, 'expanding' # contracted before the image loaded post.file.isExpanded = true + post.file.fullImage.play() if post.file.isVideo unless post.nodes.root.parentNode # Image might start/finish loading before the post is inserted. # Don't scroll when it's expanded in a QP for example. diff --git a/src/Images/ImageHover.coffee b/src/Images/ImageHover.coffee index 97e44971a..cdf35b575 100644 --- a/src/Images/ImageHover.coffee +++ b/src/Images/ImageHover.coffee @@ -9,19 +9,26 @@ ImageHover = name: 'Image Hover' cb: @catalogNode node: -> - return unless @file?.isImage + return unless @file and (@file.isImage or @file.isVideo) $.on @file.thumb, 'mouseover', ImageHover.mouseover catalogNode: -> - return unless @thread.OP.file?.isImage + return unless @thread.OP.file and (@thread.OP.file.isImage @thread.OP.file.isVideo) $.on @nodes.thumb, 'mouseover', ImageHover.mouseover mouseover: (e) -> post = if $.hasClass @, 'thumb' g.posts[@parentNode.dataset.fullID] else Get.postFromNode @ - el = $.el 'img', - id: 'ihover' - src: post.file.URL + el = if post.file.isImage + $.el 'img', + id: 'ihover' + src: post.file.URL + else + $.el 'video', + id: 'ihover' + src: post.file.URL + autoplay: true + loop: true el.dataset.fullID = post.fullID $.add d.body, el UI.hover @@ -29,7 +36,7 @@ ImageHover = el: el latestEvent: e endEvents: 'mouseout click' - asapTest: -> el.naturalHeight + asapTest: -> post.file.isVideo or el.naturalHeight $.on el, 'error', ImageHover.error error: -> return unless doc.contains @ diff --git a/src/Miscellaneous/FileInfo.coffee b/src/Miscellaneous/FileInfo.coffee index 0534b2c33..c94bb41bd 100644 --- a/src/Miscellaneous/FileInfo.coffee +++ b/src/Miscellaneous/FileInfo.coffee @@ -47,4 +47,4 @@ FileInfo = B: -> FileInfo.convertUnit @file.sizeInBytes, 'B' K: -> FileInfo.convertUnit @file.sizeInBytes, 'KB' M: -> FileInfo.convertUnit @file.sizeInBytes, 'MB' - r: -> if @file.isImage then @file.dimensions else 'PDF' + r: -> @file.dimensions or 'PDF' diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 0d4a9673d..f6e440268 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -1,6 +1,4 @@ QR = - # Add empty mimeType to avoid errors with URLs selected in Window's file dialog. - mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/x-shockwave-flash', ''] init: -> return if !Conf['Quick Reply'] @@ -258,21 +256,14 @@ QR = if file.size > max QR.error "#{file.name}: File too large (file: #{$.bytesToString file.size}, max: #{$.bytesToString max})." return - unless file.type in QR.mimeTypes - unless /^text/.test file.type - QR.error "#{file.name}: Unsupported file type." - return - if isSingle - post = QR.selected - else if (post = QR.posts[QR.posts.length - 1]).com - post = new QR.post() - post.pasteText file - return if isSingle post = QR.selected else if (post = QR.posts[QR.posts.length - 1]).file post = new QR.post() - post.setFile file + if /^text/.test file.type + post.pasteText file + else + post.setFile file openFileInput: -> QR.nodes.fileInput.click() From f04f411018163e1ce16e08b52de050235374ea19 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sat, 5 Apr 2014 00:35:50 +0200 Subject: [PATCH 3/3] Release 4chan X v3.20.0. --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 637e6eccb..d48ede46b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## 3.20.0 - *2014-04-05* + - Add support for .webm files. ### 3.19.5 - *2014-04-03* diff --git a/package.json b/package.json index 04ec95b96..5e94d7500 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "4chan-X", - "version": "3.19.5", + "version": "3.20.0", "description": "Cross-browser extension for productive lurking on 4chan.", "meta": { "name": "4chan X",