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

Merge branch 'master' into support/edit-readme

Yuki Takei 8 лет назад
Родитель
Сommit
448329f51d

+ 5 - 0
CHANGES.md

@@ -11,9 +11,14 @@ CHANGES
 * Improvement: Replace markdown parser with markdown-it
 * Improvement: Generate anchor of headers with header strings
 * Improvement: Update `#revision-body` tab contents after saving with `Ctrl-S`
+
+## 2.3.9
+
 * Fix: `Ctrl-/` doesn't work on Chrome
 * Fix: Close Shortcuts help with `Ctrl-/`, ESC key
 * Fix: Jump to last line wrongly when `.revision-head-edit-button` clicked
+* Support: Upgrade libs
+    * googleapis
 
 ## 2.3.8
 

+ 2 - 1
README.md

@@ -13,10 +13,11 @@ crowi-plus [![Chat on Slack](https://crowi-plus-slackin.weseek.co.jp/badge.svg)]
 [![wercker status](https://app.wercker.com/status/39cdc49d067d65c39cb35d52ceae6dc1/s/master "wercker status")](https://app.wercker.com/project/byKey/39cdc49d067d65c39cb35d52ceae6dc1)
 [![dependencies status](https://david-dm.org/weseek/crowi-plus.svg)](https://david-dm.org/weseek/crowi-plus)
 [![devDependencies Status](https://david-dm.org/weseek/crowi-plus/dev-status.svg)](https://david-dm.org/weseek/crowi-plus?type=dev)
+[![docker pulls](https://img.shields.io/docker/pulls/weseek/crowi-plus.svg)](https://hub.docker.com/r/weseek/crowi-plus/)
 [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
 
 
-**crowi-plus** is a fork of [Crowi][crowi] which is [perfectly compatible with the official project](https://github.com/weseek/crowi-plus/wiki/Correspondence-table-with-official-version).
+**crowi-plus** is a fork of [Crowi][crowi] which is [perfectly compatible with the official project](https://github.com/weseek/crowi-plus/wiki/Correspondence-table-with-Crowi-version).
 
 
 Why crowi-plus?

+ 12 - 22
lib/models/user.js

@@ -436,34 +436,24 @@ module.exports = function(crowi) {
 
 
   userSchema.statics.findUserByUsername = function(username) {
-    var User = this;
-    return new Promise(function(resolve, reject) {
-      User.findOne({username: username}, function (err, userData) {
-        if (err) {
-          return reject(err);
-        }
-
-        return resolve(userData);
-      });
-    });
+    if (username == null) {
+      return Promise.resolve(null);
+    }
+    return this.findOne({username});
   };
 
   userSchema.statics.findUserByApiToken = function(apiToken) {
-    var self = this;
-
-    return new Promise(function(resolve, reject) {
-      self.findOne({apiToken: apiToken}, function (err, userData) {
-        if (err) {
-          return reject(err);
-        } else {
-          return resolve(userData);
-        }
-      });
-    });
+    if (apiToken == null) {
+      return Promise.resolve(null);
+    }
+    return this.findOne({apiToken});
   };
 
   userSchema.statics.findUserByGoogleId = function(googleId, callback) {
-    this.findOne({googleId: googleId}, function (err, userData) {
+    if (googleId == null) {
+      callback(null, null);
+    }
+    this.findOne({googleId}, function (err, userData) {
       callback(err, userData);
     });
   };

+ 5 - 3
lib/util/googleAuth.js

@@ -5,7 +5,8 @@
 module.exports = function(config) {
   'use strict';
 
-  var google = require('googleapis')
+  const { GoogleApis } = require('googleapis');
+  var google = new GoogleApis()
     , debug = require('debug')('crowi:lib:googleAuth')
     , lib = {}
     ;
@@ -58,8 +59,9 @@ module.exports = function(config) {
           return callback(new Error('[googleAuth.handleCallback] Error while proceccing userinfo.get.'), null);
         }
 
-        response.user_id = response.id; // This is for B.C. (tokeninfo をつかっている前提のコードに対してのもの)
-        return callback(null, response);
+        let data = response.data;
+        data.user_id = data.id;           // This is for B.C. (tokeninfo をつかっている前提のコードに対してのもの)
+        return callback(null, data);
       });
     });
   };

+ 12 - 1
lib/views/admin/customize.html

@@ -248,8 +248,11 @@
         </p>
 
         <p class="help-block">
-          Available Placeholders:
+          Placeholders:<br>
+          (Available after <code>load</code> event)
           <dl class="dl-horizontal">
+            <dt><code>$</code></dt>
+            <dd>jQuery instance</dd>
             <dt><code>crowi</code></dt>
             <dd>Crowi context instance</dd>
             <dt><code>Crowi</code></dt>
@@ -260,6 +263,14 @@
             <dd>crowi-plus plugin manager instance</dd>
           </dl>
         </p>
+        <p class="help-block">
+          Examples:
+<pre><code>console.log($('.main-container'));
+
+window.addEventListener('load', (event) => {
+  console.log('config: ', crowi.config);
+});</code></pre>
+        </p>
 
         <div class="form-group">
           <div class="col-xs-12">

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

@@ -27,7 +27,7 @@
         <div class="comment-form-main">
           <div class="comment-write" id="comment-write">
             <textarea class="comment-form-comment form-control" id="comment-form-comment" name="commentForm[comment]"
-                rows="10" placeholder="Write comments here..." {% if not user %}disabled{% endif %}></textarea>
+                required placeholder="Write comments here..." {% if not user %}disabled{% endif %}></textarea>
           </div>
           <div class="comment-submit">
             <input type="hidden" name="_csrf" value="{{ csrf() }}">

+ 3 - 2
package.json

@@ -83,7 +83,7 @@
     "express-session": "~1.15.0",
     "express-webpack-assets": "^0.1.0",
     "file-loader": "^1.1.0",
-    "googleapis": "^25.0.0",
+    "googleapis": "^26.0.0",
     "graceful-fs": "^4.1.11",
     "i18next": "^10.0.1",
     "i18next-express-middleware": "^1.0.5",
@@ -98,7 +98,7 @@
     "markdown-it-named-headers": "^0.0.4",
     "markdown-it-plantuml": "^0.3.1",
     "markdown-it-task-lists": "^2.1.0",
-    "markdown-it-toc-and-anchor": "^4.1.2",
+    "markdown-it-toc-and-anchor-with-slugid": "^1.1.2",
     "md5": "^2.2.1",
     "method-override": "^2.3.10",
     "mkdirp": "~0.5.1",
@@ -134,6 +134,7 @@
     "toastr": "^2.1.2",
     "uglifycss": "^0.0.27",
     "url-join": "^4.0.0",
+    "uslug": "^1.0.4",
     "webpack": "^3.1.0",
     "webpack-bundle-analyzer": "^2.9.0",
     "webpack-merge": "~4.1.0",

+ 10 - 3
resource/css/_comment_crowi-plus.scss

@@ -90,19 +90,26 @@
   .comment-form {
     position: relative;
     margin-top: 2em;
-    // ユーザーアイコン
+    // user icon
     .picture.picture-rounded {
       @extend %picture-rounded;
     }
 
-    // コメントフォームセクション
+    // seciton
     .comment-form-main {
       @extend %comment-section;
     }
 
-    // コメント入力フォーム
+    // textarea
     .comment-write {
       margin-bottom: 0.5em;
     }
+    .comment-form-comment {
+      height: 80px;
+      &:focus, &:not(:invalid) {
+        transition: height 0.2s ease-out;
+        height: 180px;
+      }
+    }
   }
 }

+ 4 - 2
resource/js/app.js

@@ -137,8 +137,10 @@ if (pageEditorElem) {
   const onSaveSuccess = function(page) {
     // modify the revision id value to pass checking id when updating
     crowi.getCrowiForJquery().updateCurrentRevision(page.revision._id);
-    // re-render Page component
-    componentInstances.page.setMarkdown(page.revision.body);
+    // re-render Page component if exists
+    if (componentInstances.page != null) {
+      componentInstances.page.setMarkdown(page.revision.body);
+    }
   }
 
   pageEditor = ReactDOM.render(

+ 4 - 9
resource/js/util/markdown-it/toc-and-anchor.js

@@ -1,3 +1,5 @@
+import uslug from 'uslug';
+
 export default class TocAndAnchorConfigurer {
 
   constructor(crowi, renderToc) {
@@ -6,13 +8,11 @@ export default class TocAndAnchorConfigurer {
   }
 
   configure(md) {
-    md.use(require('markdown-it-toc-and-anchor').default, {
+    md.use(require('markdown-it-toc-and-anchor-with-slugid').default, {
         anchorLinkBefore: false,
         anchorLinkSymbol: '',
         anchorLinkSymbolClassName: 'fa fa-link',
         anchorClassName: 'revision-head-link',
-      })
-      .use(require('markdown-it-named-headers'), {  // overwrite id defined by markdown-it-toc-and-anchor
         slugify: this.customSlugify,
       })
       ;
@@ -29,14 +29,9 @@ export default class TocAndAnchorConfigurer {
 
   /**
    * create Base64 encoded id
-   * @see https://qiita.com/satokaz/items/64582da4640898c4bf42
    * @param {string} header
    */
   customSlugify(header) {
-    return encodeURIComponent(header.trim()
-      .toLowerCase()
-      .replace(/[\]\[\!\"\#\$\%\&\'\(\)\*\+\,\.\/\:\;\<\=\>\?\@\\\^\_\{\|\}\~]/g, '')
-      .replace(/\s+/g, '-')) // Replace spaces with hyphens
-      .replace(/\-+$/, ''); // Replace trailing hyphen
+    return encodeURIComponent(uslug(header.trim()));
   }
 }

+ 18 - 19
yarn.lock

@@ -300,12 +300,6 @@ async@2.1.4:
   dependencies:
     lodash "^4.14.0"
 
-async@2.6.0, async@^2.1.2, async@^2.1.5, async@^2.3.0:
-  version "2.6.0"
-  resolved "https://registry.yarnpkg.com/async/-/async-2.6.0.tgz#61a29abb6fcc026fea77e56d1c6ec53a795951f4"
-  dependencies:
-    lodash "^4.14.0"
-
 async@^0.9.0:
   version "0.9.2"
   resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d"
@@ -314,6 +308,12 @@ async@^1.5.0:
   version "1.5.2"
   resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"
 
+async@^2.1.2, async@^2.1.5, async@^2.3.0:
+  version "2.6.0"
+  resolved "https://registry.yarnpkg.com/async/-/async-2.6.0.tgz#61a29abb6fcc026fea77e56d1c6ec53a795951f4"
+  dependencies:
+    lodash "^4.14.0"
+
 async@~0.2.6:
   version "0.2.10"
   resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1"
@@ -2649,12 +2649,12 @@ good-listener@^1.2.2:
   dependencies:
     delegate "^3.1.2"
 
-google-auth-library@^1.0.0:
-  version "1.1.0"
-  resolved "https://registry.yarnpkg.com/google-auth-library/-/google-auth-library-1.1.0.tgz#f3e17e8d9f93a0cdd8c78503427cb656be3aa435"
+google-auth-library@^1.1.0:
+  version "1.2.1"
+  resolved "https://registry.yarnpkg.com/google-auth-library/-/google-auth-library-1.2.1.tgz#20eb9d585b1837a703712abdb787da4984982b64"
   dependencies:
     axios "^0.17.1"
-    gtoken "^2.0.2"
+    gtoken "^2.1.0"
     jws "^3.1.4"
     lodash.isstring "^4.0.1"
     lru-cache "^4.1.1"
@@ -2666,12 +2666,11 @@ google-p12-pem@^1.0.0:
     node-forge "^0.7.1"
     pify "^3.0.0"
 
-googleapis@^25.0.0:
-  version "25.0.0"
-  resolved "https://registry.yarnpkg.com/googleapis/-/googleapis-25.0.0.tgz#0f6f48109584e035e266022eb7fdc1a86823da3a"
+googleapis@^26.0.0:
+  version "26.0.1"
+  resolved "https://registry.yarnpkg.com/googleapis/-/googleapis-26.0.1.tgz#e1efb43b00546b1ad8c055a83cf210d5422b7f42"
   dependencies:
-    async "2.6.0"
-    google-auth-library "^1.0.0"
+    google-auth-library "^1.1.0"
     qs "^6.5.1"
     string-template "1.0.0"
     uuid "^3.1.0"
@@ -2688,7 +2687,7 @@ growly@^1.2.0:
   version "1.3.0"
   resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
 
-gtoken@^2.0.2:
+gtoken@^2.1.0:
   version "2.1.0"
   resolved "https://registry.yarnpkg.com/gtoken/-/gtoken-2.1.0.tgz#e65028d32d1d52eeb17b00f85ef0f7484f0fd36f"
   dependencies:
@@ -3693,9 +3692,9 @@ markdown-it-task-lists@^2.1.0:
   version "2.1.0"
   resolved "https://registry.yarnpkg.com/markdown-it-task-lists/-/markdown-it-task-lists-2.1.0.tgz#4594f750f70df053d1dad68024388007c1d20783"
 
-markdown-it-toc-and-anchor@^4.1.2:
-  version "4.1.2"
-  resolved "https://registry.yarnpkg.com/markdown-it-toc-and-anchor/-/markdown-it-toc-and-anchor-4.1.2.tgz#b271f694a70bf719e6b728056d7bd931d364214d"
+markdown-it-toc-and-anchor-with-slugid@^1.1.2:
+  version "1.1.2"
+  resolved "https://registry.yarnpkg.com/markdown-it-toc-and-anchor-with-slugid/-/markdown-it-toc-and-anchor-with-slugid-1.1.2.tgz#14d293ee530891107a13575407ede0376fb3666e"
   dependencies:
     clone "^2.1.0"
     uslug "^1.0.4"