class Pettanr.Picture extends Peta.Content url: '/pictures/' @singular: () -> 'Picture' @plural: () -> 'Pictures' defaults: { id: null } is_visible: (operators) -> return true filename: () -> @get('id') + '.' + @get('ext') gifname: () -> @get('id') + '.gif' mime_type: () -> 'image/' + @get('ext') r_url: () -> '/pictures/' + @filename() opt_img_tag: () -> {src: @r_url(), width: @get('width'), height: @get('height')} tmb_opt_img_tag: () -> wh = Pettanr.Imager.thumbnail_size(@get('width'), @get('height')) {src: @r_url(), width: wh[0], height: wh[1]} tail_opt_img_tag: (img) -> {src: img, width: @get('width'), height: @get('height')} tail_tmb_opt_img_tag: (img) -> wh = Pettanr.Imager.thumbnail_size(@get('width'), @get('height')) {src: img, width: wh[0], height: wh[1]} alt_name: () -> lgn = Pettanr.to_s(@license().license_group().get('caption')) ln = Pettanr.to_s(@license().get('caption')) lgn + '[' + ln + ']' symbol_option: () -> this is_enable: () -> if @head().resource_picture() true else false @head: (opid) -> #Picture.find( conditions => ['original_picture_id = ?', opid], :order => 'pictures.revision desc') head: () -> Picture.head(@get('original_picture_id')) is_head: () -> #this == @head() subdirs: () -> if @license_extend().reverse < 0 [''] else ['', 'v', 'h', 'vh'] is_showable: (operators = null) -> return false if not @original_picture() return true if @is_own(operators) #@is_enable() and @is_head() initialize: () -> if @id @url = @url + @id class Pettanr.Picture.Collection extends Backbone.Collection model: Pettanr.Picture url: '/pictures'