Compare commits

...

21 Commits

Author SHA1 Message Date
f968d05ea0 2.37.7 2018-06-12 09:10:52 +09:00
d6e5dc2167 Fix bugs 2018-06-12 09:10:34 +09:00
460147fea2 2.37.6 2018-06-12 08:59:36 +09:00
cea44834bb Improve usability 2018-06-12 08:58:50 +09:00
1af50fd7b8 冗長なハッシュタグの表示を無くした 2018-06-12 08:43:48 +09:00
b18013025f 🎨 2018-06-12 08:09:27 +09:00
399eb60809 2.37.5 2018-06-12 02:47:17 +09:00
ed67e3506b ✌️ 2018-06-12 02:46:54 +09:00
d8ff37fc45 ✌️ 2018-06-12 02:28:28 +09:00
2fcc3bb1ea 2.37.4 2018-06-12 02:19:00 +09:00
2e680c3d1e Fix bug 2018-06-12 02:18:29 +09:00
af0a0ef41b Merge branch 'master' of https://github.com/syuilo/misskey 2018-06-12 02:03:26 +09:00
bbfccb0bbf 🎨 2018-06-12 02:03:18 +09:00
c89eb5d69f Merge pull request #1705 from syuilo/l10n_master
New Crowdin translations
2018-06-12 02:03:06 +09:00
ebde84214e Improve hashtag trend detection 2018-06-12 02:00:05 +09:00
03fbae7b6d 変数調整 2018-06-12 01:51:51 +09:00
f90e9596d4 Fix bug 2018-06-12 01:48:29 +09:00
944f9524e2 Fix bug 2018-06-12 01:45:58 +09:00
c61050244e 変数調整 2018-06-12 01:43:56 +09:00
90337adbbc Improve hashtag trend detection 2018-06-12 01:41:17 +09:00
7b67e41c5b New translations ja.yml (Polish) 2018-06-11 19:22:16 +09:00
8 changed files with 120 additions and 25 deletions

View File

@ -258,6 +258,7 @@ common/views/widgets/posts-monitor.vue:
common/views/widgets/hashtags.vue:
title: "ハッシュタグ"
count: "{}人が投稿"
empty: "トレンドなし"
common/views/widgets/server.vue:
title: "サーバー情報"

View File

@ -70,7 +70,7 @@ common:
donation: "Dotacje"
nav: "Nawigacja"
tips: "Wskazówki"
hashtags: "ハッシュタグ"
hashtags: "Hashtagi"
deck:
widgets: "Widżety"
home: "Strona główna"
@ -226,8 +226,8 @@ common/views/widgets/posts-monitor.vue:
title: "Wykres wpisów"
toggle: "Przełącz widok"
common/views/widgets/hashtags.vue:
title: "ハッシュタグ"
count: "{}人が投稿"
title: "Hashtagi"
count: "Wspomniany przez {} użytkowników"
common/views/widgets/server.vue:
title: "Informacje o serwerze"
toggle: "Przełącz widok"

View File

@ -1,8 +1,8 @@
{
"name": "misskey",
"author": "syuilo <i@syuilo.com>",
"version": "2.37.3",
"clientVersion": "1.0.6453",
"version": "2.37.7",
"clientVersion": "1.0.6474",
"codename": "nighthike",
"main": "./built/index.js",
"private": true,

View File

@ -40,6 +40,17 @@ export default Vue.component('mk-note-html', {
ast = this.ast;
}
if (ast.filter(x => x.type != 'hashtag').length == 0) {
return;
}
while (
ast[ast.length - 1].type == 'hashtag' ||
(ast[ast.length - 1].type == 'text' && ast[ast.length - 1].content == ' ') ||
(ast[ast.length - 1].type == 'text' && ast[ast.length - 1].content == '\n')) {
ast.pop();
}
// Parse ast to DOM
const els = flatten(ast.map(token => {
switch (token.type) {
@ -92,7 +103,7 @@ export default Vue.component('mk-note-html', {
case 'hashtag':
return createElement('a', {
attrs: {
href: `${url}/search?q=${token.content}`,
href: `${url}/tags/${token.content}`,
target: '_blank'
}
}, token.content);

View File

@ -49,7 +49,8 @@ export default Vue.extend({
polylinePoints: '',
polygonPoints: '',
headX: null,
headY: null
headY: null,
clock: null
};
},
watch: {
@ -59,6 +60,12 @@ export default Vue.extend({
},
created() {
this.draw();
// Vueが何故かWatchを発動させない場合があるので
this.clock = setInterval(this.draw, 1000);
},
beforeDestroy() {
clearInterval(this.clock);
},
methods: {
draw() {

View File

@ -5,7 +5,8 @@
<div class="mkw-hashtags--body" :data-mobile="platform == 'mobile'">
<p class="fetching" v-if="fetching">%fa:spinner .pulse .fw%%i18n:common.loading%<mk-ellipsis/></p>
<div v-else>
<p class="empty" v-else-if="stats.length == 0">%fa:exclamation-circle%%i18n:@empty%</p>
<transition-group v-else tag="div" name="chart">
<div v-for="stat in stats" :key="stat.tag">
<div class="tag">
<router-link :to="`/tags/${ stat.tag }`" :title="stat.tag">#{{ stat.tag }}</router-link>
@ -13,7 +14,7 @@
</div>
<x-chart class="chart" :src="stat.chart"/>
</div>
</div>
</transition-group>
</div>
</mk-widget-container>
</div>
@ -65,8 +66,9 @@ export default define({
root(isDark)
.mkw-hashtags--body
> .fetching
> .empty
margin 0
padding 12px 16px
padding 16px
text-align center
color #aaa
@ -74,10 +76,18 @@ root(isDark)
margin-right 4px
> div
.chart-enter
.chart-leave-to
opacity 0
transform translateY(-30px)
> *
transition transform .3s ease, opacity .3s ease
> div
display flex
align-items center
padding 16px
padding 14px 16px
&:not(:last-child)
border-bottom solid 1px isDark ? #393f4f : #eee

View File

@ -5,7 +5,7 @@
<div class="gqpwvtwtprsbmnssnbicggtwqhmylhnq">
<template v-if="edit">
<header>
<select v-model="widgetAdderSelected">
<select v-model="widgetAdderSelected" @change="addWidget">
<option value="profile">%i18n:common.widgets.profile%</option>
<option value="analog-clock">%i18n:common.widgets.analog-clock%</option>
<option value="calendar">%i18n:common.widgets.calendar%</option>
@ -30,20 +30,15 @@
<option value="nav">%i18n:common.widgets.nav%</option>
<option value="tips">%i18n:common.widgets.tips%</option>
</select>
<button @click="addWidget">%i18n:@add%</button>
</header>
<x-draggable
:list="column.widgets"
:options="{ handle: '.handle', animation: 150 }"
:options="{ animation: 150 }"
@sort="onWidgetSort"
>
<div v-for="widget in column.widgets" class="customize-container" :key="widget.id">
<header>
<span class="handle">%fa:bars%</span>{{ widget.name }}<button class="remove" @click="removeWidget(widget)">%fa:times%</button>
</header>
<div @click="widgetFunc(widget.id)">
<component :is="`mkw-${widget.name}`" :widget="widget" :ref="widget.id" :is-customize-mode="true" platform="deck"/>
</div>
<div v-for="widget in column.widgets" class="customize-container" :key="widget.id" @contextmenu.stop.prevent="widgetFunc(widget.id)">
<button class="remove" @click="removeWidget(widget)">%fa:times%</button>
<component :is="`mkw-${widget.name}`" :widget="widget" :ref="widget.id" :is-customize-mode="true" platform="deck"/>
</div>
</x-draggable>
</template>
@ -142,6 +137,13 @@ export default Vue.extend({
root(isDark)
.gqpwvtwtprsbmnssnbicggtwqhmylhnq
> header
padding 16px
> *
width 100%
padding 4px
.widget, .customize-container
margin 8px
@ -149,7 +151,21 @@ root(isDark)
margin-top 0
.customize-container
background #fff
cursor move
> *:not(.remove)
pointer-events none
> .remove
position absolute
z-index 1
top 8px
right 8px
width 32px
height 32px
color #fff
background rgba(#000, 0.7)
border-radius 4px
> header
color isDark ? #fff : #000

View File

@ -1,13 +1,26 @@
import Note from '../../../../models/note';
/*
トレンドに載るためには「『直近a分間のユニーク投稿数が今からa分前今からb分前の間のユニーク投稿数のn倍以上』のハッシュタグの上位5位以内に入る」ことが必要
ユニーク投稿数とはそのハッシュタグと投稿ユーザーのペアのカウントで、例えば同じユーザーが複数回同じハッシュタグを投稿してもそのハッシュタグのユニーク投稿数は1とカウントされる
*/
const rangeA = 1000 * 60 * 30; // 30分
const rangeB = 1000 * 60 * 120; // 2時間
const coefficient = 1.5; // 「n倍」の部分
const requiredUsers = 3; // 最低何人がそのタグを投稿している必要があるか
const max = 5;
/**
* Get trends of hashtags
*/
module.exports = () => new Promise(async (res, rej) => {
//#region 1. 直近Aの内に投稿されたハッシュタグ(とユーザーのペア)を集計
const data = await Note.aggregate([{
$match: {
createdAt: {
$gt: new Date(Date.now() - 1000 * 60 * 60)
$gt: new Date(Date.now() - rangeA)
},
tags: {
$exists: true,
@ -26,6 +39,7 @@ module.exports = () => new Promise(async (res, rej) => {
userId: any;
}
}>;
//#endregion
if (data.length == 0) {
return res([]);
@ -33,6 +47,7 @@ module.exports = () => new Promise(async (res, rej) => {
const tags = [];
// カウント
data.map(x => x._id).forEach(x => {
const i = tags.findIndex(tag => tag.name == x.tags);
if (i != -1) {
@ -45,11 +60,45 @@ module.exports = () => new Promise(async (res, rej) => {
}
});
const hots = tags
// 最低要求投稿者数を下回るならカットする
const limitedTags = tags.filter(tag => tag.count >= requiredUsers);
//#region 2. 1で取得したそれぞれのタグについて、「直近a分間のユニーク投稿数が今からa分前今からb分前の間のユニーク投稿数のn倍以上」かどうかを判定する
const hotsPromises = limitedTags.map(async tag => {
const passedCount = (await Note.distinct('userId', {
tags: tag.name,
createdAt: {
$lt: new Date(Date.now() - rangeA),
$gt: new Date(Date.now() - rangeB)
}
}) as any).length;
if (tag.count >= (passedCount * coefficient)) {
return tag;
} else {
return null;
}
});
//#endregion
// タグを人気順に並べ替え
let hots = (await Promise.all(hotsPromises))
.filter(x => x != null)
.sort((a, b) => b.count - a.count)
.map(tag => tag.name)
.slice(0, 5);
.slice(0, max);
//#region 3. もし上記の方法でのトレンド抽出の結果、求められているタグ数に達しなければ「ただ単に現在投稿数が多いハッシュタグ」に切り替える
if (hots.length < max) {
hots = hots.concat(tags
.filter(tag => hots.indexOf(tag.name) == -1)
.sort((a, b) => b.count - a.count)
.map(tag => tag.name)
.slice(0, max - hots.length));
}
//#endregion
//#region 2(または3)で話題と判定されたタグそれぞれについて過去の投稿数グラフを取得する
const countPromises: Array<Promise<any[]>> = [];
const range = 20;
@ -75,6 +124,7 @@ module.exports = () => new Promise(async (res, rej) => {
$gt: new Date(Date.now() - (interval * range))
}
})));
//#endregion
const stats = hots.map((tag, i) => ({
tag,