mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-25 00:49:17 +09:00
wip
This commit is contained in:
parent
9aed3d21c9
commit
77528f022d
@ -241,6 +241,7 @@ desktop:
|
|||||||
mk-ui-header-nav:
|
mk-ui-header-nav:
|
||||||
home: "Home"
|
home: "Home"
|
||||||
messaging: "Messages"
|
messaging: "Messages"
|
||||||
|
bbs: "BBS"
|
||||||
info: "News"
|
info: "News"
|
||||||
|
|
||||||
mk-ui-header-search:
|
mk-ui-header-search:
|
||||||
@ -351,6 +352,11 @@ desktop:
|
|||||||
mk-repost-form-window:
|
mk-repost-form-window:
|
||||||
title: "Are you sure you want to repost this post?"
|
title: "Are you sure you want to repost this post?"
|
||||||
|
|
||||||
|
mk-bbs-page:
|
||||||
|
title: "Misskey BBS"
|
||||||
|
new: "Create new thread"
|
||||||
|
thread-title: "Thread title"
|
||||||
|
|
||||||
mobile:
|
mobile:
|
||||||
tags:
|
tags:
|
||||||
mk-drive-file-viewer:
|
mk-drive-file-viewer:
|
||||||
|
@ -241,6 +241,7 @@ desktop:
|
|||||||
mk-ui-header-nav:
|
mk-ui-header-nav:
|
||||||
home: "ホーム"
|
home: "ホーム"
|
||||||
messaging: "メッセージ"
|
messaging: "メッセージ"
|
||||||
|
bbs: "掲示板"
|
||||||
info: "お知らせ"
|
info: "お知らせ"
|
||||||
|
|
||||||
mk-ui-header-search:
|
mk-ui-header-search:
|
||||||
@ -351,6 +352,11 @@ desktop:
|
|||||||
mk-repost-form-window:
|
mk-repost-form-window:
|
||||||
title: "この投稿をRepostしますか?"
|
title: "この投稿をRepostしますか?"
|
||||||
|
|
||||||
|
mk-bbs-page:
|
||||||
|
title: "Misskey掲示板"
|
||||||
|
new: "スレッドを作成"
|
||||||
|
thread-title: "スレッドのタイトル"
|
||||||
|
|
||||||
mobile:
|
mobile:
|
||||||
tags:
|
tags:
|
||||||
mk-drive-file-viewer:
|
mk-drive-file-viewer:
|
||||||
|
29
src/api/endpoints/bbs/threads/create.ts
Normal file
29
src/api/endpoints/bbs/threads/create.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/**
|
||||||
|
* Module dependencies
|
||||||
|
*/
|
||||||
|
import $ from 'cafy';
|
||||||
|
import Thread from '../../../models/bbs-thread';
|
||||||
|
import serialize from '../../../serializers/bbs-thread';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a thread
|
||||||
|
*
|
||||||
|
* @param {any} params
|
||||||
|
* @param {any} user
|
||||||
|
* @return {Promise<any>}
|
||||||
|
*/
|
||||||
|
module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||||
|
// Get 'title' parameter
|
||||||
|
const [title, titleErr] = $(params.title).string().range(1, 100).$;
|
||||||
|
if (titleErr) return rej('invalid title param');
|
||||||
|
|
||||||
|
// Create a thread
|
||||||
|
const thread = await Thread.insert({
|
||||||
|
created_at: new Date(),
|
||||||
|
user_id: user._id,
|
||||||
|
title: title
|
||||||
|
});
|
||||||
|
|
||||||
|
// Response
|
||||||
|
res(await serialize(thread));
|
||||||
|
});
|
13
src/api/models/bbs-thread.ts
Normal file
13
src/api/models/bbs-thread.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import * as mongo from 'mongodb';
|
||||||
|
import db from '../../db/mongodb';
|
||||||
|
|
||||||
|
const collection = db.get('bbs_threads');
|
||||||
|
|
||||||
|
export default collection as any; // fuck type definition
|
||||||
|
|
||||||
|
export type IBbsThread = {
|
||||||
|
_id: mongo.ObjectID;
|
||||||
|
created_at: Date;
|
||||||
|
title: string;
|
||||||
|
user_id: mongo.ObjectID;
|
||||||
|
};
|
44
src/api/serializers/bbs-thread.ts
Normal file
44
src/api/serializers/bbs-thread.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/**
|
||||||
|
* Module dependencies
|
||||||
|
*/
|
||||||
|
import * as mongo from 'mongodb';
|
||||||
|
import deepcopy = require('deepcopy');
|
||||||
|
import { IUser } from '../models/user';
|
||||||
|
import { default as Thread, IBbsThread } from '../models/bbs-thread';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serialize a thread
|
||||||
|
*
|
||||||
|
* @param thread target
|
||||||
|
* @param me? serializee
|
||||||
|
* @return response
|
||||||
|
*/
|
||||||
|
export default (
|
||||||
|
thread: string | mongo.ObjectID | IBbsThread,
|
||||||
|
me?: string | mongo.ObjectID | IUser
|
||||||
|
) => new Promise<any>(async (resolve, reject) => {
|
||||||
|
|
||||||
|
let _thread: any;
|
||||||
|
|
||||||
|
// Populate the thread if 'thread' is ID
|
||||||
|
if (mongo.ObjectID.prototype.isPrototypeOf(thread)) {
|
||||||
|
_thread = await Thread.findOne({
|
||||||
|
_id: thread
|
||||||
|
});
|
||||||
|
} else if (typeof thread === 'string') {
|
||||||
|
_thread = await Thread.findOne({
|
||||||
|
_id: new mongo.ObjectID(thread)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
_thread = deepcopy(thread);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rename _id to id
|
||||||
|
_thread.id = _thread._id;
|
||||||
|
delete _thread._id;
|
||||||
|
|
||||||
|
// Remove needless properties
|
||||||
|
delete _thread.user_id;
|
||||||
|
|
||||||
|
resolve(_thread);
|
||||||
|
});
|
@ -61,6 +61,7 @@ require('./pages/user.tag');
|
|||||||
require('./pages/post.tag');
|
require('./pages/post.tag');
|
||||||
require('./pages/search.tag');
|
require('./pages/search.tag');
|
||||||
require('./pages/not-found.tag');
|
require('./pages/not-found.tag');
|
||||||
|
require('./pages/bbs.tag');
|
||||||
require('./autocomplete-suggestion.tag');
|
require('./autocomplete-suggestion.tag');
|
||||||
require('./progress-dialog.tag');
|
require('./progress-dialog.tag');
|
||||||
require('./user-preview.tag');
|
require('./user-preview.tag');
|
||||||
|
30
src/web/app/desktop/tags/pages/bbs.tag
Normal file
30
src/web/app/desktop/tags/pages/bbs.tag
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<mk-bbs-page>
|
||||||
|
<mk-ui ref="ui">
|
||||||
|
<main>
|
||||||
|
<h1>%i18n:desktop.tags.mk-bbs-page.title%</h1>
|
||||||
|
<button onclick={ parent.new }>%i18n:desktop.tags.mk-bbs-page.new%</button>
|
||||||
|
</main>
|
||||||
|
</mk-ui>
|
||||||
|
<style>
|
||||||
|
:scope
|
||||||
|
display block
|
||||||
|
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
this.mixin('api');
|
||||||
|
|
||||||
|
this.on('mount', () => {
|
||||||
|
document.title = '%i18n:desktop.tags.mk-bbs-page.title%';
|
||||||
|
});
|
||||||
|
|
||||||
|
this.new = () => {
|
||||||
|
const title = window.prompt('%i18n:desktop.tags.mk-bbs-page.thread-title%');
|
||||||
|
|
||||||
|
this.api('bbs/threads/create', {
|
||||||
|
title: title
|
||||||
|
}).then(thread => {
|
||||||
|
location.href = '/bbs/' + thread.id;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
</mk-bbs-page>
|
@ -319,7 +319,8 @@
|
|||||||
</mk-ui-header-notifications>
|
</mk-ui-header-notifications>
|
||||||
|
|
||||||
<mk-ui-header-nav>
|
<mk-ui-header-nav>
|
||||||
<ul if={ SIGNIN }>
|
<ul>
|
||||||
|
<virtual if={ SIGNIN }>
|
||||||
<li class="home { active: page == 'home' }">
|
<li class="home { active: page == 'home' }">
|
||||||
<a href={ CONFIG.url }>
|
<a href={ CONFIG.url }>
|
||||||
<i class="fa fa-home"></i>
|
<i class="fa fa-home"></i>
|
||||||
@ -333,6 +334,13 @@
|
|||||||
<i class="fa fa-circle" if={ hasUnreadMessagingMessages }></i>
|
<i class="fa fa-circle" if={ hasUnreadMessagingMessages }></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
</virtual>
|
||||||
|
<li class="bbs">
|
||||||
|
<a href={ CONFIG.url + '/bbs' }>
|
||||||
|
<i class="fa fa-coffee"></i>
|
||||||
|
<p>%i18n:desktop.tags.mk-ui-header-nav.bbs%</p>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
<li class="info">
|
<li class="info">
|
||||||
<a href="https://twitter.com/misskey_xyz" target="_blank">
|
<a href="https://twitter.com/misskey_xyz" target="_blank">
|
||||||
<i class="fa fa-info"></i>
|
<i class="fa fa-info"></i>
|
||||||
|
Loading…
Reference in New Issue
Block a user