class Pettanr.Picture extends Peta.Content @singular: () -> 'Picture' @plural: () -> 'Pictures' defaults: { id: null } @trace_routes: () -> { resource_picture: ['resource_picture_picture', 'resource_picture'] } is_visible: (operators = Pettanr.cache.operators) -> return true filename: () -> @get('id') + '.' + @get('ext') gifname: () -> @get('id') + '.gif' mime_type: () -> 'image/' + @get('ext') r_url: () -> '/pictures/' + @filename() img_option: () -> title = if @['get'] # is instance? @model_name() + ' ID:' + Pettanr.to_s(@get('id')) else @model_name() { title: title alt: @model_name() } opt_img_tag: () -> @picture_file() tmb_opt_img_tag: () -> @symbol_file() 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: (context, options) -> @retrieve(this, { success: (symbol_item) => options.success.call(context, symbol_item.to_symbol()) }) 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 = Pettanr.cache.operators) -> return false if not @original_picture() return true if @is_own(operators) #@is_enable() and @is_head() history_view: () -> new Pettanr.Views.Picture.History({item: this}) initialize: (attr = {}, options = {}) -> super(attr, options)