Skip to content

Commit

Permalink
Replaced copyrighted column in Expressions table with enum intellectu…
Browse files Browse the repository at this point in the history
…al_property.

- Updated Manifestation CRUD pages
- Updated TextAPI to accept array `intellectual_property_types` instead of `is_copyrighted`
- Extracted common view code used to render intellectual property info with into a shared partial and reused it on several pages.
- Updated Admin#missing_copyright action to render works with unknown intellectual property
  • Loading branch information
damisul committed Apr 25, 2024
1 parent 4f0d21d commit 1a85400
Show file tree
Hide file tree
Showing 29 changed files with 221 additions and 132 deletions.
5 changes: 3 additions & 2 deletions app/api/v1/entities/manifestation_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class ManifestationIndex < Grape::Entity
expose :orig_publication_date
expose :author_gender, as: :author_genders, documentation: { values: ::Person.genders.keys, is_array: true }
expose :translator_gender, as: :translator_genders, documentation: { values: ::Person.genders.keys, is_array: true }
expose :copyright_status, documentation: { type: 'Boolean' }
expose :intellectual_property,
documentation: { values: ::Expression.intellectual_properties.keys, is_array: true }
expose :period, documentation: { values: Expression.periods.keys }
expose :raw_creation_date
expose :creation_date
Expand All @@ -45,4 +46,4 @@ class ManifestationIndex < Grape::Entity
end
end
end
end
end
22 changes: 18 additions & 4 deletions app/api/v1/texts_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@ class V1::TextsAPI < V1::ApplicationApi
type: [String],
values: Expression.periods.keys,
desc: 'specifies what section of the rough timeline of Hebrew literature an object belongs to.'
optional :is_copyrighted,
type: Boolean,
desc: 'limit search to copyrighted works or to non-copyrighted works'
optional :intellectual_property_types,
type: [String],
values: Expression.intellectual_properties.keys,
desc: 'limit search to works with selected intellectual property types'
optional :author_genders, type: [String], values: Person.genders.keys
optional :translator_genders, type: [String], values: Person.genders.keys
optional :title, type: String, desc: "a substring to match against a text's title"
Expand Down Expand Up @@ -140,7 +141,20 @@ class V1::TextsAPI < V1::ApplicationApi
success V1::Entities::ManifestationsPage
end
post do
filters = params.slice(*%w(genres periods is_copyrighted author_genders translator_genders title author fulltext author_ids uploaded_between created_between published_between))
filters = params.slice(*%w(
genres
periods
intellectual_property_types
author_genders
translator_genders
title
author
fulltext
author_ids
uploaded_between
created_between
published_between
))

orig_lang = params['original_language']
if orig_lang.present?
Expand Down
2 changes: 1 addition & 1 deletion app/chewy/manifestations_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ManifestationsIndex < Chewy::Index
field :tags, type: 'keyword', value: ->{ approved_tags.map(&:name) }
field :author_gender, value: ->(manifestation) {manifestation.author_gender }, type: 'keyword'
field :translator_gender, value: ->(manifestation) {manifestation.translator_gender}, type: 'keyword'
field :copyright_status, value: ->(manifestation) {manifestation.copyright?}, type: 'keyword' # TODO: make non boolean
field :intellectual_property, value: ->(manifestation) {manifestation.expression.intellectual_property}, type: 'keyword'
field :period, value: ->(manifestation) {manifestation.expression.period}, type: 'keyword'
field :raw_creation_date, value: ->(manifestation) {manifestation.expression.work.date}
field :creation_date, type: 'date', value: ->(manifestation) {normalize_date(manifestation.expression.work.date)}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def missing_images

def missing_copyright
@authors = Person.where(public_domain: nil)
records = Manifestation.joins(:expression).where(expressions: {copyrighted: nil})
records = Manifestation.joins(:expression).merge(Expression.intellectual_property_unknown)
@total = records.count
@mans = records.page(params[:page]).per(50)
@page_title = t(:missing_copyright_report)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/manifestation_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ def update
@e.title = params[:etitle]
@e.date = params[:edate]
@e.comment = params[:ecomment]
@e.copyrighted = (params[:public_domain] == 'false' ? true : false) # field name semantics are flipped from param name, yeah
@e.intellectual_property = params[:intellectual_property]
unless params[:add_person_e].blank?
r = Realizer.new(expression_id: @e.id, person_id: params[:add_person_e], role: params[:role_e].to_i)
r.save!
Expand Down
18 changes: 16 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ def textify_genre(genre)
return I18n.t(genre)
end

def textify_intellectual_property(value)
t(value, scope: 'intellectual_property')
end

# TODO: remove
def textify_copyright_status(copyrighted)
copyrighted ? t(:by_permission) : t(:public_domain)
end
Expand Down Expand Up @@ -154,8 +159,17 @@ def translators_linked_string(m)
return m.expression.translators.map{|x| "<a href=\"#{url_for(controller: :authors, action: :toc, id: x.id)}\">#{x.name}</a>"}.join(', ')
end

def copyright_glyph(is_copyright)
return is_copyright ? 'x' : 'm' # per /BY icons font/ben-yehuda/icons-reference.html
def intellectual_property_glyph(intellectual_property)
# per /BY icons font/ben-yehuda/icons-reference.html
case intellectual_property
when 'public_domain'
return 'm'
when 'copyrighted'
when 'by_permission'
return 'x'
else
return nil
end
end

def newsitem_glyph(item) # per icons-reference.html
Expand Down
5 changes: 5 additions & 0 deletions app/models/expression.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ class Expression < ApplicationRecord
has_many :tags, through: :taggings, class_name: 'Tag'
has_paper_trail # for monitoring crowdsourced inputs

enum intellectual_property: { public_domain: 0, by_permission: 1, copyrighted: 2, orphan: 3, unknown: 100 },
_prefix: true

validates_presence_of :intellectual_property

def editors
return realizers.includes(:person).where(role: Realizer.roles[:editor]).map{|x| x.person}
end
Expand Down
7 changes: 1 addition & 6 deletions app/services/search_manifestations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ def call(sort_by, sort_dir, filters)

add_simple_filter(filter, :genre, filters['genres'])
add_simple_filter(filter, :period, filters['periods'])
is_copyrighted = filters['is_copyrighted']

unless is_copyrighted.nil?
filter << { terms: { copyright_status: [is_copyrighted] } }
end

add_simple_filter(filter, :intellectual_property, filters['intellectual_property_types'])
add_simple_filter(filter, :author_gender, filters['author_genders'])
add_simple_filter(filter, :translator_gender, filters['translator_genders'])
add_simple_filter(filter, :author_ids, filters['author_ids'])
Expand Down
12 changes: 3 additions & 9 deletions app/views/authors/_author_top.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,8 @@
.author-page-top-years!= "(#{@author.life_years})"
.author-top-second-line
.author-page-top-rights
- if @author.public_domain
%span.by-icon-v02.copyright-icon> m
= textify_copyright_status(false)
= link_to '[?]', '#', 'class' => 'help', 'data-toggle' => 'popover', 'data-trigger' => 'focus', title: t(:about_public_domain), 'data-content' => t(:public_domain_popover)
- else
%span.by-icon-v02.copyright-icon> x
= textify_copyright_status(true)
= link_to '[?]', '#', 'class' => 'help', 'data-toggle' => 'popover', 'data-trigger' => 'focus', title: t(:about_permission), 'data-content' => t(:permission_popover)
= render partial: 'shared/intellectual_property',
locals: { intellectual_property: @author.public_domain ? :public_domain : :by_permission }
.author-sort-area
.author-page-top-sort-desktop.notyet
= t(:sort_and_filter)
Expand Down Expand Up @@ -73,4 +67,4 @@
$('.printbutton').click(function() {
window.open("#{@print_url}",'_blank');
});
});
});
10 changes: 2 additions & 8 deletions app/views/manifestation/_dict_entry_top.haml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,8 @@
- else
= '?'
.BYD-rights
- if @m.copyright?
%span.by-icon-v02.copyright-icon> x
= textify_copyright_status(true)
= link_to '[?]', '#', 'class' => 'help', 'data-toggle' => 'popover', 'data-trigger' => 'focus', title: t(:about_permission), 'data-content' => t(:permission_popover)
- else
%span.by-icon-v02.copyright-icon> m
= textify_copyright_status(false)
= link_to '[?]', '#', 'class' => 'help', 'data-toggle' => 'popover', 'data-trigger' => 'focus', title: t(:about_public_domain), 'data-content' => t(:public_domain_popover)
= render partial: 'shared/intellectual_property',
locals: { intellectual_property: @e.intellectual_property }
.topNavEntryArea.topNavEntryAreaDesktop
- unless @prev_entry.nil?
.topNavEntry
Expand Down
12 changes: 3 additions & 9 deletions app/views/manifestation/_dict_top.haml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@
- else
= '?'
.BYD-rights
- if @m.copyright?
%span.by-icon-v02.copyright-icon> x
= textify_copyright_status(true)
= link_to '[?]', '#', 'class' => 'help', 'data-toggle' => 'popover', 'data-trigger' => 'focus', title: t(:about_permission), 'data-content' => t(:permission_popover)
- else
%span.by-icon-v02.copyright-icon> m
= textify_copyright_status(false)
= link_to '[?]', '#', 'class' => 'help', 'data-toggle' => 'popover', 'data-trigger' => 'focus', title: t(:about_public_domain), 'data-content' => t(:public_domain_popover)
= render partial: 'shared/intellectual_property',
locals: { intellectual_property: @e.intellectual_property }
.author-sort-area.notyet#sort_filter_toggle{title: t(:toggle_filters_tt)}
.author-page-top-sort-desktop
%span.help= t(:filter)+' [?]'
Expand Down Expand Up @@ -119,4 +113,4 @@
$('.toggle-button-no').toggle();
$('.toggle-button-yes').toggle();
});
});
});
9 changes: 1 addition & 8 deletions app/views/manifestation/_metadata.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@

%div
.metadata
- if @m.copyright?
%span.by-icon-v02> x
= textify_copyright_status(true)
= link_to '[?]', '#', 'class' => 'help', 'data-toggle' => 'popover', 'data-trigger' => 'focus', title: t(:about_permission), 'data-content' => t(:permission_popover)
- else
%span.by-icon-v02> m
= textify_copyright_status(false)
= link_to '[?]', '#', 'class' => 'help', 'data-toggle' => 'popover', 'data-trigger' => 'focus', title: t(:about_public_domain), 'data-content' => t(:public_domain_popover)
= render partial: 'shared/intellectual_property', locals: { intellectual_property: @e.intellectual_property }
.metadata
%span.by-icon-v02.internal-genre-icon>= glyph_for_genre(@w.genre)
= textify_genre(@w.genre)
Expand Down
11 changes: 4 additions & 7 deletions app/views/manifestation/edit_metadata.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,9 @@
%b= t(:comments)+': '
= text_area_tag :ecomment, @e.comment, rows: 4, cols: 40
%p
%h3= t(:copyright_status)
= radio_button_tag :public_domain, true, @e.copyrighted.nil? ? false : (not @e.copyrighted)
= label_tag t(:public_domain)
= radio_button_tag(:public_domain, false, @e.copyrighted.nil? ? false : @e.copyrighted)
= label_tag t(:by_permission)
/ = textify_copyright_status(@e.copyrighted) # TODO: make editable
%h3= Expression.human_attribute_name(:intellectual_property)
- options = Expression.intellectual_properties.keys.map{ |code| [textify_intellectual_property(code), code] }
= select_tag :intellectual_property, options_for_select(options, @e.intellectual_property)
= render partial: 'shared/associated_people', locals: { which: :expression, expression: @e, edit: true}

%h2= t(:manifestation_details)
Expand Down Expand Up @@ -95,4 +92,4 @@
= text_field_tag :link_description
%p
= submit_tag t(:save)
= link_to t(:back), action: :show, id: @m.id
= link_to t(:back), action: :show, id: @m.id
4 changes: 2 additions & 2 deletions app/views/manifestation/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
%b= t(:period) + ': '
= t(@e.period)
%p
%b= t(:copyright_status)
= textify_copyright_status(@e.copyrighted)
%b #{Expression.human_attribute_name(:intellectual_property)}:
= textify_intellectual_property(@e.intellectual_property)
%p
%b= t(:language) + ': '
= textify_lang(@e.language)
Expand Down
13 changes: 4 additions & 9 deletions app/views/shared/_anth_panel.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,9 @@
%span{:style => "font-weight:bold"}= t(:page_count)+': '
%span= text.page_count
%div
- if text.manifestation.copyright?
%span.by-icon-v02.copyright-icon> x
= textify_copyright_status(true)
= link_to '[?]', '#', 'class' => 'help', 'data-toggle' => 'popover', 'data-trigger' => 'focus', title: t(:about_permission), 'data-content' => t(:permission_popover)
- else
%span.by-icon-v02.copyright-icon> m
= textify_copyright_status(false)
= link_to '[?]', '#', 'class' => 'help', 'data-toggle' => 'popover', 'data-trigger' => 'focus', title: t(:about_public_domain), 'data-content' => t(:public_domain_popover)
- intellectual_property = text.manifestation.expression.intellectual_property
= render partial: 'shared/intellectual_property',
locals: { intellectual_property: intellectual_property }
.bottom-right-buttons
#add_work_block{style: 'display: none'}
.by-button-v02.by-button-secondary-v02#add_work_btn{title: t(:anth_add_work_tt)}
Expand Down Expand Up @@ -285,4 +280,4 @@
// enable multi-select mode
}
});
});
});
6 changes: 6 additions & 0 deletions app/views/shared/_intellectual_property.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
%span.by-icon-v02= intellectual_property_glyph(intellectual_property)
= textify_intellectual_property(intellectual_property)
= link_to '[?]', '#',
class: :help,
data: { toggle: :popover, trigger: :focus, content: t(".popover.#{intellectual_property}") },
title: t(".about.#{intellectual_property}")
6 changes: 3 additions & 3 deletions app/views/shared/_surprise_work.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
.row
.col-md-6.col-sm-12
.metadata
.by-icon-v02.copyright-icon= copyright_glyph(manifestation.copyright?)
= textify_copyright_status(manifestation.copyright?)
%span.help{ 'data-toggle' => 'tooltip', title: manifestation.copyright? ? t(:permission_explain) : t(:pd_explain)}= '[?]'
.by-icon-v02.copyright-icon= intellectual_property_glyph(e.intellectual_property)
= textify_intellectual_property(e.intellectual_property)
%span.help{ data: { toggle: :tooltip }, title: t(".explanations.#{e.intellectual_property}")}= '[?]'
- if e.translation
.metadata
%b= t(:orig_lang)+': '
Expand Down
5 changes: 5 additions & 0 deletions config/locales/active_record.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
en:
activerecord:
attributes:
expression:
intellectual_property: Type of intellectual property
5 changes: 5 additions & 0 deletions config/locales/active_record.he.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
he:
activerecord:
attributes:
expression:
intellectual_property: Type of intellectual property
26 changes: 26 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@ en:
next_page: Next page
previous_page: Previous page
first_page: First page
surprise_work:
explanations:
public_domain: not protected by intellectual property laws
by_permission: there is an explicit permission for publication from the owner
copyrighted: copyrighted
orphan: orphan
unknown: unknown
intellectual_property:
about:
public_domain: what does it means 'public domain'?
by_permission: what does it means 'by permission'?
copyrighted: what does it means 'copyrighted'?
orphan: what does it means 'orphan'?
unknown: what does it means 'unknown'?
popover:
public_domain: Copyright Law protects against unauthorized use of works for the duration of its validity (in Israel, seventy years from the end of the year of the creator's death). With the expiry of the rights, the creation becomes 'public domain', that is, the property of the public. This means that the work belongs to all of us, and we are all entitled to make any use of it, including commercial use, without the need to ask permission of anyone.
by_permission: Although the work is still copyrighted, the Ben־Yehuda Project has received *explicit permission to publish* The work in the Ben־Yehuda Project database, for the general public to read and research. Other uses (such as play, composition, or commercial performance) still *require express approval* from the rights holders.
copyrighted: TBD description for 'copyrighted'
orphan: TBD description for 'orphan'
unknown: TBD description for 'unknown'
welcome:
submit_contact:
ziburit_failed: Control question failed
Expand All @@ -24,3 +44,9 @@ en:
ziburit_failed: Control question failed
email_missing: Please provide an email address
manifestation:
intellectual_property:
public_domain: public domain
by_permission: by permission
copyrighted: copyrighted
orphan: orphan
unknown: unknown
Loading

0 comments on commit 1a85400

Please sign in to comment.