octalens-mentions 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/App-B-QcAxW7.js +29 -0
- package/dist/_chunks/App-B-QcAxW7.js.map +1 -0
- package/dist/_chunks/App-DjWYlFjn.mjs +29 -0
- package/dist/_chunks/App-DjWYlFjn.mjs.map +1 -0
- package/dist/_chunks/en-B4KWt_jN.js +1 -0
- package/dist/_chunks/en-B4KWt_jN.js.map +1 -0
- package/dist/_chunks/en-Byx4XI2L.mjs +1 -0
- package/dist/_chunks/en-Byx4XI2L.mjs.map +1 -0
- package/dist/_chunks/index-QtHFaCQE.js +179 -0
- package/dist/_chunks/index-QtHFaCQE.js.map +1 -0
- package/dist/_chunks/index-S3IY0oBe.mjs +180 -0
- package/dist/_chunks/index-S3IY0oBe.mjs.map +1 -0
- package/dist/admin/index.js +3 -1
- package/dist/admin/index.js.map +1 -0
- package/dist/admin/index.mjs +3 -1
- package/dist/admin/index.mjs.map +1 -0
- package/dist/admin/src/components/MentionsHome/index.d.ts +1 -0
- package/dist/admin/src/components/MentionsTable/index.d.ts +6 -0
- package/dist/admin/src/components/MentionsWidget/index.d.ts +1 -0
- package/dist/admin/src/constants.d.ts +5 -0
- package/dist/admin/src/hooks/useMentions.d.ts +6 -0
- package/dist/admin/src/types/index.d.ts +10 -0
- package/dist/admin/src/utils/getMentionTitle.d.ts +9 -0
- package/dist/server/index.js +32 -6
- package/dist/server/index.js.map +1 -0
- package/dist/server/index.mjs +32 -6
- package/dist/server/index.mjs.map +1 -0
- package/dist/server/src/index.d.ts +11 -0
- package/dist/server/src/routes/admin-api.d.ts +9 -0
- package/dist/server/src/routes/index.d.ts +11 -0
- package/package.json +1 -1
- package/dist/_chunks/App-B6IICgyu.js +0 -23
- package/dist/_chunks/App-BVO2PSDy.mjs +0 -23
- package/dist/_chunks/index-DWKoTnWi.js +0 -65
- package/dist/_chunks/index-Dwi45-n4.mjs +0 -66
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const admin = require("@strapi/strapi/admin");
|
|
5
|
+
const reactRouterDom = require("react-router-dom");
|
|
6
|
+
const designSystem = require("@strapi/design-system");
|
|
7
|
+
const index = require("./index-QtHFaCQE.js");
|
|
8
|
+
const HomePage = () => {
|
|
9
|
+
const { mentions, loading, error } = index.useMentions();
|
|
10
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Main, { children: [
|
|
11
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 8, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", children: "Mentions" }) }),
|
|
12
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { paddingLeft: 8, paddingRight: 8, children: [
|
|
13
|
+
loading && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: "Loading mentions..." }),
|
|
14
|
+
error && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { textColor: "danger600", children: [
|
|
15
|
+
"Error: ",
|
|
16
|
+
error.message
|
|
17
|
+
] }),
|
|
18
|
+
!loading && !error && /* @__PURE__ */ jsxRuntime.jsx(index.MentionsTable, { mentions })
|
|
19
|
+
] })
|
|
20
|
+
] });
|
|
21
|
+
};
|
|
22
|
+
const App = () => {
|
|
23
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
|
|
24
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { index: true, element: /* @__PURE__ */ jsxRuntime.jsx(HomePage, {}) }),
|
|
25
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "*", element: /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Error, {}) })
|
|
26
|
+
] });
|
|
27
|
+
};
|
|
28
|
+
exports.App = App;
|
|
29
|
+
//# sourceMappingURL=App-B-QcAxW7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App-B-QcAxW7.js","sources":["../../admin/src/pages/HomePage.tsx","../../admin/src/pages/App.tsx"],"sourcesContent":["import { Main, Box, Typography } from '@strapi/design-system';\nimport { MentionsTable } from '../components/MentionsTable';\nimport { useMentions } from '../hooks/useMentions';\n\nconst HomePage = () => {\n const { mentions, loading, error } = useMentions();\n\n return (\n <Main>\n <Box padding={8}>\n <Typography variant=\"alpha\">\n Mentions\n </Typography>\n </Box>\n <Box paddingLeft={8} paddingRight={8}> \n {loading && <Typography>Loading mentions...</Typography>}\n {error && <Typography textColor=\"danger600\">Error: {error.message}</Typography>}\n {!loading && !error && <MentionsTable mentions={mentions} />}\n </Box>\n </Main>\n );\n};\n\nexport { HomePage };\n","import { Page } from '@strapi/strapi/admin';\nimport { Routes, Route } from 'react-router-dom';\n\nimport { HomePage } from './HomePage';\n\nconst App = () => {\n return (\n <Routes>\n <Route index element={<HomePage />} />\n <Route path=\"*\" element={<Page.Error />} />\n </Routes>\n );\n};\n\nexport { App };\n"],"names":["useMentions","Main","jsx","Box","Typography","jsxs","MentionsTable","Routes","Route","Page"],"mappings":";;;;;;;AAIA,MAAM,WAAW,MAAM;AACrB,QAAM,EAAE,UAAU,SAAS,MAAA,IAAUA,MAAAA,YAAA;AAErC,yCACGC,mBAAA,EACC,UAAA;AAAA,IAAAC,2BAAAA,IAACC,aAAAA,KAAA,EAAI,SAAS,GACZ,UAAAD,2BAAAA,IAACE,2BAAW,SAAQ,SAAQ,sBAE5B,EAAA,CACF;AAAA,IACAC,2BAAAA,KAACF,aAAAA,KAAA,EAAI,aAAa,GAAG,cAAc,GAChC,UAAA;AAAA,MAAA,WAAWD,2BAAAA,IAACE,aAAAA,cAAW,UAAA,sBAAA,CAAmB;AAAA,MAC1C,SAASC,2BAAAA,KAACD,aAAAA,YAAA,EAAW,WAAU,aAAY,UAAA;AAAA,QAAA;AAAA,QAAQ,MAAM;AAAA,MAAA,GAAQ;AAAA,MACjE,CAAC,WAAW,CAAC,SAASF,2BAAAA,IAACI,MAAAA,iBAAc,SAAA,CAAoB;AAAA,IAAA,EAAA,CAC5D;AAAA,EAAA,GACF;AAEJ;AChBA,MAAM,MAAM,MAAM;AAChB,yCACGC,uBAAA,EACC,UAAA;AAAA,IAAAL,+BAACM,eAAAA,SAAM,OAAK,MAAC,SAASN,+BAAC,YAAS,GAAI;AAAA,IACpCA,+BAACM,eAAAA,SAAM,MAAK,KAAI,SAASN,2BAAAA,IAACO,MAAAA,KAAK,OAAL,CAAA,CAAW,EAAA,CAAI;AAAA,EAAA,GAC3C;AAEJ;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Page } from "@strapi/strapi/admin";
|
|
3
|
+
import { Routes, Route } from "react-router-dom";
|
|
4
|
+
import { Main, Box, Typography } from "@strapi/design-system";
|
|
5
|
+
import { u as useMentions, M as MentionsTable } from "./index-S3IY0oBe.mjs";
|
|
6
|
+
const HomePage = () => {
|
|
7
|
+
const { mentions, loading, error } = useMentions();
|
|
8
|
+
return /* @__PURE__ */ jsxs(Main, { children: [
|
|
9
|
+
/* @__PURE__ */ jsx(Box, { padding: 8, children: /* @__PURE__ */ jsx(Typography, { variant: "alpha", children: "Mentions" }) }),
|
|
10
|
+
/* @__PURE__ */ jsxs(Box, { paddingLeft: 8, paddingRight: 8, children: [
|
|
11
|
+
loading && /* @__PURE__ */ jsx(Typography, { children: "Loading mentions..." }),
|
|
12
|
+
error && /* @__PURE__ */ jsxs(Typography, { textColor: "danger600", children: [
|
|
13
|
+
"Error: ",
|
|
14
|
+
error.message
|
|
15
|
+
] }),
|
|
16
|
+
!loading && !error && /* @__PURE__ */ jsx(MentionsTable, { mentions })
|
|
17
|
+
] })
|
|
18
|
+
] });
|
|
19
|
+
};
|
|
20
|
+
const App = () => {
|
|
21
|
+
return /* @__PURE__ */ jsxs(Routes, { children: [
|
|
22
|
+
/* @__PURE__ */ jsx(Route, { index: true, element: /* @__PURE__ */ jsx(HomePage, {}) }),
|
|
23
|
+
/* @__PURE__ */ jsx(Route, { path: "*", element: /* @__PURE__ */ jsx(Page.Error, {}) })
|
|
24
|
+
] });
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
App
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=App-DjWYlFjn.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App-DjWYlFjn.mjs","sources":["../../admin/src/pages/HomePage.tsx","../../admin/src/pages/App.tsx"],"sourcesContent":["import { Main, Box, Typography } from '@strapi/design-system';\nimport { MentionsTable } from '../components/MentionsTable';\nimport { useMentions } from '../hooks/useMentions';\n\nconst HomePage = () => {\n const { mentions, loading, error } = useMentions();\n\n return (\n <Main>\n <Box padding={8}>\n <Typography variant=\"alpha\">\n Mentions\n </Typography>\n </Box>\n <Box paddingLeft={8} paddingRight={8}> \n {loading && <Typography>Loading mentions...</Typography>}\n {error && <Typography textColor=\"danger600\">Error: {error.message}</Typography>}\n {!loading && !error && <MentionsTable mentions={mentions} />}\n </Box>\n </Main>\n );\n};\n\nexport { HomePage };\n","import { Page } from '@strapi/strapi/admin';\nimport { Routes, Route } from 'react-router-dom';\n\nimport { HomePage } from './HomePage';\n\nconst App = () => {\n return (\n <Routes>\n <Route index element={<HomePage />} />\n <Route path=\"*\" element={<Page.Error />} />\n </Routes>\n );\n};\n\nexport { App };\n"],"names":[],"mappings":";;;;;AAIA,MAAM,WAAW,MAAM;AACrB,QAAM,EAAE,UAAU,SAAS,MAAA,IAAU,YAAA;AAErC,8BACG,MAAA,EACC,UAAA;AAAA,IAAA,oBAAC,KAAA,EAAI,SAAS,GACZ,UAAA,oBAAC,cAAW,SAAQ,SAAQ,sBAE5B,EAAA,CACF;AAAA,IACA,qBAAC,KAAA,EAAI,aAAa,GAAG,cAAc,GAChC,UAAA;AAAA,MAAA,WAAW,oBAAC,cAAW,UAAA,sBAAA,CAAmB;AAAA,MAC1C,SAAS,qBAAC,YAAA,EAAW,WAAU,aAAY,UAAA;AAAA,QAAA;AAAA,QAAQ,MAAM;AAAA,MAAA,GAAQ;AAAA,MACjE,CAAC,WAAW,CAAC,SAAS,oBAAC,iBAAc,SAAA,CAAoB;AAAA,IAAA,EAAA,CAC5D;AAAA,EAAA,GACF;AAEJ;AChBA,MAAM,MAAM,MAAM;AAChB,8BACG,QAAA,EACC,UAAA;AAAA,IAAA,oBAAC,SAAM,OAAK,MAAC,SAAS,oBAAC,YAAS,GAAI;AAAA,IACpC,oBAAC,SAAM,MAAK,KAAI,SAAS,oBAAC,KAAK,OAAL,CAAA,CAAW,EAAA,CAAI;AAAA,EAAA,GAC3C;AAEJ;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"en-B4KWt_jN.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"en-Byx4XI2L.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const icons = require("@strapi/icons");
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const designSystem = require("@strapi/design-system");
|
|
6
|
+
const admin = require("@strapi/strapi/admin");
|
|
7
|
+
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
8
|
+
const v = glob[path];
|
|
9
|
+
if (v) {
|
|
10
|
+
return typeof v === "function" ? v() : Promise.resolve(v);
|
|
11
|
+
}
|
|
12
|
+
return new Promise((_, reject) => {
|
|
13
|
+
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
|
14
|
+
reject.bind(
|
|
15
|
+
null,
|
|
16
|
+
new Error(
|
|
17
|
+
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
|
18
|
+
)
|
|
19
|
+
)
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const PLUGIN_ID = "octalens-mentions";
|
|
24
|
+
const Initializer = ({ setPlugin }) => {
|
|
25
|
+
const ref = react.useRef(setPlugin);
|
|
26
|
+
react.useEffect(() => {
|
|
27
|
+
ref.current(PLUGIN_ID);
|
|
28
|
+
}, []);
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
31
|
+
const PluginIcon = () => /* @__PURE__ */ jsxRuntime.jsx(icons.Globe, {});
|
|
32
|
+
const BASE_PATH = "/octalens-mentions";
|
|
33
|
+
const CONSTANTS = {
|
|
34
|
+
routes: {
|
|
35
|
+
MENTIONS_URL: BASE_PATH + "/mentions"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
function useMentions() {
|
|
39
|
+
const { get } = admin.useFetchClient();
|
|
40
|
+
const [mentions, setMentions] = react.useState([]);
|
|
41
|
+
const [loading, setLoading] = react.useState(true);
|
|
42
|
+
const [error, setError] = react.useState(null);
|
|
43
|
+
react.useEffect(() => {
|
|
44
|
+
const fetchMentions = async () => {
|
|
45
|
+
try {
|
|
46
|
+
setLoading(true);
|
|
47
|
+
setError(null);
|
|
48
|
+
const { data } = await get(CONSTANTS.routes.MENTIONS_URL);
|
|
49
|
+
const mentions2 = data?.data;
|
|
50
|
+
setMentions(mentions2 || []);
|
|
51
|
+
} catch (error2) {
|
|
52
|
+
console.error("Error fetching mentions:", error2);
|
|
53
|
+
setError(error2 instanceof Error ? error2 : new Error("Failed to fetch mentions"));
|
|
54
|
+
} finally {
|
|
55
|
+
setLoading(false);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
fetchMentions();
|
|
59
|
+
}, [get]);
|
|
60
|
+
return { mentions, loading, error };
|
|
61
|
+
}
|
|
62
|
+
const COL_COUNT = 7;
|
|
63
|
+
function MentionsTable({ mentions }) {
|
|
64
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: COL_COUNT, rowCount: mentions.length, children: [
|
|
65
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
|
|
66
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Checkbox, { "aria-label": "Select all entries" }) }),
|
|
67
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Title" }) }),
|
|
68
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Source" }) }),
|
|
69
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Keyword" }) }),
|
|
70
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Relevance Score" }) }),
|
|
71
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Comment" }) }),
|
|
72
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: "Actions" }) })
|
|
73
|
+
] }) }),
|
|
74
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: mentions.map((mention) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
|
|
75
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Checkbox, { "aria-label": `Select ${mention.title}` }) }),
|
|
76
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", fontWeight: "bold", children: mention.title || "Untitled" }) }),
|
|
77
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: mention.source }) }),
|
|
78
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: mention.keyword }) }),
|
|
79
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: mention.relevanceScore }) }),
|
|
80
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { textColor: "neutral600", ellipsis: true, children: [
|
|
81
|
+
mention.relevanceComment?.substring(0, 50),
|
|
82
|
+
mention.relevanceComment?.length > 50 ? "..." : ""
|
|
83
|
+
] }) }),
|
|
84
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { children: [
|
|
85
|
+
mention.url && /* @__PURE__ */ jsxRuntime.jsx(
|
|
86
|
+
designSystem.IconButton,
|
|
87
|
+
{
|
|
88
|
+
tag: "a",
|
|
89
|
+
href: mention.url,
|
|
90
|
+
target: "_blank",
|
|
91
|
+
rel: "noopener noreferrer",
|
|
92
|
+
label: "View source",
|
|
93
|
+
borderWidth: 0,
|
|
94
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {})
|
|
95
|
+
}
|
|
96
|
+
),
|
|
97
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
98
|
+
designSystem.IconButton,
|
|
99
|
+
{
|
|
100
|
+
onClick: () => console.log("edit", mention.documentId),
|
|
101
|
+
label: "Edit",
|
|
102
|
+
borderWidth: 0,
|
|
103
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {})
|
|
104
|
+
}
|
|
105
|
+
) }),
|
|
106
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
107
|
+
designSystem.IconButton,
|
|
108
|
+
{
|
|
109
|
+
onClick: () => console.log("delete", mention.documentId),
|
|
110
|
+
label: "Delete",
|
|
111
|
+
borderWidth: 0,
|
|
112
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {})
|
|
113
|
+
}
|
|
114
|
+
) })
|
|
115
|
+
] }) })
|
|
116
|
+
] }, mention.documentId)) })
|
|
117
|
+
] });
|
|
118
|
+
}
|
|
119
|
+
function MentionsWidget() {
|
|
120
|
+
const { mentions, loading, error } = useMentions();
|
|
121
|
+
if (loading) {
|
|
122
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: "Loading mentions..." }) });
|
|
123
|
+
}
|
|
124
|
+
if (error) {
|
|
125
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { textColor: "danger600", children: [
|
|
126
|
+
"Error: ",
|
|
127
|
+
error.message
|
|
128
|
+
] }) });
|
|
129
|
+
}
|
|
130
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(MentionsTable, { mentions }) });
|
|
131
|
+
}
|
|
132
|
+
const index = {
|
|
133
|
+
register(app) {
|
|
134
|
+
app.addMenuLink({
|
|
135
|
+
to: `plugins/${PLUGIN_ID}`,
|
|
136
|
+
icon: PluginIcon,
|
|
137
|
+
intlLabel: {
|
|
138
|
+
id: `${PLUGIN_ID}.plugin.name`,
|
|
139
|
+
defaultMessage: PLUGIN_ID
|
|
140
|
+
},
|
|
141
|
+
Component: async () => {
|
|
142
|
+
const { App } = await Promise.resolve().then(() => require("./App-B-QcAxW7.js"));
|
|
143
|
+
return App;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
app.widgets.register({
|
|
147
|
+
icon: icons.Globe,
|
|
148
|
+
title: {
|
|
149
|
+
id: `${PLUGIN_ID}.mentions-widget.title`,
|
|
150
|
+
defaultMessage: "Social Mentions"
|
|
151
|
+
},
|
|
152
|
+
component: () => Promise.resolve(MentionsWidget),
|
|
153
|
+
pluginId: PLUGIN_ID,
|
|
154
|
+
id: "mentions-widget"
|
|
155
|
+
});
|
|
156
|
+
app.registerPlugin({
|
|
157
|
+
id: PLUGIN_ID,
|
|
158
|
+
initializer: Initializer,
|
|
159
|
+
isReady: false,
|
|
160
|
+
name: PLUGIN_ID
|
|
161
|
+
});
|
|
162
|
+
},
|
|
163
|
+
async registerTrads({ locales }) {
|
|
164
|
+
return Promise.all(
|
|
165
|
+
locales.map(async (locale) => {
|
|
166
|
+
try {
|
|
167
|
+
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("./en-B4KWt_jN.js")) }), `./translations/${locale}.json`, 3);
|
|
168
|
+
return { data, locale };
|
|
169
|
+
} catch {
|
|
170
|
+
return { data: {}, locale };
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
exports.MentionsTable = MentionsTable;
|
|
177
|
+
exports.index = index;
|
|
178
|
+
exports.useMentions = useMentions;
|
|
179
|
+
//# sourceMappingURL=index-QtHFaCQE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-QtHFaCQE.js","sources":["../../admin/src/pluginId.ts","../../admin/src/components/Initializer.tsx","../../admin/src/components/PluginIcon.tsx","../../admin/src/constants.ts","../../admin/src/hooks/useMentions.ts","../../admin/src/components/MentionsTable/index.tsx","../../admin/src/components/MentionsWidget/index.tsx","../../admin/src/index.ts"],"sourcesContent":["export const PLUGIN_ID = 'octalens-mentions';\n","import { useEffect, useRef } from 'react';\n\nimport { PLUGIN_ID } from '../pluginId';\n\ntype InitializerProps = {\n setPlugin: (id: string) => void;\n};\n\nconst Initializer = ({ setPlugin }: InitializerProps) => {\n const ref = useRef(setPlugin);\n\n useEffect(() => {\n ref.current(PLUGIN_ID);\n }, []);\n\n return null;\n};\n\nexport { Initializer };\n","import { Globe } from '@strapi/icons';\n\nconst PluginIcon = () => <Globe />;\n\nexport { PluginIcon };\n","const BASE_PATH = '/octalens-mentions';\n\nexport const CONSTANTS = {\n routes: {\n MENTIONS_URL: BASE_PATH + '/mentions',\n },\n};\n","import { useEffect, useState } from 'react';\nimport { useFetchClient } from '@strapi/strapi/admin';\nimport type { IMention } from '../types';\nimport { CONSTANTS } from '../constants';\n\nexport function useMentions() {\n const { get } = useFetchClient();\n const [mentions, setMentions] = useState<IMention[]>([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n const fetchMentions = async () => {\n try {\n setLoading(true);\n setError(null);\n const { data } = await get(CONSTANTS.routes.MENTIONS_URL);\n const mentions = data?.data;\n setMentions(mentions || []);\n } catch (error) {\n console.error('Error fetching mentions:', error);\n setError(error instanceof Error ? error : new Error('Failed to fetch mentions'));\n } finally {\n setLoading(false);\n }\n };\n\n fetchMentions();\n }, [get]);\n\n return { mentions, loading, error };\n}\n","import {\n Table,\n Thead,\n Tbody,\n Tr,\n Td,\n Th,\n Typography,\n Checkbox,\n VisuallyHidden,\n Flex,\n Box,\n IconButton,\n} from '@strapi/design-system';\nimport { Pencil, Trash, Eye } from '@strapi/icons';\nimport type { IMention } from '../../types';\n\nconst COL_COUNT = 7;\n\ninterface MentionsTableProps {\n readonly mentions: IMention[];\n}\n\nexport function MentionsTable({ mentions }: MentionsTableProps) {\n return (\n <Table colCount={COL_COUNT} rowCount={mentions.length}>\n <Thead>\n <Tr>\n <Th>\n <Checkbox aria-label=\"Select all entries\" />\n </Th>\n <Th>\n <Typography variant=\"sigma\">Title</Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">Source</Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">Keyword</Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">Relevance Score</Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">Comment</Typography>\n </Th>\n <Th>\n <VisuallyHidden>Actions</VisuallyHidden>\n </Th>\n </Tr>\n </Thead>\n <Tbody>\n {mentions.map((mention) => (\n <Tr key={mention.documentId}>\n <Td>\n <Checkbox aria-label={`Select ${mention.title}`} />\n </Td>\n <Td>\n <Typography textColor=\"neutral800\" fontWeight=\"bold\">\n {mention.title || 'Untitled'}\n </Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">{mention.source}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">{mention.keyword}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">{mention.relevanceScore}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral600\" ellipsis>\n {mention.relevanceComment?.substring(0, 50)}\n {mention.relevanceComment?.length > 50 ? '...' : ''}\n </Typography>\n </Td>\n <Td>\n <Flex>\n {mention.url && (\n <IconButton\n tag=\"a\"\n href={mention.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n label=\"View source\"\n borderWidth={0}\n >\n <Eye />\n </IconButton>\n )}\n <Box paddingLeft={1}>\n <IconButton\n onClick={() => console.log('edit', mention.documentId)}\n label=\"Edit\"\n borderWidth={0}\n >\n <Pencil />\n </IconButton>\n </Box>\n <Box paddingLeft={1}>\n <IconButton\n onClick={() => console.log('delete', mention.documentId)}\n label=\"Delete\"\n borderWidth={0}\n >\n <Trash />\n </IconButton>\n </Box>\n </Flex>\n </Td>\n </Tr>\n ))}\n </Tbody>\n </Table>\n );\n}\n","import { Box, Typography } from '@strapi/design-system';\nimport { useMentions } from '../../hooks/useMentions';\nimport { MentionsTable } from '../MentionsTable';\n\nexport function MentionsWidget() {\n const { mentions, loading, error } = useMentions();\n\n if (loading) {\n return (\n <Box padding={4}>\n <Typography>Loading mentions...</Typography>\n </Box>\n );\n }\n\n if (error) {\n return (\n <Box padding={4}>\n <Typography textColor=\"danger600\">Error: {error.message}</Typography>\n </Box>\n );\n }\n\n return (\n <Box padding={4}>\n <MentionsTable mentions={mentions} />\n </Box>\n );\n}\n","import { Globe } from \"@strapi/icons\";\n\nimport { PLUGIN_ID } from './pluginId';\nimport { Initializer } from './components/Initializer';\nimport { PluginIcon } from './components/PluginIcon';\nimport { MentionsWidget } from \"./components/MentionsWidget\";\n\nexport default {\n register(app: any) {\n app.addMenuLink({\n to: `plugins/${PLUGIN_ID}`,\n icon: PluginIcon,\n intlLabel: {\n id: `${PLUGIN_ID}.plugin.name`,\n defaultMessage: PLUGIN_ID,\n },\n Component: async () => {\n const { App } = await import('./pages/App');\n\n return App;\n },\n });\n\n app.widgets.register({\n icon: Globe,\n title: {\n id: `${PLUGIN_ID}.mentions-widget.title`,\n defaultMessage: \"Social Mentions\"\n },\n component: () => Promise.resolve(MentionsWidget),\n pluginId: PLUGIN_ID,\n id: \"mentions-widget\"\n })\n\n app.registerPlugin({\n id: PLUGIN_ID,\n initializer: Initializer,\n isReady: false,\n name: PLUGIN_ID,\n });\n\n },\n\n async registerTrads({ locales }: { locales: string[] }) {\n return Promise.all(\n locales.map(async (locale) => {\n try {\n const { default: data } = await import(`./translations/${locale}.json`);\n\n return { data, locale };\n } catch {\n return { data: {}, locale };\n }\n })\n );\n },\n};\n"],"names":["useRef","useEffect","jsx","Globe","useFetchClient","useState","mentions","error","Table","Thead","Tr","Th","Checkbox","Typography","VisuallyHid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AAA;AAAAA,MACN,OAAO;AAAA,QACL,IAAI,GAAG,SAAS;AAAA,QAChB,gBAAgB;AAAA,MAAA;AAAA,MAElB,WAAW,MAAM,QAAQ,QAAQ,cAAc;AAAA,MAC/C,UAAU;AAAA,MACV,IAAI;AAAA,IAAA,CACL;AAED,QAAI,eAAe;AAAA,MACjB,IAAI;AAAA,MACJ,aAAa;AAAA,MACb,SAAS;AAAA,MACT,MAAM;AAAA,IAAA,CACP;AAAA,EAEH;AAAA,EAEA,MAAM,cAAc,EAAE,WAAkC;AACtD,WAAO,QAAQ;AAAA,MACb,QAAQ,IAAI,OAAO,WAAW;AAC5B,YAAI;AACF,gBAAM,EAAE,SAAS,KAAA,IAAS,MAAM,qCAAA,uBAAA,OAAA,EAAA,0BAAA,MAAA,QAAA,QAAA,EAAA,KAAA,MAAA,QAAA,kBAAA,CAAA,EAAA,CAAA,GAAA,kBAAA,MAAA,SAAA,CAAA;AAEhC,iBAAO,EAAE,MAAM,OAAA;AAAA,QACjB,QAAQ;AACN,iBAAO,EAAE,MAAM,CAAA,GAAI,OAAA;AAAA,QACrB;AAAA,MACF,CAAC;AAAA,IAAA;AAAA,EAEL;AACF;;;;"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { Globe, Eye, Pencil, Trash } from "@strapi/icons";
|
|
2
|
+
import { useRef, useEffect, useState } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Table, Thead, Tr, Th, Checkbox, Typography, VisuallyHidden, Tbody, Td, Flex, IconButton, Box } from "@strapi/design-system";
|
|
5
|
+
import { useFetchClient } from "@strapi/strapi/admin";
|
|
6
|
+
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
7
|
+
const v = glob[path];
|
|
8
|
+
if (v) {
|
|
9
|
+
return typeof v === "function" ? v() : Promise.resolve(v);
|
|
10
|
+
}
|
|
11
|
+
return new Promise((_, reject) => {
|
|
12
|
+
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
|
13
|
+
reject.bind(
|
|
14
|
+
null,
|
|
15
|
+
new Error(
|
|
16
|
+
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
|
17
|
+
)
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const PLUGIN_ID = "octalens-mentions";
|
|
23
|
+
const Initializer = ({ setPlugin }) => {
|
|
24
|
+
const ref = useRef(setPlugin);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
ref.current(PLUGIN_ID);
|
|
27
|
+
}, []);
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
const PluginIcon = () => /* @__PURE__ */ jsx(Globe, {});
|
|
31
|
+
const BASE_PATH = "/octalens-mentions";
|
|
32
|
+
const CONSTANTS = {
|
|
33
|
+
routes: {
|
|
34
|
+
MENTIONS_URL: BASE_PATH + "/mentions"
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function useMentions() {
|
|
38
|
+
const { get } = useFetchClient();
|
|
39
|
+
const [mentions, setMentions] = useState([]);
|
|
40
|
+
const [loading, setLoading] = useState(true);
|
|
41
|
+
const [error, setError] = useState(null);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
const fetchMentions = async () => {
|
|
44
|
+
try {
|
|
45
|
+
setLoading(true);
|
|
46
|
+
setError(null);
|
|
47
|
+
const { data } = await get(CONSTANTS.routes.MENTIONS_URL);
|
|
48
|
+
const mentions2 = data?.data;
|
|
49
|
+
setMentions(mentions2 || []);
|
|
50
|
+
} catch (error2) {
|
|
51
|
+
console.error("Error fetching mentions:", error2);
|
|
52
|
+
setError(error2 instanceof Error ? error2 : new Error("Failed to fetch mentions"));
|
|
53
|
+
} finally {
|
|
54
|
+
setLoading(false);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
fetchMentions();
|
|
58
|
+
}, [get]);
|
|
59
|
+
return { mentions, loading, error };
|
|
60
|
+
}
|
|
61
|
+
const COL_COUNT = 7;
|
|
62
|
+
function MentionsTable({ mentions }) {
|
|
63
|
+
return /* @__PURE__ */ jsxs(Table, { colCount: COL_COUNT, rowCount: mentions.length, children: [
|
|
64
|
+
/* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
|
|
65
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Checkbox, { "aria-label": "Select all entries" }) }),
|
|
66
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Title" }) }),
|
|
67
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Source" }) }),
|
|
68
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Keyword" }) }),
|
|
69
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Relevance Score" }) }),
|
|
70
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Comment" }) }),
|
|
71
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(VisuallyHidden, { children: "Actions" }) })
|
|
72
|
+
] }) }),
|
|
73
|
+
/* @__PURE__ */ jsx(Tbody, { children: mentions.map((mention) => /* @__PURE__ */ jsxs(Tr, { children: [
|
|
74
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Checkbox, { "aria-label": `Select ${mention.title}` }) }),
|
|
75
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", fontWeight: "bold", children: mention.title || "Untitled" }) }),
|
|
76
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: mention.source }) }),
|
|
77
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: mention.keyword }) }),
|
|
78
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: mention.relevanceScore }) }),
|
|
79
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Typography, { textColor: "neutral600", ellipsis: true, children: [
|
|
80
|
+
mention.relevanceComment?.substring(0, 50),
|
|
81
|
+
mention.relevanceComment?.length > 50 ? "..." : ""
|
|
82
|
+
] }) }),
|
|
83
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Flex, { children: [
|
|
84
|
+
mention.url && /* @__PURE__ */ jsx(
|
|
85
|
+
IconButton,
|
|
86
|
+
{
|
|
87
|
+
tag: "a",
|
|
88
|
+
href: mention.url,
|
|
89
|
+
target: "_blank",
|
|
90
|
+
rel: "noopener noreferrer",
|
|
91
|
+
label: "View source",
|
|
92
|
+
borderWidth: 0,
|
|
93
|
+
children: /* @__PURE__ */ jsx(Eye, {})
|
|
94
|
+
}
|
|
95
|
+
),
|
|
96
|
+
/* @__PURE__ */ jsx(Box, { paddingLeft: 1, children: /* @__PURE__ */ jsx(
|
|
97
|
+
IconButton,
|
|
98
|
+
{
|
|
99
|
+
onClick: () => console.log("edit", mention.documentId),
|
|
100
|
+
label: "Edit",
|
|
101
|
+
borderWidth: 0,
|
|
102
|
+
children: /* @__PURE__ */ jsx(Pencil, {})
|
|
103
|
+
}
|
|
104
|
+
) }),
|
|
105
|
+
/* @__PURE__ */ jsx(Box, { paddingLeft: 1, children: /* @__PURE__ */ jsx(
|
|
106
|
+
IconButton,
|
|
107
|
+
{
|
|
108
|
+
onClick: () => console.log("delete", mention.documentId),
|
|
109
|
+
label: "Delete",
|
|
110
|
+
borderWidth: 0,
|
|
111
|
+
children: /* @__PURE__ */ jsx(Trash, {})
|
|
112
|
+
}
|
|
113
|
+
) })
|
|
114
|
+
] }) })
|
|
115
|
+
] }, mention.documentId)) })
|
|
116
|
+
] });
|
|
117
|
+
}
|
|
118
|
+
function MentionsWidget() {
|
|
119
|
+
const { mentions, loading, error } = useMentions();
|
|
120
|
+
if (loading) {
|
|
121
|
+
return /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsx(Typography, { children: "Loading mentions..." }) });
|
|
122
|
+
}
|
|
123
|
+
if (error) {
|
|
124
|
+
return /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsxs(Typography, { textColor: "danger600", children: [
|
|
125
|
+
"Error: ",
|
|
126
|
+
error.message
|
|
127
|
+
] }) });
|
|
128
|
+
}
|
|
129
|
+
return /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsx(MentionsTable, { mentions }) });
|
|
130
|
+
}
|
|
131
|
+
const index = {
|
|
132
|
+
register(app) {
|
|
133
|
+
app.addMenuLink({
|
|
134
|
+
to: `plugins/${PLUGIN_ID}`,
|
|
135
|
+
icon: PluginIcon,
|
|
136
|
+
intlLabel: {
|
|
137
|
+
id: `${PLUGIN_ID}.plugin.name`,
|
|
138
|
+
defaultMessage: PLUGIN_ID
|
|
139
|
+
},
|
|
140
|
+
Component: async () => {
|
|
141
|
+
const { App } = await import("./App-DjWYlFjn.mjs");
|
|
142
|
+
return App;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
app.widgets.register({
|
|
146
|
+
icon: Globe,
|
|
147
|
+
title: {
|
|
148
|
+
id: `${PLUGIN_ID}.mentions-widget.title`,
|
|
149
|
+
defaultMessage: "Social Mentions"
|
|
150
|
+
},
|
|
151
|
+
component: () => Promise.resolve(MentionsWidget),
|
|
152
|
+
pluginId: PLUGIN_ID,
|
|
153
|
+
id: "mentions-widget"
|
|
154
|
+
});
|
|
155
|
+
app.registerPlugin({
|
|
156
|
+
id: PLUGIN_ID,
|
|
157
|
+
initializer: Initializer,
|
|
158
|
+
isReady: false,
|
|
159
|
+
name: PLUGIN_ID
|
|
160
|
+
});
|
|
161
|
+
},
|
|
162
|
+
async registerTrads({ locales }) {
|
|
163
|
+
return Promise.all(
|
|
164
|
+
locales.map(async (locale) => {
|
|
165
|
+
try {
|
|
166
|
+
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("./en-Byx4XI2L.mjs") }), `./translations/${locale}.json`, 3);
|
|
167
|
+
return { data, locale };
|
|
168
|
+
} catch {
|
|
169
|
+
return { data: {}, locale };
|
|
170
|
+
}
|
|
171
|
+
})
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
export {
|
|
176
|
+
MentionsTable as M,
|
|
177
|
+
index as i,
|
|
178
|
+
useMentions as u
|
|
179
|
+
};
|
|
180
|
+
//# sourceMappingURL=index-S3IY0oBe.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-S3IY0oBe.mjs","sources":["../../admin/src/pluginId.ts","../../admin/src/components/Initializer.tsx","../../admin/src/components/PluginIcon.tsx","../../admin/src/constants.ts","../../admin/src/hooks/useMentions.ts","../../admin/src/components/MentionsTable/index.tsx","../../admin/src/components/MentionsWidget/index.tsx","../../admin/src/index.ts"],"sourcesContent":["export const PLUGIN_ID = 'octalens-mentions';\n","import { useEffect, useRef } from 'react';\n\nimport { PLUGIN_ID } from '../pluginId';\n\ntype InitializerProps = {\n setPlugin: (id: string) => void;\n};\n\nconst Initializer = ({ setPlugin }: InitializerProps) => {\n const ref = useRef(setPlugin);\n\n useEffect(() => {\n ref.current(PLUGIN_ID);\n }, []);\n\n return null;\n};\n\nexport { Initializer };\n","import { Globe } from '@strapi/icons';\n\nconst PluginIcon = () => <Globe />;\n\nexport { PluginIcon };\n","const BASE_PATH = '/octalens-mentions';\n\nexport const CONSTANTS = {\n routes: {\n MENTIONS_URL: BASE_PATH + '/mentions',\n },\n};\n","import { useEffect, useState } from 'react';\nimport { useFetchClient } from '@strapi/strapi/admin';\nimport type { IMention } from '../types';\nimport { CONSTANTS } from '../constants';\n\nexport function useMentions() {\n const { get } = useFetchClient();\n const [mentions, setMentions] = useState<IMention[]>([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n const fetchMentions = async () => {\n try {\n setLoading(true);\n setError(null);\n const { data } = await get(CONSTANTS.routes.MENTIONS_URL);\n const mentions = data?.data;\n setMentions(mentions || []);\n } catch (error) {\n console.error('Error fetching mentions:', error);\n setError(error instanceof Error ? error : new Error('Failed to fetch mentions'));\n } finally {\n setLoading(false);\n }\n };\n\n fetchMentions();\n }, [get]);\n\n return { mentions, loading, error };\n}\n","import {\n Table,\n Thead,\n Tbody,\n Tr,\n Td,\n Th,\n Typography,\n Checkbox,\n VisuallyHidden,\n Flex,\n Box,\n IconButton,\n} from '@strapi/design-system';\nimport { Pencil, Trash, Eye } from '@strapi/icons';\nimport type { IMention } from '../../types';\n\nconst COL_COUNT = 7;\n\ninterface MentionsTableProps {\n readonly mentions: IMention[];\n}\n\nexport function MentionsTable({ mentions }: MentionsTableProps) {\n return (\n <Table colCount={COL_COUNT} rowCount={mentions.length}>\n <Thead>\n <Tr>\n <Th>\n <Checkbox aria-label=\"Select all entries\" />\n </Th>\n <Th>\n <Typography variant=\"sigma\">Title</Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">Source</Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">Keyword</Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">Relevance Score</Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">Comment</Typography>\n </Th>\n <Th>\n <VisuallyHidden>Actions</VisuallyHidden>\n </Th>\n </Tr>\n </Thead>\n <Tbody>\n {mentions.map((mention) => (\n <Tr key={mention.documentId}>\n <Td>\n <Checkbox aria-label={`Select ${mention.title}`} />\n </Td>\n <Td>\n <Typography textColor=\"neutral800\" fontWeight=\"bold\">\n {mention.title || 'Untitled'}\n </Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">{mention.source}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">{mention.keyword}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">{mention.relevanceScore}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral600\" ellipsis>\n {mention.relevanceComment?.substring(0, 50)}\n {mention.relevanceComment?.length > 50 ? '...' : ''}\n </Typography>\n </Td>\n <Td>\n <Flex>\n {mention.url && (\n <IconButton\n tag=\"a\"\n href={mention.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n label=\"View source\"\n borderWidth={0}\n >\n <Eye />\n </IconButton>\n )}\n <Box paddingLeft={1}>\n <IconButton\n onClick={() => console.log('edit', mention.documentId)}\n label=\"Edit\"\n borderWidth={0}\n >\n <Pencil />\n </IconButton>\n </Box>\n <Box paddingLeft={1}>\n <IconButton\n onClick={() => console.log('delete', mention.documentId)}\n label=\"Delete\"\n borderWidth={0}\n >\n <Trash />\n </IconButton>\n </Box>\n </Flex>\n </Td>\n </Tr>\n ))}\n </Tbody>\n </Table>\n );\n}\n","import { Box, Typography } from '@strapi/design-system';\nimport { useMentions } from '../../hooks/useMentions';\nimport { MentionsTable } from '../MentionsTable';\n\nexport function MentionsWidget() {\n const { mentions, loading, error } = useMentions();\n\n if (loading) {\n return (\n <Box padding={4}>\n <Typography>Loading mentions...</Typography>\n </Box>\n );\n }\n\n if (error) {\n return (\n <Box padding={4}>\n <Typography textColor=\"danger600\">Error: {error.message}</Typography>\n </Box>\n );\n }\n\n return (\n <Box padding={4}>\n <MentionsTable mentions={mentions} />\n </Box>\n );\n}\n","import { Globe } from \"@strapi/icons\";\n\nimport { PLUGIN_ID } from './pluginId';\nimport { Initializer } from './components/Initializer';\nimport { PluginIcon } from './components/PluginIcon';\nimport { MentionsWidget } from \"./components/MentionsWidget\";\n\nexport default {\n register(app: any) {\n app.addMenuLink({\n to: `plugins/${PLUGIN_ID}`,\n icon: PluginIcon,\n intlLabel: {\n id: `${PLUGIN_ID}.plugin.name`,\n defaultMessage: PLUGIN_ID,\n },\n Component: async () => {\n const { App } = await import('./pages/App');\n\n return App;\n },\n });\n\n app.widgets.register({\n icon: Globe,\n title: {\n id: `${PLUGIN_ID}.mentions-widget.title`,\n defaultMessage: \"Social Mentions\"\n },\n component: () => Promise.resolve(MentionsWidget),\n pluginId: PLUGIN_ID,\n id: \"mentions-widget\"\n })\n\n app.registerPlugin({\n id: PLUGIN_ID,\n initializer: Initializer,\n isReady: false,\n name: PLUGIN_ID,\n });\n\n },\n\n async registerTrads({ locales }: { locales: string[] }) {\n return Promise.all(\n locales.map(async (locale) => {\n try {\n const { default: data } = await import(`./translations/${locale}.json`);\n\n return { data, locale };\n } catch {\n return { data: {}, locale };\n }\n })\n );\n },\n};\n"],"names":["mentions","error"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,YAAY;ACQzB,MAAM,cAAc,CAAC,EAAE,gBAAkC;AACvD,QAAM,MAAM,OAAO,SAAS;AAE5B,YAAU,MAAM;AACd,QAAI,QAAQ,SAAS;AAAA,EACvB,GAAG,CAAA,CAAE;AAEL,SAAO;AACT;ACdA,MAAM,aAAa,MAAM,oBAAC,OAAA,EAAM;ACFhC,MAAM,YAAY;AAEX,MAAM,YAAY;AAAA,EACvB,QAAQ;AAAA,IACN,cAAc,YAAY;AAAA,EAAA;AAE9B;ACDO,SAAS,cAAc;AAC5B,QAAM,EAAE,IAAA,IAAQ,eAAA;AAChB,QAAM,CAAC,UAAU,WAAW,IAAI,SAAqB,CAAA,CAAE;AACvD,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,IAAI;AAC3C,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAuB,IAAI;AAErD,YAAU,MAAM;AACd,UAAM,gBAAgB,YAAY;AAChC,UAAI;AACF,mBAAW,IAAI;AACf,iBAAS,IAAI;AACb,cAAM,EAAE,KAAA,IAAS,MAAM,IAAI,UAAU,OAAO,YAAY;AACxD,cAAMA,YAAW,MAAM;AACvB,oBAAYA,aAAY,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AA,EAEH;AAAA,EAEA,MAAM,cAAc,EAAE,WAAkC;AACtD,WAAO,QAAQ;AAAA,MACb,QAAQ,IAAI,OAAO,WAAW;AAC5B,YAAI;AACF,gBAAM,EAAE,SAAS,KAAA,IAAS,MAAM,qCAAA,uBAAA,OAAA,EAAA,0BAAA,MAAA,OAAA,mBAAA,EAAA,CAAA,GAAA,kBAAA,MAAA,SAAA,CAAA;AAEhC,iBAAO,EAAE,MAAM,OAAA;AAAA,QACjB,QAAQ;AACN,iBAAO,EAAE,MAAM,CAAA,GAAI,OAAA;AAAA,QACrB;AAAA,MACF,CAAC;AAAA,IAAA;AAAA,EAEL;AACF;"}
|
package/dist/admin/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/dist/admin/index.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function MentionsHome(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function MentionsWidget(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the display title for a mention.
|
|
3
|
+
* If title is empty or "Untitled", uses the first 100 characters from body.
|
|
4
|
+
*
|
|
5
|
+
* @param title - The mention title
|
|
6
|
+
* @param body - The mention body content
|
|
7
|
+
* @returns The display title
|
|
8
|
+
*/
|
|
9
|
+
export declare function getMentionTitle(title: string, body: string): string;
|
package/dist/server/index.js
CHANGED
|
@@ -22,10 +22,10 @@ const options = {
|
|
|
22
22
|
};
|
|
23
23
|
const pluginOptions = {
|
|
24
24
|
"content-manager": {
|
|
25
|
-
visible:
|
|
25
|
+
visible: false
|
|
26
26
|
},
|
|
27
27
|
"content-type-builder": {
|
|
28
|
-
visible:
|
|
28
|
+
visible: false
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
const attributes = {
|
|
@@ -104,14 +104,25 @@ const contentTypes = {
|
|
|
104
104
|
};
|
|
105
105
|
const { createCoreController } = require("@strapi/strapi").factories;
|
|
106
106
|
const mention$1 = createCoreController("plugin::octalens-mentions.mention");
|
|
107
|
+
function getMentionTitle(title, body) {
|
|
108
|
+
if (!title || title.trim() === "" || title.toLowerCase() === "untitled") {
|
|
109
|
+
if (!body) return "Untitled";
|
|
110
|
+
const excerpt = body.substring(0, 100).trim();
|
|
111
|
+
return excerpt.length === 100 ? `${excerpt}...` : excerpt;
|
|
112
|
+
}
|
|
113
|
+
return title;
|
|
114
|
+
}
|
|
107
115
|
const controller = ({ strapi }) => ({
|
|
108
116
|
async ingest(ctx) {
|
|
109
117
|
const requestBody = ctx.request.body;
|
|
110
118
|
if (!requestBody?.data) return ctx.badRequest("Missing data in request body");
|
|
119
|
+
const rawTitle = requestBody.data?.title || "";
|
|
120
|
+
const rawBody = requestBody.data?.body || "";
|
|
121
|
+
const generatedTitle = getMentionTitle(rawTitle, rawBody);
|
|
111
122
|
const mentionData = {
|
|
112
123
|
action: requestBody.action,
|
|
113
|
-
title:
|
|
114
|
-
body:
|
|
124
|
+
title: generatedTitle,
|
|
125
|
+
body: rawBody,
|
|
115
126
|
url: requestBody.data?.url || "",
|
|
116
127
|
timestamp: requestBody.data?.timestamp || "",
|
|
117
128
|
imageUrl: requestBody.data?.imageUrl || "",
|
|
@@ -149,7 +160,17 @@ const controllers = {
|
|
|
149
160
|
};
|
|
150
161
|
const middlewares = {};
|
|
151
162
|
const policies = {};
|
|
152
|
-
const
|
|
163
|
+
const adminApiRoutes = [
|
|
164
|
+
{
|
|
165
|
+
method: "GET",
|
|
166
|
+
path: "/mentions",
|
|
167
|
+
handler: "mention.find",
|
|
168
|
+
config: {
|
|
169
|
+
policies: ["admin::isAuthenticatedAdmin"]
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
];
|
|
173
|
+
const contentApiRoutes = [
|
|
153
174
|
{
|
|
154
175
|
method: "GET",
|
|
155
176
|
path: "/mentions",
|
|
@@ -197,9 +218,13 @@ const contentApi = [
|
|
|
197
218
|
}
|
|
198
219
|
];
|
|
199
220
|
const routes = {
|
|
221
|
+
"admin-api": {
|
|
222
|
+
type: "admin",
|
|
223
|
+
routes: [...adminApiRoutes]
|
|
224
|
+
},
|
|
200
225
|
"content-api": {
|
|
201
226
|
type: "content-api",
|
|
202
|
-
routes: [...
|
|
227
|
+
routes: [...contentApiRoutes]
|
|
203
228
|
}
|
|
204
229
|
};
|
|
205
230
|
const { createCoreService } = require("@strapi/strapi").factories;
|
|
@@ -220,3 +245,4 @@ const index = {
|
|
|
220
245
|
middlewares
|
|
221
246
|
};
|
|
222
247
|
module.exports = index;
|
|
248
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../server/src/bootstrap.ts","../../server/src/destroy.ts","../../server/src/register.ts","../../server/src/config/index.ts","../../server/src/content-types/mention/index.ts","../../server/src/content-types/index.ts","../../server/src/controllers/mention/index.ts","../../server/src/controllers/ingest/index.ts","../../server/src/controllers/index.ts","../../server/src/middlewares/index.ts","../../server/src/policies/index.ts","../../server/src/routes/admin-api.ts","../../server/src/routes/content-api.ts","../../server/src/routes/index.ts","../../server/src/services/mention/index.ts","../../server/src/services/index.ts","../../server/src/index.ts"],"sourcesContent":["import type { Core } from '@strapi/strapi';\n\nconst bootstrap = ({ strapi }: { strapi: Core.Strapi }) => {\n // bootstrap phase\n};\n\nexport default bootstrap;\n","import type { Core } from '@strapi/strapi';\n\nconst destroy = ({ strapi }: { strapi: Core.Strapi }) => {\n // destroy phase\n};\n\nexport default destroy;\n","import type { Core } from '@strapi/strapi';\n\nconst register = ({ strapi }: { strapi: Core.Strapi }) => {\n // register phase\n};\n\nexport default register;\n","export default {\n default: {},\n validator() {},\n};\n","import schema from './schema.json';\n\nexport default {\n schema,\n};","import mention from './mention';\n\nexport default {\n mention,\n};","'use strict';\n\n/**\n * mention controller\n */\n\nconst { createCoreController } = require('@strapi/strapi').factories;\n\nexport default createCoreController('plugin::octalens-mentions.mention');","import type { Core } from '@strapi/strapi';\n\n/**\n * Gets the display title for a mention.\n * If title is empty or \"Untitled\", uses the first 100 characters from body.\n */\nfunction getMentionTitle(title: string, body: string): string {\n if (!title || title.trim() === '' || title.toLowerCase() === 'untitled') {\n if (!body) return 'Untitled';\n\n const excerpt = body.substring(0, 100).trim();\n return excerpt.length === 100 ? `${excerpt}...` : excerpt;\n }\n\n return title;\n}\n\nconst controller = ({ strapi }: { strapi: Core.Strapi }) => ({\n async ingest(ctx) {\n const requestBody = ctx.request.body;\n\n if (!requestBody?.data) return ctx.badRequest('Missing data in request body');\n\n const rawTitle = requestBody.data?.title || '';\n const rawBody = requestBody.data?.body || '';\n const generatedTitle = getMentionTitle(rawTitle, rawBody);\n\n const mentionData = {\n action: requestBody.action,\n title: generatedTitle,\n body: rawBody,\n url: requestBody.data?.url || '',\n timestamp: requestBody.data?.timestamp || '',\n imageUrl: requestBody.data?.imageUrl || '',\n author: requestBody.data?.author || '',\n authorProfileLink: requestBody.data?.authorProfileLink || '',\n source: requestBody.data?.source || '',\n sourceId: requestBody.data?.sourceId || '',\n relevanceScore: requestBody.data?.relevanceScore || '',\n relevanceComment: requestBody.data?.relevanceComment || '',\n keyword: requestBody.data?.keyword || '',\n bookmarked: requestBody.data?.bookmarked || false,\n language: requestBody.data?.language || '',\n sentimentLabel: requestBody.data?.sentimentLabel || '',\n viewId: requestBody.data?.viewId || null,\n viewName: requestBody.data?.viewName || '',\n subreddit: requestBody.data?.subreddit || '',\n };\n\n console.log('###############################');\n console.log('Parsed mention data:', mentionData);\n console.log('###############################');\n\n try {\n const mention = await strapi.service('plugin::octalens-mentions.mention').create({\n data: mentionData,\n });\n\n ctx.body = { data: mention };\n } catch (error) {\n console.error('Error creating mention:', error);\n ctx.throw(500, 'Failed to create mention');\n }\n },\n});\n\nexport default controller;\n","import mention from './mention';\nimport ingest from './ingest';\n\nexport default {\n mention,\n ingest\n};","export default {};\n","export default {};\n","export default [\n {\n method: 'GET',\n path: '/mentions',\n handler: 'mention.find',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n];\n","export default [\n {\n method: 'GET',\n path: '/mentions',\n handler: 'mention.find',\n config: {\n policies: [],\n },\n },\n {\n method: 'GET',\n path: '/mentions/:id',\n handler: 'mention.findOne',\n config: {\n policies: [],\n },\n },\n {\n method: 'DELETE',\n path: '/mentions/:id',\n handler: 'mention.delete',\n config: {\n policies: [],\n },\n },\n {\n method: 'PUT',\n path: '/mentions/:id',\n handler: 'mention.update',\n config: {\n policies: [],\n },\n },\n {\n method: 'POST',\n path: '/mentions',\n handler: 'mention.create',\n config: {\n policies: [],\n },\n },\n {\n method: 'POST',\n path: '/ingest',\n handler: 'ingest.ingest'\n }\n];\n","\"use strict\";\n\nimport adminApiRoutes from \"./admin-api\";\nimport contentApiRoutes from \"./content-api\";\n\n\nexport default {\n \"admin-api\": {\n type: \"admin\",\n routes: [...adminApiRoutes],\n },\n \"content-api\": {\n type: \"content-api\",\n routes: [...contentApiRoutes],\n },\n};","'use strict';\n\n/**\n * mention service\n */\n\nconst { createCoreService } = require('@strapi/strapi').factories;\n\nexport default createCoreService('plugin::octalens-mentions.mention');\n","import mention from './mention';\n\nexport default {\n mention,\n};\n","/**\n * Application methods\n */\nimport bootstrap from './bootstrap';\nimport destroy from './destroy';\nimport register from './register';\n\n/**\n * Plugin server methods\n */\nimport config from './config';\nimport contentTypes from './content-types';\nimport controllers from './controllers';\nimport middlewares from './middlewares';\nimport policies from './policies';\nimport routes from './routes';\nimport services from './services';\n\nexport default {\n register,\n bootstrap,\n destroy,\n config,\n controllers,\n routes,\n services,\n contentTypes,\n policies,\n middlewares,\n};\n"],"names":["mention","ingest"],"mappings":";AAEA,MAAM,YAAY,CAAC,EAAE,a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AA,EAEF;AAAA,IACE,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,MACN,UAAU,CAAA;AAAA,IAAC;AAAA,EACb;AAAA,EAEF;AAAA,IACE,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,MACN,UAAU,CAAA;AAAA,IAAC;AAAA,EACb;AAAA,EAEF;AAAA,IACE,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,MACN,UAAU,CAAA;AAAA,IAAC;AAAA,EACb;AAAA,EAEF;AAAA,IACE,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,MACN,UAAU,CAAA;AAAA,IAAC;AAAA,EACb;AAAA,EAEF;AAAA,IACE,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,EAAA;AAEb;ACxCA,MAAA,SAAe;AAAA,EACb,aAAa;AAAA,IACX,MAAM;AAAA,IACN,QAAQ,CAAC,GAAG,cAAc;AAAA,EAAA;AAAA,EAE5B,eAAe;AAAA,IACb,MAAM;AAAA,IACN,QAAQ,CAAC,GAAG,gBAAgB;AAAA,EAAA;AAEhC;ACTA,MAAM,EAAE,kBAAA,IAAsB,QAAQ,gBAAgB,EAAE;AAExD,MAAA,UAAe,kBAAkB,mCAAmC;ACNpE,MAAA,WAAe;AAAA,EACb;AACF;ACcA,MAAA,QAAe;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;"}
|
package/dist/server/index.mjs
CHANGED
|
@@ -21,10 +21,10 @@ const options = {
|
|
|
21
21
|
};
|
|
22
22
|
const pluginOptions = {
|
|
23
23
|
"content-manager": {
|
|
24
|
-
visible:
|
|
24
|
+
visible: false
|
|
25
25
|
},
|
|
26
26
|
"content-type-builder": {
|
|
27
|
-
visible:
|
|
27
|
+
visible: false
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
const attributes = {
|
|
@@ -103,14 +103,25 @@ const contentTypes = {
|
|
|
103
103
|
};
|
|
104
104
|
const { createCoreController } = require("@strapi/strapi").factories;
|
|
105
105
|
const mention$1 = createCoreController("plugin::octalens-mentions.mention");
|
|
106
|
+
function getMentionTitle(title, body) {
|
|
107
|
+
if (!title || title.trim() === "" || title.toLowerCase() === "untitled") {
|
|
108
|
+
if (!body) return "Untitled";
|
|
109
|
+
const excerpt = body.substring(0, 100).trim();
|
|
110
|
+
return excerpt.length === 100 ? `${excerpt}...` : excerpt;
|
|
111
|
+
}
|
|
112
|
+
return title;
|
|
113
|
+
}
|
|
106
114
|
const controller = ({ strapi }) => ({
|
|
107
115
|
async ingest(ctx) {
|
|
108
116
|
const requestBody = ctx.request.body;
|
|
109
117
|
if (!requestBody?.data) return ctx.badRequest("Missing data in request body");
|
|
118
|
+
const rawTitle = requestBody.data?.title || "";
|
|
119
|
+
const rawBody = requestBody.data?.body || "";
|
|
120
|
+
const generatedTitle = getMentionTitle(rawTitle, rawBody);
|
|
110
121
|
const mentionData = {
|
|
111
122
|
action: requestBody.action,
|
|
112
|
-
title:
|
|
113
|
-
body:
|
|
123
|
+
title: generatedTitle,
|
|
124
|
+
body: rawBody,
|
|
114
125
|
url: requestBody.data?.url || "",
|
|
115
126
|
timestamp: requestBody.data?.timestamp || "",
|
|
116
127
|
imageUrl: requestBody.data?.imageUrl || "",
|
|
@@ -148,7 +159,17 @@ const controllers = {
|
|
|
148
159
|
};
|
|
149
160
|
const middlewares = {};
|
|
150
161
|
const policies = {};
|
|
151
|
-
const
|
|
162
|
+
const adminApiRoutes = [
|
|
163
|
+
{
|
|
164
|
+
method: "GET",
|
|
165
|
+
path: "/mentions",
|
|
166
|
+
handler: "mention.find",
|
|
167
|
+
config: {
|
|
168
|
+
policies: ["admin::isAuthenticatedAdmin"]
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
];
|
|
172
|
+
const contentApiRoutes = [
|
|
152
173
|
{
|
|
153
174
|
method: "GET",
|
|
154
175
|
path: "/mentions",
|
|
@@ -196,9 +217,13 @@ const contentApi = [
|
|
|
196
217
|
}
|
|
197
218
|
];
|
|
198
219
|
const routes = {
|
|
220
|
+
"admin-api": {
|
|
221
|
+
type: "admin",
|
|
222
|
+
routes: [...adminApiRoutes]
|
|
223
|
+
},
|
|
199
224
|
"content-api": {
|
|
200
225
|
type: "content-api",
|
|
201
|
-
routes: [...
|
|
226
|
+
routes: [...contentApiRoutes]
|
|
202
227
|
}
|
|
203
228
|
};
|
|
204
229
|
const { createCoreService } = require("@strapi/strapi").factories;
|
|
@@ -221,3 +246,4 @@ const index = {
|
|
|
221
246
|
export {
|
|
222
247
|
index as default
|
|
223
248
|
};
|
|
249
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../server/src/bootstrap.ts","../../server/src/destroy.ts","../../server/src/register.ts","../../server/src/config/index.ts","../../server/src/content-types/mention/index.ts","../../server/src/content-types/index.ts","../../server/src/controllers/mention/index.ts","../../server/src/controllers/ingest/index.ts","../../server/src/controllers/index.ts","../../server/src/middlewares/index.ts","../../server/src/policies/index.ts","../../server/src/routes/admin-api.ts","../../server/src/routes/content-api.ts","../../server/src/routes/index.ts","../../server/src/services/mention/index.ts","../../server/src/services/index.ts","../../server/src/index.ts"],"sourcesContent":["import type { Core } from '@strapi/strapi';\n\nconst bootstrap = ({ strapi }: { strapi: Core.Strapi }) => {\n // bootstrap phase\n};\n\nexport default bootstrap;\n","import type { Core } from '@strapi/strapi';\n\nconst destroy = ({ strapi }: { strapi: Core.Strapi }) => {\n // destroy phase\n};\n\nexport default destroy;\n","import type { Core } from '@strapi/strapi';\n\nconst register = ({ strapi }: { strapi: Core.Strapi }) => {\n // register phase\n};\n\nexport default register;\n","export default {\n default: {},\n validator() {},\n};\n","import schema from './schema.json';\n\nexport default {\n schema,\n};","import mention from './mention';\n\nexport default {\n mention,\n};","'use strict';\n\n/**\n * mention controller\n */\n\nconst { createCoreController } = require('@strapi/strapi').factories;\n\nexport default createCoreController('plugin::octalens-mentions.mention');","import type { Core } from '@strapi/strapi';\n\n/**\n * Gets the display title for a mention.\n * If title is empty or \"Untitled\", uses the first 100 characters from body.\n */\nfunction getMentionTitle(title: string, body: string): string {\n if (!title || title.trim() === '' || title.toLowerCase() === 'untitled') {\n if (!body) return 'Untitled';\n\n const excerpt = body.substring(0, 100).trim();\n return excerpt.length === 100 ? `${excerpt}...` : excerpt;\n }\n\n return title;\n}\n\nconst controller = ({ strapi }: { strapi: Core.Strapi }) => ({\n async ingest(ctx) {\n const requestBody = ctx.request.body;\n\n if (!requestBody?.data) return ctx.badRequest('Missing data in request body');\n\n const rawTitle = requestBody.data?.title || '';\n const rawBody = requestBody.data?.body || '';\n const generatedTitle = getMentionTitle(rawTitle, rawBody);\n\n const mentionData = {\n action: requestBody.action,\n title: generatedTitle,\n body: rawBody,\n url: requestBody.data?.url || '',\n timestamp: requestBody.data?.timestamp || '',\n imageUrl: requestBody.data?.imageUrl || '',\n author: requestBody.data?.author || '',\n authorProfileLink: requestBody.data?.authorProfileLink || '',\n source: requestBody.data?.source || '',\n sourceId: requestBody.data?.sourceId || '',\n relevanceScore: requestBody.data?.relevanceScore || '',\n relevanceComment: requestBody.data?.relevanceComment || '',\n keyword: requestBody.data?.keyword || '',\n bookmarked: requestBody.data?.bookmarked || false,\n language: requestBody.data?.language || '',\n sentimentLabel: requestBody.data?.sentimentLabel || '',\n viewId: requestBody.data?.viewId || null,\n viewName: requestBody.data?.viewName || '',\n subreddit: requestBody.data?.subreddit || '',\n };\n\n console.log('###############################');\n console.log('Parsed mention data:', mentionData);\n console.log('###############################');\n\n try {\n const mention = await strapi.service('plugin::octalens-mentions.mention').create({\n data: mentionData,\n });\n\n ctx.body = { data: mention };\n } catch (error) {\n console.error('Error creating mention:', error);\n ctx.throw(500, 'Failed to create mention');\n }\n },\n});\n\nexport default controller;\n","import mention from './mention';\nimport ingest from './ingest';\n\nexport default {\n mention,\n ingest\n};","export default {};\n","export default {};\n","export default [\n {\n method: 'GET',\n path: '/mentions',\n handler: 'mention.find',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n];\n","export default [\n {\n method: 'GET',\n path: '/mentions',\n handler: 'mention.find',\n config: {\n policies: [],\n },\n },\n {\n method: 'GET',\n path: '/mentions/:id',\n handler: 'mention.findOne',\n config: {\n policies: [],\n },\n },\n {\n method: 'DELETE',\n path: '/mentions/:id',\n handler: 'mention.delete',\n config: {\n policies: [],\n },\n },\n {\n method: 'PUT',\n path: '/mentions/:id',\n handler: 'mention.update',\n config: {\n policies: [],\n },\n },\n {\n method: 'POST',\n path: '/mentions',\n handler: 'mention.create',\n config: {\n policies: [],\n },\n },\n {\n method: 'POST',\n path: '/ingest',\n handler: 'ingest.ingest'\n }\n];\n","\"use strict\";\n\nimport adminApiRoutes from \"./admin-api\";\nimport contentApiRoutes from \"./content-api\";\n\n\nexport default {\n \"admin-api\": {\n type: \"admin\",\n routes: [...adminApiRoutes],\n },\n \"content-api\": {\n type: \"content-api\",\n routes: [...contentApiRoutes],\n },\n};","'use strict';\n\n/**\n * mention service\n */\n\nconst { createCoreService } = require('@strapi/strapi').factories;\n\nexport default createCoreService('plugin::octalens-mentions.mention');\n","import mention from './mention';\n\nexport default {\n mention,\n};\n","/**\n * Application methods\n */\nimport bootstrap from './bootstrap';\nimport destroy from './destroy';\nimport register from './register';\n\n/**\n * Plugin server methods\n */\nimport config from './config';\nimport contentTypes from './content-types';\nimport controllers from './controllers';\nimport middlewares from './middlewares';\nimport policies from './policies';\nimport routes from './routes';\nimport services from './services';\n\nexport default {\n register,\n bootstrap,\n destroy,\n config,\n controllers,\n routes,\n services,\n contentTypes,\n policies,\n middlewares,\n};\n"],"names":["mention","ingest"],"mappings":"AAEA,MAAM,YAAY,CAAC,EAAE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AAAA,EAEF;AAAA,IACE,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,MACN,UAAU,CAAA;AAAA,IAAC;AAAA,EACb;AAAA,EAEF;AAAA,IACE,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,MACN,UAAU,CAAA;AAAA,IAAC;AAAA,EACb;AAAA,EAEF;AAAA,IACE,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,MACN,UAAU,CAAA;AAAA,IAAC;AAAA,EACb;AAAA,EAEF;AAAA,IACE,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,MACN,UAAU,CAAA;AAAA,IAAC;AAAA,EACb;AAAA,EAEF;AAAA,IACE,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,EAAA;AAEb;ACxCA,MAAA,SAAe;AAAA,EACb,aAAa;AAAA,IACX,MAAM;AAAA,IACN,QAAQ,CAAC,GAAG,cAAc;AAAA,EAAA;AAAA,EAE5B,eAAe;AAAA,IACb,MAAM;AAAA,IACN,QAAQ,CAAC,GAAG,gBAAgB;AAAA,EAAA;AAEhC;ACTA,MAAM,EAAE,kBAAA,IAAsB,QAAQ,gBAAgB,EAAE;AAExD,MAAA,UAAe,kBAAkB,mCAAmC;ACNpE,MAAA,WAAe;AAAA,EACb;AACF;ACcA,MAAA,QAAe;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;"}
|
|
@@ -21,6 +21,17 @@ declare const _default: {
|
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
23
|
routes: {
|
|
24
|
+
"admin-api": {
|
|
25
|
+
type: string;
|
|
26
|
+
routes: {
|
|
27
|
+
method: string;
|
|
28
|
+
path: string;
|
|
29
|
+
handler: string;
|
|
30
|
+
config: {
|
|
31
|
+
policies: string[];
|
|
32
|
+
};
|
|
33
|
+
}[];
|
|
34
|
+
};
|
|
24
35
|
"content-api": {
|
|
25
36
|
type: string;
|
|
26
37
|
routes: ({
|
package/package.json
CHANGED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const admin = require("@strapi/strapi/admin");
|
|
5
|
-
const reactRouterDom = require("react-router-dom");
|
|
6
|
-
const designSystem = require("@strapi/design-system");
|
|
7
|
-
const reactIntl = require("react-intl");
|
|
8
|
-
const index = require("./index-DWKoTnWi.js");
|
|
9
|
-
const getTranslation = (id) => `${index.PLUGIN_ID}.${id}`;
|
|
10
|
-
const HomePage = () => {
|
|
11
|
-
const { formatMessage } = reactIntl.useIntl();
|
|
12
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Main, { children: /* @__PURE__ */ jsxRuntime.jsxs("h1", { children: [
|
|
13
|
-
"Welcome to ",
|
|
14
|
-
formatMessage({ id: getTranslation("plugin.name") })
|
|
15
|
-
] }) });
|
|
16
|
-
};
|
|
17
|
-
const App = () => {
|
|
18
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
|
|
19
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { index: true, element: /* @__PURE__ */ jsxRuntime.jsx(HomePage, {}) }),
|
|
20
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "*", element: /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Error, {}) })
|
|
21
|
-
] });
|
|
22
|
-
};
|
|
23
|
-
exports.App = App;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Page } from "@strapi/strapi/admin";
|
|
3
|
-
import { Routes, Route } from "react-router-dom";
|
|
4
|
-
import { Main } from "@strapi/design-system";
|
|
5
|
-
import { useIntl } from "react-intl";
|
|
6
|
-
import { P as PLUGIN_ID } from "./index-Dwi45-n4.mjs";
|
|
7
|
-
const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
|
|
8
|
-
const HomePage = () => {
|
|
9
|
-
const { formatMessage } = useIntl();
|
|
10
|
-
return /* @__PURE__ */ jsx(Main, { children: /* @__PURE__ */ jsxs("h1", { children: [
|
|
11
|
-
"Welcome to ",
|
|
12
|
-
formatMessage({ id: getTranslation("plugin.name") })
|
|
13
|
-
] }) });
|
|
14
|
-
};
|
|
15
|
-
const App = () => {
|
|
16
|
-
return /* @__PURE__ */ jsxs(Routes, { children: [
|
|
17
|
-
/* @__PURE__ */ jsx(Route, { index: true, element: /* @__PURE__ */ jsx(HomePage, {}) }),
|
|
18
|
-
/* @__PURE__ */ jsx(Route, { path: "*", element: /* @__PURE__ */ jsx(Page.Error, {}) })
|
|
19
|
-
] });
|
|
20
|
-
};
|
|
21
|
-
export {
|
|
22
|
-
App
|
|
23
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const react = require("react");
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const icons = require("@strapi/icons");
|
|
5
|
-
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
6
|
-
const v = glob[path];
|
|
7
|
-
if (v) {
|
|
8
|
-
return typeof v === "function" ? v() : Promise.resolve(v);
|
|
9
|
-
}
|
|
10
|
-
return new Promise((_, reject) => {
|
|
11
|
-
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
|
12
|
-
reject.bind(
|
|
13
|
-
null,
|
|
14
|
-
new Error(
|
|
15
|
-
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
|
16
|
-
)
|
|
17
|
-
)
|
|
18
|
-
);
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
const PLUGIN_ID = "octalens-mentions";
|
|
22
|
-
const Initializer = ({ setPlugin }) => {
|
|
23
|
-
const ref = react.useRef(setPlugin);
|
|
24
|
-
react.useEffect(() => {
|
|
25
|
-
ref.current(PLUGIN_ID);
|
|
26
|
-
}, []);
|
|
27
|
-
return null;
|
|
28
|
-
};
|
|
29
|
-
const PluginIcon = () => /* @__PURE__ */ jsxRuntime.jsx(icons.PuzzlePiece, {});
|
|
30
|
-
const index = {
|
|
31
|
-
register(app) {
|
|
32
|
-
app.addMenuLink({
|
|
33
|
-
to: `plugins/${PLUGIN_ID}`,
|
|
34
|
-
icon: PluginIcon,
|
|
35
|
-
intlLabel: {
|
|
36
|
-
id: `${PLUGIN_ID}.plugin.name`,
|
|
37
|
-
defaultMessage: PLUGIN_ID
|
|
38
|
-
},
|
|
39
|
-
Component: async () => {
|
|
40
|
-
const { App } = await Promise.resolve().then(() => require("./App-B6IICgyu.js"));
|
|
41
|
-
return App;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
app.registerPlugin({
|
|
45
|
-
id: PLUGIN_ID,
|
|
46
|
-
initializer: Initializer,
|
|
47
|
-
isReady: false,
|
|
48
|
-
name: PLUGIN_ID
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
async registerTrads({ locales }) {
|
|
52
|
-
return Promise.all(
|
|
53
|
-
locales.map(async (locale) => {
|
|
54
|
-
try {
|
|
55
|
-
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("./en-B4KWt_jN.js")) }), `./translations/${locale}.json`, 3);
|
|
56
|
-
return { data, locale };
|
|
57
|
-
} catch {
|
|
58
|
-
return { data: {}, locale };
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
exports.PLUGIN_ID = PLUGIN_ID;
|
|
65
|
-
exports.index = index;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { useRef, useEffect } from "react";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { PuzzlePiece } from "@strapi/icons";
|
|
4
|
-
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
5
|
-
const v = glob[path];
|
|
6
|
-
if (v) {
|
|
7
|
-
return typeof v === "function" ? v() : Promise.resolve(v);
|
|
8
|
-
}
|
|
9
|
-
return new Promise((_, reject) => {
|
|
10
|
-
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
|
11
|
-
reject.bind(
|
|
12
|
-
null,
|
|
13
|
-
new Error(
|
|
14
|
-
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
|
15
|
-
)
|
|
16
|
-
)
|
|
17
|
-
);
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
const PLUGIN_ID = "octalens-mentions";
|
|
21
|
-
const Initializer = ({ setPlugin }) => {
|
|
22
|
-
const ref = useRef(setPlugin);
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
ref.current(PLUGIN_ID);
|
|
25
|
-
}, []);
|
|
26
|
-
return null;
|
|
27
|
-
};
|
|
28
|
-
const PluginIcon = () => /* @__PURE__ */ jsx(PuzzlePiece, {});
|
|
29
|
-
const index = {
|
|
30
|
-
register(app) {
|
|
31
|
-
app.addMenuLink({
|
|
32
|
-
to: `plugins/${PLUGIN_ID}`,
|
|
33
|
-
icon: PluginIcon,
|
|
34
|
-
intlLabel: {
|
|
35
|
-
id: `${PLUGIN_ID}.plugin.name`,
|
|
36
|
-
defaultMessage: PLUGIN_ID
|
|
37
|
-
},
|
|
38
|
-
Component: async () => {
|
|
39
|
-
const { App } = await import("./App-BVO2PSDy.mjs");
|
|
40
|
-
return App;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
app.registerPlugin({
|
|
44
|
-
id: PLUGIN_ID,
|
|
45
|
-
initializer: Initializer,
|
|
46
|
-
isReady: false,
|
|
47
|
-
name: PLUGIN_ID
|
|
48
|
-
});
|
|
49
|
-
},
|
|
50
|
-
async registerTrads({ locales }) {
|
|
51
|
-
return Promise.all(
|
|
52
|
-
locales.map(async (locale) => {
|
|
53
|
-
try {
|
|
54
|
-
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("./en-Byx4XI2L.mjs") }), `./translations/${locale}.json`, 3);
|
|
55
|
-
return { data, locale };
|
|
56
|
-
} catch {
|
|
57
|
-
return { data: {}, locale };
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
export {
|
|
64
|
-
PLUGIN_ID as P,
|
|
65
|
-
index as i
|
|
66
|
-
};
|