-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from xushiwei/frame
community framework
- Loading branch information
Showing
12 changed files
with
187 additions
and
242 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 |
---|---|---|
@@ -1,33 +1,35 @@ | ||
import "github.com/goplus/community/internal/core" | ||
import ( | ||
"github.com/goplus/community/internal/core" | ||
"github.com/goplus/community/markdown" | ||
) | ||
|
||
// TODO: Config Init | ||
config := &core.Config{ | ||
core.ArticleConfig{}, | ||
} | ||
community := core.New(config) | ||
|
||
get "/article/:id", ctx => { | ||
param := ctx.param("id") | ||
println "Visiting article " + param | ||
|
||
h := community.GetArticleHandler() | ||
info, _ := h.GetArticle(param) | ||
var ( | ||
community *core.Community | ||
) | ||
|
||
get "/p/:id", ctx => { | ||
id := ctx.param("id") | ||
article, _ := community.article(id) | ||
html, _ := markdown.render(article.Content) | ||
ctx.yap "article", { | ||
"id": info.Id, | ||
"title": info.Title, | ||
"content": info.Content, | ||
"ID": id, | ||
"Title": article.Title, | ||
"Body": string(html), | ||
} | ||
} | ||
get "/", ctx => { | ||
articles, _, _ := community.listArticle(core.MarkBegin, 20) | ||
ctx.yap "home", { | ||
"Items": articles, | ||
} | ||
} | ||
get "/user/:id", ctx => { | ||
ctx.yap "user", { | ||
"id": ctx.param("id"), | ||
get "/edit", ctx => { | ||
ctx.yap "edit", { | ||
"ID": ctx.param("id"), | ||
} | ||
} | ||
|
||
println "Community server running on :8080" | ||
config := &core.Config{} | ||
community, _ = core.New(config) | ||
|
||
run ":8080" |
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
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 |
---|---|---|
|
@@ -3,6 +3,6 @@ | |
<meta charset="utf-8"/> | ||
</head> | ||
<body> | ||
Markdown Edit Page. | ||
Edit {{.ID}} | ||
</body> | ||
</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
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.