This is the clipper Reference Manual, version 0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 05:40:29 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
clipper
File attachment library.
Rudolph-Miller
MIT
# Clipper
[![Build Status](https://circleci.com/gh/Rudolph-Miller/clipper.svg?style=shield)](https://circleci.com/gh/Rudolph-Miller/clipper)
[![Quicklisp dist](http://quickdocs.org/badge/clipper.svg)](http://quickdocs.org/clipper/)
Clipper is a file attachment library.
[Introduction to Clipper(Japanese)](http://blog.rudolph-miller.com/2015/08/10/introduction-to-clipper/)
## Usage
“‘Lisp
(in-package :cl-user)
(defpackage clipper.sample
(:use :cl
:integral
:clipper))
(in-package :clipper.sample)
(connect-toplevel :mysql :database-name "clipper_sample" :username "root")
(defclass picture ()
((id :col-type (:integer 11)
:primary-key t
:auto-increment t
:not-null t
:initarg :id)
(image-file-name :col-type (:varchar 255)
:initarg :image-file-name)
(image-content-type :col-type (:varchar 255)
:initarg :image-content-type)
(image-file-size :col-type (:integer 11)
:initarg :image-file-size)
(url :type string
:initarg :url))
(:metaclass <dao-table-class>)
(:table-name "pictures"))
(setup-clipper :store-type :s3
:aws-access-key (asdf::getenv "AWS_ACCESS_KEY")
:aws-secret-key (asdf::getenv "AWS_SECRET_KEY")
:s3-endpoint "s3-ap-northeast-1.amazonaws.com"
:s3-bucket-name "clipper-sample"
:clipper-class (find-class ’picture)
:format ":ID/:FILE-NAME.:EXTENSION")
(let ((object (create-dao ’picture)))
(save-dao (attach-image object :url "http://www.lisperati.com/lisplogo_alien_256.png"))
(image-url object))
=> "https://s3-ap-northeast-1.amazonaws.com/clipper-sample/1/lisplogo_alien_256.png"
(setup-clipper :store-type :local
:image-directory #P"/home/cl-user/common-lisp/clipper/images/"
:relative #P"/home/cl-user/common-lisp/clipper/"
:prefix "http://localhost:3000/"
:clipper-class (find-class ’picture)
:format ":ID/:FILE-NAME.:EXTENSION")
(let ((object (create-dao ’picture)))
(save-dao (attach-image object :url "http://www.lisperati.com/lisplogo_alien_256.png"))
(image-url object))
=> "http://localhsot:3000/images/2/lisplogo_alien_256.png"
“‘
## setup-clipper
“‘Lisp
(setup-clipper :store-type :local)
“‘
or
“‘Lisp
(setup-clipper :store-type :s3)
“‘
or you can create ‘:store-type‘ other than ‘:local‘ or ‘:s3‘.
### :store-type :local
“‘Lisp
(setup-clipper :store-type :local
:image-directory #P"/home/cl-user/common-lisp/clipper/images/"
:relative #P"/home/cl-user/common-lisp/clipper/"
:prefix "http://localhost:3000/"
:clipper-class (find-class ’picture)
:format ":ID/:FILE-NAME.:EXTENSION")
(let ((object (create-dao ’picture)))
(save-dao (attach-image object :url "http://www.lisperati.com/lisplogo_alien_256.png"))
(image-url object))
=> "http://localhsot:3000/images/2/lisplogo_alien_256.png"
“‘
- ‘:image-directory‘
“‘Lisp
(setup-clipper :store-type :local
:image-directory #P"/home/cl-user/common-lisp/clipper/images/"
:clipper-class (find-class ’picture)
:format ":ID/:FILE-NAME.:EXTENSION")
(let ((object (create-dao ’picture)))
(save-dao (attach-image object :url "http://www.lisperati.com/lisplogo_alien_256.png"))
(image-url object))
=> "/home/cl-user/common-lisp/clipper/images/2/lisplogo_alien_256.png"
“‘
- ‘:relative‘
“‘Lisp
(setup-clipper :store-type :local
:image-directory #P"/home/cl-user/common-lisp/clipper/images/"
:relative #P"/home/cl-user/common-lisp/clipper/"
:clipper-class (find-class ’picture)
:format ":ID/:FILE-NAME.:EXTENSION")
(let ((object (create-dao ’picture)))
(save-dao (attach-image object :url "http://www.lisperati.com/lisplogo_alien_256.png"))
(image-url object))
=> "images/2/lisplogo_alien_256.png"
“‘
- ‘:prefix‘
“‘Lisp
(setup-clipper :store-type :local
:image-directory #P"/home/cl-user/common-lisp/clipper/images/"
:relative #P"/home/cl-user/common-lisp/clipper/"
:prefix "http://localhost:3000/"
:clipper-class (find-class ’picture)
:format ":ID/:FILE-NAME.:EXTENSION")
(let ((object (create-dao ’picture)))
(save-dao (attach-image object :url "http://www.lisperati.com/lisplogo_alien_256.png"))
(image-url object))
=> "http://localhost3000/images/2/lisplogo_alien_256.png"
“‘
### :store-type :s3
“‘Lisp
(setup-clipper :store-type :s3
:aws-access-key (asdf::getenv "AWS_ACCESS_KEY")
:aws-secret-key (asdf::getenv "AWS_SECRET_KEY")
:s3-endpoint "s3-ap-northeast-1.amazonaws.com"
:s3-bucket-name "clipper-sample"
:clipper-class (find-class ’picture)
:format "images:ID/:FILE-NAME.:EXTENSION")
(let ((object (create-dao ’picture)))
(save-dao (attach-image object :url "http://www.lisperati.com/lisplogo_alien_256.png"))
(image-url object))
=> "https://s3-ap-northeast-1.amazonaws.com/clipper-sample/images/1/lisplogo_alien_256.png"
“‘
### :clipper-class
‘:clipper-class‘ can take any class or struct which have slots for ‘id‘, ‘image-file-name‘, ‘image-content-type‘, ‘image-file-size‘ and ‘url‘, and each slot can be specified by ‘setup-clipper‘.
“‘Lisp
(defclass picture ()
((id :col-type (:integer 11)
:primary-key t
:auto-increment t
:not-null t
:initarg :id)
(image-file-name :col-type (:varchar 255)
:initarg :image-file-name)
(image-content-type :col-type (:varchar 255)
:initarg :image-content-type)
(image-file-size :col-type (:integer 11)
:initarg :image-file-size)
(url :type string
:initarg :url))
(:metaclass <dao-table-class>)
(:table-name "pictures"))
(setup-clipper :clipper-class (find-class ’picture)
:id-slot ’id
:url-slot ’url
:image-file-name-slot ’image-file-name
:image-content-type-slot ’image-content-type
:image-file-size-slot ’image-file-size)
“‘
### :format
- ‘:format‘ can take string with ‘:KEYWORD‘ and ‘:KEYWORD‘ is declared in ‘*format-keys*‘.
- Default declared ‘:KEYWORD‘ is ‘:ID‘, ‘:URL‘, ‘:FILE-NAME‘ and ‘:EXTENSION‘.
- ‘*format-keys*‘ is a plist of ‘:KEYWORD‘ and ‘function‘ which will be called with ‘object‘.
- ‘:FILE-NAME‘ will return ‘:image-file-name‘ without extension.
“‘Lisp
(defvar *format-keys*
(list :ID #’clip-id
:URL #’clip-url
:FILE-NAME #’clip-image-file-name-without-extension
:EXTENSION #’clip-extension))
(store-format (setup-clipper :format ":ID/:URL/:FILE-NAME.:EXTENSION"))
(make-instance ’picture :id 1 :url "sample-url" :image-file-name "smaple.png")
=> format will be "1/sample-url/sample.png"
“‘
## attach-image
- ‘attach-image‘ take ‘object‘ and keyword arguments(‘:url‘, ‘:image‘, ‘:path-name‘ and ‘:file-name‘).
- ‘attach-image‘ return ‘object‘ with ‘image-file-name‘, ‘image-content-type‘, ‘image-file-size‘ and ‘url‘.
- You have to save returned ‘object‘ on yourself.
“‘Lisp
(let ((object (make-instance ’picture)))
(attach-image object :url "http://www.lisperati.com/lisplogo_alien_256.png")
(attach-image object :path-name "/home/lisp-user/image/lisplogo_alien_256.png")
(attach-image object :image (drakma:http-request "http://www.lisperati.com/lisplogo_alien_256.png")
:file-name "lisplogo_alien_256.nng")
;; or
(setf (picture-url object) "http://www.lisperati.com/lisplogo_alien_256.png")
(attach-image object))
“‘
## attach-image with resize
If you add ‘:width‘ and ‘:height‘, ‘attach-image‘ resize image with ‘opticl:fit-image-into‘.
“‘Lisp
(setup-clipper :store-type :local
:image-directory #P"/home/cl-user/common-lisp/clipper/images/"
:relative #P"/home/cl-user/common-lisp/clipper/"
:prefix "http://localhost:3000/"
:clipper-class (find-class ’picture)
:format ":ID/:FILE-NAME.:EXTENSION"
:width 200
:height 200)
“‘
## See Also
- [Integral](https://github.com/fukamachi/integral) - Object relational mapper for Common Lisp
- [opticl](https://github.com/slyrus/opticl) - A library for representing and processing images in Common Lisp
## Author
* Rudolph-Miller (chopsticks.tk.ppfm@gmail.com)
## Copyright
Copyright (c) 2015 Rudolph-Miller (chopsticks.tk.ppfm@gmail.com)
0.1
cl-syntax-annot
(system).
closer-mop
(system).
dexador
(system).
quri
(system).
split-sequence
(system).
alexandria
(system).
zs3
(system).
cl-fad
(system).
opticl
(system).
fast-io
(system).
src
(module).
Modules are listed depth-first from the system components tree.
clipper/src
clipper
(system).
clipper.lisp
(file).
database.lisp
(file).
image.lisp
(file).
s3.lisp
(file).
local.lisp
(file).
config.lisp
(file).
format.lisp
(file).
error.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
clipper/clipper.asd
clipper/src/clipper.lisp
clipper/src/database.lisp
clipper/src/image.lisp
clipper/src/s3.lisp
clipper/src/local.lisp
clipper/src/config.lisp
clipper/src/format.lisp
clipper/src/error.lisp
clipper/src/clipper.lisp
database.lisp
(file).
image.lisp
(file).
s3.lisp
(file).
local.lisp
(file).
config.lisp
(file).
format.lisp
(file).
error.lisp
(file).
src
(module).
image-url
(function).
clipper/src/database.lisp
config.lisp
(file).
error.lisp
(file).
src
(module).
clip-extension
(function).
clip-id
(function).
clip-image-content-type
(function).
(setf clip-image-content-type)
(function).
clip-image-file-name
(function).
(setf clip-image-file-name)
(function).
clip-image-file-name-without-extension
(function).
clip-image-file-size
(function).
(setf clip-image-file-size)
(function).
clip-url
(function).
(setf clip-url)
(function).
get-extension
(function).
clipper/src/image.lisp
database.lisp
(file).
src
(module).
*supported-content-types*
(special variable).
attach-image
(generic function).
convert-image
(function).
read-image-to-vector
(function).
store-image
(generic function).
write-image-to-out
(function).
%attach-image
(function).
extension->type
(function).
temporary-file-template
(function).
clipper/src/s3.lisp
database.lisp
(file).
image.lisp
(file).
format.lisp
(file).
src
(module).
access-key
(method).
retrieve-url
(method).
secret-key
(method).
store-image
(method).
upload
(function).
environment-credentials
(class).
clipper/src/local.lisp
database.lisp
(file).
image.lisp
(file).
format.lisp
(file).
src
(module).
image-pathname
(function).
retrieve-url
(method).
store-image
(method).
clipper/src/config.lisp
error.lisp
(file).
src
(module).
*clipper-config*
(special variable).
clipper-config
(structure).
clipper-config-aws-access-key
(reader).
(setf clipper-config-aws-access-key)
(writer).
clipper-config-aws-secret-key
(reader).
(setf clipper-config-aws-secret-key)
(writer).
clipper-config-clipper-class
(reader).
(setf clipper-config-clipper-class)
(writer).
clipper-config-format
(reader).
(setf clipper-config-format)
(writer).
clipper-config-height
(reader).
(setf clipper-config-height)
(writer).
clipper-config-id-slot
(reader).
(setf clipper-config-id-slot)
(writer).
clipper-config-image-content-type-slot
(reader).
(setf clipper-config-image-content-type-slot)
(writer).
clipper-config-image-directory
(reader).
(setf clipper-config-image-directory)
(writer).
clipper-config-image-file-name-slot
(reader).
(setf clipper-config-image-file-name-slot)
(writer).
clipper-config-image-file-size-slot
(reader).
(setf clipper-config-image-file-size-slot)
(writer).
clipper-config-prefix
(reader).
(setf clipper-config-prefix)
(writer).
clipper-config-relative
(reader).
(setf clipper-config-relative)
(writer).
clipper-config-s3-bucket-name
(reader).
(setf clipper-config-s3-bucket-name)
(writer).
clipper-config-s3-endpoint
(reader).
(setf clipper-config-s3-endpoint)
(writer).
clipper-config-store-type
(reader).
(setf clipper-config-store-type)
(writer).
clipper-config-url-slot
(reader).
(setf clipper-config-url-slot)
(writer).
clipper-config-width
(reader).
(setf clipper-config-width)
(writer).
setup-clipper
(function).
*local-requrie-list*
(special variable).
*s3-require-list*
(special variable).
clipper-config-p
(function).
complete-slot-of-class
(function).
copy-clipper-config
(function).
find-slot-by-the-name
(function).
make-clipper-config
(function).
clipper/src/format.lisp
database.lisp
(file).
src
(module).
*format-keys*
(special variable).
retrieve-url
(generic function).
store-format
(function).
clipper/src/error.lisp
src
(module).
<clipper-error>
(condition).
<clipper-image-type-error>
(condition).
<clipper-incomplete-config>
(condition).
<clipper-incomplete-for-attach-image>
(condition).
<clipper-incomplete-local-config>
(condition).
<clipper-incomplete-s3-config>
(condition).
<clipper-invalid-store-type>
(condition).
<clipper-no-source-specified>
(condition).
<clipper-unsupported-content-type>
(condition).
Packages are listed by definition order.
clipper
clipper.database
clipper.error
clipper.image
clipper.config
clipper.s3
clipper.local
clipper.format
clipper-asd
clipper.database
cl-annot.class
.
clipper.config
.
common-lisp
.
clip-extension
(function).
clip-id
(function).
clip-image-content-type
(function).
(setf clip-image-content-type)
(function).
clip-image-file-name
(function).
(setf clip-image-file-name)
(function).
clip-image-file-name-without-extension
(function).
clip-image-file-size
(function).
(setf clip-image-file-size)
(function).
clip-url
(function).
(setf clip-url)
(function).
get-extension
(function).
clipper.error
common-lisp
.
<clipper-error>
(condition).
<clipper-image-type-error>
(condition).
<clipper-incomplete-config>
(condition).
<clipper-incomplete-for-attach-image>
(condition).
<clipper-incomplete-local-config>
(condition).
<clipper-incomplete-s3-config>
(condition).
<clipper-invalid-store-type>
(condition).
<clipper-no-source-specified>
(condition).
<clipper-unsupported-content-type>
(condition).
clipper.image
cl-annot.doc
.
clipper.config
.
clipper.database
.
clipper.error
.
common-lisp
.
fast-io
.
opticl
.
quri
.
*supported-content-types*
(special variable).
attach-image
(generic function).
convert-image
(function).
read-image-to-vector
(function).
store-image
(generic function).
write-image-to-out
(function).
%attach-image
(function).
extension->type
(function).
temporary-file-template
(function).
clipper.config
cl-annot.class
.
cl-annot.doc
.
clipper.error
.
common-lisp
.
*clipper-config*
(special variable).
clipper-config
(structure).
clipper-config-aws-access-key
(reader).
(setf clipper-config-aws-access-key)
(writer).
clipper-config-aws-secret-key
(reader).
(setf clipper-config-aws-secret-key)
(writer).
clipper-config-clipper-class
(reader).
(setf clipper-config-clipper-class)
(writer).
clipper-config-format
(reader).
(setf clipper-config-format)
(writer).
clipper-config-height
(reader).
(setf clipper-config-height)
(writer).
clipper-config-id-slot
(reader).
(setf clipper-config-id-slot)
(writer).
clipper-config-image-content-type-slot
(reader).
(setf clipper-config-image-content-type-slot)
(writer).
clipper-config-image-directory
(reader).
(setf clipper-config-image-directory)
(writer).
clipper-config-image-file-name-slot
(reader).
(setf clipper-config-image-file-name-slot)
(writer).
clipper-config-image-file-size-slot
(reader).
(setf clipper-config-image-file-size-slot)
(writer).
clipper-config-prefix
(reader).
(setf clipper-config-prefix)
(writer).
clipper-config-relative
(reader).
(setf clipper-config-relative)
(writer).
clipper-config-s3-bucket-name
(reader).
(setf clipper-config-s3-bucket-name)
(writer).
clipper-config-s3-endpoint
(reader).
(setf clipper-config-s3-endpoint)
(writer).
clipper-config-store-type
(reader).
(setf clipper-config-store-type)
(writer).
clipper-config-url-slot
(reader).
(setf clipper-config-url-slot)
(writer).
clipper-config-width
(reader).
(setf clipper-config-width)
(writer).
setup-clipper
(function).
*local-requrie-list*
(special variable).
*s3-require-list*
(special variable).
clipper-config-p
(function).
complete-slot-of-class
(function).
copy-clipper-config
(function).
find-slot-by-the-name
(function).
make-clipper-config
(function).
clipper.s3
clipper.config
.
clipper.database
.
clipper.format
.
clipper.image
.
common-lisp
.
zs3
.
upload
(function).
environment-credentials
(class).
clipper.local
clipper.config
.
clipper.database
.
clipper.format
.
clipper.image
.
common-lisp
.
image-pathname
(function).
clipper.format
cl-annot.doc
.
clipper.config
.
clipper.database
.
common-lisp
.
*format-keys*
(special variable).
retrieve-url
(generic function).
store-format
(function).
Definitions are sorted by export status, category, package, and then by lexicographic order.
Global variable for config object.
List of functions used for #’store-format.
Return URL for object.
Setup clipper. You must call this before use clipper.
Return formatted id of object.
Attach the image to the object.
(eql :local)
)) ¶environment-credentials
)) ¶zs3
.
environment-credentials
)) ¶zs3
.
Base error condition.
simple-error
.
Image type error.
Type slot.
common-lisp
.
:type
Incomplete config error.
Invalid slot list slot.
:slot-list
Incomplete for attach-image.
Incomplete local config error.
Incomplete S3 config error.
Invalid stare type error.
Type slot.
common-lisp
.
:type
No source specified error.
Object slot.
:object
Unsupported content type error.
Content type slot.
:content-type
structure-object
.
""
""
common-lisp
.
"/:id/:file-name.:extension"
Jump to: | %
(
A C E F G I M R S T U W |
---|
Jump to: | %
(
A C E F G I M R S T U W |
---|
Jump to: | *
A C F H I O P R S T U W |
---|
Jump to: | *
A C F H I O P R S T U W |
---|
Jump to: | <
C D E F I L M P S |
---|
Jump to: | <
C D E F I L M P S |
---|