OSDN Git Service

fic picture publishing
authoryasushiito <yas@pen-chan.jp>
Sat, 26 Apr 2014 02:02:10 +0000 (11:02 +0900)
committeryasushiito <yas@pen-chan.jp>
Sat, 26 Apr 2014 02:02:10 +0000 (11:02 +0900)
13 files changed:
app/assets/javascripts/manifest/work/items.js.coffee.erb
app/assets/javascripts/manifest/work/models.js.coffee.erb
app/assets/javascripts/manifest/work/profilers.js.coffee.erb
app/assets/stylesheets/test.css.scss
app/controllers/original_picture_license_groups_controller.rb
app/models/picture.rb
app/models/resource_picture.rb
app/views/resource_pictures/_form.html.erb
config/locales/pettanr.ja.yml
db/migrate/20140422231825_add_system_picture_id_on_resource_picture.rb [new file with mode: 0644]
db/migrate/20140422233206_add_system_picture_id_on_resource_picture_data.rb [new file with mode: 0644]
lib/peta/system_resource.rb
public/manifest.json

index a383a5f..95852f2 100644 (file)
         # expand license_group_settings\r
         license_group: {\r
           resource_name: 'license_group',\r
+          engine_resource_name: 'license_groups',\r
+          engine_resource_extend_column_name: 'license_group_classname',\r
           extend_column_name: 'license_group_classname',\r
           settings_column_name: 'license_group_settings',\r
           extend_model_class_name: 'License',\r
         license: {\r
           level: 'read',\r
           resource_name: 'license_group',\r
+          engine_resource_name: 'license_groups',\r
+          engine_resource_extend_column_name: 'license_group_classname',\r
           extend_column_name: 'license_group_classname',\r
+          settings_column_name: 'license_settings',\r
           extend_model_class_name: 'Attribute',\r
           extend_item_name: 'attribute',\r
         },\r
         credit_picture: {\r
           level: 'read',\r
           resource_name: 'license_group',\r
+          engine_resource_name: 'license_groups',\r
+          engine_resource_extend_column_name: 'license_group_classname',\r
           extend_column_name: 'license_group_classname',\r
           settings_column_name: 'credit_picture_settings',\r
           extend_model_class_name: 'CreditPicture',\r
index 8d38edf..4a197d3 100644 (file)
           number: true,\r
         }\r
       },\r
-      revision: {\r
-        type: 'number',\r
-        rules : {\r
-          required: true,\r
-          number: true,\r
-        }\r
-      },\r
       ext: {\r
         type: 'text',\r
         rules : {\r
index 71074fb..b047fd1 100644 (file)
     },\r
     column_names: [\r
       'original_picture_id', \r
-      'revision', \r
       'ext', \r
       'width', \r
       'height', \r
index 48bdcff..9c1c215 100644 (file)
@@ -357,6 +357,9 @@ font-family : monospace;
   clear: both;
 }
 
+.extend_column {
+  margin-left: 20px;
+}
 
 .filer {
     list-style-type: none;
index dff5e0b..eebd199 100644 (file)
@@ -18,6 +18,8 @@ class OriginalPictureLicenseGroupsController < ApplicationController
     @original_picture_license_group = OriginalPictureLicenseGroup.new params[:original_picture_license_group]
     @license_group = LicenseGroup.show @original_picture_license_group.license_group_id, @operators
     @ctl = @license_group.my_engine_name
+    @attr = @license_group.my_engine.new_attribute {}
+    @attr.supply_default @operators
 
     respond_to do |format|
       if @original_picture_license_group.valid?
index 0725faf..85c68ef 100644 (file)
@@ -3,6 +3,7 @@ class Picture < Peta::Content
   load_manifest
   belongs_to :original_picture
   belongs_to :license
+  belongs_to :system_picture
   belongs_to :artist
   has_one :resource_picture
   
@@ -14,6 +15,7 @@ class Picture < Peta::Content
   validates :filesize, :presence => true, :numericality => {:greater_than => 0, :less_than_or_equal_to => 2000000}, :natural_number => true
   validates :md5, :presence => true, :length => {:minimum => 32, :maximum => 32}
   validates :license_id, :presence => true, :numericality => true, :existence => {:both => false}
+  validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :artist_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :artist_name, :presence => true
   validates :license_group_classname, :presence => true, :length => {:maximum => 50}
@@ -23,7 +25,8 @@ class Picture < Peta::Content
   
   def overwrite rp
     attr = {:width => rp.width, :height => rp.height, :ext => rp.ext, :filesize => rp.filesize, 
-      :original_picture_id => rp.original_picture_id, :license_id => rp.license_id, :artist_id => rp.artist_id, 
+      :original_picture_id => rp.original_picture_id, :license_id => rp.license_id, 
+      :system_picture_id => rp.system_picture_id, :artist_id => rp.artist_id, 
       :md5 => rp.md5, :artist_name => rp.artist_name, 
       :license_group_classname => rp.license_group_classname, 
       :license_group_settings => rp.license_group_settings, 
@@ -78,6 +81,10 @@ class Picture < Peta::Content
     {:src => img, :width => tw, :height => th}
   end
   
+  def alt_name
+    self.license.license_group.caption.to_s + '[' + self.license.caption.to_s + ']'
+  end
+  
   def symbol_option
     self.tmb_opt_img_tag
   end
index 2ec0685..c6975ef 100644 (file)
@@ -3,6 +3,7 @@ class ResourcePicture < Peta::Content
   load_manifest
   belongs_to :artist
   belongs_to :license
+  belongs_to :system_picture
   belongs_to :picture
   belongs_to :original_picture
   
@@ -13,6 +14,7 @@ class ResourcePicture < Peta::Content
   validates :md5, :presence => true, :length => {:minimum => 32, :maximum => 32}
   validates :artist_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :license_id, :presence => true, :numericality => true, :existence => {:both => false}
+  validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :original_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :artist_name, :presence => true
   validates :license_group_classname, :presence => true, :length => {:maximum => 50}
@@ -68,6 +70,10 @@ class ResourcePicture < Peta::Content
     {:src => self.url('full'), :width => self.width, :height => self.height}
   end
   
+  def alt_name
+    self.license.license_group.caption.to_s + '[' + self.license.caption.to_s + ']'
+  end
+  
   def symbol_option
     self.tmb_opt_img_tag
   end
index 5025683..03c6b5d 100644 (file)
@@ -8,6 +8,7 @@
 
   <%= f.hidden_field :original_picture_id %>
   <%= f.hidden_field :license_id %>
+  <%= f.hidden_field :system_picture_id %>
   <%= f.hidden_field :artist_name %>
   <%= f.hidden_field :license_group_classname %>
   <%= f.hidden_field :license_group_settings %>
index a254fb1..3b8aa88 100644 (file)
@@ -49,6 +49,12 @@ ja:
       provider_license: ライセンス対照表
       provider_artist: 絵師対照表
       provider_original_picture: 原画対照表
+      pettanr_creative_commons_v30_licenses/attribute: クリエイティブコモンズ3.0
+      pettanr_pettan_commons_v01_licenses/attribute: ぺったんコモンズ0.1
+      pettanr_pettan_protected_v01_licenses/attribute: ぺったんProtected0.1
+      pettanr_pettan_public_v01_licenses/attribute: ぺったんパブリック0.1
+      pettanr_public_domain_v01_licenses/attribute: パブリックドメイン
+      pettanr_unknown_v01_licenses/attribute: 不明0.1
     attributes:
       user:
         name: ペンネーム
@@ -238,9 +244,10 @@ ja:
         artist_id: 絵師
         license_id: ライセンス
         artist_name: 著作者名
-        classname: ライセンスクラス名
-        credit: クレジット拡張データ
-        settings: 拡張データ
+        license_group_settings: ライセンスフラグ
+        credit_picture_settings: クレジット拡張データ
+        license_settings: ライセンス拡張データ
+        license_group_classname: ライセンスクラス名
         created_at: 公開日時
         updated_at: 公開日時
       resource_picture:
@@ -253,9 +260,10 @@ ja:
         artist_id: 絵師
         license_id: ライセンス
         artist_name: 著作者名
-        classname: ライセンスクラス名
-        credit: クレジット拡張データ
-        settings: 拡張データ
+        license_group_settings: ライセンスフラグ
+        credit_picture_settings: クレジット拡張データ
+        license_settings: ライセンス拡張データ
+        license_group_classname: ライセンスクラス名
         picture_id: 実素材
         created_at: 作成
         updated_at: 更新
@@ -369,8 +377,131 @@ ja:
       provider_original_picture:
         created_at: 作成
         updated_at: 更新
+      pettanr_creative_commons_v30_licenses/license:
+          open: クローズドな利用
+          commercial: 商用利用
+          official: 公式ライセンス
+          attribution: クレジットの表示
+          derive: 改変
+          thumbnail: サムネイルの作成
+          gif_convert: GIFフォーマットへの変換
+          reverse: 反転
+          sync_vh: 縦横比の改変
+          overlap: 重ね合わせ
+      pettanr_creative_commons_v30_licenses/credit_picture:
+          source_url_btn_id: URLボタン
+          source_url_off_btn_id: URLはないボタン
+      pettanr_creative_commons_v30_licenses/attribute:
+          license_id: ライセンスID
+          system_picture_id: マーク画像ID
+          artist_name: 著作者名
+          caption: 作品の名前
+          artist_url: 作者のホームページURL
+          source_url: 参考にした画像のURL
+          more_permission_url: 追加的許諾のURL
+      pettanr_pettan_commons_v01_licenses/license:
+          open: クローズドな利用
+          commercial: 商用利用
+          official: 公式ライセンス
+          attribution: クレジットの表示
+          derive: 改変
+          thumbnail: サムネイルの作成
+          gif_convert: GIFフォーマットへの変換
+          reverse: 反転
+          sync_vh: 縦横比の改変
+          overlap: 重ね合わせ
+      pettanr_pettan_commons_v01_licenses/credit_picture:
+          source_url_btn_id: URLボタン
+          source_url_off_btn_id: URLはないボタン
+      pettanr_pettan_commons_v01_licenses/attribute:
+          license_id: ライセンスID
+          system_picture_id: マーク画像ID
+          artist_name: 著作者名
+          caption: 作品の名前
+          sources: 参考にした画像のURL
+      pettanr_pettan_protected_v01_licenses/license:
+          open: クローズドな利用
+          commercial: 商用利用
+          official: 公式ライセンス
+          attribution: クレジットの表示
+          derive: 改変
+          thumbnail: サムネイルの作成
+          gif_convert: GIFフォーマットへの変換
+          reverse: 反転
+          sync_vh: 縦横比の改変
+          overlap: 重ね合わせ
+          trackback: トラックバック
+      pettanr_pettan_protected_v01_licenses/credit_picture:
+          source_url_btn_id: URLボタン
+          source_url_off_btn_id: URLはないボタン
+      pettanr_pettan_protected_v01_licenses/attribute:
+          license_id: ライセンスID
+          system_picture_id: マーク画像ID
+          artist_name: 著作者名
+          caption: 作品の名前
+          sources: 参考にした画像のURL
+      pettanr_pettan_public_v01_licenses/license:
+          open: クローズドな利用
+          commercial: 商用利用
+          official: 公式ライセンス
+          attribution: クレジットの表示
+          derive: 改変
+          thumbnail: サムネイルの作成
+          gif_convert: GIFフォーマットへの変換
+          reverse: 反転
+          sync_vh: 縦横比の改変
+          overlap: 重ね合わせ
+          trackback: トラックバック
+      pettanr_pettan_public_v01_licenses/credit_picture:
+          source_url_btn_id: URLボタン
+      pettanr_pettan_public_v01_licenses/attribute:
+          license_id: ライセンスID
+          system_picture_id: マーク画像ID
+          artist_name: 著作者名
+          caption: 作品の名前
+          sources: 参考にした画像のURL
+      pettanr_public_domain_v01_licenses/license:
+          open: クローズドな利用
+          commercial: 商用利用
+          official: 公式ライセンス
+          attribution: クレジットの表示
+          derive: 改変
+          thumbnail: サムネイルの作成
+          gif_convert: GIFフォーマットへの変換
+          reverse: 反転
+          sync_vh: 縦横比の改変
+          overlap: 重ね合わせ
+          trackback: トラックバック
+      pettanr_public_domain_v01_licenses/credit_picture:
+          source_url_btn_id: URLボタン
+          source_url_off_btn_id: URLはないボタン
+      pettanr_public_domain_v01_licenses/attribute:
+          license_id: ライセンスID
+          system_picture_id: マーク画像ID
+          artist_name: 著作者名
+          caption: 作品の名前
+          source_url: 参考にした画像のURL
+          note: 参考にした画像のURL
       pettanr_unknown_v01_licenses/license:
-          open: ライセンス
+          open: クローズドな利用
+          commercial: 商用利用
+          official: 公式ライセンス
+          attribution: クレジットの表示
+          derive: 改変
+          thumbnail: サムネイルの作成
+          gif_convert: GIFフォーマットへの変換
+          reverse: 反転
+          sync_vh: 縦横比の改変
+          overlap: 重ね合わせ
+          trackback: トラックバック
+      pettanr_unknown_v01_licenses/credit_picture:
+          source_url_btn_id: URLボタン
+          source_url_off_btn_id: URLはないボタン
+      pettanr_unknown_v01_licenses/attribute:
+          license_id: ライセンスID
+          system_picture_id: マーク画像ID
+          source_url: 参考にした画像のURL
+          note: 参考にした画像のURL
   picture_io:
     error: 画像保管庫との手続きで異常が発生しました。
   select_items:
diff --git a/db/migrate/20140422231825_add_system_picture_id_on_resource_picture.rb b/db/migrate/20140422231825_add_system_picture_id_on_resource_picture.rb
new file mode 100644 (file)
index 0000000..1de7173
--- /dev/null
@@ -0,0 +1,9 @@
+class AddSystemPictureIdOnResourcePicture < ActiveRecord::Migration
+  def up
+    add_column :resource_pictures, :system_picture_id, :integer, :null => false, :default => 0
+    add_column :pictures, :system_picture_id, :integer, :null => false, :default => 0
+  end
+
+  def down
+  end
+end
diff --git a/db/migrate/20140422233206_add_system_picture_id_on_resource_picture_data.rb b/db/migrate/20140422233206_add_system_picture_id_on_resource_picture_data.rb
new file mode 100644 (file)
index 0000000..bac0710
--- /dev/null
@@ -0,0 +1,31 @@
+class AddSystemPictureIdOnResourcePictureData < ActiveRecord::Migration
+  def up
+    ResourcePicture.all.each do |i|
+      if i.system_picture_id == 0 or i.system_picture_id.blank?
+        i.system_picture_id = i.license.system_picture_id
+        s = JSON.parse i.license_group_settings
+        if s['resize']
+          s.delete 'resize'
+          i.license_group_settings = s.to_json
+        end
+        i.boosts 'post'
+        i.save!
+      end
+    end
+    Picture.all.each do |i|
+      if i.system_picture_id == 0 or i.system_picture_id.blank?
+        i.system_picture_id = i.license.system_picture_id
+        s = JSON.parse i.license_group_settings
+        if s['resize']
+          s.delete 'resize'
+          i.license_group_settings = s.to_json
+        end
+        i.boosts 'post'
+        i.save!
+      end
+    end
+  end
+
+  def down
+  end
+end
index 953ceb9..c669aa6 100644 (file)
@@ -31,6 +31,10 @@ module Peta
       self.my_engine_resource.resource_items[self.classname]
     end
     
+    def my_engine
+      Object.const_get self.classname
+    end
+    
     def own? operators
       operators.admin?
     end
index cf9648b..0144577 100644 (file)
@@ -90,6 +90,8 @@
         "boost": {\r
           "license_group": {\r
             "resource_name": "license_group",\r
+            "engine_resource_name": "license_groups",\r
+            "engine_resource_extend_column_name": "license_group_classname",\r
             "extend_column_name": "license_group_classname",\r
             "settings_column_name": "license_group_settings",\r
             "extend_model_class_name": "License",\r
           "license": {\r
             "level": "read",\r
             "resource_name": "license_group",\r
+            "engine_resource_name": "license_groups",\r
+            "engine_resource_extend_column_name": "license_group_classname",\r
             "extend_column_name": "license_group_classname",\r
+            "settings_column_name": "license_settings",\r
             "extend_model_class_name": "Attribute",\r
             "extend_item_name": "attribute"\r
           },\r
           "credit_picture": {\r
             "level": "read",\r
             "resource_name": "license_group",\r
+            "engine_resource_name": "license_groups",\r
+            "engine_resource_extend_column_name": "license_group_classname",\r
             "extend_column_name": "license_group_classname",\r
             "settings_column_name": "credit_picture_settings",\r
             "extend_model_class_name": "CreditPicture",\r