The clavatar Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The clavatar Reference Manual

This is the clavatar Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Aug 15 04:11:42 2022 GMT+0.

Table of Contents


1 Introduction

#+TITLE: Clavatar: Common Lisp Avatar URL Determiner

* What it Is
Clavatar is a Common Lisp library to find an avatar URL using some sort of
identifier.

* Synopsis

#+begin_src lisp
  (clavatar:get-avatar-url "avatars@example.com" :size 120)
  ; => #
  (clavatar:get-avatar-url "http://example.com/user/avatars")
  ; => #
#+end_src

* API
** get-avatar-url (identifier &key size default services)
Returns an avatar URL for a given identifier.

First, checks if the domain of identifier provides some clue as to how to get
avatars.  If so, uses the federated behavior of the domain.  Otherwise, tries
SERVICES in order and uses the first service which does not return a 404.  Will
use DEFAULT on the last service if no service knows about the identifier.

Note that because this involves DNS and HTTP queries, it is slow and you should
cache the results.

SERVICES is a list which may contain any of 'LIBRAVATAR, 'GRAVATAR, or
'UNICORNIFY by default.  Additional services may also be used, if support is
added for them.  See "Adding a New Service Type", below.

* Supported Services
 * Gravatar
 * Libravatar (both hosted and federated)
 * Unicornify

* Supported Identifier Types
 * E-mail addresses (as strings)
 * URLs (as strings, and as PURI:URI objects)

* Adding a New Identifier Type
In some cases, it may be desirable to extend Clavatar's identifier support to an
object type it does not know about; for instance, the e-mail address type of an
SMTP library.  This can be accomplished by adding methods on
CANONICAL-IDENTIFIER and IDENTIFIER-DOMAIN.

The return value from CANONICAL-IDENTIFIER should be a string, representing the
canonical form of the identifier (hostnames in lowercase, etc.).

The return value of IDENTIFIER-DOMAIN should be a string, representing the
domain name which has authority for the given identifier.  E.g., the host
portion of an URL, or the domain of an e-mail address.

see =identifiers.lisp= for examples.

* Adding a New Service Type
At minimum, adding a service requires adding a class for the service, and two
methods on AVATAR-URL.

The first method should be of the form:
#+begin_src lisp
  (defmethod avatar-url ((service (eql 'service-name)) identifier &rest rest)
    (apply #'avatar-url (make-instance 'service-object) identifier rest))
#+end_src
SERVICE-NAME and SERVICE-OBJECT should probably be the same symbol, but this is
not required.  This method is what enables GET-AVATAR-URL's list of services to
work with bare symbols.

The second method should be of the form:
#+begin_src lisp
  (defmethod avatar-url ((service service-type) identifier &key size default &allow-other-keys)
    (determine-identifiers-avatar-uri))
#+end_src
This is the workhorse method whose job is to produce the URL of an avatar.

see =clavatar.lisp= for examples.

* See Also
 * cl-gravatar :: Essentially the same thing, but Gravatar-specific


2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 clavatar

Determines appropriate URLs for avatars using assorted avatar services.

Author

Pixie <pix@kepibu.org>

License

MIT

Dependencies
  • iolib (system).
  • ironclad (system).
  • babel (system).
  • drakma (system).
Source

clavatar.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

3.1.1 clavatar/clavatar.asd

Source

clavatar.asd.

Parent Component

clavatar (system).

ASDF Systems

clavatar.


3.1.2 clavatar/package.lisp

Source

clavatar.asd.

Parent Component

clavatar (system).

Packages

clavatar.


3.1.3 clavatar/util.lisp

Dependency

package.lisp (file).

Source

clavatar.asd.

Parent Component

clavatar (system).

Internals

3.1.4 clavatar/identifiers.lisp

Dependency

util.lisp (file).

Source

clavatar.asd.

Parent Component

clavatar (system).

Public Interface
Internals

3.1.5 clavatar/clavatar.lisp

Dependency

identifiers.lisp (file).

Source

clavatar.asd.

Parent Component

clavatar (system).

Public Interface
Internals

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 clavatar

Source

package.lisp.

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Public Interface


5.1.1 Ordinary functions

Function: get-avatar-url (identifier &key size default services)

Returns an avatar URL for a given identifier.

First, checks if the domain of identifier provides some clue as to how to get avatars. If so, uses the federated behavior of the domain. Otherwise, tries SERVICES in order and uses the first service which does not return a 404. Will use DEFAULT on the last service if no service knows about the identifier.

Note that because this involves DNS and HTTP queries, it is slow and you should cache the results.

Package

clavatar.

Source

clavatar.lisp.


5.1.2 Generic functions

Generic Function: canonical-identifier (identifier)
Package

clavatar.

Source

identifiers.lisp.

Methods
Method: canonical-identifier ((e-mail %e-mail))
Method: canonical-identifier ((uri uri))
Method: canonical-identifier ((identifier string))
Generic Function: identifier-domain (identifier)
Package

clavatar.

Source

identifiers.lisp.

Methods
Method: identifier-domain ((identifier %e-mail))
Method: identifier-domain ((identifier uri))
Method: identifier-domain ((identifier string))

5.1.3 Classes

Class: gravatar
Package

clavatar.

Source

clavatar.lisp.

Direct superclasses

hosted-service.

Direct methods

avatar-url.

Direct slots
Slot: base-uri
Initform

(puri:uri "https://secure.gravatar.com/")

Class: libravatar
Package

clavatar.

Source

clavatar.lisp.

Direct superclasses
Direct slots
Slot: base-uri
Initform

(puri:uri "https://seccdn.libravatar.org/")

Class: unicornify
Package

clavatar.

Source

clavatar.lisp.

Direct superclasses

hosted-service.

Direct methods

avatar-url.

Direct slots
Slot: base-uri
Initform

(puri:uri "https://unicornify.appspot.com/")


5.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

5.2.1 Ordinary functions

Reader: %e-mail-domain (instance)
Writer: (setf %e-mail-domain) (instance)
Package

clavatar.

Source

identifiers.lisp.

Target Slot

domain.

Reader: %e-mail-local-part (instance)
Writer: (setf %e-mail-local-part) (instance)
Package

clavatar.

Source

identifiers.lisp.

Target Slot

local-part.

Function: %e-mail-p (object)
Package

clavatar.

Source

identifiers.lisp.

Function: build-url-query (args)
Package

clavatar.

Source

util.lisp.

Function: copy-%e-mail (instance)
Package

clavatar.

Source

identifiers.lisp.

Function: default-port-p (scheme port)
Package

clavatar.

Source

util.lisp.

Function: ensure-identifier (identifier)
Package

clavatar.

Source

identifiers.lisp.

Function: identifier-hash (identifier hash)
Package

clavatar.

Source

identifiers.lisp.

Function: make-%e-mail (local-part domain)
Package

clavatar.

Source

identifiers.lisp.

Function: make-e-mail (string)
Package

clavatar.

Source

identifiers.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

5.2.2 Generic functions

Generic Function: avatar-url (service identifier &key size default &allow-other-keys)
Package

clavatar.

Source

clavatar.lisp.

Methods
Method: avatar-url ((service federated-service) identifier &key size default &allow-other-keys)
Method: avatar-url ((service unicornify) identifier &rest rest)
Method: avatar-url ((service libravatar-protocol) identifier &rest rest)
Method: avatar-url ((service gravatar) identifier &rest rest)
Method: avatar-url :around ((service hosted-service) identifier &key size default &allow-other-keys)
Method: avatar-url ((service (eql clavatar::federated)) identifier &rest rest)
Method: avatar-url ((service (eql clavatar:unicornify)) identifier &rest rest)
Method: avatar-url ((service (eql clavatar:libravatar)) identifier &rest rest)
Method: avatar-url ((service (eql clavatar:gravatar)) identifier &rest rest)

Next: , Previous: , Up: Internals   [Contents][Index]

5.2.3 Structures

Structure: %e-mail
Package

clavatar.

Source

identifiers.lisp.

Direct superclasses

structure-object.

Direct methods
Direct slots
Slot: local-part
Readers

%e-mail-local-part.

Writers

(setf %e-mail-local-part).

Slot: domain
Readers

%e-mail-domain.

Writers

(setf %e-mail-domain).


Previous: , Up: Internals   [Contents][Index]

5.2.4 Classes

Class: federated-service
Package

clavatar.

Source

clavatar.lisp.

Direct superclasses

libravatar-protocol.

Direct methods

avatar-url.

Class: hosted-service
Package

clavatar.

Source

clavatar.lisp.

Direct subclasses
Direct methods

avatar-url.

Direct slots
Slot: base-uri
Class: libravatar-protocol
Package

clavatar.

Source

clavatar.lisp.

Direct subclasses
Direct methods

avatar-url.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   %   (  
A   B   C   D   E   F   G   I   M  
Index Entry  Section

%
%e-mail-domain: Private ordinary functions
%e-mail-local-part: Private ordinary functions
%e-mail-p: Private ordinary functions

(
(setf %e-mail-domain): Private ordinary functions
(setf %e-mail-local-part): Private ordinary functions

A
avatar-url: Private generic functions
avatar-url: Private generic functions
avatar-url: Private generic functions
avatar-url: Private generic functions
avatar-url: Private generic functions
avatar-url: Private generic functions
avatar-url: Private generic functions
avatar-url: Private generic functions
avatar-url: Private generic functions
avatar-url: Private generic functions

B
build-url-query: Private ordinary functions

C
canonical-identifier: Public generic functions
canonical-identifier: Public generic functions
canonical-identifier: Public generic functions
canonical-identifier: Public generic functions
copy-%e-mail: Private ordinary functions

D
default-port-p: Private ordinary functions

E
ensure-identifier: Private ordinary functions

F
Function, %e-mail-domain: Private ordinary functions
Function, %e-mail-local-part: Private ordinary functions
Function, %e-mail-p: Private ordinary functions
Function, (setf %e-mail-domain): Private ordinary functions
Function, (setf %e-mail-local-part): Private ordinary functions
Function, build-url-query: Private ordinary functions
Function, copy-%e-mail: Private ordinary functions
Function, default-port-p: Private ordinary functions
Function, ensure-identifier: Private ordinary functions
Function, get-avatar-url: Public ordinary functions
Function, identifier-hash: Private ordinary functions
Function, make-%e-mail: Private ordinary functions
Function, make-e-mail: Private ordinary functions

G
Generic Function, avatar-url: Private generic functions
Generic Function, canonical-identifier: Public generic functions
Generic Function, identifier-domain: Public generic functions
get-avatar-url: Public ordinary functions

I
identifier-domain: Public generic functions
identifier-domain: Public generic functions
identifier-domain: Public generic functions
identifier-domain: Public generic functions
identifier-hash: Private ordinary functions

M
make-%e-mail: Private ordinary functions
make-e-mail: Private ordinary functions
Method, avatar-url: Private generic functions
Method, avatar-url: Private generic functions
Method, avatar-url: Private generic functions
Method, avatar-url: Private generic functions
Method, avatar-url: Private generic functions
Method, avatar-url: Private generic functions
Method, avatar-url: Private generic functions
Method, avatar-url: Private generic functions
Method, avatar-url: Private generic functions
Method, canonical-identifier: Public generic functions
Method, canonical-identifier: Public generic functions
Method, canonical-identifier: Public generic functions
Method, identifier-domain: Public generic functions
Method, identifier-domain: Public generic functions
Method, identifier-domain: Public generic functions

Jump to:   %   (  
A   B   C   D   E   F   G   I   M