From 305e1657cf5987ffd750f8feeb6d361b68cb6043 Mon Sep 17 00:00:00 2001 From: "R.Piontik" Date: Fri, 26 Aug 2022 10:13:50 +0300 Subject: [PATCH 1/6] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20=D0=B2=D1=8B=D0=B1=D0=B8=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D1=8C=20=D1=81=D0=B5=D1=80=D0=B2=D0=B5=D1=80=20=D1=80=D0=B5?= =?UTF-8?q?=D0=BD=D0=B4=D0=B5=D1=80=D0=B8=D0=BD=D0=B3=D0=B0=20=D0=B8=20?= =?UTF-8?q?=D0=B4=D0=B2=D0=B8=D0=B6=D0=BE=D0=BA=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D1=81=D0=B1=D0=BE=D1=80=D0=BA=D0=B8=20=D0=B2=20=D1=80=D0=B5?= =?UTF-8?q?=D0=B6=D0=B8=D0=BC=D0=B5=20=D0=BF=D0=BB=D0=B0=D0=B3=D0=B8=D0=BD?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.json | 1 + config.js | 5 +- public/documentation/root.yaml | 2 +- public/documentation/template.pml | 6 + src/components/Docs/DocMixin.js | 3 +- src/components/Schema/PlantUML.vue | 2 +- src/components/Schema/Schema.vue | 14 +- src/helpers/plantuml.js | 8 +- src/helpers/requests.js | 8 +- src/main.js | 3 + src/manifest/manifest_parser.js | 2 - src/plugin.html | 249 +++++++++++++++++++++++++++++ 12 files changed, 285 insertions(+), 18 deletions(-) create mode 100644 public/documentation/template.pml diff --git a/.eslintrc.json b/.eslintrc.json index e5553906..56a6a865 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -5,6 +5,7 @@ "node": true, "jest": true }, + "ignorePatterns": ["**/public/libs/*.js"], "extends": [ "eslint:recommended", "plugin:vue/recommended" diff --git a/config.js b/config.js index 232ea4e3..7448e81b 100644 --- a/config.js +++ b/config.js @@ -48,6 +48,9 @@ if (process.env.VUE_APP_DOCHUB_MODE === 'plugin') { } } -config.pumlServer = process.env.VUE_APP_PLANTUML_SERVER || 'www.plantuml.com/plantuml/svg/'; +config.pumlServer = + window.$PAPI?.settings?.render?.server + || process.env.VUE_APP_PLANTUML_SERVER + || 'www.plantuml.com/plantuml/svg/'; export default config; diff --git a/public/documentation/root.yaml b/public/documentation/root.yaml index a70c7ada..a8617ebf 100755 --- a/public/documentation/root.yaml +++ b/public/documentation/root.yaml @@ -1,4 +1,4 @@ # Манифест описывающий сам DocHub imports: # Подключение манифестов - docs/root.yaml - - arch/root.yaml + - arch/root.yaml \ No newline at end of file diff --git a/public/documentation/template.pml b/public/documentation/template.pml new file mode 100644 index 00000000..6045b2f9 --- /dev/null +++ b/public/documentation/template.pml @@ -0,0 +1,6 @@ +@startuml +{{$self}} +{{#.}} +{{from}} -> {{to}}: {{title}} +{{/.}} +@enduml \ No newline at end of file diff --git a/src/components/Docs/DocMixin.js b/src/components/Docs/DocMixin.js index c04e4b00..0b485a5c 100644 --- a/src/components/Docs/DocMixin.js +++ b/src/components/Docs/DocMixin.js @@ -31,10 +31,11 @@ export default { return this.manifest?.docs?.[this.document] || {}; }, url() { - return this.profile ? + const result = this.profile ? docs.urlFromProfile(this.profile, (this.$store.state.sources.find((item) => item.path === `/docs/${this.document}`) || {}).location ): ''; + return `${result}?id=${this.document}`; } }, props: { diff --git a/src/components/Schema/PlantUML.vue b/src/components/Schema/PlantUML.vue index f9148b03..c90f1d70 100644 --- a/src/components/Schema/PlantUML.vue +++ b/src/components/Schema/PlantUML.vue @@ -265,7 +265,7 @@ this.isLoading = true; this.$nextTick(() => { - const request= window.$IDE_PLUGIN + const request= window.$PAPI?.settings?.render?.external === false ? window.$PAPI.renderPlantUML(this.uml) : axios({url: plantUML.svgURL(this.uml)}); request.then((response) => { diff --git a/src/components/Schema/Schema.vue b/src/components/Schema/Schema.vue index 3e8914f2..2a447e7f 100644 --- a/src/components/Schema/Schema.vue +++ b/src/components/Schema/Schema.vue @@ -101,16 +101,14 @@ notation = this.schema.uml.$notation; } - switch((process.env.VUE_APP_DOCHUB_RENDER_CORE || '').toLowerCase()) { + const renderCore = ( + process.env.VUE_APP_DOCHUB_RENDER_CORE || window.$PAPI?.settings?.render?.mode || '' + ).toLowerCase(); + + switch(renderCore) { case 'smetana': uml += '!pragma layout smetana\n'; break; case 'elk': uml += '!pragma layout elk\n'; break; - case 'graphviz': break; - default: - if (process.env.VUE_APP_DOCHUB_MODE === 'plugin') { - uml += '!pragma layout smetana\n'; - } else { - uml += '!pragma layout elk\n'; - } + case 'graphviz': uml += '!pragma layout graphviz\n'; break; } switch (notation.toLowerCase()) { diff --git a/src/helpers/plantuml.js b/src/helpers/plantuml.js index db4b6632..808cf5f4 100644 --- a/src/helpers/plantuml.js +++ b/src/helpers/plantuml.js @@ -1,4 +1,6 @@ import config from '../../config'; +import requests from '../helpers/requests'; + export default { svgURL(uml) { return this.compress(uml); @@ -34,6 +36,10 @@ export default { // eslint-disable-next-line no-undef let compressor = new Zopfli.RawDeflate(arr); let compressed = compressor.compress(); - return `${window.location.protocol}//${config.pumlServer}` + this.encode64_(compressed); + let serverURL = config.pumlServer; + if (!requests.isURL(serverURL)) { + serverURL = `${window?.location?.protocol || 'https:'}//${config.pumlServer}`; + } + return serverURL + this.encode64_(compressed); } }; diff --git a/src/helpers/requests.js b/src/helpers/requests.js index d4101d4c..d7e7d690 100644 --- a/src/helpers/requests.js +++ b/src/helpers/requests.js @@ -46,10 +46,12 @@ if(window.$PAPI) { export default { axios, + isURL(url) { + // eslint-disable-next-line no-useless-escape + return url.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.?[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/); + }, isExtarnalURI(uri) { - return (uri.slice(0, window.origin.length) !== window.origin) - // eslint-disable-next-line no-useless-escape - && uri.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/); + return (uri.slice(0, window.origin.length) !== window.origin) && this.isURL(uri); }, getSourceRoot(){ if(window.$IDE_PLUGIN) { diff --git a/src/main.js b/src/main.js index db803551..5198b4b0 100644 --- a/src/main.js +++ b/src/main.js @@ -30,6 +30,9 @@ import '@/assets/styles/main.css'; window.Vue = Vue; window.Router = router; +// eslint-disable-next-line no-console +console.info(window.$PAPI); + Vue.use(Vuex); Vue.use(Vuetify); Vue.use(VueCookie); diff --git a/src/manifest/manifest_parser.js b/src/manifest/manifest_parser.js index 6d1389c3..40b26bfd 100644 --- a/src/manifest/manifest_parser.js +++ b/src/manifest/manifest_parser.js @@ -227,8 +227,6 @@ const parser = { // Подключение манифеста import(uri, subimport) { - // eslint-disable-next-line no-console - console.info('>>>>>IMPORT ', uri, 'subimport=', subimport); if (!subimport) { this.mergeMap = []; this.manifest = { [this.MODE_AS_IS] : this.merge({}, this.makeBaseManifest(), uri)}; diff --git a/src/plugin.html b/src/plugin.html index bb7e7a55..3f315627 100644 --- a/src/plugin.html +++ b/src/plugin.html @@ -4,6 +4,254 @@ +