Esempio n. 1
0
func init() {
	// Initialized recent viewed project list.
	num, err := beego.AppConfig.Int("recentViewedProNum")
	if err == nil {
		recentViewedProNum = num
		beego.Trace("Loaded 'recentViewedProNum' -> value:", recentViewedProNum)
	} else {
		beego.Trace("Failed to load 'recentViewedProNum' -> Use default value:", recentViewedProNum)
	}

	recentViewedPros = make([]*recentPro, 0, recentViewedProNum)
	// Get recent viewed projects from database.
	proinfos, _ := models.GetRecentPros(recentViewedProNum)
	for _, p := range proinfos {
		recentViewedPros = append(recentViewedPros,
			&recentPro{
				Path:       p.Path,
				ViewedTime: p.ViewedTime,
				IsGoRepo:   p.ProName == "Go",
				Views:      p.Views,
			})
	}

	// Initialized language type list.
	langs := strings.Split(beego.AppConfig.String("language"), "|")
	names := strings.Split(beego.AppConfig.String("langNames"), "|")
	langTypes = make([]*langType, 0, len(langs))
	for i, v := range langs {
		langTypes = append(langTypes, &langType{
			Lang: v,
			Name: names[i],
		})
	}
}
Esempio n. 2
0
func init() {
	// Initialized recent viewed project list.
	num, err := beego.AppConfig.Int("recentViewedProNum")
	if err == nil {
		recentViewedProNum = num
		beego.Trace("Loaded 'recentViewedProNum' -> value:", recentViewedProNum)
	} else {
		beego.Trace("Failed to load 'recentViewedProNum' -> Use default value:", recentViewedProNum)
	}

	recentViewedPros = make([]*recentPro, 0, recentViewedProNum)
	// Get recent viewed projects from database.
	proinfos, _ := models.GetRecentPros(recentViewedProNum)
	for _, p := range proinfos {
		// Only projects with import path length is less than 40 letters will be showed.
		if len(p.Path) < 40 {
			recentViewedPros = append(recentViewedPros,
				&recentPro{
					Path:       p.Path,
					Synopsis:   p.Synopsis,
					ViewedTime: p.ViewedTime,
					IsGoRepo: p.ProName == "Go" &&
						strings.Index(p.Path, ".") == -1,
				})
		}
	}

	// Initialize project tags.
	labelList = strings.Split(beego.AppConfig.String("labels"), "|")
	for _, s := range labelList {
		labelSet += "&quot;" + s + "&quot;,"
	}
	labelSet = labelSet[:len(labelSet)-1]
}