$project-path: absolute-path(join-file-segments(".."));

@import "compass/configuration";

@function asset-host($path) {
  @return "http://assets#{str-length($path) % 4}.example.com"
}

@function busted($url, $file) {
  $file-parts: split-filename($url);

  $dirname: nth($file-parts, 1);
  $basename: nth($file-parts, 2);
  $extname: nth($file-parts, 3);

  @if $basename == "grid" {
    @return (path: "#{$dirname}/#{$basename}-BUSTED#{$extname}", query: null);
  } @else if $basename == "feed" {
    @return "query_string";
  } @else if $basename == "dk" {
    @return (query: "query_string");
  } @else if $basename == "us" {
    @return (query: "h=#{md5sum($file)}");
  } @else if $basename == "gb" {
    @return (query: "i=#{md5sum($file, integer)}");
  } @else {
    @return null;
  }
}

@include compass-configuration($asset-cache-buster: busted, $asset-host: asset-host);
