فهرست منبع

WIP: move portal, portal functions

Sotaro KARASAWA 9 سال پیش
والد
کامیت
dc64b10c14
4فایلهای تغییر یافته به همراه60 افزوده شده و 5 حذف شده
  1. 9 0
      lib/routes/page.js
  2. 9 0
      lib/util/swigFunctions.js
  3. 7 2
      lib/views/modal/widget_unportalize.html
  4. 35 3
      lib/views/page_list.html

+ 9 - 0
lib/routes/page.js

@@ -77,12 +77,21 @@ module.exports = function(crowi, app) {
       page: null,
       page: null,
       path: path,
       path: path,
       pages: [],
       pages: [],
+      tree: [],
     };
     };
 
 
     Page.hasPortalPage(path, req.user)
     Page.hasPortalPage(path, req.user)
     .then(function(portalPage) {
     .then(function(portalPage) {
       renderVars.page = portalPage;
       renderVars.page = portalPage;
 
 
+      if (portalPage) {
+        return Revision.findRevisionList(portalPage.path, {});
+      } else {
+        return Promise.resolve([]);
+      }
+    }).then(function(tree) {
+      renderVars.tree = tree;
+
       return Page.findListByStartWith(path, req.user, queryOptions);
       return Page.findListByStartWith(path, req.user, queryOptions);
     }).then(function(pageList) {
     }).then(function(pageList) {
 
 

+ 9 - 0
lib/util/swigFunctions.js

@@ -43,6 +43,15 @@ module.exports = function(crowi, app, req, locals) {
     return false;
     return false;
   };
   };
 
 
+  locals.isTopPage = function() {
+    var path = req.path || '';
+    if (path === '/') {
+      return true;
+    }
+
+    return false;
+  };
+
   locals.isTrashPage = function() {
   locals.isTrashPage = function() {
     var path = req.path || '';
     var path = req.path || '';
     if (path.match(/^\/trash\/.*/)) {
     if (path.match(/^\/trash\/.*/)) {

+ 7 - 2
lib/views/modal/widget_unportalize.html

@@ -1,3 +1,8 @@
+{% if isTopPage() %}
+  {% set unportalizedPath = '/top-' + Date.now() %}
+{% else %}
+  {% set unportalizedPath = page.path|replace('(\/)$', '') %}
+{% endif %}
   <div class="modal fade" id="unportalize">
   <div class="modal fade" id="unportalize">
     <div class="modal-dialog">
     <div class="modal-dialog">
       <div class="modal-content">
       <div class="modal-content">
@@ -17,14 +22,14 @@
                 <label for="">このページ</label><br><code>{{ page.path }}</code>
                 <label for="">このページ</label><br><code>{{ page.path }}</code>
               </p>
               </p>
               <p>
               <p>
-                <label for="">解除後のページ</label><br><code>{{ page.path|replace('(\/)$', '') }}</code>
+                <label for="">解除後のページ</label><br><code>{{ unportalizedPath }}</code>
               </p>
               </p>
             </div>
             </div>
         </div>
         </div>
         <div class="modal-footer">
         <div class="modal-footer">
           <p><small class="pull-left" id="newPageNameCheck"></small></p>
           <p><small class="pull-left" id="newPageNameCheck"></small></p>
           <input type="hidden" name="path" value="{{ page.path }}">
           <input type="hidden" name="path" value="{{ page.path }}">
-          <input type="hidden" class="form-control" name="new_path" id="newPageName" value="{{ page.path|replace('(\/)$', '') }}">
+          <input type="hidden" class="form-control" name="new_path" id="newPageName" value="{{ unportalizedPath }}">
           <input type="hidden" name="page_id" value="{{ page._id.toString() }}">
           <input type="hidden" name="page_id" value="{{ page._id.toString() }}">
           <input type="hidden" name="revision_id" value="{{ page.revision._id.toString() }}">
           <input type="hidden" name="revision_id" value="{{ page.revision._id.toString() }}">
           <input type="submit" class="btn btn-primary" value="Unportalize!">
           <input type="submit" class="btn btn-primary" value="Unportalize!">

+ 35 - 3
lib/views/page_list.html

@@ -20,7 +20,7 @@
     {% endif %}
     {% endif %}
     <h1 class="title">
     <h1 class="title">
       <span class="" id="revision-path">{{ path|insertSpaceToEachSlashes }}</span>
       <span class="" id="revision-path">{{ path|insertSpaceToEachSlashes }}</span>
-      {% if searchConfigured() && path != '/' && !isTrashPage() %}
+      {% if searchConfigured() && !isTopPage() && !isTrashPage() %}
       <form class="input-group search-input-group hidden-xs hidden-sm" data-toggle="tooltip" data-placement="bottom" title="{{ path }} 以下から検索" id="search-listpage-form">
       <form class="input-group search-input-group hidden-xs hidden-sm" data-toggle="tooltip" data-placement="bottom" title="{{ path }} 以下から検索" id="search-listpage-form">
         <input type="text" class="search-listpage-input form-control" data-path="{{ path }}" id="search-listpage-input">
         <input type="text" class="search-listpage-input form-control" data-path="{{ path }}" id="search-listpage-input">
         <span class="input-group-btn search-listpage-submit-group">
         <span class="input-group-btn search-listpage-submit-group">
@@ -46,7 +46,7 @@
  # but now the header and page list content is rendered separately by the server,
  # but now the header and page list content is rendered separately by the server,
  # so now bind the values through the hidden fields.
  # so now bind the values through the hidden fields.
  #}
  #}
-{% if searchConfigured() && path != '/' && !isTrashPage() %}
+{% if searchConfigured() && !isTopPage() && !isTrashPage() %}
 <div id="page-list-search">
 <div id="page-list-search">
 </div>
 </div>
 {% endif %}
 {% endif %}
@@ -85,7 +85,7 @@
         <i class="fa fa-times"></i>
         <i class="fa fa-times"></i>
       </a>
       </a>
     </li>
     </li>
-    {%  else %}
+    {% else %}
     <li class="dropdown pull-right">
     <li class="dropdown pull-right">
       <a class="dropdown-toggle" data-toggle="dropdown" href="#">
       <a class="dropdown-toggle" data-toggle="dropdown" href="#">
         <i class="fa fa-wrench"></i> <span class="caret"></span>
         <i class="fa fa-wrench"></i> <span class="caret"></span>
@@ -94,6 +94,7 @@
        <li><a href="#" data-target="#unportalize" data-toggle="modal"><i class="fa fa-share"></i> ポータル解除</a></li>
        <li><a href="#" data-target="#unportalize" data-toggle="modal"><i class="fa fa-share"></i> ポータル解除</a></li>
       </ul>
       </ul>
     </li>
     </li>
+    <li class="pull-right"><a href="#revision-history" data-toggle="tab"><i class="fa fa-history"></i> History</a></li>
     {% endif %}
     {% endif %}
   </ul>
   </ul>
   {% include 'modal/widget_unportalize.html' %}
   {% include 'modal/widget_unportalize.html' %}
@@ -106,7 +107,38 @@
     <div class="tab-pane edit-form portal-form {% if req.body.pageForm %}active{% endif %}" id="edit-form">
     <div class="tab-pane edit-form portal-form {% if req.body.pageForm %}active{% endif %}" id="edit-form">
       {% include '_form.html' with {forceGrant: 1} %}
       {% include '_form.html' with {forceGrant: 1} %}
     </div>
     </div>
+
+    <div class="tab-pane revision-history" id="revision-history">
+      <h1><i class="fa fa-history"></i> History</h1>
+      {% if not page %}
+      {% else %}
+      <div class="revision-history-list">
+        {% for t in tree %}
+        <div class="revision-hisory-outer">
+          <img src="{{ t.author|picture }}" class="picture picture-rounded">
+          <div class="revision-history-main">
+            <div class="revision-history-author">
+              <strong>{% if t.author %}{{ t.author.username }}{% else %}-{% endif %}</strong>
+            </div>
+            <div class="revision-history-comment">
+            </div>
+            <div class="revision-history-meta">
+              {{ t.createdAt|datetz('Y-m-d H:i:s') }}
+              <br>
+              <a href="?revision={{ t._id.toString() }}"><i class="fa fa-history"></i> このバージョンを見る</a>
+              <a class="diff-view" data-revision-id="{{ t._id.toString() }}">
+                <i id="diff-icon-{{ t._id.toString() }}" class="fa fa-arrow-circle-right"></i> 差分を見る
+              </a>
+              <pre class="" id="diff-display-{{ t._id.toString()}}" style="display: none"></pre>
+            </div>
+          </div>
+        </div>
+        {% endfor %}
+      </div>
+      {% endif %}
+    </div>
   </div>
   </div>
+
 </div> {# /.portal #}
 </div> {# /.portal #}
 
 
 <div class="page-list-container">
 <div class="page-list-container">