Skip to content

Add new Node Type Icons

Thuy Le edited this page Jun 6, 2016 · 5 revisions

Generate a sprite for icons

Every time you call a website, your device (client) sends dozens or hundreds of http-requests to a server before loading a page. Because the servers are limited to handle a number of http-requests at the same time, it may slows down the page load. To reduce the page load we deliver the map-icons through a sprite.

Compass sprite

For generating a icon sprite file we use the built-in feature of compass. Unfortunately when new icon images were added to or old ones removed from app/assets/images/icons without any changes to the SCSS files compass will not recognize these.

This will be fixed once we switched to Rails 4. See: https://github.com/Compass/compass-rails/issues/52#issuecomment-29966698

For now the best way to regenerate the sprite file is simply to change a value or add a new line in one of the SCSS files and request the page locally. This will force Rails to run compass' compile and check for new icon files. Don't forget to remove your temporary changes in the SCSS file afterwards.

Alternatively you can run rake tmp:clear and restart your local development server.

Generate the icon zip file

The icon.zip file in the public folder is used by our mobile apps to download all icons at once and use our node type API to assign these icon files to specific node types.

To combine all icons into a new zip file, use the following rake task:

$ rake assets:create_zip 

Precompile assets

During the deployment the gem capistrano will precompile the assets automatically through a script. However, in case you need to precompile assets manually, run following command:

$ bundle exec rake assets:precompile

Important: If you want to precompile manually in another environment than development (default), set the proper environment:

$ RAILS_ENV=production bundle exec rake assets:precompile