From 36ad5f2415c3e22a951d3d9bfe2db60a2fd517ab Mon Sep 17 00:00:00 2001 From: DIYgod Date: Tue, 15 May 2018 01:55:19 +0800 Subject: [PATCH] app: welcome page --- favicon.png | Bin 0 -> 2668 bytes index.js | 4 ++++ middleware/template.js | 12 +++++++----- package.json | 2 ++ router.js | 5 ++++- views/welcome.art | 31 +++++++++++++++++++++++++----- yarn.lock | 42 ++++++++++++++++++++++++++++++++++++----- 7 files changed, 80 insertions(+), 16 deletions(-) create mode 100644 favicon.png diff --git a/favicon.png b/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..add6436b017f9c752b92794afa31382156eda3f9 GIT binary patch literal 2668 zcmV-y3X}DTP)PxdQT3u{aRTf_7+yccGWlCF|Dr&_TCcKzIXAEjGCO*uI35p5fO?@!x z0|_y{`QQWaMofr?%sh;~O-SsB@zI$0i;%G@_zMaZs<&E!;ioMWxcAKWt-aR1`<&jE zV%_Q9>t}y^?QgHM&pG?v+f3$BilWHn;J?<3WE-T&)?vtiWZ3{@w`2^U4MZZTyG;l& z>QlpX^-Z9w4o4kwShCt)x&4uSS(Y^oIjgYQ+V>YDuXf7G#umwo=McOiIa@ol@)Bl?^_45qjH_%vSC%{`=33i1Lz1u}XVV0$JVyD-W|Z z8k$IA4&5W9aZ3y0*nAYRwq~mz8FF|k6BfaZEs_-n{;^$}&DW)9u9Bkg4w0toyrQmC zO?0BwrVlmtL2qIlZLI{ND2xq@$vB?#H(oD}{bxIQ1x%|gITUbU_rI~^O)-0#jYm!0-pg;(XwNz`9Oj(;oCb%RJh-fJsS zYgiadyzIe@t?>*=h~Ac>{b()ZK-s)If1Kp9`(ng zB7%Chk-Lz4kx2qu}So@yKffhWYg}{cX3kW zn_-bpKNLBOE5q6SMvR2ut6pXHdDWZRCSdGzoD>7he?s1X@t*O;m_HQ^HluK2IDHcK zpTl?4uyzD)eYB>|jl>f>0=v|~;Bu%>`~fn%+gIk-9`urrH+w0guAN;P+r)adsj z2R|0MbUA>WFfAwTK9}ttr~0PXG2J9zDf3!^jY$SmRnvTGqlv`OfASZRPu|7DVZz2! zIKCp;<$GKg(}Mc;3*>Da@v->8=(w8VlN-)S)6_2OpEws5Fo^|thEuHKfvxswPR(yI zx#ul7Jt&@dO0T63HIl|iB_2;^Aixfr!%0q0i+qmz;4-$5`;=_uty}7=&QtiQva*1< z0%PP0iUchXMX9HpnTiih*!z3~cOf|}Mlvh{wvW+Hl4sG$uz(!B z$3f~%y#1!_0A;|of|!r-occS9C{UqQuQBNU(N)CM_ zO$f&&P&I(b(QhptE(GsY`H0?vRsCeljX49Y7=;uJoG(WRuR zpeP2CJ{H*Aq!XH@L*EDILRx;%7{L{2N0@Vxz>G@2RnE_9uL`P6D2_l8zvpf5rmfbRXxrfTx+;F6l4nGRDl;OVo|v%S(09`~VVfo%;T8<@nala3^f&|J2Ey{8!PQO@>| zr_S0a-pu9Mwfm%dDSrd{eag}$2#(Bn^{b!~vodM3RVUVgZ`youWTiS|0>CQ8xU73} zU!G+zHl@FJXX)+50l&4ZSl%M%WL#>>+A%kPlUuYH{EUFVnA9|9k?rKKg}BBjD|>gz z&3&V)FSNO_7vwEVamyem=Ou6BS(X)N7r#n^k8UrTaT?80>87}PzhQ3r-NRut;yPtuSc(Eh9=cyr@ERnog zL&si_oBH;sek~18lXtJh@8QT8iE{z`N;+Kx1-zDT&F+0BZk2RUH79AG6t6zsDaS^)$oT2!@D}cuD-HYx1=7o| z!;Oi($&ZdCsFg#Z&$$3XxB|)`O6_ffB6qC=>1-U^Zl?@%<9`pr%~`^kF(-K+P!uob zvVH%0yw&huA5H#}GJwfZi|%kE63IoFyxIa3=8MSiUmrMMWqDox_Rz2_@7XK&Jv*=e a`uIPxGCnD>8q0qG0000 { await next(); - ctx.body = art(path.resolve(__dirname, '../views/rss.art'), { - lastBuildDate: new Date().toUTCString(), - ttl: config.cacheExpire, - ...ctx.state.data, - }); + if (!ctx.body) { + ctx.body = art(path.resolve(__dirname, '../views/rss.art'), { + lastBuildDate: new Date().toUTCString(), + ttl: config.cacheExpire, + ...ctx.state.data, + }); + } }; \ No newline at end of file diff --git a/package.json b/package.json index a50b0a347..2254a83cf 100644 --- a/package.json +++ b/package.json @@ -31,9 +31,11 @@ "crypto": "1.0.1", "eslint": "4.19.1", "form-data": "^2.3.2", + "git-rev-sync": "1.12.0", "googleapis": "30.0.0", "json-bigint": "0.2.3", "koa": "2.5.0", + "koa-favicon": "2.0.1", "koa-redis-cache": "3.0.0", "koa-router": "7.4.0", "lru-cache": "4.1.2", diff --git a/router.js b/router.js index 53d5b8476..10c6b1e05 100644 --- a/router.js +++ b/router.js @@ -4,12 +4,15 @@ const art = require('art-template'); const path = require('path'); const config = require('./config'); const logger = require('./utils/logger'); +const git = require('git-rev-sync'); router.get('/', async (ctx) => { ctx.set({ 'Content-Type': 'text/html; charset=UTF-8', }); - ctx.body = art(path.resolve(__dirname, './views/welcome.art'), {}); + ctx.body = art(path.resolve(__dirname, './views/welcome.art'), { + hash: git.short(), + }); }); // bilibili diff --git a/views/welcome.art b/views/welcome.art index 4b2ad1384..87f3e4650 100644 --- a/views/welcome.art +++ b/views/welcome.art @@ -6,17 +6,38 @@ body { width: 35em; margin: 0 auto; - font-family: Tahoma, Verdana, Arial, sans-serif; + font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-size: 16px; + color: #2c3e50; + } + + .content { + position: absolute; + top: 40%; + left: 50%; + transform: translate(-50%, -50%); + min-width: 400px; + text-align: center; } -

Welcome to RSSHub!

+
+

RSSHub

-

If you see this page, the RSSHub is successfully installed and working.

+

Welcome to RSSHub!

-

For online documentation and support please refer to rsshub.js.org.

+

If you see this page, the RSSHub{{ if hash }} ({{ hash }}){{ /if }} is successfully installed and working.

-

-- Made with ♥ by DIYgod

+

For online documentation and support please refer to + rsshub.js.org.

+ +

-- Made with + ♥ by + DIYgod +

+
\ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 2b69672c7..38a9a837f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1652,7 +1652,7 @@ escape-html@^1.0.3, escape-html@~1.0.1: version "1.0.3" resolved "http://registry.npm.taobao.org/escape-html/download/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" -escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: +escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" @@ -2078,6 +2078,14 @@ getpass@^0.1.1: dependencies: assert-plus "^1.0.0" +git-rev-sync@1.12.0: + version "1.12.0" + resolved "https://registry.npmjs.org/git-rev-sync/-/git-rev-sync-1.12.0.tgz#4468406c7e6c3ba4cf4587999e1adb28d9d1af55" + dependencies: + escape-string-regexp "1.0.5" + graceful-fs "4.1.11" + shelljs "0.7.7" + glob-parent@^3.1.0: version "3.1.0" resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae" @@ -2100,7 +2108,7 @@ glob@7.0.x: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^7.0.3, glob@^7.0.5, glob@^7.1.2: +glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.2: version "7.1.2" resolved "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: @@ -2213,7 +2221,7 @@ got@^6.7.1: unzip-response "^2.0.1" url-parse-lax "^1.0.0" -graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6: +graceful-fs@4.1.11, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6: version "4.1.11" resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" @@ -2543,6 +2551,10 @@ inquirer@^3.0.6: strip-ansi "^4.0.0" through "^2.3.6" +interpret@^1.0.0: + version "1.1.0" + resolved "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614" + is-absolute-url@^2.0.0: version "2.1.0" resolved "https://registry.npmjs.org/is-absolute-url/-/is-absolute-url-2.1.0.tgz#50530dfb84fcc9aa7dbe7852e83a37b93b9f2aa6" @@ -2963,6 +2975,12 @@ koa-convert@^1.2.0: co "^4.6.0" koa-compose "^3.0.0" +koa-favicon@2.0.1: + version "2.0.1" + resolved "https://registry.npmjs.org/koa-favicon/-/koa-favicon-2.0.1.tgz#cfae363e5fd00bd5dd67c1150fbef31e0b5d6f4d" + dependencies: + mz "^2.7.0" + koa-is-json@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/koa-is-json/-/koa-is-json-1.0.0.tgz#273c07edcdcb8df6a2c1ab7d59ee76491451ec14" @@ -3528,7 +3546,7 @@ mute-stream@0.0.7: version "0.0.7" resolved "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" -mz@^2.6.0: +mz@^2.6.0, mz@^2.7.0: version "2.7.0" resolved "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz#95008057a56cafadc2bc63dde7f9ff6955948e32" dependencies: @@ -4537,6 +4555,12 @@ readdirp@^2.0.0: readable-stream "^2.0.2" set-immediate-shim "^1.0.1" +rechoir@^0.6.2: + version "0.6.2" + resolved "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" + dependencies: + resolve "^1.1.6" + redent@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/redent/-/redent-2.0.0.tgz#c1b2007b42d57eb1389079b3c8333639d5e1ccaa" @@ -4731,7 +4755,7 @@ resolve-url@^0.2.1: version "0.2.1" resolved "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" -resolve@^1.2.0, resolve@^1.6.0: +resolve@^1.1.6, resolve@^1.2.0, resolve@^1.6.0: version "1.7.1" resolved "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz#aadd656374fd298aee895bc026b8297418677fd3" dependencies: @@ -4896,6 +4920,14 @@ shebang-regex@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" +shelljs@0.7.7: + version "0.7.7" + resolved "https://registry.npmjs.org/shelljs/-/shelljs-0.7.7.tgz#b2f5c77ef97148f4b4f6e22682e10bba8667cff1" + dependencies: + glob "^7.0.0" + interpret "^1.0.0" + rechoir "^0.6.2" + signal-exit@^3.0.0, signal-exit@^3.0.2: version "3.0.2" resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"