Skip to content

Commit

Permalink
change cut preview, add nsfw filter
Browse files Browse the repository at this point in the history
  • Loading branch information
RusovDmitriy committed Apr 24, 2018
1 parent b024c28 commit 6f548a3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 33 deletions.
16 changes: 9 additions & 7 deletions client/src/components/chains/feed/FeedArticle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
@click.prevent="show"
v-if="post.image !== DEFAULT_IMAGE"
:style="`background-image: url('${post.image}')`">
<div class="nsfw-image"
v-if="post.nsfw && post.nsfw !== 'show'"
@click.stop.prevent="post.nsfw = 'show'">
{{$t('chains.imageIsHidden')}}
</div>
</a>
<div class="feed__post-content">
<div class="feed__post-reposted" v-if="isRepost">
Expand All @@ -14,12 +19,12 @@
class="feed__repost-avatar"
:style="`background-image: url('${post.reblog_avatars[0]}');`"
></span>
<router-link tag="a" :to="{name:'chain-account-view', params:{chain: chain, username:post.author}}" class="link link--op">
<router-link tag="a" :to="{name:'chain-account-view', params:{chain: chain, username:post.reblog_by[0]}}" class="link link--op">
{{post.reblog_by[0]}}
</router-link>
</div>

<h3 class="feed__post-title h3" :class="{'lines-2x': lines2x, 'lines-1x': lines1x}">
<h3 class="feed__post-title h3">
<a
:href="link"
@click.prevent="show"
Expand All @@ -28,7 +33,7 @@
{{post.title}}
</a>
</h3>
<p class="feed__post-text">
<p class="feed__post-text" :class="{'lines-2x': lines2x, 'lines-1x': lines1x}">
<a
:href="link"
@click.prevent="show"
Expand Down Expand Up @@ -103,11 +108,8 @@ export default {
link() {
return this.$helper.makePathForPost(this.post, this.chain)
},
cutTitle() {
return parser.cutTitle(this.chain, this.post.title)
},
cutPreview() {
return parser.cutPreview(this.chain, this.post.preview, this.isRepost)
return parser.cutPreview(this.post.preview)
},
isRepost() {
return this.post.reblog_by.length > 0
Expand Down
18 changes: 11 additions & 7 deletions client/src/components/chains/profile/ProfileBlogArticle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
v-if="post.image !== DEFAULT_IMAGE"
class="feed__post-image"
:style="`background-image: url('${post.image}')`">
<div class="nsfw-image"
v-if="post.nsfw && post.nsfw !== 'show'"
@click.stop.prevent="post.nsfw = 'show'">
{{$t('chains.imageIsHidden')}}
</div>
</a>
<div class="feed__post-content">

Expand All @@ -15,10 +20,12 @@
<router-link tag="a" :to="{name:'chain-account-view', params:{chain: chain, username:post.author}}" class="link link--op">{{post.author}}</router-link>
</div>

<h3 class="feed__post-title h3" :class="{'lines-2x': lines2x, 'lines-1x': lines1x}">
<a @click.prevent="show" :href="$helper.makePathForPost(post, chain)" class="link" :title="post.title">{{post.title}}</a>
<h3 class="feed__post-title h3">
<a @click.prevent="show" :href="$helper.makePathForPost(post, chain)" class="link" :title="post.title">
<span class="nsfw-warning" v-show="post.nsfw">nsfw</span>
{{post.title}}</a>
</h3>
<p class="feed__post-text">
<p class="feed__post-text" :class="{'lines-2x': lines2x, 'lines-1x': lines1x}">
<a @click.prevent="show" :href="$helper.makePathForPost(post, chain)" class="link">{{cutPreview}}</a>
</p>
<div class="feed__post-info" v-if="!$store.state.core.params[chain].processing">
Expand Down Expand Up @@ -80,11 +87,8 @@ export default {
isRepost() {
return this.account.name !== this.post.author
},
cutTitle() {
return parser.cutTitle(this.chain, this.post.title)
},
cutPreview() {
return parser.cutPreview(this.chain, this.post.preview, this.isRepost)
return parser.cutPreview(this.post.preview)
}
},
methods: {
Expand Down
21 changes: 2 additions & 19 deletions common/@oneplace/blockchains-api/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,25 +374,8 @@ class Parser {
})
}

static cutTitle(chain, title) {
const STR_LIMIT = chain === CONSTANTS.BLOCKCHAIN.SOURCE.GOLOS ? 70 : 80
if (title.length > STR_LIMIT) {
title =
title.substring(
0,
title
.substr(0, STR_LIMIT)
.split('')
.lastIndexOf(' ')
) + '...'
}
return title
}

static cutPreview(chain, preview, isRepost) {
let STR_LIMIT = isRepost ? 50 : 110
if (chain === CONSTANTS.BLOCKCHAIN.SOURCE.GOLOS)
STR_LIMIT = isRepost ? 50 : 90
static cutPreview(preview) {
let STR_LIMIT = 200

if (preview.length > STR_LIMIT) {
preview =
Expand Down

0 comments on commit 6f548a3

Please sign in to comment.