Skip to content

Commit

Permalink
Merge branch 'main' of github.com:linqs/shark-clipper
Browse files Browse the repository at this point in the history
  • Loading branch information
eriq-augustine committed Oct 5, 2024
2 parents 09492a3 + 8040101 commit 5820585
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 5 deletions.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,48 @@ After that, you may run the binary as any normal program:
./shark-clipper-linux-x64-latest.bin
```

#### Using the Mac Prebuilt Binary

Mac requires additional security steps to run the prebuilt binary.
These steps need to be done every time a new binary is downloaded and run for the first time.
Running binary files is best done via the command line.
If you're not familiar with the terminal, you can use [this guide](https://gomakethings.com/navigating-the-file-system-with-terminal/)
to get started.
For a more comprehensive command line guide refer to MIT's [Missing Semester course](https://missing.csail.mit.edu/2020/course-shell/).

1) Unzip the downloaded shark-clipper-macos-x64-latest.zip file.

2) Open the Terminal application and navigate to the directory where shark-clipper-macos-x64-latest.bin is located e.g. if the file is in the "Downloads" folder:
```
cd ~/Downloads
```

3) Set execute permissions on the Mac prebuilt binary, e.g.:
```
chmod +x shark-clipper-macos-x64-latest.bin
```

4) Run the binary as any normal program:
```
./shark-clipper-macos-x64-latest.bin
```

5) Click "OK" on a popup that may appear saying that the file cannot be opened because Apple cannot check it for malicious software.

6) Open System Settings and navigate to the "Privacy & Security" tab.

7) Scroll down to the "Security" section.
A message should appear stating that shark-clipper-macos-x64-latest.bin was blocked because it is not from an identified developer.
Click the "Allow Anyway" button.
You may be required to provide a password.

8) Return to the terminal and re-run the binary:
```
./shark-clipper-macos-x64-latest.bin
```

9) Click "Open" on a popup that may appear again warning about running the file.

#### Using the Windows Prebuilt Binary

Windows requires some additional security steps to run the prebuilt binary.
Expand Down
5 changes: 5 additions & 0 deletions sharkclipper/api/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ def save(handler, path, temp_dir = None, data = None, out_dir = None, **kwargs):
# Out directory name is video name plus prefix of id.
id_prefix = data['video']['id'].split('-')[0]
out_dir = os.path.join(out_dir, data['video']['name'] + '-' + id_prefix)

# If directory already exists, remake to avoid conflicts.
if (os.path.exists(out_dir)):
sharkclipper.util.file.remove_dirent(out_dir)

os.makedirs(out_dir, exist_ok = True)

# Save screenshots.
Expand Down
33 changes: 28 additions & 5 deletions static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,16 @@ function initVideo(info) {

let video_location = metadata.location ?? {};
let latitude = video_location.latitude ?? undefined;
let latitude_input_value = convertCoordinatesForInput(latitude);
let longitude = video_location.longitude ?? undefined;
let longitude_input_value = convertCoordinatesForInput(longitude);

window.shark.info['video'] = {
id: info.video_id,
name: name,
start_time: start_time,
latitude: latitude,
longitude: longitude,
latitude: latitude_input_value,
longitude: longitude_input_value,
};

window.shark.info['key_metadata'] = info.key_metadata;
Expand Down Expand Up @@ -175,17 +177,19 @@ function initVideo(info) {
<input type='number' name='latitude' step='0.01'
data-video-id='${info.video_id}'
onchange='editVideo(this, "latitude")'
value='${latitude}' />
value='${latitude_input_value}' />
</div>
<div>
<label for='longitude'>Longitude:</label>
<input type='number' name='longitude' step='0.01'
data-video-id='${info.video_id}'
onchange='editVideo(this, "longitude")'
value='${longitude}' />
value='${longitude_input_value}' />
</div>
</div>
`;

removeHotkeysOnText();
}

function toggleSelection() {
Expand Down Expand Up @@ -254,7 +258,9 @@ function addScreenshot(screenshot) {
</div>
`;

document.querySelector('.screenshot-area').insertAdjacentHTML('beforeend', html);
document.querySelector('.screenshot-area').insertAdjacentHTML('afterbegin', html);

removeHotkeysOnText();
}

// Flip a screenshot by adding it the the canvas flipped horizontally or vertically.
Expand Down Expand Up @@ -419,6 +425,15 @@ function convertUnixSecsForInput(unixSeconds) {
return offsetDate.toISOString().slice(0, 19);
}

function convertCoordinatesForInput(coordinates) {
if (!coordinates) {
return undefined;
}

// Remove the leading + from coordinates.
return coordinates.replace(/^\+/, '');
}

// Fetch the server's version and add it to the page's title.
function fetchVersion() {
let promise = fetch('/version', {
Expand Down Expand Up @@ -462,6 +477,14 @@ function initializeHotkeys() {
save();
}
});

removeHotkeysOnText();
}

function removeHotkeysOnText() {
document.querySelectorAll('input[type="text"]').forEach((input) => {
input.setAttribute('onkeydown', 'event.stopPropagation()');
});
}

function main() {
Expand Down

0 comments on commit 5820585

Please sign in to comment.