diff --git a/internal/post/article.go b/internal/post/article.go
index 18c44a8c..19b59644 100644
--- a/internal/post/article.go
+++ b/internal/post/article.go
@@ -17,13 +17,14 @@ import (
// ArContent represent article content
type ArContent struct {
- ID string `json:"id"`
- Title string `json:"title"`
- Tags []string `json:"tags"`
- MD string `json:"md"`
- Render string `json:"render"`
- Lang string `json:"lang"`
- Status int `json:"status"`
+ ID string `json:"id"`
+ Title string `json:"title"`
+ Tags []string `json:"tags"`
+ MD string `json:"md"`
+ Render string `json:"render"`
+ Lang string `json:"lang"`
+ Status int `json:"status"`
+ CoverImage string `json:"cover_image"`
}
// NewArticle create a new article
@@ -57,11 +58,11 @@ func NewArticle(c echo.Context) error {
words := countWords(ar.MD)
var q *gocql.Query
if opType == PostDraft {
- q = misc.CQL.Query(`INSERT INTO article (id,uid,title,tags,md,render,words,status,edit_date,lang)
- VALUES (?,?,?,?,?,?,?,?,?,?)`, ar.ID, sess.ID, ar.Title, ar.Tags, ar.MD, ar.Render, words, PostDraft, time.Now().Unix(), ar.Lang)
+ q = misc.CQL.Query(`INSERT INTO article (id,uid,title,tags,md,render,words,status,edit_date,lang,cover_image)
+ VALUES (?,?,?,?,?,?,?,?,?,?,?)`, ar.ID, sess.ID, ar.Title, ar.Tags, ar.MD, ar.Render, words, PostDraft, time.Now().Unix(), ar.Lang, ar.CoverImage)
} else { // publish
- q = misc.CQL.Query(`INSERT INTO article (id,uid,title,tags,md,render,words,status,publish_date,edit_date,lang)
- VALUES (?,?,?,?,?,?,?,?,?,?,?)`, ar.ID, sess.ID, ar.Title, ar.Tags, ar.MD, ar.Render, words, PostPublished, time.Now().Unix(), 0, ar.Lang)
+ q = misc.CQL.Query(`INSERT INTO article (id,uid,title,tags,md,render,words,status,publish_date,edit_date,lang,cover_image)
+ VALUES (?,?,?,?,?,?,?,?,?,?,?,?)`, ar.ID, sess.ID, ar.Title, ar.Tags, ar.MD, ar.Render, words, PostPublished, time.Now().Unix(), 0, ar.Lang, ar.CoverImage)
}
err = q.Exec()
if err != nil {
@@ -92,6 +93,7 @@ type ArticleDetail struct {
Words int `json:"words"`
Likes int `json:"likes"` // all likes of this article
Liked bool `json:"liked"` // current user liked this article
+ CoverImage string `json:"cover_image"`
pubDate int64
editDate int64
}
@@ -107,8 +109,8 @@ func GetArticleDetail(c echo.Context) error {
}
detail := &ArticleDetail{ID: arID}
- err := misc.CQL.Query(`SELECT uid,title,tags,render,words,status,publish_date,edit_date,lang FROM article WHERE id=?`, arID).Scan(
- &detail.UID, &detail.Title, &detail.Tags, &detail.Render, &detail.Words, &detail.Status, &detail.pubDate, &detail.editDate, &detail.Lang,
+ err := misc.CQL.Query(`SELECT uid,title,tags,render,words,status,publish_date,edit_date,lang,cover_image FROM article WHERE id=?`, arID).Scan(
+ &detail.UID, &detail.Title, &detail.Tags, &detail.Render, &detail.Words, &detail.Status, &detail.pubDate, &detail.editDate, &detail.Lang, &detail.CoverImage,
)
if err != nil {
if err.Error() == misc.CQLNotFound {
diff --git a/quick-start/cql/start.cql b/quick-start/cql/start.cql
index 8ed9b6d8..51ec404d 100644
--- a/quick-start/cql/start.cql
+++ b/quick-start/cql/start.cql
@@ -41,6 +41,7 @@ CREATE TABLE IF NOT EXISTS article (
render text, -- rendered html
status tinyint, -- 1. draft 2. published 3. delete
words int, -- word count
+ cover_image text,
publish_date bigint,
edit_date bigint,
diff --git a/ui/src/theme/style.less b/ui/src/theme/style.less
index d7985272..3bf2f39e 100644
--- a/ui/src/theme/style.less
+++ b/ui/src/theme/style.less
@@ -18,7 +18,7 @@
.padding-right-5 {padding-right: 5px}.padding-right-10 {padding-right: 10px};.padding-right-15 {padding-right: 15px};.padding-right-20 {padding-right: 20px};
-.padding-top-5 {padding-top: 5px};.padding-top-10 {padding-top: 10px};.padding-top-15 {padding-top: 15px};.padding-top-20 {padding-top: 20px};.padding-top-40 {padding-top: 40px};.padding-top-60 {padding-top: 60px};
+.padding-top-5 {padding-top: 5px};.padding-top-10 {padding-top: 10px};.padding-top-15 {padding-top: 15px};.padding-top-20 {padding-top: 20px};.padding-top-40 {padding-top: 40px};.padding-top-50 {padding-top: 650px};.padding-top-55 {padding-top: 55px};.padding-top-60 {padding-top: 60px};
.padding-bottom-5 { padding-bottom: 5px};.padding-bottom-10 {padding-bottom: 10px};.padding-bottom-15 {padding-bottom: 15px};.padding-bottom-20 {padding-bottom: 20px};.padding-bottom-30 {padding-bottom: 30px};.padding-bottom-40 {padding-bottom: 40px};
@@ -29,7 +29,7 @@
.width-100p {width: 100%};
-.max-width-300 {width: 300px}
+.max-width-280 {width: 280px};.max-width-300 {width: 300px}
/* ----------------------------font------------------------ */
.font-size-12 {font-size:12px;};.font-size-13 {font-size:13px;};.font-size-14 {font-size:14px;};.font-size-15 {font-size:15px;};.font-size-16 {font-size:16px;};.font-size-18 {font-size:18px;};.font-size-20 {font-size:20px;};.font-size-22 {font-size:22px;};.font-size-24 {font-size:24px;};
diff --git a/ui/src/views/article/detail.vue b/ui/src/views/article/detail.vue
index 02947b7e..be321059 100644
--- a/ui/src/views/article/detail.vue
+++ b/ui/src/views/article/detail.vue
@@ -51,18 +51,19 @@
+
{{arDetail.title}}
{{arDetail.publish_date}} · {{arDetail.words}} words · Updated on {{arDetail.edit_date}}
-
+
-
-
+
+
@@ -70,8 +71,8 @@
diff --git a/ui/src/views/article/edit.vue b/ui/src/views/article/edit.vue
index 75dd34dd..b41a4a1a 100644
--- a/ui/src/views/article/edit.vue
+++ b/ui/src/views/article/edit.vue
@@ -147,6 +147,7 @@ export default {
}
this.tempArticle.render = this.tempRender
+ this.tempArticle.cover_image = 'https://res.cloudinary.com/practicaldev/image/fetch/s--irWUM2_k--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://res.cloudinary.com/practicaldev/image/fetch/s--5kGvHb_---/c_imagga_scale%2Cf_auto%2Cfl_progressive%2Ch_420%2Cq_auto%2Cw_1000/https://thepracticaldev.s3.amazonaws.com/i/adfopvch5w18u9lqpev9.jpg'
request({
url: "/web/article/saveNew",
method: "POST",
diff --git a/ui/src/views/nav.vue b/ui/src/views/nav.vue
index 09d48894..0ab3a9c4 100644
--- a/ui/src/views/nav.vue
+++ b/ui/src/views/nav.vue
@@ -110,7 +110,7 @@
-
+