This commit is contained in:
syuilo
2017-02-20 09:53:57 +09:00
parent 6a4ea35e28
commit 204ad535c0
164 changed files with 2979 additions and 2966 deletions

View File

@@ -56,19 +56,19 @@
</style>
<script>
@files = []
this.files = []
@on \mount ~>
@refs.browser.on \change-selected (files) ~>
@files = files
@update!
this.on('mount', () => {
this.refs.browser.on('change-selected', (files) => {
this.files = files
this.update();
@cancel = ~>
@trigger \canceled
@unmount!
cancel() {
this.trigger('canceled');
this.unmount();
@ok = ~>
@trigger \selected @files
@unmount!
ok() {
this.trigger 'selected' @files
this.unmount();
</script>
</mk-drive-selector>

View File

@@ -128,91 +128,91 @@
</style>
<script>
@mixin \api
@mixin \stream
this.mixin('api');
this.mixin('stream');
@files = []
@folders = []
@hierarchy-folders = []
@selected-files = []
this.files = []
this.folders = []
this.hierarchy-folders = []
this.selected-files = []
# 現在の階層(フォルダ)
# * null でルートを表す
@folder = null
// 現在の階層(フォルダ)
// * null でルートを表す
this.folder = null
@file = null
this.file = null
@is-select-mode = @opts.select? and @opts.select
@multiple = if @opts.multiple? then @opts.multiple else false
this.is-select-mode = this.opts.select? and this.opts.select
this.multiple = if this.opts.multiple? then this.opts.multiple else false
@on \mount ~>
@stream.on \drive_file_created @on-stream-drive-file-created
@stream.on \drive_file_updated @on-stream-drive-file-updated
@stream.on \drive_folder_created @on-stream-drive-folder-created
@stream.on \drive_folder_updated @on-stream-drive-folder-updated
this.on('mount', () => {
@stream.on 'drive_file_created' this.on-stream-drive-file-created
@stream.on 'drive_file_updated' this.on-stream-drive-file-updated
@stream.on 'drive_folder_created' this.on-stream-drive-folder-created
@stream.on 'drive_folder_updated' this.on-stream-drive-folder-updated
# Riotのバグでnullを渡しても""になる
# https://github.com/riot/riot/issues/2080
#if @opts.folder?
if @opts.folder? and @opts.folder != ''
@cd @opts.folder, true
else if @opts.file? and @opts.file != ''
@cf @opts.file, true
// Riotのバグでnullを渡しても""になる
// https://github.com/riot/riot/issues/2080
#if this.opts.folder?
if this.opts.folder? and this.opts.folder != ''
@cd this.opts.folder, true
else if this.opts.file? and this.opts.file != ''
@cf this.opts.file, true
else
@load!
@on \unmount ~>
@stream.off \drive_file_created @on-stream-drive-file-created
@stream.off \drive_file_updated @on-stream-drive-file-updated
@stream.off \drive_folder_created @on-stream-drive-folder-created
@stream.off \drive_folder_updated @on-stream-drive-folder-updated
this.on('unmount', () => {
@stream.off 'drive_file_created' this.on-stream-drive-file-created
@stream.off 'drive_file_updated' this.on-stream-drive-file-updated
@stream.off 'drive_folder_created' this.on-stream-drive-folder-created
@stream.off 'drive_folder_updated' this.on-stream-drive-folder-updated
@on-stream-drive-file-created = (file) ~>
on-stream-drive-file-created(file) {
@add-file file, true
@on-stream-drive-file-updated = (file) ~>
on-stream-drive-file-updated(file) {
current = if @folder? then @folder.id else null
if current != file.folder_id
@remove-file file
else
@add-file file, true
@on-stream-drive-folder-created = (folder) ~>
on-stream-drive-folder-created(folder) {
@add-folder folder, true
@on-stream-drive-folder-updated = (folder) ~>
on-stream-drive-folder-updated(folder) {
current = if @folder? then @folder.id else null
if current != folder.parent_id
@remove-folder folder
else
@add-folder folder, true
@_move = (ev) ~>
@_move = (ev) =>
@move ev.item.folder
@move = (target-folder) ~>
move(target-folder) {
@cd target-folder
@cd = (target-folder, silent = false) ~>
@file = null
cd(target-folder, silent = false) {
this.file = null
if target-folder? and typeof target-folder == \object
if target-folder? and typeof target-folder == 'object'
target-folder = target-folder.id
if target-folder == null
@go-root!
return
@loading = true
@update!
this.loading = true
this.update();
@api \drive/folders/show do
this.api 'drive/folders/show' do
folder_id: target-folder
.then (folder) ~>
@folder = folder
@hierarchy-folders = []
.then (folder) =>
this.folder = folder
this.hierarchy-folders = []
x = (f) ~>
x = (f) =>
@hierarchy-folders.unshift f
if f.parent?
x f.parent
@@ -220,18 +220,18 @@
if folder.parent?
x folder.parent
@update!
@trigger \open-folder @folder, silent
this.update();
this.trigger 'open-folder' @folder, silent
@load!
.catch (err, text-status) ->
console.error err
@add-folder = (folder, unshift = false) ~>
add-folder(folder, unshift = false) {
current = if @folder? then @folder.id else null
if current != folder.parent_id
return
if (@folders.some (f) ~> f.id == folder.id)
if (@folders.some (f) => f.id == folder.id)
return
if unshift
@@ -239,17 +239,17 @@
else
@folders.push folder
@update!
this.update();
@add-file = (file, unshift = false) ~>
add-file(file, unshift = false) {
current = if @folder? then @folder.id else null
if current != file.folder_id
return
if (@files.some (f) ~> f.id == file.id)
if (@files.some (f) => f.id == file.id)
exist = (@files.map (f) -> f.id).index-of file.id
@files[exist] = file
@update!
this.update();
return
if unshift
@@ -257,38 +257,38 @@
else
@files.push file
@update!
this.update();
@remove-folder = (folder) ~>
if typeof folder == \object
remove-folder(folder) {
if typeof folder == 'object'
folder = folder.id
@folders = @folders.filter (f) -> f.id != folder
@update!
this.folders = @folders.filter (f) -> f.id != folder
this.update();
@remove-file = (file) ~>
if typeof file == \object
remove-file(file) {
if typeof file == 'object'
file = file.id
@files = @files.filter (f) -> f.id != file
@update!
this.files = @files.filter (f) -> f.id != file
this.update();
@go-root = ~>
go-root() {
if @folder != null or @file != null
@file = null
@folder = null
@hierarchy-folders = []
@update!
@trigger \move-root
this.file = null
this.folder = null
this.hierarchy-folders = []
this.update();
this.trigger('move-root');
@load!
@load = ~>
@folders = []
@files = []
@more-folders = false
@more-files = false
@loading = true
@update!
load() {
this.folders = []
this.files = []
this.more-folders = false
this.more-files = false
this.loading = true
this.update();
@trigger \begin-load
this.trigger('begin-load');
load-folders = null
load-files = null
@@ -296,74 +296,74 @@
folders-max = 20
files-max = 20
# フォルダ一覧取得
@api \drive/folders do
// フォルダ一覧取得
this.api 'drive/folders' do
folder_id: if @folder? then @folder.id else null
limit: folders-max + 1
.then (folders) ~>
.then (folders) =>
if folders.length == folders-max + 1
@more-folders = true
this.more-folders = true
folders.pop!
load-folders := folders
complete!
.catch (err, text-status) ~>
.catch (err, text-status) =>
console.error err
# ファイル一覧取得
@api \drive/files do
// ファイル一覧取得
this.api 'drive/files' do
folder_id: if @folder? then @folder.id else null
limit: files-max + 1
.then (files) ~>
.then (files) =>
if files.length == files-max + 1
@more-files = true
this.more-files = true
files.pop!
load-files := files
complete!
.catch (err, text-status) ~>
.catch (err, text-status) =>
console.error err
flag = false
complete = ~>
complete = =>
if flag
load-folders.for-each (folder) ~>
load-folders.for-each (folder) =>
@add-folder folder
load-files.for-each (file) ~>
load-files.for-each (file) =>
@add-file file
@loading = false
@update!
this.loading = false
this.update();
@trigger \loaded
this.trigger('loaded');
else
flag := true
@trigger \load-mid
this.trigger('load-mid');
@choose-file = (file) ~>
choose-file(file) {
if @is-select-mode
exist = @selected-files.some (f) ~> f.id == file.id
exist = @selected-files.some (f) => f.id == file.id
if exist
@selected-files = (@selected-files.filter (f) ~> f.id != file.id)
selected-files(@selected-files.filter (f) { f.id != file.id)
else
@selected-files.push file
@update!
@trigger \change-selected @selected-files
this.update();
this.trigger 'change-selected' @selected-files
else
@cf file
@cf = (file, silent = false) ~>
if typeof file == \object
cf(file, silent = false) {
if typeof file == 'object'
file = file.id
@loading = true
@update!
this.loading = true
this.update();
@api \drive/files/show do
this.api 'drive/files/show' do
file_id: file
.then (file) ~>
@file = file
@folder = null
@hierarchy-folders = []
.then (file) =>
this.file = file
this.folder = null
this.hierarchy-folders = []
x = (f) ~>
x = (f) =>
@hierarchy-folders.unshift f
if f.parent?
x f.parent
@@ -371,7 +371,7 @@
if file.folder?
x file.folder
@update!
@trigger \open-file @file, silent
this.update();
this.trigger 'open-file' @file, silent
</script>
</mk-drive>

View File

@@ -180,22 +180,22 @@
</style>
<script>
@bytes-to-size = require '../../../common/scripts/bytes-to-size.js'
@get-gcd = require '../../../common/scripts/gcd.js'
this.bytes-to-size = require('../../../common/scripts/bytes-to-size.js');
this.get-gcd = require('../../../common/scripts/gcd.js');
@mixin \api
this.mixin('api');
@file = @opts.file
@kind = @file.type.split \/ .0
this.file = this.opts.file
this.kind = @file.type.split '/' .0
@rename = ~>
rename() {
name = window.prompt '名前を変更' @file.name
if name? and name != '' and name != @file.name
@api \drive/files/update do
this.api 'drive/files/update' do
file_id: @file.id
name: name
.then ~>
@parent.cf @file, true
.then =>
this.parent.cf @file, true
</script>
</mk-drive-file-viewer>

View File

@@ -122,16 +122,16 @@
</style>
<script>
@bytes-to-size = require '../../../common/scripts/bytes-to-size.js'
this.bytes-to-size = require('../../../common/scripts/bytes-to-size.js');
@browser = @parent
@file = @opts.file
@is-selected = @browser.selected-files.some (f) ~> f.id == @file.id
this.browser = this.parent
this.file = this.opts.file
this.is-selected = @browser.selected-files.some (f) => f.id == @file.id
@browser.on \change-selected (selects) ~>
@is-selected = selects.some (f) ~> f.id == @file.id
@browser.on('change-selected', (selects) => {
this.is-selected = selects.some (f) => f.id == @file.id
@onclick = ~>
onclick() {
@browser.choose-file @file
</script>
</mk-drive-file>

View File

@@ -37,10 +37,10 @@
</style>
<script>
@browser = @parent
@folder = @opts.folder
this.browser = this.parent
this.folder = this.opts.folder
@onclick = ~>
onclick() {
@browser.move @folder
</script>
</mk-drive-folder>

View File

@@ -48,58 +48,58 @@
</style>
<script>
@mixin \api
@mixin \is-promise
@mixin \stream
this.mixin('api');
this.mixin('is-promise');
this.mixin('stream');
@user = null
@user-promise = if @is-promise @opts.user then @opts.user else Promise.resolve @opts.user
@init = true
@wait = false
this.user = null
this.user-promise = if @is-promise this.opts.user then this.opts.user else Promise.resolve this.opts.user
this.init = true
this.wait = false
@on \mount ~>
@user-promise.then (user) ~>
@user = user
@init = false
@update!
@stream.on \follow @on-stream-follow
@stream.on \unfollow @on-stream-unfollow
this.on('mount', () => {
@user-promise.then (user) =>
this.user = user
this.init = false
this.update();
@stream.on 'follow' this.on-stream-follow
@stream.on 'unfollow' this.on-stream-unfollow
@on \unmount ~>
@stream.off \follow @on-stream-follow
@stream.off \unfollow @on-stream-unfollow
this.on('unmount', () => {
@stream.off 'follow' this.on-stream-follow
@stream.off 'unfollow' this.on-stream-unfollow
@on-stream-follow = (user) ~>
on-stream-follow(user) {
if user.id == @user.id
@user = user
@update!
this.user = user
this.update();
@on-stream-unfollow = (user) ~>
on-stream-unfollow(user) {
if user.id == @user.id
@user = user
@update!
this.user = user
this.update();
@onclick = ~>
@wait = true
onclick() {
this.wait = true
if @user.is_following
@api \following/delete do
this.api 'following/delete' do
user_id: @user.id
.then ~>
.then =>
@user.is_following = false
.catch (err) ->
console.error err
.then ~>
@wait = false
@update!
.then =>
this.wait = false
this.update();
else
@api \following/create do
this.api 'following/create' do
user_id: @user.id
.then ~>
.then =>
@user.is_following = true
.catch (err) ->
console.error err
.then ~>
@wait = false
@update!
.then =>
this.wait = false
this.update();
</script>
</mk-follow-button>

View File

@@ -6,38 +6,38 @@
</style>
<script>
@mixin \api
@mixin \stream
this.mixin('api');
this.mixin('stream');
@init = new Promise (res, rej) ~>
@api \posts/timeline
.then (posts) ~>
this.init = new Promise (res, rej) =>
this.api 'posts/timeline'
.then (posts) =>
res posts
@trigger \loaded
this.trigger('loaded');
@on \mount ~>
@stream.on \post @on-stream-post
@stream.on \follow @on-stream-follow
@stream.on \unfollow @on-stream-unfollow
this.on('mount', () => {
@stream.on 'post' this.on-stream-post
@stream.on 'follow' this.on-stream-follow
@stream.on 'unfollow' this.on-stream-unfollow
@on \unmount ~>
@stream.off \post @on-stream-post
@stream.off \follow @on-stream-follow
@stream.off \unfollow @on-stream-unfollow
this.on('unmount', () => {
@stream.off 'post' this.on-stream-post
@stream.off 'follow' this.on-stream-follow
@stream.off 'unfollow' this.on-stream-unfollow
@more = ~>
@api \posts/timeline do
max_id: @refs.timeline.tail!.id
more() {
this.api 'posts/timeline' do
max_id: this.refs.timeline.tail!.id
@on-stream-post = (post) ~>
@is-empty = false
@update!
@refs.timeline.add-post post
on-stream-post(post) {
this.is-empty = false
this.update();
this.refs.timeline.add-post post
@on-stream-follow = ~>
on-stream-follow() {
@fetch!
@on-stream-unfollow = ~>
on-stream-unfollow() {
@fetch!
</script>
</mk-home-timeline>

View File

@@ -13,8 +13,8 @@
</style>
<script>
@on \mount ~>
@refs.tl.on \loaded ~>
@trigger \loaded
this.on('mount', () => {
this.refs.tl.on('loaded', () => {
this.trigger('loaded');
</script>
</mk-home>

View File

@@ -18,10 +18,10 @@
</style>
<script>
@images = @opts.images
@image = @images.0
this.images = this.opts.images
this.image = @images.0
@click = ~>
click() {
window.open @image.url
</script>
</mk-images-viewer>

View File

@@ -107,7 +107,7 @@
</style>
<script>
@mixin \get-post-summary
@notification = @opts.notification
this.mixin('get-post-summary');
this.notification = this.opts.notification
</script>
</mk-notification-preview>

View File

@@ -167,7 +167,7 @@
</style>
<script>
@mixin \get-post-summary
@notification = @opts.notification
this.mixin('get-post-summary');
this.notification = this.opts.notification
</script>
</mk-notification>

View File

@@ -57,34 +57,34 @@
</style>
<script>
@mixin \api
@mixin \stream
@mixin \get-post-summary
this.mixin('api');
this.mixin('stream');
this.mixin('get-post-summary');
@notifications = []
@loading = true
this.notifications = []
this.loading = true
@on \mount ~>
@api \i/notifications
.then (notifications) ~>
@notifications = notifications
@loading = false
@update!
@trigger \loaded
this.on('mount', () => {
this.api 'i/notifications'
.then (notifications) =>
this.notifications = notifications
this.loading = false
this.update();
this.trigger('loaded');
.catch (err, text-status) ->
console.error err
@stream.on \notification @on-notification
@stream.on 'notification' this.on-notification
@on \unmount ~>
@stream.off \notification @on-notification
this.on('unmount', () => {
@stream.off 'notification' this.on-notification
@on-notification = (notification) ~>
on-notification(notification) {
@notifications.unshift notification
@update!
this.update();
@on \update ~>
@notifications.for-each (notification) ~>
this.on('update', () => {
@notifications.for-each (notification) =>
date = (new Date notification.created_at).get-date!
month = (new Date notification.created_at).get-month! + 1
notification._date = date

View File

@@ -16,22 +16,22 @@
</style>
<script>
@on \mount ~>
Velocity @root, {
bottom: \0px
this.on('mount', () => {
Velocity this.root, {
bottom: '0px'
} {
duration: 500ms
easing: \ease-out
easing: 'ease-out'
}
set-timeout ~>
Velocity @root, {
bottom: \-64px
setTimeout =>
Velocity this.root, {
bottom: '-64px'
} {
duration: 500ms
easing: \ease-out
complete: ~>
@unmount!
easing: 'ease-out'
complete: =>
this.unmount();
}
, 6000ms
</script>

View File

@@ -8,53 +8,53 @@
</style>
<script>
@mixin \ui
@mixin \ui-progress
this.mixin('ui');
this.mixin('ui-progress');
@on \mount ~>
this.on('mount', () => {
document.title = 'Misskey Drive'
@ui.trigger \title '<i class="fa fa-cloud"></i>ドライブ'
this.ui.trigger('title', '<i class="fa fa-cloud"></i>ドライブ');
@refs.ui.refs.browser.on \begin-load ~>
@Progress.start!
this.refs.ui.refs.browser.on('begin-load', () => {
this.Progress.start();
@refs.ui.refs.browser.on \loaded-mid ~>
@Progress.set 0.5
this.refs.ui.refs.browser.on('loaded-mid', () => {
this.Progress.set(0.5);
@refs.ui.refs.browser.on \loaded ~>
@Progress.done!
this.refs.ui.refs.browser.on('loaded', () => {
this.Progress.done();
@refs.ui.refs.browser.on \move-root ~>
this.refs.ui.refs.browser.on('move-root', () => {
title = 'Misskey Drive'
# Rewrite URL
history.push-state null, title, '/i/drive'
// Rewrite URL
history.pushState null, title, '/i/drive'
document.title = title
@ui.trigger \title '<i class="fa fa-cloud"></i>ドライブ'
this.ui.trigger('title', '<i class="fa fa-cloud"></i>ドライブ');
@refs.ui.refs.browser.on \open-folder (folder, silent) ~>
this.refs.ui.refs.browser.on('open-folder', (folder, silent) => {
title = folder.name + ' | Misskey Drive'
if !silent
# Rewrite URL
history.push-state null, title, '/i/drive/folder/' + folder.id
// Rewrite URL
history.pushState null, title, '/i/drive/folder/' + folder.id
document.title = title
# TODO: escape html characters in folder.name
@ui.trigger \title '<i class="fa fa-folder-open"></i>' + folder.name
// TODO: escape html characters in folder.name
this.ui.trigger('title', '<i class="fa fa-folder-open"></i>' + folder.name);
@refs.ui.refs.browser.on \open-file (file, silent) ~>
this.refs.ui.refs.browser.on('open-file', (file, silent) => {
title = file.name + ' | Misskey Drive'
if !silent
# Rewrite URL
history.push-state null, title, '/i/drive/file/' + file.id
// Rewrite URL
history.pushState null, title, '/i/drive/file/' + file.id
document.title = title
# TODO: escape html characters in file.name
@ui.trigger \title '<mk-file-type-icon class="icon"></mk-file-type-icon>' + file.name
riot.mount \mk-file-type-icon do
// TODO: escape html characters in file.name
this.ui.trigger('title', '<mk-file-type-icon class="icon"></mk-file-type-icon>' + file.name);
riot.mount 'mk-file-type-icon' do
type: file.type
</script>

View File

@@ -43,18 +43,18 @@
</style>
<script>
@mode = \signin
this.mode = 'signin'
@signup = ~>
@mode = \signup
@update!
signup() {
this.mode = 'signup'
this.update();
@signin = ~>
@mode = \signin
@update!
signin() {
this.mode = 'signin'
this.update();
@introduction = ~>
@mode = \introduction
@update!
introduction() {
this.mode = 'introduction'
this.update();
</script>
</mk-entrance>

View File

@@ -8,38 +8,38 @@
</style>
<script>
@mixin \i
@mixin \ui
@mixin \ui-progress
@mixin \stream
@mixin \get-post-summary
this.mixin('i');
this.mixin('ui');
this.mixin('ui-progress');
this.mixin('stream');
this.mixin('get-post-summary');
@unread-count = 0
this.unread-count = 0
@on \mount ~>
this.on('mount', () => {
document.title = 'Misskey'
@ui.trigger \title '<i class="fa fa-home"></i>ホーム'
this.ui.trigger('title', '<i class="fa fa-home"></i>ホーム');
@Progress.start!
this.Progress.start();
@stream.on \post @on-stream-post
document.add-event-listener \visibilitychange @window-on-visibilitychange, false
@stream.on 'post' this.on-stream-post
document.add-event-listener 'visibilitychange' @window-on-visibilitychange, false
@refs.ui.refs.home.on \loaded ~>
@Progress.done!
this.refs.ui.refs.home.on('loaded', () => {
this.Progress.done();
@on \unmount ~>
@stream.off \post @on-stream-post
document.remove-event-listener \visibilitychange @window-on-visibilitychange
this.on('unmount', () => {
@stream.off 'post' this.on-stream-post
document.remove-event-listener 'visibilitychange' @window-on-visibilitychange
@on-stream-post = (post) ~>
on-stream-post(post) {
if document.hidden and post.user_id !== @I.id
@unread-count++
document.title = '(' + @unread-count + ') ' + @get-post-summary post
@window-on-visibilitychange = ~>
window-on-visibilitychange() {
if !document.hidden
@unread-count = 0
this.unread-count = 0
document.title = 'Misskey'
</script>
</mk-home-page>

View File

@@ -7,21 +7,21 @@
display block
</style>
<script>
@mixin \api
@mixin \ui
this.mixin('api');
this.mixin('ui');
@fetching = true
this.fetching = true
@on \mount ~>
@api \users/show do
username: @opts.username
.then (user) ~>
@fetching = false
@user = user
@update!
this.on('mount', () => {
this.api 'users/show' do
username: this.opts.username
.then (user) =>
this.fetching = false
this.user = user
this.update();
document.title = 'メッセージ: ' + user.name + ' | Misskey'
# TODO: ユーザー名をエスケープ
@ui.trigger \title '<i class="fa fa-comments-o"></i>' + user.name
// TODO: ユーザー名をエスケープ
this.ui.trigger('title', '<i class="fa fa-comments-o"></i>'); + user.name
</script>
</mk-messaging-room-page>

View File

@@ -7,14 +7,14 @@
display block
</style>
<script>
@mixin \ui
@mixin \page
this.mixin('ui');
this.mixin('page');
@on \mount ~>
this.on('mount', () => {
document.title = 'Misskey | メッセージ'
@ui.trigger \title '<i class="fa fa-comments-o"></i>メッセージ'
this.ui.trigger('title', '<i class="fa fa-comments-o"></i>メッセージ');
@refs.ui.refs.index.on \navigate-user (user) ~>
this.refs.ui.refs.index.on('navigate-user', (user) => {
@page '/i/messaging/' + user.username
</script>

View File

@@ -8,16 +8,16 @@
</style>
<script>
@mixin \ui
@mixin \ui-progress
this.mixin('ui');
this.mixin('ui-progress');
@on \mount ~>
this.on('mount', () => {
document.title = 'Misskey | 通知'
@ui.trigger \title '<i class="fa fa-bell-o"></i>通知'
this.ui.trigger('title', '<i class="fa fa-bell-o"></i>通知');
@Progress.start!
this.Progress.start();
@refs.ui.refs.notifications.on \loaded ~>
@Progress.done!
this.refs.ui.refs.notifications.on('loaded', () => {
this.Progress.done();
</script>
</mk-notifications-page>

View File

@@ -18,21 +18,21 @@
</style>
<script>
@mixin \ui
@mixin \ui-progress
this.mixin('ui');
this.mixin('ui-progress');
@post = @opts.post
this.post = this.opts.post
@on \mount ~>
this.on('mount', () => {
document.title = 'Misskey'
@ui.trigger \title '<i class="fa fa-sticky-note-o"></i>投稿'
this.ui.trigger('title', '<i class="fa fa-sticky-note-o"></i>投稿');
@Progress.start!
this.Progress.start();
@refs.ui.refs.post.on \post-fetched ~>
@Progress.set 0.5
this.refs.ui.refs.post.on('post-fetched', () => {
this.Progress.set(0.5);
@refs.ui.refs.post.on \loaded ~>
@Progress.done!
this.refs.ui.refs.post.on('loaded', () => {
this.Progress.done();
</script>
</mk-post-page>

View File

@@ -8,17 +8,17 @@
</style>
<script>
@mixin \ui
@mixin \ui-progress
this.mixin('ui');
this.mixin('ui-progress');
@on \mount ~>
document.title = '検索: ' + @opts.query + ' | Misskey'
# TODO: クエリをHTMLエスケープ
@ui.trigger \title '<i class="fa fa-search"></i>' + @opts.query
this.on('mount', () => {
document.title = '検索: ' + this.opts.query + ' | Misskey'
// TODO: クエリをHTMLエスケープ
this.ui.trigger('title', '<i class="fa fa-search"></i>'); + this.opts.query
@Progress.start!
this.Progress.start();
@refs.ui.refs.search.on \loaded ~>
@Progress.done!
this.refs.ui.refs.search.on('loaded', () => {
this.Progress.done();
</script>
</mk-search-page>

View File

@@ -13,10 +13,10 @@
display block
</style>
<script>
@mixin \ui
this.mixin('ui');
@on \mount ~>
this.on('mount', () => {
document.title = 'Misskey | 設定'
@ui.trigger \title '<i class="fa fa-cog"></i>設定'
this.ui.trigger('title', '<i class="fa fa-cog"></i>設定');
</script>
</mk-settings-page>

View File

@@ -7,10 +7,10 @@
display block
</style>
<script>
@mixin \ui
this.mixin('ui');
@on \mount ~>
this.on('mount', () => {
document.title = 'Misskey | API'
@ui.trigger \title '<i class="fa fa-key"></i>API'
this.ui.trigger('title', '<i class="fa fa-key"></i>API');
</script>
</mk-api-info-page>

View File

@@ -7,10 +7,10 @@
display block
</style>
<script>
@mixin \ui
this.mixin('ui');
@on \mount ~>
this.on('mount', () => {
document.title = 'Misskey | アプリケーション'
@ui.trigger \title '<i class="fa fa-puzzle-piece"></i>アプリケーション'
this.ui.trigger('title', '<i class="fa fa-puzzle-piece"></i>アプリケーション');
</script>
</mk-authorized-apps-page>

View File

@@ -7,10 +7,10 @@
display block
</style>
<script>
@mixin \ui
this.mixin('ui');
@on \mount ~>
this.on('mount', () => {
document.title = 'Misskey | ログイン履歴'
@ui.trigger \title '<i class="fa fa-sign-in"></i>ログイン履歴'
this.ui.trigger('title', '<i class="fa fa-sign-in"></i>ログイン履歴');
</script>
</mk-signin-history-page>

View File

@@ -7,10 +7,10 @@
display block
</style>
<script>
@mixin \ui
this.mixin('ui');
@on \mount ~>
this.on('mount', () => {
document.title = 'Misskey | Twitter連携'
@ui.trigger \title '<i class="fa fa-twitter"></i>Twitter連携'
this.ui.trigger('title', '<i class="fa fa-twitter"></i>Twitter連携');
</script>
</mk-twitter-setting-page>

View File

@@ -8,29 +8,29 @@
</style>
<script>
@mixin \ui
@mixin \ui-progress
@mixin \api
this.mixin('ui');
this.mixin('ui-progress');
this.mixin('api');
@fetching = true
@user = null
this.fetching = true
this.user = null
@on \mount ~>
@Progress.start!
this.on('mount', () => {
this.Progress.start();
@api \users/show do
username: @opts.user
.then (user) ~>
@user = user
@fetching = false
this.api 'users/show' do
username: this.opts.user
.then (user) =>
this.user = user
this.fetching = false
document.title = user.name + 'のフォロワー | Misskey'
# TODO: ユーザー名をエスケープ
@ui.trigger \title '<img src="' + user.avatar_url + '?thumbnail&size=64">' + user.name + 'のフォロワー'
// TODO: ユーザー名をエスケープ
this.ui.trigger('title', '<img src="'); + user.avatar_url + '?thumbnail&size=64">' + user.name + 'のフォロワー'
@update!
this.update();
@refs.ui.refs.list.on \loaded ~>
@Progress.done!
this.refs.ui.refs.list.on('loaded', () => {
this.Progress.done();
</script>
</mk-user-followers-page>

View File

@@ -8,29 +8,29 @@
</style>
<script>
@mixin \ui
@mixin \ui-progress
@mixin \api
this.mixin('ui');
this.mixin('ui-progress');
this.mixin('api');
@fetching = true
@user = null
this.fetching = true
this.user = null
@on \mount ~>
@Progress.start!
this.on('mount', () => {
this.Progress.start();
@api \users/show do
username: @opts.user
.then (user) ~>
@user = user
@fetching = false
this.api 'users/show' do
username: this.opts.user
.then (user) =>
this.user = user
this.fetching = false
document.title = user.name + 'のフォロー | Misskey'
# TODO: ユーザー名をエスケープ
@ui.trigger \title '<img src="' + user.avatar_url + '?thumbnail&size=64">' + user.name + 'のフォロー'
// TODO: ユーザー名をエスケープ
this.ui.trigger('title', '<img src="'); + user.avatar_url + '?thumbnail&size=64">' + user.name + 'のフォロー'
@update!
this.update();
@refs.ui.refs.list.on \loaded ~>
@Progress.done!
this.refs.ui.refs.list.on('loaded', () => {
this.Progress.done();
</script>
</mk-user-following-page>

View File

@@ -8,18 +8,18 @@
</style>
<script>
@mixin \ui
@mixin \ui-progress
this.mixin('ui');
this.mixin('ui-progress');
@user = @opts.user
this.user = this.opts.user
@on \mount ~>
@Progress.start!
this.on('mount', () => {
this.Progress.start();
@refs.ui.refs.user.on \loaded (user) ~>
@Progress.done!
this.refs.ui.refs.user.on('loaded', (user) => {
this.Progress.done();
document.title = user.name + ' | Misskey'
# TODO: ユーザー名をエスケープ
@ui.trigger \title '<i class="fa fa-user"></i>' + user.name
// TODO: ユーザー名をエスケープ
this.ui.trigger('title', '<i class="fa fa-user"></i>'); + user.name
</script>
</mk-user-page>

View File

@@ -329,102 +329,102 @@
</style>
<script>
@mixin \api
@mixin \text
@mixin \get-post-summary
@mixin \open-post-form
this.mixin('api');
this.mixin('text');
this.mixin('get-post-summary');
this.mixin('open-post-form');
@fetching = true
@loading-context = false
@content = null
@post = null
this.fetching = true
this.loading-context = false
this.content = null
this.post = null
@on \mount ~>
@api \posts/show do
post_id: @opts.post
.then (post) ~>
@post = post
@is-repost = @post.repost?
@p = if @is-repost then @post.repost else @post
@summary = @get-post-summary @p
@trigger \loaded
@fetching = false
@update!
this.on('mount', () => {
this.api 'posts/show' do
post_id: this.opts.post
.then (post) =>
this.post = post
this.is-repost = @post.repost?
this.p = if @is-repost then @post.repost else @post
this.summary = @get-post-summary @p
this.trigger('loaded');
this.fetching = false
this.update();
if @p.text?
tokens = @analyze @p.text
@refs.text.innerHTML = @compile tokens
this.refs.text.innerHTML = @compile tokens
@refs.text.children.for-each (e) ~>
if e.tag-name == \MK-URL
this.refs.text.children.for-each (e) =>
if e.tag-name == 'MK-URL'
riot.mount e
# URLをプレビュー
// URLをプレビュー
tokens
.filter (t) -> t.type == \link
.map (t) ~>
@preview = @refs.text.append-child document.create-element \mk-url-preview
.filter (t) -> t.type == 'link'
.map (t) =>
this.preview = this.refs.text.appendChild document.createElement 'mk-url-preview'
riot.mount @preview, do
url: t.content
# Get likes
@api \posts/likes do
// Get likes
this.api 'posts/likes' do
post_id: @p.id
limit: 8
.then (likes) ~>
@likes = likes
@update!
.then (likes) =>
this.likes = likes
this.update();
# Get reposts
@api \posts/reposts do
// Get reposts
this.api 'posts/reposts' do
post_id: @p.id
limit: 8
.then (reposts) ~>
@reposts = reposts
@update!
.then (reposts) =>
this.reposts = reposts
this.update();
# Get replies
@api \posts/replies do
// Get replies
this.api 'posts/replies' do
post_id: @p.id
limit: 8
.then (replies) ~>
@replies = replies
@update!
.then (replies) =>
this.replies = replies
this.update();
@reply = ~>
reply() {
@open-post-form do
reply: @p
@repost = ~>
repost() {
text = window.prompt '「' + @summary + '」をRepost'
if text?
@api \posts/create do
this.api 'posts/create' do
repost_id: @p.id
text: if text == '' then undefined else text
@like = ~>
like() {
if @p.is_liked
@api \posts/likes/delete do
this.api 'posts/likes/delete' do
post_id: @p.id
.then ~>
.then =>
@p.is_liked = false
@update!
this.update();
else
@api \posts/likes/create do
this.api 'posts/likes/create' do
post_id: @p.id
.then ~>
.then =>
@p.is_liked = true
@update!
this.update();
@load-context = ~>
@loading-context = true
load-context() {
this.loading-context = true
# Get context
@api \posts/context do
// Get context
this.api 'posts/context' do
post_id: @p.reply_to_id
.then (context) ~>
@context = context.reverse!
@loading-context = false
@update!
.then (context) =>
this.context = context.reverse!
this.loading-context = false
this.update();
</script>
</mk-post-detail>

View File

@@ -182,103 +182,103 @@
</style>
<script>
get-cat = require '../../common/scripts/get-cat'
get-cat = require('../../common/scripts/get-cat');
@mixin \api
this.mixin('api');
@wait = false
@uploadings = []
@files = []
@poll = false
this.wait = false
this.uploadings = []
this.files = []
this.poll = false
@on \mount ~>
@refs.uploader.on \uploaded (file) ~>
this.on('mount', () => {
this.refs.uploader.on('uploaded', (file) => {
@add-file file
@refs.uploader.on \change-uploads (uploads) ~>
@trigger \change-uploading-files uploads
this.refs.uploader.on('change-uploads', (uploads) => {
this.trigger 'change-uploading-files' uploads
@refs.text.focus!
this.refs.text.focus();
@onkeypress = (e) ~>
if (e.char-code == 10 || e.char-code == 13) && e.ctrl-key
onkeypress(e) {
if (e.char-code == 10 || e.char-code == 13) && e.ctrlKey
@post!
else
return true
@onpaste = (e) ~>
data = e.clipboard-data
onpaste(e) {
data = e.clipboardData
items = data.items
for i from 0 to items.length - 1
item = items[i]
switch (item.kind)
| \file =>
@upload item.get-as-file!
| 'file' =>
@upload item.getAsFile();
return true
@select-file = ~>
@refs.file.click!
select-file() {
this.refs.file.click!
@select-file-from-drive = ~>
browser = document.body.append-child document.create-element \mk-drive-selector
select-file-from-drive() {
browser = document.body.appendChild document.createElement 'mk-drive-selector'
browser = riot.mount browser, do
multiple: true
.0
browser.on \selected (files) ~>
browser.on('selected', (files) => {
files.for-each @add-file
@change-file = ~>
files = @refs.file.files
change-file() {
files = this.refs.file.files
for i from 0 to files.length - 1
file = files.item i
@upload file
@upload = (file) ~>
@refs.uploader.upload file
upload(file) {
this.refs.uploader.upload file
@add-file = (file) ~>
file._remove = ~>
@files = @files.filter (x) -> x.id != file.id
@trigger \change-files @files
@update!
add-file(file) {
file._remove = =>
this.files = @files.filter (x) -> x.id != file.id
this.trigger 'change-files' @files
this.update();
@files.push file
@trigger \change-files @files
@update!
this.trigger 'change-files' @files
this.update();
@add-poll = ~>
@poll = true
add-poll() {
this.poll = true
@on-poll-destroyed = ~>
on-poll-destroyed() {
@update do
poll: false
@post = ~>
@wait = true
post() {
this.wait = true
files = if @files? and @files.length > 0
then @files.map (f) -> f.id
else undefined
@api \posts/create do
text: @refs.text.value
this.api 'posts/create' do
text: this.refs.text.value
media_ids: files
reply_to_id: if @opts.reply? then @opts.reply.id else undefined
poll: if @poll then @refs.poll.get! else undefined
.then (data) ~>
@trigger \post
@unmount!
.catch (err) ~>
reply_to_id: if this.opts.reply? then this.opts.reply.id else undefined
poll: if @poll then this.refs.poll.get! else undefined
.then (data) =>
this.trigger('post');
this.unmount();
.catch (err) =>
console.error err
#@opts.ui.trigger \notification 'Error!'
@wait = false
@update!
#this.opts.ui.trigger 'notification' 'Error!'
this.wait = false
this.update();
@cancel = ~>
@trigger \cancel
@unmount!
cancel() {
this.trigger('cancel');
this.unmount();
@cat = ~>
@refs.text.value = @refs.text.value + get-cat!
cat() {
this.refs.text.value = this.refs.text.value + get-cat!
</script>
</mk-post-form>

View File

@@ -90,5 +90,5 @@
color #717171
</style>
<script>@post = @opts.post</script>
<script>this.post = this.opts.post</script>
</mk-post-preview>

View File

@@ -7,24 +7,24 @@
</style>
<script>
@mixin \api
this.mixin('api');
@max = 30
@offset = 0
this.max = 30
this.offset = 0
@query = @opts.query
@with-media = @opts.with-media
this.query = this.opts.query
this.with-media = this.opts.with-media
@init = new Promise (res, rej) ~>
@api \posts/search do
this.init = new Promise (res, rej) =>
this.api 'posts/search' do
query: @query
.then (posts) ~>
.then (posts) =>
res posts
@trigger \loaded
this.trigger('loaded');
@more = ~>
more() {
@offset += @max
@api \posts/search do
this.api 'posts/search' do
query: @query
max: @max
offset: @offset

View File

@@ -6,10 +6,10 @@
</style>
<script>
@query = @opts.query
this.query = this.opts.query
@on \mount ~>
@refs.posts.on \loaded ~>
@trigger \loaded
this.on('mount', () => {
this.refs.posts.on('loaded', () => {
this.trigger('loaded');
</script>
</mk-search>

View File

@@ -27,27 +27,27 @@
</style>
<script>
@mixin \stream
this.mixin('stream');
@on \before-mount ~>
@state = @get-stream-state!
this.on('before-mount', () => {
this.state = @get-stream-state!
if @state == \connected
@root.style.opacity = 0
if @state == 'connected'
this.root.style.opacity = 0
@stream-state-ev.on \connected ~>
@state = @get-stream-state!
@update!
set-timeout ~>
Velocity @root, {
@stream-state-ev.on('connected', () => {
this.state = @get-stream-state!
this.update();
setTimeout =>
Velocity this.root, {
opacity: 0
} 200ms \linear
} 200ms 'linear'
, 1000ms
@stream-state-ev.on \closed ~>
@state = @get-stream-state!
@update!
Velocity @root, {
@stream-state-ev.on('closed', () => {
this.state = @get-stream-state!
this.update();
Velocity this.root, {
opacity: 1
} 0ms
</script>

View File

@@ -28,17 +28,17 @@
</style>
<script>
@mixin \text
this.mixin('text');
@post = @opts.post
this.post = this.opts.post
@on \mount ~>
this.on('mount', () => {
if @post.text?
tokens = @analyze @post.text
@refs.text.innerHTML = @compile tokens, false
this.refs.text.innerHTML = @compile tokens, false
@refs.text.children.for-each (e) ~>
if e.tag-name == \MK-URL
this.refs.text.children.for-each (e) =>
if e.tag-name == 'MK-URL'
riot.mount e
</script>
</mk-sub-post-content>

View File

@@ -97,5 +97,5 @@
font-size 80%
</style>
<script>@post = @opts.post</script>
<script>this.post = this.opts.post</script>
</mk-timeline-post-sub>

View File

@@ -286,62 +286,62 @@
</style>
<script>
@mixin \api
@mixin \text
@mixin \get-post-summary
@mixin \open-post-form
this.mixin('api');
this.mixin('text');
this.mixin('get-post-summary');
this.mixin('open-post-form');
@post = @opts.post
@is-repost = @post.repost? and !@post.text?
@p = if @is-repost then @post.repost else @post
@summary = @get-post-summary @p
@url = CONFIG.url + '/' + @p.user.username + '/' + @p.id
this.post = this.opts.post
this.is-repost = @post.repost? and !@post.text?
this.p = if @is-repost then @post.repost else @post
this.summary = @get-post-summary @p
this.url = CONFIG.url + '/' + @p.user.username + '/' + @p.id
@on \mount ~>
this.on('mount', () => {
if @p.text?
tokens = if @p._highlight?
then @analyze @p._highlight
else @analyze @p.text
@refs.text.innerHTML = @refs.text.innerHTML.replace '<p class="dummy"></p>' if @p._highlight?
this.refs.text.innerHTML = this.refs.text.innerHTML.replace '<p class="dummy"></p>' if @p._highlight?
then @compile tokens, true, false
else @compile tokens
@refs.text.children.for-each (e) ~>
if e.tag-name == \MK-URL
this.refs.text.children.for-each (e) =>
if e.tag-name == 'MK-URL'
riot.mount e
# URLをプレビュー
// URLをプレビュー
tokens
.filter (t) -> t.type == \link
.map (t) ~>
@preview = @refs.text.append-child document.create-element \mk-url-preview
.filter (t) -> t.type == 'link'
.map (t) =>
this.preview = this.refs.text.appendChild document.createElement 'mk-url-preview'
riot.mount @preview, do
url: t.content
@reply = ~>
reply() {
@open-post-form do
reply: @p
@repost = ~>
repost() {
text = window.prompt '「' + @summary + '」をRepost'
if text?
@api \posts/create do
this.api 'posts/create' do
repost_id: @p.id
text: if text == '' then undefined else text
@like = ~>
like() {
if @p.is_liked
@api \posts/likes/delete do
this.api 'posts/likes/delete' do
post_id: @p.id
.then ~>
.then =>
@p.is_liked = false
@update!
this.update();
else
@api \posts/likes/create do
this.api 'posts/likes/create' do
post_id: @p.id
.then ~>
.then =>
@p.is_liked = true
@update!
this.update();
</script>
</mk-timeline-post>

View File

@@ -74,45 +74,45 @@
</style>
<script>
@posts = []
@init = true
@fetching = false
@can-fetch-more = true
this.posts = []
this.init = true
this.fetching = false
this.can-fetch-more = true
@on \mount ~>
@opts.init.then (posts) ~>
@init = false
this.on('mount', () => {
this.opts.init.then (posts) =>
this.init = false
@set-posts posts
@on \update ~>
@posts.for-each (post) ~>
this.on('update', () => {
@posts.for-each (post) =>
date = (new Date post.created_at).get-date!
month = (new Date post.created_at).get-month! + 1
post._date = date
post._datetext = month + '月 ' + date + '日'
@more = ~>
more() {
if @init or @fetching or @posts.length == 0 then return
@fetching = true
@update!
@opts.more!.then (posts) ~>
@fetching = false
this.fetching = true
this.update();
this.opts.more!.then (posts) =>
this.fetching = false
@prepend-posts posts
@set-posts = (posts) ~>
@posts = posts
@update!
set-posts(posts) {
this.posts = posts
this.update();
@prepend-posts = (posts) ~>
posts.for-each (post) ~>
prepend-posts(posts) {
posts.for-each (post) =>
@posts.push post
@update!
this.update();
@add-post = (post) ~>
add-post(post) {
@posts.unshift post
@update!
this.update();
@tail = ~>
tail() {
@posts[@posts.length - 1]
</script>
</mk-timeline>

View File

@@ -88,17 +88,17 @@
</style>
<script>
@mixin \ui
@mixin \open-post-form
this.mixin('ui');
this.mixin('open-post-form');
@on \mount ~>
@opts.ready!
this.on('mount', () => {
this.opts.ready!
@ui.on \title (title) ~>
if @refs.title?
@refs.title.innerHTML = title
this.ui.on('title', (title) => {
if this.refs.title?
this.refs.title.innerHTML = title
@post = ~>
post() {
@open-post-form!
</script>
</mk-ui-header>

View File

@@ -117,14 +117,14 @@
</style>
<script>
@mixin \i
@mixin \page
this.mixin('i');
this.mixin('page');
@on \mount ~>
@opts.ready!
this.on('mount', () => {
this.opts.ready!
@search = ~>
query = window.prompt \検索
search() {
query = window.prompt '検索'
if query? and query != ''
@page '/search:' + query
</script>

View File

@@ -14,37 +14,37 @@
background #fff
</style>
<script>
@mixin \stream
this.mixin('stream');
@ready-count = 0
@is-drawer-opening = false
this.ready-count = 0
this.is-drawer-opening = false
#@ui.on \notification (text) ~>
# alert text
#this.ui.on('notification', (text) => {
// alert text
@on \mount ~>
@stream.on \notification @on-stream-notification
this.on('mount', () => {
@stream.on 'notification' this.on-stream-notification
@ready!
@on \unmount ~>
@stream.off \notification @on-stream-notification
this.on('unmount', () => {
@stream.off 'notification' this.on-stream-notification
@ready = ~>
ready() {
@ready-count++
if @ready-count == 2
@init-view-position!
@init-view-position = ~>
top = @refs.header.root.offset-height
@refs.main.style.padding-top = top + \px
init-view-position() {
top = this.refs.header.root.offset-height
this.refs.main.style.padding-top = top + 'px'
@toggle-drawer = ~>
@is-drawer-opening = !@is-drawer-opening
@refs.nav.root.style.display = if @is-drawer-opening then \block else \none
toggle-drawer() {
this.is-drawer-opening = !@is-drawer-opening
this.refs.nav.root.style.display = if @is-drawer-opening then 'block' else 'none'
@on-stream-notification = (notification) ~>
el = document.body.append-child document.create-element \mk-notify
on-stream-notification(notification) {
el = document.body.appendChild document.createElement 'mk-notify'
riot.mount el, do
notification: notification
</script>

View File

@@ -6,20 +6,20 @@
</style>
<script>
@mixin \api
this.mixin('api');
@user = @opts.user
this.user = this.opts.user
@fetch = (iknow, limit, cursor, cb) ~>
@api \users/followers do
fetch(iknow, limit, cursor, cb) {
this.api 'users/followers' do
user_id: @user.id
iknow: iknow
limit: limit
cursor: if cursor? then cursor else undefined
.then cb
@on \mount ~>
@refs.list.on \loaded ~>
@trigger \loaded
this.on('mount', () => {
this.refs.list.on('loaded', () => {
this.trigger('loaded');
</script>
</mk-user-followers>

View File

@@ -6,20 +6,20 @@
</style>
<script>
@mixin \api
this.mixin('api');
@user = @opts.user
this.user = this.opts.user
@fetch = (iknow, limit, cursor, cb) ~>
@api \users/following do
fetch(iknow, limit, cursor, cb) {
this.api 'users/following' do
user_id: @user.id
iknow: iknow
limit: limit
cursor: if cursor? then cursor else undefined
.then cb
@on \mount ~>
@refs.list.on \loaded ~>
@trigger \loaded
this.on('mount', () => {
this.refs.list.on('loaded', () => {
this.trigger('loaded');
</script>
</mk-user-following>

View File

@@ -85,5 +85,5 @@
color #717171
</style>
<script>@user = @opts.user</script>
<script>this.user = this.opts.user</script>
</mk-user-preview>

View File

@@ -9,23 +9,23 @@
</style>
<script>
@mixin \api
this.mixin('api');
@user = @opts.user
@with-media = @opts.with-media
this.user = this.opts.user
this.with-media = this.opts.with-media
@init = new Promise (res, rej) ~>
@api \users/posts do
this.init = new Promise (res, rej) =>
this.api 'users/posts' do
user_id: @user.id
with_media: @with-media
.then (posts) ~>
.then (posts) =>
res posts
@trigger \loaded
this.trigger('loaded');
@more = ~>
@api \users/posts do
more() {
this.api 'users/posts' do
user_id: @user.id
with_media: @with-media
max_id: @refs.timeline.tail!.id
max_id: this.refs.timeline.tail!.id
</script>
</mk-user-timeline>

View File

@@ -154,38 +154,38 @@
</style>
<script>
@age = require \s-age
this.age = require 's-age'
@mixin \i
@mixin \api
this.mixin('i');
this.mixin('api');
@username = @opts.user
@page = if @opts.page? then @opts.page else \posts
@fetching = true
this.username = this.opts.user
this.page = if this.opts.page? then this.opts.page else 'posts'
this.fetching = true
@on \mount ~>
@api \users/show do
this.on('mount', () => {
this.api 'users/show' do
username: @username
.then (user) ~>
@fetching = false
@user = user
@trigger \loaded user
@update!
.then (user) =>
this.fetching = false
this.user = user
this.trigger 'loaded' user
this.update();
@go-posts = ~>
@page = \posts
@update!
go-posts() {
this.page = 'posts'
this.update();
@go-media = ~>
@page = \media
@update!
go-media() {
this.page = 'media'
this.update();
@go-graphs = ~>
@page = \graphs
@update!
go-graphs() {
this.page = 'graphs'
this.update();
@go-likes = ~>
@page = \likes
@update!
go-likes() {
this.page = 'likes'
this.update();
</script>
</mk-user>

View File

@@ -70,44 +70,44 @@
</style>
<script>
@mixin \i
this.mixin('i');
@limit = 30users
@mode = \all
this.limit = 30users
this.mode = 'all'
@fetching = true
@more-fetching = false
this.fetching = true
this.more-fetching = false
@on \mount ~>
@fetch ~>
@trigger \loaded
this.on('mount', () => {
@fetch =>
this.trigger('loaded');
@fetch = (cb) ~>
@fetching = true
@update!
obj <~ @opts.fetch do
@mode == \iknow
fetch(cb) {
this.fetching = true
this.update();
obj <~ this.opts.fetch do
@mode == 'iknow'
@limit
null
@users = obj.users
@next = obj.next
@fetching = false
@update!
this.users = obj.users
this.next = obj.next
this.fetching = false
this.update();
if cb? then cb!
@more = ~>
@more-fetching = true
@update!
obj <~ @opts.fetch do
@mode == \iknow
more() {
this.more-fetching = true
this.update();
obj <~ this.opts.fetch do
@mode == 'iknow'
@limit
@cursor
@users = @users.concat obj.users
@next = obj.next
@more-fetching = false
@update!
this.users = @users.concat obj.users
this.next = obj.next
this.more-fetching = false
this.update();
@set-mode = (mode) ~>
set-mode(mode) {
@update do
mode: mode