From b048bd059335f0221c6eda78f0cdc845ebbe878a Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 1 Apr 2013 13:48:57 -0700 Subject: [PATCH] Add platform detection and a Windows-specific monospaced font override Summary: Use UA strings to detect platform; override general monospaced settings with platform-specific ones. Fixes T2868. Test Plan: whatcouldgowrong Reviewers: chad Reviewed By: chad CC: aran Maniphest Tasks: T2868 Differential Revision: https://secure.phabricator.com/D5526 --- conf/default.conf.php | 1 + ...ricatorSyntaxHighlightingConfigOptions.php | 12 ++++++++++ src/view/page/PhabricatorStandardPageView.php | 23 +++++++++++++++---- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/conf/default.conf.php b/conf/default.conf.php index 621b932639..83d140241d 100644 --- a/conf/default.conf.php +++ b/conf/default.conf.php @@ -1303,6 +1303,7 @@ return array( // Set the default monospaced font style for users who haven't set a custom // style. 'style.monospace' => '10px "Menlo", "Consolas", "Monaco", monospace', + 'style.monospace.windows' => '11px "Menlo", "Consolas", "Monaco", monospace', // -- Debugging ------------------------------------------------------------- // diff --git a/src/applications/config/option/PhabricatorSyntaxHighlightingConfigOptions.php b/src/applications/config/option/PhabricatorSyntaxHighlightingConfigOptions.php index a62d12bd93..1bae3269d6 100644 --- a/src/applications/config/option/PhabricatorSyntaxHighlightingConfigOptions.php +++ b/src/applications/config/option/PhabricatorSyntaxHighlightingConfigOptions.php @@ -103,12 +103,24 @@ final class PhabricatorSyntaxHighlightingConfigOptions 'style.monospace', 'string', '10px "Menlo", "Consolas", "Monaco", monospace') + ->setLocked(true) ->setSummary( pht("Default monospace font.")) ->setDescription( pht( "Set the default monospaced font style for users who haven't set ". "a custom style.")), + $this->newOption( + 'style.monospace.windows', + 'string', + '11px "Menlo", "Consolas", "Monaco", monospace') + ->setLocked(true) + ->setSummary( + pht("Default monospace font for clients on Windows.")) + ->setDescription( + pht( + "Set the default monospaced font style for users who haven't set ". + "a custom style and are using Windows.")), ); } diff --git a/src/view/page/PhabricatorStandardPageView.php b/src/view/page/PhabricatorStandardPageView.php index 6dc428b8ad..83ffa592d8 100644 --- a/src/view/page/PhabricatorStandardPageView.php +++ b/src/view/page/PhabricatorStandardPageView.php @@ -211,24 +211,29 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView { protected function getHead() { $monospaced = PhabricatorEnv::getEnvConfig('style.monospace'); + $monospaced_win = PhabricatorEnv::getEnvConfig('style.monospace.windows'); $request = $this->getRequest(); if ($request) { $user = $request->getUser(); if ($user) { - $monospaced = nonempty( - $user->loadPreferences()->getPreference( - PhabricatorUserPreferences::PREFERENCE_MONOSPACED), - $monospaced); + $pref = $user->loadPreferences()->getPreference( + PhabricatorUserPreferences::PREFERENCE_MONOSPACED); + $monospaced = nonempty($pref, $monospaced); + $monospaced_win = nonempty($pref, $monospaced_win); } } $response = CelerityAPI::getStaticResourceResponse(); return hsprintf( - '%s%s', + '%s%s', parent::getHead(), phutil_safe_html($monospaced), + phutil_safe_html($monospaced_win), $response->renderSingleResource('javelin-magical-init')); } @@ -396,6 +401,14 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView { $classes[] = $device_guess; + if (preg_match('@Windows@', $agent)) { + $classes[] = 'platform-windows'; + } else if (preg_match('@Macintosh@', $agent)) { + $classes[] = 'platform-mac'; + } else if (preg_match('@X11@', $agent)) { + $classes[] = 'platform-linux'; + } + return implode(' ', $classes); }