pull/35/head
sunface 6 years ago
parent ca863975d0
commit 3d8f939a7d

@ -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 {

@ -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,

@ -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;};

@ -51,18 +51,19 @@
<el-col
:xs="{span:22,offset:2}"
:sm="{span:17,offset:3}"
:md="{span: 13,offset:5}"
:lg="{ span: 13, offset: 5 }"
:md="{span: 13,offset:4}"
:lg="{ span: 13, offset: 4 }"
>
<img :src="arDetail.cover_image" class="width-100p"></img>
<h1 class=" margin-top-30">{{arDetail.title}}</h1>
<div class="margin-left-5">
<span class="vertical-align-middle display-inline-block"><img :src="authorInfo.avatar" alt="" class="height-40 width-40"></span>
<span class="meta-word font-size-14 font-weight-500">{{arDetail.publish_date}}<span> · {{arDetail.words}} words</span> <span v-if="arDetail.edit_date!=''">· Updated on {{arDetail.edit_date}}</span></span>
</div>
<render :content="arDetail.render" style="min-height:400px" class="min-height-400 margin-top-30 padding-left-8"></render>
<render :content="arDetail.render" style="min-height:400px" class="min-height-400 margin-top-20 padding-left-8"></render>
</el-col>
<el-col :span="1" >
<UserCard class="user-card z-index-100 position-fixed margin-top-40 max-width-300" :user="authorInfo"></UserCard>
<el-col :span="1" :offset="1">
<UserCard class="user-card z-index-100 position-fixed margin-top-40 max-width-280 margin-left-20" :user="authorInfo"></UserCard>
</el-col>
</el-row>
@ -70,8 +71,8 @@
<el-col
:xs="{span:22,offset:2}"
:sm="{span:17,offset:3}"
:md="{span: 13,offset:5}"
:lg="{ span: 13, offset: 5 }"
:md="{span: 13,offset:4}"
:lg="{ span: 13, offset: 4 }"
>
<discuss id="discuss" :postID="this.arID" postType="1" :postAuthorID="authorInfo.id"></discuss>

@ -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",

@ -110,7 +110,7 @@
</el-col>
</el-row>
</transition>
<router-view class="main-view padding-top-60"></router-view>
<router-view class="main-view padding-top-55"></router-view>
<el-dialog class="white-bg-modal sign-in-modal" :visible.sync="signInModalVisible">
<el-row class="sign-in-panel text-align-center padding-top-20 padding-bottom-20">

Loading…
Cancel
Save