summaryrefslogtreecommitdiff
path: root/src/web/app/common/scripts
diff options
context:
space:
mode:
authorsyuilo⭐️ <Syuilotan@yahoo.co.jp>2017-02-18 18:12:04 +0900
committerGitHub <noreply@github.com>2017-02-18 18:12:04 +0900
commit5305f3dde2b2ef2e36b09548452ca5c1a547092a (patch)
tree9961c66c4de99d5a4bf590f378e0474df28fef15 /src/web/app/common/scripts
parent壁紙廃止 (diff)
parentRemove unused dependency (diff)
downloadmisskey-5305f3dde2b2ef2e36b09548452ca5c1a547092a.tar.gz
misskey-5305f3dde2b2ef2e36b09548452ca5c1a547092a.tar.bz2
misskey-5305f3dde2b2ef2e36b09548452ca5c1a547092a.zip
Merge pull request #179 from syuilo/no-ls
No ls
Diffstat (limited to 'src/web/app/common/scripts')
-rw-r--r--src/web/app/common/scripts/check-for-update.js11
-rw-r--r--src/web/app/common/scripts/check-for-update.ls9
-rw-r--r--src/web/app/common/scripts/date-stringify.js13
-rw-r--r--src/web/app/common/scripts/date-stringify.ls14
-rw-r--r--src/web/app/common/scripts/generate-default-userdata.js47
-rw-r--r--src/web/app/common/scripts/generate-default-userdata.ls28
-rw-r--r--src/web/app/common/scripts/get-post-summary.js37
-rw-r--r--src/web/app/common/scripts/get-post-summary.ls30
-rw-r--r--src/web/app/common/scripts/i.js20
-rw-r--r--src/web/app/common/scripts/i.ls13
-rw-r--r--src/web/app/common/scripts/is-promise.js1
-rw-r--r--src/web/app/common/scripts/is-promise.ls1
-rw-r--r--src/web/app/common/scripts/loading.js21
-rw-r--r--src/web/app/common/scripts/loading.ls16
-rw-r--r--src/web/app/common/scripts/log.ls18
-rw-r--r--src/web/app/common/scripts/messaging-stream.js36
-rw-r--r--src/web/app/common/scripts/messaging-stream.ls34
-rw-r--r--src/web/app/common/scripts/signout.js5
-rw-r--r--src/web/app/common/scripts/signout.ls4
-rw-r--r--src/web/app/common/scripts/stream.js39
-rw-r--r--src/web/app/common/scripts/stream.ls39
21 files changed, 230 insertions, 206 deletions
diff --git a/src/web/app/common/scripts/check-for-update.js b/src/web/app/common/scripts/check-for-update.js
new file mode 100644
index 0000000000..cd7279e3b8
--- /dev/null
+++ b/src/web/app/common/scripts/check-for-update.js
@@ -0,0 +1,11 @@
+module.exports = () => {
+ fetch('/api:meta').then(res => {
+ res.json().then(meta => {
+ if (meta.commit.hash !== VERSION) {
+ if (window.confirm('新しいMisskeyのバージョンがあります。更新しますか?\r\n(このメッセージが繰り返し表示される場合は、サーバーにデータがまだ届いていない可能性があるので、少し時間を置いてから再度お試しください)')) {
+ location.reload(true);
+ }
+ }
+ });
+ });
+};
diff --git a/src/web/app/common/scripts/check-for-update.ls b/src/web/app/common/scripts/check-for-update.ls
deleted file mode 100644
index 48e250a4c7..0000000000
--- a/src/web/app/common/scripts/check-for-update.ls
+++ /dev/null
@@ -1,9 +0,0 @@
-module.exports = ->
- fetch \/api:meta
- .then (res) ~>
- meta <~ res.json!.then
- if meta.commit.hash != VERSION
- if window.confirm '新しいMisskeyのバージョンがあります。更新しますか?\r\n(このメッセージが繰り返し表示される場合は、サーバーにデータがまだ届いていない可能性があるので、少し時間を置いてから再度お試しください)'
- location.reload true
- .catch ~>
- # ignore
diff --git a/src/web/app/common/scripts/date-stringify.js b/src/web/app/common/scripts/date-stringify.js
new file mode 100644
index 0000000000..48e19704d5
--- /dev/null
+++ b/src/web/app/common/scripts/date-stringify.js
@@ -0,0 +1,13 @@
+module.exports = date => {
+ if (typeof date == 'string') date = new Date(date);
+ return (
+ date.getFullYear() + '年' +
+ date.getMonth() + 1 + '月' +
+ date.getDate() + '日' +
+ ' ' +
+ date.getHours() + '時' +
+ date.getMinutes() + '分' +
+ ' ' +
+ `(${['日', '月', '火', '水', '木', '金', '土'][date.getDay()]})`
+ );
+};
diff --git a/src/web/app/common/scripts/date-stringify.ls b/src/web/app/common/scripts/date-stringify.ls
deleted file mode 100644
index 7e85192ce7..0000000000
--- a/src/web/app/common/scripts/date-stringify.ls
+++ /dev/null
@@ -1,14 +0,0 @@
-module.exports = (date) ->
- if typeof date == \string then date = new Date date
-
- text =
- date.get-full-year! + \年 +
- date.get-month! + 1 + \月 +
- date.get-date! + \日 +
- ' ' +
- date.get-hours! + \時 +
- date.get-minutes! + \分 +
- ' ' +
- "(#{[\日 \月 \火 \水 \木 \金 \土][date.get-day!]})"
-
- return text
diff --git a/src/web/app/common/scripts/generate-default-userdata.js b/src/web/app/common/scripts/generate-default-userdata.js
new file mode 100644
index 0000000000..f6c8c2fe58
--- /dev/null
+++ b/src/web/app/common/scripts/generate-default-userdata.js
@@ -0,0 +1,47 @@
+const uuid = require('./uuid.js');
+
+const home = {
+ left: [
+ 'profile',
+ 'calendar',
+ 'rss-reader',
+ 'photo-stream'
+ ],
+ right: [
+ 'broadcast',
+ 'notifications',
+ 'user-recommendation',
+ 'donation',
+ 'nav',
+ 'tips'
+ ]
+};
+
+module.exports = () => {
+ const homeData = [];
+
+ home.left.forEach(widget => {
+ homeData.push({
+ name: widget,
+ id: uuid(),
+ place: 'left'
+ });
+ });
+
+ home.right.forEach(widget => {
+ homeData.push({
+ name: widget,
+ id: uuid(),
+ place: 'right'
+ });
+ });
+
+ const data = {
+ cache: true,
+ debug: false,
+ nya: true,
+ home: homeData
+ };
+
+ return data;
+};
diff --git a/src/web/app/common/scripts/generate-default-userdata.ls b/src/web/app/common/scripts/generate-default-userdata.ls
deleted file mode 100644
index c13d221bb9..0000000000
--- a/src/web/app/common/scripts/generate-default-userdata.ls
+++ /dev/null
@@ -1,28 +0,0 @@
-uuid = require './uuid.js'
-
-home =
- left: [ \profile \calendar \rss-reader \photo-stream ]
- right: [ \broadcast \notifications \user-recommendation \donation \nav \tips ]
-
-module.exports = ~>
- home-data = []
-
- home.left.for-each (widget) ~>
- home-data.push do
- name: widget
- id: uuid!
- place: \left
-
- home.right.for-each (widget) ~>
- home-data.push do
- name: widget
- id: uuid!
- place: \right
-
- data =
- cache: true
- debug: false
- nya: true
- home: home-data
-
- return data
diff --git a/src/web/app/common/scripts/get-post-summary.js b/src/web/app/common/scripts/get-post-summary.js
new file mode 100644
index 0000000000..8e17d54e81
--- /dev/null
+++ b/src/web/app/common/scripts/get-post-summary.js
@@ -0,0 +1,37 @@
+const getPostSummary = post => {
+ let = post.text ? post.text : '';
+
+ // メディアが添付されているとき
+ if (post.media) {
+ summary += ` (${post.media.length}つのメディア)`;
+ }
+
+ // 投票が添付されているとき
+ if (post.poll) {
+ summary += ' (投票)';
+ }
+
+ // 返信のとき
+ if (post.reply_to_id) {
+ if (post.reply_to) {
+ replySummary = getPostSummary(post.reply_to);
+ summary += ` RE: ${replySummary}`;
+ } else {
+ summary += ' RE: ...';
+ }
+ }
+
+ // Repostのとき
+ if (post.repost_id) {
+ if (post.repost) {
+ repostSummary = getPostSummary(post.repost);
+ summary += ` RP: ${repostSummary}`;
+ } else {
+ summary += ' RP: ...';
+ }
+ }
+
+ return summary.trim();
+};
+
+module.exports = getPostSummary;
diff --git a/src/web/app/common/scripts/get-post-summary.ls b/src/web/app/common/scripts/get-post-summary.ls
deleted file mode 100644
index 67178bc324..0000000000
--- a/src/web/app/common/scripts/get-post-summary.ls
+++ /dev/null
@@ -1,30 +0,0 @@
-get-post-summary = (post) ~>
- summary = if post.text? then post.text else ''
-
- # メディアが添付されているとき
- if post.media?
- summary += " (#{post.media.length}つのメディア)"
-
- # 投票が添付されているとき
- if post.poll?
- summary += " (投票)"
-
- # 返信のとき
- if post.reply_to_id?
- if post.reply_to?
- reply-summary = get-post-summary post.reply_to
- summary += " RE: #{reply-summary}"
- else
- summary += " RE: ..."
-
- # Repostのとき
- if post.repost_id?
- if post.repost?
- repost-summary = get-post-summary post.repost
- summary += " RP: #{repost-summary}"
- else
- summary += " RP: ..."
-
- return summary.trim!
-
-module.exports = get-post-summary
diff --git a/src/web/app/common/scripts/i.js b/src/web/app/common/scripts/i.js
new file mode 100644
index 0000000000..66ce37d506
--- /dev/null
+++ b/src/web/app/common/scripts/i.js
@@ -0,0 +1,20 @@
+const riot = require('riot');
+
+module.exports = me => {
+ riot.mixin('i', {
+ init: () => {
+ this.I = me;
+ this.SIGNIN = me != null;
+
+ if (this.SIGNIN) {
+ this.on('mount', () => {
+ me.on('updated', this.update);
+ });
+ this.on('unmount', () => {
+ me.off('updated', this.update);
+ });
+ }
+ },
+ me: me
+ });
+};
diff --git a/src/web/app/common/scripts/i.ls b/src/web/app/common/scripts/i.ls
deleted file mode 100644
index 9b5fa87441..0000000000
--- a/src/web/app/common/scripts/i.ls
+++ /dev/null
@@ -1,13 +0,0 @@
-riot = require \riot
-
-module.exports = (me) ->
- riot.mixin \i do
- init: ->
- @I = me
- @SIGNIN = me?
-
- if @SIGNIN
- @on \mount ~> me.on \updated @update
- @on \unmount ~> me.off \updated @update
-
- me: me \ No newline at end of file
diff --git a/src/web/app/common/scripts/is-promise.js b/src/web/app/common/scripts/is-promise.js
new file mode 100644
index 0000000000..fd3dc42da3
--- /dev/null
+++ b/src/web/app/common/scripts/is-promise.js
@@ -0,0 +1 @@
+module.exports = x => typeof x.then == 'function';
diff --git a/src/web/app/common/scripts/is-promise.ls b/src/web/app/common/scripts/is-promise.ls
deleted file mode 100644
index e3c7adff85..0000000000
--- a/src/web/app/common/scripts/is-promise.ls
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = (x) -> typeof x.then == \function
diff --git a/src/web/app/common/scripts/loading.js b/src/web/app/common/scripts/loading.js
new file mode 100644
index 0000000000..fa7eafaf96
--- /dev/null
+++ b/src/web/app/common/scripts/loading.js
@@ -0,0 +1,21 @@
+const NProgress = require('nprogress');
+NProgress.configure({
+ trickleSpeed: 500,
+ showSpinner: false
+});
+
+const root = document.getElementsByTagName('html')[0];
+
+module.exports = {
+ start: () => {
+ root.classList.add('progress');
+ NProgress.start();
+ },
+ done: () => {
+ root.classList.remove('progress');
+ NProgress.done();
+ },
+ set: val => {
+ NProgress.set(val);
+ }
+};
diff --git a/src/web/app/common/scripts/loading.ls b/src/web/app/common/scripts/loading.ls
deleted file mode 100644
index 8ebede6db4..0000000000
--- a/src/web/app/common/scripts/loading.ls
+++ /dev/null
@@ -1,16 +0,0 @@
-NProgress = require \nprogress
-NProgress.configure do
- trickle-speed: 500ms
- show-spinner: false
-
-root = document.get-elements-by-tag-name \html .0
-
-module.exports =
- start: ~>
- root.class-list.add \progress
- NProgress.start!
- done: ~>
- root.class-list.remove \progress
- NProgress.done!
- set: (val) ~>
- NProgress.set val
diff --git a/src/web/app/common/scripts/log.ls b/src/web/app/common/scripts/log.ls
deleted file mode 100644
index 6e1e3735d8..0000000000
--- a/src/web/app/common/scripts/log.ls
+++ /dev/null
@@ -1,18 +0,0 @@
-riot = require \riot
-
-logs = []
-
-ev = riot.observable!
-
-function log(msg)
- logs.push do
- date: new Date!
- message: msg
- ev.trigger \log
-
-riot.mixin \log do
- logs: logs
- log: log
- log-event: ev
-
-module.exports = log
diff --git a/src/web/app/common/scripts/messaging-stream.js b/src/web/app/common/scripts/messaging-stream.js
new file mode 100644
index 0000000000..e6fc6f8bd0
--- /dev/null
+++ b/src/web/app/common/scripts/messaging-stream.js
@@ -0,0 +1,36 @@
+const ReconnectingWebSocket = require('reconnecting-websocket');
+const riot = require('riot');
+
+class Connection {
+ constructor(me, otherparty) {
+ this.event = riot.observable();
+ this.me = me;
+
+ const host = CONFIG.api.url.replace('http', 'ws');
+ this.socket = new ReconnectingWebSocket(`${host}/messaging?i=${me.token}&otherparty=${otherparty}`);
+ this.socket.addEventListener('open', this.onOpen);
+ this.socket.addEventListener('message', this.onMessage);
+ }
+
+ onOpen() {
+ this.socket.send(JSON.stringify({
+ i: this.me.token
+ }));
+ }
+
+ onMessage(message) {
+ try {
+ const message = JSON.parse(message.data);
+ if (message.type) this.event.trigger(message.type, message.body);
+ } catch(e) {
+ // noop
+ }
+ }
+
+ close() {
+ this.socket.removeEventListener('open', this.onOpen);
+ this.socket.removeEventListener('message', this.onMessage);
+ }
+}
+
+module.exports = Connection;
diff --git a/src/web/app/common/scripts/messaging-stream.ls b/src/web/app/common/scripts/messaging-stream.ls
deleted file mode 100644
index ac3e74f1f5..0000000000
--- a/src/web/app/common/scripts/messaging-stream.ls
+++ /dev/null
@@ -1,34 +0,0 @@
-# Stream
-#================================
-
-ReconnectingWebSocket = require 'reconnecting-websocket'
-riot = require 'riot'
-
-class Connection
- (me, otherparty) ~>
- @event = riot.observable!
- @me = me
- host = CONFIG.api.url.replace \http \ws
- @socket = new ReconnectingWebSocket "#{host}/messaging?i=#{me.token}&otherparty=#{otherparty}"
-
- @socket.add-event-listener \open @on-open
- @socket.add-event-listener \message @on-message
-
- on-open: ~>
- @socket.send JSON.stringify do
- i: @me.token
-
- on-message: (message) ~>
- try
- message = JSON.parse message.data
- if message.type?
- @event.trigger message.type, message.body
- catch
- # ignore
-
- close: ~>
- @socket.remove-event-listener \open @on-open
- @socket.remove-event-listener \message @on-message
- @socket.close!
-
-module.exports = Connection
diff --git a/src/web/app/common/scripts/signout.js b/src/web/app/common/scripts/signout.js
new file mode 100644
index 0000000000..cd752423da
--- /dev/null
+++ b/src/web/app/common/scripts/signout.js
@@ -0,0 +1,5 @@
+module.exports = () => {
+ localStorage.removeItem('me');
+ document.cookie = `i=; domain=.${CONFIG.host}; expires=Thu, 01 Jan 1970 00:00:01 GMT;`;
+ location.href = '/';
+};
diff --git a/src/web/app/common/scripts/signout.ls b/src/web/app/common/scripts/signout.ls
deleted file mode 100644
index a647922678..0000000000
--- a/src/web/app/common/scripts/signout.ls
+++ /dev/null
@@ -1,4 +0,0 @@
-module.exports = ->
- local-storage.remove-item \me
- document.cookie = "i=; domain=.#{CONFIG.host}; expires=Thu, 01 Jan 1970 00:00:01 GMT;"
- location.href = \/
diff --git a/src/web/app/common/scripts/stream.js b/src/web/app/common/scripts/stream.js
new file mode 100644
index 0000000000..b31e570444
--- /dev/null
+++ b/src/web/app/common/scripts/stream.js
@@ -0,0 +1,39 @@
+const ReconnectingWebSocket = require('reconnecting-websocket');
+const riot = require('riot');
+
+module.exports = me => {
+ let state = 'initializing';
+ const stateEv = riot.observable();
+ const event = riot.observable();
+ const host = CONFIG.api.url.replace('http', 'ws');
+ const socket = new ReconnectingWebSocket(`${host}?i=${me.token}`);
+
+ socket.onopen = () => {
+ state = 'connected';
+ stateEv.trigger('connected');
+ };
+
+ socket.onclose = () => {
+ state = 'reconnecting';
+ stateEv.trigger('closed');
+ };
+
+ socket.onmessage = message => {
+ try {
+ const message = JSON.parse(message.data);
+ if (message.type) {
+ event.trigger(message.type, message.body);
+ }
+ } catch (e) {
+ // noop
+ }
+ };
+
+ event.on('i_updated', me.update);
+
+ return {
+ stateEv: stateEv,
+ getState: () => state,
+ event: event
+ };
+};
diff --git a/src/web/app/common/scripts/stream.ls b/src/web/app/common/scripts/stream.ls
deleted file mode 100644
index c2c061603e..0000000000
--- a/src/web/app/common/scripts/stream.ls
+++ /dev/null
@@ -1,39 +0,0 @@
-# Stream
-#================================
-
-ReconnectingWebSocket = require \reconnecting-websocket
-riot = require \riot
-
-module.exports = (me) ~>
- state = \initializing
- state-ev = riot.observable!
- event = riot.observable!
-
- host = CONFIG.api.url.replace \http \ws
- socket = new ReconnectingWebSocket "#{host}?i=#{me.token}"
-
- socket.onopen = ~>
- state := \connected
- state-ev.trigger \connected
-
- socket.onclose = ~>
- state := \reconnecting
- state-ev.trigger \closed
-
- socket.onmessage = (message) ~>
- try
- message = JSON.parse message.data
- if message.type?
- event.trigger message.type, message.body
- catch
- # ignore
-
- get-state = ~> state
-
- event.on \i_updated me.update
-
- {
- state-ev
- get-state
- event
- }