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.
- #open ⇒ Object
-
#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_db_state(state) ⇒ Object
-
#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.
220 221 222 |
# File 'plugins/ticket/ticket.rb', line 220 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.
244 245 246 |
# File 'plugins/ticket/ticket.rb', line 244 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
282 283 284 |
# File 'plugins/ticket/ticket.rb', line 282 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
291 292 293 |
# File 'plugins/ticket/ticket.rb', line 291 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.
321 322 323 |
# File 'plugins/ticket/ticket.rb', line 321 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
331 332 333 |
# File 'plugins/ticket/ticket.rb', line 331 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.
311 312 313 |
# File 'plugins/ticket/ticket.rb', line 311 def get_uploads( ticket_id, with_data=false ) @ticketserve.get_uploads( ticket_id, with_data ) end |
#open ⇒ Object
125 126 127 128 129 130 |
# File 'plugins/ticket/ticket.rb', line 125 def open super unless RSence.session_manager.nil? set_db_state( RSence.session_manager.db_avail ) end end |
#proto_obj ⇒ BlobObj
Returns to be used for custom objects served by #serve_obj.
261 262 263 |
# File 'plugins/ticket/ticket.rb', line 261 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.
180 181 182 |
# File 'plugins/ticket/ticket.rb', line 180 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.
232 233 234 |
# File 'plugins/ticket/ticket.rb', line 232 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.
256 257 258 |
# File 'plugins/ticket/ticket.rb', line 256 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)
272 273 274 |
# File 'plugins/ticket/ticket.rb', line 272 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.
301 302 303 |
# File 'plugins/ticket/ticket.rb', line 301 def serve_rsrc( content, content_type ) @ticketserve.serve_rsrc( content, content_type ) end |
#set_db_state(state) ⇒ Object
132 133 134 |
# File 'plugins/ticket/ticket.rb', line 132 def set_db_state( state ) @ticketserve.set_db_state( state ) end |
#set_favicon(ico_data, content_type = false) ⇒ nil
Sets a custom favicon for RSence
208 209 210 |
# File 'plugins/ticket/ticket.rb', line 208 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
344 345 346 |
# File 'plugins/ticket/ticket.rb', line 344 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 |