Skip to content

Commit

Permalink
!18 dev
Browse files Browse the repository at this point in the history
Merge pull request !18 from 大猫猫/refactor-comments
  • Loading branch information
bbbbbbbbbbbbba authored and gitee-org committed Apr 22, 2020
2 parents 153f6dd + b568574 commit f2c248a
Show file tree
Hide file tree
Showing 11 changed files with 627 additions and 397 deletions.
2 changes: 2 additions & 0 deletions server/build.sh
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@

GOOS=linux GOARCH=386 go build

17 changes: 8 additions & 9 deletions server/controllers/render/render.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package render

import (
"html/template"
"strconv"
"strings"

Expand Down Expand Up @@ -115,13 +114,13 @@ func BuildArticle(article *model.Article) *model.ArticleResponse {

if article.ContentType == model.ContentTypeMarkdown {
mr := simple.NewMd(simple.MdWithTOC()).Run(article.Content)
rsp.Content = template.HTML(BuildHtmlContent(mr.ContentHtml))
rsp.Toc = template.HTML(mr.TocHtml)
rsp.Content = BuildHtmlContent(mr.ContentHtml)
rsp.Toc = mr.TocHtml
if len(rsp.Summary) == 0 {
rsp.Summary = mr.SummaryText
}
} else if article.ContentType == model.ContentTypeHtml {
rsp.Content = template.HTML(BuildHtmlContent(article.Content))
rsp.Content = BuildHtmlContent(article.Content)
if len(rsp.Summary) == 0 {
rsp.Summary = simple.GetSummary(article.Content, 256)
}
Expand Down Expand Up @@ -233,8 +232,8 @@ func BuildTopic(topic *model.Topic) *model.TopicResponse {
rsp.Tags = BuildTags(tags)

mr := simple.NewMd(simple.MdWithTOC()).Run(topic.Content)
rsp.Content = template.HTML(BuildHtmlContent(mr.ContentHtml))
rsp.Toc = template.HTML(mr.TocHtml)
rsp.Content = BuildHtmlContent(mr.ContentHtml)
rsp.Toc = mr.TocHtml

return rsp
}
Expand Down Expand Up @@ -333,11 +332,11 @@ func BuildProject(project *model.Project) *model.ProjectResponse {
rsp.CreateTime = project.CreateTime

if project.ContentType == model.ContentTypeHtml {
rsp.Content = template.HTML(BuildHtmlContent(project.Content))
rsp.Content = BuildHtmlContent(project.Content)
rsp.Summary = simple.GetSummary(simple.GetHtmlText(project.Content), 256)
} else {
mr := simple.NewMd().Run(project.Content)
rsp.Content = template.HTML(BuildHtmlContent(mr.ContentHtml))
rsp.Content = BuildHtmlContent(mr.ContentHtml)
rsp.Summary = mr.SummaryText
}

Expand Down Expand Up @@ -419,7 +418,7 @@ func _buildComment(comment *model.Comment, buildQuote bool) *model.CommentRespon
quote := _buildComment(services.CommentService.Get(comment.QuoteId), false)
if quote != nil {
ret.Quote = quote
ret.QuoteContent = template.HTML(quote.User.Nickname+":") + quote.Content
ret.QuoteContent = quote.User.Nickname + ":" + quote.Content
}
}
return ret
Expand Down
14 changes: 5 additions & 9 deletions server/model/response.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package model

import (
"html/template"
)

type UserInfo struct {
Id int64 `json:"id"`
Username string `json:"username"`
Expand Down Expand Up @@ -54,8 +50,8 @@ type ArticleSimpleResponse struct {

type ArticleResponse struct {
ArticleSimpleResponse
Content template.HTML `json:"content"`
Toc template.HTML `json:"toc"`
Content string `json:"content"`
Toc string `json:"toc"`
}

type NodeResponse struct {
Expand All @@ -82,8 +78,8 @@ type TopicSimpleResponse struct {
// 帖子详情返回实体
type TopicResponse struct {
TopicSimpleResponse
Content template.HTML `json:"content"`
Toc template.HTML `json:"toc"`
Content string `json:"content"`
Toc string `json:"toc"`
}

// 帖子列表返回实体
Expand Down Expand Up @@ -114,7 +110,7 @@ type ProjectSimpleResponse struct {
// 项目详情
type ProjectResponse struct {
ProjectSimpleResponse
Content template.HTML `json:"content"`
Content string `json:"content"`
}

type CommentResponse struct {
Expand Down
191 changes: 191 additions & 0 deletions site/assets/styles/comment.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
.comment-form {
background-color: #fff;
padding: 10px;
margin-bottom: 10px;

.comment-create {
/*border: 1px solid #f0f0f0;*/
border-radius: 4px;
overflow: hidden;
position: relative;
padding: 0;
box-sizing: border-box;

.comment-quote-info {
font-size: 13px;
color: #000;
margin-bottom: 3px;
font-weight: 600;

i {
font-size: 12px !important;
color: blue;
cursor: pointer;
}

i:hover {
color: red;
}
}

.comment-input-wrapper {
margin-bottom: 8px;

.text-input {
outline: none;
width: 100%;
height: 85px;
font-size: 14px;
padding: 10px 40px 10px 10px;
color: #54412e;
line-height: 16px;
max-width: 100%;
resize: none;
border: 1px solid #e9e9e9;
box-sizing: border-box;
border-radius: var(--jinsom-border-radius);
}
}

.comment-button-wrapper {
user-select: none;
display: flex;
float: right;
height: 30px;
line-height: 30px;

span {
color: #c2c2c2;
font-size: 13px;
margin-right: 5px;
}

button {
font-weight: 500;
}
}
}

.comment-not-login {
border: 1px solid #f0f0f0;
border-radius: 0px;
margin-bottom: 10px;
overflow: hidden;
position: relative;
padding: 10px;
box-sizing: border-box;

.comment-login-div {
color: #d5d5d5;
cursor: pointer;
border-radius: 3px;
padding: 0 10px;

a {
margin-left: 10px;
margin-right: 10px;
}
}
}
}

.comments {
background-color: #fff;
padding: 0 10px;

.comment {
padding: 8px 0;
overflow: hidden;

&:not(:last-child) {
border-bottom: 1px dashed #d1d1d1;
}

.comment-avatar {
float: left;
padding: 3px;
margin-right: 5px;

.avatar {
min-width: 36px;
min-height: 36px;
width: 36px;
height: 36px;
}
}

.comment-meta {
position: relative;
height: 36px;

.comment-nickname {
position: relative;
font-size: 14px;
font-weight: 800;
margin-right: 5px;
cursor: pointer;
color: #1abc9c;
text-decoration: none;
display: inline-block;
}

.comment-time {
font-size: 12px;
color: #999999;
line-height: 1;
display: inline-block;
position: relative;
}

.comment-reply {
float: right;
font-size: 12px;
}
}

.comment-content {
word-wrap: break-word;
word-break: break-all;
text-align: justify;
color: #4a4a4a;
font-size: 14px;
line-height: 1.6;
position: relative;
padding-left: 45px;
margin-top: -5px;
}

.comment-quote {
font-size: 12px;
padding: 10px 10px;
border-left: 2px solid #5978f3;

&::after {
content: '\201D';
font-family: Georgia, serif;
font-size: 60px;
font-weight: bold;
color: #aaa;
position: absolute;
right: 0px;
top: -18px;
}

.comment-quote-user {
display: flex;

.quote-nickname {
line-height: 20px;
font-weight: 700;
margin-left: 5px;
}

.quote-time {
line-height: 20px;
margin-left: 5px;
color: rgba(134, 142, 150, 0.8);
}
}
}
}
}
1 change: 1 addition & 0 deletions site/assets/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
@import "./article";
@import "./topic";
@import "./tweets";
@import "./comment";
@import "./link";
@import "./ad";
Loading

0 comments on commit f2c248a

Please sign in to comment.