diff --git a/source/golang/README.md b/source/golang/README.md index 278f1d8..c77faf1 100644 --- a/source/golang/README.md +++ b/source/golang/README.md @@ -9,9 +9,28 @@ The prototype is able to: * Initialise by creating a config file * Create a JSON **martiLQ** definition file based on files in a directory + +## Client + __TO COME__ -Publish of Golan package is yet to occur. A binary executable will also be +Publish of Golang package is yet to occur. A binary executable will also be published for Linux and Windows of the prototype. This will occur after merge of code into ``main`` branch. + +## Server + +A web UI exists as a functionnal demonstration to view a collection of +**martiLQ** definition files. + +## Docker + +``` + +go env -w GOOS=linux +go env -w GOARCH=386 +go build ./main.go + +docker build -t martilq-go-server:latest . +``` diff --git a/source/golang/server/Dockerfile b/source/golang/server/Dockerfile new file mode 100644 index 0000000..3ea50a4 --- /dev/null +++ b/source/golang/server/Dockerfile @@ -0,0 +1,14 @@ +FROM busybox + +LABEL version="202111A" +LABEL description="matiLQ Go web UI by Meerkat Manor " +LABEL authors="meerkat@merebox.com" + +COPY ./static /home/static +COPY ./main /home/main +COPY ./docs /home/docs +COPY ./data /data + +EXPOSE 8080 + +ENTRYPOINT exec /home/main -p 8080 -s /home/static -data /data/ -docs /home/docs diff --git a/source/golang/server/data/martilq_afsl.json b/source/golang/server/data/martilq_afsl.json new file mode 100644 index 0000000..22cfa8a --- /dev/null +++ b/source/golang/server/data/martilq_afsl.json @@ -0,0 +1,146 @@ +{ + "content-type": "application/vnd.martilq.json", + "title": "Conversion from CKAN", + "uid": "ab7eddce-84df-4098-bc8f-500d0d9776d1", + "description": "This data has been converted from DATA GOV AU CKAN data source with URL 'https://data.gov.au/api/3/action/package_show?id=ab7eddce-84df-4098-bc8f-500d0d9776d1'", + "issued": "2021-11-06T13:48:28", + "modified": "2021-11-06T13:48:28", + "expires": "", + "tags": [ + "document", + "marti", + "ckan", + "gov", + "au" + ], + "publisher": "Australian Securities and Investments Commission (ASIC)", + "contactPoint": "Access.Request@asic.gov.au", + "accessLevel": "Confidential", + "rights": "Restricted", + "license": "cc-by", + "state": "active", + "batch": 1.0, + "describedBy": "", + "landingPage": "https://data.gov.au/dataset/ds-dga-ab7eddce-84df-4098-bc8f-500d0d9776d1/details?q=AFS%20Licensee%20Dataset%20extract%20as", + "theme": "", + "resources": [ + { + "title": "AFS Licensee Dataset - Current", + "uid": "d98a113d-6b50-40e6-b65f-2612efc877f4", + "documentName": "afs_lic_202111.csv", + "issuedDate": "2016-03-10T12:15:49.07712", + "modified": "2021-11-01T03:46:03.958513", + "state": "active", + "author": "Australian Securities and Investments Commission (ASIC)", + "length": 9328930, + "hash": { + "algo": "SHA256", + "value": "307d8972c10a0723af7bfa5f03c56c36", + "signed": false + }, + "description": "AFS Licensee Dataset extract as at 01/11/2021 14:33", + "url": "https://data.gov.au/data/dataset/ab7eddce-84df-4098-bc8f-500d0d9776d1/resource/d98a113d-6b50-40e6-b65f-2612efc877f4/download/afs_lic_202111.csv", + "version": "1.1.0", + "format": "CSV", + "compression": "", + "encryption": "" + }, + { + "title": "AFS Licensee - Help File", + "uid": "2e831e8d-f9d7-4de2-9482-0597f4f6abf9", + "documentName": "australian-financial-services-licensee-help-file.pdf", + "issuedDate": "2016-03-10T12:32:04.564184", + "modified": "2017-05-29T00:09:40.392458", + "state": "active", + "author": "Australian Securities and Investments Commission (ASIC)", + "length": null, + "hash": { + "algo": "SHA256", + "value": "", + "signed": false + }, + "description": "Help File as at 10/03/2016", + "url": "https://data.gov.au/data/dataset/ab7eddce-84df-4098-bc8f-500d0d9776d1/resource/2e831e8d-f9d7-4de2-9482-0597f4f6abf9/download/australian-financial-services-licensee-help-file.pdf", + "version": "1.1.0", + "format": "PDF", + "compression": "", + "encryption": "" + }, + { + "title": "AFS Licensee Dataset - National Map", + "uid": "197ae0f5-121f-4ded-87f7-a54ff76f9471", + "documentName": "afs_lic_202111.csv-geo-au", + "issuedDate": "2016-03-10T14:31:00.013256", + "modified": "2021-11-01T03:46:09.778434", + "state": "active", + "author": "Australian Securities and Investments Commission (ASIC)", + "length": 9179162, + "hash": { + "algo": "SHA256", + "value": "", + "signed": false + }, + "description": "The following changes were made to align with national map: - Delimiter changed to comma (,) - Latitude and longitude field names changed to lat and lon", + "url": "https://data.gov.au/data/dataset/ab7eddce-84df-4098-bc8f-500d0d9776d1/resource/197ae0f5-121f-4ded-87f7-a54ff76f9471/download/afs_lic_202111.csv-geo-au", + "version": "1.1.0", + "format": "CSV-GEO-AU", + "compression": "", + "encryption": "" + }, + { + "title": "AFS Licensee Dataset - Current", + "uid": "710d69b2-05cc-473e-94ae-075766081d49", + "documentName": "afs_lic_202111.xlsx", + "issuedDate": "2016-04-06T13:55:16.278489", + "modified": "2021-11-01T03:46:11.303206", + "state": "active", + "author": "Australian Securities and Investments Commission (ASIC)", + "length": 707842, + "hash": { + "algo": "SHA256", + "value": "", + "signed": false + }, + "description": "AFS Licensee Dataset extract as at 01/11/2021 14:30", + "url": "https://data.gov.au/data/dataset/ab7eddce-84df-4098-bc8f-500d0d9776d1/resource/710d69b2-05cc-473e-94ae-075766081d49/download/afs_lic_202111.xlsx", + "version": "1.1.0", + "format": "XLSX", + "compression": "", + "encryption": "" + }, + { + "title": "AFS Licensee Dataset - Current", + "uid": "1fc2b334-74ae-4588-85aa-83e3a8c9f2cc", + "documentName": "afs_lic_202111.tsv", + "issuedDate": "2016-11-30T08:55:39.249263", + "modified": "2021-11-01T03:46:12.987395", + "state": "active", + "author": "Australian Securities and Investments Commission (ASIC)", + "length": 9170476, + "hash": { + "algo": "SHA256", + "value": "", + "signed": false + }, + "description": "AFS Licensee Dataset extract as at 01/11/2021 14:30", + "url": "https://data.gov.au/data/dataset/ab7eddce-84df-4098-bc8f-500d0d9776d1/resource/1fc2b334-74ae-4588-85aa-83e3a8c9f2cc/download/afs_lic_202111.tsv", + "version": "1.1.0", + "format": "TSV", + "compression": "", + "encryption": "" + } + ], + "custom": [ + { + "extension": "software", + "softwareName": "MartiReference", + "author": "Meerkat@merebox.com", + "version": "0.0.1" + }, + { + "extension": "template", + "renderer": "MartiReference:Mustache", + "url": "data/martilq_ckan.must" + } + ] +} diff --git a/source/golang/server/data/marti_test_asic.json b/source/golang/server/data/martilq_asic.json similarity index 95% rename from source/golang/server/data/marti_test_asic.json rename to source/golang/server/data/martilq_asic.json index 1768b17..ee67c47 100644 --- a/source/golang/server/data/marti_test_asic.json +++ b/source/golang/server/data/martilq_asic.json @@ -10,7 +10,7 @@ "document", "marti" ], - "publisher": "VCOFF\\meerkat", + "publisher": "Australian Securities and Investments Commission (ASIC)", "contactPoint": "Access.Request@asic.gov.au", "accessLevel": "Confidential", "rights": "Restricted", @@ -18,7 +18,7 @@ "state": "active", "batch": 1.0, "describedBy": "", - "landingPage": "", + "landingPage": "https://data.gov.au/dataset/ds-dga-f2b7c2c1-f4ef-4ae9-aba5-45c19e4d3038/details?q=Adviser", "theme": "", "resources": [ { @@ -91,6 +91,11 @@ "softwareName": "MartiReference", "author": "Meerkat@merebox.com", "version": "0.0.1" + }, + { + "extension": "template", + "renderer": "MartiReference:Mustache", + "url": "data/martilq_ckan.must" } ] } diff --git a/source/golang/server/data/martilq_bsb.json b/source/golang/server/data/martilq_bsb.json new file mode 100644 index 0000000..5a7b553 --- /dev/null +++ b/source/golang/server/data/martilq_bsb.json @@ -0,0 +1,564 @@ +{ + "content-type": "application/vnd.martilq.json", + "title": "Australian BSB source", + "uid": "ae5d4d4b-5a7f-494d-8629-a0ced5bc7ba0", + "description": "The original files are published on the APN FTP site and have been copied to a web server", + "modified": "2021-11-05", + "publisher": "Australian Payment Network", + "contactPoint": "", + "accessLevel": "Confidential", + "rights": "Restricted", + "tags": [], + "license": "", + "state": "active", + "batch": 1.0, + "describedBy": "", + "landingPage": "https://bsb.auspaynet.com.au/public/BSB_DB.NSF/publicBSB.xsp", + "theme": "", + "resources": [ + { + "title": "BSBDirectoryOct21-307", + "uid": "0c2ee577-3fbb-46b9-bcc6-40eae069569c", + "documentName": "BSBDirectoryOct21-307.csv", + "issuedDate": "2021-11-05T20:58:03", + "modified": "2021-11-01T09:00:45", + "expires": "", + "state": "active", + "author": "Meerkat@merebox.com", + "length": 1352205, + "hash": { + "algo": "SHA256", + "value": "dd01585bed7a0b6da5d4deb5dff70a4b8ccfee873cf0454f2a46910c3275f03e", + "signed": false + }, + "description": "", + "url": "", + "version": "", + "content-type": "text/csv", + "encoding": null, + "compression": null, + "encryption": null, + "attributes": [ + { + "category": "dataset", + "name": "header", + "function": "count", + "comparison": "NA", + "value": 1 + }, + { + "category": "dataset", + "name": "footer", + "function": "count", + "comparison": "NA", + "value": 0 + }, + { + "category": "format", + "name": "separator", + "function": "value", + "comparison": "NA", + "value": "," + }, + { + "category": "format", + "name": "columns", + "function": "value", + "comparison": "NA", + "value": "," + }, + { + "category": "dataset", + "name": "records", + "function": "count", + "comparison": "EQ", + "value": 15054 + }, + { + "category": "dataset", + "name": "columns", + "function": "count", + "comparison": "EQ", + "value": 8 + } + ] + }, + { + "title": "BSBDirectorySep21-306", + "uid": "900e815a-e052-4198-9d92-e0f1aac07616", + "documentName": "BSBDirectorySep21-306.csv", + "issuedDate": "2021-11-05T20:58:03", + "modified": "2021-10-01T09:00:48", + "expires": "", + "state": "active", + "author": "Meerkat@merebox.com", + "length": 1351281, + "hash": { + "algo": "SHA256", + "value": "4f5c97799f6006247fad64f9a5acc425e79f31342cbbbdaaba2995af16ac56b4", + "signed": false + }, + "description": "", + "url": "", + "version": "", + "content-type": "text/csv", + "encoding": null, + "compression": null, + "encryption": null, + "attributes": [ + { + "category": "dataset", + "name": "header", + "function": "count", + "comparison": "NA", + "value": 1 + }, + { + "category": "dataset", + "name": "footer", + "function": "count", + "comparison": "NA", + "value": 0 + }, + { + "category": "format", + "name": "separator", + "function": "value", + "comparison": "NA", + "value": "," + }, + { + "category": "format", + "name": "columns", + "function": "value", + "comparison": "NA", + "value": "," + }, + { + "category": "dataset", + "name": "records", + "function": "count", + "comparison": "EQ", + "value": 15050 + }, + { + "category": "dataset", + "name": "columns", + "function": "count", + "comparison": "EQ", + "value": 8 + } + ] + }, + { + "title": "BSBDirectoryAug21-305", + "uid": "2ebda69a-8eef-4eb4-817d-a78e38bf5141", + "documentName": "BSBDirectoryAug21-305.csv", + "issuedDate": "2021-11-05T20:58:03", + "modified": "2021-09-01T09:00:43", + "expires": "", + "state": "active", + "author": "Meerkat@merebox.com", + "length": 1352016, + "hash": { + "algo": "SHA256", + "value": "26e40760989ff8a314cda70628c38b66d0d565ea8ad677b81b83780e33984104", + "signed": false + }, + "description": "", + "url": "", + "version": "", + "content-type": "text/csv", + "encoding": null, + "compression": null, + "encryption": null, + "attributes": [ + { + "category": "dataset", + "name": "header", + "function": "count", + "comparison": "NA", + "value": 1 + }, + { + "category": "dataset", + "name": "footer", + "function": "count", + "comparison": "NA", + "value": 0 + }, + { + "category": "format", + "name": "separator", + "function": "value", + "comparison": "NA", + "value": "," + }, + { + "category": "format", + "name": "columns", + "function": "value", + "comparison": "NA", + "value": "," + }, + { + "category": "dataset", + "name": "records", + "function": "count", + "comparison": "EQ", + "value": 15055 + }, + { + "category": "dataset", + "name": "columns", + "function": "count", + "comparison": "EQ", + "value": 8 + } + ] + }, + { + "title": "BSBDirectoryJul21-304", + "uid": "1af01fb4-003e-4179-bb26-e74a543bc837", + "documentName": "BSBDirectoryJul21-304.csv", + "issuedDate": "2021-11-05T20:58:03", + "modified": "2021-08-05T09:00:46", + "expires": "", + "state": "active", + "author": "Meerkat@merebox.com", + "length": 1351065, + "hash": { + "algo": "SHA256", + "value": "5306b8baaafaf60600b645f3514dde3f654ac2b0bdbae96b0d0501b18488b1b5", + "signed": false + }, + "description": "", + "url": "", + "version": "", + "content-type": "text/csv", + "encoding": null, + "compression": null, + "encryption": null, + "attributes": [ + { + "category": "dataset", + "name": "header", + "function": "count", + "comparison": "NA", + "value": 1 + }, + { + "category": "dataset", + "name": "footer", + "function": "count", + "comparison": "NA", + "value": 0 + }, + { + "category": "format", + "name": "separator", + "function": "value", + "comparison": "NA", + "value": "," + }, + { + "category": "format", + "name": "columns", + "function": "value", + "comparison": "NA", + "value": "," + }, + { + "category": "dataset", + "name": "records", + "function": "count", + "comparison": "EQ", + "value": 15044 + }, + { + "category": "dataset", + "name": "columns", + "function": "count", + "comparison": "EQ", + "value": 8 + } + ] + }, + { + "title": "BSBDirectoryJun21-303", + "uid": "e37d8ab5-e733-458d-a0b5-72368a8e201a", + "documentName": "BSBDirectoryJun21-303.csv", + "issuedDate": "2021-11-05T20:58:03", + "modified": "2021-07-01T09:00:48", + "expires": "", + "state": "active", + "author": "Meerkat@merebox.com", + "length": 1350547, + "hash": { + "algo": "SHA256", + "value": "77a1274fe6d7d239540b434b26e57c41a9d5a38b86bdb9f7e86a7874af5e8fef", + "signed": false + }, + "description": "", + "url": "", + "version": "", + "content-type": "text/csv", + "encoding": null, + "compression": null, + "encryption": null, + "attributes": [ + { + "category": "dataset", + "name": "header", + "function": "count", + "comparison": "NA", + "value": 1 + }, + { + "category": "dataset", + "name": "footer", + "function": "count", + "comparison": "NA", + "value": 0 + }, + { + "category": "format", + "name": "separator", + "function": "value", + "comparison": "NA", + "value": "," + }, + { + "category": "format", + "name": "columns", + "function": "value", + "comparison": "NA", + "value": "," + }, + { + "category": "dataset", + "name": "records", + "function": "count", + "comparison": "EQ", + "value": 15042 + }, + { + "category": "dataset", + "name": "columns", + "function": "count", + "comparison": "EQ", + "value": 8 + } + ] + }, + { + "title": "BSBDirectoryMay21-302", + "uid": "69681b42-2950-4878-a932-cbda107677ec", + "documentName": "BSBDirectoryMay21-302.csv", + "issuedDate": "2021-11-05T20:58:03", + "modified": "2021-06-01T09:00:52", + "expires": "", + "state": "active", + "author": "Meerkat@merebox.com", + "length": 1350255, + "hash": { + "algo": "SHA256", + "value": "f978eeb1a8939206a2794eccabd54f1285edb77fd5d1994b42b24fb813a21a77", + "signed": false + }, + "description": "", + "url": "", + "version": "", + "content-type": "text/csv", + "encoding": null, + "compression": null, + "encryption": null, + "attributes": [ + { + "category": "dataset", + "name": "header", + "function": "count", + "comparison": "NA", + "value": 1 + }, + { + "category": "dataset", + "name": "footer", + "function": "count", + "comparison": "NA", + "value": 0 + }, + { + "category": "format", + "name": "separator", + "function": "value", + "comparison": "NA", + "value": "," + }, + { + "category": "format", + "name": "columns", + "function": "value", + "comparison": "NA", + "value": "," + }, + { + "category": "dataset", + "name": "records", + "function": "count", + "comparison": "EQ", + "value": 15040 + }, + { + "category": "dataset", + "name": "columns", + "function": "count", + "comparison": "EQ", + "value": 8 + } + ] + }, + { + "title": "BSBDirectoryApr21-301", + "uid": "8f10458d-6256-457f-ae90-77b8286b88ba", + "documentName": "BSBDirectoryApr21-301.csv", + "issuedDate": "2021-11-05T20:58:03", + "modified": "2021-05-03T09:00:51", + "expires": "", + "state": "active", + "author": "Meerkat@merebox.com", + "length": 1352037, + "hash": { + "algo": "SHA256", + "value": "9b170364f544e6fa92ed1abe40d726d1d43685fe61dd3e4796ed0b48a47644a8", + "signed": false + }, + "description": "", + "url": "", + "version": "", + "content-type": "text/csv", + "encoding": null, + "compression": null, + "encryption": null, + "attributes": [ + { + "category": "dataset", + "name": "header", + "function": "count", + "comparison": "NA", + "value": 1 + }, + { + "category": "dataset", + "name": "footer", + "function": "count", + "comparison": "NA", + "value": 0 + }, + { + "category": "format", + "name": "separator", + "function": "value", + "comparison": "NA", + "value": "," + }, + { + "category": "format", + "name": "columns", + "function": "value", + "comparison": "NA", + "value": "," + }, + { + "category": "dataset", + "name": "records", + "function": "count", + "comparison": "EQ", + "value": 15064 + }, + { + "category": "dataset", + "name": "columns", + "function": "count", + "comparison": "EQ", + "value": 8 + } + ] + }, + { + "title": "BSBDirectoryMar21-300", + "uid": "b5d88aa6-1b40-49eb-93c1-98a6e7d06007", + "documentName": "BSBDirectoryMar21-300.csv", + "issuedDate": "2021-11-05T20:58:03", + "modified": "2021-04-01T09:00:55", + "expires": "", + "state": "active", + "author": "Meerkat@merebox.com", + "length": 1353104, + "hash": { + "algo": "SHA256", + "value": "8a566fb97e800b05dd5dec9cfd030f4f1fb10259714d33b22aaeb22788a6d19a", + "signed": false + }, + "description": "", + "url": "", + "version": "", + "content-type": "text/csv", + "encoding": null, + "compression": null, + "encryption": null, + "attributes": [ + { + "category": "dataset", + "name": "header", + "function": "count", + "comparison": "NA", + "value": 1 + }, + { + "category": "dataset", + "name": "footer", + "function": "count", + "comparison": "NA", + "value": 0 + }, + { + "category": "format", + "name": "separator", + "function": "value", + "comparison": "NA", + "value": "," + }, + { + "category": "format", + "name": "columns", + "function": "value", + "comparison": "NA", + "value": "," + }, + { + "category": "dataset", + "name": "records", + "function": "count", + "comparison": "EQ", + "value": 15065 + }, + { + "category": "dataset", + "name": "columns", + "function": "count", + "comparison": "EQ", + "value": 8 + } + ] + } + ], + "custom": [ + { + "extension": "software", + "softwareName": "MARTILQREFERENCE", + "author": "Meerkat@merebox.com", + "version": "0.0.1" + } + ] +} \ No newline at end of file diff --git a/source/golang/server/data/martilq_ckan.must b/source/golang/server/data/martilq_ckan.must new file mode 100644 index 0000000..3749d88 --- /dev/null +++ b/source/golang/server/data/martilq_ckan.must @@ -0,0 +1,41 @@ + +

This martiLQ definition has been generated from CKAN data source {{item.landingPage}}

+

The publisher is {{item.publisher}} and the contact is {{item.contactPoint}}

+ +
+ + + + + + + + + + + + +
Title{{item.title}}
UID{{item.uid}}
Description{{{describe}}}
State{{{item.state}}}
Issued{{item.issued}}
Modified{{item.modified}}
Expires{{item.expires}}
Tags{{item.tags}}
Access Level{{item.accessLevel}}
Rights{{item.rights}}
License{{item.license}}
+ +{{#item}} +
+ + + + + +{{#resources}} + + + + + + + + + + +{{/resources}} + +
TitleDocumentSizeIssuedModifiedFormatStateVersion
{{title}}{{documentName}}{{length}}{{issuedDate}}{{modified}}{{format}}{{state}}{{version}}
+{{/item}} diff --git a/source/golang/server/data/martilq_custom.must b/source/golang/server/data/martilq_custom.must new file mode 100644 index 0000000..adef5e7 --- /dev/null +++ b/source/golang/server/data/martilq_custom.must @@ -0,0 +1,36 @@ + +

This is a custom template file

+ +
+ + + + + + + + +
Title{{item.title}}
UID{{item.uid}}
Description{{{describe}}}
Issued{{item.issued}}
Modified{{item.modified}}
Access Level{{item.accessLevel}}
Rights{{item.rights}}
+ +{{#item}} +
+ + + + + +{{#resources}} + + + + + + + + + + +{{/resources}} + +
TitleDocumentSizeIssuedModifiedExpiresStateVersion
{{title}}{{documentName}}{{length}}{{issuedDate}}{{modified}}{{expires}}{{state}}{{version}}
+{{/item}} diff --git a/source/golang/server/data/martilq_def.must b/source/golang/server/data/martilq_def.must new file mode 100644 index 0000000..cb48785 --- /dev/null +++ b/source/golang/server/data/martilq_def.must @@ -0,0 +1,38 @@ + +
+ + + + + + + + + + + + +
Title{{item.title}}
UID{{item.uid}}
Description{{{describe}}}
State{{{item.state}}}
Issued{{item.issued}}
Modified{{item.modified}}
Expires{{item.expires}}
Tags{{item.tags}}
Access Level{{item.accessLevel}}
Rights{{item.rights}}
License{{item.license}}
+ +{{#item}} +
+ + + + + +{{#resources}} + + + + + + + + + + +{{/resources}} + +
TitleDocumentSizeIssuedModifiedFormatStateVersion
{{title}}{{documentName}}{{length}}{{issuedDate}}{{modified}}{{format}}{{state}}{{version}}
+{{/item}} diff --git a/source/golang/server/data/marti_test01.json b/source/golang/server/data/martilq_docs.json similarity index 99% rename from source/golang/server/data/marti_test01.json rename to source/golang/server/data/martilq_docs.json index be37d1d..2ba3758 100644 --- a/source/golang/server/data/marti_test01.json +++ b/source/golang/server/data/martilq_docs.json @@ -1,8 +1,8 @@ { "content-type": "application/vnd.martilq.json", - "title": "", + "title": "Sample martiLQ generatd framework file", "uid": "c525f5c5-ce87-4688-aa36-d0aa59d1e939", - "description": "Sample execution", + "description": "Sample execution of martiLQ execution", "issued": "2021-11-21T16:57:37", "modified": "2021-11-21T16:57:37", "expires": "", @@ -10,7 +10,7 @@ "document", "marti" ], - "publisher": "VCOFF\\meerkat", + "publisher": "meerkat", "contactPoint": "", "accessLevel": "Confidential", "rights": "Restricted", diff --git a/source/golang/server/docker-compose.yml b/source/golang/server/docker-compose.yml new file mode 100644 index 0000000..224de16 --- /dev/null +++ b/source/golang/server/docker-compose.yml @@ -0,0 +1,15 @@ +version: '3.7' + +services: + + web: + hostname: martilq-web + image: martilq-go-server:latest + container_name: matilq-web + + ports: + - 8080:8080 + + volumes: + - ./data:/home/data + - ../../../docs:/home/docs diff --git a/source/golang/server/main b/source/golang/server/main new file mode 100644 index 0000000..2d79739 Binary files /dev/null and b/source/golang/server/main differ diff --git a/source/golang/server/main.go b/source/golang/server/main.go index 3e1aa80..025b2a2 100644 --- a/source/golang/server/main.go +++ b/source/golang/server/main.go @@ -11,43 +11,62 @@ import ( func main() { port := flag.String("p", "8080", "Http listen port") - directory := flag.String("d", "static", "Static directory content") + staticDirectory := flag.String("s", "static", "Static directory content") docsDirectory := flag.String("docs", "", "Docs directory content") + dataDirectory := flag.String("data", "", "Data directory content") + trace := flag.Bool("trace", false, "Produce trace logs") flag.Parse() + if *trace == true { + log.Printf("static folder: %s\n", *staticDirectory) + log.Printf("data folder: %s\n", *dataDirectory) + log.Printf("docs folder: %s\n", *docsDirectory) + } + http.HandleFunc("/data/", func( res http.ResponseWriter, req *http.Request ) { - //log.Printf("Data file %s \n", req.URL.Path) - http.ServeFile(res, req, req.URL.Path[1:]); + safePath := ValidatePath(filepath.FromSlash(req.URL.Path[1:])) + if (*dataDirectory != "") { + safePath = filepath.FromSlash(filepath.Join(*dataDirectory, strings.Replace(safePath, "data/", "", 1))) + } + http.ServeFile(res, req, safePath) }) http.HandleFunc("/docs/", func( res http.ResponseWriter, req *http.Request ) { + localPath := "" if (*docsDirectory == "") { temp := "../../.." docsDirectory = &temp + localPath = ValidatePath(filepath.FromSlash(*docsDirectory+req.URL.Path)) + } else { + localPath = ValidatePath(filepath.FromSlash(*docsDirectory+strings.Replace(req.URL.Path, "docs/", "", 1))) + } + if *trace == true { + log.Printf("fetch docs: \"%s\"", localPath) } - //log.Printf("Docs file %s \n", req.URL.Path) - localPath := filepath.FromSlash(*docsDirectory+req.URL.Path) f, err := os.Open(localPath) if err != nil { - http.ServeFile(res, req, filepath.FromSlash(*directory + "/404.html")); + log.Printf("fetch docs error: \"%s\" with %s", localPath, err) + http.ServeFile(res, req, filepath.FromSlash(*staticDirectory + "/404.html")); } else { s, err := f.Stat() if err != nil || s.IsDir() { - http.ServeFile(res, req, filepath.FromSlash(*directory + "/404.html")); + log.Printf("fetch docs stat error: \"%s\"", localPath) + http.ServeFile(res, req, filepath.FromSlash(*staticDirectory + "/404.html")) } else { - http.ServeFile(res, req, localPath); + http.ServeFile(res, req, localPath) } } }) - fileServer := http.FileServer(FileSystem{http.Dir(*directory)}) + fileServer := http.FileServer(FileSystem{http.Dir(*staticDirectory)}) http.Handle("/", fileServer) - log.Printf("Serving \"%s\" on HTTP port: %s\n", *directory, *port) + log.Printf("Serving on HTTP port: %s\n", *port) log.Fatal(http.ListenAndServe(":"+*port, nil)) } + type FileSystem struct { fs http.FileSystem } @@ -59,7 +78,6 @@ func (fs FileSystem) Open(path string) (http.File, error) { } s, err := f.Stat() - //log.Printf("File %s \n", path) if s.IsDir() { index := strings.TrimSuffix(path, "/") + "/index.html" if _, err := fs.fs.Open(index); err != nil { @@ -68,4 +86,11 @@ func (fs FileSystem) Open(path string) (http.File, error) { } return f, nil +} + +func ValidatePath(path string) string { + + safePath := path + + return safePath } \ No newline at end of file diff --git a/source/golang/server/static/browse.html b/source/golang/server/static/browse.html new file mode 100644 index 0000000..8379728 --- /dev/null +++ b/source/golang/server/static/browse.html @@ -0,0 +1,62 @@ + + + + + + + + + MartiLQ Definition + + + + + + + + + + + +
+
+ +
+ +

MartiLQ definition

+
+
+
+
+
+
+ + + + + + + + + + diff --git a/source/golang/server/static/index.html b/source/golang/server/static/index.html index 908f93f..f69f1de 100644 --- a/source/golang/server/static/index.html +++ b/source/golang/server/static/index.html @@ -6,10 +6,10 @@ - MartiLQ Dashboard + MartiLQ Definition - + - - -
@@ -46,21 +41,48 @@

MartiLQ definition

-
+ +

The following martiLQ definitions are provided as samples

+

The server code for this is available and the code can be changed to reflect your actual or sample definitions

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
DefinitionDescription
martilq_afsl.jsonAustralian Financial Services License sample
martilq_asic.jsonAustralian Securities and Incetsments Commission adviser sample
martilq_bsb.jsonAustralian Payment Network BSB sample
martilq_docs.jsonMartiLQ documentation folder sample
+
- diff --git a/source/golang/server/static/js/app.js b/source/golang/server/static/js/app.js deleted file mode 100644 index a5f29bd..0000000 --- a/source/golang/server/static/js/app.js +++ /dev/null @@ -1,103 +0,0 @@ - -"use strict"; - -const output = document.querySelector(".output"); -var localJsonFile = "data/marti_test_asic.json"; - -var btn = document.getElementById("loadBtn"); -btn.onclick = dataLoadFunction; - -function dataLoadFunction() { - var loadDef = document.getElementById("loaddefinition") - fetchData("data/"+loadDef.value); -} - -window.addEventListener("DOMContentLoaded", () => { - var urlParams = new URLSearchParams(window.location.search); - if (urlParams.has('martilq')) { - var loadDef = urlParams.get('martilq'); - fetchData("data/"+ loadDef); - var ld = document.getElementById("loaddefinition") - ld.value = loadDef - } else { - output.textContent = "Please supply a MartiLQ definition to load, such as \"marti_test_asic.json\""; - } -}); - -function fetchData(dataFile) { - output.textContent = "Loading...."; - - fetch(dataFile) - .then((response) => response.json()) - .then((data) => { - output.innerHTML = ""; - - var hdr = itemHeader(data) - output.append(hdr); - - const br = document.createElement("br"); - output.append(br); - - const tble = document.createElement("table"); - tble.classList.add("table"); - tble.classList.add("table-striped"); - tble.classList.add("table-sm"); - - var thd = document.createElement("thead"); - var th = document.createElement("tr"); - //scope="col" - th.innerHTML = "TitleDocumentSizeIssuedModifiedExpiresStateVersion"; - thd.append(th); - tble.append(thd); - - var tby = document.createElement("tbody"); - data.resources.forEach((el) => { - //console.log(el); - jsonList(tby, el); - }); - tble.append(tby); - output.append(tble); - }); -} - -function jsonList(tble, item) { - const tr = document.createElement("tr"); - tr.innerHTML = itemRow(item); - tble.append(tr); -} - - -function itemHeader(item) { - - const hdr = document.createElement("table"); - hdr.classList.add("table"); - hdr.classList.add("table-striped"); - hdr.classList.add("table-sm"); - - var describe = item.description.replace(/\r\n/g, "
"); - var rows = `Title${item.title}`; - rows = rows+ `UID${item.uid}`; - rows = rows+ `Description${describe}`; - rows = rows+ `Issued${item.issued}`; - rows = rows+ `Modified${item.modified}`; - rows = rows+ `Access Level${item.accessLevel}`; - rows = rows+ `Rights${item.rights}`; - hdr.innerHTML = rows; - - return hdr -} - - -function itemRow(item) { - - var row = `${item.title}`; - row = row + `${item.documentName}`; - row = row + `${item.length}`; - row = row + `${item.issuedDate}`; - row = row + `${item.modified}`; - row = row + `${item.expires}`; - row = row + `${item.state}`; - row = row + `${item.version}`; - - return row -} diff --git a/source/golang/server/static/js/martilq_app.js b/source/golang/server/static/js/martilq_app.js new file mode 100644 index 0000000..12666c0 --- /dev/null +++ b/source/golang/server/static/js/martilq_app.js @@ -0,0 +1,78 @@ + +"use strict"; + +const output = document.querySelector(".output"); +var localJsonFile = "data/marti_test_asic.json"; + +var btn = document.getElementById("loadBtn"); +btn.onclick = dataLoadFunction; + +function dataLoadFunction() { + var loadDef = document.getElementById("loaddefinition") + if (loadDef.value.startsWith("http://") || loadDef.value.startsWith("https://")) { + fetchData(loadDef.value); + } else { + fetchData("data/"+ loadDef.value); + } +} + + +var definition_must = ""; +var jdata = {}; + +window.addEventListener("DOMContentLoaded", () => { + + var urlParams = new URLSearchParams(window.location.search); + if (urlParams.has('martilq')) { + var loadDef = urlParams.get('martilq'); + if (loadDef.startsWith("http://") || loadDef.startsWith("https://")) { + fetchData(loadDef); + } else { + fetchData("data/"+ loadDef); + } + var ld = document.getElementById("loaddefinition") + ld.value = loadDef + } else { + output.innerHTML = "Please supply a MartiLQ definition to load, such as \"martilq_asic.json\""; + } +}); + +function fetchData(dataFile) { + output.textContent = "Loading...."; + + fetch(dataFile) + .then((response) => response.json()) + .then((data) => { + + var template = "data/martilq_def.must"; + jdata["item"] = data; + jdata["describe"] = data.description.replace(/\r\n/g, "
"); + + if (data["custom"]) { + data.custom.forEach((el) => { + if (el.extension == "template" && el.renderer == "MartiReference:Mustache") { + template = el.url; + } + }); + } + // Use the template + fetchMust(template); + + }); +} + + +function fetchMust(mustTemplateFile) { + + fetch(mustTemplateFile) + .then((response) => response.text()) + .then((data) => { + definition_must = data + + const dMust = document.createElement("div"); + dMust.innerHTML = Mustache.render(definition_must, jdata); + output.innerHTML = ""; + output.append(dMust); + }); + +} diff --git a/test/powershell/test_MartiLQCkan.ps1 b/test/powershell/test_MartiLQCkan.ps1 index 5520659..3e3088f 100644 --- a/test/powershell/test_MartiLQCkan.ps1 +++ b/test/powershell/test_MartiLQCkan.ps1 @@ -50,6 +50,7 @@ $oMarti.tags += "ckan" $oMarti.tags += "gov" $oMarti.tags += "au" $oMarti.publisher = "Australian Securities and Investments Commission (ASIC)" +$oMarti.landingPage = "https://data.gov.au/dataset/ds-dga-ab7eddce-84df-4098-bc8f-500d0d9776d1/details?q=AFS%20Licensee%20Dataset%20extract%20as" $x = ConvertTo-Json -InputObject $oMarti -Depth 5 Set-Content -Path $outFile -Value $x Write-Host "Wrote converted definition to: $outFile"