-
Notifications
You must be signed in to change notification settings - Fork 53
silgy_minify
Jurek Muszyński edited this page Sep 10, 2018
·
3 revisions
Minifies NULL-terminated src as CSS or JS and writes result to dest. Maximum length is 4 MB.
Returns new length.
#define COLOR_RED "#b40508" // carefully crafted 'red' we want to use across
// the entire app, as well as many times in CSS
// ...
void create_css() // called from app_init()
{
char dsk[2048];
char mob[2048];
char dsk_min[2048];
char mob_min[2048];
// .w_border style used in .....
sprintf(dsk, ".w_border {color:%s; border:1px solid grey;}", COLOR_RED);
sprintf(mob, ".w_border {color:%s; border:2px solid grey;}", COLOR_RED);
// .no_border style used in .....
sprintf(dsk, " %s .no_border {color:%s; border:0;}", dsk, COLOR_RED);
sprintf(mob, " %s .no_border {color:%s; border:0;}", mob, COLOR_RED);
// ...
silgy_minify(dsk_min, dsk);
silgy_add_to_static_res("dsk.css", dsk_min);
silgy_minify(mob_min, mob);
silgy_add_to_static_res("mob.css", mob_min);
}