func (c *ArticleController) ArticleDetail() {

	id, _ := c.GetInt64(":id")
	ip := c.Ip()
	userId, _ := c.GetInt64(":userId")

	c.TplName = "article_detail.html"

	if id <= 0 {
		c.StringError("文章不存在")
		c.Ctx.Redirect(302, "/")
		return
	}

	host := c.Host()
	url := c.Ctx.Request.RequestURI

	reqUri := fmt.Sprintf("%s%s", host, url)

	c.Data["reqUri"] = reqUri

	article, error := services.ArticleById(id)

	if error == nil {
		writer, _ := services.User(article.UserId)
		article.User = writer
	}

	if userId > 0 {
		hasLike, err := services.HasLikeArticle(id, userId, db.NewDB())
		if nil == err {
			article.HasLike = hasLike
		}
	}

	if nil != error {
		c.StringError("文章不存在")
	} else {
		currUserId := c.CurrentUserId()
		success, _ := services.IncrViewCount(id, currUserId, ip)
		if success {
			article.ViewCount = article.ViewCount + 1
		}
		c.Data["article"] = article

		c.SetCategories(article.UserId)

		c.SetKeywords(article.Categories + "," + article.Tags)
		var subLength = services.ParameterIntValue("seo-description-length")
		c.SetDescription(article.ShortContent(subLength)).SetTitle(article.Title)
	}
}
func TestGet(t *testing.T) {
	article, _ := services.ArticleById(35120)
	var content = html.UnescapeString(article.Content)
	if len(content) == 0 {
		return
	}
	reader := strings.NewReader(content)
	doc, _ := goquery.NewDocumentFromReader(reader)
	text := doc.Text()
	text = strings.Replace(text, " ", "", -1)
	text = strings.Replace(text, "\n", "", -1)
	text = strings.Replace(text, "\t", "", -1)
	subText := com.SubString(text, 0, 160)
	beego.Error(subText)
}