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
44 changed files
with
633 additions
and
330 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,65 @@ | ||
package app | ||
|
||
import ( | ||
"github.com/jinzhu/gorm" | ||
"github.com/kataras/iris" | ||
"github.com/kataras/iris/mvc" | ||
"iosxc.com/levante/controllers" | ||
"iosxc.com/levante/repositories" | ||
"iosxc.com/levante/services" | ||
) | ||
|
||
const url_index = "/" | ||
const url_favicon = "/favicon.ico" | ||
const url_sitemap = "/sitemap.xml" | ||
const url_start = "/start" | ||
const url_about = "/about" | ||
const url_photo = "/photo" | ||
const url_post = "/post" | ||
const url_comment = "/comment" | ||
|
||
func InitRoute(application *iris.Application, config *AppConfig, database *gorm.DB) { | ||
application.Favicon(config.Home+"assets/statics/img/favicon.ico", url_favicon) | ||
|
||
indexCtrl := new(controllers.IndexController) | ||
postCtrl := new(controllers.PostController) | ||
commentCtrl := new(controllers.CommentController) | ||
photoCtrl := new(controllers.PhotoController) | ||
aboutCtrl := new(controllers.AboutController) | ||
startCtrl := new(controllers.StartController) | ||
sitemapCtrl := new(controllers.SiteMapController) | ||
|
||
cacheRepository := repositories.NewMemCacheRepository(2048) | ||
|
||
postRepository := repositories.NewPostRepository(database) | ||
linkRepository := repositories.NewLinkRepository(database) | ||
|
||
postService := services.NewPostService(postRepository,cacheRepository) | ||
linkService := services.NewLinkService(linkRepository) | ||
|
||
indexMvc := mvc.New(application.Party(url_index)) | ||
indexMvc.Register(postService) | ||
indexMvc.Handle(indexCtrl) | ||
|
||
postMvc := mvc.New(application.Party(url_post)) | ||
postMvc.Register(postService) | ||
postMvc.Handle(postCtrl) | ||
|
||
startMvc := mvc.New(application.Party(url_start)) | ||
startMvc.Register(linkService) | ||
startMvc.Handle(startCtrl) | ||
|
||
|
||
commentMvc := mvc.New(application.Party(url_comment)) | ||
commentMvc.Handle(commentCtrl) | ||
|
||
photoMvc := mvc.New(application.Party(url_photo)) | ||
photoMvc.Handle(photoCtrl) | ||
|
||
aboutMvc := mvc.New(application.Party(url_about)) | ||
aboutMvc.Handle(aboutCtrl) | ||
|
||
sitemapMvc := mvc.New(application.Party(url_sitemap)) | ||
sitemapMvc.Register(postService) | ||
sitemapMvc.Handle(sitemapCtrl) | ||
} |
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,15 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/kataras/iris/mvc" | ||
"iosxc.com/levante/services" | ||
) | ||
|
||
type AboutController struct { | ||
PostService services.PostService | ||
LinkService services.LinkService | ||
} | ||
|
||
func (this *AboutController) Get() mvc.Result { | ||
return ViewPagePlant("about") | ||
} |
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,38 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/kataras/iris" | ||
"github.com/kataras/iris/mvc" | ||
"iosxc.com/levante/model" | ||
) | ||
|
||
type BaseController struct { | ||
Ctx iris.Context | ||
} | ||
|
||
var ViewPageNotFound = mvc.View{ | ||
Name: "front/error.html", | ||
Data: model.RspDataPageNotFound, | ||
} | ||
|
||
var ViewPagePlant = func(html string) mvc.View { | ||
return mvc.View{ | ||
Name: "front/"+html+".html", | ||
} | ||
} | ||
|
||
var ViewPageWithDataMap = func(html string,dataMap iris.Map) mvc.View { | ||
return mvc.View{ | ||
Name: "front/"+html+".html", | ||
Data: dataMap, | ||
} | ||
} | ||
|
||
var ViewPageWithModel = func(html,key string,model interface{}) mvc.View { | ||
return mvc.View{ | ||
Name: "front/"+html+".html", | ||
Data: iris.Map{ | ||
key: model, | ||
}, | ||
} | ||
} |
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,15 @@ | ||
package controllers | ||
|
||
import "github.com/kataras/iris/mvc" | ||
|
||
type CommentController struct { | ||
BaseController | ||
} | ||
|
||
func (this *CommentController) ReadHandle() mvc.Result{ | ||
return ViewPageNotFound | ||
} | ||
|
||
func (this *CommentController) CreateHandle() mvc.Result{ | ||
return ViewPageNotFound | ||
} |
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,25 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/kataras/iris" | ||
"github.com/kataras/iris/mvc" | ||
"iosxc.com/levante/services" | ||
) | ||
|
||
type IndexController struct { | ||
PostService services.PostService | ||
LinkService services.LinkService | ||
} | ||
|
||
func (this *IndexController) Get() mvc.Result{ | ||
var postList = this.PostService.GetList(0,5) | ||
var mcList = this.PostService.GetMonthList() | ||
var tagList = this.PostService.GetTagList() | ||
var dataMap = iris.Map{} | ||
dataMap["postList"] = postList | ||
dataMap["monthList"] = mcList | ||
dataMap["tagList"] = tagList | ||
return ViewPageWithDataMap("index",dataMap) | ||
|
||
} | ||
|
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/kataras/iris/mvc" | ||
) | ||
|
||
type PhotoController struct { | ||
BaseController | ||
} | ||
|
||
func (this *PhotoController) ReadHandle() mvc.Result{ | ||
return ViewPageNotFound | ||
|
||
} | ||
|
||
func (this *PhotoController) IndexHandle() mvc.Result{ | ||
return ViewPageNotFound | ||
|
||
} | ||
|
||
func (this *PhotoController) UpdateHandle() mvc.Result{ | ||
return ViewPageNotFound | ||
|
||
} |
Oops, something went wrong.