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

remove concept of empty page id

yohei0125 4 лет назад
Родитель
Сommit
196e2ec6d5

+ 1 - 1
packages/app/src/client/services/ContextExtractor.tsx

@@ -49,7 +49,7 @@ const ContextExtractorOnce: FC = () => {
    */
    */
   const revisionId = mainContent?.getAttribute('data-page-revision-id');
   const revisionId = mainContent?.getAttribute('data-page-revision-id');
   const path = decodeURI(mainContent?.getAttribute('data-path') || '');
   const path = decodeURI(mainContent?.getAttribute('data-path') || '');
-  const pageId = mainContent?.getAttribute('data-page-id') || JSON.parse(notFoundContent?.getAttribute('data-empty-page-id') || jsonNull);
+  const pageId = mainContent?.getAttribute('data-page-id') || notFoundContent?.getAttribute('data-page-id');
 
 
   const revisionCreatedAt = +(mainContent?.getAttribute('data-page-revision-created') || '');
   const revisionCreatedAt = +(mainContent?.getAttribute('data-page-revision-created') || '');
 
 

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

@@ -278,11 +278,11 @@ module.exports = function(crowi, app) {
     renderVars.isNotFoundPermalink = !isPath && !await Page.exists({ _id: pathOrId });
     renderVars.isNotFoundPermalink = !isPath && !await Page.exists({ _id: pathOrId });
   }
   }
 
 
-  async function addRenderVarsWhenEmptyPage(renderVars, emptyPageId) {
-    if (emptyPageId == null) {
+  async function addRenderVarsWhenEmptyPage(renderVars, pageId) {
+    if (pageId == null) {
       return;
       return;
     }
     }
-    renderVars.emptyPageId = emptyPageId;
+    renderVars.pageId = pageId;
   }
   }
 
 
   function replacePlaceholdersOfTemplate(template, req) {
   function replacePlaceholdersOfTemplate(template, req) {
@@ -340,8 +340,8 @@ module.exports = function(crowi, app) {
     await addRenderVarsForDescendants(renderVars, path, req.user, offset, limit, true);
     await addRenderVarsForDescendants(renderVars, path, req.user, offset, limit, true);
     await addRenderVarsForPageTree(renderVars, pathOrId, req.user);
     await addRenderVarsForPageTree(renderVars, pathOrId, req.user);
     await addRenderVarsWhenNotFound(renderVars, pathOrId);
     await addRenderVarsWhenNotFound(renderVars, pathOrId);
-    if (req.emptyPageId != null) {
-      await addRenderVarsWhenEmptyPage(renderVars, req.emptyPageId);
+    if (req.pageId != null) {
+      await addRenderVarsWhenEmptyPage(renderVars, req.pageId);
     }
     }
     return res.render(view, renderVars);
     return res.render(view, renderVars);
   }
   }
@@ -647,7 +647,7 @@ module.exports = function(crowi, app) {
       return _notFound(req, res);
       return _notFound(req, res);
     }
     }
     if (isEmptyPage) {
     if (isEmptyPage) {
-      req.emptyPageId = pages[0]._id;
+      req.pageId = pages[0]._id;
       return _notFound(req, res);
       return _notFound(req, res);
     }
     }
 
 

+ 1 - 1
packages/app/src/server/views/layout-growi/not_found.html

@@ -11,7 +11,7 @@
   <div
   <div
     id="growi-not-found-context"
     id="growi-not-found-context"
     data-is-not-found-permalink="{% if isNotFoundPermalink %}{{isNotFoundPermalink|json}}{% endif %}"
     data-is-not-found-permalink="{% if isNotFoundPermalink %}{{isNotFoundPermalink|json}}{% endif %}"
-    data-empty-page-id="{%if emptyPageId %}{{emptyPageId|json}}{% endif %}"
+    data-page-id="{%if pageId %}{{pageId.toString()}}{% endif %}"
   >
   >
   </div>
   </div>
   <div class="grw-container-convertible">
   <div class="grw-container-convertible">