Esempio n. 1
0
func Badge(ctx *middleware.Context) {
	importPath := ctx.Params("*")
	pkg, err := models.GetPakcageByPath(importPath)
	if err != nil {
		if err == models.ErrPackageNotExist {
			ctx.Error(404)
		} else {
			ctx.Handle(500, "Badge", err)
		}
		return
	}
	ctx.Redirect(fmt.Sprintf("http://img.shields.io/badge/downloads-%d_total-blue.svg?style=flat", pkg.DownloadCount))
}
Esempio n. 2
0
func Package(ctx *middleware.Context) {
	importPath := ctx.Params("*")
	_, err := models.GetPakcageByPath(importPath)
	if err != nil {
		if err == models.ErrPackageNotExist {
			ctx.Handle(404, "Package", nil)
		} else {
			ctx.Handle(500, "Package", err)
		}
		return
	}

	ctx.Data["Title"] = importPath
	ctx.Data["ImportPath"] = importPath
	ctx.HTML(200, "package")
}