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

rename page-path-utils to path-utils

Yuki Takei 7 лет назад
Родитель
Сommit
9764e923bd

+ 3 - 3
src/client/js/components/PagePathAutoComplete.jsx

@@ -1,7 +1,7 @@
 import React from 'react';
 import React from 'react';
 import PropTypes from 'prop-types';
 import PropTypes from 'prop-types';
 
 
-import * as pagePathUtils from '@commons/util/page-path-utils';
+import * as pathUtils from '@commons/util/path-utils';
 import SearchTypeahead from './SearchTypeahead';
 import SearchTypeahead from './SearchTypeahead';
 
 
 export default class PagePathAutoComplete extends React.Component {
 export default class PagePathAutoComplete extends React.Component {
@@ -35,8 +35,8 @@ export default class PagePathAutoComplete extends React.Component {
 
 
   getKeywordOnInit(path) {
   getKeywordOnInit(path) {
     return this.props.addSlashToTheEnd
     return this.props.addSlashToTheEnd
-      ? pagePathUtils.addSlashToTheEnd(path)
-      : pagePathUtils.removeLastSlash(path);
+      ? pathUtils.addSlashToTheEnd(path)
+      : pathUtils.removeLastSlash(path);
   }
   }
 
 
   render() {
   render() {

+ 2 - 2
src/client/js/legacy/crowi.js

@@ -7,7 +7,7 @@ import ReactDOM from 'react-dom';
 
 
 import { debounce } from 'throttle-debounce';
 import { debounce } from 'throttle-debounce';
 
 
-const pagePathUtils = require('@commons/util/page-path-utils');
+const pathUtils = require('@commons/util/path-utils');
 const entities = require('entities');
 const entities = require('entities');
 const escapeStringRegexp = require('escape-string-regexp');
 const escapeStringRegexp = require('escape-string-regexp');
 require('jquery.cookie');
 require('jquery.cookie');
@@ -343,7 +343,7 @@ $(function() {
     if (name.match(/.+\/$/)) {
     if (name.match(/.+\/$/)) {
       name = name.substr(0, name.length - 1);
       name = name.substr(0, name.length - 1);
     }
     }
-    top.location.href = pagePathUtils.encodePagePath(name) + '#edit';
+    top.location.href = pathUtils.encodePagePath(name) + '#edit';
     return false;
     return false;
   });
   });
 
 

+ 0 - 0
src/lib/util/page-path-utils.js → src/lib/util/path-utils.js


+ 8 - 8
src/server/routes/page.js

@@ -3,7 +3,7 @@ module.exports = function(crowi, app) {
 
 
   const debug = require('debug')('growi:routes:page')
   const debug = require('debug')('growi:routes:page')
     , logger = require('@alias/logger')('growi:routes:page')
     , logger = require('@alias/logger')('growi:routes:page')
-    , pagePathUtils = require('@commons/util/page-path-utils')
+    , pathUtils = require('@commons/util/path-utils')
     , Page = crowi.model('Page')
     , Page = crowi.model('Page')
     , User = crowi.model('User')
     , User = crowi.model('User')
     , Config   = crowi.model('Config')
     , Config   = crowi.model('Config')
@@ -153,7 +153,7 @@ module.exports = function(crowi, app) {
       seener_threshold: SEENER_THRESHOLD,
       seener_threshold: SEENER_THRESHOLD,
     };
     };
     renderVars.pager = generatePager(result.offset, result.limit, result.totalCount);
     renderVars.pager = generatePager(result.offset, result.limit, result.totalCount);
-    renderVars.pages = pagePathUtils.encodePagesPath(result.pages);
+    renderVars.pages = pathUtils.encodePagesPath(result.pages);
   }
   }
 
 
   function replacePlaceholdersOfTemplate(template, req) {
   function replacePlaceholdersOfTemplate(template, req) {
@@ -233,7 +233,7 @@ module.exports = function(crowi, app) {
     }
     }
     else if (page.redirectTo) {
     else if (page.redirectTo) {
       debug(`Redirect to '${page.redirectTo}'`);
       debug(`Redirect to '${page.redirectTo}'`);
-      return res.redirect(encodeURI(page.redirectTo + '?redirectFrom=' + pagePathUtils.encodePagePath(path)));
+      return res.redirect(encodeURI(page.redirectTo + '?redirectFrom=' + pathUtils.encodePagePath(path)));
     }
     }
 
 
     logger.debug('Page is found when processing pageShowForGrowiBehavior', page._id, page.path);
     logger.debug('Page is found when processing pageShowForGrowiBehavior', page._id, page.path);
@@ -334,7 +334,7 @@ module.exports = function(crowi, app) {
 
 
       if (hasPortalPage) {
       if (hasPortalPage) {
         logger.debug('The portal page is found', portalPagePath);
         logger.debug('The portal page is found', portalPagePath);
-        return res.redirect(encodeURI(portalPagePath + '?redirectFrom=' + pagePathUtils.encodePagePath(req.path)));
+        return res.redirect(encodeURI(portalPagePath + '?redirectFrom=' + pathUtils.encodePagePath(req.path)));
       }
       }
     }
     }
 
 
@@ -446,7 +446,7 @@ module.exports = function(crowi, app) {
     }
     }
 
 
     renderVars.pager = generatePager(result.offset, result.limit, result.totalCount);
     renderVars.pager = generatePager(result.offset, result.limit, result.totalCount);
-    renderVars.pages = pagePathUtils.encodePagesPath(result.pages);
+    renderVars.pages = pathUtils.encodePagesPath(result.pages);
     res.render('customlayout-selector/page_list', renderVars);
     res.render('customlayout-selector/page_list', renderVars);
 
 
   };
   };
@@ -460,7 +460,7 @@ module.exports = function(crowi, app) {
     const page = await Page.findByIdAndViewer(id, req.user);
     const page = await Page.findByIdAndViewer(id, req.user);
 
 
     if (page != null) {
     if (page != null) {
-      return res.redirect(pagePathUtils.encodePagePath(page.path));
+      return res.redirect(pathUtils.encodePagePath(page.path));
     }
     }
 
 
     return res.redirect('/');
     return res.redirect('/');
@@ -510,7 +510,7 @@ module.exports = function(crowi, app) {
         result.pages.pop();
         result.pages.pop();
       }
       }
 
 
-      result.pages = pagePathUtils.encodePagesPath(result.pages);
+      result.pages = pathUtils.encodePagesPath(result.pages);
       return res.json(ApiResponse.success(result));
       return res.json(ApiResponse.success(result));
     }
     }
     catch (err) {
     catch (err) {
@@ -1086,7 +1086,7 @@ module.exports = function(crowi, app) {
 
 
     try {
     try {
       let result = await Page.findListByCreator(page.creator, req.user, queryOptions);
       let result = await Page.findListByCreator(page.creator, req.user, queryOptions);
-      result.pages = pagePathUtils.encodePagesPath(result.pages);
+      result.pages = pathUtils.encodePagesPath(result.pages);
 
 
       return res.json(ApiResponse.success(result));
       return res.json(ApiResponse.success(result));
     }
     }