1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/outline_ynh.git synced 2024-09-03 19:56:12 +02:00

Test patching

This commit is contained in:
Limezy 2022-09-10 23:17:17 +07:00
parent 4ed46c5caf
commit 6ea6d8cfc2
2 changed files with 227 additions and 0 deletions

View file

@ -0,0 +1,102 @@
diff --git a/server/routes/auth/providers/req.ts b/server/routes/auth/providers/req.ts
new file mode 100644
index 00000000..22beba6e
--- /dev/null
+++ b/server/routes/auth/providers/req.ts
@@ -0,0 +1,64 @@
+import passport from "@outlinewiki/koa-passport";
+import Router from "koa-router";
+import { capitalize } from "lodash";
+import { Strategy as ReqStrategy } from "passport-req";
+import accountProvisioner from "@server/commands/accountProvisioner";
+import env from "@server/env";
+import passportMiddleware from "@server/middlewares/passport";
+import { getAllowedDomains } from "@server/utils/authentication";
+import { StateStore } from "@server/utils/passport";
+
+const router = new Router();
+const providerName = "req";
+const allowedDomains = getAllowedDomains();
+
+export const config = {
+ name: "Visitor",
+ enabled: true,
+};
+
+if (true) {
+ passport.use(
+ new ReqStrategy(
+ async function (req,done) {
+ try {
+ const domain = "domain.tld";
+ const subdomain = domain.split(".")[0];
+ const teamName = capitalize(subdomain);
+ const name = "Visitor";
+ const email = "visitor@domain.tld";
+ const result = await accountProvisioner({
+ ip: req.ip,
+ team: {
+ name: teamName,
+ domain,
+ subdomain,
+ },
+ user: {
+ name: name,
+ email: email,
+ avatarUrl: null,
+ },
+ authenticationProvider: {
+ name: providerName,
+ providerId: domain,
+ },
+ authentication: {
+ providerId: "1234",
+ accessToken: null,
+ refreshToken: null,
+ scopes: [],
+ },
+ });
+ return done(null, result.user, result);
+ } catch (err) {
+ return done(err, null);
+ }
+ }
+ )
+ );
+
+ router.get("req", passportMiddleware(providerName));
+}
+
+export default router;
diff --git a/yarn.lock b/yarn.lock
index 0bc83b9b..b642b8f7 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -11790,6 +11790,15 @@ passport-oauth@1.0.x:
passport-oauth1 "1.x.x"
passport-oauth2 "1.x.x"
+passport-req@^0.1.1:
+ version "0.1.1"
+ resolved "https://registry.yarnpkg.com
+ passport-req/-/passport-req-0.1.1.tgz#451bff1500b3d464a768d42f0762328a21236a18"
+ integrity sha1-RRv/FQCz1GSnaNQvB2IyiiEjahg=
+ dependencies:
+ passport "~0.1.1"
+ pkginfo "0.2.x"
+
passport-slack-oauth2@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/passport-slack-oauth2/-/passport-slack-oauth2-1.1.1.tgz#d831ffc3f1e968fcc3622e6ecf41643c8d8f9cbc"
diff --git a/package.json b/package.json
index ff45e246..a5837c23 100644
--- a/package.json
+++ b/package.json
@@ -144,6 +144,7 @@
"passport": "^0.6.0",
"passport-google-oauth2": "^0.2.0",
"passport-oauth2": "^1.6.1",
+ "passport-req": "^0.1.1",
"passport-slack-oauth2": "^1.1.1",
"pg": "^8.5.1",
"pg-hstore": "^2.3.4",

View file

@ -0,0 +1,125 @@
diff --git a/app/editor/menus/block.ts b/app/editor/menus/block.ts
index 9a6fbe7d..26fac655 100644
--- a/app/editor/menus/block.ts
+++ b/app/editor/menus/block.ts
@@ -18,6 +18,7 @@ import {
AttachmentIcon,
ClockIcon,
CalendarIcon,
+ BookmarkedIcon,
} from "outline-icons";
import { MenuItem } from "@shared/editor/types";
import { Dictionary } from "~/hooks/useDictionary";
@@ -168,5 +169,12 @@ export default function blockMenuItems(dictionary: Dictionary): MenuItem[] {
keywords: "notice card suggestion",
attrs: { style: "tip" },
},
+ {
+ name: "container_notice",
+ title: dictionary.bibleNotice,
+ icon: BookmarkedIcon,
+ keywords: "notice card suggestion",
+ attrs: { style: "bible" },
+ },
];
}
diff --git a/app/hooks/useDictionary.ts b/app/hooks/useDictionary.ts
index 67001749..d8492e05 100644
--- a/app/hooks/useDictionary.ts
+++ b/app/hooks/useDictionary.ts
@@ -75,6 +75,8 @@ export default function useDictionary() {
showSource: t("Show source"),
warning: t("Warning"),
warningNotice: t("Warning notice"),
+ bible: t("Bible"),
+ bibleNotice: t("Bible quote"),
insertDate: t("Current date"),
insertTime: t("Current time"),
insertDateTime: t("Current date and time"),
diff --git a/app/typings/styled-components.d.ts b/app/typings/styled-components.d.ts
index c8e571d5..7d8aef81 100644
--- a/app/typings/styled-components.d.ts
+++ b/app/typings/styled-components.d.ts
@@ -54,6 +54,8 @@ declare module "styled-components" {
noticeTipText: string;
noticeWarningBackground: string;
noticeWarningText: string;
+ noticeBibleBackground: string;
+ noticeBibleText: string;
}
interface Colors {
diff --git a/shared/editor/components/Styles.ts b/shared/editor/components/Styles.ts
index e1ba4bfa..f6725fb5 100644
--- a/shared/editor/components/Styles.ts
+++ b/shared/editor/components/Styles.ts
@@ -511,6 +511,20 @@ h6 {
}
}
+.notice-block.bible {
+ background: ${transparentize(0.9, props.theme.noticeBibleBackground)};
+ border-left: 4px solid ${props.theme.noticeBibleBackground};
+ color: ${props.theme.noticeBibleText};
+
+ .icon {
+ color: ${props.theme.noticeBibleBackground};
+ }
+
+ a {
+ color: ${props.theme.noticeBibleText};
+ }
+}
+
blockquote {
margin: 0;
padding-left: 1.5em;
diff --git a/shared/editor/nodes/Notice.tsx b/shared/editor/nodes/Notice.tsx
index 158a0dfb..f297c343 100644
--- a/shared/editor/nodes/Notice.tsx
+++ b/shared/editor/nodes/Notice.tsx
@@ -1,5 +1,5 @@
import Token from "markdown-it/lib/token";
-import { WarningIcon, InfoIcon, StarredIcon } from "outline-icons";
+import { WarningIcon, InfoIcon, StarredIcon, BookmarkedIcon } from "outline-icons";
import { wrappingInputRule } from "prosemirror-inputrules";
import { NodeSpec, Node as ProsemirrorNode, NodeType } from "prosemirror-model";
import * as React from "react";
@@ -15,6 +15,7 @@ export default class Notice extends Node {
info: this.options.dictionary.info,
warning: this.options.dictionary.warning,
tip: this.options.dictionary.tip,
+ bible: this.options.dictionary.bible,
});
}
@@ -47,6 +48,8 @@ export default class Notice extends Node {
? "tip"
: dom.className.includes("warning")
? "warning"
+ : dom.className.includes("bible")
+ ? "bible"
: undefined,
}),
},
@@ -75,6 +78,8 @@ export default class Notice extends Node {
component = <StarredIcon color="currentColor" />;
} else if (node.attrs.style === "warning") {
component = <WarningIcon color="currentColor" />;
+ } else if (node.attrs.style === "bible") {
+ component = <BookmarkedIcon color="currentColor" />;
} else {
component = <InfoIcon color="currentColor" />;
}
diff --git a/shared/styles/theme.ts b/shared/styles/theme.ts
index 3ff5c7cf..f3809fd1 100644
--- a/shared/styles/theme.ts
+++ b/shared/styles/theme.ts
@@ -87,6 +87,8 @@ export const base = {
noticeTipText: colors.almostBlack,
noticeWarningBackground: "#d73a49",
noticeWarningText: colors.almostBlack,
+ noticeBibleBackground: "#e9f5f9",
+ noticeBibleText: colors.almostBlack,
breakpoints,
};