Compare commits
14 Commits
8147d9bef6
...
v0.7.0
Author | SHA1 | Date | |
---|---|---|---|
ec752b1c66 | |||
46aef4f12f | |||
1b29e328cf | |||
e50cb819f3 | |||
c32e38ca10 | |||
d7c8c7a43a | |||
1cd3edc90c | |||
0e768c9f61 | |||
1fcd775cc5 | |||
203a1ed147 | |||
ef1914ee5c | |||
084b101e31 | |||
b2db128aa9 | |||
081e880fb6 |
@ -35,8 +35,7 @@ func ServeArticle(c *b.Config, db *b.DB) http.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
articleAbsName := fmt.Sprint(c.ArticleDir, "/", article.ID, ".md")
|
contentBytes, err := os.ReadFile(article.Link)
|
||||||
contentBytes, err := os.ReadFile(articleAbsName)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
@ -94,7 +94,7 @@ func SubmitArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
article.Link = fmt.Sprint(c.Domain, "/article/serve/", article.ID)
|
article.Link = fmt.Sprint("http://", c.Domain, c.Port, "/article/serve/", article.ID)
|
||||||
if err = db.UpdateAttributes(&b.Attribute{Table: "articles", ID: article.ID, AttName: "link", Value: article.Link}); err != nil {
|
if err = db.UpdateAttributes(&b.Attribute{Table: "articles", ID: article.ID, AttName: "link", Value: article.Link}); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
@ -521,16 +521,9 @@ func ShowPublishedArticles(c *b.Config, db *b.DB, s *b.CookieStore) http.Handler
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredArticles := make([]*b.Article, 0)
|
|
||||||
for _, article := range publishedArticles {
|
|
||||||
if article.Title != "Autogenerated cpolis Issue Article" {
|
|
||||||
filteredArticles = append(filteredArticles, article)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/published-articles.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/published-articles.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
tmpl.ExecuteTemplate(w, "page-content", filteredArticles)
|
tmpl.ExecuteTemplate(w, "page-content", publishedArticles)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -579,8 +572,7 @@ func ReviewArticleForDeletion(c *b.Config, db *b.DB, s *b.CookieStore) http.Hand
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
articleAbsName := fmt.Sprint(c.ArticleDir, "/", article.ID, ".md")
|
contentBytes, err := os.ReadFile(article.Link)
|
||||||
contentBytes, err := os.ReadFile(articleAbsName)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
@ -628,12 +620,6 @@ func DeleteArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = os.Remove(fmt.Sprint(c.ArticleDir, "/", id, ".md")); err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
feed, err := b.GenerateRSS(c, db)
|
feed, err := b.GenerateRSS(c, db)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
@ -60,7 +60,7 @@ func PublishLatestIssue(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFun
|
|||||||
|
|
||||||
article := &b.Article{
|
article := &b.Article{
|
||||||
Title: "Autogenerated cpolis Issue Article",
|
Title: "Autogenerated cpolis Issue Article",
|
||||||
EncURL: fmt.Sprint(c.Domain, "/image/serve/", imgFileName),
|
EncURL: fmt.Sprint("http://", c.Domain, c.Port, "/image/serve/", imgFileName),
|
||||||
EncLength: int(imgSize),
|
EncLength: int(imgSize),
|
||||||
EncType: mimeType,
|
EncType: mimeType,
|
||||||
Published: true,
|
Published: true,
|
||||||
@ -84,7 +84,7 @@ func PublishLatestIssue(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFun
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
article.Link = fmt.Sprint(c.Domain, "/article/serve/", article.ID)
|
article.Link = fmt.Sprint("http://", c.Domain, c.Port, "/article/serve/", article.ID)
|
||||||
if err = db.UpdateAttributes(&b.Attribute{Table: "articles", ID: article.ID, AttName: "link", Value: article.Link}); err != nil {
|
if err = db.UpdateAttributes(&b.Attribute{Table: "articles", ID: article.ID, AttName: "link", Value: article.Link}); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
@ -43,15 +43,13 @@ chmod +x $CPOLIS_DIR/tailwindcss
|
|||||||
$CPOLIS_DIR/tailwindcss -i $CPOLIS_DIR/web/static/css/input.css -o $CPOLIS_DIR/web/static/css/style.css
|
$CPOLIS_DIR/tailwindcss -i $CPOLIS_DIR/web/static/css/input.css -o $CPOLIS_DIR/web/static/css/style.css
|
||||||
|
|
||||||
echo '\nBuilding cpolis...' >&2
|
echo '\nBuilding cpolis...' >&2
|
||||||
cd $CPOLIS_DIR
|
go build -o $TMP_DIR/cpolis $CPOLIS_DIR/cmd/main.go
|
||||||
go build -o $BIN_DIR/cpolis cmd/main.go
|
|
||||||
cd
|
|
||||||
|
|
||||||
echo '\nSetting up system files...' >&2
|
echo '\nSetting system files up...' >&2
|
||||||
|
sudo mv $TMP_DIR/cpolis $BIN_DIR/cpolis
|
||||||
sudo chown root:root $BIN_DIR/cpolis
|
sudo chown root:root $BIN_DIR/cpolis
|
||||||
chmod +x $BIN_DIR/cpolis
|
chmod +x $BIN_DIR/cpolis
|
||||||
|
|
||||||
echo '\nSetting up service...' >&2
|
|
||||||
sudo mv $CPOLIS_DIR/cpolis.service $SYSTEMD_DIR
|
sudo mv $CPOLIS_DIR/cpolis.service $SYSTEMD_DIR
|
||||||
sudo chown root:root $SYSTEMD_DIR/cpolis.service
|
sudo chown root:root $SYSTEMD_DIR/cpolis.service
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
|
Reference in New Issue
Block a user