Skip to content

Commit

Permalink
Merge branch 'stage' of https://github.com/AletheiaFact/aletheia into…
Browse files Browse the repository at this point in the history
… fix-load-search-overlay
  • Loading branch information
caneppelevitor committed Dec 3, 2024
2 parents bb5fae2 + 2c47e3c commit bce8e28
Show file tree
Hide file tree
Showing 37 changed files with 532 additions and 152 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
65 changes: 10 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ cp config/localConfig.example.ts config/localConfig.ts
``` sh
yarn seed
```
- Run the command below to update the users' affiliations:
``` sh
./node_modules/.bin/ts-node ./server/scripts/updateAllUsersAppAffiliation.ts
```
## Build to production

- The build step should be run as follow:
Expand Down Expand Up @@ -88,67 +92,18 @@ Check if users were created successfully by accessing the identities page:
### Ory Cloud
#### Taking What You Need:
- Create an account and a project on https://console.ory.sh/login.
- Copy the SDK Configuration url and save it.
- Scroll down in the same page and create a Personal Access Tokens, copy the acess token that gonna show up on the bottom of your screen and save it.
- Go to Identity Schema and click on Customize Identity Schema then change the actual schema to the code below and click Update after the change:
```
{
"$id": "https://schemas.ory.sh/presets/kratos/identity.email.schema.json",
"title": "Person",
"type": "object",
"properties": {
"traits": {
"type": "object",
"properties": {
"email": {
"type": "string",
"format": "email",
"title": "E-Mail",
"ory.sh/kratos": {
"credentials": {
"password": {
"identifier": true
},
"webauthn": {
"identifier": true
},
"totp": {
"account_name": true
}
},
"recovery": {
"via": "email"
},
"verification": {
"via": "email"
}
},
"maxLength": 320
},
"user_id": {
"type": "string"
},
"role": {
"type": "object"
}
},
"required": [
"email",
"user_id"
],
"additionalProperties": false
}
}
}
```
- In Project settings, copy the SDK configuration URL and save it.
- On the same page, in API keys, create a new API key, copy it, and save it.
- Go to User Management in Identity Schema and click on Duplicate Identity Schema. Then, update the current schema to [IdentitySchema.JSON](https://github.com/AletheiaFact/aletheia/blob/stage/ory_config/identity.schema.json) and click Save after making the changes:
- Go to SDK Configuration url that you saved and add /schemas in the end of the url then copy the first id on the page and save it.
- If you want to check if it is the right id, at the same url paste after /schemas the /<schema_id> contaning the id that you just copied.

#### Making The Changes On Your Code:
- First you gonna have to change the ``authentication_type: `` to ory on your config.yaml and config.seed.yaml.
- Now take SDK Configuration url and paste on ``url: `` in both pages config.yaml, config.seed.yaml and on ``ORY_SDK_URL=`` in your .env too.
- Now Paste the acess token that you saved on ``access_token: `` in your config.yaml and config.seed.yaml.
- Do the same as above but now with the id that you saved and paste it on ``schema_id: ``.
- Now Paste the acess token that you saved on ``access_token: `` in your config.yaml and config.seed.yaml and on
``ORY_ACCESS_TOKEN=`` in your .env too.
- Do the same as above, but now with the Schema ID you saved, and paste it into ``schema_id`` and on ``ALETHEIA_SCHEMA_ID=`` in .env.

#### Setting up your own UI to make the right redirects:
- Go to User Interface on Ory Console and rewrite these fields: Login UI with http://localhost:3000/login and Settings UI with http://localhost:3000/profile.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"@langchain/community": "^0.0.54",
"@langchain/openai": "^0.0.28",
"@mui/icons-material": "^5.10.9",
"@mui/joy": "^5.0.0-beta.48",
"@mui/material": "5.16.6",
"@mui/x-data-grid": "^7.12.0",
"@nestjs/axios": "^3.0.0",
Expand Down
10 changes: 4 additions & 6 deletions public/locales/en/donationBanner.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"title": "AletheiaFact {{date}} Donation Campaign",
"paragraph": "AletheiaFact.org works to combat misinformation and strengthen fact-checking. With your donation, you support the movement against FAKE NEWS, ensuring reliable information reaches you.",
"donateButton": "Donate to aletheia",
"showButton": "Show",
"hideButton": "Hide"

"title": "AletheiaFact.org needs you to survive",
"paragraph": "AletheiaFact.org is unique and relies on the community. No ads, no subscriptions, we are driven by the passion to ensure free and reliable access to information. With your help, we continue to be a trusted reference. <strong>Our strength lies in the community – and that includes you.</strong> Today, we ask you to support us in this commitment to the truth. Show Brazil that reliable and impartial information is essential and that you stand with us in this mission. <strong>Donate now and help strengthen the fight against misinformation.</strong> Even a small donation makes a big difference. This is the time to act so that together, we can promote more democratic journalism and fight misinformation. <strong>Thank you for believing in AletheiaFact.org.</strong>",
"yesDonateButton": "I want to contribute!",
"noDonateButton": "I don't want to donate"
}
10 changes: 4 additions & 6 deletions public/locales/pt/donationBanner.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"title": "Campanha doação AletheiaFact {{date}}",
"paragraph": "A AletheiaFact.org trabalha para combater a desinformação e fortalecer a checagem de fatos. Com sua doação, você apoia o movimento contra FAKE NEWS e informações confiáveis cheguem a você.",
"donateButton": "Doe para aletheia",
"showButton": "Mostrar",
"hideButton": "Ocultar"

"title": "A AletheiaFact.org precisa de você para sobreviver",
"paragraph": "A AletheiaFact.org é única e depende da comunidade. Sem anúncios, sem assinaturas, somos movidos pela paixão de garantir acesso livre e confiável à informação. Com sua ajuda, continuamos sendo um referencial de confiança. <strong>Nossa força está na comunidade – e isso inclui você.</strong> Hoje, pedimos que nos apoie nesse compromisso com a verdade. Mostre ao Brasil que informações confiáveis e imparciais são essenciais e que você está ao nosso lado nessa missão. <strong>Doe agora e ajude a fortalecer o combate à desinformação.</strong> Mesmo uma doação pequena faz uma grande diferença. Este é o momento de agir para que, juntos, possamos promover um jornalismo mais democrático e combater a desinformação. <strong>Obrigado por acreditar na AletheiaFact.org.</strong>",
"yesDonateButton": "Quero contribuir!",
"noDonateButton": "Não quero doar"
}
60 changes: 60 additions & 0 deletions server/scripts/createNovuSubscribersFromDB.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { NestFactory } from "@nestjs/core";
import { AppModule } from "../app.module";
import { NestExpressApplication } from "@nestjs/platform-express";
import { UsersService } from "../users/users.service";
import { NotificationService } from "../notifications/notifications.service";
import { WinstonLogger } from "../winstonLogger";
import loadConfig from "../configLoader";

async function createNovuSubscriber(userFromDB, novuService) {
if (!userFromDB || !userFromDB.id) {
throw new Error(`Invalid user data: ${JSON.stringify(userFromDB)}`);
}

try {
await novuService.createSubscriber({
_id: userFromDB.id,
email: userFromDB.email,
name: userFromDB.name,
});
console.log(`Subscriber created for user ${userFromDB.email}`);
} catch (error) {
throw new Error(
`Failed to create Novu subscriber for user ${userFromDB.email}: ${error.message}`
);
}
}

async function initApp() {
const options = loadConfig();
const logger = new WinstonLogger();

const app = await NestFactory.create<NestExpressApplication>(
AppModule.register(options)
);

logger.log(`AppModule loaded`);

const userService = await app.resolve(UsersService);
const novuService = await app.resolve(NotificationService);

try {
const users = await userService.getAllUsers();

for (const user of users) {
await createNovuSubscriber(user, novuService);
logger.log(`Novu subscriber created for user: ${user.email}`);
}

logger.log("All users have been processed for Novu subscription.");
} catch (error) {
logger.error(
"An error occurred while creating Novu subscribers:",
error
);
} finally {
await app.close();
}
}

initApp();
52 changes: 38 additions & 14 deletions src/components/Home/DonationBanner.style.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,74 @@
import styled from "styled-components";
import colors from "../../styles/colors";
import { Col } from "antd";
import { queries } from "../../styles/mediaQueries";

const DonationBannerStyle = styled(Col)`
background-color: ${colors.quartiary};
background-color: ${colors.inactive};
.show-banner {
color: ${colors.white};
font-size: 13px;
border: none;
background-color: ${colors.blackTertiary};
font-weight: 600;
cursor: pointer;
.close-banner {
color: ${colors.primary};
font-size: 25px;
align-self: flex-end;
position: absolute;
right: 10px;
bottom: -25px;
bottom: -10px;
z-index: 1;
}
.banner-content {
display: flex;
margin: 25px auto;
flex-direction: column;
align-items: center;
padding: 20px 0px;
max-width: 60%;
gap: 20px;
}
.banner-buttons {
display: flex;
gap: 30px;
}
.banner-content > h1 {
width: 100%;
color: ${colors.black};
color: ${colors.primary};
font-size: 26px;
line-height: 34px;
font-weight: 800;
text-align: center;
}
.banner-content > p {
color: ${colors.blackTertiary};
color: ${colors.black};
font-size: 16px;
font-weight: 600;
line-height: 24px;
text-align: center;
}
.banner-button {
font-weight: 600;
font-weight: 700;
}
@media ${queries.md} {
.banner-content {
max-width: 80%;
}
}
@media ${queries.xs} {
.banner-content > h1 {
font-size: 20px;
}
.banner-content > p {
font-size: 12px;
}
.close-banner {
align-self: flex-start;
top: -10px;
}
}
`;

Expand Down
64 changes: 41 additions & 23 deletions src/components/Home/DonationBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,51 @@
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import DonationBannerContent from "./DonationBanner/DonationBannerContent";
import DonationBannerStyle from "./DonationBanner.style";
import { Col } from "antd";
import { useTranslation } from "next-i18next";
import Cookies from "js-cookie";
import CloseOutlined from "@mui/icons-material/CloseOutlined";

const closeBanner = (onClose) => {
onClose();
Cookies.set("cta_donation_banner_show", "false");
};

const DonationBanner = () => {
const { t } = useTranslation();
const [isBannerVisible, setIsBannerVisible] = useState(true);
const enableDonationBanner = process.env.NEXT_PUBLIC_ENABLE_BANNER_DONATION === "true";
const handleToggleBanner = () => {
setIsBannerVisible((prev) => !prev);
}
const enableDonationBanner =
process.env.NEXT_PUBLIC_ENABLE_BANNER_DONATION === "true";
const [showDonationBanner, setDonationBanner] = useState<boolean>(false);

useEffect(() => {
const CloseBannerCookies = Cookies.get("cta_donation_banner_show");
if (CloseBannerCookies) {
return setDonationBanner(false);
}
setDonationBanner(true);
}, []);

if (!enableDonationBanner){
return null
};
if (!enableDonationBanner) {
return null;
}

return (
<DonationBannerStyle>
<Col className="banner-container">
{isBannerVisible && <DonationBannerContent />}
<button
className="show-banner"
onClick={handleToggleBanner}>
{isBannerVisible ? t("donationBanner:hideButton") : t("donationBanner:showButton")}
</button>
</Col>
</DonationBannerStyle >
);
return (
showDonationBanner && (
<DonationBannerStyle>
<Col className="banner-container">
<CloseOutlined
className="close-banner"
onClick={() =>
closeBanner(() => setDonationBanner(false))
}
/>
<DonationBannerContent
closeClick={() =>
closeBanner(() => setDonationBanner(false))
}
/>
</Col>
</DonationBannerStyle>
)
);
};

export default DonationBanner;
25 changes: 19 additions & 6 deletions src/components/Home/DonationBanner/DonationBannerButton.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
import { useTranslation } from "next-i18next";
import Button from "../../Button";
import { trackUmamiEvent } from "../../../lib/umami";

const DonationBannerButton = ({ type }) => {
const { t } = useTranslation();
interface DonationBannerButtonProps {
type: any;
closeClick: () => void;
href?: string;
text: string;
trackEvent: string;
}

const DonationBannerButton = ({
type,
closeClick,
href,
text,
trackEvent,
}: DonationBannerButtonProps) => {
return (
<Button
type={type}
href={t("home:donateUrlButton")}
href={href}
target="_blank"
rel="noreferrer"
onClick={() => {
trackUmamiEvent("header-banner-donate-button", "Donate");
if (closeClick) closeClick();
trackUmamiEvent(trackEvent, text);
}}
className="banner-button"
>
{t("donationBanner:donateButton")}
{text}
</Button>
);
};
Expand Down
Loading

0 comments on commit bce8e28

Please sign in to comment.