@lblod/ember-rdfa-editor-lblod-plugins 0.1.0

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.
Files changed (94) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +37 -0
  3. package/addon-main.js +4 -0
  4. package/dist/_app_/components/besluit-type-plugin/besluit-type-select.js +1 -0
  5. package/dist/_app_/components/besluit-type-plugin/toolbar-dropdown.js +1 -0
  6. package/dist/_app_/components/citaten-plugin/citaat-card.js +1 -0
  7. package/dist/_app_/components/citaten-plugin/citaat-insert.js +1 -0
  8. package/dist/_app_/components/citaten-plugin/citations/article-list.js +1 -0
  9. package/dist/_app_/components/citaten-plugin/citations/article-preview.js +1 -0
  10. package/dist/_app_/components/citaten-plugin/citations/decision-detail.js +1 -0
  11. package/dist/_app_/components/citaten-plugin/citations/decision-list.js +1 -0
  12. package/dist/_app_/components/citaten-plugin/citations/decision-preview.js +1 -0
  13. package/dist/_app_/components/citaten-plugin/citations/search-modal.js +1 -0
  14. package/dist/_app_/components/citaten-plugin/helpers/alert-load-error.js +1 -0
  15. package/dist/_app_/components/citaten-plugin/helpers/alert-no-items.js +1 -0
  16. package/dist/_app_/components/import-snippet-plugin/card.js +1 -0
  17. package/dist/_app_/components/rdfa-date-plugin/rdfa-date-plugin-card.js +1 -0
  18. package/dist/_app_/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +1 -0
  19. package/dist/_app_/components/rdfa-date-plugin/rdfa-date-time-picker.js +1 -0
  20. package/dist/_app_/components/standard-template-plugin/template-card.js +1 -0
  21. package/dist/_app_/components/standard-template-plugin/template-provider.js +1 -0
  22. package/dist/_app_/components/table-of-contents-plugin/card.js +1 -0
  23. package/dist/_app_/components/table-of-contents-plugin/inline-components/outline.js +1 -0
  24. package/dist/_app_/components/table-of-contents-plugin/inline-components/table-of-contents.js +1 -0
  25. package/dist/_app_/initializers/plugin-initializer.js +1 -0
  26. package/dist/_app_/models/template.js +1 -0
  27. package/dist/_app_/serializers/application.js +1 -0
  28. package/dist/_app_/services/import-rdfa-snippet.js +1 -0
  29. package/dist/_app_/services/standard-template-plugin.js +1 -0
  30. package/dist/_rollupPluginBabelHelpers-537ad14b.js +48 -0
  31. package/dist/_rollupPluginBabelHelpers-537ad14b.js.map +1 -0
  32. package/dist/components/besluit-type-plugin/besluit-type-select.js +30 -0
  33. package/dist/components/besluit-type-plugin/besluit-type-select.js.map +1 -0
  34. package/dist/components/besluit-type-plugin/toolbar-dropdown.js +292 -0
  35. package/dist/components/besluit-type-plugin/toolbar-dropdown.js.map +1 -0
  36. package/dist/components/citaten-plugin/citaat-card.js +367 -0
  37. package/dist/components/citaten-plugin/citaat-card.js.map +1 -0
  38. package/dist/components/citaten-plugin/citaat-insert.js +84 -0
  39. package/dist/components/citaten-plugin/citaat-insert.js.map +1 -0
  40. package/dist/components/citaten-plugin/citations/article-list.js +10 -0
  41. package/dist/components/citaten-plugin/citations/article-list.js.map +1 -0
  42. package/dist/components/citaten-plugin/citations/article-preview.js +10 -0
  43. package/dist/components/citaten-plugin/citations/article-preview.js.map +1 -0
  44. package/dist/components/citaten-plugin/citations/decision-detail.js +123 -0
  45. package/dist/components/citaten-plugin/citations/decision-detail.js.map +1 -0
  46. package/dist/components/citaten-plugin/citations/decision-list.js +10 -0
  47. package/dist/components/citaten-plugin/citations/decision-list.js.map +1 -0
  48. package/dist/components/citaten-plugin/citations/decision-preview.js +10 -0
  49. package/dist/components/citaten-plugin/citations/decision-preview.js.map +1 -0
  50. package/dist/components/citaten-plugin/citations/search-modal.js +282 -0
  51. package/dist/components/citaten-plugin/citations/search-modal.js.map +1 -0
  52. package/dist/components/citaten-plugin/helpers/alert-load-error.js +10 -0
  53. package/dist/components/citaten-plugin/helpers/alert-load-error.js.map +1 -0
  54. package/dist/components/citaten-plugin/helpers/alert-no-items.js +10 -0
  55. package/dist/components/citaten-plugin/helpers/alert-no-items.js.map +1 -0
  56. package/dist/components/import-snippet-plugin/card.js +99 -0
  57. package/dist/components/import-snippet-plugin/card.js.map +1 -0
  58. package/dist/components/rdfa-date-plugin/rdfa-date-plugin-card.js +85 -0
  59. package/dist/components/rdfa-date-plugin/rdfa-date-plugin-card.js.map +1 -0
  60. package/dist/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +23 -0
  61. package/dist/components/rdfa-date-plugin/rdfa-date-plugin-insert.js.map +1 -0
  62. package/dist/components/rdfa-date-plugin/rdfa-date-time-picker.js +91 -0
  63. package/dist/components/rdfa-date-plugin/rdfa-date-time-picker.js.map +1 -0
  64. package/dist/components/standard-template-plugin/template-card.js +15 -0
  65. package/dist/components/standard-template-plugin/template-card.js.map +1 -0
  66. package/dist/components/standard-template-plugin/template-provider.js +109 -0
  67. package/dist/components/standard-template-plugin/template-provider.js.map +1 -0
  68. package/dist/components/table-of-contents-plugin/card.js +52 -0
  69. package/dist/components/table-of-contents-plugin/card.js.map +1 -0
  70. package/dist/components/table-of-contents-plugin/inline-components/outline.js +10 -0
  71. package/dist/components/table-of-contents-plugin/inline-components/outline.js.map +1 -0
  72. package/dist/components/table-of-contents-plugin/inline-components/table-of-contents.js +92 -0
  73. package/dist/components/table-of-contents-plugin/inline-components/table-of-contents.js.map +1 -0
  74. package/dist/constants-af958fcd.js +12 -0
  75. package/dist/constants-af958fcd.js.map +1 -0
  76. package/dist/index.js +2 -0
  77. package/dist/index.js.map +1 -0
  78. package/dist/initializers/plugin-initializer.js +307 -0
  79. package/dist/initializers/plugin-initializer.js.map +1 -0
  80. package/dist/legislation-types-4d487cb9.js +26 -0
  81. package/dist/legislation-types-4d487cb9.js.map +1 -0
  82. package/dist/models/template.js +48 -0
  83. package/dist/models/template.js.map +1 -0
  84. package/dist/serializers/application.js +10 -0
  85. package/dist/serializers/application.js.map +1 -0
  86. package/dist/services/import-rdfa-snippet.js +178 -0
  87. package/dist/services/import-rdfa-snippet.js.map +1 -0
  88. package/dist/services/standard-template-plugin.js +53 -0
  89. package/dist/services/standard-template-plugin.js.map +1 -0
  90. package/dist/styles/citaten-plugin.scss +50 -0
  91. package/dist/styles/test.css +0 -0
  92. package/dist/vlaamse-codex-187fe526.js +304 -0
  93. package/dist/vlaamse-codex-187fe526.js.map +1 -0
  94. package/package.json +117 -0
@@ -0,0 +1,178 @@
1
+ import { b as _defineProperty } from '../_rollupPluginBabelHelpers-537ad14b.js';
2
+ import Service from '@ember/service';
3
+ import { A } from '@ember/array';
4
+ import ContextScanner from '@lblod/marawa/rdfa-context-scanner';
5
+
6
+ /*
7
+ * @module editor-import-snippet-plugin
8
+ * @class ImportRdfaSnippet
9
+ * @constructor
10
+ */
11
+ class RdfaSnippet {
12
+ constructor(source, type, content, blocks) {
13
+ this.source = source;
14
+ this.content = content;
15
+ this.blocks = blocks;
16
+ this.type = type;
17
+ }
18
+ get resourceTypeString() {
19
+ return (this.resourceTypes || []).join(', ');
20
+ }
21
+ }
22
+
23
+ /**
24
+ * Service responsible for fetching and storing a snippet
25
+ *
26
+ * Assumptions
27
+ * -----------
28
+ * - one toplevel rdfa block per snippet
29
+ *
30
+ * @module editor-import-snippet-plugin
31
+ * @class ImportRdfaSnippet
32
+ * @constructor
33
+ * @extends EmberService
34
+ */
35
+ class ImportRdfaSnippet extends Service {
36
+ constructor() {
37
+ super(...arguments);
38
+ _defineProperty(this, "errors", void 0);
39
+ _defineProperty(this, "snippets", void 0);
40
+ this.snippets = A();
41
+ this.errors = A();
42
+ this.contextScanner = new ContextScanner();
43
+ }
44
+
45
+ /**
46
+ * Download, processes and stores snippet
47
+ * @method downloadSnippet
48
+ * @param {Object}: {source}
49
+ * @return {String}
50
+ * @public
51
+ */
52
+ async downloadSnippet(params) {
53
+ const data = await this.getSnippet(params);
54
+ if (data) await this.processSnippet(params, data);
55
+ }
56
+
57
+ /**
58
+ * Remove a snippet from the store, typically after using it
59
+ * @method removeSnippet
60
+ * @param {RdfaSnippet} snippet
61
+ * @return void
62
+ * @public
63
+ */
64
+ removeSnippet(snippet) {
65
+ const index = this.snippets.indexOf(snippet);
66
+ if (index >= 0) {
67
+ this.snippets.splice(index, 1);
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Return snippets for a given type, current supported types are 'roadsign' and 'generic'
73
+ * @method snippetsForType
74
+ * @params {String} type
75
+ * @return {Array} array of RdfaSnippets
76
+ */
77
+ snippetsForType(type) {
78
+ return this.snippets.filter(snippet => snippet.type === type);
79
+ }
80
+
81
+ /**
82
+ * Fetches snippet from remote
83
+ * @method processSnippet
84
+ * @param params.omitCredentials {String} if truthy, the fetch call will omit credentials (this is important for endpoints that only provide simple CORS headers). When not set or falsy we fetch with "include" credentials. This means the endpoint needs to provide the Access-Control-Allow-Credentials and Access-Controlled-Allow-Origin needs to be set to the requesting domain ('*' is not allowed)
85
+ * @param params.source {String} the URL of the document to fetch
86
+ * @result {Response} result from ember fetch call
87
+ * @private
88
+ */
89
+ async getSnippet(params) {
90
+ let data = null;
91
+ try {
92
+ const credentials = params.omitCredentials ? 'omit' : 'include';
93
+ data = await fetch(params.source, {
94
+ credentials,
95
+ headers: {
96
+ Accept: 'text/html'
97
+ }
98
+ });
99
+ if (!data) {
100
+ this.errors.pushObject({
101
+ source: params.source,
102
+ details: `No data found for ${params.uri}`
103
+ });
104
+ }
105
+ } catch (err) {
106
+ this.errors.pushObject({
107
+ source: params.source,
108
+ details: `Error fetching data ${params.uri}: ${err}`
109
+ });
110
+ }
111
+ return data;
112
+ }
113
+
114
+ /**
115
+ * heuristic to determine the type of snippet
116
+ * currently just a very basic check if a type exists in the snippet.
117
+ * @method determineType
118
+ */
119
+ determineType(params, snippet, rdfaBlocks) {
120
+ const triples = rdfaBlocks.map(block => block.context).reduce((prevValue, next) => [...prevValue, ...next]).filter((v, i, a) => a.indexOf(v) === i); //This filters only unique values
121
+ const types = triples.filter(triple => triple.predicate === 'a').map(triple => triple.object).filter((v, i, a) => a.indexOf(v) === i); //This filters only unique values
122
+ if (types.includes('https://data.vlaanderen.be/ns/mobiliteit#Verkeersbord-Verkeersteken')) {
123
+ return 'roadsign';
124
+ } else {
125
+ return 'generic';
126
+ }
127
+ }
128
+
129
+ /**
130
+ * Processes and stores snippet
131
+ * @method processSnippet
132
+ * @param {Object} { source }
133
+ * @param {Object} { text } (result from ember fetch call)
134
+ * @private
135
+ */
136
+ async processSnippet(params, data) {
137
+ try {
138
+ const snippet = await data.text();
139
+ const snippetElements = this.htmlToElements(snippet);
140
+ const rdfaBlocks = snippetElements.map(e => this.contextScanner.analyse(e)).reduce((acc, blocks) => [...acc, ...blocks], []);
141
+ const type = this.determineType(params, snippet, rdfaBlocks);
142
+ this.storeSnippet(params.source, type, snippet, rdfaBlocks);
143
+ } catch (err) {
144
+ this.errors.pushObject({
145
+ source: params.source,
146
+ details: `Error fetching data ${params.uri}: ${err}`
147
+ });
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Make HTML Content Template from string
153
+ * @method htmlToElement
154
+ * @param {String}
155
+ * @return {Object}
156
+ * @private
157
+ */
158
+ htmlToElements(html) {
159
+ const template = document.createElement('template');
160
+ template.innerHTML = html;
161
+ return [...template.content.children];
162
+ }
163
+
164
+ /**
165
+ * Stores snippet
166
+ * @method storeSnippet
167
+ * @param {String} source the source url of the snippet
168
+ * @param {String} content the unparsed text content of the snippet
169
+ * @param {Array} block array of richnodes representing the content of the snippet
170
+ * @private
171
+ */
172
+ storeSnippet(source, type, content, blocks) {
173
+ this.snippets.pushObject(new RdfaSnippet(source, type, content, blocks));
174
+ }
175
+ }
176
+
177
+ export { ImportRdfaSnippet as default };
178
+ //# sourceMappingURL=import-rdfa-snippet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-rdfa-snippet.js","sources":["../../src/services/import-rdfa-snippet.js"],"sourcesContent":["import Service from '@ember/service';\nimport { A } from '@ember/array';\nimport ContextScanner from '@lblod/marawa/rdfa-context-scanner';\n\n/*\n * @module editor-import-snippet-plugin\n * @class ImportRdfaSnippet\n * @constructor\n */\nclass RdfaSnippet {\n constructor(source, type, content, blocks) {\n this.source = source;\n this.content = content;\n this.blocks = blocks;\n this.type = type;\n }\n\n get resourceTypeString() {\n return (this.resourceTypes || []).join(', ');\n }\n}\n\n/**\n * Service responsible for fetching and storing a snippet\n *\n * Assumptions\n * -----------\n * - one toplevel rdfa block per snippet\n *\n * @module editor-import-snippet-plugin\n * @class ImportRdfaSnippet\n * @constructor\n * @extends EmberService\n */\nexport default class ImportRdfaSnippet extends Service {\n errors;\n\n snippets;\n\n constructor() {\n super(...arguments);\n this.snippets = A();\n this.errors = A();\n this.contextScanner = new ContextScanner();\n }\n\n /**\n * Download, processes and stores snippet\n * @method downloadSnippet\n * @param {Object}: {source}\n * @return {String}\n * @public\n */\n async downloadSnippet(params) {\n const data = await this.getSnippet(params);\n if (data) await this.processSnippet(params, data);\n }\n\n /**\n * Remove a snippet from the store, typically after using it\n * @method removeSnippet\n * @param {RdfaSnippet} snippet\n * @return void\n * @public\n */\n removeSnippet(snippet) {\n const index = this.snippets.indexOf(snippet);\n if (index >= 0) {\n this.snippets.splice(index, 1);\n }\n }\n\n /**\n * Return snippets for a given type, current supported types are 'roadsign' and 'generic'\n * @method snippetsForType\n * @params {String} type\n * @return {Array} array of RdfaSnippets\n */\n snippetsForType(type) {\n return this.snippets.filter((snippet) => snippet.type === type);\n }\n\n /**\n * Fetches snippet from remote\n * @method processSnippet\n * @param params.omitCredentials {String} if truthy, the fetch call will omit credentials (this is important for endpoints that only provide simple CORS headers). When not set or falsy we fetch with \"include\" credentials. This means the endpoint needs to provide the Access-Control-Allow-Credentials and Access-Controlled-Allow-Origin needs to be set to the requesting domain ('*' is not allowed)\n * @param params.source {String} the URL of the document to fetch\n * @result {Response} result from ember fetch call\n * @private\n */\n async getSnippet(params) {\n let data = null;\n try {\n const credentials = params.omitCredentials ? 'omit' : 'include';\n data = await fetch(params.source, {\n credentials,\n headers: { Accept: 'text/html' },\n });\n\n if (!data) {\n this.errors.pushObject({\n source: params.source,\n details: `No data found for ${params.uri}`,\n });\n }\n } catch (err) {\n this.errors.pushObject({\n source: params.source,\n details: `Error fetching data ${params.uri}: ${err}`,\n });\n }\n return data;\n }\n\n /**\n * heuristic to determine the type of snippet\n * currently just a very basic check if a type exists in the snippet.\n * @method determineType\n */\n determineType(params, snippet, rdfaBlocks) {\n const triples = rdfaBlocks\n .map((block) => block.context)\n .reduce((prevValue, next) => [...prevValue, ...next])\n .filter((v, i, a) => a.indexOf(v) === i); //This filters only unique values\n const types = triples\n .filter((triple) => triple.predicate === 'a')\n .map((triple) => triple.object)\n .filter((v, i, a) => a.indexOf(v) === i); //This filters only unique values\n if (\n types.includes(\n 'https://data.vlaanderen.be/ns/mobiliteit#Verkeersbord-Verkeersteken'\n )\n ) {\n return 'roadsign';\n } else {\n return 'generic';\n }\n }\n\n /**\n * Processes and stores snippet\n * @method processSnippet\n * @param {Object} { source }\n * @param {Object} { text } (result from ember fetch call)\n * @private\n */\n async processSnippet(params, data) {\n try {\n const snippet = await data.text();\n const snippetElements = this.htmlToElements(snippet);\n const rdfaBlocks = snippetElements\n .map((e) => this.contextScanner.analyse(e))\n .reduce((acc, blocks) => [...acc, ...blocks], []);\n const type = this.determineType(params, snippet, rdfaBlocks);\n this.storeSnippet(params.source, type, snippet, rdfaBlocks);\n } catch (err) {\n this.errors.pushObject({\n source: params.source,\n details: `Error fetching data ${params.uri}: ${err}`,\n });\n }\n }\n\n /**\n * Make HTML Content Template from string\n * @method htmlToElement\n * @param {String}\n * @return {Object}\n * @private\n */\n htmlToElements(html) {\n const template = document.createElement('template');\n template.innerHTML = html;\n return [...template.content.children];\n }\n\n /**\n * Stores snippet\n * @method storeSnippet\n * @param {String} source the source url of the snippet\n * @param {String} content the unparsed text content of the snippet\n * @param {Array} block array of richnodes representing the content of the snippet\n * @private\n */\n storeSnippet(source, type, content, blocks) {\n this.snippets.pushObject(new RdfaSnippet(source, type, content, blocks));\n }\n}\n"],"names":["RdfaSnippet","constructor","source","type","content","blocks","resourceTypeString","resourceTypes","join","ImportRdfaSnippet","Service","arguments","snippets","A","errors","contextScanner","ContextScanner","downloadSnippet","params","data","getSnippet","processSnippet","removeSnippet","snippet","index","indexOf","splice","snippetsForType","filter","credentials","omitCredentials","fetch","headers","Accept","pushObject","details","uri","err","determineType","rdfaBlocks","triples","map","block","context","reduce","prevValue","next","v","i","a","types","triple","predicate","object","includes","text","snippetElements","htmlToElements","e","analyse","acc","storeSnippet","html","template","document","createElement","innerHTML","children"],"mappings":";;;;;AAIA;AACA;AACA;AACA;AACA;AACA,MAAMA,WAAW,CAAC;EAChBC,WAAW,CAACC,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAE;IACzC,IAAI,CAACH,MAAM,GAAGA,MAAM,CAAA;IACpB,IAAI,CAACE,OAAO,GAAGA,OAAO,CAAA;IACtB,IAAI,CAACC,MAAM,GAAGA,MAAM,CAAA;IACpB,IAAI,CAACF,IAAI,GAAGA,IAAI,CAAA;AAClB,GAAA;AAEA,EAAA,IAAIG,kBAAkB,GAAG;IACvB,OAAO,CAAC,IAAI,CAACC,aAAa,IAAI,EAAE,EAAEC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC9C,GAAA;AACF,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,MAAMC,iBAAiB,SAASC,OAAO,CAAC;AAKrDT,EAAAA,WAAW,GAAG;IACZ,KAAK,CAAC,GAAGU,SAAS,CAAC,CAAA;AAAC,IAAA,eAAA,CAAA,IAAA,EAAA,QAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAAA,IAAA,eAAA,CAAA,IAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AACpB,IAAA,IAAI,CAACC,QAAQ,GAAGC,CAAC,EAAE,CAAA;AACnB,IAAA,IAAI,CAACC,MAAM,GAAGD,CAAC,EAAE,CAAA;AACjB,IAAA,IAAI,CAACE,cAAc,GAAG,IAAIC,cAAc,EAAE,CAAA;AAC5C,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;EAC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QAAQ,CAAC3D,OAAO,CAAC+D,QAAQ,CAAC,CAAA;AACvC,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEN,YAAY,CAAC3D,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAE;AAC1C,IAAA,IAAI,CAACO,QAAQ,CAACsB,UAAU,CAAC,IAAIlC,WAAW,CAACE,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,CAAC,CAAC,CAAA;AAC1E,GAAA;AACF;;;;"}
@@ -0,0 +1,53 @@
1
+ import { _ as _applyDecoratedDescriptor, a as _initializerDefineProperty } from '../_rollupPluginBabelHelpers-537ad14b.js';
2
+ import Service, { inject } from '@ember/service';
3
+ import { task, waitForProperty } from 'ember-concurrency';
4
+ import { tracked } from '@glimmer/tracking';
5
+
6
+ var _class, _descriptor, _descriptor2;
7
+ let RdfaEditorStandardTemplatePluginService = (_class = class RdfaEditorStandardTemplatePluginService extends Service {
8
+ constructor() {
9
+ super(...arguments);
10
+ _initializerDefineProperty(this, "store", _descriptor, this);
11
+ _initializerDefineProperty(this, "templates", _descriptor2, this);
12
+ this.loadTemplates();
13
+ }
14
+ *fetchTemplates() {
15
+ yield waitForProperty(this, 'templates');
16
+ return this.templates;
17
+ }
18
+ async loadTemplates() {
19
+ this.templates = await this.store.query('template', {
20
+ fields: {
21
+ templates: 'title,contexts,matches,disabled-in-contexts'
22
+ }
23
+ });
24
+ }
25
+
26
+ /**
27
+ Filter the valid templates for a context.
28
+ @method templatesForContext
29
+ @param {Array} Array of templates
30
+ @param {Array} The path of rdfaContext objects from the root till the current context
31
+ @return {Array} Array of templates (filtered)
32
+ @private
33
+ */
34
+ templatesForContext(templates, rdfaTypes) {
35
+ let isMatchingForContext = template => {
36
+ return rdfaTypes.filter(e => template.get('contexts').includes(e)).length > 0 && rdfaTypes.filter(e => template.get('disabledInContexts').includes(e)).length === 0;
37
+ };
38
+ return templates.filter(isMatchingForContext);
39
+ }
40
+ }, (_descriptor = _applyDecoratedDescriptor(_class.prototype, "store", [inject], {
41
+ configurable: true,
42
+ enumerable: true,
43
+ writable: true,
44
+ initializer: null
45
+ }), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "templates", [tracked], {
46
+ configurable: true,
47
+ enumerable: true,
48
+ writable: true,
49
+ initializer: null
50
+ }), _applyDecoratedDescriptor(_class.prototype, "fetchTemplates", [task], Object.getOwnPropertyDescriptor(_class.prototype, "fetchTemplates"), _class.prototype)), _class);
51
+
52
+ export { RdfaEditorStandardTemplatePluginService as default };
53
+ //# sourceMappingURL=standard-template-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standard-template-plugin.js","sources":["../../src/services/standard-template-plugin.js"],"sourcesContent":["import Service, { inject as service } from '@ember/service';\nimport { task, waitForProperty } from 'ember-concurrency';\nimport { tracked } from '@glimmer/tracking';\n\nexport default class RdfaEditorStandardTemplatePluginService extends Service {\n @service store;\n @tracked templates;\n\n constructor() {\n super(...arguments);\n this.loadTemplates();\n }\n\n @task\n *fetchTemplates() {\n yield waitForProperty(this, 'templates');\n return this.templates;\n }\n\n async loadTemplates() {\n this.templates = await this.store.query('template', {\n fields: { templates: 'title,contexts,matches,disabled-in-contexts' },\n });\n }\n\n /**\n Filter the valid templates for a context.\n @method templatesForContext\n @param {Array} Array of templates\n @param {Array} The path of rdfaContext objects from the root till the current context\n @return {Array} Array of templates (filtered)\n @private\n */\n templatesForContext(templates, rdfaTypes) {\n let isMatchingForContext = (template) => {\n return (\n rdfaTypes.filter((e) => template.get('contexts').includes(e)).length >\n 0 &&\n rdfaTypes.filter((e) => template.get('disabledInContexts').includes(e))\n .length === 0\n );\n };\n return templates.filter(isMatchingForContext);\n }\n}\n"],"names":["RdfaEditorStandardTemplatePluginService","Service","constructor","arguments","loadTemplates","fetchTemplates","waitForProperty","templates","store","query","fields","templatesForContext","rdfaTypes","isMatchingForContext","template","filter","e","get","includes","length","service","tracked","task"],"mappings":";;;;;;AAE4C,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/C,GAAA;AACF,CAAC,uEAvCEO,MAAO,CAAA,EAAA;AAAA,EAAA,YAAA,EAAA,IAAA;AAAA,EAAA,UAAA,EAAA,IAAA;AAAA,EAAA,QAAA,EAAA,IAAA;AAAA,EAAA,WAAA,EAAA,IAAA;AAAA,CAAA,CAAA,EAAA,YAAA,GAAA,yBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,WAAA,EAAA,CACPC,OAAO,CAAA,EAAA;AAAA,EAAA,YAAA,EAAA,IAAA;AAAA,EAAA,UAAA,EAAA,IAAA;AAAA,EAAA,QAAA,EAAA,IAAA;AAAA,EAAA,WAAA,EAAA,IAAA;AAAA,CAAA,CAAA,EAAA,yBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,CAOPC,IAAI,CAAA,EAAA,MAAA,CAAA,wBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,gBAAA,CAAA,EAAA,MAAA,CAAA,SAAA,CAAA,GAAA,MAAA;;;;"}
@@ -0,0 +1,50 @@
1
+ @import '@appuniversum/ember-appuniversum/app/styles/ember-appuniversum';
2
+
3
+ .citaten--decision-list {
4
+ max-height: 35vh;
5
+ overflow: auto;
6
+ }
7
+
8
+ .citaten--decision-title {
9
+ /*Still with vendor prefixes for now */
10
+ /*Have the title only a couple of lines long at the most*/
11
+ display: -webkit-box;
12
+ overflow: hidden;
13
+ text-overflow: ellipsis;
14
+ -webkit-line-clamp: 3;
15
+ -webkit-box-orient: vertical;
16
+ }
17
+
18
+ /*To show the dopdown content on top of the modal*/
19
+ .ember-basic-dropdown-content {
20
+ z-index: 1000000 !important;
21
+ }
22
+
23
+ .citaten--main-container {
24
+ height: 100% !important;
25
+ }
26
+
27
+ .citaten--main-container .citaten--sidebar,
28
+ .citaten--main-container .au-c-main-container__sidebar {
29
+ @include mq(medium) {
30
+ flex-basis: 30rem;
31
+ }
32
+ }
33
+
34
+ .citaten--main-container .au-c-main-container__content {
35
+ display: flex;
36
+ flex-direction: column;
37
+ justify-content: space-between;
38
+ }
39
+
40
+ .citaten--container-header {
41
+ border-bottom: .1rem solid var(--au-gray-200);
42
+ }
43
+
44
+ .citaten--container-content {
45
+ overflow: auto;
46
+ }
47
+
48
+ .citaten--error-code {
49
+ font-family: var(--au-font-tertiary);
50
+ }
File without changes
@@ -0,0 +1,304 @@
1
+ import { a as LEGISLATION_TYPE_CONCEPTS } from './legislation-types-4d487cb9.js';
2
+ import { warn } from '@ember/debug';
3
+ import { htmlSafe } from '@ember/template';
4
+
5
+ const SPARQL_ENDPOINT = '/codex/sparql/';
6
+
7
+ //const SPARQL_ENDPOINT = 'https://codex.opendata.api.vlaanderen.be:8888/sparql';
8
+
9
+ class Decision {
10
+ constructor({
11
+ uri,
12
+ legislationTypeUri,
13
+ title,
14
+ publicationDate,
15
+ documentDate
16
+ }) {
17
+ this.uri = uri;
18
+ this.legislationType = LEGISLATION_TYPE_CONCEPTS.find(t => t.value == legislationTypeUri);
19
+ this.title = title;
20
+ this.publicationDate = publicationDate;
21
+ this.documentDate = documentDate;
22
+ }
23
+ get fullTitle() {
24
+ return `${this.legislationType.label} ${this.title}`;
25
+ }
26
+ }
27
+ class Article {
28
+ constructor({
29
+ uri,
30
+ number,
31
+ content,
32
+ dateInForce,
33
+ dateNoLongerInForce
34
+ }) {
35
+ this.uri = uri;
36
+ this.number = number;
37
+ this.content = htmlSafe(content);
38
+ this.dateInForce = dateInForce;
39
+ this.dateNoLongerInForce = dateNoLongerInForce;
40
+ }
41
+ }
42
+
43
+ /*
44
+ * flemish codex encodes certain characters as a html character, which breaks our search
45
+ * this is an ugly work around
46
+ */
47
+ function replaceDiacriticsInWord(word) {
48
+ const characters = 'Ë À Ì Â Í Ã Î Ä Ï Ç Ò È Ó É Ô Ê Õ Ö ê Ù ë Ú î Û ï Ü ô Ý õ â û ã ÿ ç'.split(' ');
49
+ for (let char of characters) {
50
+ word = word.replace(new RegExp(`${char}`, 'g'), `&#${char.charCodeAt(0)};`);
51
+ }
52
+ return word;
53
+ }
54
+
55
+ //Attempt to memoise on the fetching by stringifying the arguments. This could spare a few fetches.
56
+ //If memoising fails, at least a normal fetch is performed.
57
+
58
+ const fetchDecisionsMemory = new Map();
59
+ async function fetchDecisions(words, filter, pageNumber = 0, pageSize = 5
60
+ /*abortSignal*/) {
61
+ //This is silly, but null != undefined, so we have to be careful and include the correct value here
62
+ //Also, reconstruct the whole filter object to always have the same ordering, hopefully.
63
+ filter = {
64
+ type: filter.type,
65
+ documentDateFrom: filter.documentDateFrom || null,
66
+ documentDateTo: filter.documentDateTo || null,
67
+ publicationDateFrom: filter.publicationDateFrom || null,
68
+ publicationDateTo: filter.publicationDateTo || null
69
+ };
70
+ const stringArguments = JSON.stringify({
71
+ words,
72
+ filter,
73
+ pageNumber,
74
+ pageSize
75
+ });
76
+ const results = fetchDecisionsMemory.get(stringArguments);
77
+ if (results) {
78
+ return results;
79
+ } else {
80
+ const newResults = await fetchDecisionsMemd(...arguments);
81
+ fetchDecisionsMemory.set(stringArguments, newResults);
82
+ return newResults;
83
+ }
84
+ }
85
+ async function fetchDecisionsMemd(words, filter, pageNumber = 0, pageSize = 5, abortSignal) {
86
+ // TBD/NOTE: in the context of a <http://data.europa.eu/eli/ontology#LegalResource>
87
+ // the eli:cites can have either a <http://xmlns.com/foaf/0.1/Document> or <http://data.europa.eu/eli/ontology#LegalResource>
88
+ // as range (see AP https://data.vlaanderen.be/doc/applicatieprofiel/besluit-publicatie/#Rechtsgrond),
89
+ // but I currently don't think in the editor you'll ever directly work on a LegalResource.
90
+ const {
91
+ type,
92
+ documentDateFrom,
93
+ documentDateTo,
94
+ publicationDateFrom,
95
+ publicationDateTo
96
+ } = filter || {};
97
+ let documentDateFilter = 'OPTIONAL { ?legalResourceUri eli:date_document ?documentDate . }';
98
+ if (documentDateFrom || documentDateTo) {
99
+ documentDateFilter = '?legalResourceUri eli:date_document ?documentDate . ';
100
+ if (documentDateFrom) documentDateFilter += `FILTER (?documentDate >= "${documentDateFrom}"^^xsd:date) `;
101
+ if (documentDateTo) documentDateFilter += `FILTER (?documentDate <= "${documentDateTo}"^^xsd:date) `;
102
+ }
103
+ let publicationDateFilter = 'OPTIONAL { ?expressionUri eli:date_publication ?publicationDate . }';
104
+ if (publicationDateFrom || publicationDateTo) {
105
+ publicationDateFilter = '?expressionUri eli:date_publication ?publicationDate . ';
106
+ if (publicationDateFrom) publicationDateFilter += `FILTER (?publicationDate >= "${publicationDateFrom}"^^xsd:date) `;
107
+ if (publicationDateTo) publicationDateFilter += `FILTER (?publicationDate <= "${publicationDateTo}"^^xsd:date) `;
108
+ }
109
+ const excludeAdaptationFilters = [];
110
+ if (!words.includes('houdende')) {
111
+ excludeAdaptationFilters.push('FILTER(! STRSTARTS(LCASE(?title),"houdende"))');
112
+ }
113
+ if (!words.includes('wijziging')) {
114
+ excludeAdaptationFilters.push('FILTER(! STRSTARTS(LCASE(?title),"tot wijziging"))');
115
+ }
116
+ const totalCount = await executeCountQuery(`PREFIX eli: <http://data.europa.eu/eli/ontology#>
117
+
118
+ SELECT COUNT(DISTINCT(?expressionUri)) as ?count
119
+ WHERE {
120
+ ?legalResourceUri eli:type_document <${type}> ;
121
+ eli:is_realized_by ?expressionUri .
122
+ ?expressionUri a <http://data.europa.eu/eli/ontology#LegalExpression> .
123
+ ?expressionUri eli:title ?title .
124
+ ${words.map(word => `FILTER (CONTAINS(LCASE(?title), "${replaceDiacriticsInWord(word).toLowerCase()}"))`).join('\n')}
125
+ ${excludeAdaptationFilters.join('\n')}
126
+ ${documentDateFilter}
127
+ ${publicationDateFilter}
128
+ }`, abortSignal);
129
+ if (totalCount > 0) {
130
+ const response = await executeQuery(`PREFIX eli: <http://data.europa.eu/eli/ontology#>
131
+
132
+ SELECT DISTINCT ?expressionUri as ?uri ?title ?publicationDate ?documentDate
133
+ WHERE {
134
+ ?legalResourceUri eli:type_document <${type}> ;
135
+ eli:is_realized_by ?expressionUri .
136
+ ?expressionUri a <http://data.europa.eu/eli/ontology#LegalExpression> .
137
+ ?expressionUri eli:title ?title .
138
+ ${words.map(word => `FILTER (CONTAINS(LCASE(?title), "${replaceDiacriticsInWord(word).toLowerCase()}"))`).join('\n')}
139
+ OPTIONAL { ?expressionUri eli:date_publication ?publicationDate . }
140
+ ${excludeAdaptationFilters.join('\n')}
141
+ ${documentDateFilter}
142
+ ${publicationDateFilter}
143
+ } ORDER BY ?title LIMIT ${pageSize} OFFSET ${pageNumber * pageSize}`, abortSignal);
144
+ const decisions = response.results.bindings.map(binding => {
145
+ const escapedTitle = escapeValue(binding.title.value);
146
+ const publicationDate = dateValue(binding.publicationDate && binding.publicationDate.value);
147
+ const documentDate = dateValue(binding.documentDate && binding.documentDate.value);
148
+ return new Decision({
149
+ uri: binding.uri.value,
150
+ title: escapedTitle,
151
+ legislationTypeUri: type,
152
+ publicationDate,
153
+ documentDate
154
+ });
155
+ });
156
+ return {
157
+ totalCount,
158
+ decisions
159
+ };
160
+ } else {
161
+ return {
162
+ totalCount,
163
+ decisions: []
164
+ };
165
+ }
166
+ }
167
+ const fetchArticlesMemory = new Map();
168
+ async function fetchArticles(legalExpression, pageNumber, pageSize, articleFilter
169
+ /*abortSignal*/) {
170
+ //Simpler here, only one way arguments are set up
171
+ const stringArguments = JSON.stringify({
172
+ legalExpression,
173
+ pageNumber,
174
+ pageSize,
175
+ articleFilter
176
+ });
177
+ const results = fetchArticlesMemory.get(stringArguments);
178
+ if (results) {
179
+ return results;
180
+ } else {
181
+ const newResults = await fetchArticlesMemd(...arguments);
182
+ fetchArticlesMemory.set(stringArguments, newResults);
183
+ return newResults;
184
+ }
185
+ }
186
+ async function fetchArticlesMemd(legalExpression, pageNumber = 0, pageSize = 10, articleFilter, abortSignal) {
187
+ const numberFilter = articleFilter ? `FILTER( !BOUND(?number) || CONTAINS(?number, "${articleFilter}"))` : '';
188
+ const totalCount = await executeCountQuery(`PREFIX eli: <http://data.europa.eu/eli/ontology#>
189
+ PREFIX dct: <http://purl.org/dc/terms/>
190
+
191
+ SELECT COUNT(DISTINCT(?article)) as ?count
192
+ WHERE {
193
+ ?legalResource eli:is_realized_by <${legalExpression}> ;
194
+ eli:has_part ?articleResource .
195
+ ?articleResource eli:is_realized_by ?article ;
196
+ dct:type <https://data.vlaanderen.be/id/concept/TypeRechtsbrononderdeel/Artikel>.
197
+ OPTIONAL {
198
+ ?article eli:first_date_entry_in_force ?dateInForce .
199
+ FILTER (?dateInForce <= NOW() )
200
+ }
201
+ OPTIONAL { ?article eli:date_no_longer_in_force ?dateNoLongerInForce }
202
+ FILTER( !BOUND(?dateNoLongerInForce) || ?dateNoLongerInForce > NOW() )
203
+ OPTIONAL { ?article eli:number ?number . }
204
+ ${numberFilter}
205
+ }`, abortSignal);
206
+ if (totalCount > 0) {
207
+ // ?number has format like "Artikel 12." We parse the number from the string for ordering
208
+ // Second degree ordering on ?numberStr to make sure "Artikel 3/1." comes after "Artikel 3."
209
+ const response = await executeQuery(`PREFIX eli: <http://data.europa.eu/eli/ontology#>
210
+ PREFIX prov: <http://www.w3.org/ns/prov#>
211
+ PREFIX dct: <http://purl.org/dc/terms/>
212
+
213
+ SELECT DISTINCT ?article ?dateInForce ?dateNoLongerInForce ?number ?content WHERE {
214
+ ?legalResource eli:is_realized_by <${legalExpression}> ;
215
+ eli:has_part ?articleResource .
216
+ ?articleResource eli:is_realized_by ?article ;
217
+ dct:type <https://data.vlaanderen.be/id/concept/TypeRechtsbrononderdeel/Artikel>.
218
+ OPTIONAL {
219
+ ?article eli:first_date_entry_in_force ?dateInForce .
220
+ FILTER (?dateInForce <= NOW() )
221
+ }
222
+ OPTIONAL { ?article eli:date_no_longer_in_force ?dateNoLongerInForce }
223
+ FILTER( !BOUND(?dateNoLongerInForce) || ?dateNoLongerInForce > NOW() )
224
+ OPTIONAL { ?article prov:value ?content . }
225
+ OPTIONAL { ?article eli:number ?number . }
226
+ ${numberFilter}
227
+ BIND(REPLACE(?number, "Artikel ", "") as ?numberStr)
228
+ BIND(STRDT(?numberStr, xsd:integer) as ?numberInt)
229
+ } ORDER BY ?numberInt ?numberStr LIMIT ${pageSize} OFFSET ${pageNumber * pageSize}`, abortSignal);
230
+ const articles = response.results.bindings.map(binding => {
231
+ const escapedContent = escapeValue(binding.content && binding.content.value);
232
+ const dateInForce = dateValue(binding.dateInForce && binding.dateInForce.value);
233
+ const dateNoLongerInForce = dateValue(binding.dateNoLongerInForce && binding.dateNoLongerInForce.value);
234
+ return new Article({
235
+ uri: binding.article.value,
236
+ number: binding.number && binding.number.value,
237
+ content: escapedContent,
238
+ dateInForce,
239
+ dateNoLongerInForce
240
+ });
241
+ });
242
+ return {
243
+ totalCount,
244
+ articles
245
+ };
246
+ } else {
247
+ return {
248
+ totalCount,
249
+ articles: []
250
+ };
251
+ }
252
+ }
253
+ function cleanCaches() {
254
+ fetchDecisionsMemory.clear();
255
+ fetchArticlesMemory.clear();
256
+ }
257
+ function escapeValue(value) {
258
+ if (value) {
259
+ const shadowDomElement = document.createElement('textarea');
260
+ shadowDomElement.innerHTML = value;
261
+ return shadowDomElement.textContent;
262
+ } else {
263
+ return null;
264
+ }
265
+ }
266
+ function dateValue(value) {
267
+ if (value) {
268
+ try {
269
+ return new Intl.DateTimeFormat('nl-BE').format(new Date(Date.parse(value)));
270
+ } catch (e) {
271
+ warn(`Error parsing date ${value}: ${e.message}`, {
272
+ id: 'date-parsing-error'
273
+ });
274
+ return null;
275
+ }
276
+ } else {
277
+ return null;
278
+ }
279
+ }
280
+ async function executeCountQuery(query, abortSignal) {
281
+ const response = await executeQuery(query, abortSignal);
282
+ return parseInt(response.results.bindings[0].count.value);
283
+ }
284
+ async function executeQuery(query, abortSignal) {
285
+ const encodedQuery = encodeURIComponent(query.trim());
286
+ const endpoint = `${SPARQL_ENDPOINT}`;
287
+ const response = await fetch(endpoint, {
288
+ method: 'POST',
289
+ headers: {
290
+ Accept: 'application/sparql-results+json',
291
+ 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
292
+ },
293
+ body: `query=${encodedQuery}`,
294
+ signal: abortSignal
295
+ });
296
+ if (response.ok) {
297
+ return response.json();
298
+ } else {
299
+ throw new Error(`Request to Vlaamse Codex was unsuccessful: [${response.status}] ${response.statusText}`);
300
+ }
301
+ }
302
+
303
+ export { fetchArticles as a, cleanCaches as c, fetchDecisions as f };
304
+ //# sourceMappingURL=vlaamse-codex-187fe526.js.map