Docstrings and package-renaming

No functional changes; simply adds a couple
docstrings and renames
…/ACTIVITY-VOCABULARY → [AS]/VOCAB/ACTIVITY
…/LITEPUB → ACTIVITYPUB-SERVIST/VOCAB/LITEPUB
This commit is contained in:
Jaidyn Ann 2024-09-03 12:09:18 -05:00
parent b15c138378
commit 86b8d0a514
66 changed files with 69 additions and 47 deletions

View File

@ -9,31 +9,41 @@
:homepage "https://hak.xwx.moe/jadedctrl/activity-servist" :homepage "https://hak.xwx.moe/jadedctrl/activity-servist"
:in-order-to ((test-op (test-op "activitypub/tests"))) :in-order-to ((test-op (test-op "activitypub/tests")))
:depends-on ("activity-servist/signatures" :depends-on (:activity-servist/signatures
"alexandria" "clack" "dexador" :alexandria :clack :dexador
"local-time" "purl" "str" "webtentacle" "yason") :local-time :purl :str :webtentacle :yason)
:components ((:file "src/activity-servist"))) :components ((:file "src/activity-servist")))
(asdf:defsystem "activity-servist/activity-vocabulary" (asdf:defsystem "activity-servist/vocab"
:version "0.0"
:license "AGPLv3"
:description "A-S subpackage providing a standard vocabulary for ActivityPub programs."
:author "Jaidyn Ann <jadedctrl@posteo.at>"
:homepage "https://hak.xwx.moe/jadedctrl/activity-servist"
:depends-on (:activity-servist/vocab/activity :activity-servist/vocab/litepub))
(asdf:defsystem "activity-servist/vocab/activity"
:version "0.0" :version "0.0"
:license "AGPLv3" :license "AGPLv3"
:description "A-S subpackage containing ActivityVocabulary class-definitions." :description "A-S subpackage containing ActivityVocabulary class-definitions."
:author "Jaidyn Ann <jadedctrl@posteo.at>" :author "Jaidyn Ann <jadedctrl@posteo.at>"
:homepage "https://hak.xwx.moe/jadedctrl/activity-servist" :homepage "https://hak.xwx.moe/jadedctrl/activity-servist"
:depends-on ("activity-servist/json-ld") :depends-on (:activity-servist/json-ld)
:components ((:file "src/activity-vocabulary"))) :components ((:file "src/activity-vocabulary")))
(asdf:defsystem "activity-servist/litepub" (asdf:defsystem "activity-servist/vocab/litepub"
:version "0.0" :version "0.0"
:license "AGPLv3" :license "AGPLv3"
:description "A-S subpackage providing an expanded vocabulary." :description "A-S subpackage providing an expanded vocabulary."
:author "Jaidyn Ann <jadedctrl@posteo.at>" :author "Jaidyn Ann <jadedctrl@posteo.at>"
:homepage "https://hak.xwx.moe/jadedctrl/activity-servist" :homepage "https://hak.xwx.moe/jadedctrl/activity-servist"
:depends-on ("activity-servist/activity-vocabulary") :depends-on (:activity-servist/vocab/activity)
:components ((:file "src/litepub"))) :components ((:file "src/litepub")))
@ -44,7 +54,7 @@
:author "Jaidyn Ann <jadedctrl@posteo.at>" :author "Jaidyn Ann <jadedctrl@posteo.at>"
:homepage "https://hak.xwx.moe/jadedctrl/activity-servist" :homepage "https://hak.xwx.moe/jadedctrl/activity-servist"
:depends-on ("alexandria" "dexador" "str" "yason") :depends-on (:alexandria :dexador :str :yason)
:components ((:file "src/json-ld"))) :components ((:file "src/json-ld")))
@ -55,21 +65,22 @@
:author "Jaidyn Ann <jadedctrl@posteo.at>" :author "Jaidyn Ann <jadedctrl@posteo.at>"
:homepage "https://hak.xwx.moe/jadedctrl/activity-servist" :homepage "https://hak.xwx.moe/jadedctrl/activity-servist"
:depends-on ("cl-base64" "flexi-streams" "inferior-shell" "ironclad" "str") :depends-on (:cl-base64 :flexi-streams :inferior-shell :ironclad :str)
:components ((:file "src/signatures"))) :components ((:file "src/signatures")))
;;; Tests ;;; Tests
;;; ————————————————————————————————————— ;;; —————————————————————————————————————
(asdf:defsystem "activity-servist/tests/activity-vocabulary" (asdf:defsystem "activity-servist/tests/vocab/activity"
:version "0.0" :version "0.0"
:license "AGPLv3" :license "AGPLv3"
:author "Jaidyn Ann <jadedctrl@posteo.at>" :author "Jaidyn Ann <jadedctrl@posteo.at>"
:description "Tests the activity-servist/activity-vocabulary package, and indirectly /json-ld." :description "Tests the activity-servist/vocab/activity package, and indirectly /json-ld."
:depends-on (:activity-servist/activity-vocabulary :alexandria :lisp-unit2) :depends-on (:activity-servist/vocab/activity
:components ((:file "t/activity-vocabulary"))) :alexandria :lisp-unit2)
:components ((:file "t/vocab/activity")))
(asdf:defsystem "activity-servist/tests/signatures" (asdf:defsystem "activity-servist/tests/signatures"
@ -78,7 +89,8 @@
:author "Jaidyn Ann <jadedctrl@posteo.at>" :author "Jaidyn Ann <jadedctrl@posteo.at>"
:description "Tests for the the activity-servist/signatures package." :description "Tests for the the activity-servist/signatures package."
:depends-on (:activity-servist/signatures :lisp-unit2) :depends-on (:activity-servist/signatures
:lisp-unit2)
:components ((:file "t/signatures"))) :components ((:file "t/signatures")))
@ -88,7 +100,7 @@
:author "Jaidyn Ann <jadedctrl@posteo.at>" :author "Jaidyn Ann <jadedctrl@posteo.at>"
:description "Tests for all activity-servist subpacakges." :description "Tests for all activity-servist subpacakges."
:depends-on (:activity-servist/tests/activity-vocabulary :depends-on (:activity-servist/tests/vocab/activity
:activity-servist/tests/signatures :activity-servist/tests/signatures
:alexandria :lisp-unit2) :alexandria :lisp-unit2)
:components ((:file "t/t"))) :components ((:file "t/t")))
@ -100,6 +112,6 @@
`(defmethod asdf:perform ((o asdf:test-op) (c (eql (asdf:find-system ',package)))) `(defmethod asdf:perform ((o asdf:test-op) (c (eql (asdf:find-system ',package))))
(eval (read-from-string (format nil "(~A:run-with-summary)" ',package))))) (eval (read-from-string (format nil "(~A:run-with-summary)" ',package)))))
(define-asdf-testing activity-servist/tests/activity-vocabulary) (define-asdf-testing activity-servist/tests/vocab/activity)
(define-asdf-testing activity-servist/tests/signatures) (define-asdf-testing activity-servist/tests/signatures)
(define-asdf-testing activity-servist/tests) (define-asdf-testing activity-servist/tests)

View File

@ -1,4 +1,4 @@
;;;; activity-vocabulary: Base classes for ActivityStreams. ;;;; activity-vocabulary: Base vocabulary classes for ActivityStreams.
;; Copyright © 2024 Jaidyn Ann <jadedctrl@posteo.at> ;; Copyright © 2024 Jaidyn Ann <jadedctrl@posteo.at>
;; ;;
@ -15,9 +15,9 @@
;; You should have received a copy of the GNU General Public License ;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>. ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(defpackage #:activity-servist/activity-vocabulary (defpackage #:activity-servist/vocab/activity
(:use #:cl) (:use #:cl)
(:nicknames "AS/AV" "ACTIVITY-VOCABULARY") (:nicknames "AS/V/A" "ACTIVITY-VOCABULARY")
(:shadow #:block #:delete #:ignore #:listen #:read #:remove) (:shadow #:block #:delete #:ignore #:listen #:read #:remove)
;; One should never USE this package, since some class-names shadow ;; One should never USE this package, since some class-names shadow
;; core Common Lisp symbols! Beware! :P ;; core Common Lisp symbols! Beware! :P
@ -53,7 +53,7 @@
:relationship-object :relationship-relationship :relationship-subject :relationship-object :relationship-relationship :relationship-subject
:tombstone-former-type :tombstone-deleted)) :tombstone-former-type :tombstone-deleted))
(in-package #:activity-servist/activity-vocabulary) (in-package #:activity-servist/vocab/activity)
(defmacro define-json-empty-types (superclass context &rest direct-children) (defmacro define-json-empty-types (superclass context &rest direct-children)
"For each list of DIRECT-CHILDREN, a hollow JSON subtype and CLOS subclass "For each list of DIRECT-CHILDREN, a hollow JSON subtype and CLOS subclass
@ -176,10 +176,10 @@ The notion of “context” used is intentionally vague. The intended function i
;; looking at Links properties), but its implied by the Mention example. ;; looking at Links properties), but its implied by the Mention example.
(json-ld:define-json-type (link "Link") () (json-ld:define-json-type (link "Link") ()
"https://www.w3.org/ns/activitystreams" "https://www.w3.org/ns/activitystreams"
((@id ((json-ld:@id
"id" "id"
:documentation "Provides the globally unique identifier for a Link.") :documentation "Provides the globally unique identifier for a Link.")
(@type (json-ld:@type
"type" "type"
:documentation "Identifies the Link type. Multiple values may be specified.") :documentation "Identifies the Link type. Multiple values may be specified.")
(height (height

View File

@ -44,9 +44,19 @@ For example: “https://www.w3.org/ns/activitystreams#Object”
The default value * refers to the base JSON-LD-OBJECT type.") The default value * refers to the base JSON-LD-OBJECT type.")
(defvar *http-cache* (make-hash-table :test #'equal)) (defvar *json-types* (make-hash-table :test #'equal)
(defvar *json-types* (make-hash-table :test #'equal)) "Stores descriptions of each JSON-type, mapping type-IRI to class-name and property-name to slot-name.
(defvar *class-defs* (make-hash-table)) Used during encoding an object to JSON, for finding type/property-names from class/slot-names.
Keys are the type-IRI (e.g., (https://www.w3.org/ns/activitystreams#Accept), and values are an irregular association list, of the form:
((CLASS-NAME-SYMBOL . TYPE-NAME) (PROPERTY-IRI SLOT-NAME-SYMBOL . PROPERTY-NAME) )")
(defvar *class-defs* (make-hash-table)
"Stores the slot definitions of classes, stored directly from DEFINE-JSON-TYPE.
Used for the :UPDATE feature of DEFINE-JSON-TYPE, so you can add a slot to a pre-existing class without having to redefine the old slots.")
(defvar *http-cache* (make-hash-table :test #'equal)
"Caches context-texts fetched over HTTP.
Maps URLs to text-content, so we dont have to download the same context again and again.")

View File

@ -15,11 +15,11 @@
;; You should have received a copy of the GNU General Public License ;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>. ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(defpackage #:activity-servist/litepub (defpackage #:activity-servist/vocab/litepub
(:use #:cl) (:use #:cl)
(:nicknames "AS/LP" "LITEPUB")) (:nicknames "AS/V/LP" "LITEPUB"))
(in-package #:activity-servist/litepub) (in-package #:activity-servist/vocab/litepub)
;;; Globals ;;; Globals
@ -38,7 +38,7 @@ Defaults to a copy at jam.xwx.moe — because why not? ¯\_(ツ)_/¯")
() ()
(:documentation "The base class used for Litepub objects.")) (:documentation "The base class used for Litepub objects."))
(json-ld:define-json-type (as/av:object "Object") (as/jld::json-ld-object litepub-object) *litepub-uri* (json-ld:define-json-type (as/v/a:object "Object") (as/jld::json-ld-object litepub-object) *litepub-uri*
((atom-uri ((atom-uri
"atomUri" "atomUri"
:documentation "A string containing a URI to an Atom-feed alternative representation of an object. :documentation "A string containing a URI to an Atom-feed alternative representation of an object.
@ -60,7 +60,7 @@ Seemingly may be set in the Activity modifying the Note, or the Note itself.")
(:update 't)) (:update 't))
(json-ld:define-json-type (as/av:activity "Activity") (as/av:object) *litepub-uri* (json-ld:define-json-type (as/v/a:activity "Activity") (as/v/a:object) *litepub-uri*
(;; https://blog.dereferenced.org/leveraging-json-ld-compound-typing-for-behavioural-hinting-in-activitypub (;; https://blog.dereferenced.org/leveraging-json-ld-compound-typing-for-behavioural-hinting-in-activitypub
(invisible (invisible
"invisible" "invisible"
@ -86,7 +86,7 @@ Potentially deprecated/very uncommon.")
;;; Extended Activity types ;;; Extended Activity types
;;; ———————————————————————————————————————— ;;; ————————————————————————————————————————
(json-ld:define-json-type (as/av:update "Update") (as/av:activity) *litepub-uri* (json-ld:define-json-type (as/v/a:update "Update") (as/v/a:activity) *litepub-uri*
(;; https://ostatus.github.io/spec/OStatus%201.0%20Draft%202.html#rfc.section.6 (;; https://ostatus.github.io/spec/OStatus%201.0%20Draft%202.html#rfc.section.6
(conversation (conversation
"conversation" "conversation"
@ -98,7 +98,7 @@ The target and origin typically have no defined meaning.")
;; https://codeberg.org/fediverse/fep/src/branch/main/fep/c0e0/fep-c0e0.md ;; https://codeberg.org/fediverse/fep/src/branch/main/fep/c0e0/fep-c0e0.md
(json-ld:define-json-type (emoji-react "EmojiReact") (as/av:like) *litepub-uri* (json-ld:define-json-type (emoji-react "EmojiReact") (as/v/a:like) *litepub-uri*
() ()
(:documentation "This activity is similar to Like activity. In addition to standard properties of Like activity, EmojiReact activity MUST have a content property. Reaction content MUST be either a single unicode grapheme, or a shortcode of a custom emoji. If custom emoji is used, EmojiReact activity MUST have a tag property containing a single Emoji object.")) (:documentation "This activity is similar to Like activity. In addition to standard properties of Like activity, EmojiReact activity MUST have a content property. Reaction content MUST be either a single unicode grapheme, or a shortcode of a custom emoji. If custom emoji is used, EmojiReact activity MUST have a tag property containing a single Emoji object."))
@ -106,7 +106,7 @@ The target and origin typically have no defined meaning.")
;;; Extended Actor types ;;; Extended Actor types
;;; ———————————————————————————————————————— ;;; ————————————————————————————————————————
(json-ld:define-json-type (as/av:person "Person") (as/av:object) *litepub-uri* (json-ld:define-json-type (as/v/a:person "Person") (as/v/a:object) *litepub-uri*
(;; https://docs.joinmastodon.org/spec/activitypub/#discoverable (;; https://docs.joinmastodon.org/spec/activitypub/#discoverable
(public-key (public-key
"publicKey" "publicKey"
@ -135,12 +135,12 @@ One known capabilitity-name is Pleromas “acceptsChatMessages”."))
;;; Extended Object types ;;; Extended Object types
;;; ———————————————————————————————————————— ;;; ————————————————————————————————————————
;; https://docs.joinmastodon.org/spec/activitypub/#Emoji ;; https://docs.joinmastodon.org/spec/activitypub/#Emoji
(json-ld:define-json-type (emoji "Emoji") (as/av:object) *litepub-uri* (json-ld:define-json-type (emoji "Emoji") (as/v/a:object) *litepub-uri*
() ()
(:documentation "Represents a custom-emoji, with a shortcode (NAME), ID, and ICON (containing MEDIA-TYPE and URL).")) (:documentation "Represents a custom-emoji, with a shortcode (NAME), ID, and ICON (containing MEDIA-TYPE and URL)."))
(json-ld:define-json-type (as/av:note "Note") (as/av:object) *litepub-uri* (json-ld:define-json-type (as/v/a:note "Note") (as/v/a:object) *litepub-uri*
(;; https://misskey-hub.net/ns#_misskey_quote (;; https://misskey-hub.net/ns#_misskey_quote
(quote-url (quote-url
"quoteUrl" "quoteUrl"
@ -162,7 +162,7 @@ It is, however, unclear which one will win out in the end. The implementer prefe
;; https://docs-develop.pleroma.social/backend/development/ap_extensions/#chatmessages ;; https://docs-develop.pleroma.social/backend/development/ap_extensions/#chatmessages
(json-ld:define-json-type (chat-message "ChatMessage") (as/av:note) *litepub-uri* (json-ld:define-json-type (chat-message "ChatMessage") (as/v/a:note) *litepub-uri*
() ()
(:documentation "Represents a private and one-on-one chat-message. (:documentation "Represents a private and one-on-one chat-message.
Similar to Notes in creation and use, but TO may contain only one recipient. Similar to Notes in creation and use, but TO may contain only one recipient.
@ -174,12 +174,12 @@ Potentially very uncommon — it is used by at least Pleroma."))
Will set/get the value of either QUOTE-URL or QUOTE-URI, depending on which is currently in use. Will set/get the value of either QUOTE-URL or QUOTE-URI, depending on which is currently in use.
In case of doubt, QUOTE-URL is preferred.")) In case of doubt, QUOTE-URL is preferred."))
(defmethod note-quote-url ((obj as/av:note)) (defmethod note-quote-url ((obj as/v/a:note))
(or (and (slot-boundp note 'quote-url) (slot-value note 'quote-url)) (or (and (slot-boundp note 'quote-url) (slot-value note 'quote-url))
(and (slot-boundp note 'quote-uri) (slot-value note 'quote-uri)))) (and (slot-boundp note 'quote-uri) (slot-value note 'quote-uri))))
(defgeneric (setf note-quote-url) (obj value)) (defgeneric (setf note-quote-url) (obj value))
(defmethod (setf note-quote-url) ((obj as/av:note) value) (defmethod (setf note-quote-url) ((obj as/v/a:note) value)
(if (slot-boundp note 'quote-uri) (if (slot-boundp note 'quote-uri)
(setf (slot-value note 'quote-uri) value) (setf (slot-value note 'quote-uri) value)
(setf (slot-value note 'quote-url) value))) (setf (slot-value note 'quote-url) value)))
@ -189,6 +189,6 @@ In case of doubt, QUOTE-URL is preferred."))
;;; Extended Link types ;;; Extended Link types
;;; ———————————————————————————————————————— ;;; ————————————————————————————————————————
;; https://docs.joinmastodon.org/spec/activitypub/#Hashtag ;; https://docs.joinmastodon.org/spec/activitypub/#Hashtag
(json-ld:define-json-type (hashtag "Hashtag") (as/av:link litepub-object) *litepub-uri* (json-ld:define-json-type (hashtag "Hashtag") (as/v/a:link litepub-object) *litepub-uri*
() ()
(:documentation "Similar to Mentions, a Hashtag is used to link a post to given topics. Should be stored in a TAG slot, and contain NAME (#hashtag) and HREF (link to a servers hashtag listing).")) (:documentation "Similar to Mentions, a Hashtag is used to link a post to given topics. Should be stored in a TAG slot, and contain NAME (#hashtag) and HREF (link to a servers hashtag listing)."))

View File

@ -25,7 +25,7 @@
(defun run () (defun run ()
"Run tests from all activity-servist subpackages." "Run tests from all activity-servist subpackages."
(activity-servist/tests/signatures:run) (activity-servist/tests/signatures:run)
(activity-servist/tests/activity-vocabulary:run)) (activity-servist/tests/vocab/activity:run))
(defun run-with-summary () (defun run-with-summary ()
"Run tests with summary for all activity-servist subpackages." "Run tests with summary for all activity-servist subpackages."

View File

@ -1,4 +1,4 @@
;;;; activity-servist/tests/activity-vocabulary: Testing activity-vocabulary. ;;;; activity-servist/tests/vocab/activity: Testing activity-vocabulary.
;; Copyright © 2024 Jaidyn Levesque <jadedctrl@posteo.at> ;; Copyright © 2024 Jaidyn Levesque <jadedctrl@posteo.at>
;; ;;
@ -15,17 +15,17 @@
;; You should have received a copy of the GNU Affero General Public License ;; You should have received a copy of the GNU Affero General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>. ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(defpackage :activity-servist/tests/activity-vocabulary (defpackage :activity-servist/tests/vocab/activity
(:use :cl :lisp-unit2) (:use :cl :lisp-unit2)
(:nicknames "AS/T/AV") (:nicknames "AS/T/V/AV")
(:export :run :run-with-summary)) (:export :run :run-with-summary))
(in-package :activity-servist/tests/activity-vocabulary) (in-package :activity-servist/tests/vocab/activity)
(defun run () (defun run ()
"Run all ACTIVITY-VOCABULARY tests." "Run all ACTIVITY-VOCABULARY tests."
(let ((json-ld:*default-json-type* "https://www.w3.org/ns/activitystreams#Object")) (let ((json-ld:*default-json-type* "https://www.w3.org/ns/activitystreams#Object"))
(lisp-unit2:run-tests :package :activity-servist/tests/activity-vocabulary))) (lisp-unit2:run-tests :package :activity-servist/tests/vocab/activity)))
(defun run-with-summary () (defun run-with-summary ()
"Run tests with summary for ACTIVITY-VOCABULARY." "Run tests with summary for ACTIVITY-VOCABULARY."
@ -38,7 +38,7 @@
;;; ———————————————————————————————————————— ;;; ————————————————————————————————————————
(defmacro relative-pathname (path) (defmacro relative-pathname (path)
"Return an absolute path adding the relative PATH to the systems path." "Return an absolute path adding the relative PATH to the systems path."
`(asdf:system-relative-pathname :activity-servist/tests/activity-vocabulary ,path)) `(asdf:system-relative-pathname :activity-servist/tests/vocab/activity ,path))
(defmacro define-json-test (path tags) (defmacro define-json-test (path tags)
"Define a lisp-unit2 test for parsing of the given JSON file. "Define a lisp-unit2 test for parsing of the given JSON file.
@ -92,4 +92,4 @@ Any nested hash-tables found as values are also sorted, recursively."
(mapcar (lambda (file) (mapcar (lambda (file)
(eval `(define-json-test ,file '(:activity-vocabulary)))) (eval `(define-json-test ,file '(:activity-vocabulary))))
(uiop:directory-files (uiop:directory-files
(relative-pathname "t/activity-vocabulary/"))) (relative-pathname "t/vocab/activity/")))