From b45e9eacb04c1d112147fcd5323249e1fd34a042 Mon Sep 17 00:00:00 2001
From: life <lifephp@gmail.com>
Date: Thu, 13 Nov 2014 12:35:48 +0800
Subject: [PATCH] beta2 preview controller

---
 app/controllers/BlogController.go | 14 +++++++++-----
 conf/routes-default               |  6 +++---
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/app/controllers/BlogController.go b/app/controllers/BlogController.go
index f2fe79f..e6021fd 100644
--- a/app/controllers/BlogController.go
+++ b/app/controllers/BlogController.go
@@ -102,19 +102,23 @@ func (c Blog) setPreviewUrl() {
 	var indexUrl, postUrl, searchUrl, cateUrl, singleUrl, tagsUrl, archiveUrl string
 
 	userId := c.GetUserId()
+	userIdOrEmail := userId
+	username := c.GetUsername()
+	if username != "" {
+		userIdOrEmail = username
+	}
 	themeId := c.Session["themeId"]
 	theme := themeService.GetTheme(userId, themeId)
 
 	siteUrl := configService.GetSiteUrl()
 	blogUrl := siteUrl + "/preview" // blog.leanote.com
-	userIdOrEmail := userId
 
 	indexUrl = blogUrl + "/" + userIdOrEmail
-	cateUrl = blogUrl + "/cate" // /notebookId
+	cateUrl = blogUrl + "/cate/" + userIdOrEmail // /notebookId
 
-	postUrl = blogUrl + "/post"                         // /xxxxx
+	postUrl = blogUrl + "/post/" + userIdOrEmail                         // /xxxxx
 	searchUrl = blogUrl + "/search/" + userIdOrEmail    // blog.leanote.com/search/userId
-	singleUrl = blogUrl + "/single"                     // blog.leanote.com/single/singleId
+	singleUrl = blogUrl + "/single/" + userIdOrEmail                     // blog.leanote.com/single/singleId
 	archiveUrl = blogUrl + "/archives/" + userIdOrEmail // blog.leanote.com/archive/userId
 	tagsUrl = blogUrl + "/tags/" + userIdOrEmail        // blog.leanote.com/archive/userId
 
@@ -841,4 +845,4 @@ func (c Blog) ListCateLatest(notebookId, callback string) revel.Result {
 	re.Ok = true
 	re.List = blogs
 	return c.RenderJsonP(callback, re)
-}
+}
\ No newline at end of file
diff --git a/conf/routes-default b/conf/routes-default
index d7bab55..a94c0d0 100644
--- a/conf/routes-default
+++ b/conf/routes-default
@@ -82,13 +82,13 @@ GET		/preview/archives	Preview.Archives
 GET		/preview/view/:noteId			Preview.Post
 
 GET		/preview/post/:noteId			Preview.Post
-GET		/preview/post/userIdOrEmail/:noteId			Preview.Post
+GET		/preview/post/:userIdOrEmail/:noteId			Preview.Post
 
-GET		/preview/single/userIdOrEmail/:singleId			Preview.Single
+GET		/preview/single/:userIdOrEmail/:singleId			Preview.Single
 GET		/preview/single/:singleId			Preview.Single
 
 GET		/preview/cate/:notebookId		Preview.Cate
-GET		/preview/cate/userIdOrEmail/:notebookId		Preview.Cate
+GET		/preview/cate/:userIdOrEmail/:notebookId		Preview.Cate
 
 GET		/preview/:userIdOrEmail		Preview.Index
 GET		/preview						Preview.Index