-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,431 changed files
with
142,347 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "debug", | ||
"remotePath": "", | ||
"port": 2345, | ||
"host": "127.0.0.1", | ||
"program": "${workspaceRoot}", | ||
"env": {}, | ||
"args": [], | ||
"showLog": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
appname = ONE | ||
httpport = 8080 | ||
runmode = dev | ||
|
||
uname=admin | ||
pwd=admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/astaxie/beego" | ||
"ONE/models" | ||
) | ||
|
||
type ACatController struct { | ||
beego.Controller | ||
} | ||
|
||
func (this *ACatController) Get() { | ||
this.TplName = "AdminCategory.html" | ||
|
||
op := this.Input().Get("op") | ||
|
||
switch op { | ||
case "add": | ||
name := this.Input().Get("name") | ||
if len(name) == 0 { | ||
break | ||
} | ||
err := models.AddCategory(name) | ||
if err != nil { | ||
beego.Error(err) | ||
} | ||
|
||
this.Redirect("/admin/acategory", 301) | ||
|
||
case "del": | ||
id := this.Input().Get("id") | ||
if len(id) == 0 { | ||
break | ||
} | ||
|
||
err := models.DeleteCategory(id) | ||
if err != nil { | ||
beego.Error(err) | ||
} | ||
this.Redirect("/admin/acategory", 301) | ||
return | ||
|
||
} | ||
|
||
var err error | ||
this.Data["Categories"], err = models.GetAllCategories() | ||
|
||
if err != nil { | ||
beego.Error(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/astaxie/beego" | ||
) | ||
|
||
type AdminController struct { | ||
beego.Controller | ||
} | ||
|
||
func (this *AdminController) Get() { | ||
this.TplName = "OneAdmin.html" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/astaxie/beego" | ||
"ONE/models" | ||
"net/http" | ||
) | ||
|
||
type ATopicController struct { | ||
beego.Controller | ||
http.Request | ||
} | ||
|
||
func (this *ATopicController) Get() { | ||
this.TplName = "AdminTopic.html" | ||
|
||
this.Data["IsLogin"] = checkAccount(this.Ctx) | ||
this.Data["IsTopic"] = true | ||
|
||
topics, err := models.GetAllTopics("", false, true) | ||
|
||
if err != nil { | ||
beego.Error(err) | ||
} else { | ||
this.Data["Topics"] = topics | ||
} | ||
} | ||
|
||
func (this *ATopicController) Post() { | ||
if !checkAccount(this.Ctx) { | ||
this.Redirect("/login", 302) | ||
return | ||
} | ||
|
||
// 解析表单 | ||
tid := this.Input().Get("tid") | ||
title := this.Input().Get("title") | ||
content := this.Input().Get("content") | ||
// content := this.Request.FormValue("editormd-html-code") | ||
category := this.Input().Get("category") | ||
label := this.Input().Get("label") | ||
summary := this.Input().Get("summary") | ||
|
||
var err error | ||
if len(tid) == 0 { | ||
err = models.AddTopic(title, category, label, summary, content) | ||
} else { | ||
err = models.ModifyTopic(tid, title, category, summary, content, label) | ||
} | ||
|
||
if err != nil { | ||
beego.Error(err) | ||
} | ||
|
||
// this.Redirect("/topic", 302) | ||
this.Redirect("/topic/view/"+tid, 302) | ||
} | ||
|
||
func (this *ATopicController) Add() { | ||
this.Data["IsLogin"] = checkAccount(this.Ctx) | ||
this.TplName = "topic_add.html" | ||
if !checkAccount(this.Ctx) { | ||
this.Redirect("/login", 302) | ||
return | ||
} | ||
|
||
categories, err := models.GetAllCategories() | ||
if err != nil { | ||
beego.Error(err) | ||
} | ||
this.Data["Categories"] = categories | ||
} | ||
|
||
func (this *ATopicController) View() { | ||
this.TplName = "topic_view.html" | ||
|
||
topic, err := models.GetTopic(this.Ctx.Input.Params()["0"]) | ||
if err != nil { | ||
beego.Error(err) | ||
this.Redirect("/", 302) | ||
return | ||
} | ||
|
||
this.Data["Topic"] = topic | ||
this.Data["Tid"] = this.Ctx.Input.Params()["0"] | ||
|
||
replies, err := models.GetAllReplies(this.Ctx.Input.Params()["0"]) | ||
if err != nil { | ||
beego.Error(err) | ||
return | ||
} | ||
|
||
this.Data["Replies"] = replies | ||
this.Data["IsLogin"] = checkAccount(this.Ctx) | ||
|
||
} | ||
|
||
func (this *ATopicController) Modify() { | ||
this.TplName = "topic_modify.html" | ||
|
||
tid := this.Input().Get("tid") | ||
topic, err := models.GetTopic(tid) | ||
if err != nil { | ||
beego.Error(err) | ||
this.Redirect("/", 302) | ||
return | ||
} | ||
|
||
this.Data["Topic"] = topic | ||
this.Data["Tid"] = tid | ||
|
||
categories, err := models.GetAllCategories() | ||
if err != nil { | ||
beego.Error(err) | ||
} | ||
this.Data["Categories"] = categories | ||
} | ||
|
||
func (this *ATopicController) Delete() { | ||
this.TplName = "topic.html" | ||
if !checkAccount(this.Ctx) { | ||
this.Redirect("/login", 302) | ||
return | ||
} | ||
|
||
err := models.DeleteTopic(this.Input().Get("tid")) | ||
// err := models.DeleteTopic(this.Ctx.Input.Params()["0"]) | ||
if err != nil { | ||
beego.Error(err) | ||
} | ||
this.Redirect("/topic", 302) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/astaxie/beego" | ||
"ONE/models" | ||
) | ||
|
||
type CategoryController struct { | ||
beego.Controller | ||
} | ||
|
||
func (this *CategoryController) Get() { | ||
this.Data["IsLogin"] = checkAccount(this.Ctx) | ||
op := this.Input().Get("op") | ||
|
||
switch op { | ||
case "add": | ||
name := this.Input().Get("name") | ||
if len(name) == 0 { | ||
break | ||
} | ||
err := models.AddCategory(name) | ||
if err != nil { | ||
beego.Error(err) | ||
} | ||
|
||
this.Redirect("category", 301) | ||
|
||
case "del": | ||
id := this.Input().Get("id") | ||
if len(id) == 0 { | ||
break | ||
} | ||
|
||
err := models.DeleteCategory(id) | ||
if err != nil { | ||
beego.Error(err) | ||
} | ||
this.Redirect("/category", 301) | ||
return | ||
|
||
} | ||
|
||
this.TplName = "category.html" | ||
this.Data["IsCategory"] = true | ||
|
||
var err error | ||
this.Data["Categories"], err = models.GetAllCategories() | ||
|
||
if err != nil { | ||
beego.Error(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/astaxie/beego" | ||
//"strconv" | ||
"ONE/models" | ||
) | ||
|
||
type MainController struct { | ||
beego.Controller | ||
} | ||
|
||
func (c *MainController) Get() { | ||
c.Data["IsHome"] = true | ||
c.TplName = "home.html" | ||
c.Data["IsLogin"] = checkAccount(c.Ctx) | ||
|
||
topics, err := models.GetAllTopics(c.Input().Get("cate"), true, false) | ||
if err != nil { | ||
beego.Error(err) | ||
} else { | ||
c.Data["Topics"] = topics | ||
} | ||
|
||
categories, err := models.GetAllCategories() | ||
if err != nil { | ||
beego.Error(err) | ||
} | ||
|
||
c.Data["Categories"] = categories | ||
|
||
// 模板使用 | ||
// c.Data["Website"] = "golang.org" | ||
// c.Data["Email"] = "[email protected]" | ||
|
||
// c.Data["Truecond"] = true | ||
// c.Data["Falsecond"] = false | ||
|
||
// type u struct { | ||
// Name string | ||
// Age int | ||
// Sex string | ||
// } | ||
|
||
// user := &u{ | ||
// Name: "GoBlog", | ||
// Age: 9, | ||
// Sex: "nil", | ||
// } | ||
|
||
// c.Data["user"] = user | ||
|
||
// nums := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0} | ||
|
||
// c.Data["Nums"] = nums | ||
|
||
// c.Data["GO"] = "hello GO" | ||
|
||
// c.Data["html"] = "<div> Hello Beego</div>" | ||
|
||
// c.Data["Pipe"] = "<div>Hello Beego</div>" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/astaxie/beego" | ||
) | ||
|
||
type ErrorController struct { | ||
beego.Controller | ||
} | ||
|
||
func (this *ErrorController) Error404() { | ||
this.Data["content"] = "page not found" | ||
this.TplName = "404.html" | ||
} | ||
|
||
func (this *ErrorController) Error501() { | ||
this.Data["content"] = "server error" | ||
this.TplName = "500.html" | ||
} | ||
|
||
// func (this *ErrorController) ErrorDb() { | ||
// this.Data["content"] = "database is now down" | ||
// this.TplName = "dberror.tpl" | ||
// } |
Oops, something went wrong.