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

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

View File

@@ -191,7 +191,7 @@
this.rename = () => {
name = window.prompt '名前を変更' 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
name: name
.then =>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -220,8 +220,8 @@
this.refs.file.click();
this.select-file-from-drive = () => {
browser = document.body.appendChild document.createElement 'mk-drive-selector'
browser = riot.mount browser, do
browser = document.body.appendChild(document.createElement('mk-drive-selector'));
browser = riot.mount browser, do
multiple: true
.0
browser.on('selected', (files) => {
@@ -260,12 +260,12 @@
then this.files.map (f) -> f.id
else undefined
this.api 'posts/create' do
this.api('posts/create', {
text: this.refs.text.value
media_ids: files
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
.then (data) =>
}).then((data) => {
this.trigger('post');
this.unmount();
.catch (err) =>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,20 +3,43 @@
<header>
<div class="banner" style={ user.banner_url ? 'background-image: url(' + user.banner_url + '?thumbnail&size=1024)' : '' }></div>
<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>
</div>
<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 class="bio">{ user.bio }</div>
<div class="info">
<p class="location" if={ user.location }><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>
<p class="location" if={ user.location }>
<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 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>
<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>
<div class="body">
<mk-user-timeline if={ page == 'posts' } user={ user }></mk-user-timeline>
@@ -154,38 +177,30 @@
</style>
<script>
this.age = require 's-age'
this.age = require('s-age');
this.mixin('i');
this.mixin('api');
this.username = this.opts.user
this.page = if this.opts.page? then this.opts.page else 'posts'
this.fetching = true
this.username = this.opts.user;
this.page = this.opts.page ? this.opts.page : 'posts';
this.fetching = true;
this.on('mount', () => {
this.api 'users/show' do
this.api('users/show', {
username: this.username
.then (user) =>
this.fetching = false
this.user = user
this.trigger 'loaded' user
}).then(user => {
this.fetching = false;
this.user = user;
this.trigger('loaded', user);
this.update();
});
});
this.go-posts = () => {
this.page = 'posts'
this.update();
this.go-media = () => {
this.page = 'media'
this.update();
this.go-graphs = () => {
this.page = 'graphs'
this.update();
this.go-likes = () => {
this.page = 'likes'
this.update();
this.go = page => {
this.update({
page: page
});
};
</script>
</mk-user>