1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Support WOFF files in Celerity and add Source Sans Pro

Summary:
  - Allow Celerity to map and serve WOFF files.
  - Add Source Sans Pro, Source Sans Pro Bold, and the corresponding LICENSE.
  - Add a `font-source-sans-pro` resource for the font.

Test Plan:
  - Changed body `font-face` to `'Source Sans Pro'`.
  - Added `require_celerity_resource('font-source-sans-pro')` in StandardPageView.

Works in Firefox/Chrome/Safari, at least:

{F123296}

{F123297}

{F123298}

Reviewers: btrahan, chad

Reviewed By: chad

CC: chad, aran

Differential Revision: https://secure.phabricator.com/D8430
This commit is contained in:
epriestley 2014-03-06 11:28:24 -08:00
parent d08576ed4e
commit 270916a26e
20 changed files with 294 additions and 50 deletions

View file

@ -7,7 +7,7 @@
return array(
'names' =>
array(
'core.pkg.css' => '9cc0bd27',
'core.pkg.css' => '2ed3f133',
'core.pkg.js' => 'b7bdab05',
'darkconsole.pkg.js' => 'ca8671ce',
'differential.pkg.css' => 'd1b3a605',
@ -115,7 +115,8 @@ return array(
'rsrc/css/core/remarkup.css' => 'ca7f2265',
'rsrc/css/core/syntax.css' => '3c18c1cb',
'rsrc/css/core/z-index.css' => '0fd29d49',
'rsrc/css/diviner/diviner-shared.css' => 'be90f718',
'rsrc/css/diviner/diviner-shared.css' => '38813222',
'rsrc/css/font/font-source-sans-pro.css' => '225851dd',
'rsrc/css/layout/phabricator-action-header-view.css' => 'c14dfc57',
'rsrc/css/layout/phabricator-action-list-view.css' => '81383e25',
'rsrc/css/layout/phabricator-crumbs-view.css' => '2d9db584',
@ -129,11 +130,12 @@ return array(
'rsrc/css/phui/calendar/phui-calendar.css' => '5e1ad989',
'rsrc/css/phui/phui-box.css' => 'a36cf3a5',
'rsrc/css/phui/phui-button.css' => '8784a966',
'rsrc/css/phui/phui-document.css' => '143b2ac8',
'rsrc/css/phui/phui-document.css' => 'b56323cf',
'rsrc/css/phui/phui-feed-story.css' => '3a59c2cf',
'rsrc/css/phui/phui-fontkit.css' => 'de84aa4a',
'rsrc/css/phui/phui-form-view.css' => '0efd3326',
'rsrc/css/phui/phui-form.css' => 'b78ec020',
'rsrc/css/phui/phui-header-view.css' => '472a6003',
'rsrc/css/phui/phui-header-view.css' => 'b76a37b3',
'rsrc/css/phui/phui-icon.css' => '7a5771a9',
'rsrc/css/phui/phui-info-panel.css' => '27ea50a1',
'rsrc/css/phui/phui-list.css' => '2edb76cf',
@ -166,6 +168,8 @@ return array(
'rsrc/css/sprite-projects.css' => '7578fa56',
'rsrc/css/sprite-status.css' => '8bce1c97',
'rsrc/css/sprite-tokens.css' => '1706b943',
'rsrc/externals/font/SourceSansPro.woff' => '44e50175',
'rsrc/externals/font/SourceSansProBold.woff' => '8799f025',
'rsrc/externals/javelin/core/Event.js' => '79473b62',
'rsrc/externals/javelin/core/Stratcom.js' => 'c293f7b9',
'rsrc/externals/javelin/core/__tests__/event-stop-and-kill.js' => '717554e4',
@ -516,7 +520,8 @@ return array(
'diffusion-commit-view-css' => '92d1e8f9',
'diffusion-icons-css' => '384a0f7d',
'diffusion-source-css' => '66fdf661',
'diviner-shared-css' => 'be90f718',
'diviner-shared-css' => '38813222',
'font-source-sans-pro' => '225851dd',
'global-drag-and-drop-css' => '697324ad',
'herald-css' => '59d48f01',
'herald-rule-editor' => '4f31d692',
@ -744,11 +749,12 @@ return array(
'phui-calendar-day-css' => 'de035c8a',
'phui-calendar-list-css' => 'c1d0ca59',
'phui-calendar-month-css' => '5e762971',
'phui-document-view-css' => '143b2ac8',
'phui-document-view-css' => 'b56323cf',
'phui-feed-story-css' => '3a59c2cf',
'phui-fontkit-css' => 'de84aa4a',
'phui-form-css' => 'b78ec020',
'phui-form-view-css' => '0efd3326',
'phui-header-view-css' => '472a6003',
'phui-header-view-css' => 'b76a37b3',
'phui-icon-view-css' => '7a5771a9',
'phui-info-panel-css' => '27ea50a1',
'phui-list-view-css' => '2edb76cf',

View file

@ -61,7 +61,7 @@ class AphrontDefaultApplicationConfiguration
'(?:(?P<mtime>[0-9]+)T/)?'.
'(?P<library>[^/]+)/'.
'(?P<hash>[a-f0-9]{8})/'.
'(?P<path>.+\.(?:css|js|jpg|png|swf|gif))'
'(?P<path>.+\.(?:css|js|jpg|png|swf|gif|woff))'
=> 'CelerityPhabricatorResourceController',
),
);

View file

@ -10,6 +10,12 @@ final class AphrontFileResponse extends AphrontResponse {
private $download;
private $rangeMin;
private $rangeMax;
private $allowOrigins = array();
public function addAllowOrigin($origin) {
$this->allowOrigins[] = $origin;
return $this;
}
public function setDownload($download) {
$download = preg_replace('/[^A-Za-z0-9_.-]/', '_', $download);
@ -76,6 +82,12 @@ final class AphrontFileResponse extends AphrontResponse {
);
}
if ($this->allowOrigins) {
$headers[] = array(
'Access-Control-Allow-Origin',
implode(',', $this->allowOrigins));
}
$headers = array_merge(parent::getHeaders(), $headers);
return $headers;
}

View file

@ -222,6 +222,10 @@ abstract class PhabricatorController extends AphrontController {
$page->setDeviceReady(true);
}
if (idx($options, 'fonts')) {
$page->setExtraFonts(true);
}
$page->setShowChrome(idx($options, 'chrome', true));
$application_menu = $this->buildApplicationMenu();

View file

@ -121,6 +121,7 @@ final class DivinerAtomController extends DivinerController {
$document = id(new PHUIDocumentView())
->setBook($book->getTitle(), $group_name)
->setHeader($header)
->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS)
->appendChild($properties)
->appendChild($warnings)
->appendChild($content);
@ -248,6 +249,7 @@ final class DivinerAtomController extends DivinerController {
array(
'title' => $symbol->getTitle(),
'device' => true,
'fonts' => true,
));
}
@ -460,10 +462,8 @@ final class DivinerAtomController extends DivinerController {
case DivinerAtom::TYPE_METHOD:
case DivinerAtom::TYPE_FUNCTION:
break;
case DivinerAtom::TYPE_ARTICLE:
return $symbol->getTitle();
default:
return null;
return $symbol->getTitle();
}
$atom = $symbol->getAtom();

View file

@ -38,6 +38,7 @@ final class DivinerBookController extends DivinerController {
$document = new PHUIDocumentView();
$document->setHeader($header);
$document->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS);
$properties = $this->buildPropertyList($book);
@ -68,7 +69,19 @@ final class DivinerBookController extends DivinerController {
$section->addContent($this->renderAtomList($atoms));
$out[] = $section;
}
$preface = $book->getPreface();
$preface_view = null;
if (strlen($preface)) {
$preface_view =
PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($preface),
'default',
$viewer);
}
$document->appendChild($properties);
$document->appendChild($preface_view);
$document->appendChild($out);
return $this->buildApplicationPage(
@ -79,6 +92,7 @@ final class DivinerBookController extends DivinerController {
array(
'title' => $book->getTitle(),
'device' => true,
'fonts' => true,
));
}
@ -95,15 +109,6 @@ final class DivinerBookController extends DivinerController {
pht('Updated'),
phabricator_datetime($book->getDateModified(), $viewer));
$preface = $book->getPreface();
if (strlen($preface)) {
$view->addTextContent(
PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($preface),
'default',
$viewer));
}
return $view;
}

View file

@ -86,6 +86,7 @@ final class DivinerFindController extends DivinerController {
array(
'title' => array(pht('Find'), pht('"%s"', $query_text)),
'device' => true,
'fonts' => true,
));
}

View file

@ -33,23 +33,27 @@ final class DivinerMainController extends DivinerController {
$document = new PHUIDocumentView();
$document->setHeader($header);
$document->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS);
if ($books) {
$list = id(new PHUIObjectItemListView())
->setUser($viewer)
->setPlain(true);
$books = msort($books, 'getTitle');
$list = array();
foreach ($books as $book) {
$item = id(new PHUIObjectItemView())
$item = id(new DivinerBookItemView())
->setTitle($book->getTitle())
->setHref('/book/'.$book->getName().'/')
->setHeader($book->getTitle())
->addAttribute($book->getPreface());
$list->addItem($item);
->setSubtitle($book->getPreface());
$list[] = $item;
}
$list = id(new PHUIBoxView())
->addPadding(PHUI::PADDING_LARGE_LEFT)
->addPadding(PHUI::PADDING_LARGE_RIGHT)
->addPadding(PHUI::PADDING_SMALL_TOP)
->addPadding(PHUI::PADDING_SMALL_BOTTOM)
->appendChild($list);
$document->appendChild($list);
} else {
$text = pht(
"(NOTE) **Looking for Phabricator documentation?** If you're looking ".
@ -84,6 +88,7 @@ final class DivinerMainController extends DivinerController {
array(
'title' => pht('Documentation Books'),
'device' => true,
'fonts' => true,
));
}
}

View file

@ -70,6 +70,17 @@ abstract class CelerityResourceController extends PhabricatorController {
$response = new AphrontFileResponse();
$response->setContent($data);
$response->setMimeType($type_map[$type]);
// NOTE: This is a piece of magic required to make WOFF fonts work in
// Firefox. Possibly we should generalize this.
if ($type == 'woff') {
// We could be more tailored here, but it's not currently trivial to
// generate a comprehensive list of valid origins (an install may have
// arbitrarily many Phame blogs, for example), and we lose nothing by
// allowing access from anywhere.
$response->addAllowOrigin("*");
}
return $this->makeResponseCacheable($response);
}
@ -81,6 +92,7 @@ abstract class CelerityResourceController extends PhabricatorController {
'gif' => 'image/gif',
'jpg' => 'image/jpg',
'swf' => 'application/x-shockwave-flash',
'woff' => 'font/woff',
);
}

View file

@ -33,6 +33,7 @@ abstract class CelerityResourcesOnDisk extends CelerityPhysicalResources {
'jpg',
'gif',
'swf',
'woff',
);
}

View file

@ -12,6 +12,7 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView {
private $glyph;
private $menuContent;
private $showChrome = true;
private $extraFonts;
private $disableConsole;
private $pageObjects = array();
private $applicationMenu;
@ -57,6 +58,15 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView {
return $this->showChrome;
}
public function setExtraFonts($extra) {
$this->extraFonts = $extra;
return $this;
}
public function getExtraFonts() {
return $this->extraFonts;
}
public function appendPageObjects(array $objs) {
foreach ($objs as $obj) {
$this->pageObjects[] = $obj;
@ -233,8 +243,16 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView {
$response = CelerityAPI::getStaticResourceResponse();
$fonts = null;
if ($this->getExtraFonts()) {
$fonts = hsprintf("<link
href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700'
rel='stylesheet'
type='text/css'>");
}
return hsprintf(
'%s<style type="text/css">'.
'%s%s<style type="text/css">'.
'.PhabricatorMonospaced, '.
'.phabricator-remarkup .remarkup-code-block { font: %s; } '.
'.platform-windows .PhabricatorMonospaced, '.
@ -242,6 +260,7 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView {
'.remarkup-code-block { font: %s; }'.
'</style>%s',
parent::getHead(),
$fonts,
phutil_safe_html($monospaced),
phutil_safe_html($monospaced_win),
$response->renderSingleResource('javelin-magical-init', 'phabricator'));

View file

@ -5,6 +5,7 @@ final class PHUIDocumentView extends AphrontTagView {
/* For mobile displays, where do you want the sidebar */
const NAV_BOTTOM = 'nav_bottom';
const NAV_TOP = 'nav_top';
const FONT_SOURCE_SANS = 'source-sans';
private $offset;
private $header;
@ -14,6 +15,7 @@ final class PHUIDocumentView extends AphrontTagView {
private $bookname;
private $bookdescription;
private $mobileview;
private $fontKit;
public function setOffset($offset) {
$this->offset = $offset;
@ -50,6 +52,11 @@ final class PHUIDocumentView extends AphrontTagView {
return $this;
}
public function setFontKit($kit) {
$this->fontKit = $kit;
return $this;
}
public function getTagAttributes() {
$classes = array();
@ -64,6 +71,9 @@ final class PHUIDocumentView extends AphrontTagView {
public function getTagContent() {
require_celerity_resource('phui-document-view-css');
if ($this->fontKit) {
require_celerity_resource('phui-fontkit-css');
}
$classes = array();
$classes[] = 'phui-document-view';
@ -122,6 +132,17 @@ final class PHUIDocumentView extends AphrontTagView {
$this->bookName);
}
if ($this->fontKit) {
$main_content = phutil_tag(
'div',
array(
'class' => 'phui-font-'.$this->fontKit
),
$this->renderChildren());
} else {
$main_content = $this->renderChildren();
}
$content_inner = phutil_tag(
'div',
array(
@ -131,7 +152,7 @@ final class PHUIDocumentView extends AphrontTagView {
$book,
$this->header,
$topnav,
$this->renderChildren(),
$main_content,
$crumbs
));

View file

@ -15,10 +15,6 @@
margin: 0 8px 16px;
}
a.diviner-atom-signature-name {
color: {$violet};
}
.diviner-table-header {
padding: 4px 16px;
background-color: {$greybackground};
@ -71,6 +67,8 @@ a.diviner-atom-signature-name {
body .diviner-document-section .phui-header-view {
width: 100%;
font-size: 20px;
font-weight: 400;
}
.phui-property-list-view + .diviner-document-section {
@ -92,7 +90,8 @@ body .diviner-document-section .phui-header-view {
}
.diviner-list .diviner-atom-signature {
color: {$greytext};
color: {$violet};
margin-left: -16px;
}
.diviner-list a {
@ -120,9 +119,13 @@ body .diviner-document-section .phui-header-view {
padding-top: 0;
}
.diviner-list {
padding-left: 12px;
}
.diviner-list li {
line-height: 18px;
padding-bottom: 4px;
line-height: 20px;
padding-bottom: 12px;
}
/* - Book Index ----------------------------------------------------------------
@ -133,8 +136,8 @@ body .diviner-document-section .phui-header-view {
.diviner-book-item {
display: block;
padding: 4px 16px;
margin: 0 -16px;
padding: 6px 16px;
margin: 4px -16px;
}
.diviner-book-item:hover {
@ -142,11 +145,13 @@ body .diviner-document-section .phui-header-view {
}
.device-desktop .diviner-book-item:hover {
background-color: {$lightgreybackground};
background-color: #F5EEFF;
}
.diviner-book-item-title {
font-weight: bold;
font-weight: 700;
font-size: 16px;
color: {$darkbluetext};
}
.diviner-book-item-type {
@ -156,6 +161,6 @@ body .diviner-document-section .phui-header-view {
.diviner-book-item-subtitle {
display: block;
line-height: 18px;
color: {$lightbluetext};
line-height: 20px;
color: {$lightgreytext};
}

View file

@ -0,0 +1,23 @@
/**
* @provides font-source-sans-pro
*/
@font-face {
font-family: 'Source Sans Pro';
font-style: normal;
font-weight: 400;
src: local('Source Sans Pro'),
local('SourceSansPro-Regular'),
url(/rsrc/externals/font/SourceSansPro.woff)
format('woff');
}
@font-face {
font-family: 'Source Sans Pro';
font-style: normal;
font-weight: 700;
src: local('Source Sans Pro Bold'),
local('SourceSansPro-Bold'),
url(/rsrc/externals/font/SourceSansProBold.woff)
format('woff');
}

View file

@ -77,7 +77,7 @@
.phui-header-shell.phui-header-no-backgound
.phui-header-view {
padding: 8px 0 4px;
font-size: 14px;
font-size: 15px;
}
.phui-document-content .phui-header-view {

View file

@ -0,0 +1,38 @@
/**
* @provides phui-fontkit-css
*/
.phui-font-source-sans {
font-family: 'Source Sans Pro', 'Helvetica Neue', Arial, sans-serif;
font-size: 15px;
font-weight: 400;
line-height: 20px;
}
.phui-font-source-sans .phabricator-remarkup h2 {
padding: 8px 24px 8px 0;
border-bottom: 1px solid {$thinblueborder};
font-size: 20px;
font-weight: 400;
color: {$bluetext};
margin: 0 0 16px;
}
.phui-font-source-sans .phabricator-remarkup tt {
font-size: 13px;
padding: 1px 3px 2px;
}
.phui-font-source-sans .phui-property-list-section {
border-bottom: 1px solid {$thinblueborder};
margin-bottom: 8px;
background: {$lightgreybackground};
}
.phui-font-source-sans .phui-property-list-container {
padding-bottom: 6px;
}
.phui-font-source-sans a {
color: {$blue};
}

View file

@ -16,16 +16,15 @@ body .phui-header-shell.phui-header-no-backgound {
}
body .phui-header-shell.phui-bleed-header {
background-color: {$lightgreybackground};
border-top: 1px solid {$thinblueborder};
border-bottom: none;
background-color: #fff;
border-bottom: 1px solid {$thinblueborder};
width: auto;
margin-bottom: 16px;
margin: 16px;
}
body .phui-header-shell.phui-bleed-header
.phui-header-view {
padding: 8px 24px 8px 16px;
padding: 8px 24px 8px 0;
color: {$bluetext};
}

93
webroot/rsrc/externals/font/LICENSE vendored Normal file
View file

@ -0,0 +1,93 @@
Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries.
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Binary file not shown.

Binary file not shown.