Skip to content

Commit 6f834a5

Browse files
Changes from jan-2024 to feb-2024
1 parent 3f1f594 commit 6f834a5

File tree

644 files changed

+25765
-42485
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

644 files changed

+25765
-42485
lines changed

.env

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"core/extensions/markdown/core/render/logic/Markdoc",
3131
"*.js",
3232

33-
"**/dist/**/*"
33+
"**/dist/**/*",
34+
"target/tauri/target"
3435
],
3536
"plugins": ["@typescript-eslint", "react", "react-hooks", "promise"],
3637
"settings": {
@@ -81,11 +82,13 @@
8182
"@typescript-eslint/no-unsafe-assignment": "off",
8283
"@typescript-eslint/no-unsafe-member-access": "off",
8384
"@typescript-eslint/restrict-plus-operands": "off",
85+
"@typescript-eslint/no-unused-vars": "warn",
8486
"@typescript-eslint/restrict-template-expressions": "off",
8587
"@typescript-eslint/no-unsafe-any": "off",
8688
"@typescript-eslint/no-explicit-any": "off",
8789
"@typescript-eslint/no-unsafe-call": "off",
8890
"@typescript-eslint/explicit-function-return-type": "off",
91+
"@typescript-eslint/no-base-to-string": "warn",
8992
"no-case-declarations": "off",
9093

9194
"prefer-const": "warn",

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ yarn-error.log*
5252
.Trashes
5353
ehthumbs.db
5454
Thumbs.db
55-
junit.xml
55+
.env*
56+
junit*.xml
5657
.idea/
5758

5859

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Gramax — это бесплатный текстовый редактор со
99

1010
### Разворачивание приложения для редактирования
1111

12-
Чтобы начать редактировать документацию, достаточно скачать приложение или открыть его в браузере. Ссылки доступны на [gram.ax](https://gram.ax).
12+
Чтобы начать редактировать документацию, достаточно скачать приложение или открыть его в браузере. Ссылки доступны на нашем [сайте](https://gram.ax).
1313

1414
### Разворачивание портала для читателей
1515

@@ -22,15 +22,15 @@ Gramax — это бесплатный текстовый редактор со
2222
Откройте ваш терминал и выполните команду:
2323

2424
```bash
25-
curl https://raw.githubusercontent.com/StanislavPetrovIcs/test-gramax-setup/main/setup.sh | bash; docker compose up
25+
curl -O https://gram.ax/docker-compose.yaml; docker compose up
2626
```
2727

2828
#### На Windows
2929

3030
Откройте powershell и выполните команду:
3131

3232
```powershell
33-
Invoke-Expression (Invoke-WebRequest -Uri "https://raw.githubusercontent.com/StanislavPetrovIcs/test-gramax-setup/main/setup.ps1" -UseBasicParsing).Content; docker compose up
33+
Invoke-WebRequest -Uri "https://gram.ax/docker-compose.yaml" -OutFile "docker-compose.yaml"; docker compose up
3434
```
3535

3636
### Запуск для разработки (Vite и Next.js)

app/browser/app.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import Logger from "@ext/loggers/Logger";
1616
import MarkdownParser from "@ext/markdown/core/Parser/Parser";
1717
import ParserContextFactory from "@ext/markdown/core/Parser/ParserContext/ParserContextFactory";
1818
import MarkdownFormatter from "@ext/markdown/core/edit/logic/Formatter/Formatter";
19+
import FuseSearcher from "@ext/search/Fuse/FuseSearcher";
1920
import IndexCacheProvider from "@ext/search/IndexCacheProvider";
20-
import LunrSearcher from "@ext/search/Lunr/Searcher";
21-
import Searcher from "@ext/search/Searcher";
21+
import { IndexDataProvider } from "@ext/search/IndexDataProvider";
2222
import AuthManager from "@ext/security/logic/AuthManager";
2323
import { TicketManager } from "@ext/security/logic/TicketManager/TicketManager";
2424
import { AppConfig } from "../config/AppConfig";
@@ -42,7 +42,7 @@ const _init = async (config: AppConfig): Promise<Application> => {
4242
await fp.validate();
4343

4444
const libRules = getExecutingEnvironment() == "browser" ? [deleteAnyFolderRule] : [];
45-
const lib = new Library(rp);
45+
const lib = new Library(rp, config.isServerApp);
4646
await lib.addFileProvider(fp, (fs) => FSLocalizationRules.bind(fs), libRules);
4747

4848
if (config.paths.local) {
@@ -51,8 +51,8 @@ const _init = async (config: AppConfig): Promise<Application> => {
5151
await lib.addFileProvider(fp);
5252
}
5353

54-
const cacheFileProvider = new FileProvider(config.paths.cache);
55-
const cache = new IndexCacheProvider(cacheFileProvider);
54+
const cacheFileProvider = new FileProvider(config.paths.userDataPath);
55+
const indexCacheProvider = new IndexCacheProvider(cacheFileProvider);
5656
const hashes = new Hash();
5757
const tm = new ThemeManager();
5858
const encoder = new Encoder();
@@ -70,15 +70,9 @@ const _init = async (config: AppConfig): Promise<Application> => {
7070
config.enterpriseServerUrl,
7171
);
7272
const logger: Logger = new BugsnagLogger(config.bugsnagApiKey);
73-
const searcher: Searcher = new LunrSearcher(lib, parser, parserContextFactory, cache);
74-
const sitePresenterFactory = new SitePresenterFactory(
75-
lib,
76-
parser,
77-
parserContextFactory,
78-
searcher,
79-
rp,
80-
errorArticlesProvider,
81-
);
73+
const indexDataProvider = new IndexDataProvider(lib, parser, parserContextFactory, indexCacheProvider);
74+
const searcher = new FuseSearcher(indexDataProvider);
75+
const sitePresenterFactory = new SitePresenterFactory(lib, parser, parserContextFactory, rp, errorArticlesProvider);
8276
const contextFactory = new ContextFactory(tm, config.cookieSecret);
8377

8478
return {
@@ -100,13 +94,14 @@ const _init = async (config: AppConfig): Promise<Application> => {
10094
parserContextFactory,
10195
errorArticlesProvider,
10296
conf: {
103-
corsProxy: corsProxy,
97+
corsProxy,
10498
branch: config.branch,
10599
basePath: config.paths.base,
106100
isReadOnly: config.isReadOnly,
107101
isServerApp: config.isServerApp,
108102
ssoServerUrl: config.ssoServerUrl,
109103
ssoPublicKey: config.ssoPublicKey,
104+
authServiceUrl: config.authServiceUrl,
110105
isProduction: config.isProduction,
111106
enterpriseServerUrl: config.enterpriseServerUrl,
112107
bugsnagApiKey: config.bugsnagApiKey,

app/browser/configure.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const configure = (): AppConfig => {
1111
branch: env("BRANCH") ?? "develop",
1212
ssoServerUrl: env("SSO_SERVER_URL") ?? null,
1313
ssoPublicKey: env("SSO_PUBLIC_KEY") ?? null,
14+
authServiceUrl: env("AUTH_SERVICE_URL") ?? "https://app.gram.ax/-server/auth",
1415
enterpriseServerUrl: env("ENTERPRISE_SERVER_URL") ?? null,
1516
bugsnagApiKey: env("BUGSNAG_API_KEY") ?? null,
1617
cookieSecret: env("COOKIE_SECRET") ?? null,

app/commands/article/create.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { AuthorizeMiddleware } from "@core/Api/middleware/AuthorizeMiddleware";
22
import { DesktopModeMiddleware } from "@core/Api/middleware/DesktopModeMiddleware";
3+
import ReloadConfirmMiddleware from "@core/Api/middleware/ReloadConfirmMiddleware";
34
import Context from "@core/Context/Context";
45
import Path from "@core/FileProvider/Path/Path";
56
import ResourceUpdater from "@core/Resource/ResourceUpdater";
@@ -11,7 +12,7 @@ const create: Command<{ ctx: Context; catalogName: string; parentPath?: Path },
1112

1213
kind: ResponseKind.plain,
1314

14-
middlewares: [new AuthorizeMiddleware(), new DesktopModeMiddleware()],
15+
middlewares: [new AuthorizeMiddleware(), new DesktopModeMiddleware(), new ReloadConfirmMiddleware()],
1516

1617
async do({ ctx, catalogName, parentPath }) {
1718
const { formatter, lib, parser, parserContextFactory } = this._app;
@@ -27,7 +28,7 @@ const create: Command<{ ctx: Context; catalogName: string; parentPath?: Path },
2728
parentPath ? parentRef : null,
2829
);
2930

30-
return article.logicPath;
31+
return await catalog.getPathname(article);
3132
},
3233

3334
params(ctx: Context, query: { [key: string]: string }) {

app/commands/article/editOn/app.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Command, ResponseKind } from "@app/types/Command";
2+
import Path from "@core/FileProvider/Path/Path";
3+
import RouterPathProvider from "@core/RouterPath/RouterPathProvider";
4+
5+
const app: Command<{ catalogName: string; articlePath: Path }, string> = Command.create({
6+
path: "article/editOn/app",
7+
8+
kind: ResponseKind.plain,
9+
10+
async do({ catalogName, articlePath }) {
11+
const { lib } = this._app;
12+
const catalog = await lib.getCatalog(catalogName);
13+
if (!catalog) return;
14+
const fp = lib.getFileProviderByCatalog(catalog);
15+
const itemRef = fp.getItemRef(articlePath);
16+
const item = catalog.findArticleByItemRef(itemRef);
17+
return RouterPathProvider.getPathname(await catalog.getPathnameData(item)).value;
18+
},
19+
20+
params(ctx, q) {
21+
const catalogName = q.catalogName;
22+
const articlePath = new Path(q.articlePath);
23+
return { ctx, catalogName, articlePath };
24+
},
25+
});
26+
27+
export default app;
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
import Path from "@core/FileProvider/Path/Path";
21
import { Command, ResponseKind } from "@app/types/Command";
2+
import Path from "@core/FileProvider/Path/Path";
33

4-
const fileLink: Command<{ catalogName: string; articlePath: Path }, string> = Command.create({
5-
path: "article/redirect/fileLink",
4+
const source: Command<{ catalogName: string; articlePath: Path }, string> = Command.create({
5+
path: "article/editOn/source",
66

7-
kind: ResponseKind.redirect,
7+
kind: ResponseKind.plain,
88

99
async do({ catalogName, articlePath }) {
1010
const { lib } = this._app;
1111
const catalog = await lib.getCatalog(catalogName);
12+
if (!catalog) return;
13+
if (!articlePath.startsWith(catalog.getBasePath())) return;
1214
const fp = lib.getFileProviderByCatalog(catalog);
1315
const itemRef = fp.getItemRef(articlePath);
14-
const path = catalog?.getRelativeRepPath(itemRef) ?? null;
16+
const path = catalog.getRelativeRepPath(itemRef);
1517
const { gitVersionControl } = await catalog.repo.gvc.getGitVersionControlContainsItem(path);
1618

1719
return await catalog.repo.storage.getFileLink(path, await gitVersionControl.getCurrentBranch());
@@ -24,4 +26,4 @@ const fileLink: Command<{ catalogName: string; articlePath: Path }, string> = Co
2426
},
2527
});
2628

27-
export default fileLink;
29+
export default source;

app/commands/article/features/checkLastModified.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
import { AuthorizeMiddleware } from "@core/Api/middleware/AuthorizeMiddleware";
2-
import { DesktopModeMiddleware } from "@core/Api/middleware/DesktopModeMiddleware";
32
import Context from "@core/Context/Context";
43
import Path from "@core/FileProvider/Path/Path";
54
import { Article } from "@core/FileStructue/Article/Article";
6-
import { ArticleData } from "@core/SitePresenter/SitePresenter";
5+
import { ArticlePageData } from "@core/SitePresenter/SitePresenter";
76
import DefaultError from "../../../../core/extensions/errorHandlers/logic/DefaultError";
87
import { Command, ResponseKind } from "../../../types/Command";
98

10-
const checkLastModified: Command<{ ctx: Context; articlePath: Path; catalogName: string }, ArticleData> =
9+
const checkLastModified: Command<{ ctx: Context; articlePath: Path; catalogName: string }, ArticlePageData> =
1110
Command.create({
1211
path: "article/features/checkLastModified",
1312

1413
kind: ResponseKind.json,
1514

16-
middlewares: [new AuthorizeMiddleware(), new DesktopModeMiddleware()],
15+
middlewares: [new AuthorizeMiddleware()],
1716

1817
async do({ ctx, articlePath, catalogName }) {
1918
const { lib, sitePresenterFactory } = this._app;
2019
const catalog = await lib.getCatalog(catalogName);
21-
if (!catalog) return;
20+
if (!catalog || !catalog.getRootCategory().items.length) return;
2221

2322
const fp = lib.getFileProviderByCatalog(catalog);
2423
const itemRef = fp.getItemRef(articlePath);
25-
const article = catalog.findItemByItemRef(itemRef) as Article;
26-
if (!article) return;
24+
const article = catalog.findItemByItemRef<Article>(itemRef);
25+
if (!article || article.props.welcome) return;
2726
let res = false;
2827

2928
try {
@@ -33,7 +32,7 @@ const checkLastModified: Command<{ ctx: Context; articlePath: Path; catalogName:
3332
if (e?.code === "ENOENT") throw new DefaultError(null, e, { errorCode: e?.code });
3433
}
3534

36-
return res ? await sitePresenterFactory.fromContext(ctx).getArticleData(article, catalog) : null;
35+
return res ? await sitePresenterFactory.fromContext(ctx).getArticlePageData(article, catalog) : null;
3736
},
3837

3938
params(ctx, q) {

0 commit comments

Comments
 (0)