Просмотр исходного кода

Merge pull request #3944 from weseek/feat/6338-6554-implement-top-page

Feat/6338 6554 implement top page
Yuki Takei 4 лет назад
Родитель
Сommit
65e36d2208

+ 15 - 0
packages/slackbot-proxy/src/Server.ts

@@ -88,6 +88,21 @@ const helmetOptions = isProduction ? {} : {
   exclude: [
     '**/*.spec.ts',
   ],
+  viewsDir: `${rootDir}/views`,
+  views: {
+    root: `${rootDir}/views`,
+    viewEngine: 'ejs',
+    extensions: {
+      ejs: 'ejs',
+    },
+  },
+  statics: {
+    '/': [
+      {
+        root: `${rootDir}/public`,
+      },
+    ],
+  },
 })
 export class Server {
 

+ 1 - 1
packages/slackbot-proxy/src/controllers/privacy.ts

@@ -4,7 +4,7 @@ import { Request, Response } from 'express';
 const isOfficialMode = process.env.OFFICIAL_MODE === 'true';
 
 @Controller('/privacy')
-export class SlackCtrl {
+export class PrivacyCtrl {
 
   constructor(router: PlatformRouter) {
     if (isOfficialMode) {

+ 0 - 21
packages/slackbot-proxy/src/controllers/slack.ts

@@ -53,27 +53,6 @@ export class SlackCtrl {
   @Inject()
   unregisterService: UnregisterService;
 
-  @Get('/install')
-  async install(): Promise<string> {
-    const url = await this.installerService.installer.generateInstallUrl({
-      // Add the scopes your app needs
-      scopes: [
-        'channels:history',
-        'commands',
-        'groups:history',
-        'im:history',
-        'mpim:history',
-        'chat:write',
-        'team:read',
-      ],
-    });
-
-    return `<a href="${url}">`
-      // eslint-disable-next-line max-len
-      + '<img alt="Add to Slack" height="40" width="139" src="https://platform.slack-edge.com/img/add_to_slack.png" srcSet="https://platform.slack-edge.com/img/add_to_slack.png 1x, https://platform.slack-edge.com/img/add_to_slack@2x.png 2x" />'
-      + '</a>';
-  }
-
   /**
    * Send command to specified GROWIs
    * @param growiCommand

+ 35 - 0
packages/slackbot-proxy/src/controllers/top.ts

@@ -0,0 +1,35 @@
+import {
+  Controller, Get, Inject, View,
+} from '@tsed/common';
+
+import { InstallerService } from '~/services/InstallerService';
+
+const isOfficialMode = process.env.OFFICIAL_MODE === 'true';
+
+
+@Controller('/')
+export class TopCtrl {
+
+  @Inject()
+  installerService: InstallerService;
+
+  @Get('/')
+  @View('top.ejs')
+  async getTopPage(): Promise<any> {
+    const url = await this.installerService.installer.generateInstallUrl({
+      // Add the scopes your app needs
+      scopes: [
+        'channels:history',
+        'commands',
+        'groups:history',
+        'im:history',
+        'mpim:history',
+        'chat:write',
+        'team:read',
+      ],
+    });
+
+    return { url, isOfficialMode };
+  }
+
+}

BIN
packages/slackbot-proxy/src/public/images/growi-bot.png


+ 20 - 0
packages/slackbot-proxy/src/views/top.ejs

@@ -0,0 +1,20 @@
+<head>
+  <meta name="viewport" content="width=device-width,initial-scale=1">
+</head>
+
+<body style="padding-top:100px; text-align:center;">
+  <h1 >GROWI Bot</h1>
+  <div>
+    <img height="300" width="300" alt="GROWi Bot" src="/images/growi-bot.png" />
+  </div>
+  <div style="display:flex; justify-content: space-around; max-width: 500px; margin:30px auto;">
+    <a href=<%- url %>>
+      <img alt="Add to Slack" height="40" width="139" src="https://platform.slack-edge.com/img/add_to_slack.png" srcSet="https://platform.slack-edge.com/img/add_to_slack.png 1x, https://platform.slack-edge.com/img/add_to_slack@2x.png 2x" />
+    </a>
+    <% if (isOfficialMode) { %>
+      <a href="/privacy">
+        Privacy Policy
+      </a>
+    <% } %>
+  </div>
+</body>