use proper PGN content type in export endpoints

pull/2403/head
Thibault Duplessis 2016-10-21 15:23:59 +02:00
parent 5d2996d0e2
commit d84827e1a7
5 changed files with 7 additions and 5 deletions

View File

@ -24,7 +24,7 @@ object Export extends LilaController {
asImported = get("as") contains "imported",
asRaw = get("as").contains("raw")) map { content =>
Ok(content).withHeaders(
CONTENT_TYPE -> ContentTypes.TEXT,
CONTENT_TYPE -> pgnContentType,
CONTENT_DISPOSITION -> ("attachment; filename=" + (Env.api.pgnDump filename game)))
} recover {
case err => NotFound(err.getMessage)

View File

@ -49,7 +49,7 @@ object Game extends LilaController {
import org.joda.time.format.DateTimeFormat
val date = (DateTimeFormat forPattern "yyyy-MM-dd") print new DateTime
Ok.chunked(Env.api.pgnDump exportUserGames userId).withHeaders(
CONTENT_TYPE -> ContentTypes.TEXT,
CONTENT_TYPE -> pgnContentType,
CONTENT_DISPOSITION -> ("attachment; filename=" + s"lichess_${me.username}_$date.pgn"))
})
else notFound

View File

@ -386,4 +386,6 @@ private[controllers] trait LilaController
protected def errorsAsJson(form: play.api.data.Form[_])(implicit lang: play.api.i18n.Messages) =
lila.common.Form errorsAsJson form
protected val pgnContentType = "application/x-chess-pgn"
}

View File

@ -65,7 +65,7 @@ object Search extends LilaController {
import org.joda.time.format.DateTimeFormat
val date = (DateTimeFormat forPattern "yyyy-MM-dd") print DateTime.now
Ok.chunked(Env.api.pgnDump exportGamesFromIds ids).withHeaders(
CONTENT_TYPE -> ContentTypes.TEXT,
CONTENT_TYPE -> pgnContentType,
CONTENT_DISPOSITION -> ("attachment; filename=" + s"lichess_search_$date.pgn"))
}
}

View File

@ -242,7 +242,7 @@ object Study extends LilaController {
lila.mon.export.pgn.study()
env.pgnDump(study) map { pgns =>
Ok(pgns.mkString("\n\n\n")).withHeaders(
CONTENT_TYPE -> ContentTypes.TEXT,
CONTENT_TYPE -> pgnContentType,
CONTENT_DISPOSITION -> ("attachment; filename=" + (env.pgnDump filename study)))
}
}
@ -259,7 +259,7 @@ object Study extends LilaController {
lila.mon.export.pgn.studyChapter()
env.pgnDump.ofChapter(study, chapter) map { pgn =>
Ok(pgn.toString).withHeaders(
CONTENT_TYPE -> ContentTypes.TEXT,
CONTENT_TYPE -> pgnContentType,
CONTENT_DISPOSITION -> ("attachment; filename=" + (env.pgnDump.filename(study, chapter))))
}
}