Page MenuHomePhabricator

How can I augment the javascript or css included by default on the pages rendered by phabricator in an extensible manner?
Closed, ResolvedPublic

Asked by yelirekim on Sep 25 2015, 7:30 PM.

Details

I'm attempting to write a remarkup rule that would require some particular javascript libraries to be present. I'm pretty sure it looks like this, but can't figure out how to actually include the resources in the response.

  • Dump the resources into my repo
  • Annotate those resources for celerity
  • Extend CelerityResourcesOnDisk to describe where my stuff is
  • Run celerity
  • ???

Answers

chad
Updated 3,357 Days Ago

Basically it should be:

@provides my-resource-js-css should go in your files
require_celerity_resource('my-resource-js-css') should go in the new remarkup file
bin/celerity map builds the resources

See also https://secure.phabricator.com/book/phabdev/article/celerity/

epriestley
Updated 3,357 Days Ago

With all the caveats of T5447:

require_celerity_resource('your-resource-name', 'your-map-name'); during rendering in your rule body, where your-resource-name is annotated as @provides your-resource-name in the header of your JS/CSS file.

Note that you can't currently @requires across maps, so if you write some JS that needs core Javelin stuff you'll have to manually require_celerity_resource(...) it alongside your callsite. I'm also not sure if it's possible to get Javelin::initBehavior() working with behaviors in third-party maps right now or not.

Generally, this stuff is modularized somewhat but not all of the kinks have been ironed out. I think third-party apps also have no access to spriting right now, and probably can't define CSS variables.

New Answer

Answer

This question has been marked as closed, but you can still leave a new answer.