Compare commits
2 Commits
82faacb9ec
...
523bdb24cd
Author | SHA1 | Date | |
---|---|---|---|
523bdb24cd | |||
376a1264f5 |
@ -50,6 +50,17 @@ func ServeArticle(c *b.Config, db *b.DB) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Fprint(w, content)
|
||||
article.Clicks++
|
||||
if err = db.UpdateAttributes(&b.Attribute{Table: "articles", ID: article.ID, AttName: "clicks", Value: article.Clicks}); err != nil {
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err = fmt.Fprint(w, content); err != nil {
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -121,6 +121,7 @@ func SubmitArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
||||
Rejected: false,
|
||||
IsInIssue: r.PostFormValue("issue") == "on",
|
||||
AutoGenerated: false,
|
||||
EditedID: 0,
|
||||
}
|
||||
|
||||
if len(article.Title) == 0 {
|
||||
|
@ -34,7 +34,8 @@ CREATE TABLE articles (
|
||||
rejected BOOL NOT NULL,
|
||||
creator_id INT NOT NULL,
|
||||
issue_id INT NOT NULL,
|
||||
edited_id INT,
|
||||
edited_id INT NOT NULL,
|
||||
clicks INT NOT NULL,
|
||||
is_in_issue BOOL NOT NULL,
|
||||
auto_generated BOOL NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
@ -49,24 +50,24 @@ CREATE TABLE tags (
|
||||
);
|
||||
|
||||
CREATE TABLE articles_authors (
|
||||
article_id INT,
|
||||
author_id INT,
|
||||
article_id INT NOT NULL,
|
||||
author_id INT NOT NULL,
|
||||
PRIMARY KEY (article_id, author_id),
|
||||
FOREIGN KEY (article_id) REFERENCES articles (id),
|
||||
FOREIGN KEY (author_id) REFERENCES users (id)
|
||||
);
|
||||
|
||||
CREATE TABLE articles_contributors (
|
||||
article_id INT,
|
||||
contributor_id INT,
|
||||
article_id INT NOT NULL,
|
||||
contributor_id INT NOT NULL,
|
||||
PRIMARY KEY (article_id, contributor_id),
|
||||
FOREIGN KEY (article_id) REFERENCES articles (id),
|
||||
FOREIGN KEY (contributor_id) REFERENCES users (id)
|
||||
);
|
||||
|
||||
CREATE TABLE articles_tags (
|
||||
article_id INT,
|
||||
tag_id INT,
|
||||
article_id INT NOT NULL,
|
||||
tag_id INT NOT NULL,
|
||||
PRIMARY KEY (article_id, tag_id),
|
||||
FOREIGN KEY (article_id) REFERENCES articles (id),
|
||||
FOREIGN KEY (tag_id) REFERENCES tags (id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user