Skip to content

Commit

Permalink
Merge branch 'master' into translate
Browse files Browse the repository at this point in the history
  • Loading branch information
schlagmichdoch committed Jan 6, 2024
2 parents 6217042 + 1a9fa8e commit 70f7492
Show file tree
Hide file tree
Showing 14 changed files with 116 additions and 74 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ If applicable, add screenshots to help explain your problem.

**Bug occurs on official PairDrop instance https://pairdrop.net/**
No | Yes
Version: v1.10.1
Version: v1.10.3

**Bug occurs on self-hosted PairDrop instance**
No | Yes

**Self-Hosted Setup**
Proxy: Nginx | Apache2
Deployment: docker run | docker compose | npm run start:prod
Version: v1.10.1
Version: v1.10.3

**Additional context**
Add any other context about the problem here.
3 changes: 1 addition & 2 deletions .github/workflows/zip-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ jobs:
- name: Archive Release
uses: thedoctor0/zip-release@b57d897cb5d60cb78b51a507f63fa184cfe35554 # v0.7.6
with:
type: 'zip'
filename: 'pairdrop-cli.zip'
path: 'pairdrop-cli'
directory: 'pairdrop-cli'
exclusions: '*.git* /*node_modules/* .editorconfig'
- name: Upload Release
uses: ncipollo/release-action@6c75be85e571768fa31b40abf38de58ba0397db5 # v1.13.0
Expand Down
98 changes: 60 additions & 38 deletions docs/how-to.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This opens PairDrop in the default browser where you can choose the receiver.
```bash
pairdrop -h
```
```bash
```
Send files or text with PairDrop via command-line interface.
Current domain: https://pairdrop-dev.onrender.com/
Expand All @@ -35,44 +35,61 @@ Send text: pairdrop -t "text"
Specify domain: pairdrop -d "https://pairdrop.net/"
Show this help text: pairdrop (-h|--help)
This pairdrop-cli version was released alongside v1.10.0
This pairdrop-cli version was released alongside v1.10.4
```

<br>

### Setup
Download the bash file: [pairdrop-cli/pairdrop](/pairdrop-cli/pairdrop).

#### Linux
#### Linux / Mac
1. Download the latest _pairdrop-cli.zip_ from the [releases page](https://github.com/schlagmichdoch/PairDrop/releases)
2. Unzip the archive to a folder of your choice e.g. `/usr/local/bin/pairdrop-cli/`
3. Make sure the bash file `/usr/local/bin/pairdrop-cli/pairdrop` is executable. Otherwise, use `chmod +x pairdrop`
4. Add absolute path of the folder to PATH variable to make `pairdrop` available globally by executing
`export PATH=$PATH:/usr/local/bin/pairdrop-cli/`

<br>

#### Mac
1. add bash file to `/usr/local/bin`
```shell
wget "https://github.com/schlagmichdoch/PairDrop/releases/download/v1.10.4/pairdrop-cli.zip"
```
or
```shell
curl -LO "https://github.com/schlagmichdoch/PairDrop/releases/download/v1.10.4/pairdrop-cli.zip"
```
2. Unzip the archive to a folder of your choice e.g. `/usr/share/pairdrop-cli/`
```shell
sudo unzip pairdrop-cli.zip -d /usr/share/pairdrop-cli/
```
3. Copy the file _.pairdrop-cli-config.example_ to _.pairdrop-cli-config_
```shell
sudo cp /usr/share/pairdrop-cli/.pairdrop-cli-config.example /usr/share/pairdrop-cli/.pairdrop-cli-config
```
4. Make the bash file _pairdrop_ executable
```shell
sudo chmod +x /usr/share/pairdrop-cli/pairdrop
```
5. Add a symlink to /usr/local/bin/ to include _pairdrop_ to _PATH_
```shell
sudo ln -s /usr/share/pairdrop-cli/pairdrop /usr/local/bin/pairdrop
```

<br>

#### Windows
1. Download the latest _pairdrop-cli.zip_ from the [releases page](https://github.com/schlagmichdoch/PairDrop/releases)
2. Put file in a preferred folder e.g. `C:\Program Files\pairdrop-cli`
3. Search for and open `Edit environment variables for your account`
4. Click `Environment Variables…`
5. Under *System Variables* select `Path` and click *Edit...*
6. Click *New*, insert the preferred folder (`C:\Program Files\pairdrop-cli`), click *OK* until all windows are closed
7. Reopen Command prompt window
3. Inside this folder, copy the file _.pairdrop-cli-config.example_ to _.pairdrop-cli-config_
4. Search for and open `Edit environment variables for your account`
5. Click `Environment Variables…`
6. Under _System Variables_ select `Path` and click _Edit..._
7. Click _New_, insert the preferred folder (`C:\Program Files\pairdrop-cli`), click *OK* until all windows are closed
8. Reopen Command prompt window

<br>
**Requirements**

### Requirements
As Windows cannot execute bash scripts natively, you need to install [Git Bash](https://gitforwindows.org/).
Then, you can also use pairdrop-cli from the default Windows Command Prompt \
by using the shell file instead of the bash file: `pairdrop.sh -h` which then itself executes \
pairdrop-cli (the bash file) via the Git Bash.

Then, you can also use pairdrop-cli from the default Windows Command Prompt
by using the shell file instead of the bash file which then itself executes
_pairdrop-cli_ (the bash file) via the Git Bash.
```shell
pairdrop.sh -h
```

<br>

Expand All @@ -82,14 +99,15 @@ pairdrop-cli (the bash file) via the Git Bash.
It is possible to send multiple files with PairDrop via the context menu by adding pairdrop-cli to Windows `Send to` menu:
1. Download the latest _pairdrop-cli.zip_ from the [releases page](https://github.com/schlagmichdoch/PairDrop/releases)
2. Unzip the archive to a folder of your choice e.g. `C:\Program Files\pairdrop-cli\`
3. Copy the shortcut _send with PairDrop.lnk_
4. Hit Windows Key+R, type: `shell:sendto` and hit Enter.
5. Paste the copied shortcut into the directory
6. Open the properties window of the shortcut and edit the link field to point to _send-with-pairdrop.ps1_ located in the folder you used in step 2: \
3. Inside this folder, copy the file _.pairdrop-cli-config.example_ to _.pairdrop-cli-config_
4. Copy the shortcut _send with PairDrop.lnk_
5. Hit Windows Key+R, type: `shell:sendto` and hit Enter.
6. Paste the copied shortcut into the directory
7. Open the properties window of the shortcut and edit the link field to point to _send-with-pairdrop.ps1_ located in the folder you used in step 2: \
`"C:\Program Files\PowerShell\7\pwsh.exe" -File "C:\Program Files\pairdrop-cli\send-with-pairdrop.ps1"`
7. You are done! You can now send multiple files and directories directly via PairDrop:
8. You are done! You can now send multiple files and directories directly via PairDrop:

> _context menu > Send to > PairDrop_
_context menu_ > _Send to_ > _PairDrop_

##### Requirements
As Windows cannot execute bash scripts natively, you need to install [Git Bash](https://gitforwindows.org/).
Expand All @@ -100,21 +118,25 @@ As Windows cannot execute bash scripts natively, you need to install [Git Bash](

### Registering to open files with PairDrop
It is possible to send multiple files with PairDrop via the context menu by adding pairdrop-cli to Nautilus `Scripts` menu:
1. Download the latest _pairdrop-cli.zip_ from the [releases page](https://github.com/schlagmichdoch/PairDrop/releases)
2. Unzip the archive to a folder of your choice e.g. `/usr/local/bin/pairdrop-cli/`
3. Copy the shell file _send-with-pairdrop.sh_ to `/home/<user>/.local/share/nautilus/scripts/`
4. Edit the shell file and edit the variable `pathToPairDropCli` to point to the pairdrop-cli executable from step 2 (e.g. `/usr/local/bin/pairdrop-cli/pairdrop`)
5. Make sure the shell file `/home/<user>/.local/share/nautilus/scripts/send-with-pairdrop.sh` is executable. Otherwise, use `chmod +x send-with-pairdrop.sh`
6. You are done! You can now send multiple files and directories directly via PairDrop:

> _context menu > Scripts > send-with-pairdrop.sh_
1. Register _pairdrop_ as executable via [guide above](#linux).
2. Copy the shell file _send-with-pairdrop_ to `~/.local/share/nautilus/scripts/` to include it in the context menu
```shell
cp /usr/share/pairdrop-cli/send-with-pairdrop ~/.local/share/nautilus/scripts/
```
3. Make the shell file _send-with-pairdrop_ executable
```shell
chmod +x ~/.local/share/nautilus/scripts/send-with-pairdrop`
```
4. You are done! You can now send multiple files and directories directly via PairDrop:

_context menu_ > _Scripts_ > _send-with-pairdrop_

<br>

## File Handling API
The [File Handling API](https://learn.microsoft.com/en-us/microsoft-edge/progressive-web-apps-chromium/how-to/handle-files)
was implemented, but it was removed as default file associations were overwritten ([#17](https://github.com/schlagmichdoch/PairDrop/issues/17),
[#116](https://github.com/schlagmichdoch/PairDrop/issues/116) [#190](https://github.com/schlagmichdoch/PairDrop/issues/190))
and it only worked with explicitly specified file types and not with directories at all.
and it only worked with explicitly specified file types and couldn't handle directories at all.
[< Back](/README.md)
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pairdrop",
"version": "1.10.1",
"version": "1.10.3",
"type": "module",
"description": "",
"main": "server/index.js",
Expand All @@ -15,7 +15,7 @@
"express-rate-limit": "^7.1.5",
"ua-parser-js": "^1.0.37",
"unique-names-generator": "^4.3.0",
"ws": "^8.15.0"
"ws": "^8.16.0"
},
"engines": {
"node": ">=15"
Expand Down
1 change: 1 addition & 0 deletions pairdrop-cli/.pairdrop-cli-config.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DOMAIN=https://pairdrop.net/
12 changes: 9 additions & 3 deletions pairdrop-cli/pairdrop
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash
set -e

# PairDrop version when this file was last changed
version="v1.10.4"

############################################################
# Help #
############################################################
Expand All @@ -17,7 +20,7 @@ help()
echo -e "Specify domain:\t\t$(basename "$0") -d \"https://pairdrop.net/\""
echo -e "Show this help text:\t$(basename "$0") (-h|--help)"
echo
echo "This pairdrop-cli version was released alongside v1.10.0"
echo "This pairdrop-cli version was released alongside ${version}"
}

openPairDrop()
Expand Down Expand Up @@ -337,12 +340,15 @@ popd > '/dev/null';

config_path="${script_path}/.pairdrop-cli-config"

# If config file does not exist, try to create it. If it fails log error message and exit
[ ! -f "$config_path" ] &&
specifyDomain "https://pairdrop.net/" &&
[ ! -f "$config_path" ] &&
echo "Could not create config file. Add 'DOMAIN=https://pairdrop.net/' to a file called .pairdrop-cli-config in the same file as this 'pairdrop' bash file"
echo "Could not create config file. Add 'DOMAIN=https://pairdrop.net/' to a file called .pairdrop-cli-config in the same file as this 'pairdrop' bash file (${script_path})" &&
exit

[ ! -f "$config_path" ] || export "$(grep -v '^#' "$config_path" | xargs)"
# Read config variables
export "$(grep -v '^#' "$config_path" | xargs)"

setOs

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/bash

# edit this to point to the pairdrop-cli executable
pathToPairDropCli="/usr/local/bin/pairdrop-cli/pairdrop"

# Initialize an array
lines=()

Expand All @@ -17,4 +14,4 @@ length=${#lines[@]}
# Remove the last entry
unset 'lines[length-1]'

$pathToPairDropCli "${lines[@]}"
pairdrop "${lines[@]}"
Binary file modified public/images/favicon-96x96-notification.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/favicon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ <h2 class="dialog-title"></h2>
</svg>
<div class="title-wrapper" dir="ltr">
<h1>PairDrop</h1>
<div class="font-subheading">v1.10.1</div>
<div class="font-subheading">v1.10.3</div>
</div>
<div class="font-subheading" data-i18n-key="about.claim" data-i18n-attrs="text"></div>
<div class="row">
Expand Down
29 changes: 22 additions & 7 deletions public/scripts/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1978,12 +1978,15 @@ class ReceiveTextDialog extends Dialog {
this._receiveTextQueue = [];
}

selectionEmpty() {
return !window.getSelection().toString()
}

async _onKeyDown(e) {
if (!this.isShown()) return

if (e.code === "KeyC" && (e.ctrlKey || e.metaKey)) {
if (e.code === "KeyC" && (e.ctrlKey || e.metaKey) && this.selectionEmpty()) {
await this._onCopy()
this.hide();
}
else if (e.code === "Escape") {
this.hide();
Expand Down Expand Up @@ -2014,10 +2017,19 @@ class ReceiveTextDialog extends Dialog {

// Beautify text if text is short
if (text.length < 2000) {
// replace urls with actual links
this.$text.innerHTML = this.$text.innerHTML.replace(/((https?:\/\/|www)[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\-._~:\/?#\[\]@!$&'()*+,;=]+)/g, url => {
return `<a href="${url}" target="_blank">${url}</a>`;
});
// replace URLs with actual links
this.$text.innerHTML = this.$text.innerHTML
.replace(/(^|(?<=(<br>|\s)))(https?:\/\/|www.)(([a-z]|[A-Z]|[0-9]|[\-_~:\/?#\[\]@!$&'()*+,;=%]){2,}\.)(([a-z]|[A-Z]|[0-9]|[\-_~:\/?#\[\]@!$&'()*+,;=%.]){2,})/g,
(url) => {
let link = url;

// prefix www.example.com with http protocol to prevent it from being a relative link
if (link.startsWith('www')) {
link = "http://" + link
}

return `<a href="${link}" target="_blank">${url}</a>`;
});
}

this._evaluateOverflowing(this.$text);
Expand Down Expand Up @@ -2049,7 +2061,10 @@ class ReceiveTextDialog extends Dialog {

hide() {
super.hide();
setTimeout(() => this._dequeueRequests(), 500);
setTimeout(() => {
this._dequeueRequests();
this.$text.innerHTML = "";
}, 500);
}
}

Expand Down
2 changes: 1 addition & 1 deletion public/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const cacheVersion = 'v1.10.1';
const cacheVersion = 'v1.10.3';
const cacheTitle = `pairdrop-cache-${cacheVersion}`;
const forceFetch = false; // FOR DEVELOPMENT: Set to true to always update assets instead of using cached versions
const relativePathsToCache = [
Expand Down
Loading

0 comments on commit 70f7492

Please sign in to comment.