feat: rss stylesheet

This commit is contained in:
DIYgod
2019-08-13 00:59:24 +08:00
parent 0aaf1e3f6c
commit a04ad04f05
7 changed files with 119 additions and 4 deletions

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

+85
View File
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<html>
<head>
<title>
<xsl:value-of select="rss/channel/title" />
</title>
<style type="text/css">
body {
font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;
max-width: 980px;
margin: 0 auto;
padding: 20px;
font-size: 15px;
color: #1a1a1a;
}
a {
color:#f5712c;
text-decoration:none;
}
h1 {
font-size:24px;
font-weight:bold;
}
.description {
color: #555;
margin: 15px 0;
}
.title {
font-size:16px;
font-weight:bold;
border-bottom:solid 1px #f5712c;
}
</style>
</head>
<body>
<xsl:apply-templates select="rss/channel" />
</body>
</html>
</xsl:template>
<xsl:template match="channel">
<div class="header">
<h1>
<xsl:element name="A">
<xsl:attribute name="href">
<xsl:value-of select="link"/>
</xsl:attribute>
<xsl:value-of select="title"/>
</xsl:element>
</h1>
<div class="description">
<xsl:value-of select="description" />
</div>
</div>
<table width="90%" cellpadding="4" cellspacing="0">
<xsl:for-each select="item">
<tr>
<td class="title">
<xsl:element name="A">
<xsl:attribute name="href">
<xsl:value-of select="link" />
</xsl:attribute>
<xsl:attribute name="target">_blank</xsl:attribute>
<xsl:value-of select="title" />
</xsl:element>
</td>
</tr>
<tr>
<td>
<xsl:value-of select="description" disable-output-escaping="yes" />
</td>
</tr>
<tr height="10">
<td></td>
</tr>
</xsl:for-each>
<tr>
<td height="40"></td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
+4 -1
View File
@@ -19,6 +19,7 @@ const accessControl = require('./middleware/access-control');
const router = require('./router');
const protected_router = require('./protected_router');
const mount = require('koa-mount');
const serve = require('koa-static');
// API related
@@ -44,7 +45,7 @@ if (cluster.isMaster && config.enableCluster && process.env.NODE_ENV !== 'test'
app.proxy = true;
// favicon
app.use(favicon(__dirname + '/favicon.png'));
app.use(favicon(__dirname + '/assets/favicon.png'));
// global error handing
app.use(onerror);
@@ -87,6 +88,8 @@ if (cluster.isMaster && config.enableCluster && process.env.NODE_ENV !== 'test'
// API router
app.use(mount('/api', api_router.routes())).use(api_router.allowedMethods());
app.use(mount('/assets', serve(__dirname + '/assets')));
// connect
let server;
if (config.connect.socket) {
+1 -1
View File
@@ -7,7 +7,7 @@ const utils = require('@/utils/common-utils');
module.exports = async (ctx, next) => {
await next();
if (!ctx.state.data && !ctx._matchedRoute) {
if (!ctx.state.data && !ctx._matchedRoute && !ctx.request.url.startsWith('/assets/')) {
throw Error('wrong path');
}
+1 -1
View File
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="/assets/rss.xsl" media="all" ?>
{{ if itunes_author }}
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
{{else}}
+1
View File
@@ -72,6 +72,7 @@
"koa-favicon": "2.0.1",
"koa-mount": "4.0.0",
"koa-router": "7.4.0",
"koa-static": "^5.0.0",
"lru-cache": "5.1.1",
"lz-string": "1.4.4",
"markdown-it": "9.0.1",
+27 -1
View File
@@ -6269,6 +6269,24 @@ koa-router@7.4.0:
path-to-regexp "^1.1.1"
urijs "^1.19.0"
koa-send@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/koa-send/-/koa-send-5.0.0.tgz#5e8441e07ef55737734d7ced25b842e50646e7eb"
integrity sha512-90ZotV7t0p3uN9sRwW2D484rAaKIsD8tAVtypw/aBU+ryfV+fR2xrcAwhI8Wl6WRkojLUs/cB9SBSCuIb+IanQ==
dependencies:
debug "^3.1.0"
http-errors "^1.6.3"
mz "^2.7.0"
resolve-path "^1.4.0"
koa-static@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/koa-static/-/koa-static-5.0.0.tgz#5e92fc96b537ad5219f425319c95b64772776943"
integrity sha512-UqyYyH5YEXaJrf9S8E23GoJFQZXkBVJ9zYYMPGz919MSX1KuvAcycIuS0ci150HCoPf4XQVhQ84Qf8xRPWxFaQ==
dependencies:
debug "^3.1.0"
koa-send "^5.0.0"
koa@2.7.0:
version "2.7.0"
resolved "https://registry.yarnpkg.com/koa/-/koa-2.7.0.tgz#7e00843506942b9d82c6cc33749f657c6e5e7adf"
@@ -7703,7 +7721,7 @@ path-exists@^3.0.0:
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"
integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=
path-is-absolute@^1.0.0:
path-is-absolute@1.0.1, path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
@@ -8905,6 +8923,14 @@ resolve-from@^4.0.0:
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6"
integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==
resolve-path@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/resolve-path/-/resolve-path-1.4.0.tgz#c4bda9f5efb2fce65247873ab36bb4d834fe16f7"
integrity sha1-xL2p9e+y/OZSR4c6s2u02DT+Fvc=
dependencies:
http-errors "~1.6.2"
path-is-absolute "1.0.1"
resolve-url@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"