當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Package.ViewDirPath方法代碼示例

本文整理匯總了Golang中github.com/Unknwon/hv.Package.ViewDirPath方法的典型用法代碼示例。如果您正苦於以下問題:Golang Package.ViewDirPath方法的具體用法?Golang Package.ViewDirPath怎麽用?Golang Package.ViewDirPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/Unknwon/hv.Package的用法示例。


在下文中一共展示了Package.ViewDirPath方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: generatePage

// generatePage genarates documentation page for project.
// it returns false when it's a invaild(empty) project.
func generatePage(this *HomeRouter, pdoc *hv.Package, q, tag string) bool {
	docPath := pdoc.ImportPath + utils.TagSuffix("-", tag)

	if pdoc.IsNeedRender {
		if !renderDoc(this, pdoc, q, tag, docPath) {
			return false
		}
	} else {
		pdecl, err := models.LoadProject(pdoc.Id, tag)
		if err != nil {
			beego.Error("HomeController.generatePage ->", err)
			return false
		}

		err = ConvertDataFormat(pdoc, pdecl)
		if err != nil {
			beego.Error("HomeController.generatePage -> ConvertDataFormat:", err)
			return false
		}

		this.Data["UtcTime"] = pdoc.Created.Add(4 * time.Hour)
		this.Data["TimeSince"] = calTimeSince(pdoc.Created.Add(4 * time.Hour))
	}

	proName := path.Base(pdoc.ImportPath)
	if i := strings.Index(proName, "?"); i > -1 {
		proName = proName[:i]
	}
	this.Data["ProName"] = proName

	// Check if need to show Hacker View.
	f := this.Input().Get("f")
	hvJs := utils.HvJsPath + pdoc.ImportPath + "/" + f + ".js"
	if len(tag) == 0 && (pdoc.IsCmd || pdoc.IsGoRepo || pdoc.IsGoSubrepo) &&
		len(f) > 0 && com.IsExist("."+hvJs) {
		this.TplNames = "hv.html"

		var query string
		if i := strings.Index(pdoc.ViewDirPath, "?"); i > -1 {
			query = pdoc.ViewDirPath[i:]
			pdoc.ViewDirPath = pdoc.ViewDirPath[:i]
		}
		this.Data["ViewDirPath"] = strings.TrimSuffix(pdoc.ViewDirPath, "/")
		this.Data["Query"] = query
		this.Data["FileName"] = f
		this.Data["HvJs"] = hvJs
		return true
	}

	// Set properties.
	this.TplNames = "docs.html"

	this.Data["Pid"] = pdoc.Id
	this.Data["IsGoRepo"] = pdoc.IsGoRepo

	if len(tag) == 0 && (pdoc.IsCmd || pdoc.IsGoRepo || pdoc.IsGoSubrepo) {
		this.Data["IsHasHv"] = true
	}

	// Refresh (within 10 seconds).
	this.Data["IsRefresh"] = pdoc.Created.UTC().Add(10 * time.Second).After(time.Now().UTC())

	this.Data["VCS"] = pdoc.Vcs
	this.Data["ProPath"] = pdoc.ProjectPath
	this.Data["ProDocPath"] = path.Dir(pdoc.ImportPath)

	// Introduction.
	this.Data["ImportPath"] = pdoc.ImportPath
	lang := this.Data["Lang"].(string)
	byts, _ := base32.StdEncoding.DecodeString(
		models.LoadPkgDoc(pdoc.ImportPath, lang, "rm"))
	if len(byts) > 0 {
		this.Data["IsHasReadme"] = true
		this.Data["PkgDoc"] = string(byts)
	}

	// Index.
	this.Data["IsHasExports"] = pdoc.IsHasExport
	this.Data["IsHasConst"] = pdoc.IsHasConst
	this.Data["IsHasVar"] = pdoc.IsHasVar

	if !pdoc.IsCmd {
		this.Data["IsHasExams"] = pdoc.IsHasExample

		tags := strings.Split(pdoc.Tags, "|||")
		// Tags.
		if len(tag) == 0 {
			tag = tags[0]
		}
		this.Data["CurTag"] = tag
		this.Data["Tags"] = tags
	} else {
		this.Data["IsCmd"] = true
	}

	this.Data["Rank"] = pdoc.Rank
	this.Data["Views"] = pdoc.Views + 1
	//this.Data["Labels"] = getLabels(pdoc.Labels)
//.........這裏部分代碼省略.........
開發者ID:CharlesSong,項目名稱:gowalker,代碼行數:101,代碼來源:home.go


注:本文中的github.com/Unknwon/hv.Package.ViewDirPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。