mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +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:
parent
7bf20ece81
commit
b048bd0593
3 changed files with 31 additions and 5 deletions
|
@ -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 ------------------------------------------------------------- //
|
||||
|
|
|
@ -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.")),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<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(),
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue