Procházet zdrojové kódy

Merge pull request #2366 from weseek/support/not-found-page

Support/not found page
Yuki Takei před 5 roky
rodič
revize
dbf8a419eb

+ 1 - 1
src/server/routes/index.js

@@ -180,7 +180,7 @@ module.exports = function(crowi, app) {
   app.post('/_api/hackmd.discard'        , accessTokenParser , loginRequiredStrictly , csrf, hackmd.validateForApi, hackmd.discard);
   app.post('/_api/hackmd.saveOnHackmd'   , accessTokenParser , loginRequiredStrictly , csrf, hackmd.validateForApi, hackmd.saveOnHackmd);
 
-  app.get('/share/:linkId', page.showSharedPage, page.notFound);
+  app.get('/share/:linkId', page.showSharedPage);
 
   app.get('/*/$'                   , loginRequired , page.showPageWithEndOfSlash, page.notFound);
   app.get('/*'                     , loginRequired , page.showPage, page.notFound);

+ 7 - 2
src/server/routes/page.js

@@ -451,8 +451,13 @@ module.exports = function(crowi, app) {
 
     if (page == null) {
       // page is not found
-      // TODO GW-2735 create not found page
-      // return res.render(`layout-${layoutName}/not_found_shared_page`);
+      return res.render(`layout-${layoutName}/not_found_shared_page`);
+    }
+
+    // check if share link is expired
+    if (shareLink.expiredAt.getTime() < new Date().getTime()) {
+      // page is not found
+      return res.render(`layout-${layoutName}/expired_shared_page`);
     }
 
     const renderVars = {};

+ 13 - 0
src/server/views/layout-growi/expired_shared_page.html

@@ -0,0 +1,13 @@
+{% extends './shared_page.html' %}
+
+{% block content_header %}
+{% endblock %}
+
+{% block content_page %}
+  <div class="col-md-12">
+    <h2 class="text-muted">
+      <i class="icon-ban" aria-hidden="true"></i>
+      Page is expired
+    </h2>
+  </div>
+{% endblock %}

+ 13 - 0
src/server/views/layout-growi/not_found_shared_page.html

@@ -0,0 +1,13 @@
+{% extends './shared_page.html' %}
+
+{% block content_header %}
+{% endblock %}
+
+{% block content_page %}
+  <div class="col-md-12">
+    <h2 class="text-muted">
+      <i class="icon-info" aria-hidden="true"></i>
+      Page is not found
+    </h2>
+  </div>
+{% endblock %}

+ 15 - 13
src/server/views/layout-growi/shared_page.html

@@ -15,23 +15,25 @@
 
 {% block content_main %}
   <div class="row" id="is-shared-page" data-share-link-expired-at="{{ sharelink.expiredAt|datetz('Y/m/d H:i:s')}}" data-share-link-created-at="{{ sharelink.createdAt|datetz('Y/m/d H:i:s')}}">
-    <div class="col grw-page-content-container">
-     <div id="share-link-alert"></div>
+    {% block content_page %}
+      <div class="col grw-page-content-container">
+      <div id="share-link-alert"></div>
 
-      {% include '../widget/page_content.html' %}
-      {# force remove #revision-toc from #content_main of parent #}
-      <script>
-        $('#revision-toc').remove();
-      </script>
+        {% include '../widget/page_content.html' %}
+        {# force remove #revision-toc from #content_main of parent #}
+        <script>
+          $('#revision-toc').remove();
+        </script>
 
-    </div>
+      </div>
 
-    {# relocate #revision-toc #}
-    <div class="col-xl-2 col-lg-3 d-none d-lg-block revision-toc-container">
-      <div id="revision-toc" class="revision-toc mt-3 sps sps--abv" data-sps-offset="123">
-        <div id="revision-toc-content" class="revision-toc-content"></div>
+      {# relocate #revision-toc #}
+      <div class="col-xl-2 col-lg-3 d-none d-lg-block revision-toc-container">
+        <div id="revision-toc" class="revision-toc mt-3 sps sps--abv" data-sps-offset="123">
+          <div id="revision-toc-content" class="revision-toc-content"></div>
+        </div>
       </div>
-    </div>
+    {% endblock %}
 
   </div>
 

+ 13 - 0
src/server/views/layout-kibela/expired_shared_page.html

@@ -0,0 +1,13 @@
+{% extends './shared_page.html' %}
+
+{% block content_header %}
+{% endblock %}
+
+{% block content_page %}
+  <div class="col-md-12">
+    <h2 class="text-muted">
+      <i class="icon-ban" aria-hidden="true"></i>
+      Page is expired
+    </h2>
+  </div>
+{% endblock %}

+ 13 - 0
src/server/views/layout-kibela/not_found_shared_page.html

@@ -0,0 +1,13 @@
+{% extends './shared_page.html' %}
+
+{% block content_header %}
+{% endblock %}
+
+{% block content_page %}
+  <div class="col-md-12">
+    <h2 class="text-muted">
+      <i class="icon-info" aria-hidden="true"></i>
+      Page is not found
+    </h2>
+  </div>
+{% endblock %}

+ 19 - 17
src/server/views/layout-kibela/shared_page.html

@@ -14,24 +14,26 @@
 {% endblock %}
 
 {% block content_main %}
-  <div class="row" id="is-shared-page" data-share-link-expired-at="{{ sharelink.expiredAt|datetz('Y/m/d H:i:s')}}"  data-share-link-created-at="{{ sharelink.createdAt|datetz('Y/m/d H:i:s')}}">
-    <div class="col-12 col-xl-9 col-lg-8 bg-white round-corner">
-      <div id="share-link-alert"></div>
-
-      {% include '../widget/page_content.html' %}
-      {# force remove #revision-toc from #content_main of parent #}
-      <script>
-        $('#revision-toc').remove();
-      </script>
-
-    </div>
-
-    {# relocate #revision-toc #}
-    <div class="col-xl-3 col-lg-4 d-none d-lg-block revision-toc-container">
-      <div id="revision-toc" class="revision-toc mt-3 sps sps--abv" data-sps-offset="123">
-        <div id="revision-toc-content" class="revision-toc-content"></div>
+  <div class="row" id="is-shared-page" data-share-link-expired-at="{{ sharelink.expiredAt|datetz('Y/m/d H:i:s')}}" data-share-link-created-at="{{ sharelink.createdAt|datetz('Y/m/d H:i:s')}}">
+    {% block content_page %}
+      <div class="col-12 col-xl-9 col-lg-8 bg-white round-corner">
+        <div id="share-link-alert"></div>
+
+        {% include '../widget/page_content.html' %}
+        {# force remove #revision-toc from #content_main of parent #}
+        <script>
+          $('#revision-toc').remove();
+        </script>
+
+      </div>
+
+      {# relocate #revision-toc #}
+      <div class="col-xl-3 col-lg-4 d-none d-lg-block revision-toc-container">
+        <div id="revision-toc" class="revision-toc mt-3 sps sps--abv" data-sps-offset="123">
+          <div id="revision-toc-content" class="revision-toc-content"></div>
+        </div>
       </div>
-    </div>
+    {% endblock %}
 
   </div>
 {% endblock %}