2024-06-12 16:06:17 -05:00
|
|
|
|
;;;; activity-vocabulary: Classes for ActivityVocabulary types.
|
|
|
|
|
|
|
|
|
|
;; Copyright © 2024 Jaidyn Ann <jadedctrl@posteo.at>
|
|
|
|
|
;;
|
|
|
|
|
;; This program is free software: you can redistribute it and/or
|
|
|
|
|
;; modify it under the terms of the GNU General Public License as
|
|
|
|
|
;; published by the Free Software Foundation, either version 3 of
|
|
|
|
|
;; the License, or (at your option) any later version.
|
|
|
|
|
;;
|
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
;;
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
(defpackage #:activitypub-servist/activity-vocabulary
|
|
|
|
|
(:use #:cl)
|
2024-06-12 21:42:47 -05:00
|
|
|
|
;; One should never USE this package, since some class-names shadow
|
|
|
|
|
;; core Common Lisp symbols! Beware! :P
|
|
|
|
|
(:shadow #:delete #:ignore #:listen #:read #:remove)
|
2024-06-12 16:06:17 -05:00
|
|
|
|
(:nicknames "AP-S/AV" "AV"))
|
|
|
|
|
|
|
|
|
|
(in-package #:activitypub-servist/activity-vocabulary)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Macros
|
|
|
|
|
;;; ————————————————————————————————————————
|
|
|
|
|
(defmacro defclass-w-accessors (name direct-superclasses slots &rest options)
|
2024-06-12 21:42:47 -05:00
|
|
|
|
"Identical to DEFCLASS, but with one convenience: A slot definition, if being
|
|
|
|
|
simply a symbol, will default to a slot with an accessor and init-arg named after the
|
|
|
|
|
symbol. The init-arg will be “:symbol”, and the accessor will be “classname-symbol”.
|
|
|
|
|
For instance,
|
|
|
|
|
|
|
|
|
|
(defclass-w-accessors PERSON () (AGE
|
|
|
|
|
HEIGHT
|
|
|
|
|
(NAME :INIT-FORM “Unknown”)))
|
|
|
|
|
```
|
|
|
|
|
is equivalent to
|
|
|
|
|
```
|
|
|
|
|
(defclass PERSON () ((AGE :INIT-ARG :AGE :ACCESSOR PERSON-AGE)
|
|
|
|
|
(HEIGHT :INIT-ARG :HEIGHT :ACCESSOR PERSON-HEIGHT)
|
|
|
|
|
(NAME :INIT-FORM “Unknown”)))
|
|
|
|
|
```"
|
2024-06-12 16:06:17 -05:00
|
|
|
|
`(defclass ,name ,direct-superclasses
|
|
|
|
|
,(mapcar
|
|
|
|
|
(lambda (slot)
|
|
|
|
|
(typecase slot
|
|
|
|
|
(list slot)
|
2024-06-12 21:42:47 -05:00
|
|
|
|
(t (list slot :accessor (intern (format nil "~A-~A" name slot))
|
|
|
|
|
:initarg (intern (symbol-name slot) "KEYWORD")))))
|
2024-06-12 16:06:17 -05:00
|
|
|
|
slots)
|
|
|
|
|
,@options))
|
|
|
|
|
|
2024-06-12 21:42:47 -05:00
|
|
|
|
(defmacro defclass-empty-children (name direct-children)
|
|
|
|
|
"For each name in the list DIRECT-CHILDREN, a subclass of NAME will be created.
|
|
|
|
|
These new subclasses have no slots of its own — they will be empty derivatives
|
|
|
|
|
of NAME."
|
|
|
|
|
(append
|
|
|
|
|
'(progn)
|
|
|
|
|
(mapcar (lambda (a)
|
|
|
|
|
`(defclass ,a (,name) ()))
|
|
|
|
|
direct-children)))
|
|
|
|
|
|
2024-06-12 16:06:17 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Core types
|
|
|
|
|
;;; ————————————————————————————————————————
|
|
|
|
|
;; https://www.w3.org/ns/activitystreams#Object
|
2024-06-12 21:42:47 -05:00
|
|
|
|
(defclass-w-accessors object ()
|
2024-06-12 16:06:17 -05:00
|
|
|
|
(
|
|
|
|
|
attachment attributed-to audience bcc bto cc content context
|
|
|
|
|
duration end-time generator icon image in-reply-to location
|
|
|
|
|
media-type name preview published replies start-time summary
|
|
|
|
|
tag to updated url))
|
|
|
|
|
|
|
|
|
|
;; https://www.w3.org/ns/activitystreams#Link
|
2024-06-12 21:42:47 -05:00
|
|
|
|
(defclass-w-accessors link ()
|
2024-06-12 16:06:17 -05:00
|
|
|
|
(height href hreflang media-type name preview rel width))
|
|
|
|
|
|
|
|
|
|
;; https://www.w3.org/ns/activitystreams#Activity
|
2024-06-12 21:42:47 -05:00
|
|
|
|
(defclass-w-accessors activity (object)
|
2024-06-12 16:06:17 -05:00
|
|
|
|
(actor instrument object origin result target))
|
|
|
|
|
|
|
|
|
|
;; Should be ordinary Activity, sans `object`.
|
|
|
|
|
;; https://www.w3.org/ns/activitystreams#IntransitiveActivity
|
2024-06-12 21:42:47 -05:00
|
|
|
|
(defclass intransitive-activity (activity) ())
|
2024-06-12 16:06:17 -05:00
|
|
|
|
|
|
|
|
|
;; https://www.w3.org/ns/activitystreams#Collection
|
2024-06-12 21:42:47 -05:00
|
|
|
|
(defclass-w-accessors collection (object)
|
2024-06-12 16:06:17 -05:00
|
|
|
|
(current first items last total-items))
|
|
|
|
|
|
|
|
|
|
;; https://www.w3.org/ns/activitystreams#OrderedCollection
|
2024-06-12 21:42:47 -05:00
|
|
|
|
(defclass ordered-collection (collection) ())
|
2024-06-12 16:06:17 -05:00
|
|
|
|
|
|
|
|
|
;; https://www.w3.org/ns/activitystreams#CollectionPage
|
2024-06-12 21:42:47 -05:00
|
|
|
|
(defclass-w-accessors collection-page (collection)
|
2024-06-12 16:06:17 -05:00
|
|
|
|
(next part-of prev))
|
|
|
|
|
|
|
|
|
|
;; https://www.w3.org/ns/activitystreams#OrderedCollectionPage
|
2024-06-12 21:42:47 -05:00
|
|
|
|
(defclass-w-accessors ordered-collection-page (collection-page)
|
|
|
|
|
(start-index))
|
2024-06-12 16:06:17 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Extended Activity types
|
|
|
|
|
;;; ————————————————————————————————————————
|
2024-06-12 21:42:47 -05:00
|
|
|
|
(defclass-empty-children activity
|
|
|
|
|
(accept add announce create delete dislike flag follow ignore join leave
|
|
|
|
|
like listen move offer read reject remove travel undo update view))
|
|
|
|
|
|
|
|
|
|
(defclass arrive (intransitive-activity) ())
|
|
|
|
|
(defclass ignore (block) ())
|
|
|
|
|
(defclass invite (offer) ())
|
|
|
|
|
(defclass question (intransitive-activity) ())
|
|
|
|
|
(defclass tentative-accept (accept) ())
|
|
|
|
|
(defclass tentative-reject (reject) ())
|
2024-06-12 22:21:48 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Extended Actor types
|
|
|
|
|
;;; ————————————————————————————————————————
|
|
|
|
|
(defclass-empty-children actor
|
|
|
|
|
(application group organization person service))
|
2024-06-12 22:29:27 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Extended Object types
|
|
|
|
|
;;; ————————————————————————————————————————
|
|
|
|
|
(defclass-empty-children object
|
|
|
|
|
(article document event note))
|
|
|
|
|
|
|
|
|
|
(defclass-empty-children document
|
|
|
|
|
(audio image page video))
|
|
|
|
|
|
|
|
|
|
;; https://www.w3.org/ns/activitystreams#Place
|
|
|
|
|
(defclass-w-accessors place (object)
|
|
|
|
|
(accuracy altitude latitude longitude radius units))
|
|
|
|
|
|
|
|
|
|
;; https://www.w3.org/ns/activitystreams#Profile
|
|
|
|
|
(defclass-w-accessors profile (object)
|
|
|
|
|
(describes))
|
|
|
|
|
|
|
|
|
|
;; https://www.w3.org/ns/activitystreams#Relationship
|
|
|
|
|
(defclass-w-accessors relationship (object)
|
|
|
|
|
(object relationship subject))
|
|
|
|
|
|
|
|
|
|
;; https://www.w3.org/ns/activitystreams#Tombstone
|
|
|
|
|
(defclass-w-accessors tombstone (object)
|
|
|
|
|
(former-type deleted))
|