pettanr_creative_commons_v30_licenses 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/pettanr_creative_commons_v30_licenses/attributes_controller.rb +2 -3
- data/app/models/pettanr_creative_commons_v30_licenses/attribute.rb +16 -16
- data/app/views/pettanr_creative_commons_v30_licenses/attributes/_credit.html.erb +6 -5
- data/app/views/pettanr_creative_commons_v30_licenses/attributes/_full_credit.html.erb +4 -4
- data/db/migrate/20140410234708_fix_pettanr_creative_commons_v30_licenses_attributes_system_picture_id.rb +8 -0
- data/lib/pettanr_creative_commons_v30_licenses.rb +7 -7
- data/lib/pettanr_creative_commons_v30_licenses/version.rb +1 -1
- metadata +3 -2
@@ -2,8 +2,7 @@ require_dependency "pettanr_creative_commons_v30_licenses/application_controller
|
|
2
2
|
|
3
3
|
module PettanrCreativeCommonsV30Licenses
|
4
4
|
class AttributesController < ApplicationController
|
5
|
-
|
6
|
-
before_filter :authenticate_user!, :only => [:new, :create]
|
5
|
+
before_filter :authenticate_user, :only => [:new, :create]
|
7
6
|
before_filter :authenticate_artist, :only => [:new, :create]
|
8
7
|
|
9
8
|
def new
|
@@ -24,7 +23,7 @@ module PettanrCreativeCommonsV30Licenses
|
|
24
23
|
@creative_commons_license = PettanrCreativeCommonsV30Licenses::Attribute.new params[:creative_commons_license]
|
25
24
|
@license = License.show @creative_commons_license.license_id, @operators
|
26
25
|
@resource_picture = @original_picture.resource_picture || ResourcePicture.new
|
27
|
-
@resource_picture.attributes = @creative_commons_license.resource_picture_attributes @original_picture
|
26
|
+
@resource_picture.attributes = @creative_commons_license.resource_picture_attributes @original_picture, @license
|
28
27
|
@resource_picture.overwrite @original_picture
|
29
28
|
respond_to do |format|
|
30
29
|
if @creative_commons_license.valid?
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module PettanrCreativeCommonsV30Licenses
|
2
2
|
class Attribute < ActiveRecord::Base
|
3
|
-
|
3
|
+
# belongs_to :license
|
4
4
|
|
5
|
-
|
5
|
+
# validates :license_id, :presence => true, :numericality => true, :existence => true
|
6
6
|
validates :artist_name, :presence => true
|
7
7
|
validates :artist_url, :url => {:allow_blank => true}
|
8
8
|
validates :source_url, :url => {:allow_blank => true}
|
@@ -12,11 +12,21 @@ module PettanrCreativeCommonsV30Licenses
|
|
12
12
|
self.artist_name = operators.artist.name
|
13
13
|
end
|
14
14
|
|
15
|
-
def resource_picture_attributes op
|
15
|
+
def resource_picture_attributes op, ls
|
16
16
|
{
|
17
|
-
:original_picture_id => op.id,
|
18
|
-
:
|
19
|
-
:
|
17
|
+
:original_picture_id => op.id,
|
18
|
+
:license_id => ls.id,
|
19
|
+
:artist_name => self.artist_name,
|
20
|
+
:license_group_classname => ls.license_group_classname,
|
21
|
+
:license_group_settings => ls.license_group_settings,
|
22
|
+
:credit_picture_settings => ls.credit_picture_settings,
|
23
|
+
:license_settings => {
|
24
|
+
:system_picture_id => ls.system_picture_id,
|
25
|
+
:caption => self.caption,
|
26
|
+
:artist_url => self.artist_url,
|
27
|
+
:source_url => self.source_url,
|
28
|
+
:more_permission_url => self.more_permission_url
|
29
|
+
}.to_json
|
20
30
|
}
|
21
31
|
end
|
22
32
|
|
@@ -27,15 +37,5 @@ module PettanrCreativeCommonsV30Licenses
|
|
27
37
|
[op, oplg, lg]
|
28
38
|
end
|
29
39
|
|
30
|
-
def credit
|
31
|
-
{
|
32
|
-
:system_picture_id => self.license.system_picture_id,
|
33
|
-
:caption => self.caption,
|
34
|
-
:artist_url => self.artist_url,
|
35
|
-
:source_url => self.source_url,
|
36
|
-
:more_permission_url => self.more_permission_url
|
37
|
-
}.to_json.to_s
|
38
|
-
end
|
39
|
-
|
40
40
|
end
|
41
41
|
end
|
@@ -7,29 +7,30 @@
|
|
7
7
|
%>
|
8
8
|
</td>
|
9
9
|
<td>
|
10
|
+
<% picture.boosts 'post' %>
|
10
11
|
<div class="md5">
|
11
12
|
<%= h(truncate(picture.artist_name, :length => 12)) %>
|
12
13
|
</div>
|
13
14
|
<div class="md5">
|
14
|
-
<%= h(truncate(picture.
|
15
|
+
<%= h(truncate(picture.attribute_extend.caption, :length => 12)) %>
|
15
16
|
</div>
|
16
17
|
<div class="md5">
|
17
18
|
<% picture.license.boosts 'read' %>
|
18
|
-
<% if picture.
|
19
|
+
<% if picture.attribute_extend.source_url.blank? %>
|
19
20
|
<% else %>
|
20
21
|
<% source_url_btn = SystemPicture.find(picture.license.credit_picture_extend.source_url_btn_id) %>
|
21
22
|
<%= link_to(
|
22
23
|
tag(:img, :src => source_url_btn.url, :alt => 'source url', :width => source_url_btn.width, :height => source_url_btn.height),
|
23
|
-
picture.
|
24
|
+
picture.attribute_extend.source_url )
|
24
25
|
%>
|
25
26
|
<% end %>
|
26
27
|
|
27
|
-
<% if picture.
|
28
|
+
<% if picture.attribute_extend.more_permission_url.blank? %>
|
28
29
|
<% else %>
|
29
30
|
<% source_url_btn = SystemPicture.find(picture.license.credit_picture_extend.source_url_btn_id) %>
|
30
31
|
<%= link_to(
|
31
32
|
tag(:img, :src => source_url_btn.url, :alt => 'source url', :width => source_url_btn.width, :height => source_url_btn.height),
|
32
|
-
picture.
|
33
|
+
picture.attribute_extend.more_permission_url )
|
33
34
|
%>
|
34
35
|
<% end %>
|
35
36
|
</div>
|
@@ -14,7 +14,7 @@
|
|
14
14
|
</tr>
|
15
15
|
<tr>
|
16
16
|
<td><%= t_m 'PettanrCreativeCommonsV30Licenses::Attribute.artist_name' -%></td>
|
17
|
-
<td><%= link_to_if picture.
|
17
|
+
<td><%= link_to_if picture.attribute_extend.artist_url, h(picture.artist_name), picture.attribute_extend.artist_url -%></td>
|
18
18
|
</tr>
|
19
19
|
<tr>
|
20
20
|
<td><%= t_m 'LicenseGroup' -%></td>
|
@@ -26,14 +26,14 @@
|
|
26
26
|
</tr>
|
27
27
|
<tr>
|
28
28
|
<td><%= t_m 'PettanrCreativeCommonsV30Licenses::Attribute.caption' -%></td>
|
29
|
-
<td><%= h picture.
|
29
|
+
<td><%= h picture.attribute_extend.caption -%></td>
|
30
30
|
</tr>
|
31
31
|
<tr>
|
32
32
|
<td><%= t_m 'PettanrCreativeCommonsV30Licenses::Attribute.source_url' -%></td>
|
33
|
-
<td><%= link_to(h(picture.
|
33
|
+
<td><%= link_to(h(picture.attribute_extend.source_url), picture.attribute_extend.source_url) -%></td>
|
34
34
|
</tr>
|
35
35
|
<tr>
|
36
36
|
<td><%= t_m 'PettanrCreativeCommonsV30Licenses::Attribute.more_permission_url' -%></td>
|
37
|
-
<td><%= link_to(h(picture.
|
37
|
+
<td><%= link_to(h(picture.attribute_extend.more_permission_url), picture.attribute_extend.more_permission_url) -%></td>
|
38
38
|
</tr>
|
39
39
|
</table>
|
@@ -53,21 +53,21 @@ module PettanrCreativeCommonsV30Licenses
|
|
53
53
|
super
|
54
54
|
end
|
55
55
|
|
56
|
-
def
|
57
|
-
self.
|
58
|
-
@
|
56
|
+
def attribute_extend
|
57
|
+
self.new_attribute unless @attribute_extend
|
58
|
+
@attribute_extend ||= PettanrCreativeCommonsV30Licenses::Attribute.new
|
59
59
|
end
|
60
60
|
|
61
|
-
def
|
61
|
+
def attribute_extend= params
|
62
62
|
# load attributes
|
63
|
-
@
|
63
|
+
@attribute_extend = PettanrCreativeCommonsV30Licenses::Attribute.new params
|
64
64
|
# no supply default params
|
65
65
|
end
|
66
66
|
|
67
67
|
def new_resource_picture params = {}
|
68
|
-
@
|
68
|
+
@attribute_extend = PettanrCreativeCommonsV30Licenses::Attribute.new params
|
69
69
|
# Attribute's supply_default need operators
|
70
|
-
# @
|
70
|
+
# @attribute_extend.supply_default operators
|
71
71
|
end
|
72
72
|
|
73
73
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pettanr_creative_commons_v30_licenses
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- db/migrate/20121008044128_create_pettanr_creative_commons_v30_licenses_attributes.rb
|
83
83
|
- db/migrate/20140408085033_create_pettanr_creative_commons_v30_licenses_licenses.rb
|
84
84
|
- db/migrate/20140408085049_create_pettanr_creative_commons_v30_licenses_credit_pictures.rb
|
85
|
+
- db/migrate/20140410234708_fix_pettanr_creative_commons_v30_licenses_attributes_system_picture_id.rb
|
85
86
|
- db/pettanr_creative_commons_v30_license.json
|
86
87
|
- db/pettanr_creative_commons_v30_license.yml
|
87
88
|
- lib/pettanr_creative_commons_v30_licenses/engine.rb
|