releave db.video by simplifying /video UI for bots
This commit is contained in:
parent
9b7e68db30
commit
9399d8b86d
|
@ -17,7 +17,11 @@ object Video extends LilaController {
|
||||||
private def WithUserControl[A](f: UserControl => Fu[A])(implicit ctx: Context): Fu[A] = {
|
private def WithUserControl[A](f: UserControl => Fu[A])(implicit ctx: Context): Fu[A] = {
|
||||||
val reqTags = get("tags") ?? (_.split('^').toList.map(_.trim.toLowerCase))
|
val reqTags = get("tags") ?? (_.split('^').toList.map(_.trim.toLowerCase))
|
||||||
env.api.tag.paths(reqTags) map { tags =>
|
env.api.tag.paths(reqTags) map { tags =>
|
||||||
UserControl(filter = Filter(reqTags), tags = tags, query = get("q"))
|
UserControl(
|
||||||
|
filter = Filter(reqTags),
|
||||||
|
tags = tags,
|
||||||
|
query = get("q"),
|
||||||
|
bot = HTTPRequest.isBot(ctx.req))
|
||||||
} flatMap f
|
} flatMap f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
@(vv: lila.video.VideoView, control: lila.video.UserControl)(implicit ctx: Context)
|
@(vv: lila.video.VideoView, control: lila.video.UserControl)(implicit ctx: Context)
|
||||||
|
|
||||||
<a class="card paginated_element" href="@routes.Video.show(vv.video.id)?@control.queryString">
|
<a class="card paginated_element" href="@routes.Video.show(vv.video.id)?@control.queryStringUnlessBot">
|
||||||
@if(vv.view) {
|
@if(vv.view) {
|
||||||
<span class="view">watched</span>
|
<span class="view">watched</span>
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,8 @@ case class Filter(tags: List[String]) {
|
||||||
case class UserControl(
|
case class UserControl(
|
||||||
filter: Filter,
|
filter: Filter,
|
||||||
tags: List[TagNb],
|
tags: List[TagNb],
|
||||||
query: Option[String]) {
|
query: Option[String],
|
||||||
|
bot: Boolean) {
|
||||||
|
|
||||||
def toggleTag(tag: String) = copy(
|
def toggleTag(tag: String) = copy(
|
||||||
filter = filter toggle tag,
|
filter = filter toggle tag,
|
||||||
|
@ -31,4 +32,6 @@ case class UserControl(
|
||||||
filter.tags.nonEmpty option s"tags=${filter.tags.sorted mkString "^"}".replace(" ", "+"),
|
filter.tags.nonEmpty option s"tags=${filter.tags.sorted mkString "^"}".replace(" ", "+"),
|
||||||
query.map { q => s"q=$q" }
|
query.map { q => s"q=$q" }
|
||||||
).flatten mkString "&"
|
).flatten mkString "&"
|
||||||
|
|
||||||
|
def queryStringUnlessBot = !bot ?? queryString
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue