This commit is contained in:
syuilo 2017-02-20 16:09:46 +09:00
parent 4c43573c1e
commit c05abf4da7
80 changed files with 400 additions and 366 deletions

View File

@ -112,13 +112,13 @@
this.app = @session.app this.app = @session.app
this.cancel = () => { this.cancel = () => {
this.api 'auth/deny' do this.api('auth/deny', {
token: @session.token token: @session.token
.then => .then =>
this.trigger('denied'); this.trigger('denied');
this.accept = () => { this.accept = () => {
this.api 'auth/accept' do this.api('auth/accept', {
token: @session.token token: @session.token
.then => .then =>
this.trigger('accepted'); this.trigger('accepted');

View File

@ -100,15 +100,15 @@
if not this.SIGNIN then return if not this.SIGNIN then return
// Fetch session // Fetch session
this.api 'auth/session/show' do this.api('auth/session/show', {
token: @token token: @token
.then (session) => }).then((session) => {
this.session = session this.session = session
this.fetching = false this.fetching = false
// 既に連携していた場合 // 既に連携していた場合
if @session.app.is_authorized if @session.app.is_authorized
this.api 'auth/accept' do this.api('auth/accept', {
token: @session.token token: @session.token
.then => .then =>
@accepted! @accepted!

View File

@ -310,10 +310,10 @@
if (q == '') { if (q == '') {
this.searchResult = []; this.searchResult = [];
} else { } else {
this.api 'users/search' do this.api('users/search', {
query: q query: q
max: 5 max: 5
.then (users) => }).then((users) => {
users.forEach (user) => users.forEach (user) =>
user._click = => user._click = =>
this.trigger 'navigate-user' user this.trigger 'navigate-user' user

View File

@ -56,7 +56,7 @@
this.on('mount', () => { this.on('mount', () => {
this.api 'i/signin_history' this.api 'i/signin_history'
.then (history) => }).then((history) => {
this.history = history this.history = history
this.fetching = false this.fetching = false
this.update(); this.update();

View File

@ -103,9 +103,9 @@
this.signing = false; this.signing = false;
this.oninput = () => { this.oninput = () => {
this.api 'users/show' do this.api('users/show', {
username: this.refs.username.value username: this.refs.username.value
.then (user) => }).then((user) => {
this.user = user this.user = user
this.trigger 'user' user this.trigger 'user' user
this.update(); this.update();
@ -123,7 +123,7 @@
this.signing = true this.signing = true
this.update(); this.update();
this.api 'signin' do this.api('signin', {
username: this.refs.username.value username: this.refs.username.value
password: this.refs.password.value password: this.refs.password.value
.then => .then =>

View File

@ -220,9 +220,9 @@
this.username-state = 'wait' this.username-state = 'wait'
this.update(); this.update();
this.api 'username/available' do this.api('username/available', {
username: username username: username
.then (result) => }).then((result) => {
if result.available if result.available
this.username-state = 'ok' this.username-state = 'ok'
else else
@ -271,14 +271,14 @@
const username = this.refs.username.value; const username = this.refs.username.value;
const password = this.refs.password.value; const password = this.refs.password.value;
locker = document.body.appendChild document.createElement 'mk-locker' locker = document.body.appendChild(document.createElement('mk-locker'));
this.api 'signup' do this.api('signup', {
username: username, username: username,
password: password, password: password,
'g-recaptcha-response': grecaptcha.getResponse() 'g-recaptcha-response': grecaptcha.getResponse()
.then => .then =>
this.api 'signin' do this.api('signin', {
username: username username: username
password: password password: password
.then => .then =>

View File

@ -95,10 +95,10 @@
Array.prototype.forEach.call all, (el) => Array.prototype.forEach.call all, (el) =>
el.addEventListener 'mousedown' @mousedown el.addEventListener 'mousedown' @mousedown
this.api 'users/search_by_username' do this.api('users/search_by_username', {
query: @q query: @q
limit: 30users limit: 30users
.then (users) => }).then((users) => {
this.users = users this.users = users
this.loading = false this.loading = false
this.update(); this.update();
@ -114,7 +114,7 @@
this.mousedown = (e) => { this.mousedown = (e) => {
if (!contains this.root, e.target) and (this.root != e.target) if (!contains this.root, e.target) and (this.root != e.target)
@close! @close();
this.on-click = (e) => { this.on-click = (e) => {
@complete e.item @complete e.item
@ -128,24 +128,24 @@
e.stopPropagation(); e.stopPropagation();
@complete this.users[@select] @complete this.users[@select]
else else
@close! @close();
| 27 => // Key[ESC] | 27 => // Key[ESC]
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@close! @close();
| 38 => // Key[↑] | 38 => // Key[↑]
if @select != -1 if @select != -1
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@select-prev! @select-prev!
else else
@close! @close();
| 9, 40 => // Key[TAB] or Key[↓] | 9, 40 => // Key[TAB] or Key[↓]
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@select-next! @select-next!
| _ => | _ =>
@close! @close();
this.select-next = () => { this.select-next = () => {
@select++ @select++
@ -174,7 +174,7 @@
this.opts.complete user this.opts.complete user
this.close = () => { this.close = () => {
this.opts.close! this.opts.close();
function contains(parent, child) function contains(parent, child)
node = child.parentNode node = child.parentNode

View File

@ -80,7 +80,7 @@
this.wait = false this.wait = false
this.on('mount', () => { this.on('mount', () => {
this.user-promise.then (user) => this.user-promise}).then((user) => {
this.user = user this.user = user
this.init = false this.init = false
this.update(); this.update();
@ -104,7 +104,7 @@
this.onclick = () => { this.onclick = () => {
this.wait = true this.wait = true
if this.user.is_following if this.user.is_following
this.api 'following/delete' do this.api('following/delete', {
user_id: this.user.id user_id: this.user.id
.then => .then =>
this.user.is_following = false this.user.is_following = false
@ -114,7 +114,7 @@
this.wait = false this.wait = false
this.update(); this.update();
else else
this.api 'following/create' do this.api('following/create', {
user_id: this.user.id user_id: this.user.id
.then => .then =>
this.user.is_following = true this.user.is_following = true

View File

@ -100,7 +100,7 @@
this.mousedown = (e) => { this.mousedown = (e) => {
e.preventDefault(); e.preventDefault();
if (!contains this.root, e.target) and (this.root != e.target) if (!contains this.root, e.target) and (this.root != e.target)
@close! @close();
return false return false
this.open = (pos) => { this.open = (pos) => {

View File

@ -175,14 +175,14 @@
this.ok = () => { this.ok = () => {
@cropper.get-cropped-canvas!.to-blob (blob) => @cropper.get-cropped-canvas!.to-blob (blob) =>
this.trigger 'cropped' blob this.trigger 'cropped' blob
this.refs.window.close! this.refs.window.close();
this.skip = () => { this.skip = () => {
this.trigger('skiped'); this.trigger('skiped');
this.refs.window.close! this.refs.window.close();
this.cancel = () => { this.cancel = () => {
this.trigger('canceled'); this.trigger('canceled');
this.refs.window.close! this.refs.window.close();
</script> </script>
</mk-crop-window> </mk-crop-window>

View File

@ -84,7 +84,7 @@
button._onclick = => button._onclick = =>
if button.onclick? if button.onclick?
button.onclick(); button.onclick();
@close! @close();
this.on('mount', () => { this.on('mount', () => {
this.refs.header.innerHTML = this.opts.title this.refs.header.innerHTML = this.opts.title
@ -142,6 +142,6 @@
if @can-through if @can-through
if this.opts.on-through? if this.opts.on-through?
this.opts.on-through! this.opts.on-through!
@close! @close();
</script> </script>
</mk-dialog> </mk-dialog>

View File

@ -54,11 +54,13 @@
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
this.I.data.no_donation = true this.I.data.no_donation = true;
this.I.update! this.I.update();
this.api 'i/appdata/set' do this.api('i/appdata/set', {
data: JSON.stringify do data: JSON.stringify({
no_donation: this.I.data.no_donation no_donation: this.I.data.no_donation
})
});
this.unmount(); this.unmount();
}; };

View File

@ -23,16 +23,16 @@
this.open = (pos) => { this.open = (pos) => {
this.refs.ctx.open pos this.refs.ctx.open pos
this.create-folder = () => { this.createFolder = () => {
this.browser.create-folder! this.browser.createFolder!
this.refs.ctx.close! this.refs.ctx.close();
this.upload = () => { this.upload = () => {
this.browser.select-local-file! this.browser.select-local-file!
this.refs.ctx.close! this.refs.ctx.close();
this.url-upload = () => { this.url-upload = () => {
this.browser.url-upload! this.browser.url-upload!
this.refs.ctx.close! this.refs.ctx.close();
</script> </script>
</mk-drive-browser-base-contextmenu> </mk-drive-browser-base-contextmenu>

View File

@ -36,11 +36,11 @@
this.refs.window.on('closed', () => { this.refs.window.on('closed', () => {
this.unmount(); this.unmount();
this.api 'drive' .then (info) => this.api 'drive' }).then((info) => {
@update do @update do
usage: info.usage / info.capacity * 100 usage: info.usage / info.capacity * 100
this.close = () => { this.close = () => {
this.refs.window.close! this.refs.window.close();
</script> </script>
</mk-drive-browser-window> </mk-drive-browser-window>

View File

@ -405,7 +405,7 @@
if (this.files.some (f) => f.id == file) if (this.files.some (f) => f.id == file)
return false return false
@remove-file file @remove-file file
this.api 'drive/files/update' do this.api('drive/files/update', {
file_id: file file_id: file
folder_id: if this.folder? then this.folder.id else null folder_id: if this.folder? then this.folder.id else null
.then => .then =>
@ -422,7 +422,7 @@
if (this.folders.some (f) => f.id == folder) if (this.folders.some (f) => f.id == folder)
return false return false
@remove-folder folder @remove-folder folder
this.api 'drive/folders/update' do this.api('drive/folders/update', {
folder_id: folder folder_id: folder
parent_id: if this.folder? then this.folder.id else null parent_id: if this.folder? then this.folder.id else null
.then => .then =>
@ -442,7 +442,7 @@
e.preventDefault(); e.preventDefault();
e.stopImmediatePropagation(); e.stopImmediatePropagation();
ctx = document.body.appendChild document.createElement 'mk-drive-browser-base-contextmenu' ctx = document.body.appendChild(document.createElement('mk-drive-browser-base-contextmenu'));
ctx = riot.mount ctx, do ctx = riot.mount ctx, do
browser: this browser: this
ctx = ctx.0 ctx = ctx.0
@ -462,7 +462,7 @@
null null
if url? and url != '' if url? and url != ''
this.api 'drive/files/upload_from_url' do this.api('drive/files/upload_from_url', {
url: url url: url
folder_id: if this.folder? then this.folder.id else undefined folder_id: if this.folder? then this.folder.id else undefined
@ -473,16 +473,16 @@
text: 'OK' text: 'OK'
] ]
this.create-folder = () => { this.createFolder = () => {
name <~ @input-dialog do name <~ @input-dialog do
'フォルダー作成' 'フォルダー作成'
'フォルダー名' 'フォルダー名'
null null
this.api 'drive/folders/create' do this.api('drive/folders/create', {
name: name name: name
folder_id: if this.folder? then this.folder.id else undefined folder_id: if this.folder? then this.folder.id else undefined
.then (folder) => }).then((folder) => {
@add-folder folder, true @add-folder folder, true
this.update(); this.update();
.catch (err) => .catch (err) =>
@ -502,8 +502,8 @@
this.get-selection = () => { this.get-selection = () => {
this.files.filter (file) -> file._selected this.files.filter (file) -> file._selected
this.new-window = (folder-id) => { this.newWindow = (folder-id) => {
browser = document.body.appendChild document.createElement 'mk-drive-browser-window' browser = document.body.appendChild(document.createElement('mk-drive-browser-window'));
riot.mount browser, do riot.mount browser, do
folder: folder-id folder: folder-id
@ -518,9 +518,9 @@
this.loading = true this.loading = true
this.update(); this.update();
this.api 'drive/folders/show' do this.api('drive/folders/show', {
folder_id: target-folder folder_id: target-folder
.then (folder) => }).then((folder) => {
this.folder = folder this.folder = folder
this.hierarchyFolders = [] this.hierarchyFolders = []
@ -607,10 +607,10 @@
files-max = 30 files-max = 30
// フォルダ一覧取得 // フォルダ一覧取得
this.api 'drive/folders' do this.api('drive/folders', {
folder_id: if this.folder? then this.folder.id else null folder_id: if this.folder? then this.folder.id else null
limit: folders-max + 1 limit: folders-max + 1
.then (folders) => }).then((folders) => {
if folders.length == folders-max + 1 if folders.length == folders-max + 1
this.more-folders = true this.more-folders = true
folders.pop! folders.pop!
@ -620,10 +620,10 @@
console.error err console.error err
// ファイル一覧取得 // ファイル一覧取得
this.api 'drive/files' do this.api('drive/files', {
folder_id: if this.folder? then this.folder.id else null folder_id: if this.folder? then this.folder.id else null
limit: files-max + 1 limit: files-max + 1
.then (files) => }).then((files) => {
if files.length == files-max + 1 if files.length == files-max + 1
this.more-files = true this.more-files = true
files.pop! files.pop!

View File

@ -58,14 +58,14 @@
this.refs.ctx.open pos this.refs.ctx.open pos
this.rename = () => { this.rename = () => {
this.refs.ctx.close! this.refs.ctx.close();
name <~ @input-dialog do name <~ @input-dialog do
'ファイル名の変更' 'ファイル名の変更'
'新しいファイル名を入力してください' '新しいファイル名を入力してください'
this.file.name this.file.name
this.api 'drive/files/update' do this.api('drive/files/update', {
file_id: this.file.id file_id: this.file.id
name: name name: name
.then => .then =>
@ -77,18 +77,18 @@
@NotImplementedException! @NotImplementedException!
this.download = () => { this.download = () => {
this.refs.ctx.close! this.refs.ctx.close();
this.set-avatar = () => { this.set-avatar = () => {
this.refs.ctx.close! this.refs.ctx.close();
@update-avatar this.I, null, this.file @update-avatar this.I, null, this.file
this.set-banner = () => { this.set-banner = () => {
this.refs.ctx.close! this.refs.ctx.close();
@update-banner this.I, null, this.file @update-banner this.I, null, this.file
this.set-wallpaper = () => { this.set-wallpaper = () => {
this.refs.ctx.close! this.refs.ctx.close();
@update-wallpaper this.I, null, this.file @update-wallpaper this.I, null, this.file
this.add-app = () => { this.add-app = () => {

View File

@ -177,7 +177,7 @@
this.is-contextmenu-showing = true this.is-contextmenu-showing = true
this.update(); this.update();
ctx = document.body.appendChild document.createElement 'mk-drive-browser-file-contextmenu' ctx = document.body.appendChild(document.createElement('mk-drive-browser-file-contextmenu'));
ctx = riot.mount ctx, do ctx = riot.mount ctx, do
browser: this.browser browser: this.browser
file: this.file file: this.file

View File

@ -21,11 +21,11 @@
this.mixin('api'); this.mixin('api');
this.mixin('input-dialog'); this.mixin('input-dialog');
this.browser = this.opts.browser this.browser = this.opts.browser;
this.folder = this.opts.folder this.folder = this.opts.folder;
this.open = (pos) => { this.open = pos => {
this.refs.ctx.open pos this.refs.ctx.open(pos);
this.refs.ctx.on('closed', () => { this.refs.ctx.on('closed', () => {
this.trigger('closed'); this.trigger('closed');
@ -33,29 +33,25 @@
this.move = () => { this.move = () => {
this.browser.move this.folder.id this.browser.move this.folder.id
this.refs.ctx.close! this.refs.ctx.close();
this.new-window = () => { this.newWindow = () => {
this.browser.new-window this.folder.id this.browser.newWindow this.folder.id
this.refs.ctx.close! this.refs.ctx.close();
this.create-folder = () => { this.createFolder = () => {
this.browser.create-folder! this.browser.createFolder();
this.refs.ctx.close! this.refs.ctx.close();
this.upload = () => {
this.browser.select-lcoal-file!
this.refs.ctx.close!
this.rename = () => { this.rename = () => {
this.refs.ctx.close! this.refs.ctx.close();
name <~ @input-dialog do name <~ @input-dialog do
'フォルダ名の変更' 'フォルダ名の変更'
'新しいフォルダ名を入力してください' '新しいフォルダ名を入力してください'
this.folder.name this.folder.name
this.api 'drive/folders/update' do this.api('drive/folders/update', {
folder_id: this.folder.id folder_id: this.folder.id
name: name name: name
.then => .then =>

View File

@ -115,7 +115,7 @@
if obj.type == 'file' if obj.type == 'file'
file = obj.id file = obj.id
this.browser.remove-file file this.browser.remove-file file
this.api 'drive/files/update' do this.api('drive/files/update', {
file_id: file file_id: file
folder_id: this.folder.id folder_id: this.folder.id
.then => .then =>
@ -130,7 +130,7 @@
if folder == this.folder.id if folder == this.folder.id
return false return false
this.browser.remove-folder folder this.browser.remove-folder folder
this.api 'drive/folders/update' do this.api('drive/folders/update', {
folder_id: folder folder_id: folder
parent_id: this.folder.id parent_id: this.folder.id
.then => .then =>
@ -167,7 +167,7 @@
this.is-contextmenu-showing = true this.is-contextmenu-showing = true
this.update(); this.update();
ctx = document.body.appendChild document.createElement 'mk-drive-browser-folder-contextmenu' ctx = document.body.appendChild(document.createElement('mk-drive-browser-folder-contextmenu'));
ctx = riot.mount ctx, do ctx = riot.mount ctx, do
browser: this.browser browser: this.browser
folder: this.folder folder: this.folder

View File

@ -69,7 +69,7 @@
if obj.type == 'file' if obj.type == 'file'
file = obj.id file = obj.id
this.browser.remove-file file this.browser.remove-file file
this.api 'drive/files/update' do this.api('drive/files/update', {
file_id: file file_id: file
folder_id: if this.folder? then this.folder.id else null folder_id: if this.folder? then this.folder.id else null
.then => .then =>
@ -84,7 +84,7 @@
if this.folder? and folder == this.folder.id if this.folder? and folder == this.folder.id
return false return false
this.browser.remove-folder folder this.browser.remove-folder folder
this.api 'drive/folders/update' do this.api('drive/folders/update', {
folder_id: folder folder_id: folder
parent_id: if this.folder? then this.folder.id else null parent_id: if this.folder? then this.folder.id else null
.then => .then =>

View File

@ -77,7 +77,7 @@
this.wait = false this.wait = false
this.on('mount', () => { this.on('mount', () => {
this.user-promise.then (user) => this.user-promise}).then((user) => {
this.user = user this.user = user
this.init = false this.init = false
this.update(); this.update();
@ -101,7 +101,7 @@
this.onclick = () => { this.onclick = () => {
this.wait = true this.wait = true
if this.user.is_following if this.user.is_following
this.api 'following/delete' do this.api('following/delete', {
user_id: this.user.id user_id: this.user.id
.then => .then =>
this.user.is_following = false this.user.is_following = false
@ -111,7 +111,7 @@
this.wait = false this.wait = false
this.update(); this.update();
else else
this.api 'following/create' do this.api('following/create', {
user_id: this.user.id user_id: this.user.id
.then => .then =>
this.user.is_following = true this.user.is_following = true

View File

@ -140,10 +140,10 @@
this.users = null this.users = null
this.update(); this.update();
this.api 'users/recommendation' do this.api('users/recommendation', {
limit: @limit limit: @limit
offset: @limit * this.page offset: @limit * this.page
.then (users) => }).then((users) => {
this.loading = false this.loading = false
this.users = users this.users = users
this.update(); this.update();

View File

@ -72,9 +72,9 @@
this.refs.timeline.focus(); this.refs.timeline.focus();
this.fetch = (cb) => { this.fetch = (cb) => {
this.api 'posts/mentions' do this.api('posts/mentions', {
following: this.mode == 'following' following: this.mode == 'following'
.then (posts) => }).then((posts) => {
this.is-loading = false this.is-loading = false
this.is-empty = posts.length == 0 this.is-empty = posts.length == 0
this.update(); this.update();
@ -89,10 +89,10 @@
return return
this.more-loading = true this.more-loading = true
this.update(); this.update();
this.api 'posts/mentions' do this.api('posts/mentions', {
following: this.mode == 'following' following: this.mode == 'following'
max_id: this.refs.timeline.tail!.id max_id: this.refs.timeline.tail!.id
.then (posts) => }).then((posts) => {
this.more-loading = false this.more-loading = false
this.update(); this.update();
this.refs.timeline.prepend-posts posts this.refs.timeline.prepend-posts posts

View File

@ -66,10 +66,10 @@
this.on('mount', () => { this.on('mount', () => {
this.stream.on 'drive_file_created' this.on-stream-drive-file-created this.stream.on 'drive_file_created' this.on-stream-drive-file-created
this.api 'drive/stream' do this.api('drive/stream', {
type: 'image/*' type: 'image/*'
limit: 9images limit: 9images
.then (images) => }).then((images) => {
this.initializing = false this.initializing = false
this.images = images this.images = images
this.update(); this.update();

View File

@ -81,7 +81,7 @@
this.fetch = () => { this.fetch = () => {
this.api CONFIG.url + '/api:rss' do this.api CONFIG.url + '/api:rss' do
url: @url url: @url
.then (feed) => }).then((feed) => {
this.items = feed.rss.channel.item this.items = feed.rss.channel.item
this.initializing = false this.initializing = false
this.update(); this.update();

View File

@ -68,7 +68,7 @@
this.load = (cb) => { this.load = (cb) => {
this.api 'posts/timeline' this.api 'posts/timeline'
.then (posts) => }).then((posts) => {
this.is-loading = false this.is-loading = false
this.is-empty = posts.length == 0 this.is-empty = posts.length == 0
this.update(); this.update();
@ -83,9 +83,9 @@
return return
this.more-loading = true this.more-loading = true
this.update(); this.update();
this.api 'posts/timeline' do this.api('posts/timeline', {
max_id: this.refs.timeline.tail!.id max_id: this.refs.timeline.tail!.id
.then (posts) => }).then((posts) => {
this.more-loading = false this.more-loading = false
this.update(); this.update();
this.refs.timeline.prepend-posts posts this.refs.timeline.prepend-posts posts

View File

@ -132,10 +132,10 @@
this.loading = true this.loading = true
this.users = null this.users = null
if not quiet then this.update(); if not quiet then this.update();
this.api 'users/recommendation' do this.api('users/recommendation', {
limit: @limit limit: @limit
offset: @limit * this.page offset: @limit * this.page
.then (users) => }).then((users) => {
this.loading = false this.loading = false
this.users = users this.users = users
this.update(); this.update();

View File

@ -38,7 +38,7 @@
this.refs.view.style.background-position = xp + '% ' + yp + '%' this.refs.view.style.background-position = xp + '% ' + yp + '%'
this.click = () => { this.click = () => {
dialog = document.body.appendChild document.createElement 'mk-image-dialog' dialog = document.body.appendChild(document.createElement('mk-image-dialog'));
riot.mount dialog, do riot.mount dialog, do
image: @image image: @image
</script> </script>

View File

@ -141,12 +141,12 @@
this.cancel = () => { this.cancel = () => {
this.done = false this.done = false
this.refs.window.close! this.refs.window.close();
this.ok = () => { this.ok = () => {
if not @allow-empty and @text.value == '' then return if not @allow-empty and @text.value == '' then return
this.done = true this.done = true
this.refs.window.close! this.refs.window.close();
this.on-keydown = (e) => { this.on-keydown = (e) => {
if e.which == 13 // Enter if e.which == 13 // Enter

View File

@ -24,7 +24,7 @@
this.unmount(); this.unmount();
this.refs.window.refs.index.on('navigate-user', user => { this.refs.window.refs.index.on('navigate-user', user => {
w = document.body.appendChild document.createElement 'mk-messaging-room-window' w = document.body.appendChild(document.createElement('mk-messaging-room-window'));
riot.mount w, do riot.mount w, do
user: user user: user
</script> </script>

View File

@ -187,7 +187,7 @@
this.on('mount', () => { this.on('mount', () => {
this.api 'i/notifications' this.api 'i/notifications'
.then (notifications) => }).then((notifications) => {
this.notifications = notifications this.notifications = notifications
this.loading = false this.loading = false
this.update(); this.update();

View File

@ -125,13 +125,13 @@
this.like = () => { this.like = () => {
if this.post.is_liked if this.post.is_liked
this.api 'posts/likes/delete' do this.api('posts/likes/delete', {
post_id: this.post.id post_id: this.post.id
.then => .then =>
this.post.is_liked = false this.post.is_liked = false
this.update(); this.update();
else else
this.api 'posts/likes/create' do this.api('posts/likes/create', {
post_id: this.post.id post_id: this.post.id
.then => .then =>
this.post.is_liked = true this.post.is_liked = true

View File

@ -342,9 +342,9 @@
this.on('mount', () => { this.on('mount', () => {
this.api 'posts/show' do this.api('posts/show', {
post_id: this.opts.post post_id: this.opts.post
.then (post) => }).then((post) => {
this.fetching = false this.fetching = false
this.post = post this.post = post
this.trigger('loaded'); this.trigger('loaded');
@ -368,55 +368,55 @@
tokens tokens
.filter (t) -> t.type == 'link' .filter (t) -> t.type == 'link'
.map (t) => .map (t) =>
this.preview = this.refs.text.appendChild document.createElement 'mk-url-preview' this.preview = this.refs.text.appendChild(document.createElement('mk-url-preview'));
riot.mount this.preview, do riot.mount this.preview, do
url: t.content url: t.content
// Get likes // Get likes
this.api 'posts/likes' do this.api('posts/likes', {
post_id: this.p.id post_id: this.p.id
limit: 8 limit: 8
.then (likes) => }).then((likes) => {
this.likes = likes this.likes = likes
this.update(); this.update();
// Get reposts // Get reposts
this.api 'posts/reposts' do this.api('posts/reposts', {
post_id: this.p.id post_id: this.p.id
limit: 8 limit: 8
.then (reposts) => }).then((reposts) => {
this.reposts = reposts this.reposts = reposts
this.update(); this.update();
// Get replies // Get replies
this.api 'posts/replies' do this.api('posts/replies', {
post_id: this.p.id post_id: this.p.id
limit: 8 limit: 8
.then (replies) => }).then((replies) => {
this.replies = replies this.replies = replies
this.update(); this.update();
this.update(); this.update();
this.reply = () => { this.reply = () => {
form = document.body.appendChild document.createElement 'mk-post-form-window' form = document.body.appendChild(document.createElement('mk-post-form-window'));
riot.mount form, do riot.mount form, do
reply: this.p reply: this.p
this.repost = () => { this.repost = () => {
form = document.body.appendChild document.createElement 'mk-repost-form-window' form = document.body.appendChild(document.createElement('mk-repost-form-window'));
riot.mount form, do riot.mount form, do
post: this.p post: this.p
this.like = () => { this.like = () => {
if this.p.is_liked if this.p.is_liked
this.api 'posts/likes/delete' do this.api('posts/likes/delete', {
post_id: this.p.id post_id: this.p.id
.then => .then =>
this.p.is_liked = false this.p.is_liked = false
this.update(); this.update();
else else
this.api 'posts/likes/create' do this.api('posts/likes/create', {
post_id: this.p.id post_id: this.p.id
.then => .then =>
this.p.is_liked = true this.p.is_liked = true
@ -426,9 +426,9 @@
this.loading-context = true this.loading-context = true
// Get context // Get context
this.api 'posts/context' do this.api('posts/context', {
post_id: this.p.reply_to_id post_id: this.p.reply_to_id
.then (context) => }).then((context) => {
this.context = context.reverse! this.context = context.reverse!
this.loading-context = false this.loading-context = false
this.update(); this.update();

View File

@ -42,7 +42,7 @@
this.unmount(); this.unmount();
this.refs.window.refs.form.on('post', () => { this.refs.window.refs.form.on('post', () => {
this.refs.window.close! this.refs.window.close();
this.refs.window.refs.form.on('change-uploading-files', (files) => { this.refs.window.refs.form.on('change-uploading-files', (files) => {
this.uploading-files = files this.uploading-files = files

View File

@ -405,7 +405,7 @@
this.refs.file.click(); this.refs.file.click();
this.select-file-from-drive = () => { this.select-file-from-drive = () => {
browser = document.body.appendChild document.createElement 'mk-select-file-from-drive-window' browser = document.body.appendChild(document.createElement('mk-select-file-from-drive-window'));
i = riot.mount browser, do i = riot.mount browser, do
multiple: true multiple: true
i[0].one 'selected' (files) => i[0].one 'selected' (files) =>
@ -444,12 +444,12 @@
then this.files.map (f) -> f.id then this.files.map (f) -> f.id
else undefined else undefined
this.api 'posts/create' do this.api('posts/create', {
text: this.refs.text.value text: this.refs.text.value
media_ids: files media_ids: files
reply_to_id: if @in-reply-to-post? then @in-reply-to-post.id else undefined reply_to_id: if @in-reply-to-post? then @in-reply-to-post.id else undefined
poll: if this.poll then this.refs.poll.get! else undefined poll: if this.poll then this.refs.poll.get! else undefined
.then (data) => }).then((data) => {
this.trigger('post'); this.trigger('post');
@notify if @in-reply-to-post? then '返信しました!' else '投稿しました!' @notify if @in-reply-to-post? then '返信しました!' else '投稿しました!'
.catch (err) => .catch (err) =>

View File

@ -20,22 +20,22 @@
this.post = post this.post = post
this.update(); this.update();
this.api 'aggregation/posts/like' do this.api('aggregation/posts/like', {
post_id: this.post.id post_id: this.post.id
limit: 30days limit: 30days
.then (likes) => }).then((likes) => {
likes = likes.reverse! likes = likes.reverse!
this.api 'aggregation/posts/repost' do this.api('aggregation/posts/repost', {
post_id: this.post.id post_id: this.post.id
limit: 30days limit: 30days
.then (repost) => }).then((repost) => {
repost = repost.reverse! repost = repost.reverse!
this.api 'aggregation/posts/reply' do this.api('aggregation/posts/reply', {
post_id: this.post.id post_id: this.post.id
limit: 30days limit: 30days
.then (replies) => }).then((replies) => {
replies = replies.reverse! replies = replies.reverse!
new Chart this.refs.canv, do new Chart this.refs.canv, do

View File

@ -89,6 +89,6 @@
this.update(); this.update();
this.close = () => { this.close = () => {
this.refs.window.close! this.refs.window.close();
</script> </script>
</mk-progress-dialog> </mk-progress-dialog>

View File

@ -16,14 +16,14 @@
tag = e.target.tag-name.to-lower-case! tag = e.target.tag-name.to-lower-case!
if tag != 'input' and tag != 'textarea' if tag != 'input' and tag != 'textarea'
if e.which == 27 // Esc if e.which == 27 // Esc
this.refs.window.close! this.refs.window.close();
this.on('mount', () => { this.on('mount', () => {
this.refs.window.refs.form.on('cancel', () => { this.refs.window.refs.form.on('cancel', () => {
this.refs.window.close! this.refs.window.close();
this.refs.window.refs.form.on('posted', () => { this.refs.window.refs.form.on('posted', () => {
this.refs.window.close! this.refs.window.close();
document.addEventListener 'keydown' this.on-document-keydown document.addEventListener 'keydown' this.on-document-keydown

View File

@ -125,10 +125,10 @@
this.ok = () => { this.ok = () => {
this.wait = true this.wait = true
this.api 'posts/create' do this.api('posts/create', {
repost_id: this.opts.post.id repost_id: this.opts.post.id
text: if @quote then this.refs.text.value else undefined text: if @quote then this.refs.text.value else undefined
.then (data) => }).then((data) => {
this.trigger('posted'); this.trigger('posted');
@notify 'Repostしました' @notify 'Repostしました'
.catch (err) => .catch (err) =>

View File

@ -41,9 +41,9 @@
document.addEventListener 'keydown' this.on-document-keydown document.addEventListener 'keydown' this.on-document-keydown
window.addEventListener 'scroll' this.on-scroll window.addEventListener 'scroll' this.on-scroll
this.api 'posts/search' do this.api('posts/search', {
query: @query query: @query
.then (posts) => }).then((posts) => {
this.is-loading = false this.is-loading = false
this.is-empty = posts.length == 0 this.is-empty = posts.length == 0
this.update(); this.update();
@ -67,10 +67,10 @@
return return
this.more-loading = true this.more-loading = true
this.update(); this.update();
this.api 'posts/search' do this.api('posts/search', {
query: @query query: @query
page: this.page + 1 page: this.page + 1
.then (posts) => }).then((posts) => {
this.more-loading = false this.more-loading = false
this.page++ this.page++
this.update(); this.update();

View File

@ -149,13 +149,13 @@
this.unmount(); this.unmount();
this.close = () => { this.close = () => {
this.refs.window.close! this.refs.window.close();
this.upload = () => { this.upload = () => {
this.refs.window.refs.browser.select-local-file! this.refs.window.refs.browser.select-local-file!
this.ok = () => { this.ok = () => {
this.trigger 'selected' this.file this.trigger 'selected' this.file
this.refs.window.close! this.refs.window.close();
</script> </script>
</mk-select-file-from-drive-window> </mk-select-file-from-drive-window>

View File

@ -20,6 +20,6 @@
this.unmount(); this.unmount();
this.close = () => { this.close = () => {
this.refs.window.close! this.refs.window.close();
</script> </script>
</mk-settings-window> </mk-settings-window>

View File

@ -212,31 +212,31 @@
@update-avatar this.I @update-avatar this.I
this.update-account = () => { this.update-account = () => {
this.api 'i/update' do this.api('i/update', {
name: this.refs.account-name.value name: this.refs.account-name.value
location: this.refs.account-location.value location: this.refs.account-location.value
bio: this.refs.account-bio.value bio: this.refs.account-bio.value
birthday: this.refs.account-birthday.value birthday: this.refs.account-birthday.value
.then (i) => }).then((i) => {
alert 'ok' alert 'ok'
.catch (err) => .catch (err) =>
console.error err console.error err
this.update-cache = () => { this.update-cache = () => {
this.I.data.cache = !this.I.data.cache this.I.data.cache = !this.I.data.cache
this.api 'i/appdata/set' do this.api('i/appdata/set', {
data: JSON.stringify do data: JSON.stringify do
cache: this.I.data.cache cache: this.I.data.cache
this.update-debug = () => { this.update-debug = () => {
this.I.data.debug = !this.I.data.debug this.I.data.debug = !this.I.data.debug
this.api 'i/appdata/set' do this.api('i/appdata/set', {
data: JSON.stringify do data: JSON.stringify do
debug: this.I.data.debug debug: this.I.data.debug
this.update-nya = () => { this.update-nya = () => {
this.I.data.nya = !this.I.data.nya this.I.data.nya = !this.I.data.nya
this.api 'i/appdata/set' do this.api('i/appdata/set', {
data: JSON.stringify do data: JSON.stringify do
nya: this.I.data.nya nya: this.I.data.nya
</script> </script>

View File

@ -55,8 +55,13 @@
<button class={ liked: p.is_liked } onclick={ like } title="善哉"><i class="fa fa-thumbs-o-up"></i> <button class={ liked: p.is_liked } onclick={ like } title="善哉"><i class="fa fa-thumbs-o-up"></i>
<p class="count" if={ p.likes_count > 0 }>{ p.likes_count }</p> <p class="count" if={ p.likes_count > 0 }>{ p.likes_count }</p>
</button> </button>
<button onclick={ NotImplementedException }><i class="fa fa-ellipsis-h"></i></button> <button onclick={ NotImplementedException }>
<button onclick={ toggleDetail } title="詳細"><i class="fa fa-caret-down" if={ !isDetailOpened }></i><i class="fa fa-caret-up" if={ isDetailOpened }></i></button> <i class="fa fa-ellipsis-h"></i>
</button>
<button onclick={ toggleDetail } title="詳細">
<i class="fa fa-caret-down" if={ !isDetailOpened }></i>
<i class="fa fa-caret-up" if={ isDetailOpened }></i>
</button>
</footer> </footer>
</div> </div>
</article> </article>
@ -328,46 +333,45 @@
this.isDetailOpened = false; this.isDetailOpened = false;
this.on('mount', () => { this.on('mount', () => {
if this.p.text? if (this.p.text) {
tokens = if this.p._highlight? const tokens = this.analyze(this.p.text);
then @analyze this.p._highlight
else @analyze this.p.text
this.refs.text.innerHTML = this.refs.text.innerHTML.replace '<p class="dummy"></p>' if this.p._highlight? this.refs.text.innerHTML = this.refs.text.innerHTML.replace('<p class="dummy"></p>', this.compile(tokens));
then @compile tokens, true, false
else @compile tokens
this.refs.text.children.forEach (e) => this.refs.text.children.forEach(e => {
if e.tag-name == 'MK-URL' if (e.tagName == 'MK-URL') riot.mount(e);
riot.mount e });
// URLをプレビュー // URLをプレビュー
tokens tokens
.filter (t) -> t.type == 'link' .filter(t => t.type == 'link')
.map (t) => .map(t => {
this.preview = this.refs.text.appendChild document.createElement 'mk-url-preview' riot.mount(this.refs.text.appendChild(document.createElement('mk-url-preview')), {
riot.mount this.preview, do
url: t.content url: t.content
});
});
}
});
this.reply = () => { this.reply = () => {
form = document.body.appendChild document.createElement 'mk-post-form-window' form = document.body.appendChild(document.createElement('mk-post-form-window'));
riot.mount form, do riot.mount form, do
reply: this.p reply: this.p
this.repost = () => { this.repost = () => {
form = document.body.appendChild document.createElement 'mk-repost-form-window' form = document.body.appendChild(document.createElement('mk-repost-form-window'));
riot.mount form, do riot.mount form, do
post: this.p post: this.p
this.like = () => { this.like = () => {
if this.p.is_liked if this.p.is_liked
this.api 'posts/likes/delete' do this.api('posts/likes/delete', {
post_id: this.p.id post_id: this.p.id
.then => .then =>
this.p.is_liked = false this.p.is_liked = false
this.update(); this.update();
else else
this.api 'posts/likes/create' do this.api('posts/likes/create', {
post_id: this.p.id post_id: this.p.id
.then => .then =>
this.p.is_liked = true this.p.is_liked = true

View File

@ -165,11 +165,11 @@
this.is-open = false this.is-open = false
this.on('before-unmount', () => { this.on('before-unmount', () => {
@close! @close();
this.toggle = () => { this.toggle = () => {
if @is-open if @is-open
@close! @close();
else else
@open! @open!
@ -190,16 +190,16 @@
this.mousedown = (e) => { this.mousedown = (e) => {
e.preventDefault(); e.preventDefault();
if (!contains this.root, e.target) and (this.root != e.target) if (!contains this.root, e.target) and (this.root != e.target)
@close! @close();
return false return false
this.drive = () => { this.drive = () => {
@close! @close();
riot.mount document.body.appendChild document.createElement 'mk-drive-browser-window' riot.mount document.body.appendChild(document.createElement('mk-drive-browser-window'));
this.settings = () => { this.settings = () => {
@close! @close();
riot.mount document.body.appendChild document.createElement 'mk-settings-window' riot.mount document.body.appendChild(document.createElement('mk-settings-window'));
function contains(parent, child) function contains(parent, child)
node = child.parentNode node = child.parentNode

View File

@ -89,7 +89,7 @@
// Fetch count of unread messaging messages // Fetch count of unread messaging messages
this.api 'messaging/unread' this.api 'messaging/unread'
.then (count) => }).then((count) => {
if count.count > 0 if count.count > 0
this.has-unread-messaging-messages = true this.has-unread-messaging-messages = true
this.update(); this.update();
@ -107,7 +107,7 @@
this.update(); this.update();
this.messaging = () => { this.messaging = () => {
riot.mount document.body.appendChild document.createElement 'mk-messaging-window' riot.mount document.body.appendChild(document.createElement('mk-messaging-window'));
</script> </script>
</ul> </ul>
</mk-ui-header-nav> </mk-ui-header-nav>

View File

@ -79,7 +79,7 @@
this.toggle = () => { this.toggle = () => {
if @is-open if @is-open
@close! @close();
else else
@open! @open!
@ -100,7 +100,7 @@
this.mousedown = (e) => { this.mousedown = (e) => {
e.preventDefault(); e.preventDefault();
if (!contains this.root, e.target) and (this.root != e.target) if (!contains this.root, e.target) and (this.root != e.target)
@close! @close();
return false return false
function contains(parent, child) function contains(parent, child)

View File

@ -35,7 +35,8 @@
</style> </style>
<script> <script>
this.post = (e) => { this.post = e => {
this.parent.parent.open-post-form! this.parent.parent.openPostForm();
};
</script> </script>
</mk-ui-header-post-button> </mk-ui-header-post-button>

View File

@ -80,6 +80,5 @@
display none display none
</style> </style>
<script>this.mixin('i');</script> <script>this.mixin('i');</script>
</mk-ui-header> </mk-ui-header>

View File

@ -19,16 +19,16 @@
this.user = user this.user = user
this.update(); this.update();
this.api 'aggregation/users/followers' do this.api('aggregation/users/followers', {
user_id: this.user.id user_id: this.user.id
limit: 30days limit: 30days
.then (followers) => }).then((followers) => {
followers = followers.reverse! followers = followers.reverse!
this.api 'aggregation/users/following' do this.api('aggregation/users/following', {
user_id: this.user.id user_id: this.user.id
limit: 30days limit: 30days
.then (following) => }).then((following) => {
following = following.reverse! following = following.reverse!
new Chart this.refs.canv, do new Chart this.refs.canv, do

View File

@ -19,10 +19,10 @@
this.user = user this.user = user
this.update(); this.update();
this.api 'aggregation/users/like' do this.api('aggregation/users/like', {
user_id: this.user.id user_id: this.user.id
limit: 30days limit: 30days
.then (likes) => }).then((likes) => {
likes = likes.reverse! likes = likes.reverse!
new Chart this.refs.canv, do new Chart this.refs.canv, do

View File

@ -67,15 +67,15 @@
this.user-promise = if @is-promise this.opts.user then this.opts.user else Promise.resolve this.opts.user this.user-promise = if @is-promise this.opts.user then this.opts.user else Promise.resolve this.opts.user
this.on('mount', () => { this.on('mount', () => {
this.user-promise.then (user) => this.user-promise}).then((user) => {
this.user = user this.user = user
this.update(); this.update();
this.api 'users/posts' do this.api('users/posts', {
user_id: this.user.id user_id: this.user.id
with_media: true with_media: true
limit: 9posts limit: 9posts
.then (posts) => }).then((posts) => {
this.initializing = false this.initializing = false
posts.forEach (post) => posts.forEach (post) =>
post.media.forEach (image) => post.media.forEach (image) =>

View File

@ -19,10 +19,10 @@
this.user = user this.user = user
this.update(); this.update();
this.api 'aggregation/users/post' do this.api('aggregation/users/post', {
user_id: this.user.id user_id: this.user.id
limit: 30days limit: 30days
.then (data) => }).then((data) => {
data = data.reverse! data = data.reverse!
new Chart this.refs.canv, do new Chart this.refs.canv, do
type: 'line' type: 'line'

View File

@ -105,16 +105,16 @@
this.user-promise = this.user-promise =
if typeof @u == 'string' if typeof @u == 'string'
new Promise (resolve, reject) => new Promise (resolve, reject) =>
this.api 'users/show' do this.api('users/show', {
user_id: if @u.0 == '@' then undefined else @u user_id: if @u.0 == '@' then undefined else @u
username: if @u.0 == '@' then @u.substr 1 else undefined username: if @u.0 == '@' then @u.substr 1 else undefined
.then (user) => }).then((user) => {
resolve user resolve user
else else
Promise.resolve @u Promise.resolve @u
this.on('mount', () => { this.on('mount', () => {
this.user-promise.then (user) => this.user-promise}).then((user) => {
this.user = user this.user = user
this.update(); this.update();

View File

@ -87,12 +87,12 @@
this.user = this.opts.user this.user = this.opts.user
this.show-following = () => { this.show-following = () => {
window = document.body.appendChild document.createElement 'mk-user-following-window' window = document.body.appendChild(document.createElement('mk-user-following-window'));
riot.mount window, do riot.mount window, do
user: this.user user: this.user
this.show-followers = () => { this.show-followers = () => {
window = document.body.appendChild document.createElement 'mk-user-followers-window' window = document.body.appendChild(document.createElement('mk-user-followers-window'));
riot.mount window, do riot.mount window, do
user: this.user user: this.user
</script> </script>

View File

@ -63,7 +63,7 @@
document.addEventListener 'keydown' this.on-document-keydown document.addEventListener 'keydown' this.on-document-keydown
window.addEventListener 'scroll' this.on-scroll window.addEventListener 'scroll' this.on-scroll
this.user-promise.then (user) => this.user-promise}).then((user) => {
this.user = user this.user = user
this.update(); this.update();
@ -82,10 +82,10 @@
this.refs.timeline.focus(); this.refs.timeline.focus();
this.fetch = (cb) => { this.fetch = (cb) => {
this.api 'users/posts' do this.api('users/posts', {
user_id: this.user.id user_id: this.user.id
with_replies: this.mode == 'with-replies' with_replies: this.mode == 'with-replies'
.then (posts) => }).then((posts) => {
this.is-loading = false this.is-loading = false
this.is-empty = posts.length == 0 this.is-empty = posts.length == 0
this.update(); this.update();
@ -100,11 +100,11 @@
return return
this.more-loading = true this.more-loading = true
this.update(); this.update();
this.api 'users/posts' do this.api('users/posts', {
user_id: this.user.id user_id: this.user.id
with_replies: this.mode == 'with-replies' with_replies: this.mode == 'with-replies'
max_id: this.refs.timeline.tail!.id max_id: this.refs.timeline.tail!.id
.then (posts) => }).then((posts) => {
this.more-loading = false this.more-loading = false
this.update(); this.update();
this.refs.timeline.prepend-posts posts this.refs.timeline.prepend-posts posts

View File

@ -40,9 +40,9 @@
this.user = null this.user = null
this.on('mount', () => { this.on('mount', () => {
this.api 'users/show' do this.api('users/show', {
username: this.username username: this.username
.then (user) => }).then((user) => {
this.fetching = false this.fetching = false
this.user = user this.user = user
this.update(); this.update();

View File

@ -320,7 +320,7 @@
this.bg-click = () => { this.bg-click = () => {
if @can-close if @can-close
@close! @close();
this.on-body-mousedown = (e) => { this.on-body-mousedown = (e) => {
@top! @top!
@ -506,7 +506,7 @@
if @can-close if @can-close
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@close! @close();
function contains(parent, child) function contains(parent, child)
node = child.parentNode node = child.parentNode

View File

@ -203,9 +203,9 @@
this.nid-state = 'wait' this.nid-state = 'wait'
this.update(); this.update();
this.api 'app/name_id/available' do this.api('app/name_id/available', {
name_id: nid name_id: nid
.then (result) => }).then((result) => {
if result.available if result.available
this.nid-state = 'ok' this.nid-state = 'ok'
else else
@ -225,9 +225,9 @@
this.refs.permission.query-selector-all 'input' .forEach (el) => this.refs.permission.query-selector-all 'input' .forEach (el) =>
if el.checked then permission.push el.value if el.checked then permission.push el.value
locker = document.body.appendChild document.createElement 'mk-locker' locker = document.body.appendChild(document.createElement('mk-locker'));
this.api 'app/create' do this.api('app/create', {
name: name name: name
name_id: nid name_id: nid
description: description description: description

View File

@ -20,9 +20,9 @@
this.fetching = true this.fetching = true
this.on('mount', () => { this.on('mount', () => {
this.api 'app/show' do this.api('app/show', {
app_id: this.opts.app app_id: this.opts.app
.then (app) => }).then((app) => {
this.app = app this.app = app
this.fetching = false this.fetching = false
this.update(); this.update();

View File

@ -22,7 +22,7 @@
this.on('mount', () => { this.on('mount', () => {
this.api 'my/apps' this.api 'my/apps'
.then (apps) => }).then((apps) => {
this.fetching = false this.fetching = false
this.apps = apps this.apps = apps
this.update(); this.update();

View File

@ -206,9 +206,9 @@
this.loading = true this.loading = true
this.update(); this.update();
this.api 'drive/folders/show' do this.api('drive/folders/show', {
folder_id: target-folder folder_id: target-folder
.then (folder) => }).then((folder) => {
this.folder = folder this.folder = folder
this.hierarchyFolders = [] this.hierarchyFolders = []
@ -297,10 +297,10 @@
files-max = 20 files-max = 20
// フォルダ一覧取得 // フォルダ一覧取得
this.api 'drive/folders' do this.api('drive/folders', {
folder_id: if this.folder? then this.folder.id else null folder_id: if this.folder? then this.folder.id else null
limit: folders-max + 1 limit: folders-max + 1
.then (folders) => }).then((folders) => {
if folders.length == folders-max + 1 if folders.length == folders-max + 1
this.more-folders = true this.more-folders = true
folders.pop! folders.pop!
@ -310,10 +310,10 @@
console.error err console.error err
// ファイル一覧取得 // ファイル一覧取得
this.api 'drive/files' do this.api('drive/files', {
folder_id: if this.folder? then this.folder.id else null folder_id: if this.folder? then this.folder.id else null
limit: files-max + 1 limit: files-max + 1
.then (files) => }).then((files) => {
if files.length == files-max + 1 if files.length == files-max + 1
this.more-files = true this.more-files = true
files.pop! files.pop!
@ -356,9 +356,9 @@
this.loading = true this.loading = true
this.update(); this.update();
this.api 'drive/files/show' do this.api('drive/files/show', {
file_id: file file_id: file
.then (file) => }).then((file) => {
this.file = file this.file = file
this.folder = null this.folder = null
this.hierarchyFolders = [] this.hierarchyFolders = []

View File

@ -191,7 +191,7 @@
this.rename = () => { this.rename = () => {
name = window.prompt '名前を変更' this.file.name name = window.prompt '名前を変更' this.file.name
if name? and name != '' and name != this.file.name if name? and name != '' and name != this.file.name
this.api 'drive/files/update' do this.api('drive/files/update', {
file_id: this.file.id file_id: this.file.id
name: name name: name
.then => .then =>

View File

@ -58,7 +58,7 @@
this.wait = false this.wait = false
this.on('mount', () => { this.on('mount', () => {
this.user-promise.then (user) => this.user-promise}).then((user) => {
this.user = user this.user = user
this.init = false this.init = false
this.update(); this.update();
@ -82,7 +82,7 @@
this.onclick = () => { this.onclick = () => {
this.wait = true this.wait = true
if this.user.is_following if this.user.is_following
this.api 'following/delete' do this.api('following/delete', {
user_id: this.user.id user_id: this.user.id
.then => .then =>
this.user.is_following = false this.user.is_following = false
@ -92,7 +92,7 @@
this.wait = false this.wait = false
this.update(); this.update();
else else
this.api 'following/create' do this.api('following/create', {
user_id: this.user.id user_id: this.user.id
.then => .then =>
this.user.is_following = true this.user.is_following = true

View File

@ -11,7 +11,7 @@
this.init = new Promise (res, rej) => this.init = new Promise (res, rej) =>
this.api 'posts/timeline' this.api 'posts/timeline'
.then (posts) => }).then((posts) => {
res posts res posts
this.trigger('loaded'); this.trigger('loaded');
@ -26,7 +26,7 @@
this.stream.off 'unfollow' this.on-stream-unfollow this.stream.off 'unfollow' this.on-stream-unfollow
this.more = () => { this.more = () => {
this.api 'posts/timeline' do this.api('posts/timeline', {
max_id: this.refs.timeline.tail!.id max_id: this.refs.timeline.tail!.id
this.on-stream-post = (post) => { this.on-stream-post = (post) => {

View File

@ -66,7 +66,7 @@
this.on('mount', () => { this.on('mount', () => {
this.api 'i/notifications' this.api 'i/notifications'
.then (notifications) => }).then((notifications) => {
this.notifications = notifications this.notifications = notifications
this.loading = false this.loading = false
this.update(); this.update();

View File

@ -13,9 +13,9 @@
this.fetching = true this.fetching = true
this.on('mount', () => { this.on('mount', () => {
this.api 'users/show' do this.api('users/show', {
username: this.opts.username username: this.opts.username
.then (user) => }).then(user => {
this.fetching = false this.fetching = false
this.user = user this.user = user
this.update(); this.update();

View File

@ -18,9 +18,9 @@
this.on('mount', () => { this.on('mount', () => {
this.Progress.start(); this.Progress.start();
this.api 'users/show' do this.api('users/show', {
username: this.opts.user username: this.opts.user
.then (user) => }).then(user => {
this.user = user this.user = user
this.fetching = false this.fetching = false

View File

@ -18,9 +18,9 @@
this.on('mount', () => { this.on('mount', () => {
this.Progress.start(); this.Progress.start();
this.api 'users/show' do this.api('users/show', {
username: this.opts.user username: this.opts.user
.then (user) => }).then(user => {
this.user = user this.user = user
this.fetching = false this.fetching = false

View File

@ -334,15 +334,15 @@
this.mixin('get-post-summary'); this.mixin('get-post-summary');
this.mixin('open-post-form'); this.mixin('open-post-form');
this.fetching = true this.fetching = true;
this.loading-context = false this.loadingContext = false;
this.content = null this.content = null;
this.post = null this.post = null;
this.on('mount', () => { this.on('mount', () => {
this.api 'posts/show' do this.api('posts/show', {
post_id: this.opts.post post_id: this.opts.post
.then (post) => }).then((post) => {
this.post = post this.post = post
this.is-repost = this.post.repost? this.is-repost = this.post.repost?
this.p = if @is-repost then this.post.repost else this.post this.p = if @is-repost then this.post.repost else this.post
@ -363,54 +363,54 @@
tokens tokens
.filter (t) -> t.type == 'link' .filter (t) -> t.type == 'link'
.map (t) => .map (t) =>
this.preview = this.refs.text.appendChild document.createElement 'mk-url-preview' this.preview = this.refs.text.appendChild(document.createElement('mk-url-preview'));
riot.mount this.preview, do riot.mount this.preview, do
url: t.content url: t.content
// Get likes // Get likes
this.api 'posts/likes' do this.api('posts/likes', {
post_id: this.p.id post_id: this.p.id
limit: 8 limit: 8
.then (likes) => }).then((likes) => {
this.likes = likes this.likes = likes
this.update(); this.update();
// Get reposts // Get reposts
this.api 'posts/reposts' do this.api('posts/reposts', {
post_id: this.p.id post_id: this.p.id
limit: 8 limit: 8
.then (reposts) => }).then((reposts) => {
this.reposts = reposts this.reposts = reposts
this.update(); this.update();
// Get replies // Get replies
this.api 'posts/replies' do this.api('posts/replies', {
post_id: this.p.id post_id: this.p.id
limit: 8 limit: 8
.then (replies) => }).then((replies) => {
this.replies = replies this.replies = replies
this.update(); this.update();
this.reply = () => { this.reply = () => {
@open-post-form do this.openPostForm do
reply: this.p reply: this.p
this.repost = () => { this.repost = () => {
text = window.prompt '「' + @summary + '」をRepost' text = window.prompt '「' + @summary + '」をRepost'
if text? if text?
this.api 'posts/create' do this.api('posts/create', {
repost_id: this.p.id repost_id: this.p.id
text: if text == '' then undefined else text text: if text == '' then undefined else text
this.like = () => { this.like = () => {
if this.p.is_liked if this.p.is_liked
this.api 'posts/likes/delete' do this.api('posts/likes/delete', {
post_id: this.p.id post_id: this.p.id
.then => .then =>
this.p.is_liked = false this.p.is_liked = false
this.update(); this.update();
else else
this.api 'posts/likes/create' do this.api('posts/likes/create', {
post_id: this.p.id post_id: this.p.id
.then => .then =>
this.p.is_liked = true this.p.is_liked = true
@ -420,9 +420,9 @@
this.loading-context = true this.loading-context = true
// Get context // Get context
this.api 'posts/context' do this.api('posts/context', {
post_id: this.p.reply_to_id post_id: this.p.reply_to_id
.then (context) => }).then((context) => {
this.context = context.reverse! this.context = context.reverse!
this.loading-context = false this.loading-context = false
this.update(); this.update();

View File

@ -220,7 +220,7 @@
this.refs.file.click(); this.refs.file.click();
this.select-file-from-drive = () => { this.select-file-from-drive = () => {
browser = document.body.appendChild document.createElement 'mk-drive-selector' browser = document.body.appendChild(document.createElement('mk-drive-selector'));
browser = riot.mount browser, do browser = riot.mount browser, do
multiple: true multiple: true
.0 .0
@ -260,12 +260,12 @@
then this.files.map (f) -> f.id then this.files.map (f) -> f.id
else undefined else undefined
this.api 'posts/create' do this.api('posts/create', {
text: this.refs.text.value text: this.refs.text.value
media_ids: files media_ids: files
reply_to_id: if this.opts.reply? then this.opts.reply.id else undefined reply_to_id: if this.opts.reply? then this.opts.reply.id else undefined
poll: if this.poll then this.refs.poll.get! else undefined poll: if this.poll then this.refs.poll.get! else undefined
.then (data) => }).then((data) => {
this.trigger('post'); this.trigger('post');
this.unmount(); this.unmount();
.catch (err) => .catch (err) =>

View File

@ -16,15 +16,15 @@
this.with-media = this.opts.with-media this.with-media = this.opts.with-media
this.init = new Promise (res, rej) => this.init = new Promise (res, rej) =>
this.api 'posts/search' do this.api('posts/search', {
query: @query query: @query
.then (posts) => }).then((posts) => {
res posts res posts
this.trigger('loaded'); this.trigger('loaded');
this.more = () => { this.more = () => {
@offset += @max @offset += @max
this.api 'posts/search' do this.api('posts/search', {
query: @query query: @query
max: @max max: @max
offset: @offset offset: @offset

View File

@ -3,10 +3,19 @@
<mk-timeline-post-sub post={ p.reply_to }></mk-timeline-post-sub> <mk-timeline-post-sub post={ p.reply_to }></mk-timeline-post-sub>
</div> </div>
<div class="repost" if={ isRepost }> <div class="repost" if={ isRepost }>
<p><a class="avatar-anchor" href={ CONFIG.url + '/' + post.user.username }><img class="avatar" src={ post.user.avatar_url + '?thumbnail&size=64' } alt="avatar"/></a><i class="fa fa-retweet"></i><a class="name" href={ CONFIG.url + '/' + post.user.username }>{ post.user.name }</a>がRepost</p> <p>
<a class="avatar-anchor" href={ CONFIG.url + '/' + post.user.username }>
<img class="avatar" src={ post.user.avatar_url + '?thumbnail&size=64' } alt="avatar"/>
</a>
<i class="fa fa-retweet"></i>
<a class="name" href={ CONFIG.url + '/' + post.user.username }>{ post.user.name }</a>がRepost
</p>
<mk-time time={ post.created_at }></mk-time> <mk-time time={ post.created_at }></mk-time>
</div> </div>
<article><a class="avatar-anchor" href={ CONFIG.url + '/' + p.user.username }><img class="avatar" src={ p.user.avatar_url + '?thumbnail&size=96' } alt="avatar"/></a> <article>
<a class="avatar-anchor" href={ CONFIG.url + '/' + p.user.username }>
<img class="avatar" src={ p.user.avatar_url + '?thumbnail&size=96' } alt="avatar"/>
</a>
<div class="main"> <div class="main">
<header> <header>
<a class="name" href={ CONFIG.url + '/' + p.user.username }>{ p.user.name }</a> <a class="name" href={ CONFIG.url + '/' + p.user.username }>{ p.user.name }</a>
@ -289,59 +298,67 @@
this.mixin('api'); this.mixin('api');
this.mixin('text'); this.mixin('text');
this.mixin('get-post-summary'); this.mixin('get-post-summary');
this.mixin('open-post-form'); this.mixin('openPostForm');
this.post = this.opts.post this.post = this.opts.post;
this.is-repost = this.post.repost? and !this.post.text? this.isRepost = this.post.repost != null && this.post.text == null;
this.p = if @is-repost then this.post.repost else this.post this.p = this.isRepost ? this.post.repost : this.post;
this.summary = @get-post-summary this.p this.summary = this.getPostSummary(this.p);
this.url = CONFIG.url + '/' + this.p.user.username + '/' + this.p.id this.url = CONFIG.url + '/' + this.p.user.username + '/' + this.p.id
this.on('mount', () => { this.on('mount', () => {
if this.p.text? if (this.p.text) {
tokens = if this.p._highlight? const tokens = this.analyze(this.p.text);
then @analyze this.p._highlight
else @analyze this.p.text
this.refs.text.innerHTML = this.refs.text.innerHTML.replace '<p class="dummy"></p>' if this.p._highlight? this.refs.text.innerHTML = this.refs.text.innerHTML.replace('<p class="dummy"></p>', this.compile(tokens));
then @compile tokens, true, false
else @compile tokens
this.refs.text.children.forEach (e) => this.refs.text.children.forEach(e => {
if e.tag-name == 'MK-URL' if (e.tagName == 'MK-URL') riot.mount(e);
riot.mount e });
// URLをプレビュー // URLをプレビュー
tokens tokens
.filter (t) -> t.type == 'link' .filter(t => t.type == 'link')
.map (t) => .map(t => {
this.preview = this.refs.text.appendChild document.createElement 'mk-url-preview' riot.mount(this.refs.text.appendChild(document.createElement('mk-url-preview')), {
riot.mount this.preview, do
url: t.content url: t.content
});
});
}
});
this.reply = () => { this.reply = () => {
@open-post-form do this.openPostForm({
reply: this.p reply: this.p
});
};
this.repost = () => { this.repost = () => {
text = window.prompt '「' + @summary + '」をRepost' const text = window.prompt(`「${this.summary}」をRepost`);
if text? if (text) {
this.api 'posts/create' do this.api('posts/create', {
repost_id: this.p.id repost_id: this.p.id,
text: if text == '' then undefined else text text: text == '' ? undefined : text
});
}
};
this.like = () => { this.like = () => {
if this.p.is_liked if (this.p.is_liked)
this.api 'posts/likes/delete' do this.api('posts/likes/delete', {
post_id: this.p.id post_id: this.p.id
.then => }).then(() => {
this.p.is_liked = false this.p.is_liked = false;
this.update(); this.update();
else });
this.api 'posts/likes/create' do } else {
this.api('posts/likes/create', {
post_id: this.p.id post_id: this.p.id
.then => }).then(() => {
this.p.is_liked = true this.p.is_liked = true;
this.update(); this.update();
});
}
};
</script> </script>
</mk-timeline-post> </mk-timeline-post>

View File

@ -80,7 +80,7 @@
this.can-fetch-more = true this.can-fetch-more = true
this.on('mount', () => { this.on('mount', () => {
this.opts.init.then (posts) => this.opts.init}).then((posts) => {
this.init = false this.init = false
@set-posts posts @set-posts posts
@ -95,7 +95,7 @@
if @init or @fetching or this.posts.length == 0 then return if @init or @fetching or this.posts.length == 0 then return
this.fetching = true this.fetching = true
this.update(); this.update();
this.opts.more!.then (posts) => this.opts.more!}).then((posts) => {
this.fetching = false this.fetching = false
this.prepend-posts posts this.prepend-posts posts

View File

@ -89,7 +89,7 @@
</style> </style>
<script> <script>
this.mixin('ui'); this.mixin('ui');
this.mixin('open-post-form'); this.mixin('openPostForm');
this.on('mount', () => { this.on('mount', () => {
this.opts.ready! this.opts.ready!
@ -99,6 +99,6 @@
this.refs.title.innerHTML = title this.refs.title.innerHTML = title
this.post = () => { this.post = () => {
@open-post-form! this.openPostForm!
</script> </script>
</mk-ui-header> </mk-ui-header>

View File

@ -44,7 +44,7 @@
this.refs.nav.root.style.display = if @is-drawer-opening then 'block' else 'none' this.refs.nav.root.style.display = if @is-drawer-opening then 'block' else 'none'
this.on-stream-notification = (notification) => { this.on-stream-notification = (notification) => {
el = document.body.appendChild document.createElement 'mk-notify' el = document.body.appendChild(document.createElement('mk-notify'));
riot.mount el, do riot.mount el, do
notification: notification notification: notification
</script> </script>

View File

@ -11,7 +11,7 @@
this.user = this.opts.user this.user = this.opts.user
this.fetch = (iknow, limit, cursor, cb) => { this.fetch = (iknow, limit, cursor, cb) => {
this.api 'users/followers' do this.api('users/followers', {
user_id: this.user.id user_id: this.user.id
iknow: iknow iknow: iknow
limit: limit limit: limit

View File

@ -11,7 +11,7 @@
this.user = this.opts.user this.user = this.opts.user
this.fetch = (iknow, limit, cursor, cb) => { this.fetch = (iknow, limit, cursor, cb) => {
this.api 'users/following' do this.api('users/following', {
user_id: this.user.id user_id: this.user.id
iknow: iknow iknow: iknow
limit: limit limit: limit

View File

@ -15,15 +15,15 @@
this.with-media = this.opts.with-media this.with-media = this.opts.with-media
this.init = new Promise (res, rej) => this.init = new Promise (res, rej) =>
this.api 'users/posts' do this.api('users/posts', {
user_id: this.user.id user_id: this.user.id
with_media: @with-media with_media: @with-media
.then (posts) => }).then((posts) => {
res posts res posts
this.trigger('loaded'); this.trigger('loaded');
this.more = () => { this.more = () => {
this.api 'users/posts' do this.api('users/posts', {
user_id: this.user.id user_id: this.user.id
with_media: @with-media with_media: @with-media
max_id: this.refs.timeline.tail!.id max_id: this.refs.timeline.tail!.id

View File

@ -3,20 +3,43 @@
<header> <header>
<div class="banner" style={ user.banner_url ? 'background-image: url(' + user.banner_url + '?thumbnail&size=1024)' : '' }></div> <div class="banner" style={ user.banner_url ? 'background-image: url(' + user.banner_url + '?thumbnail&size=1024)' : '' }></div>
<div class="body"> <div class="body">
<div class="top"><a class="avatar"><img src={ user.avatar_url + '?thumbnail&size=160' } alt="avatar"/></a> <div class="top">
<a class="avatar">
<img src={ user.avatar_url + '?thumbnail&size=160' } alt="avatar"/>
</a>
<mk-follow-button if={ SIGNIN && I.id != user.id } user={ user }></mk-follow-button> <mk-follow-button if={ SIGNIN && I.id != user.id } user={ user }></mk-follow-button>
</div> </div>
<div class="title"> <div class="title">
<h1>{ user.name }</h1><span class="username">@{ user.username }</span><span class="followed" if={ user.is_followed }>フォローされています</span> <h1>{ user.name }</h1>
<span class="username">@{ user.username }</span>
<span class="followed" if={ user.is_followed }>フォローされています</span>
</div> </div>
<div class="bio">{ user.bio }</div> <div class="bio">{ user.bio }</div>
<div class="info"> <div class="info">
<p class="location" if={ user.location }><i class="fa fa-map-marker"></i>{ user.location }</p> <p class="location" if={ user.location }>
<p class="birthday" if={ user.birthday }><i class="fa fa-birthday-cake"></i>{ user.birthday.replace('-', '年').replace('-', '月') + '日' } ({ age(user.birthday) }歳)</p> <i class="fa fa-map-marker"></i>{ user.location }
</p>
<p class="birthday" if={ user.birthday }>
<i class="fa fa-birthday-cake"></i>{ user.birthday.replace('-', '年').replace('-', '月') + '日' } ({ age(user.birthday) }歳)
</p>
</div> </div>
<div class="friends"><a href="{ user.username }/following"><b>{ user.following_count }</b><i>フォロー</i></a><a href="{ user.username }/followers"><b>{ user.followers_count }</b><i>フォロワー</i></a></div> <div class="friends">
<a href="{ user.username }/following">
<b>{ user.following_count }</b>
<i>フォロー</i>
</a>
<a href="{ user.username }/followers">
<b>{ user.followers_count }</b>
<i>フォロワー</i>
</a>
</div> </div>
<nav><a data-is-active={ page == 'posts' } onclick={ goPosts }>投稿</a><a data-is-active={ page == 'media' } onclick={ goMedia }>メディア</a><a data-is-active={ page == 'graphs' } onclick={ goGraphs }>グラフ</a><a data-is-active={ page == 'likes' } onclick={ goLikes }>いいね</a></nav> </div>
<nav>
<a data-is-active={ page == 'posts' } onclick={ go.bind(null, 'posts') }>投稿</a>
<a data-is-active={ page == 'media' } onclick={ go.bind(null, 'media') }>メディア</a>
<a data-is-active={ page == 'graphs' } onclick={ go.bind(null, 'graphs') }>グラフ</a>
<a data-is-active={ page == 'likes' } onclick={ go.bind(null, 'likes') }>いいね</a>
</nav>
</header> </header>
<div class="body"> <div class="body">
<mk-user-timeline if={ page == 'posts' } user={ user }></mk-user-timeline> <mk-user-timeline if={ page == 'posts' } user={ user }></mk-user-timeline>
@ -154,38 +177,30 @@
</style> </style>
<script> <script>
this.age = require 's-age' this.age = require('s-age');
this.mixin('i'); this.mixin('i');
this.mixin('api'); this.mixin('api');
this.username = this.opts.user this.username = this.opts.user;
this.page = if this.opts.page? then this.opts.page else 'posts' this.page = this.opts.page ? this.opts.page : 'posts';
this.fetching = true this.fetching = true;
this.on('mount', () => { this.on('mount', () => {
this.api 'users/show' do this.api('users/show', {
username: this.username username: this.username
.then (user) => }).then(user => {
this.fetching = false this.fetching = false;
this.user = user this.user = user;
this.trigger 'loaded' user this.trigger('loaded', user);
this.update(); this.update();
});
});
this.go-posts = () => { this.go = page => {
this.page = 'posts' this.update({
this.update(); page: page
});
this.go-media = () => { };
this.page = 'media'
this.update();
this.go-graphs = () => {
this.page = 'graphs'
this.update();
this.go-likes = () => {
this.page = 'likes'
this.update();
</script> </script>
</mk-user> </mk-user>