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

web: fix problems with download page on project sites #5160

Merged
merged 1 commit into from
Mar 22, 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
14 changes: 9 additions & 5 deletions html/inc/util.inc
Original file line number Diff line number Diff line change
Expand Up @@ -900,19 +900,23 @@ function current_url() {
// @param text The text to display on the button
// @param desc The title of the destination - typically used as a popup
// @param class The optional CSS class of the button. Defaults to a standard button
// @params extra Additional text in href tag
//

function button_text($url, $text, $desc=null, $class="btn-success btn-sm") {
function button_text($url, $text, $desc=null, $class=null, $extra='') {
if (!$desc) {
$desc = $text;
}
return sprintf(' <a href="%s" title="%s" class="btn %s">%s</a>',
$url, $desc, $class, $text
if (!$class) {
$class = "btn-success btn-sm";
}
return sprintf(' <a href="%s" title="%s" class="btn %s" %s>%s</a>',
$url, $desc, $class, $extra, $text
);
}

function show_button($url, $text, $desc=null, $class="btn-success btn-sm") {
echo button_text($url, $text, $desc, $class);
function show_button($url, $text, $desc=null, $class=null, $extra=null) {
echo button_text($url, $text, $desc, $class, $extra);
}

// for places with a bunch of buttons, like forum posts
Expand Down
93 changes: 57 additions & 36 deletions html/user/download_software.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,26 @@
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.

// Show a page with download links and instructions.
// There's a logged-in user.
//
// If no project ID, direct user to BOINC web site
// otherwise...
// Page for downloading the BOINC client, with support for autoattach:
// https://boinc.berkeley.edu/trac/wiki/SimpleAttach
// Note: to use autoattach:
// 1) You need to have the client versions file
// run html/ops/get_versions.php
// 2) Put your project ID (ask DPA if you don't have one)
// in config.xml as <project_id>x</project_id>
//
// - get platform from user agent string
// - find latest version for that platform (regular and vbox)
// - Create a login token.
// - Show download button(s)
// The download will be via concierge, using the login token.
// There's a logged-in user.
//
// VirtualBox
// Autoattach case: if project has an ID and client is Win or Mac:
// - find latest version for that platform (regular and vbox)
// - Create a login token.
// - Show download button(s)
// The download will be via concierge, using the login token.
// Otherwise:
// - show link to download page on BOINC web site,
// and instructions for what to do after that.
//
// VirtualBox:
// config.xml entries:
// <need_vbox/> This project requires VBox
// <recommend_vbox> This project can use VBox
Expand All @@ -38,11 +44,6 @@
// For other platforms, direct user to VBox download page
// before installing BOINC
//
// Notes:
// 1) You need to have the client versions file
// run html/ops/get_versions.php
// 2) Put your project ID in a constant PROJECT_ID
// (this all works only for listed projects)

// Can also be called as a web RPC;
// see https://boinc.berkeley.edu/trac/wiki/WebRpc#download
Expand Down Expand Up @@ -100,6 +101,13 @@ function is_windows() {
return false;
}

function is_windows_or_mac() {
global $user_agent;
if (strstr($user_agent, 'Windows')) return true;
if (strstr($user_agent, 'Mac')) return true;
return false;
}

// find release version for user's platform
//
function get_version($user_agent, $dev) {
Expand Down Expand Up @@ -180,8 +188,7 @@ function show_vbox_info($where) {
echo "<p>";
if ($need_vbox) {
echo tra("This project requires VirtualBox.");
}
if ($recommend_vbox) {
} else if ($recommend_vbox) {
echo tra("This project recommends VirtualBox.");
}
echo " ";
Expand Down Expand Up @@ -215,27 +222,41 @@ function direct_to_boinc() {
global $master_url;
page_head(tra("Download BOINC"));
text_start();
show_vbox_info("direct");
echo sprintf(
'<p>%s
<p><p>
%s
<p>
',
tra("To download and install BOINC,
echo "<p>";
echo tra("To download and install BOINC,
click on the link below and follow the instructions.
"),
tra("When BOINC first runs it will ask you to select a project.
Select %1 from the list,
or enter this project's URL: %2",
PROJECT,
$master_url
)
);
");
echo "<p>";
show_button(
"https://boinc.berkeley.edu/download.php",
tra("Go to the BOINC download page.")
tra("Go to the BOINC download page."),
null, null, 'target=_new'
);
show_vbox_info("direct");

if (parse_bool(get_config(), 'account_manager')) {
echo sprintf(
"<p><p>%s<p>",
tra("When BOINC first runs it will ask you to select a project.
Cancel out of this dialog,
then select <b>Tools / Use Account Manager</b>
to connect BOINC to your %1 account.
See <a href=%2>detailed instructions</a>.",
PROJECT,
'https://boinc.berkeley.edu/wiki/Account_managers'
)
);
} else {
echo sprintf(
"<p><p>%s<p>",
tra("When BOINC first runs it will ask you to select a project.
Select '%1' from the list,
or enter this project's URL:<p>%2",
PROJECT,
$master_url
)
);
}
text_end();
page_tail();
}
Expand All @@ -245,7 +266,7 @@ function show_download_page($user, $user_agent, $dev) {

// If no project ID, we can't use simplified install
//
if (!$project_id) {
if (!$project_id || !is_windows_or_mac()) {
direct_to_boinc();
return;
}
Expand Down