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

Merge branch 'master' into feat/questionnaire

ryoji-s 3 лет назад
Родитель
Сommit
c30f2d575a

+ 1 - 1
packages/app/public/static/locales/en_US/admin.json

@@ -16,7 +16,7 @@
     "Guest Users Access": "Guest users access",
     "always_hidden": "Always hidden",
     "always_displayed": "Always displayed",
-    "displayed_or_hidden": "Displayed / Hidden",
+    "displayed_or_hidden": "Hidden / Displayed",
     "Fixed by env var": "This is fixed by the env var <code>{{key}}={{value}}</code>.",
     "register_limitation": "Register limitation",
     "register_limitation_desc": "Restriction of new users' registration",

+ 1 - 1
packages/app/public/static/locales/ja_JP/admin.json

@@ -24,7 +24,7 @@
     "Guest Users Access":"ゲストユーザーのアクセス",
     "always_hidden": "非表示 (固定)",
     "always_displayed": "表示 (固定)",
-    "displayed_or_hidden": "表示 / 表示",
+    "displayed_or_hidden": "表示 / 表示",
     "Fixed by env var": "環境変数 <code>{{forcewikimode}}={{wikimode}}</code> により固定されています。",
     "register_limitation": "登録の制限",
     "register_limitation_desc": "新しいユーザーを登録する方法を制限します。",

+ 1 - 1
packages/app/public/static/locales/zh_CN/admin.json

@@ -23,7 +23,7 @@
     "set_point": "设定值",
     "always_displayed": "始终显示",
     "always_hidden": "总是隐藏",
-    "displayed_or_hidden": "显示/隐藏",
+    "displayed_or_hidden": "隐藏 / 显示",
     "Guest Users Access": "来宾用户访问",
 		"Fixed by env var": "这是由env var<code>%s=%s</code>修复的。",
 		"register_limitation": "注册限制",

+ 4 - 4
packages/app/src/components/Admin/Security/SecuritySetting.jsx

@@ -347,11 +347,11 @@ class SecuritySetting extends React.Component {
             <tbody>
               <tr>
                 <th scope="row">{ t('public') }</th>
-                <td>{ t('security_settings.always_displayed') }</td>
+                <td><i className="icon-fw icon-check text-success"></i>{ t('security_settings.always_displayed') }</td>
               </tr>
               <tr>
                 <th scope="row">{ t('anyone_with_the_link') }</th>
-                <td>{ t('security_settings.always_hidden') }</td>
+                <td><i className="icon-fw icon-ban text-danger"></i>{ t('security_settings.always_hidden') }</td>
               </tr>
               <tr>
                 <th scope="row">{ t('only_me') }</th>
@@ -361,7 +361,7 @@ class SecuritySetting extends React.Component {
                       type="checkbox"
                       className="custom-control-input"
                       id="isShowRestrictedByOwner"
-                      checked={adminGeneralSecurityContainer.state.isShowRestrictedByOwner}
+                      checked={!adminGeneralSecurityContainer.state.isShowRestrictedByOwner}
                       onChange={() => { adminGeneralSecurityContainer.switchIsShowRestrictedByOwner() }}
                     />
                     <label className="custom-control-label" htmlFor="isShowRestrictedByOwner">
@@ -378,7 +378,7 @@ class SecuritySetting extends React.Component {
                       type="checkbox"
                       className="custom-control-input"
                       id="isShowRestrictedByGroup"
-                      checked={adminGeneralSecurityContainer.state.isShowRestrictedByGroup}
+                      checked={!adminGeneralSecurityContainer.state.isShowRestrictedByGroup}
                       onChange={() => { adminGeneralSecurityContainer.switchIsShowRestrictedByGroup() }}
                     />
                     <label className="custom-control-label" htmlFor="isShowRestrictedByGroup">

+ 4 - 1
packages/app/src/components/InstallerForm.tsx

@@ -2,6 +2,7 @@ import {
   FormEventHandler, memo, useCallback, useState,
 } from 'react';
 
+import { Lang, AllLang } from '@growi/core';
 import { useTranslation } from 'next-i18next';
 import { useRouter } from 'next/router';
 
@@ -15,9 +16,11 @@ const InstallerForm = memo((): JSX.Element => {
 
   const router = useRouter();
 
+  const isSupportedLang = AllLang.includes(i18n.language as Lang);
+
   const [isValidUserName, setValidUserName] = useState(true);
   const [isSubmittingDisabled, setSubmittingDisabled] = useState(false);
-  const [currentLocale, setCurrentLocale] = useState('en_US');
+  const [currentLocale, setCurrentLocale] = useState(isSupportedLang ? i18n.language : Lang.en_US);
 
   const checkUserName = useCallback(async(event) => {
     const axios = require('axios').create({

+ 0 - 1
packages/app/src/interfaces/search.ts

@@ -5,7 +5,6 @@ export type IPageSearchMeta = {
   elasticSearchResult?: {
     snippet?: string | null;
     highlightedPath?: string | null;
-    isHtmlInPath: boolean;
   };
 }
 

+ 8 - 3
packages/app/src/server/service/search-delegator/elasticsearch.ts

@@ -943,12 +943,17 @@ class ElasticsearchDelegator implements SearchDelegator<Data, ESTermsKey, ESQuer
 
   appendHighlight(query) {
     query.body.highlight = {
+      fragmenter: 'simple',
+      pre_tags: ["<em class='highlighted-keyword'>"],
+      post_tags: ['</em>'],
       fields: {
         '*': {
           fragment_size: 40,
-          fragmenter: 'simple',
-          pre_tags: ["<em class='highlighted-keyword'>"],
-          post_tags: ['</em>'],
+        },
+        'path.*': {
+          // No fragments are generated
+          // see: https://www.elastic.co/guide/en/elasticsearch/reference/current/highlighting.html#highlighting-settings
+          number_of_fragments: 0,
         },
       },
     };

+ 2 - 3
packages/app/src/server/service/search.ts

@@ -450,15 +450,14 @@ class SearchService implements SearchQueryParser, SearchResolver {
       const highlightData = data._highlight;
       if (highlightData != null) {
         const snippet = this.canShowSnippet(pageData, user, userGroups)
-          ? highlightData['body.en'] || highlightData['body.ja'] || highlightData['comments.en'] || highlightData['comments.ja']
+          // eslint-disable-next-line max-len
+          ? highlightData.body || highlightData['body.en'] || highlightData['body.ja'] || highlightData.comments || highlightData['comments.en'] || highlightData['comments.ja']
           : null;
         const pathMatch = highlightData['path.en'] || highlightData['path.ja'];
-        const isHtmlInPath = highlightData['path.en'] != null || highlightData['path.ja'] != null;
 
         elasticSearchResult = {
           snippet: snippet != null && typeof snippet[0] === 'string' ? filterXss.process(snippet) : null,
           highlightedPath: pathMatch != null && typeof pathMatch[0] === 'string' ? filterXss.process(pathMatch) : null,
-          isHtmlInPath,
         };
       }
 

+ 10 - 5
packages/remark-lsx/src/server/routes/lsx.js

@@ -104,12 +104,17 @@ class Lsx {
     }
 
     let filterPath = '';
-    if (optionsFilter.charAt(0) === '^') {
-      // move '^' to the first of path
-      filterPath = new RegExp(`^${addTrailingSlash(pagePath)}${optionsFilter.slice(1, optionsFilter.length)}`);
+    try {
+      if (optionsFilter.charAt(0) === '^') {
+        // move '^' to the first of path
+        filterPath = new RegExp(`^${addTrailingSlash(pagePath)}${optionsFilter.slice(1, optionsFilter.length)}`);
+      }
+      else {
+        filterPath = new RegExp(`^${addTrailingSlash(pagePath)}.*${optionsFilter}`);
+      }
     }
-    else {
-      filterPath = new RegExp(`^${addTrailingSlash(pagePath)}.*${optionsFilter}`);
+    catch (err) {
+      throw createError(400, err);
     }
 
     if (isExceptFilter) {