releave db.video by simplifying /video UI for bots
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] = {
|
||||
val reqTags = get("tags") ?? (_.split('^').toList.map(_.trim.toLowerCase))
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@(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) {
|
||||
<span class="view">watched</span>
|
||||
}
|
||||
|
|
|
@ -21,7 +21,8 @@ case class Filter(tags: List[String]) {
|
|||
case class UserControl(
|
||||
filter: Filter,
|
||||
tags: List[TagNb],
|
||||
query: Option[String]) {
|
||||
query: Option[String],
|
||||
bot: Boolean) {
|
||||
|
||||
def toggleTag(tag: String) = copy(
|
||||
filter = filter toggle tag,
|
||||
|
@ -31,4 +32,6 @@ case class UserControl(
|
|||
filter.tags.nonEmpty option s"tags=${filter.tags.sorted mkString "^"}".replace(" ", "+"),
|
||||
query.map { q => s"q=$q" }
|
||||
).flatten mkString "&"
|
||||
|
||||
def queryStringUnlessBot = !bot ?? queryString
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue