Delete content link from everywhere since it is only a combination of already saved info
This commit is contained in:
parent
f663592019
commit
dbddff6e55
@ -13,7 +13,6 @@ type Article struct {
|
|||||||
Title string
|
Title string
|
||||||
BannerLink string
|
BannerLink string
|
||||||
Summary string
|
Summary string
|
||||||
ContentLink string
|
|
||||||
ID int64
|
ID int64
|
||||||
AuthorID int64
|
AuthorID int64
|
||||||
IssueID int64
|
IssueID int64
|
||||||
@ -30,8 +29,8 @@ func (db *DB) AddArticle(a *Article) (int64, error) {
|
|||||||
selectQuery := "SELECT id FROM issues WHERE published = false"
|
selectQuery := "SELECT id FROM issues WHERE published = false"
|
||||||
insertQuery := `
|
insertQuery := `
|
||||||
INSERT INTO articles
|
INSERT INTO articles
|
||||||
(title, banner_link, summary, content_link, published, rejected, author_id, issue_id, edited_id, is_in_issue, auto_generated)
|
(title, banner_link, summary, published, rejected, author_id, issue_id, edited_id, is_in_issue, auto_generated)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
`
|
`
|
||||||
|
|
||||||
for i := 0; i < TxMaxRetries; i++ {
|
for i := 0; i < TxMaxRetries; i++ {
|
||||||
@ -48,7 +47,7 @@ func (db *DB) AddArticle(a *Article) (int64, error) {
|
|||||||
return 0, fmt.Errorf("error getting issue ID when adding article to DB: %v", err)
|
return 0, fmt.Errorf("error getting issue ID when adding article to DB: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := tx.Exec(insertQuery, a.Title, a.BannerLink, a.Summary, a.ContentLink, a.Published, a.Rejected, a.AuthorID, id, a.EditedID, a.IsInIssue, a.AutoGenerated)
|
result, err := tx.Exec(insertQuery, a.Title, a.BannerLink, a.Summary, a.Published, a.Rejected, a.AuthorID, id, a.EditedID, a.IsInIssue, a.AutoGenerated)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
||||||
log.Fatalf("transaction error: %v, rollback error: %v", err, rollbackErr)
|
log.Fatalf("transaction error: %v, rollback error: %v", err, rollbackErr)
|
||||||
@ -82,7 +81,7 @@ func (db *DB) AddArticle(a *Article) (int64, error) {
|
|||||||
|
|
||||||
func (db *DB) GetArticle(id int64) (*Article, error) {
|
func (db *DB) GetArticle(id int64) (*Article, error) {
|
||||||
query := `
|
query := `
|
||||||
SELECT title, created, banner_link, summary, content_link, published, author_id, issue_id, edited_id, is_in_issue, auto_generated
|
SELECT title, created, banner_link, summary, published, author_id, issue_id, edited_id, is_in_issue, auto_generated
|
||||||
FROM articles
|
FROM articles
|
||||||
WHERE id = ?
|
WHERE id = ?
|
||||||
`
|
`
|
||||||
@ -92,7 +91,7 @@ func (db *DB) GetArticle(id int64) (*Article, error) {
|
|||||||
var created []byte
|
var created []byte
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if err := row.Scan(&article.Title, &created, &article.BannerLink, &article.Summary, &article.ContentLink, &article.Published, &article.AuthorID, &article.IssueID, &article.EditedID, &article.IsInIssue, &article.AutoGenerated); err != nil {
|
if err := row.Scan(&article.Title, &created, &article.BannerLink, &article.Summary, &article.Published, &article.AuthorID, &article.IssueID, &article.EditedID, &article.IsInIssue, &article.AutoGenerated); err != nil {
|
||||||
return nil, fmt.Errorf("error scanning article row: %v", err)
|
return nil, fmt.Errorf("error scanning article row: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +106,7 @@ func (db *DB) GetArticle(id int64) (*Article, error) {
|
|||||||
|
|
||||||
func (db *DB) GetCertainArticles(attribute string, value bool) ([]*Article, error) {
|
func (db *DB) GetCertainArticles(attribute string, value bool) ([]*Article, error) {
|
||||||
query := fmt.Sprintf(`
|
query := fmt.Sprintf(`
|
||||||
SELECT id, title, created, banner_link, summary, content_link, author_id, issue_id, published, rejected, is_in_issue, auto_generated
|
SELECT id, title, created, banner_link, summary, author_id, issue_id, published, rejected, is_in_issue, auto_generated
|
||||||
FROM articles
|
FROM articles
|
||||||
WHERE %s = ?
|
WHERE %s = ?
|
||||||
`, attribute)
|
`, attribute)
|
||||||
@ -121,7 +120,7 @@ func (db *DB) GetCertainArticles(attribute string, value bool) ([]*Article, erro
|
|||||||
article := new(Article)
|
article := new(Article)
|
||||||
var created []byte
|
var created []byte
|
||||||
|
|
||||||
if err = rows.Scan(&article.ID, &article.Title, &created, &article.BannerLink, &article.Summary, &article.ContentLink, &article.AuthorID, &article.IssueID, &article.Published, &article.Rejected, &article.IsInIssue, &article.AutoGenerated); err != nil {
|
if err = rows.Scan(&article.ID, &article.Title, &created, &article.BannerLink, &article.Summary, &article.AuthorID, &article.IssueID, &article.Published, &article.Rejected, &article.IsInIssue, &article.AutoGenerated); err != nil {
|
||||||
return nil, fmt.Errorf("error scanning article row: %v", err)
|
return nil, fmt.Errorf("error scanning article row: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +140,7 @@ func (db *DB) GetCurrentIssueArticles() ([]*Article, error) {
|
|||||||
txOptions := &sql.TxOptions{Isolation: sql.LevelSerializable}
|
txOptions := &sql.TxOptions{Isolation: sql.LevelSerializable}
|
||||||
issueQuery := "SELECT id FROM issues WHERE published = false"
|
issueQuery := "SELECT id FROM issues WHERE published = false"
|
||||||
articlesQuery := `
|
articlesQuery := `
|
||||||
SELECT id, title, created, banner_link, summary, content_link, author_id, auto_generated
|
SELECT id, title, created, banner_link, summary, author_id, auto_generated
|
||||||
FROM articles
|
FROM articles
|
||||||
WHERE issue_id = ? AND published = true AND is_in_issue = true
|
WHERE issue_id = ? AND published = true AND is_in_issue = true
|
||||||
`
|
`
|
||||||
@ -174,7 +173,7 @@ func (db *DB) GetCurrentIssueArticles() ([]*Article, error) {
|
|||||||
article := new(Article)
|
article := new(Article)
|
||||||
var created []byte
|
var created []byte
|
||||||
|
|
||||||
if err = rows.Scan(&article.ID, &article.Title, &created, &article.BannerLink, &article.Summary, &article.ContentLink, &article.AuthorID, &article.AutoGenerated); err != nil {
|
if err = rows.Scan(&article.ID, &article.Title, &created, &article.BannerLink, &article.Summary, &article.AuthorID, &article.AutoGenerated); err != nil {
|
||||||
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
if rollbackErr := tx.Rollback(); rollbackErr != nil {
|
||||||
log.Fatalf("transaction error: %v, rollback error: %v", err, rollbackErr)
|
log.Fatalf("transaction error: %v, rollback error: %v", err, rollbackErr)
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ func GenerateAtomFeed(c *Config, db *DB) (*string, error) {
|
|||||||
entry := atom.NewEntry(articleTitle)
|
entry := atom.NewEntry(articleTitle)
|
||||||
entry.ID = atom.NewID(fmt.Sprint("urn:entry:", article.ID))
|
entry.ID = atom.NewID(fmt.Sprint("urn:entry:", article.ID))
|
||||||
entry.Published = atom.NewDate(article.Created)
|
entry.Published = atom.NewDate(article.Created)
|
||||||
entry.Content = atom.NewContent(atom.OutOfLine, "text/hmtl", article.ContentLink)
|
entry.Content = atom.NewContent(atom.OutOfLine, "text/hmtl", fmt.Sprint(c.Domain, "/article/serve/", article.ID))
|
||||||
|
|
||||||
if article.AutoGenerated {
|
if article.AutoGenerated {
|
||||||
entry.Summary = atom.NewText("text", "automatically generated")
|
entry.Summary = atom.NewText("text", "automatically generated")
|
||||||
|
@ -118,13 +118,6 @@ func SubmitArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
article.ContentLink = fmt.Sprint(c.Domain, "/article/serve/", article.ID)
|
|
||||||
if err = db.UpdateAttributes(&b.Attribute{Table: "articles", ID: article.ID, AttName: "content_link", Value: article.ContentLink}); err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
tags := make([]int64, 0)
|
tags := make([]int64, 0)
|
||||||
for _, tag := range r.Form["tags"] {
|
for _, tag := range r.Form["tags"] {
|
||||||
|
@ -62,19 +62,6 @@ func PublishLatestIssue(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFun
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
article.ContentLink = fmt.Sprint(c.Domain, "/article/serve/", article.ID)
|
|
||||||
if err = db.UpdateAttributes(&b.Attribute{Table: "articles", ID: article.ID, AttName: "content_link", Value: article.ContentLink}); err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = db.UpdateAttributes(&b.Attribute{Table: "articles", ID: article.ID, AttName: "content_link", Value: article.ContentLink}); err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = db.AddArticleToCurrentIssue(article.ID); err != nil {
|
if err = db.AddArticleToCurrentIssue(article.ID); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
@ -28,7 +28,6 @@ CREATE TABLE articles (
|
|||||||
created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
banner_link VARCHAR(255) NOT NULL,
|
banner_link VARCHAR(255) NOT NULL,
|
||||||
summary TEXT NOT NULL,
|
summary TEXT NOT NULL,
|
||||||
content_link VARCHAR(255) NOT NULL,
|
|
||||||
published BOOL NOT NULL,
|
published BOOL NOT NULL,
|
||||||
rejected BOOL NOT NULL,
|
rejected BOOL NOT NULL,
|
||||||
author_id INT NOT NULL,
|
author_id INT NOT NULL,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user