Skip to content

Commit

Permalink
deprecated golos comment level, image name for uploads, external link…
Browse files Browse the repository at this point in the history
… w target="_blank" , fix votes, other fixes
  • Loading branch information
RusovDmitriy committed Apr 12, 2018
1 parent 1acaa4c commit 5442d60
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 61 deletions.
4 changes: 3 additions & 1 deletion client/src/components/chains/Comment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ export default {
return CONSTANTS.DEFAULT.AVATAR_IMAGE
},
isMaxDeep() {
return this.chain === CONSTANTS.BLOCKCHAIN.SOURCE.GOLOS && this.level >= 5
return false
// After hardfork 17, Golos support more then 5 comments level, wil be deprecated
// return this.chain === CONSTANTS.BLOCKCHAIN.SOURCE.GOLOS && this.level >= 5
},
chain() {
return this.$route.params.chain || this.$store.state.chain
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/chains/PublishEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,12 @@ export default {
this.mde.createToolbar(generateToolbar())
})
EventBus.$on('EDITOR:INSERT:LINK', ({ link, isImage = false }) => {
EventBus.$on('EDITOR:INSERT:LINK', ({ name, link, isImage = false }) => {
const selections = this.mde.codemirror.getSelections()
let selectionsReplace
const template = `${isImage ? '!' : ''}[%NAME%](${link})`
selectionsReplace = selections.map(selection =>
template.replace('%NAME%', selection || link)
template.replace('%NAME%', selection || name || link)
)
this.mde.codemirror.replaceSelections(selectionsReplace)
})
Expand Down
8 changes: 7 additions & 1 deletion client/src/components/chains/PublishModalImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default {
data() {
return {
link: '',
name: '',
errorCode: null,
processing: false
}
Expand Down Expand Up @@ -81,6 +82,7 @@ export default {
this.processing = true
Api.uploadImage(file)
.then(response => {
this.name = file.name
this.link = [
window.location.origin,
'storage',
Expand All @@ -101,7 +103,11 @@ export default {
}
},
onSubmit() {
EventBus.$emit('EDITOR:INSERT:LINK', { link: this.link, isImage: true })
EventBus.$emit('EDITOR:INSERT:LINK', {
name: this.name,
link: this.link,
isImage: true
})
this.$store.commit('publish/SET_EDITOR_OBJECT', { showModalImage: false })
}
}
Expand Down
9 changes: 3 additions & 6 deletions client/src/components/settings/AccountAttachForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
{{$t('common.validate.activeKeyNotPassed')}}
</div>
</div>
// <router-link :to="{name:'welcome-step-confirm', params:{chain}}" class="login-form__advanced link">{{$t('addAccount.advancedMode')}}</router-link>
<!-- <router-link :to="{name:'welcome-step-confirm', params:{chain}}" class="login-form__advanced link">{{$t('addAccount.advancedMode')}}</router-link> -->
<p class="login-form__text login-form__text--alert" v-html="$t('accountForm.aboutPrivate')"></p>
<div class="login-form__btn-wrapper">
<button type="submit" class="btn btn--large login-form__btn login-form__btn--bchain" :disabled="processing">
Expand Down Expand Up @@ -166,7 +166,7 @@
</div>
</div>
</div>
// <router-link :to="{name:'confirm-account', params:{chain}}" class="login-form__advanced link">{{$t('addAccount.advancedMode')}}</router-link>
<!-- <router-link :to="{name:'confirm-account', params:{chain}}" class="login-form__advanced link">{{$t('addAccount.advancedMode')}}</router-link> -->
<p class="login-form__text login-form__text--alert" v-html="$t('accountForm.aboutPrivate')"></p>
<div class="login-form__btn-wrapper">
<button type="submit" class="btn login-form__btn btn--large" :disabled="processing">
Expand Down Expand Up @@ -306,10 +306,7 @@ export default {
redirectUri = encodeURIComponent(window.location.origin + redirectUri)
const appName = 'oneplace.app'
window.open(
`https://steemconnect.com/authorize/@${appName}?&redirect_uri=${redirectUri}`,
'_blank'
)
window.location.href = `https://steemconnect.com/authorize/@${appName}?&redirect_uri=${redirectUri}`
},
clearErrors() {
this.errors.remove('username', 'notFound')
Expand Down
10 changes: 5 additions & 5 deletions client/src/components/settings/AccountConfirmForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
:class="{'login-form__input--error': errors.has('activeKey')}"/>

<div v-if="errors.firstByRule('activeKey', 'required')" id="vError-activeKey-required" class="login-form__alert">
{{$t('common.validate.activeKeyRequired')}}
{{$t('common.validate.postingKeyRequired')}}
</div>
<div v-if="errors.firstByRule('activeKey', 'notPassed')" id="vError-activeKey-notPassed" class="login-form__alert">
{{$t('common.validate.activeKeyNotPassed')}}
{{$t('common.validate.postingKeyNotPassed')}}
</div>
</div>
</div>
Expand All @@ -55,9 +55,9 @@
{{$t('welcome.attachStep.skipThisStep')}}
</a>
</div>
// <div style="overflow:hidden" v-else>
// <router-link class="login-form__bottom-link link" :to="backRoute">{{$t('addAccount.backToOnePlace')}}</router-link>
// </div>
<!-- <div style="overflow:hidden" v-else>
<router-link class="login-form__bottom-link link" :to="backRoute">{{$t('addAccount.backToOnePlace')}}</router-link>
</div> -->
</div>
</form>

Expand Down
10 changes: 5 additions & 5 deletions client/src/components/settings/AccountRemoveForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ export default {
})
},
removeWithSteemConnect() {
const redirectUri = encodeURIComponent(window.location.origin + `/settings?rm=${this.account.chain}:${this.account.username}`)
const appName = 'oneplace.app'
window.open(
`https://steemconnect.com/revoke/@${appName}?&redirect_uri=${redirectUri}`,
'_blank'
const redirectUri = encodeURIComponent(
window.location.origin +
`/settings?rm=${this.account.chain}:${this.account.username}`
)
const appName = 'oneplace.app'
window.location.href = `https://steemconnect.com/revoke/@${appName}?&cb=${redirectUri}`
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions client/src/containers/chains/Publish.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ export default {
this.$auth.ready() ? init() : this.$auth.ready(init)
},
metaInfo() {
return {
title: `Publish to ${this.chain === CONSTANTS.BLOCKCHAIN.SOURCE.STEEM ? 'STEEM' : 'GOLOS'}`
}
},
methods: {
onUpdate() {
this.$refs.editor.onUpdate()
Expand Down
5 changes: 5 additions & 0 deletions client/src/containers/settings/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export default {
accountRemove: null
}
},
metaInfo() {
return {
title: 'Settings'
}
},
methods: {
closeAccountForm() {
this.attachFormShow = false
Expand Down
6 changes: 4 additions & 2 deletions client/src/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ module.exports = {
passwordRepeat: 'Password doesn\'t match',
emailVerified: 'E-mail hasn\'t been verified',
emailNotFound: 'E-mail not found',
activeKeyRequired: 'Private key can\'t be blank',
activeKeyNotPassed: 'Active key not passed',
activeKeyRequired: 'Private active key can\'t be blank',
activeKeyNotPassed: 'Private active key not passed',
postingKeyRequired: 'Private posting key can\'t be blank',
postingKeyNotPassed: 'Private posting key not passed',
usernameRequired: 'Username can\'t be blank',
usernameNotFound: 'Account with this username not found',
tagRequired: 'Tag can\'t be blank',
Expand Down
16 changes: 9 additions & 7 deletions client/src/i18n/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ module.exports = {
passwordRepeat: 'Пароль не совпадает',
emailVerified: 'Адрес e-mail не был подтвержден',
emailNotFound: 'Адрес e-mail не найден',
activeKeyRequired: 'Приватный ключ не может быть пустым',
activeKeyNotPassed: 'Активный ключ не прошел проверку',
activeKeyRequired: 'Приватный active ключ не может быть пустым',
activeKeyNotPassed: 'Приватный active ключ не прошел проверку',
postingKeyRequired: 'Приватный posting ключ не может быть пустым',
postingKeyNotPassed: 'Приватный posting ключ не прошел проверку',
usernameRequired: 'Имя пользователя не может быть пустым',
usernameNotFound: 'Аккаунта с таким именем не существует',
tagRequired: 'Строка тегов не может быть пустой',
Expand All @@ -48,9 +50,9 @@ module.exports = {
passwordRepeat: 'Повторите пароль',
username: 'Имя пользователя',
addAccountUsername: 'Имя пользователя {blockchain}',
addAccountActiveKey: 'Активный приватный ключ',
confirmAccountPostingKey: 'Приватный постинг ключ',
activeKey: 'Активный приватный ключ',
addAccountActiveKey: 'Приватный active ключ',
confirmAccountPostingKey: 'Приватный posting ключ',
activeKey: 'Приватный active ключ',
leaveAComment: 'Добавить комментарий...'
}
},
Expand Down Expand Up @@ -108,7 +110,7 @@ module.exports = {
},
confirmStep: {
header: 'Подтвердить аккаунт',
help: 'Подтвердите доступ к учетной записи, выполнив вход с помощью приватного постинг ключа.',
help: 'Подтвердите доступ к учетной записи, выполнив вход с помощью приватного posting ключа.',
help2: 'OnePlace не сохраняет ваши приватные ключи.',
confirmAccount: 'Подтвердить аккаунт'
},
Expand All @@ -131,7 +133,7 @@ module.exports = {
addAccount: 'Добавить аккаунт',
cancelRemoveAccount: 'Отмена',
aboutPrivate: '<em>OnePlace не хранит ваш приватный ключ</em>. Добавляя свой блокчейн аккаунт, вы авторизуете приложение OnePlace для голосования, публикации и редактирования записей от вашего имени. Вы можете отменить это разрешение в любой момент.',
aboutRemove: '<em>Удаление аккаунта</em>. Вы отменяете авторизацию для приложения OnePlace. Подтвердите эту операцию приватным активным ключом.',
aboutRemove: '<em>Удаление аккаунта</em>. Вы отменяете авторизацию для приложения OnePlace. Подтвердите эту операцию приватным active ключом.',
addWithSteemConnect: 'Добавить через SteemConnect',
removeWithSteemConnect: 'Удалить через SteemConnect'
},
Expand Down
8 changes: 4 additions & 4 deletions client/src/store/modules/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ export default () => {
else {
params.globalProps = result
if (chain === CONSTANTS.BLOCKCHAIN.SOURCE.GOLOS) {
params.rewardFunds.reward_balance = result.total_reward_fund_steem.replace(
params.rewardFunds.reward_balance = +result.total_reward_fund_steem.replace(
' GOLOS',
''
)
params.rewardFunds.recent_claims = result.total_reward_shares2
params.rewardFunds.recent_claims = +result.total_reward_shares2
}
params.steem_per_mvests = 1000000.0 *
parseFloat(result['total_vesting_fund_steem'].split(' ')[0]) /
Expand All @@ -91,11 +91,11 @@ export default () => {
$chains.client.api.getRewardFund('post', (err, result) => {
if (err) reject
else {
params.rewardFunds.reward_balance = result.reward_balance.replace(
params.rewardFunds.reward_balance = +result.reward_balance.replace(
' STEEM',
''
)
params.rewardFunds.recent_claims = result.recent_claims
params.rewardFunds.recent_claims = +result.recent_claims
resolve()
}
})
Expand Down
7 changes: 3 additions & 4 deletions client/static/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ input,textarea,select,button {
height: 40px;
border-radius: 0;
text-align: center;
line-height: 38px;
line-height: 36px;
font-size: 15px;
font-weight: 700;
text-transform: uppercase;
Expand Down Expand Up @@ -1028,7 +1028,6 @@ hr {

.login-form__btn--bchain {
margin: 0 0 16px;
text-transform: capitalize;
}

.login-form__btn--sc {
Expand Down Expand Up @@ -1144,7 +1143,6 @@ hr {
.login-form__text--alert {
font-size: 14px;
border-left: 2px solid #db4c2a;
text-align: justify;
}

.login-form__text--security {
Expand Down Expand Up @@ -1746,7 +1744,7 @@ hr {

.account-action__btn {
width: 100%;
text-transform: none;
text-transform: uppercase;
color: #fff;
background: #259cb7;
margin-bottom: 16px;
Expand All @@ -1757,6 +1755,7 @@ hr {
}

.account-action__btn--sc {
text-transform: none;
font-weight: 400;
color: #259cb7;
background: #fff;
Expand Down
3 changes: 2 additions & 1 deletion common/@oneplace/blockchains-api/SanitizeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module.exports = ({large = true, highQualityPost = true, noImage = false, saniti
// style is subject to attack, filtering more below
td: ['style'],
img: ['src', 'alt'],
a: ['href', 'rel'],
a: ['href', 'rel', 'target'],
},
transformTags: {
iframe: (tagName, attribs) => {
Expand Down Expand Up @@ -143,6 +143,7 @@ module.exports = ({large = true, highQualityPost = true, noImage = false, saniti
if (!href.match(/^(\/(?!\/)|https:\/\/(golos\.blog|golos\.club|golos\.io|goldvoice\.club|busy\.org|steemit\.com))/)) {
// attys.target = '_blank' // pending iframe impl https://mathiasbynens.github.io/rel-noopener/
attys.rel = highQualityPost ? 'noopener' : 'nofollow noopener'
attys.target = '_blank'
}
return {
tagName,
Expand Down
35 changes: 18 additions & 17 deletions common/@oneplace/blockchains-api/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ class Converter {
}

static voteToFiat(vote, chain, params, post, append = true) {
const CURRENCY_Q = CONSTANTS.BLOCKCHAIN.SOURCE.GOLOS ? params.goldPrice : 1
const CHAINS = CONSTANTS.BLOCKCHAIN.SOURCE
const MODES = CONSTANTS.BLOCKCHAIN.MODES
const CURRENCY_Q = chain === CHAINS.GOLOS ? params.goldPrice : 1
const feedPrice = params.feedPrice
const base = parseFloat(feedPrice.base.split(' ')[0]) / parseFloat(feedPrice.quote.split(' ')[0])
const {recent_claims, reward_balance} = params.rewardFunds
Expand All @@ -42,15 +44,14 @@ class Converter {

let result
const isLiner =
chain === CONSTANTS.BLOCKCHAIN.SOURCE.STEEM ||
post.mode !== CONSTANTS.BLOCKCHAIN.MODES.ARCHIVED ||
chain === CHAINS.STEEM ||
post.mode !== MODES.ARCHIVED ||
moment(post.created).unix() > moment("2018-04-04T00:00:00+00:00").unix()

if (isLiner) {
const allPayout = +post.pending_payout + +post.total_payout
const sumRshares = active_votes.reduce((sum, _vote) => sum += +_vote.rshares, 0)
const q = allPayout / sumRshares

const q = ((reward_balance * base) / recent_claims) * CURRENCY_Q
if (append)
result = lastPayout ? +post.payout : (+post.payout + vote.rshares * q).toFixed(2)
else
Expand All @@ -60,7 +61,7 @@ class Converter {
const created = moment(post.created).unix()

if (append) {
if (post.mode === CONSTANTS.BLOCKCHAIN.MODES.ARCHIVED)
if (post.mode === MODES.ARCHIVED)
result = (post.total_payout_value * CURRENCY_Q).toFixed(2)
else {
const currentActiveRshares =
Expand All @@ -86,18 +87,18 @@ class Converter {

} else {
const setVoteMode = (time, post) => {
if (post.mode === CONSTANTS.BLOCKCHAIN.MODES.FIRST_PAYOUT)
return CONSTANTS.BLOCKCHAIN.MODES.FIRST_PAYOUT
if (post.mode === MODES.FIRST_PAYOUT)
return MODES.FIRST_PAYOUT

if (post.mode === CONSTANTS.BLOCKCHAIN.MODES.SECOND_PAYOUT)
if (post.mode === MODES.SECOND_PAYOUT)
return time <= moment(post.last_payout).unix()
? CONSTANTS.BLOCKCHAIN.MODES.FIRST_PAYOUT
: CONSTANTS.BLOCKCHAIN.MODES.SECOND_PAYOUT
? MODES.FIRST_PAYOUT
: MODES.SECOND_PAYOUT

if (post.mode === CONSTANTS.BLOCKCHAIN.MODES.ARCHIVED)
if (post.mode === MODES.ARCHIVED)
return time <= moment(post.last_payout).subtract(30, 'days').unix()
? CONSTANTS.BLOCKCHAIN.MODES.FIRST_PAYOUT
: CONSTANTS.BLOCKCHAIN.MODES.SECOND_PAYOUT
? MODES.FIRST_PAYOUT
: MODES.SECOND_PAYOUT
}

vote.mode = setVoteMode(time, post)
Expand All @@ -113,9 +114,9 @@ class Converter {

let q = (reward_balance * base) / recent_claims
let vShares = Converter.calculateVshares(activeRshares)
if (vote.mode !== post.mode || post.mode === CONSTANTS.BLOCKCHAIN.MODES.SECOND_PAYOUT) {
if (post.mode === CONSTANTS.BLOCKCHAIN.MODES.SECOND_PAYOUT) {
if (vote.mode === CONSTANTS.BLOCKCHAIN.MODES.SECOND_PAYOUT)
if (vote.mode !== post.mode || post.mode === MODES.SECOND_PAYOUT) {
if (post.mode === MODES.SECOND_PAYOUT) {
if (vote.mode === MODES.SECOND_PAYOUT)
q = post.pending_payout_value / vShares
else
q = post.total_payout_value / vShares
Expand Down
Loading

0 comments on commit 5442d60

Please sign in to comment.