Compare commits
No commits in common. "16613eba5132525e6a38de183902eaf1cfe27914" and "a2aec426abff6d422f1b9fe0d2353516066f125c" have entirely different histories.
16613eba51
...
a2aec426ab
|
@ -23,7 +23,7 @@
|
||||||
:parse :encode
|
:parse :encode
|
||||||
:define-class-encoders
|
:define-class-encoders
|
||||||
;; Globals
|
;; Globals
|
||||||
:*ap-packages* :*default-class*
|
:*ap-packages*
|
||||||
;; Classes
|
;; Classes
|
||||||
:object
|
:object
|
||||||
;; Slots
|
;; Slots
|
||||||
|
@ -41,12 +41,6 @@ during JSON parsing. The class-name searched for is simply the value of the JSON
|
||||||
object’s “type” key. The package first in the list to export such a symbol
|
object’s “type” key. The package first in the list to export such a symbol
|
||||||
is the winner.")
|
is the winner.")
|
||||||
|
|
||||||
(defparameter *default-class* 'activity-servist/activity-streams:object
|
|
||||||
"The class used for ActivityStreams objects found during parsing that don’t
|
|
||||||
have a corresponding class defined. Notably, all keys and values without
|
|
||||||
corresponding slots are placed in the MISC slot.
|
|
||||||
The class you choose should inherit ACTIVITY-SERVIST/ACTIVITY-STREAMS:OBJECT.")
|
|
||||||
|
|
||||||
;; Private, internal variable.
|
;; Private, internal variable.
|
||||||
(defparameter *@context* nil
|
(defparameter *@context* nil
|
||||||
"Used in YASON:ENCODE to ensure that a single top-level @context can be
|
"Used in YASON:ENCODE to ensure that a single top-level @context can be
|
||||||
|
@ -102,9 +96,8 @@ again and again, by YASON:ENCODE-SLOTS."
|
||||||
|
|
||||||
(defun parse-table (table)
|
(defun parse-table (table)
|
||||||
"Parse a hash-table corresponding to YASON-parsed JSON into an ActivityPub object."
|
"Parse a hash-table corresponding to YASON-parsed JSON into an ActivityPub object."
|
||||||
(let* ((found-class (car (find-registered-classes (param-case (gethash "type" table)))))
|
(let* ((class (car (find-registered-classes (param-case (gethash "type" table)))))
|
||||||
(class (or found-class (find-class *default-class*)))
|
(obj (make-instance class)))
|
||||||
(obj (make-instance class)))
|
|
||||||
(loop for key being each hash-key of table
|
(loop for key being each hash-key of table
|
||||||
for val being each hash-value of table
|
for val being each hash-value of table
|
||||||
do (let ((slot-sym (car (find-registered-symbols (param-case key))))
|
do (let ((slot-sym (car (find-registered-symbols (param-case key))))
|
||||||
|
@ -239,11 +232,7 @@ items in each will be contained in the resultant list."
|
||||||
*ap-packages* list."
|
*ap-packages* list."
|
||||||
(remove-if
|
(remove-if
|
||||||
#'not
|
#'not
|
||||||
(mapcar (lambda (package)
|
(mapcar (lambda (package) (find-symbol (string-upcase str) package))
|
||||||
(multiple-value-bind (sym context)
|
|
||||||
(find-symbol (string-upcase str) package)
|
|
||||||
(unless (eq context :inherited)
|
|
||||||
sym)))
|
|
||||||
*ap-packages*)))
|
*ap-packages*)))
|
||||||
|
|
||||||
(defun find-registered-classes (str)
|
(defun find-registered-classes (str)
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
(defpackage #:activity-servist/activity-vocabulary
|
(defpackage #:activity-servist/activity-vocabulary
|
||||||
(:use #:cl)
|
(:use #:cl)
|
||||||
(:nicknames "AS/AV" "ACTIVITY-VOCABULARY")
|
(:nicknames "AS/AV" "ACTIVITY-VOCABULARY")
|
||||||
(:shadow #:block #:delete #:ignore #:listen #:read #:remove)
|
(:shadow #: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
|
||||||
(:export
|
(:export
|
||||||
;; Classes
|
;; Classes
|
||||||
:accept :activity :add :announce :application :arrive :article :audio :block
|
:accept :activity :add :announce :application :arrive :article :audio
|
||||||
:collection :collection-page :create :delete :dislike :document :event :flag
|
:collection :collection-page :create :delete :dislike :document :event :flag
|
||||||
:follow :group :ignore :ignore :image :intransitive-activity :invite :join
|
:follow :group :ignore :ignore :image :intransitive-activity :invite :join
|
||||||
:leave :like :link :listen :move :note :object :offer :ordered-collection
|
:leave :like :link :listen :move :note :object :offer :ordered-collection
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
:collection-total-items
|
:collection-total-items
|
||||||
:collection-page-next :collection-page-part-of :collection-page-prev
|
:collection-page-next :collection-page-part-of :collection-page-prev
|
||||||
:link-height :link-href :link-hreflang :link-media-type :link-name
|
:link-height :link-href :link-hreflang :link-media-type :link-name
|
||||||
:link-preview :link-rel :link-summary :link-width
|
:link-preview :link-rel :link-width
|
||||||
:object-attachment :object-attributed-to :object-audience :object-bcc
|
:object-attachment :object-attributed-to :object-audience :object-bcc
|
||||||
:object-bto :object-cc :object-content :object-context :object-duration
|
:object-bto :object-cc :object-content :object-context :object-duration
|
||||||
:object-end-time :object-generator :object-icon :object-image
|
:object-end-time :object-generator :object-icon :object-image
|
||||||
|
@ -45,18 +45,15 @@
|
||||||
:object-preview :object-published :object-replies :object-start-time
|
:object-preview :object-published :object-replies :object-start-time
|
||||||
:object-summary :object-tag :object-to :object-type :object-updated
|
:object-summary :object-tag :object-to :object-type :object-updated
|
||||||
:object-url
|
:object-url
|
||||||
:ordered-collection-page-start-index ordered-collection-ordered-items
|
:ordered-collection-page-start-index
|
||||||
:place-accuracy :place-altitude :place-latitude :place-longitude
|
:place-accuracy :place-altitude :place-latitude :place-longitude
|
||||||
:place-radius :place-units
|
:place-radius :place-units
|
||||||
:question-all-of :question-closed :question-one-of
|
|
||||||
:profile-describes
|
:profile-describes
|
||||||
: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/activity-vocabulary)
|
||||||
|
|
||||||
(setq activity-servist/activity-streams:*default-class*
|
|
||||||
'activity-servist/activity-vocabulary:object)
|
|
||||||
|
|
||||||
|
|
||||||
;;; Macros
|
;;; Macros
|
||||||
|
@ -106,10 +103,8 @@ of NAME."
|
||||||
tag to updated url))
|
tag to updated url))
|
||||||
|
|
||||||
;; https://www.w3.org/ns/activitystreams#Link
|
;; https://www.w3.org/ns/activitystreams#Link
|
||||||
;; “summary” here isn’t real! It’s not a property Link should have (just
|
|
||||||
;; looking at Link’s properties), but it’s implied by the Mention example.
|
|
||||||
(defclass-w-accessors link (activity-servist/activity-streams:object)
|
(defclass-w-accessors link (activity-servist/activity-streams:object)
|
||||||
(height href hreflang media-type name preview rel summary width))
|
(height href hreflang media-type name preview rel width))
|
||||||
|
|
||||||
;; https://www.w3.org/ns/activitystreams#Activity
|
;; https://www.w3.org/ns/activitystreams#Activity
|
||||||
(defclass-w-accessors activity (object)
|
(defclass-w-accessors activity (object)
|
||||||
|
@ -142,8 +137,8 @@ of NAME."
|
||||||
;;; Extended Activity types
|
;;; Extended Activity types
|
||||||
;;; ————————————————————————————————————————
|
;;; ————————————————————————————————————————
|
||||||
(defclass-empty-children activity
|
(defclass-empty-children activity
|
||||||
(accept add announce block create delete dislike flag follow ignore join leave
|
(accept add announce create delete dislike flag follow ignore join leave
|
||||||
like listen move offer read reject remove travel undo update view))
|
like listen move offer read reject remove travel undo update view))
|
||||||
|
|
||||||
(defclass arrive (intransitive-activity) ())
|
(defclass arrive (intransitive-activity) ())
|
||||||
(defclass ignore (block) ())
|
(defclass ignore (block) ())
|
||||||
|
@ -152,9 +147,6 @@ of NAME."
|
||||||
(defclass tentative-accept (accept) ())
|
(defclass tentative-accept (accept) ())
|
||||||
(defclass tentative-reject (reject) ())
|
(defclass tentative-reject (reject) ())
|
||||||
|
|
||||||
(defclass-w-accessors question (intransitive-activity)
|
|
||||||
(any-of closed one-of))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;; Extended Actor types
|
;;; Extended Actor types
|
||||||
|
@ -203,4 +195,4 @@ of NAME."
|
||||||
(as/as:define-class-encoders
|
(as/as:define-class-encoders
|
||||||
(mapcar #'find-class
|
(mapcar #'find-class
|
||||||
'(object link activity collection collection-page ordered-collection
|
'(object link activity collection collection-page ordered-collection
|
||||||
ordered-collection-page place profile question relationship tombstone)))
|
ordered-collection-page place profile relationship tombstone)))
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
|
||||||
"type": "OrderedCollection",
|
"type": "OrderedCollection",
|
||||||
"totalItems": 3,
|
"totalItems": 3,
|
||||||
"name": "Vacation photos 2016",
|
"name": "Vacation photos 2016",
|
||||||
|
|
Ŝarĝante…
Reference in New Issue