diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2020-01-30 04:37:25 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-30 04:37:25 +0900 |
| commit | f6154dc0af1a0d65819e87240f4385f9573095cb (patch) | |
| tree | 699a5ca07d6727b7f8497d4769f25d6d62f94b5a /src/client/widgets/rss.vue | |
| parent | Add Event activity-type support (#5785) (diff) | |
| download | misskey-f6154dc0af1a0d65819e87240f4385f9573095cb.tar.gz misskey-f6154dc0af1a0d65819e87240f4385f9573095cb.tar.bz2 misskey-f6154dc0af1a0d65819e87240f4385f9573095cb.zip | |
v12 (#5712)
Co-authored-by: MeiMei <30769358+mei23@users.noreply.github.com>
Co-authored-by: Satsuki Yanagi <17376330+u1-liquid@users.noreply.github.com>
Diffstat (limited to 'src/client/widgets/rss.vue')
| -rw-r--r-- | src/client/widgets/rss.vue | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/src/client/widgets/rss.vue b/src/client/widgets/rss.vue new file mode 100644 index 0000000000..61c1e23b6e --- /dev/null +++ b/src/client/widgets/rss.vue @@ -0,0 +1,101 @@ +<template> +<div> + <mk-container :show-header="!props.compact"> + <template #header><fa :icon="faRssSquare"/>RSS</template> + <template #func><button class="_button" @click="setting"><fa :icon="faCog"/></button></template> + + <div class="ekmkgxbj"> + <mk-loading v-if="fetching"/> + <div class="feed" v-else> + <a v-for="item in items" :href="item.link" rel="nofollow noopener" target="_blank" :title="item.title">{{ item.title }}</a> + </div> + </div> + </mk-container> +</div> +</template> + +<script lang="ts"> +import { faRssSquare, faCog } from '@fortawesome/free-solid-svg-icons'; +import MkContainer from '../components/ui/container.vue'; +import define from './define'; +import i18n from '../i18n'; + +export default define({ + name: 'rss', + props: () => ({ + compact: false, + url: 'http://feeds.afpbb.com/rss/afpbb/afpbbnews' + }) +}).extend({ + i18n, + components: { + MkContainer + }, + data() { + return { + items: [], + fetching: true, + clock: null, + faRssSquare, faCog + }; + }, + mounted() { + this.fetch(); + this.clock = setInterval(this.fetch, 60000); + }, + beforeDestroy() { + clearInterval(this.clock); + }, + methods: { + func() { + this.props.compact = !this.props.compact; + this.save(); + }, + fetch() { + fetch(`https://api.rss2json.com/v1/api.json?rss_url=${this.props.url}`, { + }).then(res => { + res.json().then(feed => { + this.items = feed.items; + this.fetching = false; + }); + }); + }, + setting() { + this.$root.dialog({ + title: 'URL', + input: { + type: 'url', + default: this.props.url + } + }).then(({ canceled, result: url }) => { + if (canceled) return; + this.props.url = url; + this.save(); + this.fetch(); + }); + } + } +}); +</script> + +<style lang="scss" scoped> +.ekmkgxbj { + > .feed { + padding: 0; + font-size: 0.9em; + + > a { + display: block; + padding: 8px 16px; + color: var(--text); + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + + &:nth-child(even) { + background: rgba(#000, 0.05); + } + } + } +} +</style> |