package jetbrains.buildServer.serverSide;

import jetbrains.buildServer.web.openapi.PageExtension;
import jetbrains.buildServer.web.openapi.PagePlaces;
import jetbrains.buildServer.web.openapi.PlaceId;
import org.jetbrains.annotations.NotNull;

import javax.servlet.http.HttpServletRequest;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * @author Pavel.Sher
 *         Date: 31.03.2009
 */
public class PlayerExtension implements PageExtension {
  private JokeSettings mySettings;

  public PlayerExtension(PagePlaces pagePlaces, final JokeSettings settings) {
    mySettings = settings;
    pagePlaces.getPlaceById(PlaceId.ALL_PAGES_FOOTER).addExtension(this);
  }

  @NotNull
  public String getIncludeUrl() {
    return "player.jsp";
  }

  @NotNull
  public List<String> getCssPaths() {
    return Collections.emptyList();
  }

  @NotNull
  public List<String> getJsPaths() {
    return Collections.singletonList("swfobject.js");
  }

  public String getPluginName() {
    return JokeSettings.PLUGIN_NAME;
  }

  public boolean isAvailable(@NotNull final HttpServletRequest request) {
    return mySettings.isEnabled();
  }

  public void fillModel(@NotNull final Map<String, Object> model, @NotNull final HttpServletRequest request) {
  }
}
