Changeset View
Changeset View
Standalone View
Standalone View
src/view/page/PhabricatorBarePageView.php
| Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | if ($this->getDeviceReady()) { | ||||
| array( | array( | ||||
| 'name' => 'viewport', | 'name' => 'viewport', | ||||
| 'content' => 'width=device-width, '. | 'content' => 'width=device-width, '. | ||||
| 'initial-scale=1, '. | 'initial-scale=1, '. | ||||
| 'user-scalable=no', | 'user-scalable=no', | ||||
| )); | )); | ||||
| } | } | ||||
| $mask_icon = phutil_tag( | $referrer_tag = phutil_tag( | ||||
| 'link', | 'meta', | ||||
| array( | |||||
| 'rel' => 'mask-icon', | |||||
| 'color' => '#3D4B67', | |||||
| 'href' => celerity_get_resource_uri( | |||||
| '/rsrc/favicons/mask-icon.svg'), | |||||
| )); | |||||
| $icon_tag_76 = phutil_tag( | |||||
| 'link', | |||||
| array( | |||||
| 'rel' => 'apple-touch-icon', | |||||
| 'href' => celerity_get_resource_uri( | |||||
| '/rsrc/favicons/apple-touch-icon-76x76.png'), | |||||
| )); | |||||
| $icon_tag_120 = phutil_tag( | |||||
| 'link', | |||||
| array( | array( | ||||
| 'rel' => 'apple-touch-icon', | 'name' => 'referrer', | ||||
| 'sizes' => '120x120', | 'content' => 'no-referrer', | ||||
| 'href' => celerity_get_resource_uri( | |||||
| '/rsrc/favicons/apple-touch-icon-120x120.png'), | |||||
| )); | )); | ||||
| $icon_tag_152 = phutil_tag( | |||||
| 'link', | |||||
| array( | |||||
| 'rel' => 'apple-touch-icon', | |||||
| 'sizes' => '152x152', | |||||
| 'href' => celerity_get_resource_uri( | |||||
| '/rsrc/favicons/apple-touch-icon-152x152.png'), | |||||
| )); | |||||
| $favicon_tag = phutil_tag( | $mask_icon = phutil_tag( | ||||
| 'link', | 'link', | ||||
| array( | array( | ||||
| 'id' => 'favicon', | 'rel' => 'mask-icon', | ||||
| 'rel' => 'shortcut icon', | 'color' => '#3D4B67', | ||||
| 'href' => celerity_get_resource_uri( | 'href' => celerity_get_resource_uri( | ||||
| '/rsrc/favicons/favicon.ico'), | '/rsrc/favicons/mask-icon.svg'), | ||||
| )); | )); | ||||
| $referrer_tag = phutil_tag( | $favicon_links = $this->newFavicons(); | ||||
| 'meta', | |||||
| array( | |||||
| 'name' => 'referrer', | |||||
| 'content' => 'no-referrer', | |||||
| )); | |||||
| $response = CelerityAPI::getStaticResourceResponse(); | $response = CelerityAPI::getStaticResourceResponse(); | ||||
| if ($this->getRequest()) { | if ($this->getRequest()) { | ||||
| $viewer = $this->getRequest()->getViewer(); | $viewer = $this->getRequest()->getViewer(); | ||||
| if ($viewer) { | if ($viewer) { | ||||
| $postprocessor_key = $viewer->getUserSetting( | $postprocessor_key = $viewer->getUserSetting( | ||||
| PhabricatorAccessibilitySetting::SETTINGKEY); | PhabricatorAccessibilitySetting::SETTINGKEY); | ||||
| if (strlen($postprocessor_key)) { | if (strlen($postprocessor_key)) { | ||||
| $response->setPostProcessorKey($postprocessor_key); | $response->setPostProcessorKey($postprocessor_key); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return hsprintf( | return hsprintf( | ||||
| '%s%s%s%s%s%s%s%s', | '%s%s%s%s%s', | ||||
| $viewport_tag, | $viewport_tag, | ||||
| $mask_icon, | $mask_icon, | ||||
| $icon_tag_76, | $favicon_links, | ||||
| $icon_tag_120, | |||||
| $icon_tag_152, | |||||
| $favicon_tag, | |||||
| $referrer_tag, | $referrer_tag, | ||||
| $response->renderResourcesOfType('css')); | $response->renderResourcesOfType('css')); | ||||
| } | } | ||||
| protected function getBody() { | protected function getBody() { | ||||
| return $this->bodyContent; | return $this->bodyContent; | ||||
| } | } | ||||
| protected function getTail() { | protected function getTail() { | ||||
| $response = CelerityAPI::getStaticResourceResponse(); | $response = CelerityAPI::getStaticResourceResponse(); | ||||
| return $response->renderResourcesOfType('js'); | return $response->renderResourcesOfType('js'); | ||||
| } | } | ||||
| private function newFavicons() { | |||||
| $favicon_refs = array( | |||||
| array( | |||||
| 'rel' => 'apple-touch-icon', | |||||
| 'sizes' => '76x76', | |||||
| 'width' => 76, | |||||
| 'height' => 76, | |||||
| ), | |||||
| array( | |||||
| 'rel' => 'apple-touch-icon', | |||||
| 'sizes' => '120x120', | |||||
| 'width' => 120, | |||||
| 'height' => 120, | |||||
| ), | |||||
| array( | |||||
| 'rel' => 'apple-touch-icon', | |||||
| 'sizes' => '152x152', | |||||
| 'width' => 152, | |||||
| 'height' => 152, | |||||
| ), | |||||
| array( | |||||
| 'rel' => 'icon', | |||||
| 'id' => 'favicon', | |||||
| 'width' => 64, | |||||
| 'height' => 64, | |||||
| ), | |||||
| ); | |||||
| $fetch_refs = array(); | |||||
| foreach ($favicon_refs as $key => $spec) { | |||||
| $ref = id(new PhabricatorFaviconRef()) | |||||
| ->setWidth($spec['width']) | |||||
| ->setHeight($spec['height']); | |||||
| $favicon_refs[$key]['ref'] = $ref; | |||||
| $fetch_refs[] = $ref; | |||||
| } | |||||
| id(new PhabricatorFaviconRefQuery()) | |||||
| ->withRefs($fetch_refs) | |||||
| ->execute(); | |||||
| $favicon_links = array(); | |||||
| foreach ($favicon_refs as $spec) { | |||||
| $favicon_links[] = phutil_tag( | |||||
| 'link', | |||||
| array( | |||||
| 'rel' => $spec['rel'], | |||||
| 'sizes' => idx($spec, 'sizes'), | |||||
| 'id' => idx($spec, 'id'), | |||||
| 'href' => $spec['ref']->getURI(), | |||||
| )); | |||||
| } | |||||
| return $favicon_links; | |||||
| } | |||||
| } | } | ||||