1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-11-27 14:28:49 +09:00
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", "name": "misskey",
"author": "syuilo <i@syuilo.com>", "author": "syuilo <i@syuilo.com>",
"version": "0.0.1355", "version": "0.0.1361",
"license": "MIT", "license": "MIT",
"description": "A miniblog-based SNS", "description": "A miniblog-based SNS",
"bugs": "https://github.com/syuilo/misskey/issues", "bugs": "https://github.com/syuilo/misskey/issues",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
/** /**
* MISSKEY ENTRY POINT * MISSKEY CLIENT ENTRY POINT
*/ */
(() => { (() => {
const head = document.getElementsByTagName('head')[0]; 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', { riot.mixin('i', {
init: function() { init: function() {
this.I = me; 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 * API Request
*/ */
const CONFIG = require('./config'); import CONFIG from './config';
let spinner = null; let spinner = null;
let pending = 0; let pending = 0;
@ -14,7 +14,7 @@ let pending = 0;
* @param {any} [data={}] Data * @param {any} [data={}] Data
* @return {Promise<any>} Response * @return {Promise<any>} Response
*/ */
module.exports = (i, endpoint, data = {}) => { export default (i, endpoint, data = {}) => {
if (++pending === 1) { if (++pending === 1) {
spinner = document.createElement('div'); spinner = document.createElement('div');
spinner.setAttribute('id', 'wait'); spinner.setAttribute('id', 'wait');

View File

@ -1,6 +1,6 @@
module.exports = function(bytes) { export default bytes => {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return '0Byte'; if (bytes == 0) return '0Byte';
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
return Math.round(bytes / Math.pow(1024, i), 2) + sizes[i]; 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 devUrl = `${scheme}//dev.${host}`;
const aboutUrl = `${scheme}//about.${host}`; const aboutUrl = `${scheme}//about.${host}`;
module.exports = { export default {
host, host,
scheme, scheme,
url, url,

View File

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

View File

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

View File

@ -1,4 +1,4 @@
module.exports = date => { export default date => {
if (typeof date == 'string') date = new Date(date); if (typeof date == 'string') date = new Date(date);
return ( return (
date.getFullYear() + '年' + date.getFullYear() + '年' +

View File

@ -1,2 +1,2 @@
const gcd = (a, b) => !b ? a : gcd(b, a % b); 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 = { const home = {
left: [ left: [
@ -17,7 +17,7 @@ const home = {
] ]
}; };
module.exports = () => { export default () => {
const homeData = []; const homeData = [];
home.left.forEach(widget => { home.left.forEach(widget => {

View File

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

View File

@ -32,4 +32,4 @@ const summarize = post => {
return summary.trim(); 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]; const root = document.getElementsByTagName('html')[0];
module.exports = { export default {
start: () => { start: () => {
root.classList.add('progress'); root.classList.add('progress');
NProgress.start(); NProgress.start();

View File

@ -1,6 +1,6 @@
const ReconnectingWebSocket = require('reconnecting-websocket'); const ReconnectingWebSocket = require('reconnecting-websocket');
const riot = require('riot'); import * as riot from 'riot';
const CONFIG = require('./config'); import CONFIG from './config';
class Connection { class Connection {
constructor(me, otherparty) { 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'); localStorage.removeItem('me');
document.cookie = `i=; domain=.${CONFIG.host}; expires=Thu, 01 Jan 1970 00:00:01 GMT;`; document.cookie = `i=; domain=.${CONFIG.host}; expires=Thu, 01 Jan 1970 00:00:01 GMT;`;
location.href = '/'; location.href = '/';

View File

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

View File

@ -1,13 +1,13 @@
const riot = require('riot'); import * as riot from 'riot';
//const emojinize = require('emojinize'); //const emojinize = require('emojinize');
const CONFIG = require('./config'); import CONFIG from './config';
const escape = text => const escape = text =>
text text
.replace(/>/g, '&gt;') .replace(/>/g, '&gt;')
.replace(/</g, '&lt;'); .replace(/</g, '&lt;');
module.exports = (tokens, shouldBreak) => { export default (tokens, shouldBreak) => {
if (shouldBreak == null) { if (shouldBreak == null) {
shouldBreak = true; shouldBreak = true;
} }
@ -20,21 +20,21 @@ module.exports = (tokens, shouldBreak) => {
return escape(token.content) return escape(token.content)
.replace(/(\r\n|\n|\r)/g, shouldBreak ? '<br>' : ' '); .replace(/(\r\n|\n|\r)/g, shouldBreak ? '<br>' : ' ');
case 'bold': case 'bold':
return '<strong>' + escape(token.bold) + '</strong>'; return `<strong>${escape(token.bold)}</strong>`;
case 'url': 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': 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': 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 case 'hashtag': // TODO
return '<a>' + escape(token.content) + '</a>'; return `<a>${escape(token.content)}</a>`;
case 'code': case 'code':
return '<pre><code>' + token.html + '</code></pre>'; return `<pre><code>${token.html}</code></pre>`;
case 'inline-code': case 'inline-code':
return '<code>' + token.html + '</code>'; return `<code>${token.html}</code>`;
case 'emoji': case 'emoji':
return '<i>' + token.content + '</i>'; return `<i>${token.content}</i>`;
//return emojinize.encode(token.content) //return emojinize.encode(token.content)
} }
}).join(''); }).join('');

View File

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

View File

@ -1,8 +1,8 @@
<mk-introduction> <mk-introduction>
<article> <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> <h1>Misskeyとは</h1>
<p>Twitter, Facebook, LINE, Google+ などを<del>パクって</del><i>参考にして</i>います。</p> <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>無料で誰でも利用でき、広告掲載していません。</p>
<p><a href={ CONFIG.aboutUrl } target="_blank">もっと知りたい方はこちら</a></p> <p><a href={ CONFIG.aboutUrl } target="_blank">もっと知りたい方はこちら</a></p>
</article> </article>
<style> <style>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -97,7 +97,7 @@
this.loading = true; this.loading = true;
this.on('mount', () => { 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 => { res.json().then(info => {
this.title = info.title; this.title = info.title;
this.description = info.description; 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', { riot.mixin('user-preview', {
init: function() { init: function() {

View File

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

View File

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

View File

@ -1,5 +1,5 @@
const getCaretCoordinates = require('textarea-caret'); 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 dialog = document.body.appendChild(document.createElement('mk-dialog'));
const controller = riot.observable(); const controller = riot.observable();
riot.mount(dialog, { riot.mount(dialog, {

View File

@ -1,7 +1,7 @@
require('fuckadblock'); require('fuckadblock');
const dialog = require('./dialog'); const dialog = require('./dialog');
module.exports = () => { export default () => {
if (fuckAdBlock === undefined) { if (fuckAdBlock === undefined) {
adBlockDetected(); adBlockDetected();
} else { } 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')); const dialog = document.body.appendChild(document.createElement('mk-input-dialog'));
return riot.mount(dialog, { return riot.mount(dialog, {
title: title, 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')); const notification = document.body.appendChild(document.createElement('mk-ui-notification'));
riot.mount(notification, { riot.mount(notification, {
message: message message: message

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -35,15 +35,14 @@
</ul> </ul>
</mk-contextmenu> </mk-contextmenu>
<script> <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('i');
this.mixin('update-avatar'); this.mixin('api');
this.mixin('update-banner');
this.mixin('dialog');
this.mixin('input-dialog');
this.mixin('NotImplementedException');
this.browser = this.opts.browser; this.browser = this.opts.browser;
this.file = this.opts.file; this.file = this.opts.file;
@ -85,16 +84,16 @@
this.setAvatar = () => { this.setAvatar = () => {
this.refs.ctx.close(); this.refs.ctx.close();
this.updateAvatar(this.I, null, this.file); updateAvatar(this.I, null, this.file);
}; };
this.setBanner = () => { this.setBanner = () => {
this.refs.ctx.close(); this.refs.ctx.close();
this.updateBanner(this.I, null, this.file); updateBanner(this.I, null, this.file);
}; };
this.addApp = () => { this.addApp = () => {
this.NotImplementedException(); NotImplementedException();
}; };
</script> </script>
</mk-drive-browser-file-contextmenu> </mk-drive-browser-file-contextmenu>

View File

@ -144,13 +144,13 @@
</style> </style>
<script> <script>
this.bytesToSize = require('../../../common/scripts/bytes-to-size'); import bytesToSize from '../../../common/scripts/bytes-to-size';
this.mixin('i'); this.mixin('i');
this.file = this.opts.file; this.file = this.opts.file;
this.browser = this.parent; 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.isContextmenuShowing = false;
this.isSelected = this.browser.selectedFiles.some(f => f.id == this.file.id); this.isSelected = this.browser.selectedFiles.some(f => f.id == this.file.id);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -115,8 +115,10 @@
</style> </style>
<script> <script>
this.mixin('api'); 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.mixin('user-preview');
this.post = this.opts.post; this.post = this.opts.post;
@ -124,9 +126,9 @@
this.on('mount', () => { this.on('mount', () => {
if (this.post.text) { 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 => { this.refs.text.children.forEach(e => {
if (e.tagName == 'MK-URL') riot.mount(e); if (e.tagName == 'MK-URL') riot.mount(e);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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