1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-19 16:58:48 +02:00
phorge-phorge/scripts/celerity/generate_sprites.php
Chad Little b2f3001ec4 Replace Sprite-Icons with FontAwesome
Summary: The removes the sprite sheet 'icons' and replaces it with FontAwesome fonts.

Test Plan:
- Grep for SPRITE_ICONS and replace
- Grep for sprite-icons and replace
- Grep for PhabricatorActionList and choose all new icons
- Grep for Crumbs and fix icons
- Test/Replace PHUIList Icon support
- Test/Replace ObjectList Icon support (foot, epoch, etc)
- Browse as many pages as I could get to
- Remove sprite-icons and move remarkup to own sheet
- Review this diff in Differential

Reviewers: btrahan, epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin, hach-que

Differential Revision: https://secure.phabricator.com/D9052
2014-05-12 10:08:32 -07:00

94 lines
2.6 KiB
PHP
Executable file

#!/usr/bin/env php
<?php
require_once dirname(dirname(__FILE__)).'/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline('regenerate CSS sprite sheets');
$args->setSynopsis(<<<EOHELP
**sprites**
Rebuild CSS sprite sheets.
EOHELP
);
$args->parseStandardArguments();
$args->parse(
array(
array(
'name' => 'force',
'help' => 'Force regeneration even if sources have not changed.',
),
));
$root = dirname(phutil_get_library_root('phabricator'));
$webroot = $root.'/webroot/rsrc';
$webroot = Filesystem::readablePath($webroot);
$generator = new CeleritySpriteGenerator();
$sheets = array(
'remarkup' => $generator->buildRemarkupSheet(),
'menu' => $generator->buildMenuSheet(),
'apps' => $generator->buildAppsSheet(),
'actions' => $generator->buildActionsSheet(),
'minicons' => $generator->buildMiniconsSheet(),
'conpherence' => $generator->buildConpherenceSheet(),
'apps-large' => $generator->buildAppsLargeSheet(),
'payments' => $generator->buildPaymentsSheet(),
'tokens' => $generator->buildTokenSheet(),
'buttonbar' => $generator->buildButtonBarSheet(),
'docs' => $generator->buildDocsSheet(),
'gradient' => $generator->buildGradientSheet(),
'main-header' => $generator->buildMainHeaderSheet(),
'login' => $generator->buildLoginSheet(),
'status' => $generator->buildStatusSheet(),
'projects' => $generator->buildProjectsSheet(),
);
list($err) = exec_manual('optipng');
if ($err) {
$have_optipng = false;
echo phutil_console_format(
"<bg:red> WARNING </bg> `optipng` not found in PATH.\n".
"Sprites will not be optimized! Install `optipng`!\n");
} else {
$have_optipng = true;
}
foreach ($sheets as $name => $sheet) {
$sheet->setBasePath($root);
$manifest_path = $root.'/resources/sprite/manifest/'.$name.'.json';
if (!$args->getArg('force')) {
if (Filesystem::pathExists($manifest_path)) {
$data = Filesystem::readFile($manifest_path);
$data = json_decode($data, true);
if (!$sheet->needsRegeneration($data)) {
continue;
}
}
}
$sheet
->generateCSS($webroot."/css/sprite-{$name}.css")
->generateManifest($root."/resources/sprite/manifest/{$name}.json");
foreach ($sheet->getScales() as $scale) {
if ($scale == 1) {
$sheet_name = "sprite-{$name}.png";
} else {
$sheet_name = "sprite-{$name}-X{$scale}.png";
}
$full_path = "{$webroot}/image/{$sheet_name}";
$sheet->generateImage($full_path, $scale);
if ($have_optipng) {
echo "Optimizing...\n";
phutil_passthru('optipng -o7 -clobber %s', $full_path);
}
}
}
echo "Done.\n";