OSDN Git Service

add comic story
[pettanr/pettanr.git] / app / models / panel_picture.rb
index 12e88aa..daea39d 100644 (file)
@@ -1,7 +1,5 @@
-class PanelPicture < Peta::Content
+class PanelPicture < Peta::Element
   load_manifest
-  include Peta::Element
-  include ElementInspire
   belongs_to :panel
   belongs_to :picture
   
@@ -10,18 +8,15 @@ class PanelPicture < Peta::Content
   validates :link, :length => {:maximum => 200}, :url => {:allow_blank => true, :message => I18n.t('errors.messages.url')}
   validates :x, :presence => true, :numericality => true
   validates :y, :presence => true, :numericality => true
-  validates :width, :presence => true, :numericality => true, :not_zero => true, :reverse => true, :resize => true, :sync_vh => true
-  validates :height, :presence => true, :numericality => true, :not_zero => true, :reverse => true, :resize => true, :sync_vh => true
+  validates :width, :presence => true, :numericality => true, :not_zero => true, :reverse => true, :sync_vh => true
+  validates :height, :presence => true, :numericality => true, :not_zero => true, :reverse => true, :sync_vh => true
   validates :z, :presence => true, :numericality => {:greater_than => 0}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
-  def self.colum_structures
-    @@colum_structures ||= {
-      :width => {
-        :helper => 'panels/size_helper'
-      }, 
-      :height => {
-        :helper => 'panels/size_helper'
+  def self.by_author_list_includes
+    {
+      :panel => {
+        :author => {}
       }
     }
   end
@@ -52,11 +47,6 @@ class PanelPicture < Peta::Content
     true
   end
   
-  def visible? operators
-    return false unless super
-    self.owner_model.visible? operators
-  end
-  
   def supply_default
     self.x = 0
     self.y = 0
@@ -76,12 +66,13 @@ class PanelPicture < Peta::Content
   
   def flip
     res = (self.height > 0 ? '' : 'v') + (self.width > 0 ? '' : 'h')
-    res += '/' unless res.empty?
+    res = res # format of /1.png?subdir=v
+    # res += '/' unless res.empty? # format of /v/1.png
     res
   end
   
   def filename
-    self.flip + self.picture.filename
+    self.picture.filename + '?subdir=' + self.flip
   end
   
   def url
@@ -94,10 +85,11 @@ class PanelPicture < Peta::Content
   
   def opt_img_tag spot = nil, opacity = 20
     o = (spot and spot != self) ? "opacity: #{opacity.to_f/100}; filter:alpha(opacity=#{opacity});" : ''
-    {:id => self.tag_id(:img), :panel_id => self.tag_panel_id, :element_id => self.tag_element_id, :element_type => self.tag_element_type,
-    :class => "panel-picture", :vPicture => self.id, 
-    :src => self.url, :width => self.width.abs, :height => self.height.abs, :picture_id => self.picture_id, :ext => self.picture.ext, :alt => self.caption, 
-    :style => "#{o}"}
+    self.tag_attributes(:img, {
+      :class => "panel-picture", :vPicture => self.id, 
+      :src => self.url, :width => self.width.abs, :height => self.height.abs, :picture_id => self.picture_id, :ext => self.picture.ext, :alt => self.caption, 
+      :style => "#{o}"
+    })
   end
   
   def tmb_opt_img_tag
@@ -109,14 +101,7 @@ class PanelPicture < Peta::Content
     self.picture.symbol_option
   end
   
-  def boost
-  end
-  
-  def tag_element_type
-    'panel_picture'
-  end
-  
-  def self.list_where
+  def self.public_list_where
     'panels.publish > 0'
   end