From 84a5b0cfc30cd42930ee80551ba389b223643dc3 Mon Sep 17 00:00:00 2001 From: yasushiito Date: Sat, 26 Apr 2014 11:02:10 +0900 Subject: [PATCH] fic picture publishing --- .../javascripts/manifest/work/items.js.coffee.erb | 7 + .../javascripts/manifest/work/models.js.coffee.erb | 7 - .../manifest/work/profilers.js.coffee.erb | 1 - app/assets/stylesheets/test.css.scss | 3 + .../original_picture_license_groups_controller.rb | 2 + app/models/picture.rb | 9 +- app/models/resource_picture.rb | 6 + app/views/resource_pictures/_form.html.erb | 1 + config/locales/pettanr.ja.yml | 145 ++++++++++++++++++++- ...25_add_system_picture_id_on_resource_picture.rb | 9 ++ ...d_system_picture_id_on_resource_picture_data.rb | 31 +++++ lib/peta/system_resource.rb | 4 + public/manifest.json | 7 + 13 files changed, 216 insertions(+), 16 deletions(-) create mode 100644 db/migrate/20140422231825_add_system_picture_id_on_resource_picture.rb create mode 100644 db/migrate/20140422233206_add_system_picture_id_on_resource_picture_data.rb diff --git a/app/assets/javascripts/manifest/work/items.js.coffee.erb b/app/assets/javascripts/manifest/work/items.js.coffee.erb index a383a5f6..95852f2a 100644 --- a/app/assets/javascripts/manifest/work/items.js.coffee.erb +++ b/app/assets/javascripts/manifest/work/items.js.coffee.erb @@ -101,6 +101,8 @@ # expand license_group_settings license_group: { resource_name: 'license_group', + engine_resource_name: 'license_groups', + engine_resource_extend_column_name: 'license_group_classname', extend_column_name: 'license_group_classname', settings_column_name: 'license_group_settings', extend_model_class_name: 'License', @@ -110,13 +112,18 @@ license: { level: 'read', resource_name: 'license_group', + engine_resource_name: 'license_groups', + engine_resource_extend_column_name: 'license_group_classname', extend_column_name: 'license_group_classname', + settings_column_name: 'license_settings', extend_model_class_name: 'Attribute', extend_item_name: 'attribute', }, credit_picture: { level: 'read', resource_name: 'license_group', + engine_resource_name: 'license_groups', + engine_resource_extend_column_name: 'license_group_classname', extend_column_name: 'license_group_classname', settings_column_name: 'credit_picture_settings', extend_model_class_name: 'CreditPicture', diff --git a/app/assets/javascripts/manifest/work/models.js.coffee.erb b/app/assets/javascripts/manifest/work/models.js.coffee.erb index 8d38edfb..4a197d3e 100644 --- a/app/assets/javascripts/manifest/work/models.js.coffee.erb +++ b/app/assets/javascripts/manifest/work/models.js.coffee.erb @@ -1142,13 +1142,6 @@ number: true, } }, - revision: { - type: 'number', - rules : { - required: true, - number: true, - } - }, ext: { type: 'text', rules : { diff --git a/app/assets/javascripts/manifest/work/profilers.js.coffee.erb b/app/assets/javascripts/manifest/work/profilers.js.coffee.erb index 71074fb5..b047fd16 100644 --- a/app/assets/javascripts/manifest/work/profilers.js.coffee.erb +++ b/app/assets/javascripts/manifest/work/profilers.js.coffee.erb @@ -359,7 +359,6 @@ }, column_names: [ 'original_picture_id', - 'revision', 'ext', 'width', 'height', diff --git a/app/assets/stylesheets/test.css.scss b/app/assets/stylesheets/test.css.scss index 48bdcffe..9c1c215d 100644 --- a/app/assets/stylesheets/test.css.scss +++ b/app/assets/stylesheets/test.css.scss @@ -357,6 +357,9 @@ font-family : monospace; clear: both; } +.extend_column { + margin-left: 20px; +} .filer { list-style-type: none; diff --git a/app/controllers/original_picture_license_groups_controller.rb b/app/controllers/original_picture_license_groups_controller.rb index dff5e0b2..eebd1994 100644 --- a/app/controllers/original_picture_license_groups_controller.rb +++ b/app/controllers/original_picture_license_groups_controller.rb @@ -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? diff --git a/app/models/picture.rb b/app/models/picture.rb index 0725faf8..85c68ef1 100644 --- a/app/models/picture.rb +++ b/app/models/picture.rb @@ -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 diff --git a/app/models/resource_picture.rb b/app/models/resource_picture.rb index 2ec06855..c6975ef6 100644 --- a/app/models/resource_picture.rb +++ b/app/models/resource_picture.rb @@ -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 diff --git a/app/views/resource_pictures/_form.html.erb b/app/views/resource_pictures/_form.html.erb index 5025683f..03c6b5d1 100644 --- a/app/views/resource_pictures/_form.html.erb +++ b/app/views/resource_pictures/_form.html.erb @@ -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 %> diff --git a/config/locales/pettanr.ja.yml b/config/locales/pettanr.ja.yml index a254fb1d..3b8aa881 100644 --- a/config/locales/pettanr.ja.yml +++ b/config/locales/pettanr.ja.yml @@ -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 index 00000000..1de71736 --- /dev/null +++ b/db/migrate/20140422231825_add_system_picture_id_on_resource_picture.rb @@ -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 index 00000000..bac07109 --- /dev/null +++ b/db/migrate/20140422233206_add_system_picture_id_on_resource_picture_data.rb @@ -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 diff --git a/lib/peta/system_resource.rb b/lib/peta/system_resource.rb index 953ceb9b..c669aa6c 100644 --- a/lib/peta/system_resource.rb +++ b/lib/peta/system_resource.rb @@ -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 diff --git a/public/manifest.json b/public/manifest.json index cf9648bd..0144577d 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -90,6 +90,8 @@ "boost": { "license_group": { "resource_name": "license_group", + "engine_resource_name": "license_groups", + "engine_resource_extend_column_name": "license_group_classname", "extend_column_name": "license_group_classname", "settings_column_name": "license_group_settings", "extend_model_class_name": "License", @@ -98,13 +100,18 @@ "license": { "level": "read", "resource_name": "license_group", + "engine_resource_name": "license_groups", + "engine_resource_extend_column_name": "license_group_classname", "extend_column_name": "license_group_classname", + "settings_column_name": "license_settings", "extend_model_class_name": "Attribute", "extend_item_name": "attribute" }, "credit_picture": { "level": "read", "resource_name": "license_group", + "engine_resource_name": "license_groups", + "engine_resource_extend_column_name": "license_group_classname", "extend_column_name": "license_group_classname", "settings_column_name": "credit_picture_settings", "extend_model_class_name": "CreditPicture", -- 2.11.0