Skip to content

Commit

Permalink
Remove the "can't copy/cut on Safari" warning from the Getting Starte…
Browse files Browse the repository at this point in the history
…d guides (#4300)

### What

egui 0.24 will fix the bug where coping from Safari was impossible:
- emilk/egui#3513

This PR removes the related warnings in the in-app Getting Started
guides.

- May be blocked by
lampsitter/egui_commonmark#21??
- Blocked by #4111
- Fixes #4292

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/4300) (if
applicable)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG

- [PR Build Summary](https://build.rerun.io/pr/4300)
- [Docs
preview](https://rerun.io/preview/0a0e58f6c169798c01d1932ecec3fb51cfe6360e/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/0a0e58f6c169798c01d1932ecec3fb51cfe6360e/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
  • Loading branch information
abey79 authored Dec 1, 2023
1 parent 52ce18d commit 275639c
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 45 deletions.
2 changes: 0 additions & 2 deletions crates/re_viewer/data/quick_start_guides/cpp_connect.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# C++ Quick Start

${SAFARI_WARNING}

## Installing the Rerun viewer
The Rerun C++ SDK works by connecting to an awaiting Rerun Viewer over TCP.

Expand Down
2 changes: 0 additions & 2 deletions crates/re_viewer/data/quick_start_guides/python_connect.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Python Quick Start

${SAFARI_WARNING}

## Installing the Rerun SDK

The Rerun SDK is available on [PyPI](https://pypi.org/) under the
Expand Down
2 changes: 0 additions & 2 deletions crates/re_viewer/data/quick_start_guides/python_spawn.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Python Quick Start

${SAFARI_WARNING}

## Installing the Rerun SDK

The Rerun SDK is available on [PyPI](https://pypi.org/) under the
Expand Down
2 changes: 0 additions & 2 deletions crates/re_viewer/data/quick_start_guides/rust_connect.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Rust Quick Start

${SAFARI_WARNING}

## Installing Rerun

To use the Rerun SDK in your project, you need the [rerun crate](https://crates.io/crates/rerun) which you can add with `cargo add rerun`.
Expand Down
2 changes: 0 additions & 2 deletions crates/re_viewer/data/quick_start_guides/rust_spawn.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Rust Quick Start

${SAFARI_WARNING}

## Installing Rerun

After you have [installed the viewer](https://www.rerun.io/docs/getting-started/installing-viewer) you can simply add [the rerun crate](https://crates.io/crates/rerun) to your project with `cargo add rerun`.
Expand Down
35 changes: 0 additions & 35 deletions crates/re_viewer/src/ui/welcome_screen/welcome_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ fn onboarding_content_ui(
[
("EXAMPLE_CODE", code),
("HOW_DOES_IT_WORK", HOW_DOES_IT_WORK_MARKDOWN),
("SAFARI_WARNING", safari_warning()),
]
.into(),
"C++ Quick Start",
Expand All @@ -121,7 +120,6 @@ fn onboarding_content_ui(
[
("EXAMPLE_CODE", code),
("HOW_DOES_IT_WORK", HOW_DOES_IT_WORK_MARKDOWN),
("SAFARI_WARNING", safari_warning()),
]
.into(),
"Python Quick Start",
Expand All @@ -141,7 +139,6 @@ fn onboarding_content_ui(
[
("EXAMPLE_CODE", code),
("HOW_DOES_IT_WORK", HOW_DOES_IT_WORK_MARKDOWN),
("SAFARI_WARNING", safari_warning()),
]
.into(),
"Rust Quick Start",
Expand Down Expand Up @@ -371,35 +368,3 @@ fn open_markdown_recording(

Ok(())
}

/// The User-Agent of the user's browser.
fn user_agent() -> Option<String> {
#[cfg(target_arch = "wasm32")]
return eframe::web::user_agent();

#[cfg(not(target_arch = "wasm32"))]
None
}

/// Are we running on Safari?
fn safari_warning() -> &'static str {
// Note that this implementation is very naive and might return false positives. This is ok for
// the purpose of displaying a "can't copy" warning in the Quick Start guide, but this detection
// is likely not suitable for pretty much anything else.
//
// See this page for more information on User Agent sniffing (and why/how to avoid it):
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent

let is_safari = user_agent().is_some_and(|user_agent| {
user_agent.contains("Safari")
&& !user_agent.contains("Chrome")
&& !user_agent.contains("Chromium")
});

if is_safari {
"**Note**: This browser appears to be Safari. If you are unable to copy the code, please \
try a different browser (see [this issue](https://github.com/emilk/egui/issues/3480))."
} else {
""
}
}

0 comments on commit 275639c

Please sign in to comment.