Fixing more stuff
This commit is contained in:
@@ -36,7 +36,7 @@ func Article(w http.ResponseWriter, r *http.Request) {
|
||||
Error500(w, r)
|
||||
} else {
|
||||
var authors, tags []string
|
||||
database.GetDB().Table("author").Select("id").Where("id IN (?)", database.GetDB().Table("article_author").Select("author_id").Where("article_id = ?", article.Id)).Find(&authors)
|
||||
database.GetDB().Table("author").Select("name").Where("id IN (?)", database.GetDB().Table("article_author").Select("author_id").Where("article_id = ?", article.Id)).Find(&authors)
|
||||
database.GetDB().Table("article_tag").Where("article_id = ?", article.Id).Find(&tags)
|
||||
|
||||
ta := tmplArticle{
|
||||
|
||||
23
server/assets.go
Normal file
23
server/assets.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"TheAdversary/database"
|
||||
"github.com/gorilla/mux"
|
||||
"mime"
|
||||
"net/http"
|
||||
"path"
|
||||
)
|
||||
|
||||
func Assets(w http.ResponseWriter, r *http.Request) {
|
||||
assetName := mux.Vars(r)["asset"]
|
||||
var buf []interface{}
|
||||
database.GetDB().Table("assets").Select("data").Find(&buf, "link = ?", assetName)
|
||||
|
||||
if buf == nil {
|
||||
Error404(w, r)
|
||||
} else {
|
||||
data := buf[0].([]byte)
|
||||
w.Header().Set("Content-Type", mime.TypeByExtension(path.Ext(assetName)))
|
||||
w.Write(data)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user