Class: TicketPlugin
- Inherits:
-
Plugin
- Object
- Plugin
- TicketPlugin
- Defined in:
- plugins/ticket/ticket.rb
Overview
TicketPlugin serves static and disposable data and images. It accepts Magick::Image objects too to render them only when really needed. Each serve-call returns an unique uri to pass to the client. It performs clean-ups based on session and request time-outs.
It’s available to other plugins as @plugins.ticket
Defined Under Namespace
Classes: BlobObj
Instance Method Summary collapse
-
#del_file(msg, file_id) ⇒ nil
Removes a downloadable file resource served from memory.
-
#del_img(msg, img_id) ⇒ nil
Removes a downloadable file resource served from memory.
-
#del_obj(msg, ticket_id) ⇒ nil
Deletes a custom object served by #serve_obj.
-
#del_rsrc(rsrc_id) ⇒ nil
Removes static resource served by #serve_rsrc.
-
#del_upload(ticket_id, row_id) ⇒ nil
Removes the uploaded data matching both ticket id as well as row id.
-
#del_uploads(msg, ticket_id) ⇒ nil
Removes all uploaded data matching the ticket id.
-
#get_uploads(ticket_id, with_data = false) ⇒ Array
Returns a list of uploads matching the ticket id.
-
#proto_obj ⇒ BlobObj
To be used for custom objects served by #serve_obj.
-
#serve(msg, content, format = 'PNG', type = :img) ⇒ String
Serves an RMagick::Image object accessible by a disposable ticket URL.
-
#serve_file(msg, content = '', content_type = 'text/plain', filename = nil) ⇒ String
Serves a downloadable file resource to be served from memory using a generated url.
-
#serve_img(msg, content, format = 'PNG', type = :img) ⇒ String
Serves a downloadable file resource to be served from memory using a generated url.
-
#serve_obj(msg, blob_obj, no_expire = false) ⇒ String
Serves custom object using the BlobObj API (Binary Large Object).
-
#serve_rsrc(content, content_type) ⇒ String
Serves static resource as from raw binary data.
-
#set_favicon(ico_data, content_type = false) ⇒ nil
Sets a custom favicon for RSence.
-
#upload_key(msg, value_key, max_size = 1000000, mime_allow = /(.*?)\/(.*?)/, allow_multi = true) ⇒ String
Allocates an upload slot and returns the ticket id to use for #get_uploads, #del_upload and #del_uploads.
Instance Method Details
#del_file(msg, file_id) ⇒ nil
Removes a downloadable file resource served from memory.
Does not delete any files from the file system.
218 219 220 |
# File 'plugins/ticket/ticket.rb', line 218 def del_file( msg, file_id ) @ticketserve.del_file( file_id, msg.ses_id ) end |
#del_img(msg, img_id) ⇒ nil
Removes a downloadable file resource served from memory.
Does not delete any files from the file system.
242 243 244 |
# File 'plugins/ticket/ticket.rb', line 242 def del_img( msg, img_id ) @ticketserve.del_img( img_id, msg.ses_id ) end |
#del_obj(msg, ticket_id) ⇒ nil
Deletes a custom object served by #serve_obj
280 281 282 |
# File 'plugins/ticket/ticket.rb', line 280 def del_obj( msg, ticket_id ) @ticketserve.del_blobobj( ticket_id, msg.ses_id ) end |
#del_rsrc(rsrc_id) ⇒ nil
Removes static resource served by #serve_rsrc
289 290 291 |
# File 'plugins/ticket/ticket.rb', line 289 def del_rsrc( rsrc_id ) @ticketserve.del_rsrc( rsrc_id ) end |
#del_upload(ticket_id, row_id) ⇒ nil
Removes the uploaded data matching both ticket id as well as row id.
319 320 321 |
# File 'plugins/ticket/ticket.rb', line 319 def del_upload( ticket_id, row_id ) @ticketserve.del_upload( ticket_id, row_id ) end |
#del_uploads(msg, ticket_id) ⇒ nil
Removes all uploaded data matching the ticket id
329 330 331 |
# File 'plugins/ticket/ticket.rb', line 329 def del_uploads( msg, ticket_id ) @ticketserve.del_uploads( ticket_id, msg.ses_id ) end |
#get_uploads(ticket_id, with_data = false) ⇒ Array
Returns a list of uploads matching the ticket id.
309 310 311 |
# File 'plugins/ticket/ticket.rb', line 309 def get_uploads( ticket_id, with_data=false ) @ticketserve.get_uploads( ticket_id, with_data ) end |
#proto_obj ⇒ BlobObj
Returns to be used for custom objects served by #serve_obj.
259 260 261 |
# File 'plugins/ticket/ticket.rb', line 259 def proto_obj return BlobObj end |
#serve(msg, content, format = 'PNG', type = :img) ⇒ String
Serves an RMagick::Image object accessible by a disposable ticket URL.
178 179 180 |
# File 'plugins/ticket/ticket.rb', line 178 def serve( msg, content, format='PNG', type=:img ) @ticketserve.serve( msg, content, format, type ) end |
#serve_file(msg, content = '', content_type = 'text/plain', filename = nil) ⇒ String
Serves a downloadable file resource to be served from memory using a generated url.
230 231 232 |
# File 'plugins/ticket/ticket.rb', line 230 def serve_file( msg, content='', content_type='text/plain', filename=nil ) @ticketserve.serve_file( msg, content, content_type, filename ) end |
#serve_img(msg, content, format = 'PNG', type = :img) ⇒ String
Serves a downloadable file resource to be served from memory using a generated url.
254 255 256 |
# File 'plugins/ticket/ticket.rb', line 254 def serve_img( msg, content, format='PNG', type=:img ) @ticketserve.serve_img( msg, content, format, type ) end |
#serve_obj(msg, blob_obj, no_expire = false) ⇒ String
Serves custom object using the BlobObj API (Binary Large Object)
270 271 272 |
# File 'plugins/ticket/ticket.rb', line 270 def serve_obj( msg, blob_obj, no_expire=false ) @ticketserve.serve_blobobj( msg, blob_obj, no_expire ) end |
#serve_rsrc(content, content_type) ⇒ String
Serves static resource as from raw binary data.
299 300 301 |
# File 'plugins/ticket/ticket.rb', line 299 def serve_rsrc( content, content_type ) @ticketserve.serve_rsrc( content, content_type ) end |
#set_favicon(ico_data, content_type = false) ⇒ nil
Sets a custom favicon for RSence
206 207 208 |
# File 'plugins/ticket/ticket.rb', line 206 def set_favicon( ico_data, content_type=false ) @ticketserve.set_favicon( ico_data, content_type ) end |
#upload_key(msg, value_key, max_size = 1000000, mime_allow = /(.*?)\/(.*?)/, allow_multi = true) ⇒ String
Allocates an upload slot and returns the ticket id to use for #get_uploads, #del_upload and #del_uploads
342 343 344 |
# File 'plugins/ticket/ticket.rb', line 342 def upload_key( msg, value_key, max_size=1000000, mime_allow=/(.*?)\/(.*?)/, allow_multi=true ) @ticketserve.upload_key( msg, value_key, max_size, mime_allow, allow_multi ) end |