Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix path router #3592

Open
wants to merge 116 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
3e22a58
added prefixPath for site
giuliaghisini May 12, 2022
a6cf32e
handle prefixPath in api requests
giuliaghisini May 13, 2022
a523fa7
added Image component to handle prefixPath in images
giuliaghisini May 13, 2022
30d2638
fixed prefix path in page head
giuliaghisini May 13, 2022
0be7e30
handle prefixPath in chunkExtractor
giuliaghisini May 13, 2022
ab146ac
fixed publickPath in ChunkExtractor with prefixPath
giuliaghisini May 13, 2022
cb21196
added namespace to chunkextractor
giuliaghisini May 13, 2022
4c35003
fix static paths in razzle
cekk May 13, 2022
67452b7
handle static resources with prefix path
giuliaghisini May 16, 2022
c485e5f
fix: fix empty values
giuliaghisini May 20, 2022
9505e56
fix: fix flattenHTMLtoAppUrl to handle prefixPath
giuliaghisini May 27, 2022
f2f908e
feat: added addPrefixPath util to handle static resources
giuliaghisini Aug 11, 2022
c284ec5
Update APIResourceWithAuth.js
giuliaghisini Aug 30, 2022
97f3f9c
Update Api.js
giuliaghisini Aug 30, 2022
f37a938
fix: fix linter
giuliaghisini Aug 31, 2022
76f0f33
fix: image and file views
pnicolli Sep 2, 2022
ed28182
fix: image and file views
pnicolli Sep 2, 2022
57537bb
fix: back to using simple <a> tag for ImageView
pnicolli Sep 5, 2022
4a6f184
readded tests inadvertently removed
mamico Sep 10, 2022
dfdd13f
fix tests
mamico Sep 11, 2022
e38bccc
fix tests
mamico Sep 11, 2022
cf7d2ae
fix(warning): StyleMenu dropdown item to use data-attr instead of cus…
nileshgulia1 Nov 9, 2022
3be3238
add prefix-path express-middleware
nileshgulia1 Dec 8, 2022
1ceb872
Put prefixPath in config.devServer.devMiddleware.publicPath
wesleybl Jul 4, 2023
d6f8bab
Add cypress to prefix path router (#3719)
sneridagh Jul 12, 2023
7f435b0
Avoid /my-prefix from being redirected to /my-prefix/
wesleybl Jul 12, 2023
aa7ef2b
Merge branch 'master' into prefix_path_router
nileshgulia1 Jul 18, 2023
30a9799
Merge branch 'main' into prefix_path_router
nileshgulia1 Nov 17, 2023
63c7858
Merge branch 'main' into prefix_path_router
nileshgulia1 Nov 17, 2023
035bc59
Merge branch 'main' into prefix_path_router
claudiaifrim Nov 17, 2023
392bdfd
Merge branch 'main' into prefix_path_router
nileshgulia1 Nov 20, 2023
9af9eb8
tests: update snapshots
nileshgulia1 Nov 20, 2023
e201fc3
fix(tests): remove duplicate testing-library import
nileshgulia1 Nov 20, 2023
3089740
tests: fix assertion on img src
nileshgulia1 Nov 20, 2023
7037193
tests: more fixes
nileshgulia1 Nov 20, 2023
1b4baa6
tests: intercept prefix calls
nileshgulia1 Nov 21, 2023
cc13733
tests: bring back multilingual cypress suite
nileshgulia1 Nov 22, 2023
88d8ed4
Merge branch 'main' into prefix_path_router
nileshgulia1 Nov 22, 2023
bbf84cb
fix: remove unneeded code
nileshgulia1 Nov 25, 2023
3ad97df
fix: use asyncPropExtenders for /controlpanel route when prefixed
nileshgulia1 Nov 26, 2023
6b3e876
Merge branch 'main' into prefix_path_router
nileshgulia1 Nov 27, 2023
b964d97
fix: test-setup config
nileshgulia1 Nov 27, 2023
b8d8413
fix(test): controlpanels.test.jsx
nileshgulia1 Nov 27, 2023
40e5379
Merge branch 'main' into prefix_path_router
nileshgulia1 Nov 28, 2023
db1fe08
refactor: use `addPrefixPath` helper in Image src
nileshgulia1 Nov 28, 2023
ef6216a
refactor: prettify components
nileshgulia1 Nov 28, 2023
21162d3
Merge branch 'main' into prefix_path_router
nileshgulia1 Dec 18, 2023
14de201
fix(CI): use pnpm
nileshgulia1 Dec 18, 2023
e8b3859
fix(CI): run cypress in packages/volto, update changelog
nileshgulia1 Dec 19, 2023
04dc8aa
fix: update prefix-tests
nileshgulia1 Dec 19, 2023
ecd601d
refactor: shift acceptance tests in packages/volto MAKEFILE
nileshgulia1 Dec 19, 2023
0b5bff7
ref:point to internal makefile tests
nileshgulia1 Dec 19, 2023
260cfcd
update acceptance.yml
nileshgulia1 Dec 19, 2023
f3dd2b5
fix: force yarn to vanish completely
nileshgulia1 Dec 19, 2023
1c676ff
update makefile
nileshgulia1 Dec 19, 2023
cfb5a73
fix: move changelog to correct folder
nileshgulia1 Dec 19, 2023
000f503
delete dangling one
nileshgulia1 Dec 19, 2023
76008a6
chore: amend volto-slate changelog
nileshgulia1 Dec 19, 2023
39c1e4a
Merge branch 'main' into prefix_path_router
claudiaifrim Jan 19, 2024
22749f9
Merge branch 'main' into prefix_path_router
claudiaifrim Jan 25, 2024
1b78ad5
Merge branch 'main' into prefix_path_router
nileshgulia1 Jan 29, 2024
fc56c8e
feat: add multilingual prefixed tests
nileshgulia1 Jan 29, 2024
73a3dab
Merge branch 'main' into prefix_path_router
nileshgulia1 Jan 31, 2024
ca6004e
Merge branch 'main' into prefix_path_router
nileshgulia1 Feb 12, 2024
3f3e81f
fix workflow multilingualprefix
nileshgulia1 Feb 12, 2024
ea9c14b
Merge branch 'main' into prefix_path_router
nileshgulia1 Feb 13, 2024
caae9ab
Merge branch 'main' into prefix_path_router
nileshgulia1 Feb 14, 2024
a06a91c
Merge branch 'main' into prefix_path_router
claudiaifrim Feb 22, 2024
735090c
Merge branch 'main' into prefix_path_router
wesleybl Feb 27, 2024
aa0c72b
Merge remote-tracking branch 'origin/main' into prefix_path_router
wesleybl Mar 6, 2024
3938b21
Acceptance tests of prefixed site in Node 20.x
wesleybl Mar 6, 2024
b07f431
Update github actions versions
wesleybl Mar 6, 2024
3a10d4a
Force install Cypress
wesleybl Mar 6, 2024
562e01e
Restore condition to install Cypress
wesleybl Mar 6, 2024
c50341b
Fix cache key
wesleybl Mar 7, 2024
61d96d2
Use addPrefixPath in Logo component
wesleybl Mar 7, 2024
c793816
Use addPrefixPath in image scales
wesleybl Mar 8, 2024
48554df
Merge branch 'main' into prefix_path_router
wesleybl Mar 8, 2024
294a090
Merge branch 'main' into prefix_path_router
nileshgulia1 Mar 11, 2024
ad3a147
Merge branch 'main' into prefix_path_router
wesleybl Mar 13, 2024
8d8edf3
Merge branch 'main' into prefix_path_router
wesleybl Mar 14, 2024
9a6b25f
Remove use asyncPropExtenders for /controlpanel route when prefixed
wesleybl Mar 14, 2024
149c899
Add routes with prefix path
wesleybl Mar 15, 2024
e32637b
Test core basic with prefixed site
wesleybl Mar 14, 2024
5eddf39
Test core content with prefixed site
wesleybl Mar 15, 2024
8cf3b05
Test core control panels with prefixed site
wesleybl Mar 15, 2024
5ce2e94
Test core blocks with prefixed site
wesleybl Mar 15, 2024
a59a704
Add prefix to the URL of Image Gallery images
wesleybl Mar 18, 2024
2944946
Pass the prefixPath environment variable to the test-acceptance-prefixed
wesleybl Mar 18, 2024
235e4c5
Test core blocks listing with prefixed site
wesleybl Mar 15, 2024
38e428c
Test core volto slate with prefixed site
wesleybl Mar 18, 2024
1e2620e
Merge branch 'main' into prefix_path_router
wesleybl Mar 18, 2024
f3a51a4
Merge branch 'main' into prefix_path_router
nileshgulia1 May 13, 2024
433ad1c
fix: use prefix in flattenToAppUrl, keep assets intact in dev
nileshgulia1 May 16, 2024
dd553b8
remove: addprefixPath helper
nileshgulia1 May 16, 2024
d66b0ac
fix: client and server warnings
nileshgulia1 May 16, 2024
a38dda0
Merge branch 'main' into prefix_path_router
nileshgulia1 May 16, 2024
0afb5c7
Merge branch 'main' into prefix_path_router
sneridagh Jun 7, 2024
b220146
Merge remote-tracking branch 'origin/main' into prefix_path_router
wesleybl Jul 8, 2024
699dfb1
Update pnpm-lock.yaml with main
wesleybl Jul 8, 2024
e8b69cf
Rename Makefile targets
wesleybl Jul 10, 2024
d1263ee
Merge branch 'main' into prefix_path_router
nileshgulia1 Jul 11, 2024
c2ae5a4
Does not add prefix in the flattenToAppURL function
wesleybl Jul 12, 2024
223cf17
Create function addPrefixPath
wesleybl Jul 15, 2024
0d357e1
Uses addPrefixPath where it is not possible to use the Link and
wesleybl Jul 15, 2024
453bdbc
Merge branch 'main' into prefix_path_router
wesleybl Jul 24, 2024
7efbd7f
Merge branch 'main' into prefix_path_router
wesleybl Jul 26, 2024
9e4712e
Merge branch 'main' into prefix_path_router
wesleybl Jul 30, 2024
06f3e1f
Allows use of RAZZLE PREFIX PATH variable in development mode
wesleybl Jul 30, 2024
e6ea8aa
Merge branch 'main' into prefix_path_router
wesleybl Oct 29, 2024
2b59a49
Uses actions/upload-artifact v4
wesleybl Oct 29, 2024
3856b7c
Updates configuration of prefixed acceptance tests
wesleybl Oct 29, 2024
5e90e60
Use `docker compose` in deployment-prefixed-acceptance-web-server-start
wesleybl Oct 29, 2024
e8889fe
Fixes prefixed workingcopy tests
wesleybl Oct 30, 2024
ccc0b0e
Allows use of RAZZLE_PREFIX_PATH variable in development mode
wesleybl Nov 4, 2024
01148eb
Does not avoid redirect /prefix -> prefix/
wesleybl Nov 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added Image component to handle prefixPath in images
  • Loading branch information
giuliaghisini authored and wesleybl committed Jul 12, 2023
commit a523fa72ad01d932bc49c43c0f8ab00501bf82bf
1 change: 1 addition & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ export RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
export SkipLinks from '@plone/volto/components/theme/SkipLinks/SkipLinks';
export EventDetails from '@plone/volto/components/theme/EventDetails/EventDetails';
export PreviewImage from '@plone/volto/components/theme/PreviewImage/PreviewImage';
export Image from '@plone/volto/components/theme/Image/Image';

export Error from '@plone/volto/components/theme/Error/Error';
export ErrorBoundary from '@plone/volto/components/theme/Error/ErrorBoundary';
4 changes: 2 additions & 2 deletions src/components/manage/Blocks/HeroImageLeft/Edit.jsx
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ import {
validateFileUploadSize,
} from '@plone/volto/helpers';
import { createContent } from '@plone/volto/actions';
import { Icon, SidebarPortal, LinkMore } from '@plone/volto/components';
import { Icon, SidebarPortal, LinkMore, Image } from '@plone/volto/components';

import clearSVG from '@plone/volto/icons/clear.svg';

@@ -341,7 +341,7 @@ class EditComponent extends Component {
)}
<div className="block-inner-wrapper">
{this.props.data.url ? (
<img
<Image
className="hero-image"
src={`${flattenToAppURL(this.props.data.url)}/@@images/image`}
alt=""
4 changes: 2 additions & 2 deletions src/components/manage/Blocks/HeroImageLeft/View.jsx
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { flattenToAppURL } from '@plone/volto/helpers';
import { LinkMore } from '@plone/volto/components';
import { LinkMore, Image } from '@plone/volto/components';

/**
* View image block class.
@@ -17,7 +17,7 @@ const View = ({ data }) => (
<div className="block hero">
<div className="block-inner-wrapper">
{data.url && (
<img
<Image
src={`${flattenToAppURL(data.url)}/@@images/image`}
alt=""
className="hero-image"
9 changes: 7 additions & 2 deletions src/components/manage/Blocks/Image/Edit.jsx
Original file line number Diff line number Diff line change
@@ -14,7 +14,12 @@ import loadable from '@loadable/component';
import cx from 'classnames';
import { isEqual } from 'lodash';

import { Icon, ImageSidebar, SidebarPortal } from '@plone/volto/components';
import {
Icon,
ImageSidebar,
SidebarPortal,
Image,
} from '@plone/volto/components';
import { withBlockExtensions } from '@plone/volto/helpers';
import { createContent } from '@plone/volto/actions';
import {
@@ -255,7 +260,7 @@ class Edit extends Component {
)}
>
{data.url ? (
<img
<Image
className={cx({
'full-width': data.align === 'full',
large: data.size === 'l',
4 changes: 2 additions & 2 deletions src/components/manage/Blocks/Image/ImageSidebar.jsx
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Segment } from 'semantic-ui-react';
import { useIntl, FormattedMessage } from 'react-intl';
import { BlockDataForm, Icon } from '@plone/volto/components';
import { BlockDataForm, Icon, Image } from '@plone/volto/components';
import { isInternalURL, flattenToAppURL } from '@plone/volto/helpers';
import { ImageSchema } from './schema';
import imageSVG from '@plone/volto/icons/image.svg';
@@ -24,7 +24,7 @@ const ImageSidebar = (props) => {
<>
{data.url.split('/').slice(-1)[0]}
{isInternalURL(data.url) && (
<img
<Image
src={`${flattenToAppURL(data.url)}/@@images/image/mini`}
alt={data.alt}
/>
4 changes: 2 additions & 2 deletions src/components/manage/Blocks/Image/View.jsx
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@

import React from 'react';
import PropTypes from 'prop-types';
import { UniversalLink } from '@plone/volto/components';
import { UniversalLink, Image } from '@plone/volto/components';
import cx from 'classnames';
import { withBlockExtensions } from '@plone/volto/helpers';
import { flattenToAppURL, isInternalURL } from '@plone/volto/helpers';
@@ -32,7 +32,7 @@ export const View = ({ data, detached }) => {
<>
{(() => {
const image = (
<img
<Image
className={cx({
'full-width': data.align === 'full',
large: data.size === 'l',
9 changes: 7 additions & 2 deletions src/components/manage/Blocks/LeadImage/Edit.jsx
Original file line number Diff line number Diff line change
@@ -11,7 +11,11 @@ import cx from 'classnames';
import { Message } from 'semantic-ui-react';
import { isEqual } from 'lodash';

import { LeadImageSidebar, SidebarPortal } from '@plone/volto/components';
import {
LeadImageSidebar,
SidebarPortal,
Image,
} from '@plone/volto/components';
import { flattenToAppURL } from '@plone/volto/helpers';

import imageBlockSVG from '@plone/volto/components/manage/Blocks/Image/block-image.svg';
@@ -103,7 +107,7 @@ class Edit extends Component {
</Message>
)}
{properties.image && (
<img
<Image
className={cx({ 'full-width': data.align === 'full' })}
src={
properties.image.data
@@ -113,6 +117,7 @@ class Edit extends Component {
alt={data.image_caption || ''}
/>
)}

<SidebarPortal selected={this.props.selected}>
<LeadImageSidebar {...this.props} />
</SidebarPortal>
9 changes: 7 additions & 2 deletions src/components/manage/Blocks/LeadImage/LeadImageSidebar.jsx
Original file line number Diff line number Diff line change
@@ -3,7 +3,12 @@ import PropTypes from 'prop-types';
import { Form } from 'semantic-ui-react';
import { Accordion, Grid, Segment } from 'semantic-ui-react';
import { defineMessages, FormattedMessage, injectIntl } from 'react-intl';
import { CheckboxWidget, Icon, TextWidget } from '@plone/volto/components';
import {
CheckboxWidget,
Icon,
TextWidget,
Image,
} from '@plone/volto/components';
import { flattenToAppURL } from '@plone/volto/helpers';
import AlignBlock from '@plone/volto/components/manage/Sidebar/AlignBlock';

@@ -90,7 +95,7 @@ const LeadImageSidebar = ({
<>
<Segment className="sidebar-metadata-container" secondary>
{properties.image.filename}
<img
<Image
src={
properties.image.data
? `data:${properties.image['content-type']};base64,${properties.image.data}`
4 changes: 2 additions & 2 deletions src/components/manage/Blocks/LeadImage/View.jsx
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@

import React from 'react';
import PropTypes from 'prop-types';
import { UniversalLink } from '@plone/volto/components';
import { UniversalLink, Image } from '@plone/volto/components';
import cx from 'classnames';

import { flattenToAppURL } from '@plone/volto/helpers';
@@ -29,7 +29,7 @@ const View = ({ data, properties }) => (
<>
{(() => {
const image = (
<img
<Image
className={cx({ 'full-width': data.align === 'full' })}
src={flattenToAppURL(properties.image.download)}
alt={properties.image_caption || ''}
4 changes: 2 additions & 2 deletions src/components/manage/Toolbar/PersonalTools.jsx
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import { Link } from 'react-router-dom';
import jwtDecode from 'jwt-decode';
import cx from 'classnames';
import { FormattedMessage, injectIntl, defineMessages } from 'react-intl';
import { Icon } from '@plone/volto/components';
import { Icon, Image } from '@plone/volto/components';
import { getUser } from '@plone/volto/actions';
import { Pluggable } from '@plone/volto/components/manage/Pluggable';
import {
@@ -134,7 +134,7 @@ class PersonalTools extends Component {
</header>
<div className={cx('avatar', { default: !this.props.user.portrait })}>
{this.props.user.portrait ? (
<img
<Image
src={flattenToAppURL(this.props.user.portrait)}
alt={this.props.intl.formatMessage(messages.userAvatar)}
/>
3 changes: 2 additions & 1 deletion src/components/theme/Avatar/Avatar.jsx
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { getInitials } from '@plone/volto/helpers';
import { Image } from '@plone/volto/components';

const defaultSize = 30;
const defaultColor = 'Teal';
@@ -15,7 +16,7 @@ const Avatar = ({ src, title, text, size, color, className }) => {
return (
<div className={className} title={title}>
{src ? (
<img src={src} alt={title}></img>
<Image src={src} alt={title} />
) : (
<svg width={size} height={size}>
<circle cx={radius} cy={radius} r={radius} fill={color} />
21 changes: 21 additions & 0 deletions src/components/theme/Image/Image.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
WARNING!
This componente renders images taking care of prefixPath.
It needs merge and refactor when this https://github.com/plone/volto/pull/3337 pr will be merged,
and <source srcSet={srcSet} /> needs to handle prefixPath.
*/
import React from 'react';
import { isInternalURL } from '@plone/volto/helpers';
import config from '@plone/volto/registry';

const Image = (props) => {
const { src, alt = '', ...rest } = props;
let url = src;
if (isInternalURL(src)) {
url = (config.settings.prefixPath ?? '') + src; //add prefixPath to src if it's an internal url
}

return <img src={url} {...rest} alt={alt} />;
};

export default Image;
3 changes: 2 additions & 1 deletion src/components/theme/PreviewImage/PreviewImage.jsx
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';

import { flattenToAppURL } from '@plone/volto/helpers';
import { Image } from '@plone/volto/components';
import config from '@plone/volto/registry';

import DefaultImageSVG from '@plone/volto/components/manage/Blocks/Listing/default-image.svg';
@@ -19,7 +20,7 @@ function PreviewImage(props) {
dependencies: ['listing', 'summary'],
}).component || DefaultImageSVG;

return <img src={src} alt={alt ?? item.title} {...rest} />;
return <Image src={src} alt={alt ?? item.title} {...rest} />;
}

PreviewImage.propTypes = {
3 changes: 2 additions & 1 deletion src/components/theme/View/ImageView.jsx
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ import { FormattedMessage } from 'react-intl';
import prettybytes from 'pretty-bytes';
import { flattenToAppURL } from '@plone/volto/helpers';
import config from '@plone/volto/registry';
import { Image } from '@plone/volto/components';

/**
* Image view component class.
@@ -32,7 +33,7 @@ const ImageView = ({ content }) => {
)}
{content?.image?.download && (
<a href={flattenToAppURL(content.image.download)}>
<img
<Image
alt={content.title}
src={flattenToAppURL(content.image.scales.preview.download)}
/>
3 changes: 2 additions & 1 deletion src/config/RichTextEditor/ToHTML.jsx
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ import React from 'react';
import { connect } from 'react-redux';
import { isEmpty } from 'lodash';
import UniversalLink from '@plone/volto/components/manage/UniversalLink/UniversalLink';
import { Image } from '@plone/volto/components';

const styles = {
code: {
@@ -242,7 +243,7 @@ const entities = {
),

IMAGE: (children, entity, { key }) => (
<img key={key} src={entity.src} alt={entity.alt} />
<Image key={key} src={entity.src} alt={entity.alt} />
),
};