Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the "can't copy/cut on Safari" warning from the Getting Started guides #4300

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
""
}
}
Loading