Example #1
0
func (tm *Module) Install(ctx *pucore.ModuleContext) error {
	database := new(app.Db)
	ctx.Injector.Get(database)

	// insert theme setting as default setting
	setting := &setting.Setting{
		Name:   "theme",
		UserId: 9,
	}
	setting.Encode(&Theme{
		Name:        "pugo",
		Description: "pugo's default beautiful and responsive theme",
		Homepage:    "https://github.com/go-xiaohei/pugo",
		Tags:        []string{"blog", "rss", "syntax highlighting"},
		License:     "MIT",
		MinVersion:  "2.0",
		Author: struct {
			Name     string
			Homepage string
		}{
			Name:     "fuxiaohei",
			Homepage: "https://github.com/fuxiaohei",
		},
	})
	if _, err := database.Insert(setting); err != nil {
		return err
	}
	return nil
}
Example #2
0
func (um *Module) Install(ctx *pucore.ModuleContext) error {
	database := new(app.Db)
	ctx.Injector.Get(database)
	var err error
	if err = database.Sync2(new(User)); err != nil {
		return err
	}

	// insert default user
	user := &User{
		Id:        9,
		Name:      "admin",
		Email:     "*****@*****.**",
		Nick:      "admin",
		Profile:   "this is administrator",
		Role:      USER_ROLE_ADMIN,
		Status:    USER_STATUS_ACTIVE,
		AvatarUrl: utils.Gravatar("*****@*****.**"),
	}
	user.SetPassword("123456789")
	if _, err := database.Insert(user); err != nil {
		return err
	}
	return nil
}
Example #3
0
func (am *Module) Install(ctx *pucore.ModuleContext) error {
	database := new(app.Db)
	ctx.Injector.Get(database)
	var err error
	if err = database.Sync2(new(Token)); err != nil {
		return err
	}
	return nil
}
Example #4
0
func (sm *Module) Install(ctx *pucore.ModuleContext) error {
	database := new(app.Db)
	ctx.Injector.Get(database)
	var err error
	if err = database.Sync2(new(Setting)); err != nil {
		return err
	}

	// insert settings
	setting := &Setting{
		Name:   "general",
		UserId: 9,
	}
	setting.Encode(&SettingGeneral{
		Title:          "PUGO",
		SubTitle:       "Simple Blog Engine",
		Keyword:        "pugo,blog,go,golang",
		Description:    "PUGO is a simple blog engine by golang",
		HostName:       "http://localhost",
		HeroImage:      "/img/bg.png",
		TopAvatarImage: "/img/logo.png",
	})

	/*
		setting2 := &Setting{
			Name:   "media",
			UserId: 0,
			Type:   "media",
		}
		setting2.Encode(&SettingMedia{
			MaxFileSize: 10 * 1024,
			ImageFile:   []string{"jpg", "jpeg", "png", "gif", "bmp", "vbmp"},
			DocFile:     []string{"txt", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf"},
			CommonFile:  []string{"zip", "rar"},
			DynamicLink: false,
		})

		setting3 := &Setting{
			Name:   "content",
			UserId: 0,
			Type:   "content",
		}
		setting3.Encode(&SettingContent{
			PageSize:         5,
			RSSFullText:      true,
			RSSNumberLimit:   0,
			TopPage:          0,
			PageDisallowLink: []string{"article", "archive", "feed", "comment", "admin", "sitemap"},
		})

		setting4 := &Setting{
			Name:   "comment",
			UserId: 0,
			Type:   "comment",
		}
		setting4.Encode(&SettingComment{
			IsPager:        false,
			PageSize:       10,
			Order:          "create_time DESC",
			CheckAll:       false,
			CheckNoPass:    true,
			CheckRefer:     true,
			AutoCloseDay:   30,
			SubmitDuration: 60,
			MaxLength:      512,
			MinLength:      2,
		})

		setting5 := &Setting{
			Name:   "menu",
			UserId: 0,
			Type:   "menu",
		}
		setting5.Encode([]*SettingMenu{
			{
				"Home", "/", "Home",
				false,
			},
			{
				"Archive", "/archive", "Archive",
				false,
			},
			{
				"About", "/about.html", "About",
				false,
			},
		})
	*/
	if _, err := database.Insert(setting); err != nil {
		return err
	}
	return nil
}