Merge branch 'master' into master

This commit is contained in:
Fasih Ahmad Fakhri 2020-12-16 11:29:23 +05:30 committed by GitHub
commit 026361fd8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 86 additions and 45 deletions

View file

@ -5,13 +5,16 @@
#### Snapdrop is built with the following awesome technologies: #### Snapdrop is built with the following awesome technologies:
* Vanilla HTML5 / ES6 / CSS3 * Vanilla HTML5 / ES6 / CSS3
* Progressive Web App * [Progressive Web App](https://de.wikipedia.org/wiki/Progressive_Web_App)
* [WebRTC](http://webrtc.org/) * [WebRTC](http://webrtc.org/)
* [WebSockets](http://www.websocket.org/) * [WebSockets](http://www.websocket.org/)
* [NodeJS](https://nodejs.org/en/) * [NodeJS](https://nodejs.org/en/)
* [Material Design](https://material.google.com/)
> If you want to self-host your own instance, [you can with docker.](/docs/local-dev.md)
> Have any questions? You can read our [FAQ](/docs/faq.md).
> If you want to self-host your own instance, [you can with docker](/docs/local-dev.md).
## Support the Snapdrop Community ## Support the Snapdrop Community
Snapdrop is free. Still, we have to pay for the server. If you want to contribute, please use PayPal: Snapdrop is free. Still, we have to pay for the server. If you want to contribute, please use PayPal:
@ -27,15 +30,4 @@ Alternatively, you can become a [Github Sponsor](https://github.com/sponsors/Rob
Thanks a lot for supporting free and open software! Thanks a lot for supporting free and open software!
> Have any questions? You can read our [FAQ](/docs/faq.md)
## Apps
1. [Snapdrop PWA](/docs/faq.md) <!-- Don't know how to do a direct link -->
1. [Snapdrop Desktop App](https://github.com/infin1tyy/snapdrop-desktop) built on top of Electron. (Thanks to [Infin1tyy!](https://github.com/infin1tyy/)).
1. Feel free to make one :)

View file

@ -59,16 +59,16 @@
<!-- Peers --> <!-- Peers -->
<x-peers class="center"></x-peers> <x-peers class="center"></x-peers>
<x-no-peers> <x-no-peers>
<h2>Open Snapdrop on other devices to send files.</h2> <h2>Open Snapdrop on other devices to send files</h2>
</x-no-peers> </x-no-peers>
<x-instructions desktop="Click to send files or right click to send a message." mobile="Tap to send files or long tap to send a message."></x-instructions> <x-instructions desktop="Click to send files or right click to send a message" mobile="Tap to send files or long tap to send a message"></x-instructions>
<!-- Footer --> <!-- Footer -->
<footer class="column"> <footer class="column">
<svg class="icon logo"> <svg class="icon logo">
<use xlink:href="#wifi-tethering" /> <use xlink:href="#wifi-tethering" />
</svg> </svg>
<div id="displayName">The easiest way to transfer data across devices.</div> <div id="displayName" placeholder="The easiest way to transfer data across devices"></div>
<div class="font-body2">Allow me to be discovered by: Everyone in this network.</div> <div class="font-body2">You can be discovered by everyone on this network</div>
</footer> </footer>
<!-- Receive Dialog --> <!-- Receive Dialog -->
<x-dialog id="receiveDialog"> <x-dialog id="receiveDialog">
@ -90,7 +90,7 @@
<x-background class="full center"> <x-background class="full center">
<x-paper shadow="2"> <x-paper shadow="2">
<h3>Send a Message</h3> <h3>Send a Message</h3>
<input id="textInput" placeholder="Send a message" autocomplete="off" autofocus> <textarea id="textInput" placeholder="Send a message" autocomplete="off" autofocus></textarea>
<div class="row-reverse"> <div class="row-reverse">
<button class="button" type="submit" close>Send</button> <button class="button" type="submit" close>Send</button>
<a class="button" close>Cancel</a> <a class="button" close>Cancel</a>
@ -130,7 +130,7 @@
<use xlink:href="#wifi-tethering" /> <use xlink:href="#wifi-tethering" />
</svg> </svg>
<h1>Snapdrop</h1> <h1>Snapdrop</h1>
<div class="font-subheading">The easiest way to transfer files across devices.</div> <div class="font-subheading">The easiest way to transfer files across devices</div>
<div class="row"> <div class="row">
<a class="icon-button" target="_blank" href="https://github.com/RobinLinus/snapdrop" title="Snapdrop on Github" rel="noreferrer"> <a class="icon-button" target="_blank" href="https://github.com/RobinLinus/snapdrop" title="Snapdrop on Github" rel="noreferrer">
<svg class="icon"> <svg class="icon">
@ -147,7 +147,7 @@
<use xlink:href="#twitter" /> <use xlink:href="#twitter" />
</svg> </svg>
</a> </a>
<a class="icon-button" target="_blank" href="https://github.com/RobinLinus/snapdrop/docs/faq.md" title="Frequently asked questions" rel="noreferrer"> <a class="icon-button" target="_blank" href="https://github.com/RobinLinus/snapdrop/blob/master/docs/faq.md" title="Frequently asked questions" rel="noreferrer">
<svg class="icon"> <svg class="icon">
<use xlink:href="#help-outline" /> <use xlink:href="#help-outline" />
</svg> </svg>
@ -214,7 +214,7 @@
<noscript> <noscript>
<x-noscript class="full center column"> <x-noscript class="full center column">
<h1>Enable Javascript</h1> <h1>Enable Javascript</h1>
<h3>Snapdrop works only with Javascript.</h3> <h3>Snapdrop works only with Javascript</h3>
</x-noscript> </x-noscript>
<style> <style>
x-noscript { x-noscript {

View file

@ -41,8 +41,8 @@ class ServerConnection {
case 'ping': case 'ping':
this.send({ type: 'pong' }); this.send({ type: 'pong' });
break; break;
case 'displayName': case 'display-name':
Events.fire('displayName', msg); Events.fire('display-name', msg);
break; break;
default: default:
console.error('WS: unkown message type', msg); console.error('WS: unkown message type', msg);

View file

@ -6,8 +6,8 @@ window.isProductionEnvironment = !window.location.host.startsWith('localhost');
window.iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; window.iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
// set display name // set display name
Events.on('displayName', e => { Events.on('display-name', e => {
$("displayName").textContent = "You are known as " + e.detail.message; $('displayName').textContent = 'You are known as ' + e.detail.message;
}); });
class PeersUI { class PeersUI {
@ -70,7 +70,7 @@ class PeerUI {
html() { html() {
return ` return `
<label class="column center"> <label class="column center" title="Click to send files or right click to send a text">
<input type="file" multiple> <input type="file" multiple>
<x-icon shadow="1"> <x-icon shadow="1">
<svg class="icon"><use xlink:href="#"/></svg> <svg class="icon"><use xlink:href="#"/></svg>
@ -473,7 +473,9 @@ class WebShareTargetUI {
let shareTargetText = title ? title : ''; let shareTargetText = title ? title : '';
shareTargetText += text ? shareTargetText ? ' ' + text : text : ''; shareTargetText += text ? shareTargetText ? ' ' + text : text : '';
shareTargetText += url ? shareTargetText ? ' ' + url : url : '';
if(url) shareTargetText = url; // We share only the Link - no text. Because link-only text becomes clickable.
if (!shareTargetText) return; if (!shareTargetText) return;
window.shareTargetText = shareTargetText; window.shareTargetText = shareTargetText;
history.pushState({}, 'URL Rewrite', '/'); history.pushState({}, 'URL Rewrite', '/');

View file

@ -261,7 +261,7 @@ x-peer[transfer] x-icon {
} }
x-peer[transfer] .status:before { x-peer[transfer] .status:before {
content: 'Transfering...'; content: 'Transferring...';
} }
x-peer x-icon { x-peer x-icon {
@ -292,6 +292,7 @@ footer {
right: 0; right: 0;
align-items: center; align-items: center;
padding: 0 0 16px 0; padding: 0 0 16px 0;
text-align: center;
} }
footer .logo { footer .logo {
@ -365,9 +366,22 @@ x-dialog a{
-webkit-user-select: all; -webkit-user-select: all;
-moz-user-select: all; -moz-user-select: all;
user-select: all; user-select: all;
white-space: pre;
} }
#receiveTextDialog #text a {
cursor: pointer;
}
#receiveTextDialog #text a:hover {
text-decoration: underline;
}
#receiveTextDialog h3{
/* Select the received text when double-clicking the dialog */
user-select: none;
pointer-events: none;
}
/* Button */ /* Button */
@ -449,16 +463,19 @@ button::-moz-focus-inner {
/* Text Input */ /* Text Input */
input { input,
textarea {
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
border: none; border: none;
outline: none; outline: none;
padding: 16px 24px; padding: 16px 24px;
border-radius: 50px; border-radius: 16px;
margin: 8px 0; margin: 8px 0;
line-height: 16px; line-height: 16px;
font-size: 14px; font-size: 14px;
font-family: inherit;
resize: none;
} }
@ -549,6 +566,11 @@ input {
} }
/* Generic placeholder */
[placeholder]:empty:before {
content: attr(placeholder);
}
/* Toast */ /* Toast */
.toast-container { .toast-container {
@ -590,6 +612,7 @@ x-instructions {
opacity: 0.5; opacity: 0.5;
transition: opacity 300ms; transition: opacity 300ms;
z-index: -1; z-index: -1;
text-align: center;
} }
x-instructions:before { x-instructions:before {

View file

@ -32,4 +32,17 @@ We are not trying to optimize for some edge-cases. We are optimizing the user fl
* Fix bugs and make a pull request. * Fix bugs and make a pull request.
* Do security analysis and suggestions * Do security analysis and suggestions
## Apps
1. [Snapdrop PWA](/docs/faq.md) <!-- Don't know how to do a direct link -->
1. [Snapdrop Desktop App](https://github.com/infin1tyy/snapdrop-desktop) built on top of Electron. (Thanks to [Infin1tyy!](https://github.com/infin1tyy/)).
1. [Snapdrop Android App](https://github.com/fm-sys/snapdrop-android) allows you to also send files directly from other apps via the share action.
1. Feel free to make one :)
[< Back](/README.md) [< Back](/README.md)

View file

@ -9,13 +9,16 @@ Then, clone the repository:
cd snapdrop cd snapdrop
docker-compose up -d docker-compose up -d
``` ```
To restart the containers run `docker-compose restart`.
To stop the containers run `docker-compose stop`.
Now point your browser to `http://localhost:8080`. Now point your browser to `http://localhost:8080`.
- To restart the containers run `docker-compose restart`.
- To stop the containers run `docker-compose stop`.
- To display the nodejs logs for debugging run `docker logs snapdrop_node_1`.
## Testing PWA related features ## Testing PWA related features
PWAs require that the app is served under a correctly set up and trusted TLS endpoint. PWAs require that the app is served under a correctly set up and trusted TLS endpoint.

View file

@ -1,5 +1,4 @@
const parser = require('ua-parser-js'); const parser = require('ua-parser-js');
const { uniqueNamesGenerator, animals, colors } = require('unique-names-generator');
class SnapdropServer { class SnapdropServer {
@ -20,7 +19,7 @@ class SnapdropServer {
this._keepAlive(peer); this._keepAlive(peer);
// send displayName // send displayName
this._send(peer, { type: 'displayName', message: peer.name.displayName }); this._send(peer, { type: 'display-name', message: peer.name.displayName });
} }
_onHeaders(headers, response) { _onHeaders(headers, response) {
@ -186,13 +185,22 @@ class Peer {
} }
_setName(req) { _setName(req) {
var ua = parser(req.headers['user-agent']); let ua = parser(req.headers['user-agent']);
let displayName = ua.os.name.replace('Mac OS', 'Mac') + ' ';
if (ua.device.model) {
displayName += ua.device.model;
} else {
displayName += ua.browser.name;
}
this.name = { this.name = {
model: ua.device.model, model: ua.device.model,
os: ua.os.name, os: ua.os.name,
browser: ua.browser.name, browser: ua.browser.name,
type: ua.device.type, type: ua.device.type,
displayName: uniqueNamesGenerator({ length: 2, separator: ' ', dictionaries: [colors, animals], style: 'capital' }) displayName: displayName
}; };
} }