Skip to content

Commit

Permalink
update slide 4
Browse files Browse the repository at this point in the history
  • Loading branch information
astaxie committed Jun 2, 2014
1 parent e985b8f commit 3ffd214
Show file tree
Hide file tree
Showing 16 changed files with 2,313 additions and 0 deletions.
21 changes: 21 additions & 0 deletions zh/4/base.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
type baseController struct {
beego.Controller
i18n.Locale
user models.User
isLogin bool
}

// Prepare implemented Prepare method for baseRouter.
func (this *baseController) Prepare() {
// page start time
this.Data["PageStartTime"] = time.Now()
// Setting properties.
this.Data["AppDescription"] = utils.AppDescription
this.Data["AppKeywords"] = utils.AppKeywords
this.Data["AppName"] = utils.AppName
this.Data["AppVer"] = utils.AppVer
this.Data["AppUrl"] = utils.AppUrl
this.Data["AppLogo"] = utils.AppLogo
this.Data["AvatarURL"] = utils.AvatarURL
this.Data["IsProMode"] = utils.IsProMode
}
23 changes: 23 additions & 0 deletions zh/4/base_call.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
type NestPreparer interface {
NestPrepare()
}

func (this *baseController) Prepare() {

// page start time
this.Data["PageStartTime"] = time.Now()

// Setting properties.
this.Data["AppDescription"] = utils.AppDescription
this.Data["AppKeywords"] = utils.AppKeywords
this.Data["AppName"] = utils.AppName
this.Data["AppVer"] = utils.AppVer
this.Data["AppUrl"] = utils.AppUrl
this.Data["AppLogo"] = utils.AppLogo
this.Data["AvatarURL"] = utils.AvatarURL
this.Data["IsProMode"] = utils.IsProMode

if app, ok := this.AppController.(NestPreparer); ok {
app.NestPrepare()
}
}
28 changes: 28 additions & 0 deletions zh/4/controller.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
type AddController struct {
beego.Controller
}

func (this *AddController) Get() {
this.Data["content"] = "value"
this.Layout = "admin/layout.html"
this.TplNames = "admin/add.tpl"
}

func (this *AddController) Post() {
pkgname := this.GetString("pkgname")
content := this.GetString("content")
pk := models.GetCruPkg(pkgname)
if pk.Id == 0 {
var pp models.PkgEntity
pp.Pid = 0
pp.Pathname = pkgname
pp.Intro = pkgname
models.InsertPkg(pp)
pk = models.GetCruPkg(pkgname)
}
var at models.Article
at.Pkgid = pk.Id
at.Content = content
models.InsertArticle(at)
this.Ctx.Redirect(302, "/admin/index")
}
Loading

0 comments on commit 3ffd214

Please sign in to comment.