You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by sh...@apache.org on 2024/03/25 07:40:54 UTC
(incubator-answer) branch feat/baseurl updated (eb6dc3e3 -> 7946cea3)
This is an automated email from the ASF dual-hosted git repository.
shuai pushed a change to branch feat/baseurl
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
from eb6dc3e3 fix: add REACT_APP_BASE_URL
new 2c8bcbfd feat: test add basename
new 299c5719 fix: a tag check basename
new 7946cea3 fix: base url
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
ui/package.json | 2 +-
ui/src/components/Header/index.tsx | 49 ++++++++++++----------
ui/src/components/PageTags/index.tsx | 8 +++-
ui/src/components/Share/index.tsx | 5 ++-
ui/src/pages/Admin/Answers/index.tsx | 8 ++--
ui/src/pages/Admin/Questions/index.tsx | 6 +--
.../pages/Install/components/FifthStep/index.tsx | 10 +++--
ui/src/pages/Install/index.tsx | 3 +-
.../Ask/components/SearchQuestion/index.tsx | 5 ++-
ui/src/pages/Questions/EditAnswer/index.tsx | 8 ++--
ui/src/pages/Users/Logout/index.tsx | 4 +-
ui/src/router/alias.ts | 4 ++
ui/src/utils/floppyNavigation.ts | 2 +-
13 files changed, 66 insertions(+), 48 deletions(-)
(incubator-answer) 02/03: fix: a tag check basename
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shuai pushed a commit to branch feat/baseurl
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit 299c57190436a81f1cc98b57153a25246f8d3ade
Author: shuai <li...@sifou.com>
AuthorDate: Fri Mar 22 18:34:46 2024 +0800
fix: a tag check basename
---
ui/src/components/Header/index.tsx | 25 +++++++++++-----------
ui/src/components/PageTags/index.tsx | 8 +++++--
ui/src/pages/Admin/Answers/index.tsx | 8 +++----
ui/src/pages/Admin/Questions/index.tsx | 6 +++---
.../pages/Install/components/FifthStep/index.tsx | 10 ++++++---
.../Ask/components/SearchQuestion/index.tsx | 5 +++--
ui/src/pages/Questions/EditAnswer/index.tsx | 8 +++----
7 files changed, 40 insertions(+), 30 deletions(-)
diff --git a/ui/src/components/Header/index.tsx b/ui/src/components/Header/index.tsx
index b58a36e3..2757f6c1 100644
--- a/ui/src/components/Header/index.tsx
+++ b/ui/src/components/Header/index.tsx
@@ -24,7 +24,6 @@ import {
Nav,
Form,
FormControl,
- Button,
Col,
} from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
@@ -175,24 +174,26 @@ const Header: FC = () => {
/>
) : (
<>
- <Button
- variant="link"
- className={classnames('me-2', {
+ <Link
+ className={classnames('me-2 btn btn-link', {
'link-light': navbarStyle === 'theme-colored',
'link-primary': navbarStyle !== 'theme-colored',
})}
onClick={() => floppyNavigation.storageLoginRedirect()}
- href={userCenter.getLoginUrl()}>
+ to={userCenter.getLoginUrl()}>
{t('btns.login')}
- </Button>
+ </Link>
{loginSetting.allow_new_registrations && (
- <Button
- variant={
- navbarStyle === 'theme-colored' ? 'light' : 'primary'
- }
- href={userCenter.getSignUpUrl()}>
+ <Link
+ className={classnames(
+ 'btn',
+ navbarStyle === 'theme-colored'
+ ? 'btn-light'
+ : 'btn-primary',
+ )}
+ to={userCenter.getSignUpUrl()}>
{t('btns.signup')}
- </Button>
+ </Link>
)}
</>
)}
diff --git a/ui/src/components/PageTags/index.tsx b/ui/src/components/PageTags/index.tsx
index 6bed2125..5d3dd5d7 100644
--- a/ui/src/components/PageTags/index.tsx
+++ b/ui/src/components/PageTags/index.tsx
@@ -20,6 +20,7 @@
import { FC, useEffect, useLayoutEffect } from 'react';
import { Helmet } from 'react-helmet-async';
+import { REACT_BASE_PATH } from '@/router/alias';
import { brandingStore, pageTagStore, siteInfoStore } from '@/stores';
import { getCurrentLang } from '@/utils/localize';
@@ -76,7 +77,7 @@ const Index: FC = () => {
<link
rel="icon"
type="image/png"
- href={favicon || square_icon || '/favicon.ico'}
+ href={favicon || square_icon || `${REACT_BASE_PATH}/favicon.ico`}
/>
<link rel="icon" type="image/png" sizes="192x192" href={square_icon} />
<link rel="apple-touch-icon" type="image/png" href={square_icon} />
@@ -84,7 +85,10 @@ const Index: FC = () => {
{keywords && <meta name="keywords" content={keywords} />}
{description && <meta name="description" content={description} />}
{doInsertCustomCSS && (
- <link rel="stylesheet" href={`${process.env.PUBLIC_URL}/custom.css`} />
+ <link
+ rel="stylesheet"
+ href={`${process.env.PUBLIC_URL}${REACT_BASE_PATH}/custom.css`}
+ />
)}
</Helmet>
);
diff --git a/ui/src/pages/Admin/Answers/index.tsx b/ui/src/pages/Admin/Answers/index.tsx
index 091fe2db..c05aa77e 100644
--- a/ui/src/pages/Admin/Answers/index.tsx
+++ b/ui/src/pages/Admin/Answers/index.tsx
@@ -19,7 +19,7 @@
import { FC } from 'react';
import { Form, Table, Stack } from 'react-bootstrap';
-import { useSearchParams } from 'react-router-dom';
+import { useSearchParams, Link } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import classNames from 'classnames';
@@ -110,8 +110,8 @@ const Answers: FC = () => {
return (
<tr key={li.id}>
<td>
- <a
- href={pathFactory.answerLanding({
+ <Link
+ to={pathFactory.answerLanding({
questionId: li.question_id,
slugTitle: li.question_info.url_title,
answerId: li.id,
@@ -120,7 +120,7 @@ const Answers: FC = () => {
className="text-break text-wrap"
rel="noreferrer">
{li.question_info.title}
- </a>
+ </Link>
{li.accepted === 2 && (
<Icon
name="check-circle-fill"
diff --git a/ui/src/pages/Admin/Questions/index.tsx b/ui/src/pages/Admin/Questions/index.tsx
index 0488a08b..254aeaec 100644
--- a/ui/src/pages/Admin/Questions/index.tsx
+++ b/ui/src/pages/Admin/Questions/index.tsx
@@ -109,13 +109,13 @@ const Questions: FC = () => {
return (
<tr key={li.id}>
<td>
- <a
- href={pathFactory.questionLanding(li.id, li.url_title)}
+ <Link
+ to={pathFactory.questionLanding(li.id, li.url_title)}
target="_blank"
className="text-break text-wrap"
rel="noreferrer">
{li.title}
- </a>
+ </Link>
{li.accepted_answer_id > 0 && (
<Icon
name="check-circle-fill"
diff --git a/ui/src/pages/Install/components/FifthStep/index.tsx b/ui/src/pages/Install/components/FifthStep/index.tsx
index 7a9061f9..4ec99a5c 100644
--- a/ui/src/pages/Install/components/FifthStep/index.tsx
+++ b/ui/src/pages/Install/components/FifthStep/index.tsx
@@ -21,6 +21,7 @@ import { FC } from 'react';
import { Button } from 'react-bootstrap';
import { useTranslation, Trans } from 'react-i18next';
+import { REACT_BASE_PATH } from '@/router/alias';
import Progress from '../Progress';
interface Props {
@@ -37,15 +38,18 @@ const Index: FC<Props> = ({ visible, siteUrl = '' }) => {
<p>
<Trans i18nKey="install.ready_description">
If you ever feel like changing more settings, visit
- <a href={`${siteUrl}/users/login`}> admin section</a>; find it in the
- site menu.
+ <a href={`${siteUrl}${REACT_BASE_PATH}/users/login`}>
+ {' '}
+ admin section
+ </a>
+ ; find it in the site menu.
</Trans>
</p>
<p>{t('good_luck')}</p>
<div className="d-flex align-items-center justify-content-between">
<Progress step={5} />
- <Button href={siteUrl}>{t('done')}</Button>
+ <Button href={`${siteUrl}${REACT_BASE_PATH}`}>{t('done')}</Button>
</div>
</div>
);
diff --git a/ui/src/pages/Questions/Ask/components/SearchQuestion/index.tsx b/ui/src/pages/Questions/Ask/components/SearchQuestion/index.tsx
index 96b2b0ac..0f1f527a 100644
--- a/ui/src/pages/Questions/Ask/components/SearchQuestion/index.tsx
+++ b/ui/src/pages/Questions/Ask/components/SearchQuestion/index.tsx
@@ -20,6 +20,7 @@
import { memo } from 'react';
import { Accordion, ListGroup } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
+import { Link } from 'react-router-dom';
import { Icon } from '@/components';
import { pathFactory } from '@/router/pathFactory';
@@ -45,10 +46,10 @@ const SearchQuestion = ({ similarQuestions }) => {
return (
<ListGroup.Item
action
- as="a"
+ as={Link}
className="link-dark text-wrap text-break"
key={item.id}
- href={pathFactory.questionLanding(item.id, item.url_title)}
+ to={pathFactory.questionLanding(item.id, item.url_title)}
target="_blank">
<span
className={`${
diff --git a/ui/src/pages/Questions/EditAnswer/index.tsx b/ui/src/pages/Questions/EditAnswer/index.tsx
index fbb3e327..a76a7bd0 100644
--- a/ui/src/pages/Questions/EditAnswer/index.tsx
+++ b/ui/src/pages/Questions/EditAnswer/index.tsx
@@ -19,7 +19,7 @@
import React, { useState, useRef, useEffect, useLayoutEffect } from 'react';
import { Row, Col, Form, Button, Card } from 'react-bootstrap';
-import { useParams, useNavigate } from 'react-router-dom';
+import { useParams, useNavigate, Link } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import dayjs from 'dayjs';
@@ -217,12 +217,12 @@ const Index = () => {
<h3 className="mb-4">{t('title')}</h3>
<Row>
<Col className="page-main flex-auto">
- <a
- href={pathFactory.questionLanding(qid, data?.question.url_title)}
+ <Link
+ to={pathFactory.questionLanding(qid, data?.question.url_title)}
target="_blank"
rel="noreferrer">
<h5 className="mb-3">{data?.question.title}</h5>
- </a>
+ </Link>
<div className="question-content-wrap">
<div
(incubator-answer) 01/03: feat: test add basename
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shuai pushed a commit to branch feat/baseurl
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit 2c8bcbfd7b9773ef30e0d605c0b50608d9169f03
Author: shuai <li...@sifou.com>
AuthorDate: Fri Mar 22 15:31:25 2024 +0800
feat: test add basename
---
ui/package.json | 2 +-
ui/src/components/Header/index.tsx | 24 +++++++++++++-----------
ui/src/router/alias.ts | 2 ++
ui/src/utils/floppyNavigation.ts | 2 +-
4 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/ui/package.json b/ui/package.json
index 63a1f85d..e10d6e7c 100644
--- a/ui/package.json
+++ b/ui/package.json
@@ -2,7 +2,7 @@
"name": "answer-static",
"version": "0.1.0",
"private": true,
- "homepage": "/",
+ "homepage": "/test",
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
diff --git a/ui/src/components/Header/index.tsx b/ui/src/components/Header/index.tsx
index 2f31af38..b58a36e3 100644
--- a/ui/src/components/Header/index.tsx
+++ b/ui/src/components/Header/index.tsx
@@ -249,24 +249,26 @@ const Header: FC = () => {
</Nav>
) : (
<>
- <Button
- variant="link"
- className={classnames('me-2', {
+ <Link
+ className={classnames('me-2 btn btn-link', {
'link-light': navbarStyle === 'theme-colored',
'link-primary': navbarStyle !== 'theme-colored',
})}
onClick={() => floppyNavigation.storageLoginRedirect()}
- href={userCenter.getLoginUrl()}>
+ to={userCenter.getLoginUrl()}>
{t('btns.login')}
- </Button>
+ </Link>
{loginSetting.allow_new_registrations && (
- <Button
- variant={
- navbarStyle === 'theme-colored' ? 'light' : 'primary'
- }
- href={userCenter.getSignUpUrl()}>
+ <Link
+ className={classnames(
+ 'btn',
+ navbarStyle === 'theme-colored'
+ ? 'btn-light'
+ : 'btn-primary',
+ )}
+ to={userCenter.getSignUpUrl()}>
{t('btns.signup')}
- </Button>
+ </Link>
)}
</>
)}
diff --git a/ui/src/router/alias.ts b/ui/src/router/alias.ts
index 5a155969..050f6c74 100644
--- a/ui/src/router/alias.ts
+++ b/ui/src/router/alias.ts
@@ -17,6 +17,8 @@
* under the License.
*/
+export const REACT_BASE_PATH = process.env.REACT_APP_BASE_URL || '';
+
export const RouteAlias = {
home: '/',
login: '/users/login',
diff --git a/ui/src/utils/floppyNavigation.ts b/ui/src/utils/floppyNavigation.ts
index 45758b31..308d2fac 100644
--- a/ui/src/utils/floppyNavigation.ts
+++ b/ui/src/utils/floppyNavigation.ts
@@ -137,7 +137,7 @@ const navigate = (to: string | number, config: NavigateConfig = {}) => {
} else if (handler === 'replace') {
window.location.replace(to);
} else if (typeof handler === 'function') {
- handler(to, config.options);
+ handler(to === '/test' ? '/' : to, config.options);
}
}
if (typeof to === 'number' && typeof handler === 'function') {
(incubator-answer) 03/03: fix: base url
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shuai pushed a commit to branch feat/baseurl
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit 7946cea31d6efb5adb64bc9c3b32b814387b58bf
Author: shuai <li...@sifou.com>
AuthorDate: Mon Mar 25 15:40:43 2024 +0800
fix: base url
---
ui/src/components/Share/index.tsx | 5 +++--
ui/src/pages/Install/index.tsx | 3 ++-
ui/src/pages/Users/Logout/index.tsx | 4 ++--
ui/src/router/alias.ts | 2 ++
4 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/ui/src/components/Share/index.tsx b/ui/src/components/Share/index.tsx
index 0cd46f36..203a72d6 100644
--- a/ui/src/components/Share/index.tsx
+++ b/ui/src/components/Share/index.tsx
@@ -24,6 +24,7 @@ import { useTranslation } from 'react-i18next';
import { FacebookShareButton, TwitterShareButton } from 'next-share';
import copy from 'copy-to-clipboard';
+import { BASE_ORIGIN } from '@/router/alias';
import { loggedUserInfoStore } from '@/stores';
interface IProps {
@@ -42,8 +43,8 @@ const Index: FC<IProps> = ({ type, qid, aid, title }) => {
const { t } = useTranslation();
let baseUrl =
type === 'question'
- ? `${window.location.origin}/questions/${qid}`
- : `${window.location.origin}/questions/${qid}/${aid}`;
+ ? `${BASE_ORIGIN}/questions/${qid}`
+ : `${BASE_ORIGIN}/questions/${qid}/${aid}`;
if (user.id) {
baseUrl = `${baseUrl}?shareUserId=${user.username}`;
}
diff --git a/ui/src/pages/Install/index.tsx b/ui/src/pages/Install/index.tsx
index 69723d29..39d24d09 100644
--- a/ui/src/pages/Install/index.tsx
+++ b/ui/src/pages/Install/index.tsx
@@ -31,6 +31,7 @@ import {
} from '@/services';
import { Storage, handleFormError, scrollToDocTop } from '@/utils';
import { CURRENT_LANG_STORAGE_KEY } from '@/common/constants';
+import { BASE_ORIGIN } from '@/router/alias';
import {
FirstStep,
@@ -94,7 +95,7 @@ const Index: FC = () => {
errorMsg: '',
},
site_url: {
- value: window.location.origin,
+ value: BASE_ORIGIN,
isInvalid: false,
errorMsg: '',
},
diff --git a/ui/src/pages/Users/Logout/index.tsx b/ui/src/pages/Users/Logout/index.tsx
index 9da6e59d..5561c16f 100644
--- a/ui/src/pages/Users/Logout/index.tsx
+++ b/ui/src/pages/Users/Logout/index.tsx
@@ -25,7 +25,7 @@ import { usePageTags } from '@/hooks';
import { logout } from '@/services';
import { loggedUserInfoStore } from '@/stores';
import Storage from '@/utils/storage';
-import { RouteAlias } from '@/router/alias';
+import { RouteAlias, BASE_ORIGIN } from '@/router/alias';
import { REDIRECT_PATH_STORAGE_KEY } from '@/common/constants';
const Index = () => {
@@ -43,7 +43,7 @@ const Index = () => {
const redirect =
Storage.get(REDIRECT_PATH_STORAGE_KEY) || RouteAlias.home;
Storage.remove(REDIRECT_PATH_STORAGE_KEY);
- window.location.replace(`${window.location.origin}${redirect}`);
+ window.location.replace(`${BASE_ORIGIN}${redirect}`);
});
}
// auto height of container
diff --git a/ui/src/router/alias.ts b/ui/src/router/alias.ts
index 050f6c74..5f765b22 100644
--- a/ui/src/router/alias.ts
+++ b/ui/src/router/alias.ts
@@ -19,6 +19,8 @@
export const REACT_BASE_PATH = process.env.REACT_APP_BASE_URL || '';
+export const BASE_ORIGIN = `${window.location.origin}${REACT_BASE_PATH}`;
+
export const RouteAlias = {
home: '/',
login: '/users/login',