forked from reruin/sharelist
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,111 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Teambition | ||
|
||
由 [drive.teambition.js](https://github.com/reruin/sharelist/tree/master/plugins/drive.teambition.js) 插件实现。 | ||
``` 挂载路径 | ||
挂载路径留空 | ||
``` | ||
将```挂载路径留空```,ShareList将自动开启挂载向导,按指示填写用户名、密码、初始路径(可留空)即可。 | ||
|
||
?> 初始路径可用于挂载指定目录,从官网访问到对应文件夹内,复制浏览器URL 作为初始路径即可,它的格式如下:```https://www.teambition.com/pan/org/xxxxxxxxxx/space/xxxxxxxxxx/folder/xxxxxxxxxx```。 | ||
|
||
?> 未适配国际版。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
class RSS { | ||
constructor(app) { | ||
this.name = 'RSS Server' | ||
this.app = app | ||
this.path = '/_rss' | ||
this.start() | ||
} | ||
|
||
start() { | ||
let { app, path } = this | ||
let port = app.getConfig('port') | ||
let router = app.router().all(this.path + ':path(.*)', async (ctx, next) => { | ||
await this.onRequest(ctx, next) | ||
}) | ||
app.web().use(router.routes()) | ||
|
||
this.zeroconf = app.bonjour.publish({ name: 'ShareList RSS', type: 'http', port, txt: { path } }) | ||
} | ||
|
||
async onRequest(ctx, next) { | ||
let url = ctx.params.path | ||
let resp = await this.app.command('ls', url) | ||
if( resp ){ | ||
let k = this.createDir(resp.children) | ||
ctx.type = 'application/rss+xml' | ||
ctx.body = k | ||
}else{ | ||
ctx.body = { | ||
code:404 | ||
} | ||
} | ||
|
||
await next() | ||
} | ||
|
||
createDir(items) { | ||
let path = '' | ||
let body = items.filter(i => i.hidden !== true).map(i => { | ||
let href = ((path + '/' + encodeURIComponent(i.name))).replace(/\/{2,}/g, '/') | ||
return `<item> | ||
<title>${i.name}</title> | ||
<link>${href}</link> | ||
<description>${i.name}</description> | ||
<pubDate>${i.updated_at}</pubDate> | ||
<enclosure url="${href}" | ||
length="${i.size}" type="${i.type}" /> | ||
</item>` | ||
}) | ||
|
||
return `<?xml version="1.0" encoding="UTF-8"?> | ||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> | ||
${body.join('')} | ||
</rss>` | ||
} | ||
|
||
restart() { | ||
if (this.zeroconf) { | ||
this.zeroconf.stop(()=>{ | ||
this.start() | ||
}) | ||
}else{ | ||
this.start() | ||
} | ||
} | ||
} | ||
|
||
module.exports = RSS |
Oops, something went wrong.