nicer ublog topic URLs
parent
63a27c68f0
commit
3e506f22ba
|
@ -229,7 +229,7 @@ final class Ublog(env: Env) extends LilaController(env) {
|
|||
def topic(str: String, page: Int) = Open { implicit ctx =>
|
||||
NotForKids {
|
||||
Reasonable(page, 15) {
|
||||
UblogPost.Topic.get(str) ?? { top =>
|
||||
UblogPost.Topic.fromUrl(str) ?? { top =>
|
||||
env.ublog.paginator.liveByTopic(top, page) map { posts =>
|
||||
Ok(html.ublog.index.topic(top, posts))
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ object post {
|
|||
),
|
||||
div(cls := "ublog-post__topics")(
|
||||
post.topics.map { topic =>
|
||||
a(href := routes.Ublog.topic(topic.value, 1))(topic.value)
|
||||
a(href := routes.Ublog.topic(topic.url, 1))(topic.value)
|
||||
}
|
||||
),
|
||||
strong(cls := "ublog-post__intro")(post.intro),
|
||||
|
|
|
@ -97,13 +97,13 @@ GET /blog controllers.Blog.index(page: Int ?= 1)
|
|||
GET /blog/all controllers.Blog.all
|
||||
GET /blog/$year<2\d{3}> controllers.Blog.year(year: Int)
|
||||
GET /blog/discuss/:id controllers.Blog.discuss(id: String)
|
||||
GET /blog/topic/:topic controllers.Ublog.topic(topic: String, page: Int ?= 1)
|
||||
GET /blog/:id/:slug controllers.Blog.show(id: String, slug: String, ref: Option[String] ?= None)
|
||||
GET /blog.atom controllers.Blog.atom
|
||||
GET /blog.txt controllers.Blog.sitemapTxt
|
||||
GET /blog/friends controllers.Ublog.friends(page: Int ?= 1)
|
||||
GET /blog/liked controllers.Ublog.liked(page: Int ?= 1)
|
||||
GET /blog/community controllers.Ublog.community(page: Int ?= 1)
|
||||
GET /blog/topic controllers.Ublog.topic(topic: String, page: Int ?= 1)
|
||||
|
||||
# Training - Coordinate
|
||||
GET /training/coordinate controllers.Coordinate.home
|
||||
|
|
|
@ -32,7 +32,9 @@ object UblogPost {
|
|||
|
||||
case class Recorded(by: User.ID, at: DateTime)
|
||||
|
||||
case class Topic(value: String) extends AnyVal with StringValue
|
||||
case class Topic(value: String) extends StringValue {
|
||||
val url = value.replace(" ", "_")
|
||||
}
|
||||
|
||||
object Topic {
|
||||
val all = List(
|
||||
|
@ -59,6 +61,7 @@ object UblogPost {
|
|||
val exists = all.toSet
|
||||
def get(str: String) = exists(str) option Topic(str)
|
||||
def fromStrList(str: String) = str.split(',').toList.flatMap(get).distinct
|
||||
def fromUrl(str: String) = get(str.replace("_", " "))
|
||||
}
|
||||
|
||||
case class Likes(value: Int) extends AnyVal
|
||||
|
|
Loading…
Reference in New Issue