2012-08-14 23:17:19 +02:00
|
|
|
#!/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(
|
2012-11-27 23:03:25 +01:00
|
|
|
array(
|
|
|
|
'name' => 'force',
|
|
|
|
'help' => 'Force regeneration even if sources have not changed.',
|
|
|
|
),
|
2012-08-14 23:17:19 +02:00
|
|
|
));
|
|
|
|
|
2012-11-24 01:35:39 +01:00
|
|
|
$root = dirname(phutil_get_library_root('phabricator'));
|
|
|
|
$webroot = $root.'/webroot/rsrc';
|
2012-08-14 23:17:19 +02:00
|
|
|
$webroot = Filesystem::readablePath($webroot);
|
|
|
|
|
2012-11-24 01:19:06 +01:00
|
|
|
$generator = new CeleritySpriteGenerator();
|
2012-10-07 01:21:25 +02:00
|
|
|
|
2012-11-27 23:03:25 +01:00
|
|
|
$sheets = array(
|
|
|
|
'menu' => $generator->buildMenuSheet(),
|
Use application icons for "Eye" menu and Crumbs
Summary:
Issues here:
- Need an application-sized "eye", or a "home" icon for "Phabricator Home".
- Some of the "apps_lb_2x" sliced images are the "_dark_" versions, not the light versions.
- If you slice an application-sized "logout" (power off) icon and application-sized "help" (questionmark in circle) icon I can replace the current menu icons and nearly get rid of "autosprite".
- To replace the icons on /applications/, the non-retina size is "4x", so we'd need "8x" for retina. Alternatively I can reduce the icon sizes by 50%.
- The "Help", "Settings" and "Logout" items currently have a "glowing" hover state, which needs a variant (or we can drop it).
- The /applications/ icons have a white hover state (or we can drop it).
- The 1x application (14x14) icons aren't used anywhere right now, should they be? Maybe in the feed in the future, etc?
- The "apps-2x" and "apps-large" sheets are the same image, but getting them to actually use the same file is a bit tricky, so I just left them separate for now.
Test Plan:
{F26698}
{F26699}
Reviewers: chad
Reviewed By: chad
CC: aran
Maniphest Tasks: T1960
Differential Revision: https://secure.phabricator.com/D4108
2012-12-07 22:37:28 +01:00
|
|
|
'apps' => $generator->buildAppsSheet(),
|
2013-03-13 21:03:51 +01:00
|
|
|
'conpherence' => $generator->buildConpherenceSheet(),
|
Use application icons for "Eye" menu and Crumbs
Summary:
Issues here:
- Need an application-sized "eye", or a "home" icon for "Phabricator Home".
- Some of the "apps_lb_2x" sliced images are the "_dark_" versions, not the light versions.
- If you slice an application-sized "logout" (power off) icon and application-sized "help" (questionmark in circle) icon I can replace the current menu icons and nearly get rid of "autosprite".
- To replace the icons on /applications/, the non-retina size is "4x", so we'd need "8x" for retina. Alternatively I can reduce the icon sizes by 50%.
- The "Help", "Settings" and "Logout" items currently have a "glowing" hover state, which needs a variant (or we can drop it).
- The /applications/ icons have a white hover state (or we can drop it).
- The 1x application (14x14) icons aren't used anywhere right now, should they be? Maybe in the feed in the future, etc?
- The "apps-2x" and "apps-large" sheets are the same image, but getting them to actually use the same file is a bit tricky, so I just left them separate for now.
Test Plan:
{F26698}
{F26699}
Reviewers: chad
Reviewed By: chad
CC: aran
Maniphest Tasks: T1960
Differential Revision: https://secure.phabricator.com/D4108
2012-12-07 22:37:28 +01:00
|
|
|
'apps-large' => $generator->buildAppsLargeSheet(),
|
2013-04-23 01:41:00 +02:00
|
|
|
'payments' => $generator->buildPaymentsSheet(),
|
2013-02-15 16:47:14 +01:00
|
|
|
'tokens' => $generator->buildTokenSheet(),
|
2013-03-10 22:16:16 +01:00
|
|
|
'docs' => $generator->buildDocsSheet(),
|
2012-12-07 22:35:49 +01:00
|
|
|
'gradient' => $generator->buildGradientSheet(),
|
2013-12-06 21:08:11 +01:00
|
|
|
'main-header' => $generator->buildMainHeaderSheet(),
|
2013-06-11 19:22:09 +02:00
|
|
|
'login' => $generator->buildLoginSheet(),
|
2013-10-13 04:15:38 +02:00
|
|
|
'projects' => $generator->buildProjectsSheet(),
|
2012-11-27 23:03:25 +01:00
|
|
|
);
|
|
|
|
|
2012-12-07 22:36:35 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-11-27 23:03:25 +01:00
|
|
|
foreach ($sheets as $name => $sheet) {
|
2013-05-18 19:34:10 +02:00
|
|
|
|
|
|
|
$sheet->setBasePath($root);
|
|
|
|
|
2012-11-27 23:03:25 +01:00
|
|
|
$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");
|
2012-12-07 22:35:49 +01:00
|
|
|
|
|
|
|
foreach ($sheet->getScales() as $scale) {
|
|
|
|
if ($scale == 1) {
|
|
|
|
$sheet_name = "sprite-{$name}.png";
|
|
|
|
} else {
|
|
|
|
$sheet_name = "sprite-{$name}-X{$scale}.png";
|
|
|
|
}
|
2012-12-07 22:36:35 +01:00
|
|
|
|
|
|
|
$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);
|
|
|
|
}
|
2012-12-07 22:35:49 +01:00
|
|
|
}
|
2012-11-27 23:03:25 +01:00
|
|
|
}
|
2012-08-14 23:17:19 +02:00
|
|
|
|
|
|
|
echo "Done.\n";
|