diff --git a/.gitignore b/.gitignore index 35710fa..09e873e 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ pom.xml.asc .calva .clj-kondo .lsp + +docs/samples/ diff --git a/README.md b/README.md index 0a048c8..cae8aec 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,8 @@ The full range of command-line switches is as follows: Note, though, that internationalisation files for languages other than British English have not yet been written, and that one is not complete. +Note also that reification is not, at the time of writing, working. + The following severity levels are understood: 0. `info` things which are not actuallys fault, but issues noted during @@ -48,7 +50,6 @@ The following severity levels are understood: 4. `critical` instances where I believe the fault means that the object cannot be meaningfully processed. - ## Examples ... @@ -59,23 +60,12 @@ Full documentation is [here](https://simon-brooke.github.io/dog-and-duck/). ### Bugs -... - -### Any Other Sections -### That You Think -### Might be Useful +Many. Ducks like bugs. ## License -Copyright © 2023 FIXME +Copyright © 2023 Simon Brooke -This program and the accompanying materials are made available under the -terms of the Eclipse Public License 2.0 which is available at -http://www.eclipse.org/legal/epl-2.0. - -This Source Code may also be made available under the following Secondary -Licenses when the conditions for such availability set forth in the Eclipse -Public License, v. 2.0 are satisfied: GNU General Public License as published by +This Source Code is made available under GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your -option) any later version, with the GNU Classpath Exception which is available -at https://www.gnu.org/software/classpath/license.html. +option) any later version. diff --git a/resources/public/css/ft-syntax-highlight.css b/docs/css/ft-syntax-highlight.css similarity index 100% rename from resources/public/css/ft-syntax-highlight.css rename to docs/css/ft-syntax-highlight.css diff --git a/resources/public/css/style.css b/docs/css/style.css similarity index 100% rename from resources/public/css/style.css rename to docs/css/style.css diff --git a/scan-test-docs.sh b/scan-test-docs.sh new file mode 100755 index 0000000..2cc5ecf --- /dev/null +++ b/scan-test-docs.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +docs=../dog-and-duck/resources/activitystreams-test-documents/ + +for file in ${docs}/*.json +do + name=`basename ${file} | sed s/json$/html/` + + echo ${name} + java -jar target/uberjar/quack-0.1.0-SNAPSHOT-standalone.jar \ + -i ${file} \ + -o "docs/samples/${name}" \ + -f html +done \ No newline at end of file diff --git a/src/dog_and_duck/quack/core.clj b/src/dog_and_duck/quack/core.clj index db7937b..717326b 100644 --- a/src/dog_and_duck/quack/core.clj +++ b/src/dog_and_duck/quack/core.clj @@ -11,7 +11,7 @@ [dog-and-duck.quack.utils :refer [filter-severity safe-keyword]] [hiccup.core :refer [html]] [scot.weft.i18n.core :refer [*config* - get-message + get-message parse-accept-language-header]] [trptr.java-wrapper.locale :as locale]) (:gen-class)) @@ -34,8 +34,8 @@ (def ^:const stylesheet-url ;; TODO: fix this to github pages before go live - ;;"https://simon-brooke.github.io/quack/style.css" - "resources/public/css/style.css") + ;;"https://simon-brooke.github.io/quack/css/style.css" + "../css/style.css") (def cli-options ;; An option with a required argument @@ -116,20 +116,18 @@ second) (catch Exception _ nil))])) -(defn- output-html-text-analysed +(defn- output-html-text-analysed [options] [:div {:class "text-analysed"} - [:h2 :text-analysed] + [:h2 (get-message :text-analysed)] [:pre {:class "ft-syntax-highlight" :data-syntax "javascript" :data-syntax-theme "bootstrap" :data-ui-theme "light"} (with-out-str - (json/pprint - (read-str - (slurp - (:input options)))))]]) + (slurp + (:input options)))]]) (defn output-html [faults options] diff --git a/src/dog_and_duck/quack/objects.clj b/src/dog_and_duck/quack/objects.clj index 9dc46ad..ec4efa0 100644 --- a/src/dog_and_duck/quack/objects.clj +++ b/src/dog_and_duck/quack/objects.clj @@ -419,7 +419,7 @@ :if-invalid [:must :invalid-units] ;; the narrative says that `anyURI`, but actually unless it's a recognised ;; unit the property is useless. These are the units explicitly specified. - :validator (fn [pv] (#{"cm" "feet" "inches" "km" "m" "miles"} pv))} + :validator (fn [pv] (truthy? (#{"cm" "feet" "inches" "km" "m" "miles"} pv)))} :updated {:functional true :if-invalid [:must :invalid-updated] :validator xsd-date-time?} @@ -460,7 +460,7 @@ ;; from an 'or-faults' function which did not ;; return faults (fault-list? r) (concat f r) - (false? r) (list f) + (false? r) f :else (doall (warn "Unexpected return value from validator" {:return r diff --git a/src/dog_and_duck/quack/scratch.clj b/src/dog_and_duck/quack/scratch.clj index 7a6e1d0..f40107b 100644 --- a/src/dog_and_duck/quack/scratch.clj +++ b/src/dog_and_duck/quack/scratch.clj @@ -13,4 +13,11 @@ (second (:if-missing %))) (vals object-expected-properties)))) found (read-string (slurp (str "resources/i18n/" language ".edn")))] - (sort (remove found tokens)))) \ No newline at end of file + (sort (remove found tokens)))) + +;; (def f {:arguments {:reports ({:@context "https://simon-brooke.github.io/dog-and-duck/codox/Validation_Faults.html", +;; :id "https://illuminator.local/fault/25785:1673378166063", :type "Fault", :severity :should, :fault :no-context, :narrative "Section 3 of the ActivityPub specification states Implementers SHOULD include the ActivityPub context in their object definitions`."} +;; {:@context "https://simon-brooke.github.io/dog-and-duck/codox/Validation_Faults.html", +;; :id "https://illuminator.local/fault/25785:1673378166063", :type "Fault", :severity :minor, :fault :no-id-transient, :narrative "The ActivityPub specification allows objects without `id` fields only if they are intentionally transient; even so it is preferred that the object should have an explicit null id."} +;; ({:@context "https://simon-brooke.github.io/dog-and-duck/codox/Validation_Faults.html", +;; :id "https://illuminator.local/fault/25785:1673378166069", :type "Fault", :severity :must, :fault :invalid-type, :narrative "invalid-type"})), :severity :info}}) \ No newline at end of file