Skip to content

Commit

Permalink
Merge branch 'main' into feature/savedprops
Browse files Browse the repository at this point in the history
  • Loading branch information
kailasnadh790 committed Jun 5, 2024
2 parents e348b5f + eb45666 commit 0c6df17
Show file tree
Hide file tree
Showing 20 changed files with 576 additions and 91 deletions.
93 changes: 93 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,96 @@ npm run lint
1. Install the [AEM CLI](https://github.com/adobe/aem-cli): `npm install -g @adobe/aem-cli`
1. Start AEM Proxy: `aem up` (opens your browser at `http://localhost:3000`)
1. Open the `{repo}` directory in your favorite IDE and start coding :)


### Local Proxy for APIs
There are numerous APIs that this site relies on, including but not limited to:

* Account (login, profile, etc)
* Blog
* Properties (search, listing, etc)
* Agent (details, search)
* Suggestions

All of these APIs are hosted on an AMS system. To make use of them locally, a proxy is needed.

There are two ways to set up the local proxy:

* [Real Domain Proxy](#real-domain-proxy)
* Less configuration, but must be aware when proxy is/isn't running.
* [Local Proxy to Remote](#local-proxy-to-remote)
* More configuration, but explicit domain for proxy - clear delineation of live and proxied traffic.

Either way, you need to download and install a local proxy. These instructions use [Proxyman](https://proxyman.io/download). Once you download and install Proxyman, you will need to also install the Proxyman CA certs. These are needed to be able to route the secure traffic.


#### Real Domain Proxy

In this setup, the proxy is configured to route non-API traffic on the Staging domain to your local computer. So all requests _except_ the APIs will go the local host. The API calls will remain routed to the Stage domain.

1. Create a new Allow List entry:
* _Tools_ => _Allow List_
* Name: `BHHS Stage`
* Rule: `https://stage.commonmoves.com*`
* Any, Use Wildcard
* Include all subpaths of this URL: Checked

1. Create a new Map Remote Entry:
* _Tools_ => _Map Remote_
* Matching Rule:
* Name: `BHHS API`
* Rule: `https://stage.commonmoves.com(?!(/bin|/content)).*`
* Any, Use Regex
* Include all subpaths of this URL: Checked
* Map To:
* Protocol: `http`
* Host: localhost
* Port: 3000



#### Local Proxy to Remote

This setup uses a locally resolved domain, which will Proxyman will use to route the traffic. All non-API traffic will route to localhost, all API traffic will go to the Stage domain.

1. Add an entry to `/etc/maps`:
Proxyman won't proxy localhost, so a custom domain is required. Add the following (if you already have a host entry for 127.0.0.1, simply add the new domain)
> 127.0.0.1 proxyman.debug
2. Create a self-signed cert. This is necessary for the AEM Cli to so that cookies can be persisted. It really doesn't matter what you answer for the questions. Just make sure you do not create the certs in the code repo, or add them to Git.

(`/some/path` is used as a reference here, find an appropriate spot on your local computer)

```
$ cd /some/path
$ openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout localhost.key -out localhost.crt
```

3. Create a new Allow List entry:
* _Tools_ => _Allow List_
* Name: *Localhost*
* Matching Rule `https:\/\/proxyman\.debug:\d+.*`
* Any, Use Regex
* Include all subpaths of this URL: checked

4. Create a new Map Remote Entry:
* _Tools_ => _Map Remote_
* Matching Rule
* Name: *BHHS API*
* Rule: `https://proxyman.debug:\d+(/bin|/content).*`
* Any, Use Regex
* Include all subpaths of this URL: checked
* Map To
* Protocol: `https`
* Host: `stage.commonmoves.com`
* Port: `443`

5. Staring the AEM local proxy requires also passing in the Cert info, to run using https:

(`/some/path` is the same place you previously created the cert)

```
% aem up --tls-cert /some/path/localhost.crt --tls-key /some/path/localhost.key
```

To view Proxied site use: https://proxyman.debug:3000/
101 changes: 101 additions & 0 deletions blocks/agent-about/agent-about.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
.agent-about.block {
display: flex;
flex-direction: column;
margin-top: 3rem;
line-height: var(--line-height-m);
font-size: var(--body-font-size-xs);
letter-spacing: normal;
}

.agent-about.block a {
cursor: pointer;
}

.agent-about.block .hide {
display: none;
}

.agent-about.block a.view-more::after,
.agent-about.block a.view-less::after {
display: inline-block;
margin-top: 1rem;
text-decoration: underline;
}

.agent-about.block a.view-more::after {
content: "View More";
}

.agent-about.block a.view-less::after {
content: "View Less";
}

.agent-about.block>div.cols-1,
.agent-about.block>div.cols-2,
.agent-about.block>div.cols-3 {
padding-bottom: 1rem;
}

.agent-about.block>div>div:first-of-type {
font-size: var(--body-font-size-s);
font-weight: var(--font-weight-bold);
margin-bottom: 0.5rem;
text-transform: capitalize;
}

.agent-about.block ul {
list-style: unset;
margin: 0 0 0 1.25rem;
}

@media (min-width: 600px) {
.agent-about.block {
flex-direction: row;
}

.agent-about.block>div.cols-1 {
flex: 0 0 41.6667%;
max-width: 41.6667%;
padding-right: 1rem;
}

.agent-about.block>div.cols-2 {
flex: 0 0 33.33%;
max-width: 33.33%;
padding-left: 1rem;
padding-right: 1rem;
}

.agent-about.block>div.cols-3 {
flex: 0 0 25%;
max-width: 25%;
padding-left: 1rem;
padding-right: 1rem;
}
}

@media (min-width: 900px) {
.agent-about.block>div.cols-1 {
flex: 0 0 50%;
max-width: 50%;
}

.agent-about.block>div.cols-2,
.agent-about.block>div.cols-3 {
flex: 0 0 25%;
max-width: 25%;
}

.agent-about.block {
font-size: var(--body-font-size-s);
}

.agent-about.block>div>div:first-of-type {
font-size: var(--body-font-size-m);
}

.agent-about.block a.view-more::after,
.agent-about.block a.view-less::after {
font-size: var(--body-font-size-s);
}
}
61 changes: 61 additions & 0 deletions blocks/agent-about/agent-about.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import {
a, div, ul, li,
} from '../../scripts/dom-helpers.js';

const viewMoreOnClick = (name, anchor, block) => {
anchor.addEventListener('click', () => {
if (anchor.classList.contains('view-more')) {
anchor.classList.remove('view-more');
anchor.classList.add('view-less');
block.querySelector(`.${name}`).classList.remove('hide');
block.querySelector(`.${name}-truncate`).classList.add('hide');
} else {
anchor.classList.remove('view-less');
anchor.classList.add('view-more');
block.querySelector(`.${name}`).classList.add('hide');
block.querySelector(`.${name}-truncate`).classList.remove('hide');
}
});
};

export default function decorate(block) {
const children = [...block.children];
if (children?.length) {
children.forEach((child, index) => {
child.classList.add(`cols-${index + 1}`);
if (index === 0) {
const name = 'about-text';
const threshold = 245;
child.children[1].classList.add(name);
if (child.children[1].textContent > threshold) {
child.children[1].classList.add('hide');
child.append(div({ class: `${name}-truncate` },
`${child.children[1].textContent.substring(0, threshold)}...`));
const anchor = a({ class: 'view-more' });
child.append(anchor);
viewMoreOnClick(name, anchor, block);
}
} else {
const threshold = 3;
const name = child.children[0].textContent.toLowerCase().replace(/\s/g, '-');
const liItems = child.children[1].querySelectorAll('li');
child.children[1].classList.add(name);

if (liItems.length > threshold) {
child.children[1].classList.add('hide');
const tempUl = ul({ });
Array.from(child.children[1].querySelectorAll('li'))
.slice(0, threshold).forEach((liItem) => {
const tempLi = li({}, liItem.textContent);
tempUl.append(tempLi);
});

child.append(div({ class: `${name}-truncate` }, tempUl));
const anchor = a({ class: 'view-more' });
child.append(anchor);
viewMoreOnClick(name, anchor, block);
}
}
});
}
}
94 changes: 94 additions & 0 deletions blocks/agent-testimonials/agent-testimonials.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
.agent-testimonials.block {
position: relative;
width: 100%;
overflow: hidden;
border-radius: 10px;
}

.agent-testimonials.block .testimonials {
display: flex;
transition: transform 0.5s ease;
width: 100%;
}

.agent-testimonials.block .testimonials-inner {
display: flex;
width: 100%;
}

.agent-testimonials.block .testimonials-item {
min-width: 100%;
box-sizing: border-box;
padding: 20px;
text-align: center;
display: flex;
flex-direction: column;
justify-content: space-between;
position: relative;
}

.agent-testimonials.block .rating-stars {
color: var(--primary-color);
margin-bottom: 10px;
font-size: 25px;
margin-left: 50px;
}

.agent-testimonials.block .review-text.full {
max-height: none;
font-size: 26px;
}

.agent-testimonials.block .review-text {
font-size: 26px;
margin-bottom: 20px;
padding-left: 50px;
padding-right: 50px;
}

.agent-testimonials.block .read-more {
font-size: 14px;
color: #607C8C;
cursor: pointer;
display: inline-block;

}

.agent-testimonials.block .reviewer-name {
font-weight: bold;
margin-bottom: 10px;
align-self: center;
}

.agent-testimonials.block .testimonials-arrow {
position: absolute;
top: 50%;
transform: translateY(-50%);
background: none;
border: none;
color: var(--black);
font-size: 90px;
padding: 0;
cursor: pointer;
}

.agent-testimonials.block .left-arrow {
left: 10px;
}

.agent-testimonials.block .right-arrow {
right: 10px;
}

.agent-testimonials.block .testimonials-counter {
position: absolute;
bottom: 10px;
right: 10px;
font-size: 16px;
color: #333;
}

.agent-testimonials.block .remaining-text {
font: inherit;
font-size: 26px;
}
Loading

0 comments on commit 0c6df17

Please sign in to comment.