1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-09 16:32:39 +01:00

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
This commit is contained in:
epriestley 2013-04-01 13:48:57 -07:00
parent 7bf20ece81
commit b048bd0593
3 changed files with 31 additions and 5 deletions

View file

@ -1303,6 +1303,7 @@ return array(
// Set the default monospaced font style for users who haven't set a custom // Set the default monospaced font style for users who haven't set a custom
// style. // style.
'style.monospace' => '10px "Menlo", "Consolas", "Monaco", monospace', 'style.monospace' => '10px "Menlo", "Consolas", "Monaco", monospace',
'style.monospace.windows' => '11px "Menlo", "Consolas", "Monaco", monospace',
// -- Debugging ------------------------------------------------------------- // // -- Debugging ------------------------------------------------------------- //

View file

@ -103,12 +103,24 @@ final class PhabricatorSyntaxHighlightingConfigOptions
'style.monospace', 'style.monospace',
'string', 'string',
'10px "Menlo", "Consolas", "Monaco", monospace') '10px "Menlo", "Consolas", "Monaco", monospace')
->setLocked(true)
->setSummary( ->setSummary(
pht("Default monospace font.")) pht("Default monospace font."))
->setDescription( ->setDescription(
pht( pht(
"Set the default monospaced font style for users who haven't set ". "Set the default monospaced font style for users who haven't set ".
"a custom style.")), "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.")),
); );
} }

View file

@ -211,24 +211,29 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView {
protected function getHead() { protected function getHead() {
$monospaced = PhabricatorEnv::getEnvConfig('style.monospace'); $monospaced = PhabricatorEnv::getEnvConfig('style.monospace');
$monospaced_win = PhabricatorEnv::getEnvConfig('style.monospace.windows');
$request = $this->getRequest(); $request = $this->getRequest();
if ($request) { if ($request) {
$user = $request->getUser(); $user = $request->getUser();
if ($user) { if ($user) {
$monospaced = nonempty( $pref = $user->loadPreferences()->getPreference(
$user->loadPreferences()->getPreference( PhabricatorUserPreferences::PREFERENCE_MONOSPACED);
PhabricatorUserPreferences::PREFERENCE_MONOSPACED), $monospaced = nonempty($pref, $monospaced);
$monospaced); $monospaced_win = nonempty($pref, $monospaced_win);
} }
} }
$response = CelerityAPI::getStaticResourceResponse(); $response = CelerityAPI::getStaticResourceResponse();
return hsprintf( return hsprintf(
'%s<style type="text/css">.PhabricatorMonospaced { font: %s; }</style>%s', '%s<style type="text/css">'.
'.PhabricatorMonospaced { font: %s; } '.
'.platform-windows .PhabricatorMonospaced { font: %s; }'.
'</style>%s',
parent::getHead(), parent::getHead(),
phutil_safe_html($monospaced), phutil_safe_html($monospaced),
phutil_safe_html($monospaced_win),
$response->renderSingleResource('javelin-magical-init')); $response->renderSingleResource('javelin-magical-init'));
} }
@ -396,6 +401,14 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView {
$classes[] = $device_guess; $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); return implode(' ', $classes);
} }