ソースを参照

Merge pull request #127 from weseek/master

release v1.2.16
Yuki Takei 8 年 前
コミット
4bd15939e7

+ 5 - 0
CHANGES.md

@@ -1,6 +1,11 @@
 CHANGES
 ========
 
+## 1.2.16
+
+* Improvement: Condition for creating portal
+* Fix: Couldn't create new page after installation cleanly
+
 ## 1.2.15
 
 * Improvement: Optimize cache settings for express server

+ 14 - 8
README.md

@@ -14,24 +14,30 @@ crowi-plus [![Chat on Slack](https://crowi-plus-slackin.weseek.co.jp/badge.svg)]
 [![dependencies status](https://david-dm.org/weseek/crowi-plus.svg)](https://david-dm.org/weseek/crowi-plus)
 [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
 
-This is **crowi-plus** that is the fork of [Crowi][crowi], is [perfectly compatible with official](https://github.com/weseek/crowi-plus/wiki/Questions-and-Answers#does-crowi-plus-have-compatibility-with-official-crowi), and has been enhanced with the following points:
 
-* Pluggable
+**crowi-plus** is a fork of [Crowi][crowi] that is [perfectly compatible with the official project](https://github.com/weseek/crowi-plus/wiki/Correspondence-table-with-official-version).
+
+
+Why crowi-plus?
+================
+
+* **Pluggable**
   * Find plugins from [npm](https://www.npmjs.com/browse/keyword/crowi-plugin) or [github](https://github.com/search?q=topic%3Acrowi-plugin)!
-* Faster
+* **Faster**
   * Optimize client-side code chunks by Webpack
+  * Optimize cache settings for static assets
   * Adopt the fastest logger [pino](https://github.com/pinojs/pino)
   * Using CDN
-* Secure
+* **Secure**
   * Upgrade jQuery to 3.x
   * Upgrade other insecure libs
-* [Docker Ready][dockerhub]
-* [Docker Compose Ready][docker-compose]
+* **[Docker Ready][dockerhub]**
+* **[Docker Compose Ready][docker-compose]**
   * [Multiple sites example](https://github.com/weseek/crowi-plus-docker-compose/tree/master/examples/multi-app)
   * [HTTPS(with Let's Encrypt) proxy integration example](https://github.com/weseek/crowi-plus-docker-compose/tree/master/examples/https-portal)
-* [Added miscellaneous features](https://github.com/weseek/crowi-plus/wiki/Additional-Features)
+* **[Added miscellaneous features](https://github.com/weseek/crowi-plus/wiki/Additional-Features)**
 * Support for IE11 (Experimental)
-* Developer-friendly
+* **Developer-friendly**
   * Less compile time
   * LiveReload separately available by server/client code change
   * Exclude Environment-dependency (confirmed to be developable on Win/Mac/Linux)

+ 1 - 0
config/env.dev.js

@@ -11,6 +11,7 @@ module.exports = {
   DEBUG: [
     // 'express:*',
     // 'crowi:*',
+    // 'crowi:routes:page',
     // 'crowi:plugins:*',
     // 'crowi:InterceptorManager',
   ].join(),

+ 4 - 0
lib/routes/installer.js

@@ -5,6 +5,7 @@ module.exports = function(crowi, app) {
     , models = crowi.models
     , Config = models.Config
     , User = models.User
+    , Page = models.Page
 
     , actions = {};
 
@@ -41,6 +42,9 @@ module.exports = function(crowi, app) {
             req.flash('successMessage', 'Crowi のインストールが完了しました!はじめに、このページでこの Wiki の各種設定を確認してください。');
             return res.redirect('/admin/app');
           });
+
+          // create portal page for '/'
+          Page.create('/', '# Welcome to crowi-plus!', userData, {});
         });
       });
     } else {

+ 25 - 11
lib/routes/page.js

@@ -234,10 +234,15 @@ module.exports = function(crowi, app) {
 
     var pageTeamplate = 'customlayout-selector/page';
 
+    var isRedirect = false;
     Page.findPage(path, req.user, req.query.revision)
     .then(function(page) {
+      debug('Page found', page._id, page.path);
+
       // redirect
       if (page.redirectTo) {
+        debug(`Redirect to '${page.redirectTo}'`);
+        isRedirect = true;
         return res.redirect(encodeURI(page.redirectTo + '?redirectFrom=' + page.path));
       }
 
@@ -288,12 +293,17 @@ module.exports = function(crowi, app) {
       } else {
         return Promise.resolve();
       }
-    }).catch(function(err) {
-      // page not exists
+    })
+    // page not exists
+    .catch(function(err) {
+      debug('Page not found', path);
       // change template
       pageTeamplate = 'customlayout-selector/not_found';
-    }).then(function() {
-      return Page.findListByStartWith(path, req.user, queryOptions)
+    })
+    // get list pages
+    .then(function() {
+      if (!isRedirect) {
+        Page.findListByStartWith(path, req.user, queryOptions)
         .then(function(pageList) {
           if (pageList.length > limit) {
             pageList.pop();
@@ -308,14 +318,18 @@ module.exports = function(crowi, app) {
           renderVars.pages = pageList;
 
           return Promise.resolve();
+        })
+        .then(function() {
+          return interceptorManager.process('beforeRenderPage', req, res, renderVars);
+        })
+        .then(function() {
+          res.render(req.query.presentation ? 'page_presentation' : pageTeamplate, renderVars);
+        })
+        .catch(function(err) {
+          console.log(err);
+          debug('Error on rendering pageListShowForCrowiPlus', err);
         });
-    }).then(function() {
-      return interceptorManager.process('beforeRenderPage', req, res, renderVars);
-    }).then(function() {
-      res.render(req.query.presentation ? 'page_presentation' : pageTeamplate, renderVars);
-    }).catch(function(err) {
-      console.log(err);
-      debug('Error on rendering pageListShowForCrowiPlus', err);
+      }
     });
   }
 

+ 2 - 2
lib/views/admin/customize.html

@@ -73,9 +73,9 @@
               crowi-plus Simplified Behavior <small class="text-success">(Recommended)</small>
             </h4>
             <ul>
-              <li><code>/page</code> and <code>/page/</code> both shows the page</li>
+              <li>Both of <code>/page</code> and <code>/page/</code> shows the same page</li>
               <li><code>/nonexistent_page</code> shows editing form</li>
-              <li>All pages shows the list of sub pages</li>
+              <li>All pages shows the list of sub pages when using <b>crowi-plus Enhanced Layout</b></li>
             </ul>
           </div>
         </div>

+ 1 - 1
lib/views/crowi-plus/widget/header.html

@@ -56,7 +56,7 @@
       </ul>
       {% endif %}
 
-      {% if not page and ('crowi' === behaviorType()) and not isUserPageList(path) and !isTrashPage() %}
+      {% if not page and ('/' === path or 'crowi' === behaviorType()) and not isUserPageList(path) and !isTrashPage() %}
       <div class="portal-form-button">
         <button class="btn btn-primary" id="create-portal-button" {% if not user %}disabled{% endif %}>Create Portal</button>
         <p class="help-block"><a href="#" data-target="#help-portal" data-toggle="modal"><i class="fa fa-question-circle"></i> What is Portal?</a></p>

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "crowi-plus",
-  "version": "1.2.15-RC",
+  "version": "1.2.16-RC",
   "description": "Enhanced Crowi",
   "tags": [
     "wiki",