Closes #12, #227 and #58
This commit is contained in:
syuilo 2017-03-18 20:05:11 +09:00
parent 2496cece91
commit 45e8331e26
150 changed files with 610 additions and 609 deletions

View file

@ -1,7 +1,7 @@
{
"name": "misskey",
"author": "syuilo <i@syuilo.com>",
"version": "0.0.1355",
"version": "0.0.1361",
"license": "MIT",
"description": "A miniblog-based SNS",
"bugs": "https://github.com/syuilo/misskey/issues",

View file

@ -114,7 +114,7 @@ const elements = [
// comment
code => {
if (code.substr(0, 2) != '//') return null;
const match = code.match(/^\/\/(.+?)\n/);
const match = code.match(/^\/\/(.+?)(\n|$)/);
if (!match) return null;
const comment = match[0];
return {
@ -187,7 +187,7 @@ const elements = [
regexp += char;
}
}
if (thisIsNotARegexp) return null;
if (regexp == '') return null;
if (regexp[0] == ' ' && regexp[regexp.length - 1] == ' ') return null;
@ -299,7 +299,7 @@ const elements = [
];
// specify lang is todo
module.exports = (source, lang) => {
export default (source: string, lang?: string) => {
let code = source;
let html = '';
@ -317,6 +317,8 @@ module.exports = (source, lang) => {
if (e) {
push(e);
return true;
} else {
return false;
}
});

View file

@ -2,7 +2,7 @@
* Code (block)
*/
const genHtml = require('../core/syntax-highlighter');
import genHtml from '../core/syntax-highlighter';
module.exports = text => {
const match = text.match(/^```([\s\S]+?)```/);

View file

@ -2,7 +2,7 @@
* Code (inline)
*/
const genHtml = require('../core/syntax-highlighter');
import genHtml from '../core/syntax-highlighter';
module.exports = text => {
const match = text.match(/^`(.+?)`/);

View file

@ -13,7 +13,7 @@ const elements = [
require('./elements/emoji')
];
function analyze(source) {
export default (source: string) => {
if (source == '') {
return null;
@ -40,6 +40,8 @@ function analyze(source) {
}
tokens.forEach(push);
return true;
} else {
return false;
}
});
@ -66,6 +68,4 @@ function analyze(source) {
return a.concat(b);
}
});
}
module.exports = analyze;
};

View file

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/

View file

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/

View file

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/

View file

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/

View file

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/

View file

@ -1,13 +1,12 @@
'use strict';
/**
* Module dependencies
*/
import * as mongo from 'mongodb';
import deepcopy = require('deepcopy');
import Message from '../models/messaging-message';
import serializeUser from './user';
import serializeDriveFile from './drive-file';
import deepcopy = require('deepcopy');
import parse from '../common/text';
/**
* Serialize a message
@ -47,6 +46,11 @@ export default (
_message.id = _message._id;
delete _message._id;
// Parse text
if (_message.text) {
_message.ast = parse(_message.text);
}
// Populate user
_message.user = await serializeUser(_message.user_id, me);

View file

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/

View file

@ -1,16 +1,15 @@
'use strict';
/**
* Module dependencies
*/
import * as mongo from 'mongodb';
import deepcopy = require('deepcopy');
import Post from '../models/post';
import Like from '../models/like';
import Vote from '../models/poll-vote';
import serializeApp from './app';
import serializeUser from './user';
import serializeDriveFile from './drive-file';
import deepcopy = require('deepcopy');
import parse from '../common/text';
/**
* Serialize a post
@ -54,6 +53,11 @@ const self = (
delete _post.mentions;
// Parse text
if (_post.text) {
_post.ast = parse(_post.text);
}
// Populate user
_post.user = await serializeUser(_post.user_id, me);

View file

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/

View file

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/

View file

@ -5,10 +5,11 @@
// Style
import './style.styl';
const riot = require('riot');
document.title = 'Misskey | アプリの連携';
import * as riot from 'riot';
require('./tags');
const boot = require('../boot.js');
import boot from '../boot';
document.title = 'Misskey | アプリの連携';
/**
* Boot

View file

@ -2,12 +2,14 @@
* boot
*/
const riot = require('riot');
import * as riot from 'riot';
require('velocity-animate');
const api = require('./common/scripts/api');
const signout = require('./common/scripts/signout');
const generateDefaultUserdata = require('./common/scripts/generate-default-userdata');
const mixins = require('./common/mixins');
import api from './common/scripts/api';
import signout from './common/scripts/signout';
import checkForUpdate from './common/scripts/check-for-update';
import mixin from './common/mixins';
import generateDefaultUserdata from './common/scripts/generate-default-userdata';
import CONFIG from './common/scripts/config';
require('./common/tags');
/**
@ -16,7 +18,7 @@ require('./common/tags');
"use strict";
const CONFIG = require('./common/scripts/config');
console.info(`Misskey v${VERSION}`);
document.domain = CONFIG.host;
@ -56,21 +58,10 @@ if (localStorage.getItem('should-refresh') == 'true') {
}
// 更新チェック
setTimeout(() => {
fetch(CONFIG.apiUrl + '/meta', {
method: 'POST'
}).then(res => {
res.json().then(meta => {
if (meta.version != VERSION) {
localStorage.setItem('should-refresh', 'true');
alert('Misskeyの新しいバージョンがあります。ページを再度読み込みすると更新が適用されます。');
}
});
});
}, 3000);
setTimeout(checkForUpdate, 3000);
// ユーザーをフェッチしてコールバックする
module.exports = callback => {
export default callback => {
// Get cached account data
let cachedMe = JSON.parse(localStorage.getItem('me'));
@ -113,7 +104,7 @@ module.exports = callback => {
}
}
mixins(me);
mixin(me);
const ini = document.getElementById('ini');
ini.parentNode.removeChild(ini);

View file

@ -1,5 +1,5 @@
/**
* MISSKEY ENTRY POINT
* MISSKEY CLIENT ENTRY POINT
*/
(() => {
const head = document.getElementsByTagName('head')[0];

View file

@ -1,48 +0,0 @@
const riot = require('riot');
module.exports = me => {
const i = me ? me.token : null;
require('./scripts/i')(me);
riot.mixin('api', {
api: require('./scripts/api').bind(null, i)
});
riot.mixin('cropper', {
Cropper: require('cropperjs')
});
riot.mixin('signout', {
signout: require('./scripts/signout')
});
riot.mixin('messaging-stream', {
MessagingStreamConnection: require('./scripts/messaging-stream')
});
riot.mixin('is-promise', {
isPromise: require('./scripts/is-promise')
});
riot.mixin('get-post-summary', {
getPostSummary: require('./scripts/get-post-summary')
});
riot.mixin('date-stringify', {
dateStringify: require('./scripts/date-stringify')
});
riot.mixin('text', {
analyze: require('../../../common/text/index'),
compile: require('./scripts/text-compiler')
});
riot.mixin('get-password-strength', {
getPasswordStrength: require('syuilo-password-strength')
});
riot.mixin('ui-progress', {
Progress: require('./scripts/loading')
});
};

View file

@ -0,0 +1,8 @@
import * as riot from 'riot';
import api from '../scripts/api';
export default me => {
riot.mixin('api', {
api: api.bind(null, me ? me.token : null)
});
};

View file

@ -1,6 +1,6 @@
const riot = require('riot');
import * as riot from 'riot';
module.exports = me => {
export default me => {
riot.mixin('i', {
init: function() {
this.I = me;

View file

@ -0,0 +1,9 @@
import activateMe from './i';
import activateApi from './api';
import activateStream from './stream';
export default me => {
activateMe(me);
activateApi(me);
activateStream(me);
};

View file

@ -0,0 +1,9 @@
import * as riot from 'riot';
import Connection from '../scripts/stream';
export default me => {
const stream = me ? new Connection(me) : null;
riot.mixin('stream', {
stream: stream
});
};

View file

@ -2,7 +2,7 @@
* API Request
*/
const CONFIG = require('./config');
import CONFIG from './config';
let spinner = null;
let pending = 0;
@ -14,7 +14,7 @@ let pending = 0;
* @param {any} [data={}] Data
* @return {Promise<any>} Response
*/
module.exports = (i, endpoint, data = {}) => {
export default (i, endpoint, data = {}) => {
if (++pending === 1) {
spinner = document.createElement('div');
spinner.setAttribute('id', 'wait');

View file

@ -1,6 +1,6 @@
module.exports = function(bytes) {
export default bytes => {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return '0Byte';
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
return Math.round(bytes / Math.pow(1024, i), 2) + sizes[i];
}
};

View file

@ -0,0 +1,14 @@
import CONFIG from './config';
export default function() {
fetch(CONFIG.apiUrl + '/meta', {
method: 'POST'
}).then(res => {
res.json().then(meta => {
if (meta.version != VERSION) {
localStorage.setItem('should-refresh', 'true');
alert('Misskeyの新しいバージョンがあります。ページを再度読み込みすると更新が適用されます。');
}
});
});
};

View file

@ -9,7 +9,7 @@ const apiUrl = `${scheme}//api.${host}`;
const devUrl = `${scheme}//dev.${host}`;
const aboutUrl = `${scheme}//about.${host}`;
module.exports = {
export default {
host,
scheme,
url,

View file

@ -1,8 +1,8 @@
module.exports = function(parent, child) {
export default (parent, child) => {
let node = child.parentNode;
while (node) {
if (node == parent) return true;
node = node.parentNode;
}
return false;
}
};

View file

@ -1,7 +1,7 @@
/**
* Clipboardに値をコピー(TODO: 文字列以外も対応)
*/
module.exports = val => {
export default val => {
const form = document.createElement('textarea');
form.textContent = val;
document.body.appendChild(form);

View file

@ -1,12 +1,12 @@
module.exports = date => {
export default date => {
if (typeof date == 'string') date = new Date(date);
return (
date.getFullYear() + '年' +
(date.getMonth() + 1) + '月' +
date.getFullYear() + '年' +
(date.getMonth() + 1) + '月' +
date.getDate() + '日' +
' ' +
date.getHours() + '時' +
date.getMinutes() + '分' +
date.getHours() + '時' +
date.getMinutes() + '分' +
' ' +
`(${['日', '月', '火', '水', '木', '金', '土'][date.getDay()]})`
);

View file

@ -1,2 +1,2 @@
const gcd = (a, b) => !b ? a : gcd(b, a % b);
module.exports = gcd;
export default gcd;

View file

@ -1,4 +1,4 @@
const uuid = require('./uuid.js');
import uuid from './uuid';
const home = {
left: [
@ -17,7 +17,7 @@ const home = {
]
};
module.exports = () => {
export default () => {
const homeData = [];
home.left.forEach(widget => {

View file

@ -1,3 +1 @@
module.exports = () => {
return '(=^・・^=)';
};
export default () => '(=^・・^=)';

View file

@ -32,4 +32,4 @@ const summarize = post => {
return summary.trim();
};
module.exports = summarize;
export default summarize;

View file

@ -1 +1 @@
module.exports = x => typeof x.then == 'function';
export default x => typeof x.then == 'function';

View file

@ -6,7 +6,7 @@ NProgress.configure({
const root = document.getElementsByTagName('html')[0];
module.exports = {
export default {
start: () => {
root.classList.add('progress');
NProgress.start();

View file

@ -1,6 +1,6 @@
const ReconnectingWebSocket = require('reconnecting-websocket');
const riot = require('riot');
const CONFIG = require('./config');
import * as riot from 'riot';
import CONFIG from './config';
class Connection {
constructor(me, otherparty) {
@ -40,4 +40,4 @@ class Connection {
}
}
module.exports = Connection;
export default Connection;

View file

@ -1,6 +1,6 @@
const CONFIG = require('./config');
import CONFIG from './config';
module.exports = () => {
export default () => {
localStorage.removeItem('me');
document.cookie = `i=; domain=.${CONFIG.host}; expires=Thu, 01 Jan 1970 00:00:01 GMT;`;
location.href = '/';

View file

@ -1,40 +1,53 @@
const ReconnectingWebSocket = require('reconnecting-websocket');
const riot = require('riot');
const CONFIG = require('./config');
import * as riot from 'riot';
import CONFIG from './config';
module.exports = me => {
let state = 'initializing';
const stateEv = riot.observable();
const event = riot.observable();
const host = CONFIG.apiUrl.replace('http', 'ws');
const socket = new ReconnectingWebSocket(`${host}?i=${me.token}`);
class Connection {
constructor(me) {
// BIND -----------------------------------
this.onOpen = this.onOpen.bind(this);
this.onClose = this.onClose.bind(this);
this.onMessage = this.onMessage.bind(this);
this.close = this.close.bind(this);
// ----------------------------------------
socket.onopen = () => {
state = 'connected';
stateEv.trigger('connected');
};
this.state = 'initializing';
this.stateEv = riot.observable();
this.event = riot.observable();
this.me = me;
socket.onclose = () => {
state = 'reconnecting';
stateEv.trigger('closed');
};
const host = CONFIG.apiUrl.replace('http', 'ws');
this.socket = new ReconnectingWebSocket(`${host}?i=${me.token}`);
this.socket.addEventListener('open', this.onOpen);
this.socket.addEventListener('close', this.onClose);
this.socket.addEventListener('message', this.onMessage);
socket.onmessage = message => {
this.event.on('i_updated', me.update);
}
onOpen() {
this.state = 'connected';
this.stateEv.trigger('connected');
}
onClose() {
this.state = 'reconnecting';
this.stateEv.trigger('closed');
}
onMessage(message) {
try {
const msg = JSON.parse(message.data);
if (msg.type) {
event.trigger(msg.type, msg.body);
}
} catch (e) {
if (msg.type) this.event.trigger(msg.type, msg.body);
} catch(e) {
// noop
}
};
}
event.on('i_updated', me.update);
close() {
this.socket.removeEventListener('open', this.onOpen);
this.socket.removeEventListener('message', this.onMessage);
}
}
return {
stateEv: stateEv,
getState: () => state,
event: event
};
};
export default Connection;

View file

@ -1,13 +1,13 @@
const riot = require('riot');
import * as riot from 'riot';
//const emojinize = require('emojinize');
const CONFIG = require('./config');
import CONFIG from './config';
const escape = text =>
text
.replace(/>/g, '&gt;')
.replace(/</g, '&lt;');
module.exports = (tokens, shouldBreak) => {
export default (tokens, shouldBreak) => {
if (shouldBreak == null) {
shouldBreak = true;
}
@ -20,21 +20,21 @@ module.exports = (tokens, shouldBreak) => {
return escape(token.content)
.replace(/(\r\n|\n|\r)/g, shouldBreak ? '<br>' : ' ');
case 'bold':
return '<strong>' + escape(token.bold) + '</strong>';
return `<strong>${escape(token.bold)}</strong>`;
case 'url':
return '<mk-url href="' + escape(token.content) + '" target="_blank"></mk-url>';
return `<mk-url href="${escape(token.content)}" target="_blank"></mk-url>`;
case 'link':
return '<a class="link" href="' + escape(token.url) + '" target="_blank">' + escape(token.title) + '</a>';
return `<a class="link" href="${escape(token.url)}" target="_blank" title="${escape(token.url)}">${escape(token.title)}</a>`;
case 'mention':
return '<a href="' + CONFIG.url + '/' + escape(token.username) + '" target="_blank" data-user-preview="' + token.content + '" ' + (me && me.username == token.username ? 'data-is-me' : '') + '>' + token.content + '</a>';
return `<a href="${CONFIG.url + '/' + escape(token.username)}" target="_blank" data-user-preview="${token.content}" ${me && me.username == token.username ? 'data-is-me' : ''}>${token.content}</a>`;
case 'hashtag': // TODO
return '<a>' + escape(token.content) + '</a>';
return `<a>${escape(token.content)}</a>`;
case 'code':
return '<pre><code>' + token.html + '</code></pre>';
return `<pre><code>${token.html}</code></pre>`;
case 'inline-code':
return '<code>' + token.html + '</code>';
return `<code>${token.html}</code>`;
case 'emoji':
return '<i>' + token.content + '</i>';
return `<i>${token.content}</i>`;
//return emojinize.encode(token.content)
}
}).join('');

View file

@ -1,12 +1,12 @@
module.exports = function () {
export default () => {
var uuid = '', i, random;
for (i = 0; i < 32; i++) {
random = Math.random() * 16 | 0;
if (i == 8 || i == 12 || i == 16 || i == 20) {
uuid += '-'
uuid += '-';
}
uuid += (i == 12 ? 4 : (i == 16 ? (random & 3 | 8) : random)).toString(16);
}
return uuid;
}
};

View file

@ -1,9 +1,9 @@
<mk-introduction>
<article>
<h1>Misskeyとは</h1><p><ruby>Misskey<rt>みすきー</rt></ruby>は、<a href="http://syuilo.com" target="_blank">syuilo</a>が2014年くらいから<a href="https://github.com/syuilo/misskey" target="_blank">オープンソースで</a>開発・運営を行っている、ミニブログベースのSNSです。</p>
<p>Twitter, Facebook, LINE, Google+ などを<del>パクって</del><i>参考にして</i>います。</p>
<p>無料で誰でも利用でき、広告は一切掲載していません。</p>
<p><a href={ CONFIG.aboutUrl } target="_blank">もっと知りたい方はこちら</a></p>
<h1>Misskeyとは</h1>
<p><ruby>Misskey<rt>みすきー</rt></ruby>は、<a href="http://syuilo.com" target="_blank">syuilo</a>が2014年くらいから<a href="https://github.com/syuilo/misskey" target="_blank">オープンソースで</a>開発・運営を行っている、ミニブログベースのSNSです。</p>
<p>無料で誰でも利用でき、広告掲載していません。</p>
<p><a href={ CONFIG.aboutUrl } target="_blank">もっと知りたい方はこちら</a></p>
</article>
<style>
:scope

View file

@ -119,7 +119,7 @@
<script>
this.mixin('api');
this.onpaste = (e) => {
this.onpaste = e => {
const data = e.clipboardData;
const items = data.items;
for (let i = 0; i < items.length; i++) {
@ -130,7 +130,7 @@
}
};
this.onkeypress = (e) => {
this.onkeypress = e => {
if ((e.which == 10 || e.which == 13) && e.ctrlKey) {
this.send();
}

View file

@ -203,17 +203,18 @@
</style>
<script>
import compile from '../../../common/scripts/text-compiler';
this.mixin('i');
this.mixin('text');
this.message = this.opts.message;
this.message.is_me = this.message.user.id == this.I.id;
this.on('mount', () => {
if (this.message.text) {
const tokens = this.analyze(this.message.text);
const tokens = this.message.ast;
this.refs.text.innerHTML = this.compile(tokens);
this.refs.text.innerHTML = compile(tokens);
this.refs.text.children.forEach(e => {
if (e.tagName == 'MK-URL') riot.mount(e);

View file

@ -123,9 +123,10 @@
</style>
<script>
import MessagingStreamConnection from '../../scripts/messaging-stream';
this.mixin('i');
this.mixin('api');
this.mixin('messaging-stream');
this.user = this.opts.user;
this.init = true;
@ -133,7 +134,7 @@
this.messages = [];
this.isNaked = this.opts.isNaked;
this.connection = new this.MessagingStreamConnection(this.I, this.user.id);
this.connection = new MessagingStreamConnection(this.I, this.user.id);
this.on('mount', () => {
this.connection.event.on('message', this.onMessage);

View file

@ -87,12 +87,10 @@
</style>
<script>
this.mixin('text');
import compile from '../../common/scripts/text-compiler';
this.on('mount', () => {
this.mixin('text');
const tokens = this.analyze(this.text);
const text = this.compile(tokens);
const text = compile(this.ast);
this.refs.text.innerHTML = text;
});
</script>

View file

@ -2,7 +2,8 @@
<style>
:scope
display inline
</style>
<script>this.root.innerHTML = this.opts.content</script>
<script>
this.root.innerHTML = this.opts.content;
</script>
</mk-raw>

View file

@ -48,9 +48,12 @@
</style>
<script>
this.mixin('i');
this.mixin('api');
this.mixin('stream');
const stream = this.stream.event;
this.history = [];
this.fetching = true;
@ -62,11 +65,11 @@
});
});
this.stream.on('signin', this.onSignin);
stream.on('signin', this.onSignin);
});
this.on('unmount', () => {
this.stream.off('signin', this.onSignin);
stream.off('signin', this.onSignin);
});
this.onSignin = signin => {

View file

@ -175,7 +175,7 @@
</style>
<script>
this.mixin('api');
this.mixin('get-password-strength');
const getPasswordStrength = require('syuilo-password-strength');
this.usernameState = null;
this.passwordStrength = '';
@ -257,7 +257,7 @@
return;
}
const strength = this.getPasswordStrength(password);
const strength = getPasswordStrength(password);
this.passwordStrength = strength > 0.7 ? 'high' : strength > 0.3 ? 'medium' : 'low';
this.update();
this.refs.passwordMetar.style.width = `${strength * 100}%`;

View file

@ -1,13 +1,13 @@
<mk-stream-indicator>
<p if={ state == 'initializing' }>
<p if={ stream.state == 'initializing' }>
<i class="fa fa-spinner fa-spin"></i>
<span>接続中<mk-ellipsis></mk-ellipsis></span>
</p>
<p if={ state == 'reconnecting' }>
<p if={ stream.state == 'reconnecting' }>
<i class="fa fa-spinner fa-spin"></i>
<span>切断されました 接続中<mk-ellipsis></mk-ellipsis></span>
</p>
<p if={ state == 'connected' }>
<p if={ stream.state == 'connected' }>
<i class="fa fa-check"></i>
<span>接続完了</span>
</p>
@ -34,18 +34,16 @@
</style>
<script>
this.mixin('i');
this.mixin('stream');
this.on('before-mount', () => {
this.state = this.getStreamState();
if (this.state == 'connected') {
if (this.stream.state == 'connected') {
this.root.style.opacity = 0;
}
});
this.streamStateEv.on('connected', () => {
this.state = this.getStreamState();
this.stream.stateEv.on('connected', () => {
this.update();
setTimeout(() => {
Velocity(this.root, {
@ -54,8 +52,7 @@
}, 1000);
});
this.streamStateEv.on('closed', () => {
this.state = this.getStreamState();
this.stream.stateEv.on('closed', () => {
this.update();
Velocity(this.root, {
opacity: 1

View file

@ -97,7 +97,7 @@
this.loading = true;
this.on('mount', () => {
fetch(CONFIG.url + '/api:url?url=' + this.url).then(res => {
fetch('/api:url?url=' + this.url).then(res => {
res.json().then(info => {
this.title = info.title;
this.description = info.description;

View file

@ -1,41 +0,0 @@
const riot = require('riot');
module.exports = me => {
if (me) require('./scripts/stream')(me);
require('./scripts/user-preview');
riot.mixin('notify', {
notify: require('./scripts/notify')
});
const dialog = require('./scripts/dialog');
riot.mixin('dialog', {
dialog: dialog
});
riot.mixin('NotImplementedException', {
NotImplementedException: () => {
return dialog('<i class="fa fa-exclamation-triangle"></i>Not implemented yet', '要求された操作は実装されていません。<br>→<a href="https://github.com/syuilo/misskey" target="_blank">Misskeyの開発に参加する</a>', [{
text: 'OK'
}]);
}
});
riot.mixin('input-dialog', {
inputDialog: require('./scripts/input-dialog')
});
riot.mixin('update-avatar', {
updateAvatar: require('./scripts/update-avatar')
});
riot.mixin('update-banner', {
updateBanner: require('./scripts/update-banner')
});
riot.mixin('autocomplete', {
Autocomplete: require('./scripts/autocomplete')
});
};

View file

@ -0,0 +1 @@
require('./user-preview');

View file

@ -1,4 +1,4 @@
const riot = require('riot');
import * as riot from 'riot';
riot.mixin('user-preview', {
init: function() {

View file

@ -2,11 +2,11 @@
* Desktop App Router
*/
const riot = require('riot');
import * as riot from 'riot';
const route = require('page');
let page = null;
module.exports = me => {
export default me => {
route('/', index);
route('/i>mentions', mentions);
route('/post::post', post);

View file

@ -6,11 +6,11 @@
import './style.styl';
require('./tags');
const riot = require('riot');
const boot = require('../boot');
const mixins = require('./mixins');
const route = require('./router');
const fuckAdBlock = require('./scripts/fuck-ad-block');
require('./mixins');
import * as riot from 'riot';
import boot from '../boot';
import route from './router';
import fuckAdBlock from './scripts/fuck-ad-block';
/**
* Boot
@ -31,9 +31,6 @@ boot(me => {
}
}
// Register mixins
mixins(me);
// Start routing
route(me);
});

View file

@ -1,5 +1,5 @@
const getCaretCoordinates = require('textarea-caret');
const riot = require('riot');
import * as riot from 'riot';
/**
* オートコンプリートを管理するクラス
@ -127,4 +127,4 @@ class Autocomplete {
}
}
module.exports = Autocomplete;
export default Autocomplete;

View file

@ -1,6 +1,6 @@
const riot = require('riot');
import * as riot from 'riot';
module.exports = (title, text, buttons, canThrough, onThrough) => {
export default (title, text, buttons, canThrough, onThrough) => {
const dialog = document.body.appendChild(document.createElement('mk-dialog'));
const controller = riot.observable();
riot.mount(dialog, {

View file

@ -1,7 +1,7 @@
require('fuckadblock');
const dialog = require('./dialog');
module.exports = () => {
export default () => {
if (fuckAdBlock === undefined) {
adBlockDetected();
} else {

View file

@ -1,6 +1,6 @@
const riot = require('riot');
import * as riot from 'riot';
module.exports = (title, placeholder, defaultValue, onOk, onCancel) => {
export default (title, placeholder, defaultValue, onOk, onCancel) => {
const dialog = document.body.appendChild(document.createElement('mk-input-dialog'));
return riot.mount(dialog, {
title: title,

View file

@ -0,0 +1,8 @@
import dialog from './dialog';
export default () => {
dialog('<i class="fa fa-exclamation-triangle"></i>Not implemented yet',
'要求された操作は実装されていません。<br>→<a href="https://github.com/syuilo/misskey" target="_blank">Misskeyの開発に参加する</a>', [{
text: 'OK'
}]);
};

View file

@ -1,6 +1,6 @@
const riot = require('riot');
import * as riot from 'riot';
module.exports = message => {
export default message => {
const notification = document.body.appendChild(document.createElement('mk-ui-notification'));
riot.mount(notification, {
message: message

View file

@ -1,6 +1,5 @@
const stream = require('../../common/scripts/stream');
const getPostSummary = require('../../common/scripts/get-post-summary');
const riot = require('riot');
module.exports = me => {
const s = stream(me);
@ -37,9 +36,5 @@ module.exports = me => {
setTimeout(n.close.bind(n), 6000);
});
riot.mixin('stream', {
stream: s.event,
getStreamState: s.getState,
streamStateEv: s.stateEv
});
return s;
};

View file

@ -1,9 +1,9 @@
const riot = require('riot');
const CONFIG = require('../../common/scripts/config');
const dialog = require('./dialog');
const api = require('../../common/scripts/api');
import * as riot from 'riot';
import CONFIG from '../../common/scripts/config';
import dialog from './dialog';
import api from '../../common/scripts/api';
module.exports = (I, cb, file = null) => {
export default (I, cb, file = null) => {
const fileSelected = file => {
const cropper = riot.mount(document.body.appendChild(document.createElement('mk-crop-window')), {
file: file,

View file

@ -1,9 +1,9 @@
const riot = require('riot');
const CONFIG = require('../../common/scripts/config');
const dialog = require('./dialog');
const api = require('../../common/scripts/api');
import * as riot from 'riot';
import CONFIG from '../../common/scripts/config';
import dialog from './dialog';
import api from '../../common/scripts/api';
module.exports = (I, cb, file = null) => {
export default (I, cb, file = null) => {
const fileSelected = file => {
const cropper = riot.mount(document.body.appendChild(document.createElement('mk-crop-window')), {
file: file,

View file

@ -72,7 +72,7 @@
const length = Math.min(canvW, canvH) / 4;
const uv = new Vec2(Math.sin(angle), -Math.cos(angle));
ctx.beginPath();
ctx.strokeStyle = CONFIG.themeColor;
ctx.strokeStyle = THEME_COLOR;
ctx.lineWidth = 2;
ctx.moveTo(canvW / 2 - uv.x * length / 5, canvH / 2 - uv.y * length / 5);
ctx.lineTo(canvW / 2 + uv.x * length, canvH / 2 + uv.y * length);

View file

@ -80,7 +80,7 @@
</style>
<script>
const contains = require('../../common/scripts/contains');
import contains from '../../common/scripts/contains';
this.mixin('api');

View file

@ -70,12 +70,16 @@
</style>
<script>
import isPromise from '../../common/scripts/is-promise';
this.mixin('i');
this.mixin('api');
this.mixin('is-promise');
this.mixin('stream');
const stream = this.stream.event;
this.user = null;
this.userPromise = this.isPromise(this.opts.user)
this.userPromise = isPromise(this.opts.user)
? this.opts.user
: Promise.resolve(this.opts.user);
this.init = true;
@ -87,14 +91,14 @@
init: false,
user: user
});
this.stream.on('follow', this.onStreamFollow);
this.stream.on('unfollow', this.onStreamUnfollow);
stream.on('follow', this.onStreamFollow);
stream.on('unfollow', this.onStreamUnfollow);
});
});
this.on('unmount', () => {
this.stream.off('follow', this.onStreamFollow);
this.stream.off('unfollow', this.onStreamUnfollow);
stream.off('follow', this.onStreamFollow);
stream.off('unfollow', this.onStreamUnfollow);
});
this.onStreamFollow = user => {

View file

@ -95,7 +95,7 @@
</style>
<script>
const contains = require('../../common/scripts/contains');
import contains from '../../common/scripts/contains';
this.root.addEventListener('contextmenu', e => {
e.preventDefault();

View file

@ -158,7 +158,7 @@
</style>
<script>
this.mixin('cropper');
const Cropper = require('cropperjs');
this.image = this.opts.file;
this.title = this.opts.title;
@ -167,7 +167,7 @@
this.on('mount', () => {
this.img = this.refs.window.refs.img;
this.cropper = new this.Cropper(this.img, {
this.cropper = new Cropper(this.img, {
aspectRatio: this.aspectRatio,
highlight: false,
viewMode: 1

View file

@ -47,8 +47,8 @@
</style>
<script>
this.mixin('api');
this.mixin('i');
this.mixin('api');
this.close = e => {
e.preventDefault();

View file

@ -238,13 +238,16 @@
</style>
<script>
const contains = require('../../../common/scripts/contains');
import contains from '../../../common/scripts/contains';
import dialog from '../../scripts/dialog';
import inputDialog from '../../scripts/input-dialog';
this.mixin('i');
this.mixin('api');
this.mixin('dialog');
this.mixin('input-dialog');
this.mixin('stream');
const stream = this.stream.event;
this.files = [];
this.folders = [];
this.hierarchyFolders = [];
@ -276,10 +279,10 @@
});
});
this.stream.on('drive_file_created', this.onStreamDriveFileCreated);
this.stream.on('drive_file_updated', this.onStreamDriveFileUpdated);
this.stream.on('drive_folder_created', this.onStreamDriveFolderCreated);
this.stream.on('drive_folder_updated', this.onStreamDriveFolderUpdated);
stream.on('drive_file_created', this.onStreamDriveFileCreated);
stream.on('drive_file_updated', this.onStreamDriveFileUpdated);
stream.on('drive_folder_created', this.onStreamDriveFolderCreated);
stream.on('drive_folder_updated', this.onStreamDriveFolderUpdated);
// Riotのバグでnullを渡しても""になる
// https://github.com/riot/riot/issues/2080
@ -292,10 +295,10 @@
});
this.on('unmount', () => {
this.stream.off('drive_file_created', this.onStreamDriveFileCreated);
this.stream.off('drive_file_updated', this.onStreamDriveFileUpdated);
this.stream.off('drive_folder_created', this.onStreamDriveFolderCreated);
this.stream.off('drive_folder_updated', this.onStreamDriveFolderUpdated);
stream.off('drive_file_created', this.onStreamDriveFileCreated);
stream.off('drive_file_updated', this.onStreamDriveFileUpdated);
stream.off('drive_folder_created', this.onStreamDriveFolderCreated);
stream.off('drive_folder_updated', this.onStreamDriveFolderUpdated);
});
this.onStreamDriveFileCreated = file => {
@ -445,7 +448,7 @@
}).catch(err => {
switch (err) {
case 'detected-circular-definition':
this.dialog('<i class="fa fa-exclamation-triangle"></i>操作を完了できません',
dialog('<i class="fa fa-exclamation-triangle"></i>操作を完了できません',
'移動先のフォルダーは、移動するフォルダーのサブフォルダーです。', [{
text: 'OK'
}]);
@ -479,13 +482,13 @@
};
this.urlUpload = () => {
this.inputDialog('URLアップロード', 'アップロードしたいファイルのURL', null, url => {
inputDialog('URLアップロード', 'アップロードしたいファイルのURL', null, url => {
this.api('drive/files/upload_from_url', {
url: url,
folder_id: this.folder ? this.folder.id : undefined
});
this.dialog('<i class="fa fa-check"></i>アップロードをリクエストしました',
dialog('<i class="fa fa-check"></i>アップロードをリクエストしました',
'アップロードが完了するまで時間がかかる場合があります。', [{
text: 'OK'
}]);
@ -493,7 +496,7 @@
};
this.createFolder = () => {
this.inputDialog('フォルダー作成', 'フォルダー名', null, name => {
inputDialog('フォルダー作成', 'フォルダー名', null, name => {
this.api('drive/folders/create', {
name: name,
folder_id: this.folder ? this.folder.id : undefined

View file

@ -35,15 +35,14 @@
</ul>
</mk-contextmenu>
<script>
const copyToClipboard = require('../../../common/scripts/copy-to-clipboard');
import copyToClipboard from '../../../common/scripts/copy-to-clipboard';
import dialog from '../../scripts/dialog';
import inputDialog from '../../scripts/input-dialog';
import updateAvatar from '../../scripts/update-avatar';
import NotImplementedException from '../../scripts/not-implemented-exception';
this.mixin('api');
this.mixin('i');
this.mixin('update-avatar');
this.mixin('update-banner');
this.mixin('dialog');
this.mixin('input-dialog');
this.mixin('NotImplementedException');
this.mixin('api');
this.browser = this.opts.browser;
this.file = this.opts.file;
@ -85,16 +84,16 @@
this.setAvatar = () => {
this.refs.ctx.close();
this.updateAvatar(this.I, null, this.file);
updateAvatar(this.I, null, this.file);
};
this.setBanner = () => {
this.refs.ctx.close();
this.updateBanner(this.I, null, this.file);
updateBanner(this.I, null, this.file);
};
this.addApp = () => {
this.NotImplementedException();
NotImplementedException();
};
</script>
</mk-drive-browser-file-contextmenu>

View file

@ -144,13 +144,13 @@
</style>
<script>
this.bytesToSize = require('../../../common/scripts/bytes-to-size');
import bytesToSize from '../../../common/scripts/bytes-to-size';
this.mixin('i');
this.file = this.opts.file;
this.browser = this.parent;
this.title = `${this.file.name}\n${this.file.type} ${this.bytesToSize(this.file.datasize)}`;
this.title = `${this.file.name}\n${this.file.type} ${bytesToSize(this.file.datasize)}`;
this.isContextmenuShowing = false;
this.isSelected = this.browser.selectedFiles.some(f => f.id == this.file.id);

View file

@ -18,8 +18,9 @@
</ul>
</mk-contextmenu>
<script>
import inputDialog from '../../scripts/input-dialog';
this.mixin('api');
this.mixin('input-dialog');
this.browser = this.opts.browser;
this.folder = this.opts.folder;
@ -51,7 +52,7 @@
this.rename = () => {
this.refs.ctx.close();
this.inputDialog('フォルダ名の変更', '新しいフォルダ名を入力してください', this.folder.name, name => {
inputDialog('フォルダ名の変更', '新しいフォルダ名を入力してください', this.folder.name, name => {
this.api('drive/folders/update', {
folder_id: this.folder.id,
name: name

View file

@ -50,8 +50,9 @@
</style>
<script>
import dialog from '../../scripts/dialog';
this.mixin('api');
this.mixin('dialog');
this.folder = this.opts.folder;
this.browser = this.parent;
@ -144,7 +145,7 @@
}).catch(err => {
switch (err) {
case 'detected-circular-definition':
this.dialog('<i class="fa fa-exclamation-triangle"></i>操作を完了できません',
dialog('<i class="fa fa-exclamation-triangle"></i>操作を完了できません',
'移動先のフォルダーは、移動するフォルダーのサブフォルダーです。', [{
text: 'OK'
}]);

View file

@ -67,12 +67,16 @@
</style>
<script>
import isPromise from '../../common/scripts/is-promise';
this.mixin('i');
this.mixin('api');
this.mixin('is-promise');
this.mixin('stream');
const stream = this.stream.event;
this.user = null;
this.userPromise = this.isPromise(this.opts.user)
this.userPromise = isPromise(this.opts.user)
? this.opts.user
: Promise.resolve(this.opts.user);
this.init = true;
@ -84,14 +88,14 @@
init: false,
user: user
});
this.stream.on('follow', this.onStreamFollow);
this.stream.on('unfollow', this.onStreamUnfollow);
stream.on('follow', this.onStreamFollow);
stream.on('unfollow', this.onStreamUnfollow);
});
});
this.on('unmount', () => {
this.stream.off('follow', this.onStreamFollow);
this.stream.off('unfollow', this.onStreamUnfollow);
stream.off('follow', this.onStreamFollow);
stream.off('unfollow', this.onStreamUnfollow);
});
this.onStreamFollow = user => {

View file

@ -57,14 +57,17 @@
</style>
<script>
this.mixin('i');
this.mixin('api');
this.mixin('stream');
const stream = this.stream.event;
this.images = [];
this.initializing = true;
this.on('mount', () => {
this.stream.on('drive_file_created', this.onStreamDriveFileCreated);
stream.on('drive_file_created', this.onStreamDriveFileCreated);
this.api('drive/stream', {
type: 'image/*',
@ -78,7 +81,7 @@
});
this.on('unmount', () => {
this.stream.off('drive_file_created', this.onStreamDriveFileCreated);
stream.off('drive_file_created', this.onStreamDriveFileCreated);
});
this.onStreamDriveFileCreated = file => {

View file

@ -41,17 +41,19 @@
</style>
<script>
import inputDialog from '../../scripts/input-dialog';
import updateAvatar from '../../scripts/update-avatar';
import updateBanner from '../../scripts/update-banner';
this.mixin('i');
this.mixin('user-preview');
this.mixin('update-avatar');
this.mixin('update-banner');
this.setAvatar = () => {
this.updateAvatar(this.I);
updateAvatar(this.I);
};
this.setBanner = () => {
this.updateBanner(this.I);
updateBanner(this.I);
};
</script>
</mk-profile-home-widget>

View file

@ -65,7 +65,6 @@
</style>
<script>
this.mixin('api');
this.mixin('NotImplementedException');
this.url = 'http://news.yahoo.co.jp/pickup/rss.xml';
this.items = [];
@ -81,7 +80,7 @@
});
this.fetch = () => {
this.api(CONFIG.url + '/api:rss', {
this.api('/api:rss', {
url: this.url
}).then(feed => {
this.update({
@ -92,7 +91,6 @@
};
this.settings = () => {
this.NotImplementedException();
};
</script>
</mk-rss-reader-home-widget>

View file

@ -36,15 +36,17 @@
this.mixin('api');
this.mixin('stream');
const stream = this.stream.event;
this.isLoading = true;
this.isEmpty = false;
this.moreLoading = false;
this.noFollowing = this.I.following_count == 0;
this.on('mount', () => {
this.stream.on('post', this.onStreamPost);
this.stream.on('follow', this.onStreamFollow);
this.stream.on('unfollow', this.onStreamUnfollow);
stream.on('post', this.onStreamPost);
stream.on('follow', this.onStreamFollow);
stream.on('unfollow', this.onStreamUnfollow);
document.addEventListener('keydown', this.onDocumentKeydown);
window.addEventListener('scroll', this.onScroll);
@ -53,9 +55,9 @@
});
this.on('unmount', () => {
this.stream.off('post', this.onStreamPost);
this.stream.off('follow', this.onStreamFollow);
this.stream.off('unfollow', this.onStreamUnfollow);
stream.off('post', this.onStreamPost);
stream.off('follow', this.onStreamFollow);
stream.off('unfollow', this.onStreamUnfollow);
document.removeEventListener('keydown', this.onDocumentKeydown);
window.removeEventListener('scroll', this.onScroll);

View file

@ -177,10 +177,15 @@
</style>
<script>
import getPostSummary from '../../common/scripts/get-post-summary';
this.getPostSummary = getPostSummary;
this.mixin('i');
this.mixin('api');
this.mixin('stream');
this.mixin('user-preview');
this.mixin('get-post-summary');
this.mixin('stream');
const stream = this.stream.event;
this.notifications = [];
this.loading = true;
@ -193,11 +198,11 @@
});
});
this.stream.on('notification', this.onNotification);
stream.on('notification', this.onNotification);
});
this.on('unmount', () => {
this.stream.off('notification', this.onNotification);
stream.off('notification', this.onNotification);
});
this.onNotification = notification => {

View file

@ -7,11 +7,14 @@
display block
</style>
<script>
import Progress from '../../../common/scripts/loading';
import getPostSummary from '../../../common/scripts/get-post-summary';
this.mixin('i');
this.mixin('api');
this.mixin('ui-progress');
this.mixin('stream');
this.mixin('get-post-summary');
const stream = this.stream.event;
this.unreadCount = 0;
@ -19,23 +22,23 @@
this.on('mount', () => {
this.refs.ui.refs.home.on('loaded', () => {
this.Progress.done();
Progress.done();
});
document.title = 'Misskey';
this.Progress.start();
this.stream.on('post', this.onStreamPost);
Progress.start();
stream.on('post', this.onStreamPost);
document.addEventListener('visibilitychange', this.windowOnVisibilitychange, false);
});
this.on('unmount', () => {
this.stream.off('post', this.onStreamPost);
stream.off('post', this.onStreamPost);
document.removeEventListener('visibilitychange', this.windowOnVisibilitychange);
});
this.onStreamPost = post => {
if (document.hidden && post.user_id != this.I.id) {
this.unreadCount++;
document.title = `(${this.unreadCount}) ${this.getPostSummary(post)}`;
document.title = `(${this.unreadCount}) ${getPostSummary(post)}`;
}
};

View file

@ -16,19 +16,19 @@
</style>
<script>
this.mixin('ui-progress');
import Progress from '../../../common/scripts/loading';
this.post = this.opts.post;
this.on('mount', () => {
this.Progress.start();
Progress.start();
this.refs.ui.refs.detail.on('post-fetched', () => {
this.Progress.set(0.5);
Progress.set(0.5);
});
this.refs.ui.refs.detail.on('loaded', () => {
this.Progress.done();
Progress.done();
});
});
</script>

View file

@ -7,13 +7,13 @@
display block
</style>
<script>
this.mixin('ui-progress');
import Progress from '../../../common/scripts/loading';
this.on('mount', () => {
this.Progress.start();
Progress.start();
this.refs.ui.refs.search.on('loaded', () => {
this.Progress.done();
Progress.done();
});
});
</script>

View file

@ -7,20 +7,20 @@
display block
</style>
<script>
this.mixin('ui-progress');
import Progress from '../../../common/scripts/loading';
this.user = this.opts.user;
this.on('mount', () => {
this.Progress.start();
Progress.start();
this.refs.ui.refs.user.on('user-fetched', user => {
this.Progress.set(0.5);
Progress.set(0.5);
document.title = user.name + ' | Misskey'
});
this.refs.ui.refs.user.on('loaded', () => {
this.Progress.done();
Progress.done();
});
});
</script>

View file

@ -115,8 +115,10 @@
</style>
<script>
this.mixin('api');
this.mixin('text');
this.mixin('date-stringify');
import compile from '../../common/scripts/text-compiler';
this.dateStringify = require('../../common/scripts/date-stringify');
this.mixin('user-preview');
this.post = this.opts.post;
@ -124,9 +126,9 @@
this.on('mount', () => {
if (this.post.text) {
const tokens = this.analyze(this.post.text);
const tokens = this.post.ast;
this.refs.text.innerHTML = this.compile(tokens);
this.refs.text.innerHTML = compile(tokens);
this.refs.text.children.forEach(e => {
if (e.tagName == 'MK-URL') riot.mount(e);

View file

@ -340,9 +340,11 @@
</style>
<script>
this.mixin('api');
this.mixin('text');
import compile from '../../common/scripts/text-compiler';
this.mixin('user-preview');
this.mixin('date-stringify');
this.dateStringify = require('../../common/scripts/date-stringify');
this.mixin('NotImplementedException');
this.fetching = true;
@ -367,9 +369,9 @@
this.trigger('loaded');
if (this.p.text) {
const tokens = this.analyze(this.p.text);
const tokens = this.p.ast;
this.refs.text.innerHTML = this.compile(tokens);
this.refs.text.innerHTML = compile(tokens);
this.refs.text.children.forEach(e => {
if (e.tagName == 'MK-URL') riot.mount(e);

View file

@ -306,11 +306,11 @@
</style>
<script>
const getCat = require('../../common/scripts/get-cat');
import getCat from '../../common/scripts/get-cat';
import notify from '../scripts/notify';
import Autocomplete from '../scripts/autocomplete';
this.mixin('api');
this.mixin('notify');
this.mixin('autocomplete');
this.wait = false;
this.uploadings = [];
@ -355,7 +355,7 @@
this.trigger('change-uploading-files', uploads);
});
this.autocomplete = new this.Autocomplete(this.refs.text);
this.autocomplete = new Autocomplete(this.refs.text);
this.autocomplete.attach();
// 書きかけの投稿を復元
@ -488,13 +488,13 @@
this.clear();
this.removeDraft();
this.trigger('post');
this.notify(this.repost
notify(this.repost
? 'Repostしました'
: this.inReplyToPost
? '返信しました!'
: '投稿しました!');
}).catch(err => {
this.notify(this.repost
notify(this.repost
? 'Repostできませんでした'
: this.inReplyToPost
? '返信できませんでした'

View file

@ -83,11 +83,12 @@
</style>
<script>
this.mixin('date-stringify');
import dateStringify from '../../common/scripts/date-stringify';
this.mixin('user-preview');
this.post = this.opts.post;
this.title = this.dateStringify(this.post.created_at);
this.title = dateStringify(this.post.created_at);
</script>
</mk-post-preview>

View file

@ -85,8 +85,9 @@
</style>
<script>
import notify from '../scripts/notify';
this.mixin('api');
this.mixin('notify');
this.wait = false;
this.quote = false;
@ -101,9 +102,9 @@
repost_id: this.opts.post.id
}).then(data => {
this.trigger('posted');
this.notify('Repostしました');
notify('Repostしました');
}).catch(err => {
this.notify('Repostできませんでした');
notify('Repostできませんでした');
}).then(() => {
this.update({
wait: false

View file

@ -31,11 +31,12 @@
</style>
<script>
import updateAvatar from '../scripts/update-avatar';
this.mixin('i');
this.mixin('update-avatar');
this.set = () => {
this.updateAvatar(this.I);
updateAvatar(this.I);
};
this.close = e => {

View file

@ -31,11 +31,12 @@
</style>
<script>
import updateBanner from '../scripts/update-banner';
this.mixin('i');
this.mixin('update-banner');
this.set = () => {
this.updateBanner(this.I);
updateBanner(this.I);
};
this.close = e => {

View file

@ -188,11 +188,11 @@
</style>
<script>
import updateAvatar from '../scripts/update-avatar';
import notify from '../scripts/notify';
this.mixin('i');
this.mixin('api');
this.mixin('notify');
this.mixin('dialog');
this.mixin('update-avatar');
this.page = 'account';
@ -201,7 +201,7 @@
};
this.avatar = () => {
this.updateAvatar(this.I);
updateAvatar(this.I);
};
this.updateAccount = () => {
@ -211,7 +211,7 @@
description: this.refs.accountDescription.value || undefined,
birthday: this.refs.accountBirthday.value || undefined
}).then(() => {
this.notify('プロフィールを更新しました');
notify('プロフィールを更新しました');
});
};

Some files were not shown because too many files have changed in this diff Show more