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

Merge pull request #4607 from weseek/feat/select-from-same-path-pages

feat: Select from same path pages
Yuki Takei 4 лет назад
Родитель
Сommit
e55deef2d8

+ 3 - 3
packages/app/src/server/routes/page.js

@@ -564,11 +564,11 @@ module.exports = function(crowi, app) {
    */
    */
   async function redirector(req, res, next, path) {
   async function redirector(req, res, next, path) {
     const pages = await Page.findByPathAndViewer(path, req.user, null, false);
     const pages = await Page.findByPathAndViewer(path, req.user, null, false);
+    const { redirectFrom } = req.query;
 
 
     if (pages.length >= 2) {
     if (pages.length >= 2) {
-      // TODO: return res.render('layout-growi/select_same_path_page', renderVars);
-      // TODO: put redirectFrom into renderVars
-      return res.send('Two or more pages found.');
+      // pass only redirectFrom since it is not sure whether the query params are related to the pages
+      return res.render('layout-growi/select-go-to-page', { pages, redirectFrom });
     }
     }
 
 
     const queryParams = new URLSearchParams();
     const queryParams = new URLSearchParams();

+ 22 - 0
packages/app/src/server/views/layout-growi/select-go-to-page.html

@@ -0,0 +1,22 @@
+{% extends 'base/layout.html' %}
+
+<!-- WIP -->
+
+{% block content_main %}
+  <div>ContentMain</div>
+  <div>
+    {% for page in pages %}
+      <li>{{page._id.toString()}}: {{page.path}}</li>
+    {% endfor %}
+  </div>
+  <br>
+  <div>redirectFrom: {{redirectFrom}}</div>
+{% endblock %}
+
+{% block content_footer %}
+  <div>Footer</div>
+{% endblock %}
+
+{% block body_end %}
+  <div>BodyEnd</div>
+{% endblock %}