wip
This commit is contained in:
32
src/web/app/ch/router.js
Normal file
32
src/web/app/ch/router.js
Normal file
@ -0,0 +1,32 @@
|
||||
import * as riot from 'riot';
|
||||
const route = require('page');
|
||||
let page = null;
|
||||
|
||||
export default me => {
|
||||
route('/', index);
|
||||
route('/:channel', channel);
|
||||
route('*', notFound);
|
||||
|
||||
function index() {
|
||||
mount(document.createElement('mk-index'));
|
||||
}
|
||||
|
||||
function channel(ctx) {
|
||||
const el = document.createElement('mk-channel');
|
||||
el.setAttribute('id', ctx.params.channel);
|
||||
mount(el);
|
||||
}
|
||||
|
||||
function notFound() {
|
||||
mount(document.createElement('mk-not-found'));
|
||||
}
|
||||
|
||||
// EXEC
|
||||
route();
|
||||
};
|
||||
|
||||
function mount(content) {
|
||||
if (page) page.unmount();
|
||||
const body = document.getElementById('app');
|
||||
page = riot.mount(body.appendChild(content))[0];
|
||||
}
|
18
src/web/app/ch/script.js
Normal file
18
src/web/app/ch/script.js
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Channels
|
||||
*/
|
||||
|
||||
// Style
|
||||
import './style.styl';
|
||||
|
||||
require('./tags');
|
||||
import init from '../init';
|
||||
import route from './router';
|
||||
|
||||
/**
|
||||
* init
|
||||
*/
|
||||
init(me => {
|
||||
// Start routing
|
||||
route(me);
|
||||
});
|
4
src/web/app/ch/style.styl
Normal file
4
src/web/app/ch/style.styl
Normal file
@ -0,0 +1,4 @@
|
||||
@import "../base"
|
||||
|
||||
html
|
||||
background #efefef
|
@ -1,14 +1,19 @@
|
||||
<mk-channel-page>
|
||||
<mk-ui ref="ui">
|
||||
<main if={ !parent.fetching }>
|
||||
<h1>{ parent.channel.title }</h1>
|
||||
<virtual if={ parent.posts }>
|
||||
<mk-channel-post each={ parent.posts.reverse() } post={ this } form={ parent.refs.form }/>
|
||||
</virtual>
|
||||
<hr>
|
||||
<mk-channel-form channel={ parent.channel } ref="form"/>
|
||||
</main>
|
||||
</mk-ui>
|
||||
<mk-channel>
|
||||
<main if={ !fetching }>
|
||||
<h1>{ channel.title }</h1>
|
||||
<virtual if={ posts }>
|
||||
<mk-channel-post each={ posts.slice().reverse() } post={ this } form={ parent.refs.form }/>
|
||||
</virtual>
|
||||
<hr>
|
||||
<mk-channel-form if={ SIGNIN } channel={ channel } ref="form"/>
|
||||
<div if={ !SIGNIN }>
|
||||
<p>参加するには<a href={ CONFIG.url }>ログインまたは新規登録</a>してください</p>
|
||||
</div>
|
||||
<hr>
|
||||
<footer>
|
||||
<small>Misskey ver { version } (葵 aoi)</small>
|
||||
</footer>
|
||||
</main>
|
||||
<style>
|
||||
:scope
|
||||
display block
|
||||
@ -20,16 +25,18 @@
|
||||
color #f00
|
||||
</style>
|
||||
<script>
|
||||
import Progress from '../../../common/scripts/loading';
|
||||
import ChannelStream from '../../../common/scripts/channel-stream';
|
||||
import Progress from '../../common/scripts/loading';
|
||||
import ChannelStream from '../../common/scripts/channel-stream';
|
||||
|
||||
this.mixin('i');
|
||||
this.mixin('api');
|
||||
|
||||
this.id = this.opts.id;
|
||||
this.fetching = true;
|
||||
this.channel = null;
|
||||
this.posts = null;
|
||||
this.connection = new ChannelStream();
|
||||
this.connection = new ChannelStream(this.id);
|
||||
this.version = VERSION;
|
||||
|
||||
this.on('mount', () => {
|
||||
document.documentElement.style.background = '#efefef';
|
||||
@ -56,9 +63,22 @@
|
||||
posts: posts
|
||||
});
|
||||
});
|
||||
|
||||
this.connection.on('post', this.onPost);
|
||||
});
|
||||
|
||||
this.on('unmount', () => {
|
||||
this.connection.off('post', this.onPost);
|
||||
this.connection.close();
|
||||
});
|
||||
|
||||
this.onPost = post => {
|
||||
this.posts.unshift(post);
|
||||
this.update();
|
||||
};
|
||||
|
||||
</script>
|
||||
</mk-channel-page>
|
||||
</mk-channel>
|
||||
|
||||
<mk-channel-post>
|
||||
<header>
|
||||
@ -127,7 +147,7 @@
|
||||
|
||||
</style>
|
||||
<script>
|
||||
import CONFIG from '../../../common/scripts/config';
|
||||
import CONFIG from '../../common/scripts/config';
|
||||
|
||||
this.mixin('api');
|
||||
|
2
src/web/app/ch/tags/index.js
Normal file
2
src/web/app/ch/tags/index.js
Normal file
@ -0,0 +1,2 @@
|
||||
require('./index.tag');
|
||||
require('./channel.tag');
|
24
src/web/app/ch/tags/index.tag
Normal file
24
src/web/app/ch/tags/index.tag
Normal file
@ -0,0 +1,24 @@
|
||||
<mk-index>
|
||||
<button onclick={ new }>%i18n:ch.tags.mk-index.new%</button>
|
||||
<style>
|
||||
:scope
|
||||
display block
|
||||
|
||||
</style>
|
||||
<script>
|
||||
this.mixin('api');
|
||||
|
||||
this.on('mount', () => {
|
||||
});
|
||||
|
||||
this.new = () => {
|
||||
const title = window.prompt('%i18n:ch.tags.mk-index.channel-title%');
|
||||
|
||||
this.api('channels/create', {
|
||||
title: title
|
||||
}).then(channel => {
|
||||
location.href = '/' + channel.id;
|
||||
});
|
||||
};
|
||||
</script>
|
||||
</mk-index>
|
@ -6,8 +6,10 @@ import Stream from './stream';
|
||||
* Channel stream connection
|
||||
*/
|
||||
class Connection extends Stream {
|
||||
constructor() {
|
||||
super('channel');
|
||||
constructor(channelId) {
|
||||
super('channel', {
|
||||
channel: channelId
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ const host = isRoot ? Url.host : Url.host.substring(Url.host.indexOf('.') + 1, U
|
||||
const scheme = Url.protocol;
|
||||
const url = `${scheme}//${host}`;
|
||||
const apiUrl = `${scheme}//api.${host}`;
|
||||
const chUrl = `${scheme}//ch.${host}`;
|
||||
const devUrl = `${scheme}//dev.${host}`;
|
||||
const aboutUrl = `${scheme}//about.${host}`;
|
||||
const statsUrl = `${scheme}//stats.${host}`;
|
||||
@ -16,6 +17,7 @@ export default {
|
||||
scheme,
|
||||
url,
|
||||
apiUrl,
|
||||
chUrl,
|
||||
devUrl,
|
||||
aboutUrl,
|
||||
statsUrl,
|
||||
|
@ -10,8 +10,6 @@ export default me => {
|
||||
route('/', index);
|
||||
route('/selectdrive', selectDrive);
|
||||
route('/i>mentions', mentions);
|
||||
route('/channel', channels);
|
||||
route('/channel/:channel', channel);
|
||||
route('/post::post', post);
|
||||
route('/search::query', search);
|
||||
route('/:user', user.bind(null, 'home'));
|
||||
@ -57,16 +55,6 @@ export default me => {
|
||||
mount(el);
|
||||
}
|
||||
|
||||
function channel(ctx) {
|
||||
const el = document.createElement('mk-channel-page');
|
||||
el.setAttribute('id', ctx.params.channel);
|
||||
mount(el);
|
||||
}
|
||||
|
||||
function channels() {
|
||||
mount(document.createElement('mk-channels-page'));
|
||||
}
|
||||
|
||||
function selectDrive() {
|
||||
mount(document.createElement('mk-selectdrive-page'));
|
||||
}
|
||||
|
@ -61,8 +61,6 @@ require('./pages/user.tag');
|
||||
require('./pages/post.tag');
|
||||
require('./pages/search.tag');
|
||||
require('./pages/not-found.tag');
|
||||
require('./pages/channel.tag');
|
||||
require('./pages/channels.tag');
|
||||
require('./pages/selectdrive.tag');
|
||||
require('./autocomplete-suggestion.tag');
|
||||
require('./progress-dialog.tag');
|
||||
|
@ -1,28 +0,0 @@
|
||||
<mk-channels-page>
|
||||
<mk-ui ref="ui">
|
||||
<main>
|
||||
<button onclick={ parent.new }>%i18n:desktop.tags.mk-channels-page.new%</button>
|
||||
</main>
|
||||
</mk-ui>
|
||||
<style>
|
||||
:scope
|
||||
display block
|
||||
|
||||
</style>
|
||||
<script>
|
||||
this.mixin('api');
|
||||
|
||||
this.on('mount', () => {
|
||||
});
|
||||
|
||||
this.new = () => {
|
||||
const title = window.prompt('%i18n:desktop.tags.mk-channels-page.channel-title%');
|
||||
|
||||
this.api('channels/create', {
|
||||
title: title
|
||||
}).then(channel => {
|
||||
location.href = '/channel/' + channel.id;
|
||||
});
|
||||
};
|
||||
</script>
|
||||
</mk-channels-page>
|
@ -112,7 +112,7 @@
|
||||
</header>
|
||||
<div class="body">
|
||||
<div class="text" ref="text">
|
||||
<p class="channel" if={ p.channel != null }><a href={ '/channel/' + p.channel.id }>{ p.channel.title }</a>:</p>
|
||||
<p class="channel" if={ p.channel != null }><a href={ CONFIG.chUrl + '/' + p.channel.id } target="_blank">{ p.channel.title }</a>:</p>
|
||||
<a class="reply" if={ p.reply_to }>
|
||||
<i class="fa fa-reply"></i>
|
||||
</a>
|
||||
|
@ -335,10 +335,10 @@
|
||||
</a>
|
||||
</li>
|
||||
</virtual>
|
||||
<li class="channels">
|
||||
<a href={ CONFIG.url + '/channel' }>
|
||||
<li class="ch">
|
||||
<a href={ CONFIG.chUrl } target="_blank">
|
||||
<i class="fa fa-television"></i>
|
||||
<p>%i18n:desktop.tags.mk-ui-header-nav.channels%</p>
|
||||
<p>%i18n:desktop.tags.mk-ui-header-nav.ch%</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="info">
|
||||
|
@ -164,7 +164,7 @@
|
||||
</header>
|
||||
<div class="body">
|
||||
<div class="text" ref="text">
|
||||
<p class="channel" if={ p.channel != null }><a href={ '/channel/' + p.channel.id }>{ p.channel.title }</a>:</p>
|
||||
<p class="channel" if={ p.channel != null }><a href={ CONFIG.chUrl + '/' + p.channel.id } target="_blank">{ p.channel.title }</a>:</p>
|
||||
<a class="reply" if={ p.reply_to }>
|
||||
<i class="fa fa-reply"></i>
|
||||
</a>
|
||||
|
@ -231,10 +231,11 @@
|
||||
<li><a href="/i/messaging"><i class="fa fa-comments-o"></i>%i18n:mobile.tags.mk-ui-nav.messaging%<i class="i fa fa-circle" if={ hasUnreadMessagingMessages }></i><i class="fa fa-angle-right"></i></a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a onclick={ search }><i class="fa fa-search"></i>%i18n:mobile.tags.mk-ui-nav.search%<i class="fa fa-angle-right"></i></a></li>
|
||||
<li><a href={ CONFIG.chUrl } target="_blank"><i class="fa fa-television"></i>%i18n:mobile.tags.mk-ui-nav.ch%<i class="fa fa-angle-right"></i></a></li>
|
||||
<li><a href="/i/drive"><i class="fa fa-cloud"></i>%i18n:mobile.tags.mk-ui-nav.drive%<i class="fa fa-angle-right"></i></a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="/i/drive"><i class="fa fa-cloud"></i>%i18n:mobile.tags.mk-ui-nav.drive%<i class="fa fa-angle-right"></i></a></li>
|
||||
<li><a onclick={ search }><i class="fa fa-search"></i>%i18n:mobile.tags.mk-ui-nav.search%<i class="fa fa-angle-right"></i></a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="/i/settings"><i class="fa fa-cog"></i>%i18n:mobile.tags.mk-ui-nav.settings%<i class="fa fa-angle-right"></i></a></li>
|
||||
|
Reference in New Issue
Block a user