pettanr_creative_commons_v30_licenses 0.1.5 → 0.1.6
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 +7 -8
- data/app/models/pettanr_creative_commons_v30_licenses/attribute.rb +13 -3
- data/app/views/pettanr_creative_commons_v30_licenses/attributes/_credit.html.erb +11 -6
- data/app/views/pettanr_creative_commons_v30_licenses/attributes/_form.html.erb +13 -19
- data/app/views/pettanr_creative_commons_v30_licenses/attributes/_full_credit.html.erb +3 -1
- data/db/migrate/20121008044128_create_pettanr_creative_commons_v30_licenses_attributes.rb +0 -1
- data/lib/pettanr_creative_commons_v30_licenses.rb +9 -7
- data/lib/pettanr_creative_commons_v30_licenses/version.rb +1 -1
- metadata +2 -5
- data/app/views/layouts/pettanr_creative_commons_v30_licenses/application.html.erb +0 -14
- data/app/views/pettanr_creative_commons_v30_licenses/attributes/new.js.erb +0 -1
- data/db/migrate/20140410234708_fix_pettanr_creative_commons_v30_licenses_attributes_system_picture_id.rb +0 -8
@@ -8,25 +8,24 @@ module PettanrCreativeCommonsV30Licenses
|
|
8
8
|
def new
|
9
9
|
@original_picture, @original_picture_license_group, @license_group =
|
10
10
|
PettanrCreativeCommonsV30Licenses::Attribute.remember_params params, @operators
|
11
|
-
@
|
12
|
-
@
|
11
|
+
@attr = @license_group.my_engine.new_attribute {}
|
12
|
+
@attr.supply_default @operators
|
13
13
|
|
14
14
|
respond_to do |format|
|
15
|
-
format.html
|
16
|
-
# format.js
|
15
|
+
format.html
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
20
19
|
def create
|
21
20
|
@original_picture, @original_picture_license_group, @license_group =
|
22
21
|
PettanrCreativeCommonsV30Licenses::Attribute.remember_params params, @operators
|
23
|
-
@
|
24
|
-
@license = License.show @
|
22
|
+
@attr = PettanrCreativeCommonsV30Licenses.new_attribute params[:creative_commons_license]
|
23
|
+
@license = License.show @attr.license_id, @operators
|
25
24
|
@resource_picture = @original_picture.resource_picture || ResourcePicture.new
|
26
|
-
@resource_picture.attributes = @
|
25
|
+
@resource_picture.attributes = @attr.resource_picture_attributes @original_picture, @license
|
27
26
|
@resource_picture.overwrite @original_picture
|
28
27
|
respond_to do |format|
|
29
|
-
if @
|
28
|
+
if @attr.valid?
|
30
29
|
format.html { render main_app.new_resource_picture_path }
|
31
30
|
format.json { render json: @resource_picture.to_json(ResourcePicture.show_json_opt), status: :created }
|
32
31
|
else
|
@@ -1,8 +1,7 @@
|
|
1
1
|
module PettanrCreativeCommonsV30Licenses
|
2
2
|
class Attribute < ActiveRecord::Base
|
3
|
-
# belongs_to :license
|
4
3
|
|
5
|
-
|
4
|
+
validates :license_id, :presence => true, :numericality => true #, :existence => true
|
6
5
|
validates :artist_name, :presence => true
|
7
6
|
validates :artist_url, :url => {:allow_blank => true}
|
8
7
|
validates :source_url, :url => {:allow_blank => true}
|
@@ -17,11 +16,14 @@ module PettanrCreativeCommonsV30Licenses
|
|
17
16
|
:original_picture_id => op.id,
|
18
17
|
:license_id => ls.id,
|
19
18
|
:artist_name => self.artist_name,
|
19
|
+
:system_picture_id => ls.system_picture_id,
|
20
20
|
:license_group_classname => ls.license_group_classname,
|
21
21
|
:license_group_settings => ls.license_group_settings,
|
22
22
|
:credit_picture_settings => ls.credit_picture_settings,
|
23
23
|
:license_settings => {
|
24
|
-
:
|
24
|
+
:license_id => ls.id,
|
25
|
+
# :system_picture_id => ls.system_picture_id, # no save
|
26
|
+
:artist_name => self.artist_name,
|
25
27
|
:caption => self.caption,
|
26
28
|
:artist_url => self.artist_url,
|
27
29
|
:source_url => self.source_url,
|
@@ -37,5 +39,13 @@ module PettanrCreativeCommonsV30Licenses
|
|
37
39
|
[op, oplg, lg]
|
38
40
|
end
|
39
41
|
|
42
|
+
def label_name field_name = nil
|
43
|
+
self.class.to_s + (field_name ? '.' + field_name : '')
|
44
|
+
end
|
45
|
+
|
46
|
+
def tag_name field_name
|
47
|
+
'creative_commons_license[' + field_name + ']'
|
48
|
+
end
|
49
|
+
|
40
50
|
end
|
41
51
|
end
|
@@ -2,7 +2,9 @@
|
|
2
2
|
<tr>
|
3
3
|
<td width="1px">
|
4
4
|
<%= content_tag(:a,
|
5
|
-
tag(:img, :src => picture.
|
5
|
+
tag(:img, :src => picture.system_picture.url,
|
6
|
+
:alt => h(picture.alt_name),
|
7
|
+
:width => picture.system_picture.width, :height => picture.system_picture.height),
|
6
8
|
:href => picture.license.url )
|
7
9
|
%>
|
8
10
|
</td>
|
@@ -15,21 +17,24 @@
|
|
15
17
|
<%= h(truncate(picture.attribute_extend.caption, :length => 12)) %>
|
16
18
|
</div>
|
17
19
|
<div class="md5">
|
18
|
-
<% picture.license.boosts 'read' %>
|
19
20
|
<% if picture.attribute_extend.source_url.blank? %>
|
20
21
|
<% else %>
|
21
|
-
<% source_url_btn =
|
22
|
+
<% source_url_btn = picture.credit_picture_extend.source_url_btn %>
|
22
23
|
<%= link_to(
|
23
|
-
tag(:img, :src => source_url_btn.url, :alt => 'source url',
|
24
|
+
tag(:img, :src => source_url_btn.url, :alt => 'source url',
|
25
|
+
:width => source_url_btn.width, :height => source_url_btn.height
|
26
|
+
),
|
24
27
|
picture.attribute_extend.source_url )
|
25
28
|
%>
|
26
29
|
<% end %>
|
27
30
|
|
28
31
|
<% if picture.attribute_extend.more_permission_url.blank? %>
|
29
32
|
<% else %>
|
30
|
-
<% source_url_btn =
|
33
|
+
<% source_url_btn = picture.credit_picture_extend.source_url_btn %>
|
31
34
|
<%= link_to(
|
32
|
-
tag(:img, :src => source_url_btn.url, :alt => '
|
35
|
+
tag(:img, :src => source_url_btn.url, :alt => 'more_permission_url',
|
36
|
+
:width => source_url_btn.width, :height => source_url_btn.height
|
37
|
+
),
|
33
38
|
picture.attribute_extend.more_permission_url )
|
34
39
|
%>
|
35
40
|
<% end %>
|
@@ -1,46 +1,40 @@
|
|
1
|
-
<%
|
2
|
-
unless @creative_commons_license
|
3
|
-
@creative_commons_license = PettanrCreativeCommonsV30Licenses::Attribute.new
|
4
|
-
@creative_commons_license.supply_default @operators
|
5
|
-
end
|
6
|
-
%>
|
7
1
|
<%= form_tag('/pettanr_creative_commons_v30_licenses/attributes') do %>
|
8
|
-
<%= render 'system/error_explanation', :obj => @
|
2
|
+
<%= render 'system/error_explanation', :obj => @attr %>
|
9
3
|
|
10
4
|
<table class="no-border">
|
11
5
|
<tr>
|
12
6
|
<td><%= t_m 'LicenseGroup' -%></td>
|
13
|
-
<td><%= t_m
|
7
|
+
<td><%= t_m @attr.label_name -%></td>
|
14
8
|
<td><%= t('pettanr_creative_commons_v30_licenses.selected') -%></td>
|
15
9
|
</tr>
|
16
10
|
<tr>
|
17
|
-
<td><%= t_m '
|
11
|
+
<td><%= t_m @attr.label_name('license_id') -%></td>
|
18
12
|
<td><%= collection_select :creative_commons_license, :license_id, @license_group.licenses.map {|l| [l.caption, l.id] }, :last, :first -%></td>
|
19
13
|
<td><%= t('pettanr_creative_commons_v30_licenses.no_blank') -%></td>
|
20
14
|
</tr>
|
21
15
|
<tr>
|
22
|
-
<td><%= t_m '
|
23
|
-
<td><%= text_field_tag '
|
16
|
+
<td><%= t_m @attr.label_name('artist_name') -%></td>
|
17
|
+
<td><%= text_field_tag @attr.tag_name('artist_name'), @attr.artist_name -%></td>
|
24
18
|
<td><%= t('pettanr_creative_commons_v30_licenses.no_blank') -%></td>
|
25
19
|
</tr>
|
26
20
|
<tr>
|
27
|
-
<td><%= t_m '
|
28
|
-
<td><%= text_field_tag '
|
21
|
+
<td><%= t_m @attr.label_name('caption') -%></td>
|
22
|
+
<td><%= text_field_tag @attr.tag_name('caption'), @attr.caption -%></td>
|
29
23
|
<td></td>
|
30
24
|
</tr>
|
31
25
|
<tr>
|
32
|
-
<td><%= t_m '
|
33
|
-
<td><%= text_field_tag '
|
26
|
+
<td><%= t_m @attr.label_name('artist_url') -%></td>
|
27
|
+
<td><%= text_field_tag @attr.tag_name('artist_url'), @attr.artist_url -%></td>
|
34
28
|
<td></td>
|
35
29
|
</tr>
|
36
30
|
<tr>
|
37
|
-
<td><%= t_m '
|
38
|
-
<td><%= text_field_tag '
|
31
|
+
<td><%= t_m @attr.label_name('source_url') -%></td>
|
32
|
+
<td><%= text_field_tag @attr.tag_name('source_url'), @attr.source_url -%></td>
|
39
33
|
<td></td>
|
40
34
|
</tr>
|
41
35
|
<tr>
|
42
|
-
<td><%= t_m '
|
43
|
-
<td><%= text_field_tag '
|
36
|
+
<td><%= t_m @attr.label_name('more_permission_url') -%></td>
|
37
|
+
<td><%= text_field_tag @attr.tag_name('more_permission_url'), @attr.more_permission_url -%></td>
|
44
38
|
<td></td>
|
45
39
|
</tr>
|
46
40
|
</table>
|
@@ -2,7 +2,9 @@
|
|
2
2
|
<tr>
|
3
3
|
<td colspan="2">
|
4
4
|
<%= link_to(
|
5
|
-
tag(:img, :src => picture.license.system_picture.url,
|
5
|
+
tag(:img, :src => picture.license.system_picture.url,
|
6
|
+
:alt => h(picture.alt_name),
|
7
|
+
:width => picture.system_picture.width, :height => picture.system_picture.height),
|
6
8
|
picture.license.url )
|
7
9
|
%>
|
8
10
|
</td>
|
@@ -1,7 +1,6 @@
|
|
1
1
|
class CreatePettanrCreativeCommonsV30LicensesAttributes < ActiveRecord::Migration
|
2
2
|
def change
|
3
3
|
create_table :pettanr_creative_commons_v30_licenses_attributes do |t|
|
4
|
-
t.column :license_id, :integer, :null => false, :default => 0
|
5
4
|
t.column :artist_name, :string, :null => false, :default => 'unknown'
|
6
5
|
t.column :caption, :text
|
7
6
|
t.column :artist_url, :text
|
@@ -54,21 +54,23 @@ module PettanrCreativeCommonsV30Licenses
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def attribute_extend
|
57
|
-
|
58
|
-
@attribute_extend ||= PettanrCreativeCommonsV30Licenses::Attribute.new
|
57
|
+
@attribute_extend
|
59
58
|
end
|
60
59
|
|
61
60
|
def attribute_extend= params
|
62
61
|
# load attributes
|
63
|
-
@attribute_extend = PettanrCreativeCommonsV30Licenses
|
62
|
+
@attribute_extend = PettanrCreativeCommonsV30Licenses.new_attribute params
|
64
63
|
# no supply default params
|
65
64
|
end
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
66
|
+
end
|
67
|
+
|
68
|
+
module ModuleMethods
|
69
|
+
def new_attribute params = {}
|
70
|
+
PettanrCreativeCommonsV30Licenses::Attribute.new params
|
71
71
|
end
|
72
72
|
|
73
73
|
end
|
74
|
+
|
75
|
+
extend ModuleMethods
|
74
76
|
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.6
|
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-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -61,9 +61,7 @@ files:
|
|
61
61
|
- app/models/pettanr_creative_commons_v30_licenses/attribute.rb
|
62
62
|
- app/models/pettanr_creative_commons_v30_licenses/credit_picture.rb
|
63
63
|
- app/models/pettanr_creative_commons_v30_licenses/license.rb
|
64
|
-
- app/views/layouts/pettanr_creative_commons_v30_licenses/application.html.erb
|
65
64
|
- app/views/pettanr_creative_commons_v30_licenses/attributes/new.html.erb
|
66
|
-
- app/views/pettanr_creative_commons_v30_licenses/attributes/new.js.erb
|
67
65
|
- app/views/pettanr_creative_commons_v30_licenses/attributes/_confirm.html.erb
|
68
66
|
- app/views/pettanr_creative_commons_v30_licenses/attributes/_credit.html.erb
|
69
67
|
- app/views/pettanr_creative_commons_v30_licenses/attributes/_form.html.erb
|
@@ -82,7 +80,6 @@ files:
|
|
82
80
|
- db/migrate/20121008044128_create_pettanr_creative_commons_v30_licenses_attributes.rb
|
83
81
|
- db/migrate/20140408085033_create_pettanr_creative_commons_v30_licenses_licenses.rb
|
84
82
|
- 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
|
86
83
|
- db/pettanr_creative_commons_v30_license.json
|
87
84
|
- db/pettanr_creative_commons_v30_license.yml
|
88
85
|
- lib/pettanr_creative_commons_v30_licenses/engine.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>PettanrCreativeCommonsV30Licenses</title>
|
5
|
-
<%= stylesheet_link_tag "pettanr_creative_commons_v30_licenses/application", :media => "all" %>
|
6
|
-
<%= javascript_include_tag "pettanr_creative_commons_v30_licenses/application" %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|
@@ -1 +0,0 @@
|
|
1
|
-
$("#oplg").html("<%= escape_javascript(render('form')) -%>");
|