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

development to production #432

Merged
merged 32 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
eb01683
wr-414: + modifyFontSize helper
IrynaK-a Sep 28, 2023
c401f37
Merge branch 'development' into task/wr-414-fix-the-displaying-articl…
IrynaK-a Sep 28, 2023
be51ee2
wr-414: - unnecessary attribute
IrynaK-a Sep 28, 2023
d8f9326
wr-420: * filter disabled state
PablloZz Sep 28, 2023
616f210
wr-414: - modifyFontSize;
IrynaK-a Sep 28, 2023
a82989f
Merge pull request #422 from BinaryStudioAcademy/task/wr-414-fix-the-…
andanf-e Sep 28, 2023
0c4b75e
Merge branch 'development' into fix/wr-420-enable-genre-stats-filter-…
andanf-e Sep 28, 2023
d5245b9
Merge pull request #423 from BinaryStudioAcademy/fix/wr-420-enable-ge…
andanf-e Sep 28, 2023
5fa6308
wr-403: * prompts
canterbery Sep 28, 2023
0cb25af
wr-410: + install vite-plugin-pwa
drMangust Sep 28, 2023
007f700
wr-410: + add favicon icons
drMangust Sep 28, 2023
5e5f25a
wr-410: + add icons to head
drMangust Sep 28, 2023
ad7f1e3
wr-410: + add VitePWA config
drMangust Sep 28, 2023
96f5840
Merge branch 'development' of https://github.com/BinaryStudioAcademy/…
drMangust Sep 28, 2023
1b7d914
wr-410: * rename with rules
drMangust Sep 28, 2023
5d73a73
wr-410: * prettify
drMangust Sep 28, 2023
79536b8
wr-410: * move pwa options to constant
drMangust Sep 28, 2023
fd59879
wr-418: - notification when draft is created
AnastasiaR2 Sep 28, 2023
ceaa63f
Merge branch 'development' of https://github.com/BinaryStudioAcademy/…
AnastasiaR2 Sep 28, 2023
14ce5db
wr-418: * added commentCount and viewCount in article update method
AnastasiaR2 Sep 28, 2023
75aae50
wr-418: - notification when article is already published
AnastasiaR2 Sep 28, 2023
bd0abe0
Merge pull request #428 from BinaryStudioAcademy/task/wr-418-fix-noti…
andanf-e Sep 28, 2023
5ac3e57
Merge branch 'development' into task/wr-410-pwa
drMangust Sep 28, 2023
272cab5
wr-415: * fix scroll to comments
hnoievets Sep 28, 2023
c39177a
Merge pull request #425 from BinaryStudioAcademy/task/wr-410-pwa
andanf-e Sep 28, 2023
c254898
Merge branch 'development' into task/wr-403-OpenAI-performance-check
andanf-e Sep 28, 2023
8eec363
Merge branch 'development' of github.com:BinaryStudioAcademy/bsa-2023…
hnoievets Sep 28, 2023
3fbc950
Merge pull request #424 from BinaryStudioAcademy/task/wr-403-OpenAI-p…
andanf-e Sep 28, 2023
c6642f9
Merge branch 'development' into fix/wr-415-redirection-to-comment-blo…
hnoievets Sep 28, 2023
feb43bf
Merge pull request #430 from BinaryStudioAcademy/fix/wr-415-redirecti…
andanf-e Sep 28, 2023
276f9a7
wr-328: * small fix according to bug report
kovAnya Sep 29, 2023
ce30887
Merge pull request #431 from BinaryStudioAcademy/fix/wr-328-fix-the-d…
andanf-e Sep 29, 2023
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
2 changes: 2 additions & 0 deletions backend/src/packages/articles/article.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ class ArticleRepository implements IArticleRepository {
}
: null,
coverUrl: article.cover?.url ?? null,
commentCount: EMPTY_COMMENT_COUNT,
viewCount: EMPTY_VIEW_COUNT,
});
}

Expand Down
14 changes: 11 additions & 3 deletions backend/src/packages/articles/article.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,11 @@ class ArticleService implements IService {
}),
);

void this.articleSocketService.handleNewArticle(
article.toObjectWithRelationsAndCounts(),
);
if (payload.publishedAt) {
void this.articleSocketService.handleNewArticle(
article.toObjectWithRelationsAndCounts(),
);
}

const countOfOwnArticles =
await this.articleRepository.countArticlesByUserId(payload.userId);
Expand Down Expand Up @@ -442,6 +444,12 @@ class ArticleService implements IService {
}),
);

if (payload.publishedAt && !article.publishedAt) {
void this.articleSocketService.handleNewArticle(
updatedArticle.toObjectWithRelationsAndCounts(),
);
}

return updatedArticle.toObjectWithRelationsAndCounts();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const getArticleImprovementSuggestionsCompletionConfig = (
text: string,
): CompletionConfig => {
return {
prompt: `You'll be given a html markup of article and your task is to identify some points that you would suggest to change to make the article better. Ignore any html related issues - focus on article content. Provide the result in JSON format as an array of objects where each object has keys: title (title of suggestion), description (description of suggestion), and priority (can be 1, 2, or 3, it identifies the importance of suggestion, 1 - lowest priority, 3 - highest priority). Here's the article: ${text}`,
prompt: `You'll be given a html markup of article and your task is to identify some points that you would suggest to change to make the article better. Ignore any html related issues - focus on article content. Provide the result in JSON format as an array of objects where each object has keys: title (title of suggestion), description (description of suggestion), and priority (can be 1, 2, or 3, it identifies the importance of suggestion, 1 - lowest priority, 3 - highest priority).Provide no more than 5 suggestions. Here's the article: ${text}`,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { UNKNOWN_GENRE_KEY } from '~/packages/genres/genre.js';
const getDetectArticleGenreCompletionConfig = (
text: string,
): CompletionConfig => ({
prompt: `You will be provided with a html markup of an article, and your task is to extract a list of possible genres of that article. Provide your output in json format as an array of objects with keys name and key, where name is a readble name of the genre and key - a short snake cased representation of genre name. Place the most relevant genre at the 0 index. In case you can't indentify the genre put an object { key: "${UNKNOWN_GENRE_KEY}", name: "Unknown" } as the last item in resulting array. Here is the text: ${text}.`,
prompt: `You will be provided with a html markup of an article, and your task is to extract a list of possible genres (no more than 5) of that article. Provide your output in json format as an array of objects with keys name and key, where name is a readble name of the genre and key - a short snake cased representation of genre name. Place the most relevant genre at the 0 index. In case you can't indentify the genre put an object { key: "${UNKNOWN_GENRE_KEY}", name: "Unknown" } as the last item in resulting array. Here is the text: ${text}.`,
});

export { getDetectArticleGenreCompletionConfig };
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const ArticlePromptCompletionConfig = {
MESSAGE:
'Your task is to generate a prompt for writing an article which will consist of the following components: genre, character, prop, situation and setting. You should generate a unique random value for each, so all of the elements create a consise and interesting article concept. Genre is any possible category of writing or literature. Provide your output in json format with the keys: genre, prop, character, situation, setting.',
'Your task is to generate a prompt for writing an article which will consist of the following components: genre, character, prop, situation and setting. You should generate a unique random value no longer than 4 words for each, so all of the elements create a consise and interesting article concept. Genre is any possible category of writing or literature. Provide your output in json format with the keys: genre, prop, character, situation, setting.',
TEMPERATURE: 1.5,
} as const;

Expand Down
9 changes: 8 additions & 1 deletion frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/feather-pen.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link rel="icon" type="image/png" href="/favicon.png" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#2e453b" />
<meta name="msapplication-TileColor" content="#da532c" />
<meta name="theme-color" content="#2e453b" />
<title>Writorium</title>
</head>
<body>
Expand Down
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"stylelint-config-standard-scss": "10.0.0",
"typescript-plugin-css-modules": "5.0.1",
"vite": "4.4.9",
"vite-plugin-pwa": "0.16.5",
"vite-plugin-rewrite-all": "1.0.1",
"vite-plugin-svgr": "3.2.0",
"vite-tsconfig-paths": "4.2.0"
Expand Down
Binary file added frontend/public/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions frontend/public/browserconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/mstile-150x150.png"/>
<TileColor>#da532c</TileColor>
</tile>
</msapplication>
</browserconfig>
Binary file added frontend/public/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/favicon.ico
Binary file not shown.
Binary file added frontend/public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/maskable-icon-x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/mstile-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/mstile-150x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/mstile-310x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/mstile-310x310.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/mstile-70x70.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions frontend/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Disallow:
41 changes: 41 additions & 0 deletions frontend/public/safari-pinned-tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion frontend/src/assets/img/icons/filter-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions frontend/src/pages/article/article-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const ArticlePage: React.FC = () => {

useArticleRoom(Number(id));

useEffect(() => {
const scrollToComments = useCallback(() => {
const { hash } = location;
const element = hash ? document.querySelector(hash) : null;

Expand All @@ -81,13 +81,14 @@ const ArticlePage: React.FC = () => {
}, [location]);

useEffect(() => {
void dispatch(articleActions.getArticle(Number(id)));
void dispatch(articleActions.getArticle(Number(id))).then(scrollToComments);

void dispatch(articleActions.fetchAllCommentsToArticle(Number(id)));

return () => {
void dispatch(articleActions.resetComments());
};
}, [dispatch, id]);
}, [dispatch, id, scrollToComments]);

const handleCreateComment = useCallback(
(payload: Omit<CommentBaseRequestDto, 'articleId'>): void => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ const ArticleCard: React.FC<Properties> = ({
<h4 className={styles.title}>{title}</h4>
<article
className={getValidClassNames(styles.text, 'text-overflow')}
dangerouslySetInnerHTML={{ __html: sanitizeHtml(text) }}
dangerouslySetInnerHTML={{
__html: sanitizeHtml(text),
}}
></article>
</div>
{coverUrl && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
overflow-wrap: break-word;
}

.body .text * {
font-size: 14px !important; /* stylelint-disable-line declaration-no-important */
}

.coverWrapper {
grid-area: cover;
flex-shrink: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ div.confirmModal {

.message {
margin-bottom: 20px;
padding: 24px 16px;
padding: 34px 24px 16px;
font-size: 20px;
border-bottom: 2px solid var(--light-gray-15);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const UserArticlesGenresStats: React.FC<Properties> = ({ className }) => {
options={articleStatusOptions}
control={control}
errors={errors}
isDisabled={!hasArticles}
isDisabled={!hasArticles && !filters.articlePublishedStatus}
/>
</div>
</form>
Expand Down
39 changes: 38 additions & 1 deletion frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,37 @@ import tsconfigPathsPlugin from 'vite-tsconfig-paths';
import svgr from 'vite-plugin-svgr';
import path from 'path';
import pluginRewriteAll from 'vite-plugin-rewrite-all';
import { VitePWA, VitePWAOptions } from 'vite-plugin-pwa';

const pwaOptions: Partial<VitePWAOptions> = {
registerType: 'autoUpdate',
includeAssets: ['favicon.ico', 'favicon.svg', 'apple-touch-icon.png'],
manifest: {
name: 'Writorium',
short_name: 'Writorium',
description: 'Unbounded space for freedom of your feather',
theme_color: '#2e453b',
start_url: '/',
icons: [
{
src: '/android-chrome-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: '/android-chrome-512x512.png',
sizes: '512x512',
type: 'image/png',
},
{
src: '/maskable_icon_x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable',
},
],
},
};

const config = ({ mode }: ConfigEnv): ReturnType<typeof defineConfig> => {
const {
Expand All @@ -18,7 +49,13 @@ const config = ({ mode }: ConfigEnv): ReturnType<typeof defineConfig> => {
build: {
outDir: 'build',
},
plugins: [tsconfigPathsPlugin(), reactPlugin(), svgr(), pluginRewriteAll()],
plugins: [
tsconfigPathsPlugin(),
reactPlugin(),
svgr(),
pluginRewriteAll(),
VitePWA(pwaOptions),
],
server: {
port: Number(VITE_APP_DEVELOPMENT_PORT),
proxy: {
Expand Down
Loading
Loading