Revision 1431:303b9be118d4 plugins/redmine_bibliography
| plugins/redmine_bibliography/app/controllers/publications_controller.rb | ||
|---|---|---|
| 15 | 15 |
# we'll always want a new publication to have its bibtex entry |
| 16 | 16 |
@publication.build_bibtex_entry |
| 17 | 17 |
|
| 18 |
# and at least one author |
|
| 19 |
# @publication.authorships.build.build_author |
|
| 20 |
@author_options = [["#{User.current.name} (@#{User.current.mail.partition('@')[2]})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]]
|
|
| 21 | 18 |
end |
| 22 | 19 |
|
| 23 | 20 |
def create |
| 24 | 21 |
@project = Project.find(params[:project_id]) |
| 25 | 22 |
|
| 26 |
@author_options = [] |
|
| 27 |
|
|
| 28 | 23 |
@publication = Publication.new(params[:publication]) |
| 29 | 24 |
@publication.projects << @project unless @project.nil? |
| 30 | 25 |
|
| ... | ... | |
| 91 | 86 |
@publication = Publication.find(params[:id]) |
| 92 | 87 |
@selected_bibtex_entry_type_id = @publication.bibtex_entry.entry_type |
| 93 | 88 |
|
| 94 |
@author_options = [] |
|
| 95 |
|
|
| 96 | 89 |
@bibtype_fields = BibtexEntryType.fields(@selected_bibtex_entry_type_id) |
| 97 | 90 |
end |
| 98 | 91 |
|
| 99 | 92 |
def update |
| 100 | 93 |
@publication = Publication.find(params[:id]) |
| 101 |
@author_options = [] |
|
| 102 | 94 |
|
| 103 | 95 |
if @publication.update_attributes(params[:publication]) |
| 104 | 96 |
flash[:notice] = "Successfully updated Publication." |
| ... | ... | |
| 176 | 168 |
@publication.bibtex_entry = @bentry |
| 177 | 169 |
@publication.save |
| 178 | 170 |
|
| 179 |
# what is this for??? |
|
| 180 |
# @created_publications << @publication.id |
|
| 181 |
|
|
| 182 | 171 |
# need to save all authors |
| 183 | 172 |
# and establish the author-publication association |
| 184 | 173 |
# via the authorships table |
| ... | ... | |
| 199 | 188 |
end |
| 200 | 189 |
end |
| 201 | 190 |
|
| 202 |
# parses the bibtex file |
|
| 203 |
def parse_bibtex_file |
|
| 204 |
|
|
| 205 |
end |
|
| 206 |
|
|
| 207 |
def import |
|
| 208 |
@publication = Publication.new |
|
| 209 |
|
|
| 210 |
|
|
| 211 |
end |
|
| 212 |
|
|
| 213 | 191 |
def autocomplete_for_project |
| 214 | 192 |
@publication = Publication.find(params[:id]) |
| 215 | 193 |
|
| ... | ... | |
| 225 | 203 |
@object_name = "publications[authorships_attributes][#{object_id}][search_results]"
|
| 226 | 204 |
|
| 227 | 205 |
# cc 20110909 -- revert to like instead of like_unique -- see #289 |
| 228 |
authorships_list = Authorship.like(params[:term]).find(:all, :limit => 100) |
|
| 206 |
authorships_list = Authorship.like(params[:term]).group('author_id').find(:all, :limit => 100)
|
|
| 207 |
|
|
| 208 |
authors_list = authorships_list.collect do |x| x.author end |
|
| 209 |
|
|
| 229 | 210 |
users_list = User.active.like(params[:term]).find(:all, :limit => 100) |
| 230 | 211 |
|
| 231 |
logger.debug "Query for \"#{params[:term]}\" returned \"#{authorships_list.size}\" authorships and \"#{users_list.size}\" users"
|
|
| 212 |
logger.debug "Query for \"#{params[:term]}\" returned \"#{authors_list.size}\" authors and \"#{users_list.size}\" users"
|
|
| 232 | 213 |
|
| 233 |
@results = users_list |
|
| 214 |
# will check if any of the members of the users list |
|
| 215 |
# doesn't belong to the authors list |
|
| 234 | 216 |
|
| 235 |
# TODO: can be optimized… |
|
| 236 |
authorships_list.each do |authorship| |
|
| 237 |
flag = true |
|
| 217 |
@results = authors_list |
|
| 238 | 218 |
|
| 239 |
users_list.each do |user| |
|
| 240 |
if authorship.name == user.name && authorship.email == user.mail && authorship.institution == user.institution |
|
| 241 |
Rails.logger.debug { "Rejecting Authorship #{authorship.id}" }
|
|
| 242 |
flag = false |
|
| 243 |
break |
|
| 244 |
end |
|
| 245 |
end |
|
| 246 |
|
|
| 247 |
@results << authorship if flag |
|
| 219 |
users_list.each do |user| |
|
| 220 |
@results << user unless authors_list.include?(user.author) |
|
| 248 | 221 |
end |
| 249 | 222 |
|
| 223 |
logger.debug { "Autocomplete_for_author results --> #{@results}" }
|
|
| 224 |
|
|
| 250 | 225 |
render :layout => false |
| 251 | 226 |
end |
| 252 | 227 |
|
| 253 |
def get_user_info |
|
| 254 |
object_id = params[:object_id] |
|
| 255 |
value = params[:value] |
|
| 256 |
classname = Kernel.const_get(value.split('_')[0])
|
|
| 257 |
|
|
| 258 |
item = classname.find(value.split('_')[1])
|
|
| 259 |
|
|
| 260 |
name_field = "publication_authorships_attributes_#{object_id}_name_on_paper".to_sym
|
|
| 261 |
email_field = "publication_authorships_attributes_#{object_id}_email".to_sym
|
|
| 262 |
institution_field = "publication_authorships_attributes_#{object_id}_institution".to_sym
|
|
| 263 |
|
|
| 264 |
yes_radio = "publication_authorships_attributes_#{object_id}_identify_author_yes".to_sym
|
|
| 265 |
|
|
| 266 |
respond_to do |format| |
|
| 267 |
format.js {
|
|
| 268 |
render(:update) {|page|
|
|
| 269 |
page[name_field].value = item.name |
|
| 270 |
page[email_field].value = item.mail |
|
| 271 |
page[institution_field].value = item.institution |
|
| 272 |
|
|
| 273 |
page[yes_radio].checked = true |
|
| 274 |
page[name_field].readOnly = true |
|
| 275 |
page[email_field].readOnly = true |
|
| 276 |
page[institution_field].readOnly = true |
|
| 277 |
} |
|
| 278 |
} |
|
| 279 |
end |
|
| 280 |
end |
|
| 281 |
|
|
| 282 | 228 |
def sort_author_order |
| 283 | 229 |
params[:authorships].each_with_index do |id, index| |
| 284 | 230 |
Authorship.update_all(['auth_order=?', index+1], ['id=?', id]) |
| ... | ... | |
| 303 | 249 |
end |
| 304 | 250 |
end |
| 305 | 251 |
|
| 306 |
|
|
| 307 | 252 |
def remove_project |
| 308 | 253 |
@project = Project.find(params[:project_id]) |
| 309 | 254 |
proj = Project.find(params[:remove_project_id]) |
| ... | ... | |
| 324 | 269 |
end |
| 325 | 270 |
|
| 326 | 271 |
def destroy |
| 327 |
find_project_by_project_id |
|
| 272 |
find_project_by_project_id unless params[:project_id].nil? |
|
| 273 |
@publication = Publication.find(params[:id]) |
|
| 328 | 274 |
|
| 329 | 275 |
@publication.destroy |
| 330 | 276 |
|
| plugins/redmine_bibliography/app/helpers/publications_helper.rb | ||
|---|---|---|
| 21 | 21 |
s.html_safe |
| 22 | 22 |
end |
| 23 | 23 |
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 | 24 |
def link_to_remove_fields(name, f) |
| 28 | 25 |
f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)", :class => 'icon icon-del') |
| 29 | 26 |
end |
| ... | ... | |
| 31 | 28 |
def link_to_add_author_fields(name, f, association, action) |
| 32 | 29 |
new_object = f.object.class.reflect_on_association(association).klass.new |
| 33 | 30 |
fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
|
| 31 |
# renders _authorship_fields.html.erb |
|
| 34 | 32 |
render(association.to_s.singularize + "_fields", :f => builder) |
| 35 | 33 |
end |
| 34 |
|
|
| 36 | 35 |
link_to_function(name, "add_author_fields(this, '#{association}', '#{escape_javascript(fields)}', '#{action}')", { :class => 'icon icon-add', :id => "add_another_author" })
|
| 37 | 36 |
end |
| 38 | 37 |
|
| ... | ... | |
| 59 | 58 |
str.to_sym |
| 60 | 59 |
end |
| 61 | 60 |
|
| 62 |
####### |
|
| 63 |
### DELETE ME |
|
| 64 |
|
|
| 65 |
def choose_author_link(object_name, items) |
|
| 66 |
# called by autocomplete_for_author (publications' action/view) |
|
| 67 |
# creates the select list based on the results array |
|
| 68 |
# results is an array with both Users and Authorships objects |
|
| 69 |
|
|
| 70 |
@author_options = [] |
|
| 71 |
@results.each do |result| |
|
| 72 |
email_bit = result.mail.partition('@')[2]
|
|
| 73 |
if email_bit != "" |
|
| 74 |
email_bit = "(@#{email_bit})"
|
|
| 75 |
end |
|
| 76 |
@author_options << ["#{result.name} #{email_bit}", "#{result.class.to_s}_#{result.id.to_s}"]
|
|
| 77 |
end |
|
| 78 |
|
|
| 79 |
if @results.size > 0 |
|
| 80 |
s = select_tag( form_tag_name(object_name, :author_search_results), options_for_select(@author_options), { :id => form_tag_id(object_name, :author_search_results), :size => 3} )
|
|
| 81 |
else |
|
| 82 |
s = "<em>No Authors found that match your search… sorry!</em>" |
|
| 83 |
end |
|
| 84 |
end |
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 | 61 |
def render_authorships_list(publication) |
| 89 | 62 |
s = '<p>' |
| 90 | 63 |
|
| ... | ... | |
| 133 | 106 |
end |
| 134 | 107 |
end |
| 135 | 108 |
|
| 136 |
|
|
| 137 | 109 |
def show_bibtex_fields(bibtex_entry) |
| 138 | 110 |
s = "" |
| 139 | 111 |
bibtex_entry.attributes.keys.sort.each do |key| |
| ... | ... | |
| 152 | 124 |
end |
| 153 | 125 |
end |
| 154 | 126 |
|
| 127 |
|
|
| 128 |
def render_authorship_link(link_class, link_id) |
|
| 129 |
|
|
| 130 |
# Renders a link for an author used when adding authors for a publication |
|
| 131 |
# link_class can be either User or Author |
|
| 132 |
# link_id will be the id of the Author/User we wish to link |
|
| 133 |
|
|
| 134 |
s= "" |
|
| 135 |
|
|
| 136 |
if link_class == "Author" |
|
| 137 |
url = {:controller => 'authors', :action => 'show', :id => link_id}
|
|
| 138 |
s << link_to(h(Author.find(link_id).name), url) |
|
| 139 |
else |
|
| 140 |
url = {:controller => 'users', :action => 'show', :id => link_id}
|
|
| 141 |
s << link_to(h(User.find(link_id).name), url) |
|
| 142 |
end |
|
| 143 |
|
|
| 144 |
s.html_safe |
|
| 145 |
end |
|
| 146 |
|
|
| plugins/redmine_bibliography/app/models/author.rb | ||
|---|---|---|
| 18 | 18 |
} |
| 19 | 19 |
} |
| 20 | 20 |
|
| 21 |
def institution |
|
| 22 |
if self.authorships.first.nil? |
|
| 23 |
"" |
|
| 24 |
else |
|
| 25 |
self.authorships.first.institution |
|
| 26 |
end |
|
| 27 |
end |
|
| 28 |
|
|
| 29 |
def mail |
|
| 30 |
if self.authorships.first.nil? |
|
| 31 |
"" |
|
| 32 |
else |
|
| 33 |
self.authorships.first.mail |
|
| 34 |
end |
|
| 35 |
end |
|
| 36 |
|
|
| 37 |
# todo: need to fix the name getter |
|
| 38 |
def name |
|
| 39 |
if self.authorships.first.nil? |
|
| 40 |
"" |
|
| 41 |
else |
|
| 42 |
self.authorships.first.name |
|
| 43 |
end |
|
| 44 |
end |
|
| 45 |
|
|
| 21 | 46 |
end |
| plugins/redmine_bibliography/app/models/authorship.rb | ||
|---|---|---|
| 9 | 9 |
|
| 10 | 10 |
validates_presence_of :name_on_paper |
| 11 | 11 |
|
| 12 |
attr_accessor :search_author_class, :search_author_id, :search_name, :search_results, :identify_author |
|
| 12 |
attr_writer :search_author_id , :search_author_class |
|
| 13 |
attr_writer :search_author_tie |
|
| 13 | 14 |
|
| 14 |
before_create :associate_author_user |
|
| 15 |
### attr_accessor :search_results, :identify_author |
|
| 16 |
## attr_writer :search_author_class |
|
| 17 |
|
|
| 18 |
before_save :set_author |
|
| 15 | 19 |
before_update :delete_publication_cache |
| 16 | 20 |
|
| 17 | 21 |
# tod: review scope of ordering |
| ... | ... | |
| 34 | 38 |
} |
| 35 | 39 |
} |
| 36 | 40 |
|
| 41 |
def search_author_class |
|
| 42 |
# Authorship must always have an Author |
|
| 43 |
# unless it hasn't been saved yet |
|
| 44 |
# using default setter (attr_writer) |
|
| 45 |
|
|
| 46 |
if self.author.nil? |
|
| 47 |
aclass = "" |
|
| 48 |
else |
|
| 49 |
aclass = "Author" |
|
| 50 |
end |
|
| 51 |
|
|
| 52 |
@search_author_class || aclass |
|
| 53 |
end |
|
| 54 |
|
|
| 55 |
def search_author_id |
|
| 56 |
if self.author.nil? |
|
| 57 |
authid = "" |
|
| 58 |
else |
|
| 59 |
authid = author_id |
|
| 60 |
end |
|
| 61 |
|
|
| 62 |
@search_author_id || authid |
|
| 63 |
end |
|
| 64 |
|
|
| 65 |
def search_author_tie |
|
| 66 |
if self.author.nil? |
|
| 67 |
auth_tie = false |
|
| 68 |
else |
|
| 69 |
auth_tie = true |
|
| 70 |
end |
|
| 71 |
|
|
| 72 |
@search_author_tie || auth_tie |
|
| 73 |
end |
|
| 74 |
|
|
| 37 | 75 |
def name |
| 38 | 76 |
return self.name_on_paper |
| 39 | 77 |
end |
| ... | ... | |
| 54 | 92 |
Rails.cache.delete "publication-#{publication.id}-bibtex"
|
| 55 | 93 |
end |
| 56 | 94 |
|
| 57 |
def associate_author_user |
|
| 58 |
case self.search_author_class |
|
| 59 |
when "" |
|
| 60 |
logger.debug { "Unknown Author to be added..." }
|
|
| 61 |
when "User" |
|
| 95 |
private |
|
| 96 |
|
|
| 97 |
def set_author |
|
| 98 |
# do we want to associate the authorship |
|
| 99 |
# with an existing author/user? |
|
| 100 |
if @search_author_tie |
|
| 101 |
# if an author, simply associates with it |
|
| 102 |
# if an user, checks if it has already an author associated with it |
|
| 103 |
# if so, associates with that author |
|
| 104 |
# otherwise, creates a new author |
|
| 105 |
|
|
| 106 |
case @search_author_class |
|
| 107 |
when "" |
|
| 108 |
author = Author.new |
|
| 109 |
author.save |
|
| 110 |
|
|
| 111 |
when "User" |
|
| 112 |
user = User.find(@search_author_id) |
|
| 113 |
|
|
| 114 |
if user.author.nil? |
|
| 115 |
# User w/o author: |
|
| 116 |
# create new author and update user |
|
| 117 |
author = Author.new |
|
| 118 |
author.save |
|
| 119 |
user.author = author |
|
| 120 |
user.save |
|
| 121 |
else |
|
| 122 |
author = user.author |
|
| 123 |
end |
|
| 124 |
|
|
| 125 |
when "Author" |
|
| 126 |
author = Author.find(@search_author_id) |
|
| 127 |
end |
|
| 128 |
|
|
| 129 |
# if we don't want to associate with an existing author/user |
|
| 130 |
else |
|
| 131 |
# todo: should we delete any previously existing relationship? |
|
| 62 | 132 |
author = Author.new |
| 63 | 133 |
author.save |
| 64 |
self.author_id = author.id
|
|
| 134 |
end
|
|
| 65 | 135 |
|
| 66 |
when "Author" |
|
| 67 |
selected = self.search_results |
|
| 68 |
selected_classname = Kernel.const_get(self.search_author_class) |
|
| 69 |
selected_id = self.search_author_id |
|
| 70 |
object = selected_classname.find(selected_id) |
|
| 71 |
|
|
| 72 |
if object.respond_to? :name_on_paper |
|
| 73 |
# Authorship |
|
| 74 |
self.author_id = object.author.id |
|
| 75 |
else |
|
| 76 |
# User |
|
| 77 |
unless object.author.nil? |
|
| 78 |
self.author_id = object.author.id |
|
| 79 |
else |
|
| 80 |
author = Author.new |
|
| 81 |
object.author = author |
|
| 82 |
object.save |
|
| 83 |
self.author_id = object.author.id |
|
| 84 |
end |
|
| 85 |
end |
|
| 86 |
end |
|
| 136 |
self.author = author |
|
| 87 | 137 |
end |
| 88 | 138 |
end |
| plugins/redmine_bibliography/app/models/bibtex_entry_type.rb | ||
|---|---|---|
| 1 | 1 |
class BibtexEntryType < ActiveRecord::Base |
| 2 | 2 |
unloadable |
| 3 | 3 |
|
| 4 |
@@fields = Hash['article', ['journal', 'year', 'volume', 'number', 'pages', 'month', 'note' ],
|
|
| 4 |
@@fields = Hash['article', ['journal', 'year', 'volume', 'number', 'pages', 'month', 'note' ], |
|
| 5 | 5 |
'book' , [ 'editor', 'publisher', 'volume', 'series', 'address', 'edition', 'month', 'year', 'note' ], |
| 6 | 6 |
'booklet' , [ 'howpublished', 'address', 'year', 'month', 'note', 'key' ], |
| 7 | 7 |
'conference', [ 'booktitle', 'year', 'editor', 'pages', 'organization', 'publisher', 'address', 'month', 'note' ], |
| ... | ... | |
| 25 | 25 |
end |
| 26 | 26 |
|
| 27 | 27 |
def self.fields (type) |
| 28 |
@@fields[ self.find(type).name ]
|
|
| 28 |
@@fields[ self.find(type).name ] |
|
| 29 | 29 |
end |
| 30 | 30 |
end |
| plugins/redmine_bibliography/app/models/publication.rb | ||
|---|---|---|
| 53 | 53 |
def notify_authors_publication_added(project) |
| 54 | 54 |
self.authors.each do |author| |
| 55 | 55 |
Rails.logger.debug { "Sending mail to \"#{self.title}\" publication authors." }
|
| 56 |
Mailer.deliver_publication_added(author.user, self, project) unless author.user.nil?
|
|
| 56 |
Mailer.publication_added(author.user, self, project).deliver unless author.user.nil?
|
|
| 57 | 57 |
end |
| 58 | 58 |
end |
| 59 | 59 |
|
| 60 | 60 |
def notify_authors_publication_updated(project) |
| 61 | 61 |
self.authors.each do |author| |
| 62 | 62 |
Rails.logger.debug { "Sending mail to \"#{self.title}\" publication authors." }
|
| 63 |
Mailer.deliver_publication_updated(author.user, self, project) unless author.user.nil?
|
|
| 63 |
Mailer.publication_updated(author.user, self, project).deliver unless author.user.nil?
|
|
| 64 | 64 |
end |
| 65 | 65 |
end |
| 66 | 66 |
|
| plugins/redmine_bibliography/app/views/activities/index.html.erb | ||
|---|---|---|
| 6 | 6 |
l(:label_institution_activity, h(@institution_name)) |
| 7 | 7 |
end |
| 8 | 8 |
else |
| 9 |
l(:label_user_activity, link_to_user(@author)) |
|
| 9 |
l(:label_user_activity, link_to_user(@author)).html_safe
|
|
| 10 | 10 |
end |
| 11 | 11 |
%></h2> |
| 12 | 12 |
<p class="subtitle"><%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %></p> |
| plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb | ||
|---|---|---|
| 1 |
<%- content_for :header_tags do -%> |
|
| 2 |
<%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' -%> |
|
| 3 |
<%= javascript_include_tag 'bibliography', :plugin => 'redmine_bibliography' -%> |
|
| 4 |
<%= javascript_tag "$('.author_save_btn').live('click', disable_fields);" -%>
|
|
| 5 |
<%= javascript_tag "$('.author_edit_btn').live('click', enable_fields);" -%>
|
|
| 6 |
<%- end -%> |
|
| 1 |
<div id="authors" class="fields"> |
|
| 2 |
<div class="author_edit" id="<%= form_tag_id( f.object_name, :edit_author_info ) %>"> |
|
| 7 | 3 |
|
| 8 |
<div id="authors" class="fields"> |
|
| 9 |
<div id="<%= form_tag_id( f.object_name, :search_author ) %>" style=<%= "display:none;" unless params[:action] == "new" %> > |
|
| 10 |
<p> |
|
| 11 |
<%= f.text_field :search_name, :size => 25, :class => "author_search" %> |
|
| 4 |
<p><%= f.label :name_on_paper %><%= f.text_field :name_on_paper, :class => "author_name_on_paper" -%></p> |
|
| 5 |
<p><%= f.label :institution %><%= f.text_field :institution -%></p> |
|
| 6 |
<p><%= f.label :email %><%= f.text_field :email -%></p> |
|
| 7 |
|
|
| 8 |
<p class="author_associated search_author_tie"> |
|
| 9 |
<%= f.check_box :search_author_tie, :label => '' -%> |
|
| 10 |
<span>Not associated with any SoundSoftware site user.</span> |
|
| 12 | 11 |
</p> |
| 13 | 12 |
|
| 14 |
<p style="margin-bottom: -2.5em; padding-bottom; 0"><label><%= l(:identify_author_question) %></label></p> |
|
| 15 |
|
|
| 16 |
<p class="author_identify"> |
|
| 17 |
<label class='inline'><%= radio_button_tag(:identify_author, "yes", false, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_yes )) %> <%= l(:identify_author_yes) %> </label><br /> |
|
| 18 |
|
|
| 19 |
<label class='inline'><%= radio_button_tag(:identify_author, "correct", false, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_corrections )) %> <%= l(:identify_author_correct) %> </label><br /> |
|
| 20 |
|
|
| 21 |
<label class='inline'><%= radio_button_tag(:identify_author, "no", true, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_no )) %> <%= l(:identify_author_no) %> </label><br /> |
|
| 22 |
</p> |
|
| 23 |
</div> |
|
| 24 |
|
|
| 25 |
<div class='author_edit' id="<%= form_tag_id( f.object_name, :edit_author_info ) %>"> |
|
| 26 |
<p><%= f.text_field :name_on_paper, {:class => ("readonly" unless params[:action] == "new") } %></p>
|
|
| 27 |
<p class='description' style=<%= "display:none;" unless params[:action] == "new" %>><%= h l("text_author_name_on_paper") %></p>
|
|
| 28 |
|
|
| 29 |
<p><%= f.text_field :institution, {:class => ("readonly" unless params[:action] == "new") } %></p>
|
|
| 30 |
<p class='description' style=<%= "display:none;" unless params[:action] == "new" %>><%= h l("text_author_institution") %></p>
|
|
| 31 |
<p><%= f.text_field :email, {:class => ("readonly" unless params[:action] == "new") } %></p>
|
|
| 32 |
<p class='description' style=<%= "display:none;" unless params[:action] == "new" %>><%= h l("text_author_email") %></p>
|
|
| 33 |
|
|
| 34 |
<%= hidden_field_tag(:search_author_class, '', :name => form_tag_name(f.object_name,:search_author_class ), :id => form_tag_id( f.object_name, :search_author_class )) -%> |
|
| 35 |
|
|
| 36 |
<%= hidden_field_tag(:search_author_id, '', :name => form_tag_name(f.object_name,:search_author_id ), :id => form_tag_id( f.object_name, :search_author_id )) -%> |
|
| 13 |
<%= f.hidden_field :search_author_class -%> |
|
| 14 |
<%= f.hidden_field :search_author_id -%> |
|
| 37 | 15 |
</div> |
| 38 | 16 |
|
| 39 | 17 |
<div> |
| 40 | 18 |
<p> |
| 41 | 19 |
<%= button_to_function l(:label_save_author), '', :id => form_tag_id(f.object_name, :edit_save_button), :class => 'author_save_btn' -%> |
| 42 | 20 |
|
| 43 |
<%= button_to_function l(:label_edit_author), '', :id => form_tag_id(f.object_name, :edit_button), :class => 'author_edit_btn' -%> |
|
| 21 |
<%= button_to_function l(:label_edit_author), '', :id => form_tag_id(f.object_name, :edit_button), :class => 'author_edit_btn', :style => "display:none;" -%>
|
|
| 44 | 22 |
|
| 45 | 23 |
<%= link_to_remove_fields l("remove_author"), f %>
|
| 46 | 24 |
</p> |
| 47 | 25 |
</div> |
| 48 |
</div> |
|
| 49 |
|
|
| 26 |
</div> |
|
| plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb | ||
|---|---|---|
| 1 | 1 |
<p> |
| 2 |
<label for="bibtex_entry_type"><%=l("field_entry_type")%> <span class="required">*</span></label>
|
|
| 2 |
<label for="publication_bibtex_entry_attributes_entry_type"><%=l("field_entry_type")%> <span class="required">*</span></label>
|
|
| 3 | 3 |
<%= f.collection_select :entry_type, |
| 4 | 4 |
BibtexEntryType.find(:all).reject { |x| x.redundant? },
|
| 5 | 5 |
:id, |
| ... | ... | |
| 8 | 8 |
</p> |
| 9 | 9 |
|
| 10 | 10 |
<p class="bibtex hol"> |
| 11 |
<%= f.text_field :year, :size => 4 %>
|
|
| 11 |
<%= f.label :year %><%= f.text_field :year, :size => 5 -%>
|
|
| 12 | 12 |
</p> |
| 13 | 13 |
<p class="bibtex hol"> |
| 14 |
<%= f.text_field :month, :size => 4%>
|
|
| 14 |
<%= f.label :month %><%= f.text_field :month, :size => 5 -%>
|
|
| 15 | 15 |
</p> |
| 16 | 16 |
<p class="bibtex hol"> |
| 17 |
<%= f.text_field :chapter, :size => 15%>
|
|
| 17 |
<%= f.label :chapter %><%= f.text_field :chapter, :size => 5 -%>
|
|
| 18 | 18 |
</p> |
| 19 | 19 |
<p class="bibtex hol"> |
| 20 |
<%= f.text_field :editor, :size => 33 %>
|
|
| 20 |
<%= f.label :editor %><%= f.text_field :editor -%>
|
|
| 21 | 21 |
</p> |
| 22 | 22 |
<p class="bibtex hol"> |
| 23 |
<%= f.text_field :booktitle, :size => 33 %>
|
|
| 23 |
<%= f.label :booktitle %><%= f.text_field :booktitle -%>
|
|
| 24 | 24 |
</p> |
| 25 | 25 |
<p class="bibtex hol"> |
| 26 |
<%= f.text_field :publisher,:size => 33 %>
|
|
| 26 |
<%= f.label :publisher %><%= f.text_field :publisher -%>
|
|
| 27 | 27 |
</p> |
| 28 | 28 |
<p class="bibtex hol"> |
| 29 |
<%= f.text_field :pages, :size => 12 %>
|
|
| 29 |
<%= f.label :pages %><%= f.text_field :pages, :size => 5 -%>
|
|
| 30 | 30 |
</p> |
| 31 | 31 |
<p class="bibtex hol"> |
| 32 |
<%= f.text_field :address %>
|
|
| 32 |
<%= f.label :address %><%= f.text_field :address -%>
|
|
| 33 | 33 |
</p> |
| 34 | 34 |
<p class="bibtex hol"> |
| 35 |
<%= f.text_field :annote %>
|
|
| 35 |
<%= f.label :annote %><%= f.text_field :annote -%>
|
|
| 36 | 36 |
</p> |
| 37 | 37 |
<p class="bibtex hol"> |
| 38 |
<%= f.text_field :crossref %>
|
|
| 38 |
<%= f.label :crossref %><%= f.text_field :crossref -%>
|
|
| 39 | 39 |
</p> |
| 40 | 40 |
<p class="bibtex hol"> |
| 41 |
<%= f.text_field :edition %>
|
|
| 41 |
<%= f.label :edition %><%= f.text_field :edition -%>
|
|
| 42 | 42 |
</p> |
| 43 | 43 |
<p class="bibtex hol"> |
| 44 |
<%= f.text_field :eprint %>
|
|
| 44 |
<%= f.label :eprint %><%= f.text_field :eprint -%>
|
|
| 45 | 45 |
</p> |
| 46 | 46 |
<p class="bibtex hol"> |
| 47 |
<%= f.text_field :howpublished %>
|
|
| 47 |
<%= f.label :howpublished %><%= f.text_field :howpublished -%>
|
|
| 48 | 48 |
</p> |
| 49 | 49 |
<p class="bibtex hol"> |
| 50 |
<%= f.text_field :journal %>
|
|
| 50 |
<%= f.label :journal %><%= f.text_field :journal -%>
|
|
| 51 | 51 |
</p> |
| 52 | 52 |
<p class="bibtex hol"> |
| 53 |
<%= f.text_field :key %>
|
|
| 53 |
<%= f.label :key %><%= f.text_field :key -%>
|
|
| 54 | 54 |
</p> |
| 55 | 55 |
<p class="bibtex hol"> |
| 56 |
<%= f.text_field :note %>
|
|
| 56 |
<%= f.label :note %><%= f.text_field :note -%>
|
|
| 57 | 57 |
</p> |
| 58 | 58 |
<p class="bibtex hol"> |
| 59 |
<%= f.text_field :number %>
|
|
| 59 |
<%= f.label :number %><%= f.text_field :number, :size => 5 -%>
|
|
| 60 | 60 |
</p> |
| 61 | 61 |
<p class="bibtex hol"> |
| 62 |
<%= f.text_field :organization %> |
|
| 62 |
<%= f.label :organization %><%= f.text_field :organization %>
|
|
| 63 | 63 |
</p> |
| 64 | 64 |
<p class="bibtex hol"> |
| 65 |
<%= f.text_field :school %> |
|
| 65 |
<%= f.label :school %><%= f.text_field :school %>
|
|
| 66 | 66 |
</p> |
| 67 | 67 |
<p class="bibtex hol"> |
| 68 |
<%= f.text_field :series %> |
|
| 68 |
<%= f.label :series %><%= f.text_field :series %>
|
|
| 69 | 69 |
</p> |
| 70 | 70 |
<p class="bibtex hol"> |
| 71 |
<%= f.text_field :type %> |
|
| 71 |
<%= f.label :type %><%= f.text_field :type %>
|
|
| 72 | 72 |
</p> |
| 73 | 73 |
<p class="bibtex hol"> |
| 74 |
<%= f.text_field :url %> |
|
| 74 |
<%= f.label :url %><%= f.text_field :url %>
|
|
| 75 | 75 |
</p> |
| 76 | 76 |
<p class="bibtex hol"> |
| 77 |
<%= f.text_field :volume %> |
|
| 77 |
<%= f.label :volume %><%= f.text_field :volume %>
|
|
| 78 | 78 |
</p> |
| plugins/redmine_bibliography/app/views/publications/_form.html.erb | ||
|---|---|---|
| 1 |
<%= error_messages_for 'publication' %> |
|
| 2 |
<%= javascript_tag " |
|
| 3 |
$('#publication_bibtex_entry_attributes_entry_type').live('change', function() {
|
|
| 4 |
$this = $(this); |
|
| 5 |
$.ajax({
|
|
| 6 |
type: 'get', |
|
| 7 |
url: '#{url_for(:controller => :publications, :action => :show_bibtex_fields)}',
|
|
| 8 |
data: {
|
|
| 9 |
value: $this.val() |
|
| 10 |
}, |
|
| 11 |
dataType: 'script' |
|
| 12 |
}); |
|
| 13 |
return false; |
|
| 14 |
});" |
|
| 15 |
-%> |
|
| 16 |
|
|
| 17 |
<h3><%= f.text_field :title, :required => true, :size => 70 %></h3> |
|
| 1 |
<h3><%= f.label :title %> <span class="required">*</span> <%= f.text_field :title, :required => true, :size => 70 %></h3> |
|
| 18 | 2 |
|
| 19 | 3 |
<div class="splitcontentleft"> |
| 20 | 4 |
<h3><%= l(:label_publication_other_details) %></h3> |
| ... | ... | |
| 24 | 8 |
<%- end -%> |
| 25 | 9 |
|
| 26 | 10 |
<p> |
| 27 |
<%= f.text_field :external_url, :size => 70 %>
|
|
| 11 |
<%= f.label :external_url %><%= f.text_field :external_url -%>
|
|
| 28 | 12 |
<br /> |
| 29 |
<em><%= l(:text_external_url) %></em> |
|
| 13 |
<em><%= l(:text_external_url) -%></em>
|
|
| 30 | 14 |
</p> |
| 31 | 15 |
<p> |
| 32 |
<%= f.text_field :doi, :size => 70 %>
|
|
| 16 |
<%= f.label :doi %><%= f.text_field :doi -%>
|
|
| 33 | 17 |
<br /> |
| 34 | 18 |
<em><%= l(:text_doi) %></em> |
| 35 | 19 |
</p> |
| plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.html.erb | ||
|---|---|---|
| 1 |
<%= raw @results.map {|result| {
|
|
| 2 |
'label' => "#{result.name} <em>#{result.mail.partition('@')[2]}</em>",
|
|
| 1 |
<%= raw @results.map { |result|
|
|
| 2 |
{
|
|
| 3 |
'label' => result.name, |
|
| 3 | 4 |
'value' => result.name, |
| 4 | 5 |
'search_author_class' => result.class.name, |
| 5 | 6 |
'search_author_id' => result.id, |
| 6 | 7 |
'name' => result.name, |
| 7 | 8 |
'institution' => result.institution, |
| 8 | 9 |
'email' => result.mail, |
| 10 |
'authorship_link' => " Keep associated with #{render_authorship_link(result.class.name, result.id)}"
|
|
| 9 | 11 |
} |
| 10 | 12 |
}.to_json %> |
| plugins/redmine_bibliography/app/views/publications/edit.html.erb | ||
|---|---|---|
| 1 | 1 |
<% content_for :header_tags do %> |
| 2 |
<%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %> |
|
| 3 |
<%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %> |
|
| 4 |
<%= javascript_tag "$(document).ready(function() { $('#publication_bibtex_entry_attributes_entry_type').trigger('change'); });" %>
|
|
| 2 |
<%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' -%> |
|
| 3 |
<%= javascript_include_tag 'bibliography', :plugin => 'redmine_bibliography' -%> |
|
| 4 |
<%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' -%> |
|
| 5 |
|
|
| 6 |
<%= javascript_include_tag 'edit_publication', :plugin => 'redmine_bibliography' -%> |
|
| 7 |
|
|
| 8 |
<%= javascript_tag "$('#publication_bibtex_entry_attributes_entry_type').live('change', function() {
|
|
| 9 |
$this = $(this); |
|
| 10 |
$.ajax({
|
|
| 11 |
type: 'get', |
|
| 12 |
url: '#{url_for(:controller => :publications, :action => :show_bibtex_fields)}',
|
|
| 13 |
data: {
|
|
| 14 |
value: $this.val() |
|
| 15 |
}, |
|
| 16 |
dataType: 'script' |
|
| 17 |
}); return false; });" -%> |
|
| 18 |
|
|
| 19 |
<%= javascript_tag "authorship_autocomplete('#{url_for :controller => :publications, :action => :autocomplete_for_author}');" -%>
|
|
| 20 |
|
|
| 5 | 21 |
<% end %> |
| 6 | 22 |
|
| 23 |
<%= error_messages_for 'publication' %> |
|
| 24 |
|
|
| 7 | 25 |
<h2><%=l(:label_publication_show)%></h2> |
| 8 | 26 |
|
| 9 |
<%= labelled_form_for @publication, :url => { :project_id => @project, :action => :update } do |f| -%>
|
|
| 10 |
<%= render :partial => 'form', :locals => { :f => f } %>
|
|
| 27 |
<%= form_for @publication, :url => { :project_id => @project, :action => :update } do |f| -%>
|
|
| 11 | 28 |
|
| 12 |
<div style="clear:both"></div> |
|
| 13 |
<%= f.submit %> |
|
| 29 |
<%= render :partial => 'form', :locals => { :f => f } %>
|
|
| 30 |
|
|
| 31 |
<div style="clear:both"></div> |
|
| 32 |
<%= f.submit %> |
|
| 14 | 33 |
<% end %> |
| 34 |
|
|
| 15 | 35 |
<p> |
| 16 |
<%= link_to l(:label_publication_show), { :controller => "publications", :action => "show", :id => @publication, :project_id => @project_id } %> |
|
|
| 17 |
<%= link_to l(:label_publication_index), { :controller => "publications", :action => "index", :project_id => @project } %>
|
|
| 36 |
<%= link_to l(:label_publication_show), { :controller => "publications", :action => "show", :id => @publication, :project_id => @project_id } %> |
|
|
| 37 |
<%= link_to l(:label_publication_index), { :controller => "publications", :action => "index", :project_id => @project } %>
|
|
| 18 | 38 |
</p> |
| 19 | 39 |
|
| plugins/redmine_bibliography/app/views/publications/new.html.erb | ||
|---|---|---|
| 1 | 1 |
<% content_for :header_tags do %> |
| 2 | 2 |
<%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %> |
| 3 | 3 |
<%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %> |
| 4 |
<%= javascript_include_tag 'bibliography', :plugin => 'redmine_bibliography' -%> |
|
| 5 |
<%= javascript_include_tag 'new_publication', :plugin => 'redmine_bibliography' -%> |
|
| 6 |
|
|
| 7 |
<%= javascript_tag " |
|
| 8 |
$('#publication_bibtex_entry_attributes_entry_type').live('change', function() {
|
|
| 9 |
$this = $(this); |
|
| 10 |
$.ajax({
|
|
| 11 |
type: 'get', |
|
| 12 |
url: '#{url_for(:controller => :publications, :action => :show_bibtex_fields)}',
|
|
| 13 |
data: {
|
|
| 14 |
value: $this.val() |
|
| 15 |
}, |
|
| 16 |
dataType: 'script' |
|
| 17 |
}); |
|
| 18 |
return false; |
|
| 19 |
});"-%> |
|
| 20 |
|
|
| 21 |
<%= javascript_tag "authorship_autocomplete('#{url_for :controller => :publications, :action => :autocomplete_for_author}');" -%>
|
|
| 22 |
|
|
| 4 | 23 |
<% end %> |
| 5 | 24 |
|
| 25 |
<%= error_messages_for 'publication' %> |
|
| 26 |
|
|
| 6 | 27 |
<h2><%=l(:label_publication_new)%></h2> |
| 7 | 28 |
|
| 8 |
<%= labelled_form_for @publication, :url => { :project_id => @project, :action => :create } do |f| -%>
|
|
| 29 |
<%= form_for @publication, :url => { :project_id => @project, :action => :create } do |f| -%>
|
|
| 30 |
|
|
| 9 | 31 |
<%= render :partial => 'form', :locals => { :f => f } %>
|
| 32 |
|
|
| 10 | 33 |
<div style="clear:both"></div> |
| 11 | 34 |
<%= f.submit %> |
| 12 | 35 |
<% end %> |
| plugins/redmine_bibliography/assets/javascripts/authors.js | ||
|---|---|---|
| 3 | 3 |
var regexp = new RegExp("new_" + association, "g");
|
| 4 | 4 |
|
| 5 | 5 |
$(link).before(content.replace(regexp, new_id)); |
| 6 |
|
|
| 7 |
if(action != "new"){
|
|
| 8 |
toggle_save_author(new_id, $(link)); |
|
| 9 |
} |
|
| 10 | 6 |
} |
| 11 | 7 |
|
| 12 | 8 |
function remove_fields(link) {
|
| ... | ... | |
| 14 | 10 |
$(link).closest(".fields").hide();
|
| 15 | 11 |
} |
| 16 | 12 |
|
| 17 |
$(".author_search").live('keyup.autocomplete', function(){
|
|
| 18 |
$this = $(this); |
|
| 13 |
function authorship_autocomplete(url){
|
|
| 14 |
$(".author_name_on_paper").live('keyup.autocomplete', function(){
|
|
| 15 |
$this = $(this); |
|
| 19 | 16 |
|
| 20 |
$this.autocomplete({
|
|
| 21 |
source: '/publications/autocomplete_for_author', |
|
| 22 |
minLength: 2, |
|
| 23 |
focus: function(event, ui) {
|
|
| 24 |
$this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.name);
|
|
| 25 |
$this.closest('div').next().find("input[id$='institution']").val(ui.item.institution);
|
|
| 26 |
$this.closest('div').next().find("input[id$='email']").val(ui.item.email);
|
|
| 27 |
$this.closest('div').next().find("input[id$='search_author_class']").val(ui.item.search_author_class);
|
|
| 28 |
$this.closest('div').next().find("input[id$='search_author_id']").val(ui.item.search_author_id);
|
|
| 17 |
$this.autocomplete({
|
|
| 18 |
source: url, |
|
| 19 |
minLength: 2, |
|
| 20 |
focus: function(event, ui) {
|
|
| 21 |
$this.val(ui.item.label); |
|
| 22 |
return false; |
|
| 23 |
}, |
|
| 24 |
select: function(event, ui){
|
|
| 25 |
$this.closest('div').find("input[id$='institution']").val(ui.item.institution);
|
|
| 26 |
$this.closest('div').find("input[id$='email']").val(ui.item.email);
|
|
| 29 | 27 |
|
| 30 |
return false; |
|
| 31 |
}, |
|
| 32 |
select: function(event, ui){
|
|
| 33 |
$this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.name);
|
|
| 34 |
$this.closest('div').next().find("input[id$='institution']").val(ui.item.institution);
|
|
| 35 |
$this.closest('div').next().find("input[id$='email']").val(ui.item.email);
|
|
| 36 |
$this.closest('div').next().find("input[id$='search_author_class']").val(ui.item.search_author_class);
|
|
| 37 |
$this.closest('div').next().find("input[id$='search_author_id']").val(ui.item.search_author_id);
|
|
| 38 |
} |
|
| 39 |
}) |
|
| 40 |
.data( "autocomplete" )._renderItem = function( ul, item ) {
|
|
| 41 |
return $( "<li></li>" ) |
|
| 42 |
.data( "item.autocomplete", item ) |
|
| 43 |
.append( "<a>" + item.label + "</a>" ) |
|
| 44 |
.appendTo( ul ); |
|
| 45 |
}; |
|
| 46 |
}); |
|
| 28 |
$this.closest('div').find("input[id$='search_author_class']").val(ui.item. search_author_class);
|
|
| 29 |
$this.closest('div').find("input[id$='search_author_id']").val(ui.item. search_author_id);
|
|
| 47 | 30 |
|
| 31 |
$this.closest('div').find("input[id$='search_author_tie']").attr('checked', ' checked');
|
|
| 32 |
$this.closest('div').find("input[id$='search_author_tie']").next('span').replaceWith("<span>" + ui.item.authorship_link + "</span>");
|
|
| 48 | 33 |
|
| 49 |
$("input[id$='identify_author_yes']").live("click", function() {
|
|
| 50 |
console.log("aaaa");
|
|
| 51 |
}); |
|
| 52 |
|
|
| 53 |
$("input[id$='identify_author_no']").live("click", function() {
|
|
| 54 |
$this.closest('div').next().find("input[id$='name_on_paper']").val('');
|
|
| 55 |
$this.closest('div').next().find("input[id$='institution']").val('');
|
|
| 56 |
$this.closest('div').next().find("input[id$='email']").val('');
|
|
| 57 |
$this.closest('div').next().find("input[id$='search_author_class']").val('');
|
|
| 58 |
}); |
|
| 59 |
|
|
| 60 |
function toggle_div(div_id){
|
|
| 61 |
$("#" + div_id).toggle(0.3);
|
|
| 34 |
// triggers the save button |
|
| 35 |
$this.closest('div').next('div').find('.author_save_btn').click();
|
|
| 36 |
} |
|
| 37 |
}) |
|
| 38 |
.data( "autocomplete" )._renderItem = function( ul, item ) {
|
|
| 39 |
return $( "<li>" ) |
|
| 40 |
.data("item.autocomplete", item )
|
|
| 41 |
.append( "<a>" + item.label + "<br><em>" + item.email + "</em><br>" + item. institution + "</a>" ) |
|
| 42 |
.appendTo(ul); |
|
| 43 |
}; |
|
| 44 |
}); |
|
| 62 | 45 |
} |
| 63 |
|
|
| 64 |
function toggle_save_author(form_object_id, $this){
|
|
| 65 |
$('publication_authorships_attributes_' + form_object_id + '_edit_author_info').select('input').each(function(s) {
|
|
| 66 |
toggle_input_field(s, $this); |
|
| 67 |
}); |
|
| 68 |
$('publication_authorships_attributes_' + form_object_id + '_edit_author_info').select('p.description').each(function(s) {
|
|
| 69 |
s.toggle(); |
|
| 70 |
}); |
|
| 71 |
toggle_edit_save_button(form_object_id); |
|
| 72 |
toggle_div("publication_authorships_attributes_" + form_object_id +"_search_author");
|
|
| 73 |
} |
|
| plugins/redmine_bibliography/assets/javascripts/bibliography.js | ||
|---|---|---|
| 2 | 2 |
|
| 3 | 3 |
function disable_fields(){
|
| 4 | 4 |
$this = $(this); |
| 5 |
|
|
| 5 | 6 |
$author_info = $this.closest('div').prev();
|
| 6 |
$author_info.children('.description').toggle();
|
|
| 7 |
// $author_info.children('.description').toggle();
|
|
| 7 | 8 |
$author_info.find('p :input').attr("readonly", true);
|
| 8 | 9 |
$author_info.find('p :input').addClass('readonly');
|
| 9 | 10 |
|
| 11 |
// Always hides on save |
|
| 12 |
$this.closest('div').prev().find('p.search_author_tie').hide();
|
|
| 13 |
|
|
| 10 | 14 |
$this.siblings('.author_edit_btn').show();
|
| 11 | 15 |
$this.hide(); |
| 12 | 16 |
|
| ... | ... | |
| 15 | 19 |
|
| 16 | 20 |
function enable_fields(){
|
| 17 | 21 |
$this = $(this); |
| 22 |
|
|
| 18 | 23 |
$author_info = $this.closest('div').prev();
|
| 19 |
$author_info.children('.description').toggle();
|
|
| 24 |
// $author_info.children('.description').toggle();
|
|
| 20 | 25 |
$author_info.find('p :input').attr("readonly", false);
|
| 21 | 26 |
$author_info.find('p :input').removeClass('readonly');
|
| 22 | 27 |
|
| 28 |
// Always shows on edit |
|
| 29 |
$this.closest('div').prev().find('p.search_author_tie').show();
|
|
| 30 |
|
|
| 23 | 31 |
$this.siblings('.author_save_btn').show();
|
| 24 | 32 |
$this.hide(); |
| 25 | 33 |
|
| 26 | 34 |
return false; |
| 27 | 35 |
} |
| 36 |
|
|
| plugins/redmine_bibliography/assets/javascripts/edit_publication.js | ||
|---|---|---|
| 1 |
// edit_publication.js |
|
| 2 |
|
|
| 3 |
$(document).ready(function(){
|
|
| 4 |
// shows the correct bibtex fields |
|
| 5 |
$('#publication_bibtex_entry_attributes_entry_type').trigger('change');
|
|
| 6 |
|
|
| 7 |
// adds the events to the edit/save authorship button |
|
| 8 |
$('.author_save_btn').live('click', disable_fields);
|
|
| 9 |
$('.author_edit_btn').live('click', enable_fields);
|
|
| 10 |
|
|
| 11 |
// clicks all authorships |
|
| 12 |
$('.author_save_btn').trigger('click');
|
|
| 13 |
}); |
|
| plugins/redmine_bibliography/assets/javascripts/new_publication.js | ||
|---|---|---|
| 1 |
// edit_publication.js |
|
| 2 |
|
|
| 3 |
$(document).ready(function(){
|
|
| 4 |
// adds the events to the edit/save authorship button |
|
| 5 |
$('.author_save_btn').live('click', disable_fields);
|
|
| 6 |
$('.author_edit_btn').live('click', enable_fields);
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
}); |
|
| plugins/redmine_bibliography/assets/stylesheets/bibliography.css | ||
|---|---|---|
| 20 | 20 |
} |
| 21 | 21 |
|
| 22 | 22 |
.tabular .author_edit .description {
|
| 23 |
padding-top: 0; |
|
| 24 | 23 |
font-style: italic; |
| 24 |
font-size: small; |
|
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 | 27 |
.publication_project {
|
| 28 | 28 |
margin-right: 18px; |
| 29 | 29 |
} |
| 30 | 30 |
|
| 31 |
#authors select {
|
|
| 32 |
min-width: 150px; |
|
| 33 |
} |
|
| 34 |
|
|
| 35 |
|
|
| 36 | 31 |
div#bibliography dd { margin-bottom: 1em; font-size: 0.9em; }
|
| 37 | 32 |
|
| 38 | 33 |
div#bibliography dd .authors { font-style: italic; }
|
| ... | ... | |
| 71 | 66 |
background-image: url(../../../images/loading.gif); |
| 72 | 67 |
} |
| 73 | 68 |
|
| 74 |
.author_edit_btn {
|
|
| 75 |
display:none; |
|
| 69 |
.search_author_tie {
|
|
| 70 |
display: none; |
|
| 71 |
float: left; |
|
| 76 | 72 |
} |
| 77 | 73 |
|
| 74 |
.author_edit_btn {
|
|
| 75 |
display: none; |
|
| 76 |
} |
|
| plugins/redmine_bibliography/lib/bibliography/mailer_patch.rb | ||
|---|---|---|
| 4 | 4 |
module MailerPatch |
| 5 | 5 |
def self.included(base) # :nodoc: |
| 6 | 6 |
|
| 7 |
# Builds a tmail object used to email the specified user that a publication was created and the user is
|
|
| 7 |
# Builds a tmail object used to email the specified user that a publication was created and the user is |
|
| 8 | 8 |
# an author of that publication |
| 9 | 9 |
# |
| 10 | 10 |
# Example: |
| ... | ... | |
| 16 | 16 |
@project = project |
| 17 | 17 |
|
| 18 | 18 |
set_language_if_valid user.language |
| 19 |
recipients user.mail |
|
| 20 |
subject l(:mail_subject_publication_added, Setting.app_title) |
|
| 21 |
body :publication_url => url_for( :controller => 'publications', :action => 'show', :id => publication.id ), |
|
| 22 |
:publication_title => publication.title |
|
| 23 | 19 |
|
| 24 |
render_multipart('publication_added', body)
|
|
| 20 |
mail :to => user.mail, |
|
| 21 |
:subject => l(:mail_subject_register, Setting.app_title) |
|
| 25 | 22 |
|
| 23 |
@publication_url = url_for( :controller => 'publications', :action => 'show', :id => publication.id ) |
|
| 24 |
@publication_title = publication.title |
|
| 26 | 25 |
end |
| 27 |
|
|
| 28 |
|
|
| 26 |
|
|
| 27 |
|
|
| 29 | 28 |
end |
| 30 | 29 |
end |
| 31 | 30 |
end |
| plugins/redmine_bibliography/test/fixtures/authors.yml | ||
|---|---|---|
| 1 |
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html |
|
| 1 |
# authors.yml |
|
| 2 |
--- |
|
| 2 | 3 |
one: |
| 3 | 4 |
id: 1 |
| 4 |
user_id: |
|
| 5 |
name: MyString
|
|
| 5 |
user_id: 1
|
|
| 6 |
name: |
|
| 6 | 7 |
two: |
| 7 | 8 |
id: 2 |
| 8 |
user_id:
|
|
| 9 |
name: MyString
|
|
| 10 |
one:
|
|
| 9 |
user_id: |
|
| 10 |
name: |
|
| 11 |
three:
|
|
| 11 | 12 |
id: 3 |
| 12 |
user_id:
|
|
| 13 |
name: MyString
|
|
| 14 |
two:
|
|
| 13 |
user_id: |
|
| 14 |
name: |
|
| 15 |
four:
|
|
| 15 | 16 |
id: 4 |
| 16 |
user_id: |
|
| 17 |
name: MyString |
|
| 17 |
user_id: |
|
| 18 |
name: |
|
| plugins/redmine_bibliography/test/fixtures/authorships.yml | ||
|---|---|---|
| 1 |
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html |
|
| 1 |
# authorships.yml |
|
| 2 |
--- |
|
| 2 | 3 |
one: |
| 3 | 4 |
id: 1 |
| 4 | 5 |
author_id: 1 |
| 5 | 6 |
publication_id: 1 |
| 6 | 7 |
name_on_paper: Yih-Farn R. Chen |
| 7 |
order: 1 |
|
| 8 |
institution: |
|
| 9 |
email: MyString
|
|
| 8 |
auth_order: 1
|
|
| 9 |
institution: Imperial College London
|
|
| 10 |
email: chen@imperial.ac.uk
|
|
| 10 | 11 |
two: |
| 11 | 12 |
id: 2 |
| 12 | 13 |
author_id: 2 |
| 13 | 14 |
publication_id: 1 |
| 14 | 15 |
name_on_paper: Glenn S. Fowler |
| 15 |
order: 2 |
|
| 16 |
institution:
|
|
| 16 |
auth_order: 2
|
|
| 17 |
institution: |
|
| 17 | 18 |
email: MyString |
| 18 | 19 |
three: |
| 19 | 20 |
id: 3 |
| 20 |
author_id: 1
|
|
| 21 |
author_id: 3
|
|
| 21 | 22 |
publication_id: 1 |
| 22 |
name_on_paper: Yih-Farn R. Chen
|
|
| 23 |
order: 1 |
|
| 24 |
institution:
|
|
| 25 |
email: MyString
|
|
| 23 |
name_on_paper: Jackie Brown
|
|
| 24 |
auth_order: 1
|
|
| 25 |
institution: |
|
| 26 |
email: j.brown@m.com
|
|
| 26 | 27 |
four: |
| 27 | 28 |
id: 4 |
| 28 |
author_id: 2
|
|
| 29 |
author_id: 4
|
|
| 29 | 30 |
publication_id: 1 |
| 30 |
name_on_paper: Glenn S. Fowler |
|
| 31 |
order: 2 |
|
| 32 |
institution: |
|
| 33 |
email: MyString |
|
| 31 |
name_on_paper: Captain Boomtime |
|
| 32 |
auth_order: 2 |
|
| 33 |
institution: |
|
| 34 |
email: cpt.boom@time.co.uk |
|
| 35 |
five: |
|
| 36 |
id: 5 |
|
| 37 |
author_id: 1 |
|
| 38 |
publication_id: 2 |
|
| 39 |
name_on_paper: Yih-Farn Chen |
|
| 40 |
auth_order: 1 |
|
| 41 |
institution: "Imperial College, London" |
|
| 42 |
email: yfc@gmail.com |
|
| plugins/redmine_bibliography/test/fixtures/bibtex_entries.yml | ||
|---|---|---|
| 1 |
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html |
|
| 1 |
# bibtex_entries.yml |
|
| 2 |
--- |
|
| 2 | 3 |
one: |
| 3 | 4 |
id: 1 |
| 4 | 5 |
entry_type: InProceedings |
| plugins/redmine_bibliography/test/fixtures/publications.yml | ||
|---|---|---|
| 1 | 1 |
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html |
| 2 | 2 |
one: |
| 3 |
id: 1 |
|
| 4 |
title: Test Fixture Title No1 |
|
| 5 |
bibtex_entry_id: 1 |
|
| 3 |
id: 1 |
|
| 4 |
title: Publication Number 1 |
|
| 5 |
reviewed: true |
|
| 6 |
external_url: |
|
| 7 |
doi: |
|
| 6 | 8 |
two: |
| 7 |
id: 2 |
|
| 8 |
title: MyString |
|
| 9 |
bibtex_entry_id: MyString |
|
| 9 |
id: 2 |
|
| 10 |
title: Publication Number 2 |
|
| 11 |
reviewed: false |
|
| 12 |
external_url: |
|
| 13 |
doi: |
|
| plugins/redmine_bibliography/test/fixtures/users.yml | ||
|---|---|---|
| 1 |
# users.yml |
|
| 2 |
--- |
|
| 3 |
users_004: |
|
| 4 |
created_on: 2006-07-19 19:34:07 +02:00 |
|
| 5 |
status: 1 |
|
| 6 |
last_login_on: |
|
| 7 |
language: en |
|
| 8 |
# password = foo |
|
| 9 |
salt: 3126f764c3c5ac61cbfc103f25f934cf |
|
| 10 |
hashed_password: 9e4dd7eeb172c12a0691a6d9d3a269f7e9fe671b |
|
| 11 |
updated_on: 2006-07-19 19:34:07 +02:00 |
|
| 12 |
admin: false |
|
| 13 |
mail: rhill@somenet.foo |
|
| 14 |
lastname: Hill |
|
| 15 |
firstname: Robert |
|
| 16 |
id: 4 |
|
| 17 |
auth_source_id: |
|
| 18 |
mail_notification: all |
|
| 19 |
login: rhill |
|
| 20 |
type: User |
|
| 21 |
users_001: |
|
| 22 |
created_on: 2006-07-19 19:12:21 +02:00 |
|
| 23 |
status: 1 |
|
| 24 |
last_login_on: 2006-07-19 22:57:52 +02:00 |
|
| 25 |
language: en |
|
| 26 |
# password = admin |
|
| 27 |
salt: 82090c953c4a0000a7db253b0691a6b4 |
|
| 28 |
hashed_password: b5b6ff9543bf1387374cdfa27a54c96d236a7150 |
|
| 29 |
updated_on: 2006-07-19 22:57:52 +02:00 |
|
| 30 |
admin: true |
|
| 31 |
mail: admin@somenet.foo |
|
| 32 |
lastname: Admin |
|
| 33 |
firstname: redMine |
|
| 34 |
id: 1 |
|
| 35 |
auth_source_id: |
|
| 36 |
mail_notification: all |
|
| 37 |
login: admin |
|
| 38 |
type: User |
|
| 39 |
users_002: |
|
| 40 |
created_on: 2006-07-19 19:32:09 +02:00 |
|
| 41 |
status: 1 |
|
| 42 |
last_login_on: 2006-07-19 22:42:15 +02:00 |
|
| 43 |
language: en |
|
| 44 |
# password = jsmith |
|
| 45 |
salt: 67eb4732624d5a7753dcea7ce0bb7d7d |
|
| 46 |
hashed_password: bfbe06043353a677d0215b26a5800d128d5413bc |
|
| 47 |
updated_on: 2006-07-19 22:42:15 +02:00 |
|
| 48 |
admin: false |
|
| 49 |
mail: jsmith@somenet.foo |
|
| 50 |
lastname: Smith |
|
| 51 |
firstname: John |
|
| 52 |
id: 2 |
|
| 53 |
auth_source_id: |
|
| 54 |
mail_notification: all |
|
| 55 |
login: jsmith |
|
| 56 |
type: User |
|
| 57 |
users_003: |
|
| 58 |
created_on: 2006-07-19 19:33:19 +02:00 |
|
| 59 |
status: 1 |
|
| 60 |
last_login_on: |
|
| 61 |
language: en |
|
| 62 |
# password = foo |
|
| 63 |
salt: 7599f9963ec07b5a3b55b354407120c0 |
|
| 64 |
hashed_password: 8f659c8d7c072f189374edacfa90d6abbc26d8ed |
|
| 65 |
updated_on: 2006-07-19 19:33:19 +02:00 |
|
| 66 |
admin: false |
|
| 67 |
mail: dlopper@somenet.foo |
|
| 68 |
lastname: Lopper |
|
| 69 |
firstname: Dave |
|
| 70 |
id: 3 |
|
| 71 |
auth_source_id: |
|
| 72 |
mail_notification: all |
|
| 73 |
login: dlopper |
|
| 74 |
type: User |
|
| 75 |
users_005: |
|
| 76 |
id: 5 |
|
| 77 |
created_on: 2006-07-19 19:33:19 +02:00 |
|
| 78 |
# Locked |
|
| 79 |
status: 3 |
|
| 80 |
last_login_on: |
|
| 81 |
language: en |
|
| 82 |
hashed_password: 1 |
|
| 83 |
updated_on: 2006-07-19 19:33:19 +02:00 |
|
| 84 |
admin: false |
|
| 85 |
mail: dlopper2@somenet.foo |
|
| 86 |
lastname: Lopper2 |
|
| 87 |
firstname: Dave2 |
|
| 88 |
auth_source_id: |
|
| 89 |
mail_notification: all |
|
| 90 |
login: dlopper2 |
|
| 91 |
type: User |
|
| 92 |
users_006: |
|
| 93 |
id: 6 |
|
| 94 |
created_on: 2006-07-19 19:33:19 +02:00 |
|
| 95 |
status: 0 |
|
| 96 |
last_login_on: |
|
| 97 |
language: '' |
|
| 98 |
hashed_password: 1 |
|
| 99 |
updated_on: 2006-07-19 19:33:19 +02:00 |
|
| 100 |
admin: false |
|
| 101 |
mail: '' |
|
| 102 |
lastname: Anonymous |
|
| 103 |
firstname: '' |
|
| 104 |
auth_source_id: |
|
| 105 |
mail_notification: only_my_events |
|
| 106 |
login: '' |
|
| 107 |
type: AnonymousUser |
|
| 108 |
users_007: |
|
| 109 |
id: 7 |
|
| 110 |
created_on: 2006-07-19 19:33:19 +02:00 |
|
| 111 |
status: 1 |
|
| 112 |
last_login_on: |
|
| 113 |
language: '' |
|
| 114 |
hashed_password: 1 |
|
| 115 |
updated_on: 2006-07-19 19:33:19 +02:00 |
|
| 116 |
admin: false |
|
| 117 |
mail: someone@foo.bar |
|
| 118 |
lastname: One |
|
| 119 |
firstname: Some |
|
| 120 |
auth_source_id: |
|
| 121 |
mail_notification: only_my_events |
|
| 122 |
login: someone |
|
| 123 |
type: User |
|
| 124 |
users_008: |
|
| 125 |
id: 8 |
|
| 126 |
created_on: 2006-07-19 19:33:19 +02:00 |
|
| 127 |
status: 1 |
|
| 128 |
last_login_on: |
|
| 129 |
language: 'it' |
|
| 130 |
# password = foo |
|
| 131 |
salt: 7599f9963ec07b5a3b55b354407120c0 |
|
| 132 |
hashed_password: 8f659c8d7c072f189374edacfa90d6abbc26d8ed |
|
| 133 |
updated_on: 2006-07-19 19:33:19 +02:00 |
|
| 134 |
admin: false |
|
| 135 |
mail: miscuser8@foo.bar |
|
| 136 |
lastname: Misc |
|
| 137 |
firstname: User |
|
| 138 |
auth_source_id: |
|
| 139 |
mail_notification: only_my_events |
|
| 140 |
login: miscuser8 |
|
| 141 |
type: User |
|
| 142 |
users_009: |
|
| 143 |
id: 9 |
|
| 144 |
created_on: 2006-07-19 19:33:19 +02:00 |
|
| 145 |
status: 1 |
|
| 146 |
last_login_on: |
|
| 147 |
language: 'it' |
|
| 148 |
hashed_password: 1 |
|
| 149 |
updated_on: 2006-07-19 19:33:19 +02:00 |
|
| 150 |
admin: false |
|
| 151 |
mail: miscuser9@foo.bar |
|
| 152 |
lastname: Misc |
|
| 153 |
firstname: User |
|
| 154 |
auth_source_id: |
|
| 155 |
mail_notification: only_my_events |
|
| 156 |
login: miscuser9 |
|
| 157 |
type: User |
|
| 158 |
groups_010: |
|
| 159 |
id: 10 |
|
| 160 |
lastname: A Team |
|
| 161 |
type: Group |
|
| 162 |
groups_011: |
|
| 163 |
id: 11 |
|
| 164 |
lastname: B Team |
|
| 165 |
type: Group |
|
| 166 |
|
|
| 167 |
|
|
| plugins/redmine_bibliography/test/functional/authors_controller_test.rb | ||
|---|---|---|
| 1 |
require File.dirname(__FILE__) + '/../test_helper' |
|
| 1 |
# authors_controller_test.rb |
|
| 2 |
|
|
| 3 |
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') |
|
| 2 | 4 |
|
| 3 | 5 |
class AuthorsControllerTest < ActionController::TestCase |
| 4 |
# Replace this with your real tests. |
|
| 6 |
self.fixture_path = File.dirname(__FILE__) + "/../fixtures/" |
|
| 7 |
fixtures :users, :authors, :authorships |
|
| 8 |
|
|
| 5 | 9 |
def test_truth |
| 6 | 10 |
assert true |
| 7 | 11 |
end |
| 12 |
|
|
| 8 | 13 |
end |
| plugins/redmine_bibliography/test/test_helper.rb | ||
|---|---|---|
| 1 |
ENV['RAILS_ENV'] ||= 'test' |
|
| 2 |
|
|
| 1 | 3 |
# Load the normal Rails helper |
| 2 |
require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper') |
|
| 3 |
require 'publications_controller' |
|
| 4 |
|
|
| 5 |
# Ensure that we are using the temporary fixture path |
|
| 6 |
Engines::Testing.set_fixture_path |
|
| 4 |
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper') |
|
| 5 |
require File.expand_path(File.dirname(__FILE__) + '/../app/controllers/publications_controller') |
|
| 7 | 6 |
|
| 8 | 7 |
class BibliographyControllerTest < ActionController::TestCase |
| 9 |
fixtures :all |
|
| 8 |
self.fixture_path = File.dirname(__FILE__) + "/fixtures/" |
|
| 9 |
|
|
| 10 |
fixtures :authors |
|
| 10 | 11 |
|
| 11 | 12 |
def setup |
| 13 |
|
|
| 12 | 14 |
end |
| 13 | 15 |
|
| 14 |
def test_publication
|
|
| 15 |
|
|
| 16 |
def test_truth
|
|
| 17 |
assert true |
|
| 16 | 18 |
end |
| 17 |
|
|
| 18 | 19 |
|
| 19 |
def test_routing |
|
| 20 |
assert_routing( |
|
| 21 |
{:method => :get, :path => '/requirements'},
|
|
| 22 |
:controller => 'requirements', :action => 'index' |
|
| 23 |
) |
|
| 24 |
end |
|
| 20 |
# def test_routing |
|
| 21 |
# assert_routing( |
|
| 22 |
# {:method => :get, :path => '/requirements'},
|
|
| 23 |
# :controller => 'requirements', :action => 'index' |
|
| 24 |
# ) |
|
| 25 |
# end |
|
| 26 |
|
|
| 27 |
end |
|
| plugins/redmine_bibliography/test/unit/author_test.rb | ||
|---|---|---|
| 1 |
require File.dirname(__FILE__) + '/../test_helper' |
|
| 1 |
# author_test.rb |
|
| 2 |
|
|
| 3 |
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') |
|
| 2 | 4 |
|
| 3 | 5 |
class AuthorTest < ActiveSupport::TestCase |
| 4 |
fixtures :authors |
|
| 6 |
self.fixture_path = File.dirname(__FILE__) + "/../fixtures/" |
|
| 7 |
fixtures :users, :authors, :authorships |
|
| 5 | 8 |
|
| 6 |
# Replace this with your real tests. |
|
| 7 |
def test_truth |
|
| 8 |
assert true |
|
| 9 |
end |
|
| 9 |
def test_relationships |
|
| 10 |
author = Author.find(1) |
|
| 11 |
|
|
| 12 |
assert_equal(author.authorships.first.name_on_paper, "Yih-Farn R. Chen") |
|
| 13 |
assert_equal(author.authorships.count, 2) |
|
| 14 |
|
|
| 15 |
end |
|
| 16 |
|
|
| 10 | 17 |
end |
| plugins/redmine_bibliography/test/unit/authorship_test.rb | ||
|---|---|---|
| 5 | 5 |
|
| 6 | 6 |
# Replace this with your real tests. |
| 7 | 7 |
def test_truth |
| 8 |
luis = Author.first |
|
| 9 |
|
|
| 10 |
|
|
| 8 | 11 |
assert true |
| 9 | 12 |
end |
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 10 | 16 |
end |
| plugins/redmine_bibliography/test/unit/publication_test.rb | ||
|---|---|---|
| 1 |
require File.dirname(__FILE__) + '/../test_helper' |
|
| 1 |
# publication_test |
|
| 2 |
|
|
| 3 |
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') |
|
| 2 | 4 |
|
| 3 | 5 |
class PublicationTest < ActiveSupport::TestCase |
| 4 |
fixtures :publications
|
|
| 6 |
self.fixture_path = File.dirname(__FILE__) + "/../fixtures/"
|
|
| 5 | 7 |
|
| 6 |
# Replace this with your real tests. |
|
| 7 |
def test_truth |
|
| 8 |
assert true |
|
| 9 |
end |
|
| 8 |
fixtures :publications, :authorships |
|
| 9 |
|
|
| 10 |
# Replace this with your real tests. |
|
| 11 |
def test_truth |
|
| 12 |
assert true |
|
| 13 |
end |
|
| 14 |
|
|
| 15 |
def test_relationships |
|
| 16 |
# test authorships - publication relationship |
|
| 17 |
publication = Publication.find(1) |
|
| 18 |
|
|
| 19 |
assert 4, publication.authorships.count |
|
| 20 |
end |
|
| 21 |
|
|
| 22 |
def test_new_publication_validations |
|
| 23 |
pub = Publication.create |
|
| 24 |
|
|
| 25 |
assert !pub.valid?, "!pub.valid?" |
|
| 26 |
assert_equal 2, pub.errors.count, "Number of errors" |
|
| 27 |
assert_equal ["can't be blank"], pub.errors[:title] |
|
| 28 |
assert_equal ["Please add at least one author to this publication."], pub.errors[:authorships] |
|
| 29 |
end |
|
| 30 |
|
|
| 10 | 31 |
end |
Also available in: Unified diff