Commit graph

56 commits

Author SHA1 Message Date
Pavel Djundik 0ac3ba28e1 Web Push Notifications 2017-08-22 10:54:18 +03:00
Pavel Djundik 66ea26f4bd Resolve relative URIs in link previewer
Also adds support for image_src links
2017-08-13 13:06:01 +03:00
Jérémie Astori 157289258a
Keep track of preview visibility on the server so it persists at page reload 2017-07-26 18:16:50 -04:00
Jérémie Astori 900d41bf47
Re-use .previews to order incoming previews instead of extra links 2017-07-21 01:51:51 -04:00
Jérémie Astori a13c08a45b
Enforce correct order for previews on server-side prefectch rather than at client parsing
This has the benefit of not adding `.preview` divs everywhere, anytime we use `parse()`, and also to un-tie the position of the preview blocks from the result of the helper. This means that templates that call `parse` and have some extra markup after that are not constrained anymore.

This is effectively an alternative, better way to fix https://github.com/thelounge/lounge/issues/1343, but the initial fix that was put in place (https://github.com/thelounge/lounge/pull/1347) is still relevant, for example to make sure a preview stays hidden (and does not add extra margin/padding/etc.) if the link does not prefetch.
2017-07-21 01:06:42 -04:00
Pavel Djundik f35a2809a7 Store preview images on disk for privacy, security and caching 2017-07-18 11:37:16 +03:00
Jérémie Astori 64ebe0f437
Support multiple previews per message
- Load up to 5 previews per message (to avoid abuse)
- Do not load multiple times the same URL
- Prepare preview containers per message instead of appending (to maintain correct order)
- Store an array of previews instead of a single preview in `Msg` objects
- Consolidate preview rendering for new messages and upon refresh/load history (when rendering entire channels)
- Update `parse` tests to reflect previous point
- Add test for multiple URLs
- Switch preview tests from `assert` API to `expect` API
2017-07-08 04:34:12 -04:00
Pavel Djundik 14b2ad7938 Refactor link previews 2017-07-03 00:41:18 +03:00
Jérémie Astori ad10777684 Merge pull request #1274 from thelounge/xpaw/increase-prefetch-limit
Increase max downloaded bytes for link preview
2017-06-26 02:44:46 -04:00
Pavel Djundik e967759802 Increase max downloaded bytes for link preview
twitter.com sends opengraph meta tags within ~20kb of data for individual tweets
2017-06-26 09:34:56 +03:00
Pavel Djundik 77667e7a3f Do not display preview if there is nothing to preview 2017-06-26 09:27:51 +03:00
Jérémie Astori 5abc4c8c2a Merge pull request #1256 from thelounge/xPaw/og-title
Check og:title before title tag
2017-06-26 01:48:07 -04:00
Jérémie Astori 147a36adde Merge pull request #1254 from thelounge/xpaw/thumb-is-img
Make sure thumbnail is a valid image
2017-06-26 01:46:20 -04:00
Jérémie Astori 0239fdd2fb Merge pull request #1255 from thelounge/xPaw/og-description
Check og:description before description
2017-06-26 01:44:54 -04:00
Pavel Djundik ddc076e894 Check status code in link prefetcher
Fixes #1258.
2017-06-23 20:49:45 +03:00
Pavel Djundik 015a9fb6ef Check og:title before title tag 2017-06-22 22:41:05 +03:00
Pavel Djundik 23c7f7296c Check og:description before description 2017-06-22 22:34:17 +03:00
Pavel Djundik 3fd2849a37 Make sure thumbnail is a valid image
Fixes #1239.
Fixes #1180.
2017-06-22 22:32:13 +03:00
Niko Bews 57fd0562a2 Handle images with unknown size in prefetch 2017-06-21 14:40:51 +03:00
Pavel Djundik f6dd616d5e Update to eslint 4 and enforce extra rules 2017-06-19 09:58:29 +03:00
Pavel Djundik 62d4cd8fe8 Use correct channel when pushing link prefetch messages
Fixes #781
2016-12-09 23:00:33 +02:00
stepie22 aa8e0ae2c2 Set the (correct) time on link expands 2016-11-25 21:27:19 +02:00
Jérémie Astori 089c315a8e Use forEach instead of lodash's each, and ES6 fat arrows like it's 2015 2016-10-15 15:58:48 -04:00
Pavel Djundik aa02fd5180 Enforce more eslint rules 2016-10-09 17:55:37 -04:00
Jérémie Astori caa46042bf Enforce strict mode across all JS files with ESLint
Several ES6 additions are only available in strict mode. Example:
> SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

Strict mode was also enabled in a few of our files already, and it is a good thing to have anyway.
2016-10-09 15:14:02 -04:00
Jérémie Astori b1674f4f20 Add self info to TOGGLE messages to prevent unread marker to render for oneself 2016-07-07 02:53:30 -04:00
Pavel Djundik 100262ad1f Cache loaded config and merge it with defaults
Fixes #249
2016-06-26 19:30:25 +03:00
Pavel Djundik e75a8f40a6 Stricter eslint rule for curly brackets 2016-05-01 12:41:17 +03:00
Pavel Djundik 6dc807ef07 Create a single helper function to write messages 2016-04-19 13:20:18 +03:00
Pavel Djundik 3fc7036d32 Don't reset time in link expander and hide time with css 2016-04-07 16:07:40 -04:00
Pavel Djundik e0fb454223 Search channel case insensitively 2016-04-07 16:07:37 -04:00
Pavel Djundik 82e192cd2c Enable link fetcher 2016-04-07 16:04:40 -04:00
Pavel Djundik da425fefaf Start working on moving to irc-framework 2016-04-07 16:04:28 -04:00
Pavel Djundik 93d7b16cd4 Harden url fetcher and don't crash on non-ASCII urls 2016-03-27 12:50:53 +03:00
Pavel Djundik 19bc4f37e0 Update lodash 2016-02-19 15:13:53 +02:00
Jérémie Astori 39dc4e8957 Update name and link to repo to new project 2016-02-10 06:20:05 +00:00
Pavel Djundik 12d798f0e2 Send useragent with link expander requests 2016-01-24 17:01:11 +02:00
Olivier Lambert e5858744a2 Limit preview for large image files (fix #500) 2015-11-09 10:07:47 +01:00
William Boman 8fdfd70c7e Comply with ESLint 2015-10-26 03:01:47 +01:00
Jocelyn Delande 58aa236dcd Revert "Ignore localhost links" (on prefetch)
This reverts commit 29b66ff0ec.

Rationale:

1) It's not a security feature (abuse of prefetch can be on any server it's not
   more/less risky on localhost), it's pseudo-security measure
2) It's not to us to judge if it has no use-case (in fact it has, ex: two dev
   speaking and experimenting about urls of their local site/app instance,
   local web apps...)

refs #388
2015-09-29 22:22:45 +02:00
Mattias Erming 2cee0ea6ef Increase process.setMaxListeners 2015-04-29 12:55:34 -07:00
Mattias Erming 29b66ff0ec Ignore localhost links 2015-04-06 10:40:12 -07:00
Mattias Erming e54feda878 Fix crash on broken links 2015-01-03 18:58:12 -08:00
Jon Nettleton 13717bd4f7 Catch undefined content-type headers
If content-type is undefined then catch the exception and set it
to empty just as is done for the body.
2015-01-03 10:03:43 +01:00
Cyrus 36d861fd79 handles errors, increase limit 2014-12-23 09:06:11 +08:00
Cyrus db6c6aaffc unconsole.log 2014-12-22 08:57:29 +08:00
Cyrus bd191c09e5 conserve bandwidth
include application/json

should be using hyperquest

appplication typo

adapt res

res.text

remove superagent dependency
2014-12-22 08:29:26 +08:00
Mattias Erming 67f6e526f2 Fetch max 1 link per message 2014-12-12 00:48:43 +01:00
Mattias Erming fea9fb7a85 Fix indentation 2014-10-14 20:51:27 +02:00
XeonCore 76f3646249 Restore old No description found message
When there is no meta tags, keep the old No Description found message
2014-10-12 12:53:01 +11:00