use proper PGN content type in export endpoints
This commit is contained in:
parent
5d2996d0e2
commit
d84827e1a7
|
@ -24,7 +24,7 @@ object Export extends LilaController {
|
||||||
asImported = get("as") contains "imported",
|
asImported = get("as") contains "imported",
|
||||||
asRaw = get("as").contains("raw")) map { content =>
|
asRaw = get("as").contains("raw")) map { content =>
|
||||||
Ok(content).withHeaders(
|
Ok(content).withHeaders(
|
||||||
CONTENT_TYPE -> ContentTypes.TEXT,
|
CONTENT_TYPE -> pgnContentType,
|
||||||
CONTENT_DISPOSITION -> ("attachment; filename=" + (Env.api.pgnDump filename game)))
|
CONTENT_DISPOSITION -> ("attachment; filename=" + (Env.api.pgnDump filename game)))
|
||||||
} recover {
|
} recover {
|
||||||
case err => NotFound(err.getMessage)
|
case err => NotFound(err.getMessage)
|
||||||
|
|
|
@ -49,7 +49,7 @@ object Game extends LilaController {
|
||||||
import org.joda.time.format.DateTimeFormat
|
import org.joda.time.format.DateTimeFormat
|
||||||
val date = (DateTimeFormat forPattern "yyyy-MM-dd") print new DateTime
|
val date = (DateTimeFormat forPattern "yyyy-MM-dd") print new DateTime
|
||||||
Ok.chunked(Env.api.pgnDump exportUserGames userId).withHeaders(
|
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"))
|
CONTENT_DISPOSITION -> ("attachment; filename=" + s"lichess_${me.username}_$date.pgn"))
|
||||||
})
|
})
|
||||||
else notFound
|
else notFound
|
||||||
|
|
|
@ -386,4 +386,6 @@ private[controllers] trait LilaController
|
||||||
|
|
||||||
protected def errorsAsJson(form: play.api.data.Form[_])(implicit lang: play.api.i18n.Messages) =
|
protected def errorsAsJson(form: play.api.data.Form[_])(implicit lang: play.api.i18n.Messages) =
|
||||||
lila.common.Form errorsAsJson form
|
lila.common.Form errorsAsJson form
|
||||||
|
|
||||||
|
protected val pgnContentType = "application/x-chess-pgn"
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ object Search extends LilaController {
|
||||||
import org.joda.time.format.DateTimeFormat
|
import org.joda.time.format.DateTimeFormat
|
||||||
val date = (DateTimeFormat forPattern "yyyy-MM-dd") print DateTime.now
|
val date = (DateTimeFormat forPattern "yyyy-MM-dd") print DateTime.now
|
||||||
Ok.chunked(Env.api.pgnDump exportGamesFromIds ids).withHeaders(
|
Ok.chunked(Env.api.pgnDump exportGamesFromIds ids).withHeaders(
|
||||||
CONTENT_TYPE -> ContentTypes.TEXT,
|
CONTENT_TYPE -> pgnContentType,
|
||||||
CONTENT_DISPOSITION -> ("attachment; filename=" + s"lichess_search_$date.pgn"))
|
CONTENT_DISPOSITION -> ("attachment; filename=" + s"lichess_search_$date.pgn"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,7 +242,7 @@ object Study extends LilaController {
|
||||||
lila.mon.export.pgn.study()
|
lila.mon.export.pgn.study()
|
||||||
env.pgnDump(study) map { pgns =>
|
env.pgnDump(study) map { pgns =>
|
||||||
Ok(pgns.mkString("\n\n\n")).withHeaders(
|
Ok(pgns.mkString("\n\n\n")).withHeaders(
|
||||||
CONTENT_TYPE -> ContentTypes.TEXT,
|
CONTENT_TYPE -> pgnContentType,
|
||||||
CONTENT_DISPOSITION -> ("attachment; filename=" + (env.pgnDump filename study)))
|
CONTENT_DISPOSITION -> ("attachment; filename=" + (env.pgnDump filename study)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ object Study extends LilaController {
|
||||||
lila.mon.export.pgn.studyChapter()
|
lila.mon.export.pgn.studyChapter()
|
||||||
env.pgnDump.ofChapter(study, chapter) map { pgn =>
|
env.pgnDump.ofChapter(study, chapter) map { pgn =>
|
||||||
Ok(pgn.toString).withHeaders(
|
Ok(pgn.toString).withHeaders(
|
||||||
CONTENT_TYPE -> ContentTypes.TEXT,
|
CONTENT_TYPE -> pgnContentType,
|
||||||
CONTENT_DISPOSITION -> ("attachment; filename=" + (env.pgnDump.filename(study, chapter))))
|
CONTENT_DISPOSITION -> ("attachment; filename=" + (env.pgnDump.filename(study, chapter))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue