To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / plugins / redmine_bibliography @ 1580:fa3d9c22497c

1 1133:03049d5227e3 luis
gem 'bibtex-ruby'
2
gem 'nokogiri'
3 1579:aba122ac2d40 Chris
gem 'citeproc'
4
gem 'citeproc-ruby'
5
gem 'csl-styles'
6 298:a41158bde9e0 luis
= bibliography
7
8
Description goes here
9 328:aed18b463206 luis
class AuthorsController < ApplicationController
10 616:156bd1153f47 luis
  helper :publications
11
  include PublicationsHelper
12 328:aed18b463206 luis
13
  def index
14
    @authors = Author.find(:all)
15 406:40144aa9dfe7 luis
  end
16 328:aed18b463206 luis
17 612:8fa35731c959 luis
  def show
18 616:156bd1153f47 luis
    @author = Author.find(params[:id])
19 612:8fa35731c959 luis
  end
20
21 328:aed18b463206 luis
end
22
class AuthorshipsController < ApplicationController
23
24 1364:4d5d25039a5f luis
    def sort
25
        @authorships = Authorship.find(params['authorship'])
26
27
        @authorships.each do |authorship|
28
29
            # note: auth_order is usually called position (default column name in the acts_as_list plugin )
30
            authorship.auth_order = params['authorship'].index(authorship.id.to_s) + 1
31
            authorship.save
32
        end
33
34
        render :nothing => true, :status => 200
35
    end
36 328:aed18b463206 luis
end
37 405:8a105a53b8f4 luis
class BibtexEntriesController < ApplicationController
38
39
end
40 613:3b63cea01e7b luisf
# -*- coding: utf-8 -*-
41 385:a6f8c0584a92 luis
# vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb
42
43 328:aed18b463206 luis
class PublicationsController < ApplicationController
44 425:4ecbc22579e2 luis
  unloadable
45 946:a0c9cc95bcf3 luis
46 560:735388da579a luis
  model_object Publication
47 1317:2805873c0147 luis
  before_filter :find_model_object, :only => [ :show, :add_project ]
48 631:324678bbbe77 luis
  before_filter :find_project_by_project_id, :authorize, :only => [ :edit, :new, :update, :create ]
49 946:a0c9cc95bcf3 luis
50 404:216a61338322 luis
  def new
51 539:d4bf55b01092 luis
    find_project_by_project_id
52
    @publication = Publication.new
53 946:a0c9cc95bcf3 luis
54 445:77f88379115a luis
    # we'll always want a new publication to have its bibtex entry
55 539:d4bf55b01092 luis
    @publication.build_bibtex_entry
56 946:a0c9cc95bcf3 luis
57 519:3be6bc3c2a17 luis
  end
58 409:50474139cad4 luis
59 1071:fe32745aaa3d luis
  def create
60 613:3b63cea01e7b luisf
    @project = Project.find(params[:project_id])
61
62 390:5562a95edbf7 luis
    @publication = Publication.new(params[:publication])
63 553:e25c069ab3b8 luis
    @publication.projects << @project unless @project.nil?
64 946:a0c9cc95bcf3 luis
65 1071:fe32745aaa3d luis
    if @publication.save
66 666:865d079e5fa0 luis
      @publication.notify_authors_publication_added(@project)
67 946:a0c9cc95bcf3 luis
68 445:77f88379115a luis
      flash[:notice] = "Successfully created publication."
69 613:3b63cea01e7b luisf
      redirect_to :action => :show, :id => @publication, :project_id => @project
70 445:77f88379115a luis
    else
71 613:3b63cea01e7b luisf
      render :action => 'new', :project_id => @project
72 445:77f88379115a luis
    end
73
  end
74
75
  def index
76 538:e25248ba597c luis
    if !params[:project_id].nil?
77
      find_project_by_project_id
78
      @project = Project.find(params[:project_id])
79
      @publications = Publication.find :all, :joins => :projects, :conditions => ["project_id = ?", @project.id]
80
    else
81
      @publications = Publication.find :all
82
    end
83 445:77f88379115a luis
  end
84
85
  def new_from_bibfile
86 391:fecd4b2f4b77 luis
    @publication.current_step = session[:publication_step]
87 946:a0c9cc95bcf3 luis
88 404:216a61338322 luis
    # contents of the paste text area
89
    bibtex_entry = params[:bibtex_entry]
90 384:4be6b16bc6f9 luis
91 404:216a61338322 luis
    # method for creating "pasted" bibtex entries
92 424:b601a9e472f3 luis
    if bibtex_entry
93 1071:fe32745aaa3d luis
      parse_bibtex_list bibtex_entry
94 404:216a61338322 luis
    end
95 329:4575b631f6ce luis
  end
96
97 1274:5ea1a213c7a5 luis
  def show_bibtex_fields
98
    @fields = []
99 675:fccacd8505e3 luis
100 699:2b665b7e67f4 luis
    unless params[:value].empty?
101 1274:5ea1a213c7a5 luis
      @fields = BibtexEntryType.fields(params[:value])
102 699:2b665b7e67f4 luis
    end
103 675:fccacd8505e3 luis
104
    respond_to do |format|
105
      format.js {
106 1274:5ea1a213c7a5 luis
        render :show_bibtex_fields
107 675:fccacd8505e3 luis
      }
108
    end
109
  end
110
111 467:c1ecc16cf38e luis
  def add_author
112
    if (request.xhr?)
113
      render :text => User.find(params[:user_id]).name
114
    else
115
      # No?  Then render an action.
116
      #render :action => 'view_attribute', :attr => @name
117 675:fccacd8505e3 luis
      logger.error { "Error while adding Author to publication." }
118 467:c1ecc16cf38e luis
    end
119
  end
120
121 1071:fe32745aaa3d luis
  def edit
122 547:56ad0c490f5e luis
    find_project_by_project_id unless params[:project_id].nil?
123 946:a0c9cc95bcf3 luis
124 428:9cfd7a1d848e luis
    @publication = Publication.find(params[:id])
125 626:e2663e0bd5a6 luis
    @selected_bibtex_entry_type_id = @publication.bibtex_entry.entry_type
126 1071:fe32745aaa3d luis
    @bibtype_fields = BibtexEntryType.fields(@selected_bibtex_entry_type_id)
127 430:948400933de8 luis
  end
128
129 1071:fe32745aaa3d luis
  def update
130
    @publication = Publication.find(params[:id])
131 626:e2663e0bd5a6 luis
132 430:948400933de8 luis
    if @publication.update_attributes(params[:publication])
133
      flash[:notice] = "Successfully updated Publication."
134 538:e25248ba597c luis
135 1071:fe32745aaa3d luis
      # expires the previosly cached entries
136
      Rails.cache.delete "publication-#{@publication.id}-ieee"
137
      Rails.cache.delete "publication-#{@publication.id}-bibtex"
138
139 538:e25248ba597c luis
      if !params[:project_id].nil?
140
        redirect_to :action => :show, :id => @publication, :project_id => params[:project_id]
141
      else
142
        redirect_to :action => :show, :id => @publication
143
      end
144 430:948400933de8 luis
    else
145 448:0a5d997578da luis
      render :action => 'edit'
146 1071:fe32745aaa3d luis
    end
147 328:aed18b463206 luis
  end
148
149 946:a0c9cc95bcf3 luis
150 425:4ecbc22579e2 luis
  def show
151 535:dd9d9c0ff0f9 luis
    find_project_by_project_id unless params[:project_id].nil?
152 946:a0c9cc95bcf3 luis
153 425:4ecbc22579e2 luis
    if @publication.nil?
154 579:2ada25d4b0a8 luis
      @publications = Publication.all
155
      render "index", :alert => 'The publication was not found!'
156 425:4ecbc22579e2 luis
    else
157
      @authors = @publication.authors
158
      @bibtext_entry = @publication.bibtex_entry
159
    end
160 329:4575b631f6ce luis
  end
161
162 406:40144aa9dfe7 luis
  # parse string with bibtex authors
163
  def parse_authors(authors_entry)
164
    # in bibtex the authors are always seperated by "and"
165 407:96910efbd45e luis
    return authors_entry.split(" and ")
166 406:40144aa9dfe7 luis
  end
167
168 1071:fe32745aaa3d luis
  # parses a list of bibtex
169 406:40144aa9dfe7 luis
  def parse_bibtex_list(bibtex_list)
170
    bibliography = BibTeX.parse bibtex_list
171
172
    no_entries = bibliography.data.length
173
174
    # parses the bibtex entries
175
    bibliography.data.map do |d|
176 407:96910efbd45e luis
177
      if d.class == BibTeX::Entry
178
        create_bibtex_entry d
179
      end
180 406:40144aa9dfe7 luis
    end
181 1071:fe32745aaa3d luis
  end
182 407:96910efbd45e luis
183 1071:fe32745aaa3d luis
  def create_bibtex_entry(d)
184 407:96910efbd45e luis
    @publication = Publication.new
185 1071:fe32745aaa3d luis
    @bentry = BibtexEntry.new
186 407:96910efbd45e luis
    authors = []
187
    institution = ""
188
    email = ""
189 409:50474139cad4 luis
190 407:96910efbd45e luis
    d.fields.keys.map do |field|
191
      case field.to_s
192
      when "author"
193
        authors = parse_authors d[field]
194
      when "title"
195
        @publication.title = d[field]
196
      when "institution"
197
        institution = d[field]
198
      when "email"
199
        email = d[field]
200
      else
201
        @bentry[field] = d[field]
202
      end
203 1071:fe32745aaa3d luis
    end
204 406:40144aa9dfe7 luis
205
    @publication.bibtex_entry = @bentry
206 407:96910efbd45e luis
    @publication.save
207 409:50474139cad4 luis
208 407:96910efbd45e luis
    # need to save all authors
209 1071:fe32745aaa3d luis
    #   and establish the author-publication association
210
    #   via the authorships table
211 407:96910efbd45e luis
    authors.each_with_index.map do |authorname, idx|
212
      author = Author.new(:name => authorname)
213
      if author.save!
214 946:a0c9cc95bcf3 luis
        # todo: catch the errors...
215 407:96910efbd45e luis
        puts "SAVED"
216
      else
217
        puts "NOT SAVED"
218 406:40144aa9dfe7 luis
      end
219
220 407:96910efbd45e luis
      author.authorships.create!(
221 946:a0c9cc95bcf3 luis
      :publication => @publication,
222
      :institution => institution,
223
      :email => email,
224
      :order => idx)
225 407:96910efbd45e luis
    end
226
  end
227 409:50474139cad4 luis
228 461:841b2e40895d luis
  def autocomplete_for_project
229
    @publication = Publication.find(params[:id])
230 946:a0c9cc95bcf3 luis
231 1253:29dd06e01be3 luis
    @projects = Project.active.name_or_homepage_like(params[:q]).find(:all, :limit => 100) - @publication.projects
232 461:841b2e40895d luis
    logger.debug "Query for \"#{params[:q]}\" returned \"#{@projects.size}\" results"
233
    render :layout => false
234 409:50474139cad4 luis
  end
235 471:49fb7a9ef79c luis
236 1071:fe32745aaa3d luis
  def autocomplete_for_author
237 519:3be6bc3c2a17 luis
    @results = []
238 946:a0c9cc95bcf3 luis
239 596:fcff84e1c1ce luis
    object_id = params[:object_id]
240 598:c6cfe1f2eac1 luis
    @object_name = "publications[authorships_attributes][#{object_id}][search_results]"
241 946:a0c9cc95bcf3 luis
242 1436:ee598c21c239 luis
    # todo: make sure query works with both pgres and mysql ~lf.20131010
243
    authors_list = Author.joins(:authorships).where("LOWER(authorships.name_on_paper) LIKE LOWER(?)", "%#{params[:term]}%").uniq
244 1411:6487f22bee9d luis
245 1441:8d721cac2925 luis
    # name_like scope, defined in lib/user_author patch
246
    users_list = User.active.name_like(params[:term]).find(:all, :limit => 100)
247 480:19efecf4561a luis
248 1411:6487f22bee9d luis
    logger.debug "Query for \"#{params[:term]}\" returned \"#{authors_list.size}\" authors and \"#{users_list.size}\" users"
249 946:a0c9cc95bcf3 luis
250 1411:6487f22bee9d luis
    # will check if any of the members of the users list
251
    #  doesn't belong to the authors list
252 601:1608b3cb50cd luis
253 1411:6487f22bee9d luis
    @results = authors_list
254 946:a0c9cc95bcf3 luis
255 1411:6487f22bee9d luis
    users_list.each do |user|
256
      @results << user unless authors_list.include?(user.author)
257 592:68c6b060385c luis
    end
258
259 1417:1df2db7f0e4d luis
    logger.debug { "Autocomplete_for_author results --> #{@results}" }
260
261 1071:fe32745aaa3d luis
    render :layout => false
262 598:c6cfe1f2eac1 luis
  end
263 946:a0c9cc95bcf3 luis
264 557:2fe129b04d82 luis
  def sort_author_order
265
    params[:authorships].each_with_index do |id, index|
266
      Authorship.update_all(['auth_order=?', index+1], ['id=?', id])
267 471:49fb7a9ef79c luis
    end
268
    render :nothing => true
269
  end
270 574:f463be9d101a luis
271
  def add_project
272 1071:fe32745aaa3d luis
    @projects = Project.find(params[:publication][:project_ids])
273 574:f463be9d101a luis
    @publication.projects << @projects
274 1071:fe32745aaa3d luis
    @project = Project.find(params[:project_id])
275 946:a0c9cc95bcf3 luis
276 1071:fe32745aaa3d luis
    # TODO luisf should also respond to HTML???
277 574:f463be9d101a luis
    respond_to do |format|
278
      format.html { redirect_to :back }
279 1071:fe32745aaa3d luis
      format.js {
280
        render(:update) {|page|
281
          page[:add_project_form].reset
282 574:f463be9d101a luis
          page.replace_html :list_projects, :partial => 'list_projects'
283
        }
284
      }
285
    end
286
  end
287 946:a0c9cc95bcf3 luis
288 574:f463be9d101a luis
  def remove_project
289 579:2ada25d4b0a8 luis
    @project = Project.find(params[:project_id])
290
    proj = Project.find(params[:remove_project_id])
291 554:026c9747fe9b luis
292 574:f463be9d101a luis
    if @publication.projects.length > 1
293 579:2ada25d4b0a8 luis
      if @publication.projects.exists? proj
294
        @publication.projects.delete proj if request.post?
295 554:026c9747fe9b luis
      end
296
    else
297 1071:fe32745aaa3d luis
      logger.error { "Cannot remove project from publication list" }
298 554:026c9747fe9b luis
    end
299 946:a0c9cc95bcf3 luis
300 591:9e866f13c984 luis
    logger.error { "CURRENT project name#{proj.name} and wanna delete #{@project.name}" }
301 946:a0c9cc95bcf3 luis
302 1071:fe32745aaa3d luis
    render(:update) {|page|
303 579:2ada25d4b0a8 luis
      page.replace_html "list_projects", :partial => 'list_projects', :id  => @publication
304 1071:fe32745aaa3d luis
    }
305 554:026c9747fe9b luis
  end
306 946:a0c9cc95bcf3 luis
307 560:735388da579a luis
  def destroy
308 1406:20235e6c60c0 luis
    find_project_by_project_id unless params[:project_id].nil?
309
    @publication = Publication.find(params[:id])
310 1405:43b303a229e1 luis
311 560:735388da579a luis
    @publication.destroy
312 946:a0c9cc95bcf3 luis
313 560:735388da579a luis
    flash[:notice] = "Successfully deleted Publication."
314
    redirect_to :controller => :publications, :action => 'index', :project_id => @project
315
  end
316 471:49fb7a9ef79c luis
317 538:e25248ba597c luis
  private
318 478:7097dc91e58e luis
319 328:aed18b463206 luis
end
320
module AuthorsHelper
321 540:951fcb1711f2 luis
  unloadable
322
323
  def render_author_publications(author)
324
    s = ""
325
    pubs = []
326
327
    author.publications.each do |pub|
328
     pubs << link_to(pub.title, pub)
329
    end
330
331
    if pubs.size < 3
332
      s << '<nobr>' << pubs.join(', ') << '</nobr>'
333
    else
334
      s << pubs.join(', ')
335
    end
336
    s
337
  end
338
339 612:8fa35731c959 luis
340
  # Generates a link to an author
341
  #   todo: test options
342
  def link_to_author(author, options={}, html_options = nil)
343
    url = {:controller => 'authors', :action => 'show', :id => author}.merge(options)
344
    link_to(h(author.name), url, html_options)
345
  end
346
347 328:aed18b463206 luis
end
348 1126:e65c02706f1c luis
# -*- coding: utf-8 -*-
349 328:aed18b463206 luis
module AuthorshipsHelper
350 702:3eb64cb3c7ac chris
351
  # Generates a link to either author or user, depending on which is
352
  # available
353
  def link_to_authorship(authorship)
354
    s = ''
355
    if authorship.author.nil?
356
      # legacy reasons…
357
      s << h(authorship.name_on_paper)
358
    else
359 1126:e65c02706f1c luis
      if authorship.author.user.nil?
360 702:3eb64cb3c7ac chris
        s << link_to(authorship.name_on_paper, :controller => 'authors', :action => 'show', :id => authorship.author)
361
      else
362
        s << link_to(authorship.name_on_paper, :controller => 'users', :action => 'show', :id => authorship.author.user)
363
      end
364
    end
365 1325:4ef7df804bab luis
    s.html_safe
366 702:3eb64cb3c7ac chris
  end
367
368 328:aed18b463206 luis
end
369 1317:2805873c0147 luis
370
371 405:8a105a53b8f4 luis
module BibtexEntriesHelper
372
373
end
374 615:c4ddb9531f4c chris
# -*- coding: utf-8 -*-
375 407:96910efbd45e luis
require 'bibtex'
376
377 328:aed18b463206 luis
module PublicationsHelper
378 702:3eb64cb3c7ac chris
  include AuthorshipsHelper
379 616:156bd1153f47 luis
380
  def link_to_publication(publication, options={}, html_options = nil)
381
    url = {:controller => 'publications', :action => 'show', :id => publication}.merge(options)
382
    link_to(h(publication.title), url, html_options)
383
  end
384
385 462:b02b2eb2a312 luis
  def projects_check_box_tags(name, projects)
386
    s = ''
387
    projects.sort.each do |project|
388 1068:e11d8d13ebc5 luis
      if User.current.allowed_to?(:edit_publication, project)
389 713:ebca856bd627 luis
        s << "<label>#{ check_box_tag name, project.id, false } #{link_to_project project}</label>\n"
390
        s << '<br />'
391
      end
392 462:b02b2eb2a312 luis
    end
393 712:a1e0728d1e02 luis
394 1324:2e54ae6ab02f luis
    s.html_safe
395 462:b02b2eb2a312 luis
  end
396 1068:e11d8d13ebc5 luis
397 469:ae87ae455cfb luis
  def link_to_remove_fields(name, f)
398 573:aed210f6095b chris
    f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)", :class => 'icon icon-del')
399 469:ae87ae455cfb luis
  end
400 1068:e11d8d13ebc5 luis
401 705:b6f9f005c0b6 luis
  def link_to_add_author_fields(name, f, association, action)
402 468:0bb9c7baed07 luis
    new_object = f.object.class.reflect_on_association(association).klass.new
403
    fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
404 1388:cfa9122bb584 luis
      # renders _authorship_fields.html.erb
405 468:0bb9c7baed07 luis
      render(association.to_s.singularize + "_fields", :f => builder)
406 1068:e11d8d13ebc5 luis
    end
407 1388:cfa9122bb584 luis
408 1278:f8bb7ccc6fac luis
    link_to_function(name, "add_author_fields(this, '#{association}', '#{escape_javascript(fields)}', '#{action}')", { :class => 'icon icon-add', :id => "add_another_author" })
409 1068:e11d8d13ebc5 luis
  end
410 481:dd242ea99fd3 luis
411
  def sanitized_object_name(object_name)
412
    object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/,"_").sub(/_$/,"")
413
  end
414
415
  def sanitized_method_name(method_name)
416
    method_name.sub(/\?$/, "")
417
  end
418 1068:e11d8d13ebc5 luis
419 595:84e8d34d024c luis
  def form_tag_name(object_name, method_name)
420
      str = "#{object_name.to_s}[#{sanitized_method_name(method_name.to_s)}]"
421 1068:e11d8d13ebc5 luis
      str.to_sym
422 595:84e8d34d024c luis
  end
423 1068:e11d8d13ebc5 luis
424
  def form_tag_id(object_name, method_name)
425 481:dd242ea99fd3 luis
    str = "#{sanitized_object_name(object_name.to_s)}_#{sanitized_method_name(method_name.to_s)}"
426
    str.to_sym
427
  end
428 1068:e11d8d13ebc5 luis
429 596:fcff84e1c1ce luis
  def form_object_id(object_name)
430
    str = object_name.split("\[").last().gsub("\]","")
431
    str.to_sym
432
  end
433 693:5163e3ec00b8 luis
434 1068:e11d8d13ebc5 luis
  def render_authorships_list(publication)
435 693:5163e3ec00b8 luis
    s = '<p>'
436 1068:e11d8d13ebc5 luis
437 693:5163e3ec00b8 luis
    publication.authorships.each do |authorship|
438 702:3eb64cb3c7ac chris
      s << link_to_authorship(authorship)
439 693:5163e3ec00b8 luis
      s << "<br /><em>#{authorship.institution}</em></p>"
440 1068:e11d8d13ebc5 luis
    end
441 693:5163e3ec00b8 luis
442 1307:06de38acb6b4 luis
    s.html_safe
443 693:5163e3ec00b8 luis
  end
444 1068:e11d8d13ebc5 luis
445
  def render_projects_list(publication, show_delete_icon)
446 691:f8d7e85ccd4e luis
    s= ""
447 1068:e11d8d13ebc5 luis
448 691:f8d7e85ccd4e luis
    publication.projects.visible.each do |proj|
449 629:f9470a59e5da luis
      s << link_to_project(proj, {}, :class => 'publication_project')
450 1068:e11d8d13ebc5 luis
451
      if show_delete_icon
452 691:f8d7e85ccd4e luis
        if User.current.allowed_to?(:edit_publication, @project)
453
          if @project == proj
454 945:75351d69e2ba luis
            # todo: move this message to yml file
455 691:f8d7e85ccd4e luis
            confirm_msg = 'Are you sure you want to remove the current project from this publication\'s projects list?'
456
          else
457
            confirm_msg = false
458 1068:e11d8d13ebc5 luis
          end
459
460 1317:2805873c0147 luis
          s << link_to(l(:button_delete), { :url => { :controller => 'publications', :action => 'remove_project', :id => publication, :remove_project_id => proj,  :project_id => @project }, :method => :post, :confirm => confirm_msg }, :class => 'icon icon-del', :remote => :true)
461 691:f8d7e85ccd4e luis
        end
462 629:f9470a59e5da luis
      end
463 691:f8d7e85ccd4e luis
464 1068:e11d8d13ebc5 luis
      s << "<br />"
465
    end
466
467 1307:06de38acb6b4 luis
    s.html_safe
468 541:c3abeb11bc2e luis
  end
469 1068:e11d8d13ebc5 luis
470
  def print_ieee_format(publication)
471
    Rails.cache.fetch("publication-#{publication.id}-ieee") do
472 1497:f86e70095184 Chris
      entry = publication.print_entry(:ieee)
473
      if entry
474
        entry.html_safe
475
      end
476 1068:e11d8d13ebc5 luis
    end
477 946:a0c9cc95bcf3 luis
  end
478 1068:e11d8d13ebc5 luis
479
  def print_bibtex_format(publication)
480
    Rails.cache.fetch("publication-#{publication.id}-bibtex") do
481
      publication.print_entry(:bibtex)
482
    end
483 945:75351d69e2ba luis
  end
484 1068:e11d8d13ebc5 luis
485 544:f05f3a9ef569 luis
  def show_bibtex_fields(bibtex_entry)
486
    s = ""
487 615:c4ddb9531f4c chris
    bibtex_entry.attributes.keys.sort.each do |key|
488
      value = bibtex_entry.attributes[key].to_s
489
      next if key == 'id' or key == 'publication_id' or value == ""
490 1068:e11d8d13ebc5 luis
      s << "<h4>" + l("field_#{key}") + "</h4>"
491 615:c4ddb9531f4c chris
      s << "<p>"
492
      if key == "entry_type"
493
        s << bibtex_entry.entry_type_label
494
      else
495
        s << value
496 544:f05f3a9ef569 luis
      end
497 615:c4ddb9531f4c chris
      s << "</p>"
498 544:f05f3a9ef569 luis
    end
499
    s
500 1068:e11d8d13ebc5 luis
  end
501 328:aed18b463206 luis
end
502 1407:00a51e442fe9 luis
503
504
def render_authorship_link(link_class, link_id)
505
506
  # Renders a link for an author used when adding authors for a publication
507
  # link_class can be either User or Author
508
  # link_id will be the id of the Author/User we wish to link
509
510
  s= ""
511
512
  if link_class == "Author"
513 1416:96ffcd574b96 luis
    url = {:controller => 'authors', :action => 'show', :id => link_id}
514
    s << link_to(h(Author.find(link_id).name), url)
515 1407:00a51e442fe9 luis
  else
516 1416:96ffcd574b96 luis
    url = {:controller => 'users', :action => 'show', :id => link_id}
517
    s << link_to(h(User.find(link_id).name), url)
518 1407:00a51e442fe9 luis
  end
519
520
  s.html_safe
521
end
522
523 328:aed18b463206 luis
class Author < ActiveRecord::Base
524 946:a0c9cc95bcf3 luis
  unloadable
525 1123:48c5fdd6cf10 luis
526 468:0bb9c7baed07 luis
  has_many :authorships, :dependent => :destroy
527 328:aed18b463206 luis
  has_many :publications, :through => :authorships
528 403:b15397a5341c luis
529 466:a7dc708d48a1 luis
  belongs_to :user
530 478:7097dc91e58e luis
531
  def <=>(author)
532
    name.downcase <=> author.name.downcase
533
  end
534 1123:48c5fdd6cf10 luis
535 1124:807426fa6017 luis
  # todo: review usage of scope --lf.20130108
536 1123:48c5fdd6cf10 luis
  scope :like, lambda {|q|
537 477:aeedcec4df5f luis
    s = "%#{q.to_s.strip.downcase}%"
538
    {:conditions => ["LOWER(name) LIKE :s", {:s => s}],
539
     :order => 'name'
540
    }
541 478:7097dc91e58e luis
  }
542
543 1412:48d9b3ae9e1a luis
  def institution
544 1413:0e40e05048eb luis
    if self.authorships.first.nil?
545
      ""
546
    else
547
      self.authorships.first.institution
548
    end
549 1412:48d9b3ae9e1a luis
  end
550 1414:07444815c0bd luis
551
  def mail
552
    if self.authorships.first.nil?
553
      ""
554
    else
555
      self.authorships.first.mail
556
    end
557
  end
558
559 1420:b688fe79f593 luis
  # todo: need to fix the name getter
560 1417:1df2db7f0e4d luis
  def name
561 1420:b688fe79f593 luis
    if self.authorships.first.nil?
562
      ""
563
    else
564
      self.authorships.first.name
565 1417:1df2db7f0e4d luis
    end
566
  end
567
568 328:aed18b463206 luis
end
569
class Authorship < ActiveRecord::Base
570 1123:48c5fdd6cf10 luis
  unloadable
571
572 328:aed18b463206 luis
  belongs_to :author
573
  belongs_to :publication
574 1123:48c5fdd6cf10 luis
575 483:cc267eb99115 luis
  accepts_nested_attributes_for :author
576
  accepts_nested_attributes_for :publication
577 686:b1debf464389 luis
578
  validates_presence_of :name_on_paper
579 1123:48c5fdd6cf10 luis
580 1395:0e4c6c2f400e luis
  attr_writer :search_author_id , :search_author_class
581 1394:0f918e37e1d6 luis
  attr_writer :search_author_tie
582 1364:4d5d25039a5f luis
583 1394:0f918e37e1d6 luis
  ### attr_accessor :search_results, :identify_author
584
  ## attr_writer :search_author_class
585
586 1395:0e4c6c2f400e luis
  before_save :set_author
587 1367:a2e51c0a7860 luis
  before_update :delete_publication_cache
588 591:9e866f13c984 luis
589 1363:855b4ae5ecdd luis
  # tod: review scope of ordering
590
  acts_as_list :column => 'auth_order'
591 1317:2805873c0147 luis
592 1124:807426fa6017 luis
  # todo: review usage of scope --lf.20130108
593 1123:48c5fdd6cf10 luis
  scope :like_unique, lambda {|q|
594 601:1608b3cb50cd luis
    s = "%#{q.to_s.strip.downcase}%"
595
    {:conditions => ["LOWER(name_on_paper) LIKE :s OR LOWER(email) LIKE :s", {:s => s}],
596
     :order => 'name_on_paper',
597
     :group => "name_on_paper, institution, email"
598
    }
599
  }
600
601 1124:807426fa6017 luis
  # todo: review usage of scope --lf.20130108
602 1123:48c5fdd6cf10 luis
  scope :like, lambda {|q|
603 591:9e866f13c984 luis
    s = "%#{q.to_s.strip.downcase}%"
604 601:1608b3cb50cd luis
    {:conditions => ["LOWER(name_on_paper) LIKE :s OR LOWER(email) LIKE :s", {:s => s}],
605 591:9e866f13c984 luis
     :order => 'name_on_paper'
606
    }
607
  }
608 1123:48c5fdd6cf10 luis
609 1394:0f918e37e1d6 luis
  def search_author_class
610
    # Authorship must always have an Author
611
    # unless it hasn't been saved yet
612
    # using default setter (attr_writer)
613
614
    if self.author.nil?
615 1397:bf2db886a543 luis
      aclass = ""
616 1394:0f918e37e1d6 luis
    else
617 1397:bf2db886a543 luis
      aclass = "Author"
618 1394:0f918e37e1d6 luis
    end
619 1395:0e4c6c2f400e luis
620 1397:bf2db886a543 luis
    @search_author_class || aclass
621 1394:0f918e37e1d6 luis
  end
622
623
  def search_author_id
624
    if self.author.nil?
625 1398:92d854be33d5 luis
      authid = ""
626 1394:0f918e37e1d6 luis
    else
627 1397:bf2db886a543 luis
      authid = author_id
628 1394:0f918e37e1d6 luis
    end
629 1397:bf2db886a543 luis
630
    @search_author_id || authid
631 1394:0f918e37e1d6 luis
  end
632
633
  def search_author_tie
634
    if self.author.nil?
635 1397:bf2db886a543 luis
      auth_tie = false
636 1394:0f918e37e1d6 luis
    else
637 1397:bf2db886a543 luis
      auth_tie = true
638 1394:0f918e37e1d6 luis
    end
639
640 1397:bf2db886a543 luis
    @search_author_tie || auth_tie
641 1394:0f918e37e1d6 luis
  end
642
643 592:68c6b060385c luis
  def name
644
    return self.name_on_paper
645
  end
646 1123:48c5fdd6cf10 luis
647 591:9e866f13c984 luis
  def <=>(authorship)
648 592:68c6b060385c luis
    name.downcase <=> authorship.name.downcase
649
  end
650 1123:48c5fdd6cf10 luis
651 592:68c6b060385c luis
  def mail
652
    return self.email
653 591:9e866f13c984 luis
  end
654 1123:48c5fdd6cf10 luis
655
  protected
656 1367:a2e51c0a7860 luis
657
  def delete_publication_cache
658
    publication = Publication.find(self.publication_id)
659
    Rails.cache.delete "publication-#{publication.id}-ieee"
660
    Rails.cache.delete "publication-#{publication.id}-bibtex"
661
  end
662
663 1395:0e4c6c2f400e luis
  private
664
665 1394:0f918e37e1d6 luis
  def set_author
666 1403:35732ac4324a luis
    # do we want to associate the authorship
667
    #  with an existing author/user?
668
    if @search_author_tie
669
      # if an author, simply associates with it
670
      # if an user, checks if it has already an author associated with it
671
      #   if so, associates with that author
672
      #   otherwise, creates a new author
673 1394:0f918e37e1d6 luis
674 1403:35732ac4324a luis
      case @search_author_class
675
      when ""
676
        author = Author.new
677
        author.save
678 1394:0f918e37e1d6 luis
679 1403:35732ac4324a luis
      when "User"
680
        user = User.find(@search_author_id)
681 1394:0f918e37e1d6 luis
682 1403:35732ac4324a luis
        if user.author.nil?
683
          # User w/o author:
684
          # create new author and update user
685
          author = Author.new
686
          author.save
687
          user.author = author
688
          user.save
689
        else
690
          author = user.author
691
        end
692
693
      when "Author"
694
        author = Author.find(@search_author_id)
695
      end
696
697
    # if we don't want to associate with an existing author/user
698
    else
699
      # todo: should we delete any previously existing relationship?
700 1366:7e85f7988ab8 luis
      author = Author.new
701
      author.save
702 1394:0f918e37e1d6 luis
    end
703 1366:7e85f7988ab8 luis
704 1394:0f918e37e1d6 luis
    self.author = author
705 518:b24091590b63 luis
  end
706 328:aed18b463206 luis
end
707 393:9595ab4cac6b luis
class BibtexEntry < ActiveRecord::Base
708 544:f05f3a9ef569 luis
  unloadable
709
710 393:9595ab4cac6b luis
  belongs_to :publication
711 544:f05f3a9ef569 luis
  validates_presence_of :entry_type
712
713
  def entry_type_name
714
    entry_type = self.entry_type
715
    BibtexEntryType.find(entry_type).name
716
  end
717
718 586:658cfb481618 chris
  def entry_type_label
719
    entry_type = self.entry_type
720
    BibtexEntryType.find(entry_type).label
721 685:4481db876cdb luis
  end
722 393:9595ab4cac6b luis
end
723 542:23a9272bf766 luis
class BibtexEntryType < ActiveRecord::Base
724 946:a0c9cc95bcf3 luis
  unloadable
725 685:4481db876cdb luis
726 1394:0f918e37e1d6 luis
  @@fields = Hash['article', ['journal', 'year', 'volume', 'number', 'pages', 'month', 'note' ],
727 685:4481db876cdb luis
                  'book' , [ 'editor', 'publisher', 'volume', 'series', 'address', 'edition', 'month', 'year', 'note' ],
728
                  'booklet' , [ 'howpublished', 'address', 'year', 'month', 'note', 'key' ],
729
                  'conference', [ 'booktitle', 'year', 'editor', 'pages', 'organization', 'publisher', 'address', 'month', 'note' ],
730
                  'inbook', [ 'editor', 'publisher', 'chapter', 'pages', 'volume', 'series', 'address', 'edition', 'year', 'note' ],
731
                  'incollection', [ 'editor', 'publisher', 'chapter', 'pages', 'volume', 'series', 'address', 'edition', 'year', 'note' ],
732
                  'inproceedings', [ 'booktitle', 'year', 'editor', 'pages', 'organization', 'publisher', 'address', 'month', 'note' ],
733
                  'manual', [ 'organization', 'address', 'edition', 'month', 'year', 'note' ],
734
                  'masterthesis', [ 'school', 'year', 'address', 'month', 'note' ],
735
                  'misc', [ 'howpublished', 'month', 'year', 'note' ],
736
                  'phdthesis', [ 'school', 'year', 'address', 'month', 'note' ],
737
                  'proceedings', [ 'booktitle', 'year', 'editor', 'pages', 'organization', 'publisher', 'address', 'month', 'note' ],
738
                  'techreport', [ 'year', 'type', 'number', 'address', 'month', 'note' ],
739
                  'unpublished', [ 'note', 'month', 'year' ]]
740
741 586:658cfb481618 chris
  def redundant?
742
    name == 'conference'  # conference is a duplicate of inproceedings
743
  end
744 685:4481db876cdb luis
745 586:658cfb481618 chris
  def label
746
    l("field_bibtex_#{name}")
747
  end
748 685:4481db876cdb luis
749
  def self.fields (type)
750 1394:0f918e37e1d6 luis
    @@fields[ self.find(type).name ]
751 685:4481db876cdb luis
  end
752 542:23a9272bf766 luis
end
753 385:a6f8c0584a92 luis
# vendor/plugins/redmine_bibliography/app/models/publication.rb
754
755 328:aed18b463206 luis
class Publication < ActiveRecord::Base
756 428:9cfd7a1d848e luis
  unloadable
757 1068:e11d8d13ebc5 luis
758 571:e1699e8d6d69 luis
  has_many :authorships, :dependent => :destroy, :order => "auth_order ASC"
759 447:565f82b8ff9c luis
  has_many :authors, :through => :authorships, :uniq => true
760 1068:e11d8d13ebc5 luis
761 560:735388da579a luis
  has_one :bibtex_entry, :dependent => :destroy
762 376:ad71d0604ac2 luis
763
  validates_presence_of :title
764 686:b1debf464389 luis
  validates_length_of :authorships, :minimum => 1, :message => l("error_no_authors")
765 1287:1c3e2fb6793a luis
  validates_associated :bibtex_entry, :authorships
766 445:77f88379115a luis
767
  accepts_nested_attributes_for :authorships
768 446:995d4c99843d luis
  accepts_nested_attributes_for :authors, :allow_destroy => true
769 454:2f1a308c4c11 luis
  accepts_nested_attributes_for :bibtex_entry, :allow_destroy => true
770 1068:e11d8d13ebc5 luis
771 464:fbdfec975bfa luis
  has_and_belongs_to_many :projects, :uniq => true
772 1068:e11d8d13ebc5 luis
773 567:5404f7dfb4b3 chris
  before_save :set_initial_author_order
774 653:0c5674b65db0 chris
775 1212:1186340b4ad4 luis
  scope :visible, lambda {|*args| { :include => :projects,
776
                                    :conditions => Project.allowed_to_condition(args.shift || User.current, :view_publication, *args) } }
777 1087:74407a04925c luis
778 1080:5bd8c86cfa6a luis
  acts_as_activity_provider :type => 'publication',
779
                            :timestamp => "#{Publication.table_name}.created_at",
780 1087:74407a04925c luis
                            :find_options => {
781
                              :include => :projects,
782
                              :conditions => "#{Project.table_name}.id = projects_publications.project_id"
783
                            }
784 1080:5bd8c86cfa6a luis
785
  acts_as_event :title => Proc.new {|o| o.title },
786
                :datetime => :created_at,
787
                :type => 'publications',
788 1087:74407a04925c luis
                :author => nil,
789 1080:5bd8c86cfa6a luis
                #todo - need too move the cache from the helper to the model
790
                :description => Proc.new {|o| o.print_entry(:ieee)},
791 1087:74407a04925c luis
                :url => Proc.new {|o| {:controller => 'publications', :action => 'show', :id => o.id }}
792 1080:5bd8c86cfa6a luis
793
794 653:0c5674b65db0 chris
  # Ensure error message uses proper text instead of
795
  # bibtex_entry.entry_type (#268).  There has to be a better way to
796
  # do this!
797 1287:1c3e2fb6793a luis
  def self.human_attribute_name(k, *args)
798 653:0c5674b65db0 chris
    if k == 'bibtex_entry.entry_type'
799
      l(:field_entry_type)
800
    else
801
      super
802
    end
803
  end
804
805 1068:e11d8d13ebc5 luis
  def notify_authors_publication_added(project)
806 643:505fdac73166 luis
    self.authors.each do |author|
807 651:f029431de4dd luis
      Rails.logger.debug { "Sending mail to \"#{self.title}\" publication authors." }
808 1401:95bdaaab97ca luis
      Mailer.publication_added(author.user, self, project).deliver unless author.user.nil?
809 643:505fdac73166 luis
    end
810 666:865d079e5fa0 luis
  end
811 1068:e11d8d13ebc5 luis
812
  def notify_authors_publication_updated(project)
813 666:865d079e5fa0 luis
    self.authors.each do |author|
814
      Rails.logger.debug { "Sending mail to \"#{self.title}\" publication authors." }
815 1401:95bdaaab97ca luis
      Mailer.publication_updated(author.user, self, project).deliver unless author.user.nil?
816 666:865d079e5fa0 luis
    end
817 643:505fdac73166 luis
  end
818 1068:e11d8d13ebc5 luis
819
820 556:ca9e8e562ea7 luis
  def set_initial_author_order
821
    authorships = self.authorships
822 1068:e11d8d13ebc5 luis
823 556:ca9e8e562ea7 luis
    logger.debug { "Publication \"#{self.title}\" has #{authorships.size} authors." }
824 1068:e11d8d13ebc5 luis
825 556:ca9e8e562ea7 luis
    authorships.each_with_index do |authorship, index|
826
      if authorship.auth_order.nil?
827
         authorship.auth_order = index
828
      end
829 1068:e11d8d13ebc5 luis
    end
830 556:ca9e8e562ea7 luis
  end
831 1068:e11d8d13ebc5 luis
832 946:a0c9cc95bcf3 luis
  def print_bibtex_author_names
833 1068:e11d8d13ebc5 luis
    # this authors are correctly sorted because the authorships model
834 946:a0c9cc95bcf3 luis
    # already outputs the author names ASC by auth_order
835
    self.authorships.map{|a| a.name_on_paper}.join(' and ')
836 1068:e11d8d13ebc5 luis
  end
837
838 946:a0c9cc95bcf3 luis
  def print_entry(style)
839
    bib = BibTeX::Entry.new
840
841
    bib.author = self.print_bibtex_author_names
842
    bib.title = self.title
843
844 1068:e11d8d13ebc5 luis
    self.bibtex_entry.attributes.keys.sort.each do |key|
845 946:a0c9cc95bcf3 luis
      value = self.bibtex_entry.attributes[key].to_s
846
      next if key == 'id' or key == 'publication_id' or value == ""
847
848 1068:e11d8d13ebc5 luis
      if key == "entry_type"
849 1028:b8ae7b3af25a luis
        bib.type = BibtexEntryType.find(self.bibtex_entry.entry_type).name
850 946:a0c9cc95bcf3 luis
      else
851
        bib[key.to_sym] = value
852 1068:e11d8d13ebc5 luis
      end
853 946:a0c9cc95bcf3 luis
    end
854 1068:e11d8d13ebc5 luis
855 946:a0c9cc95bcf3 luis
    if style == :ieee
856 1579:aba122ac2d40 Chris
      citeproc = bib.to_citeproc
857
      cite_id = citeproc["id"]
858
      #!!! These warns should go once I've figured out why it's not rendering!
859
      logger.warn { "rendering citation #{citeproc} with id #{ cite_id }" }
860
      cp = CiteProc::Processor.new style: 'ieee', format: 'html'
861
      cp.import citeproc
862
      cp.render :bibliography, id: cite_id
863
      logger.warn { "rendered" }
864
      result
865
866
#      CiteProc.process(bib.to_citeproc, :style => :ieee, :format => :html)
867 1068:e11d8d13ebc5 luis
    else
868 1023:3d924264419a luis
      bibtex = bib.to_s :include => :meta_content
869
      bibtex.strip!
870 1068:e11d8d13ebc5 luis
    end
871 946:a0c9cc95bcf3 luis
  end
872 328:aed18b463206 luis
end
873 1088:a9311b2d850f luis
<% events = @events_by_day %>
874
<% max = 5 %>
875
<% if (events.nil?)
876
     activity = Redmine::Activity::Fetcher.new(User.current, :project => @project)
877
878
     if @project
879
        # Don't show news (duplicated with News box) or wiki edits (too
880
	# tedious) in project front page
881
        activity.scope = [ "changesets", "files", "issues", "documents" ]
882
     end
883
884
     events = activity.events(Date.today - 28, Date.today + 1)
885
886
     if defined? user
887
        events = events.select { |e|
888
889
          if e.class != Publication
890
            user.member_of? e.project
891
          else
892 1202:8675fa03326d chris
            e.projects.map {|p| user.member_of? p }.any?
893 1088:a9311b2d850f luis
          end
894
        }
895
896
     end
897
898
     events = events.first(max)
899
900
   end
901
%>
902
903
<div id="activity">
904
905
<% if @project.nil? %>
906
   <%= content_tag('h3', l(:label_activity_my_recent)) %>
907
   <div class="activity box">
908
<% end %>
909
910
<% if events.empty? %>
911
912
   <% if @project.nil? %>
913 1202:8675fa03326d chris
     <div class="tip"><%= l(:label_activity_my_recent_none) %></div>
914 1088:a9311b2d850f luis
   <% end %>
915
916
<% else %>
917
918
   <% if !@project.nil? %>
919
     <div class="activity box">
920
     <%= content_tag('h3', l(:label_activity_recent)) %>
921
   <% end %>
922
923
   <dl>
924
   <% events.sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%>
925
    <%- if e.class != Publication -%>
926
      <dt class="<%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
927
     	<%= avatar(e.event_author, :size => "24") if e.respond_to?(:event_author) %>
928
        <span class="time"><%= format_time(e.event_datetime) %></span>
929
        <%= content_tag('span', link_to_project(e.project), :class => 'project') if @project.nil? || @project != e.project %>
930
        <% if e.respond_to?(:event_author) %>
931
          <span class="author"><%= e.event_author %></span>
932
        <% end %>
933
      </dt>
934
      <dd><%= link_to format_activity_title(e.event_title), e.event_url %>
935
        <span class="description"><%= format_activity_description(e.event_description) %></span>
936
      </dd>
937
     <% else -%>
938
      <dt class="<%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
939
         <span class="time"><%= format_time(e.event_datetime) %></span>
940
          <%= link_to format_activity_title(e.event_title), e.event_url %>
941
      was added to the following
942
      <% if e.projects.count > 1 %>
943
        projects:
944
      <%- else -%>
945
        project:
946
      <%- end -%>
947
      <%= content_tag('span', e.projects.join(', ')) -%>         <% if e.respond_to?(:event_author) %>
948
             <span class="author"><%= e.event_author %></span>
949
         <% end %>
950
        </dt>
951
           <dd><%= link_to format_activity_title(e.event_title), e.event_url %>
952
           <span class="description"><%= format_activity_description(e.event_description) %></span>
953
           </dd>
954
     <% end -%>
955
   <% end -%>
956
   </dl>
957
958
   </div>
959
960
<% end %>
961
962
<% if events.empty? and @project.nil? %></div><% end %>
963
964
</div>
965 1080:5bd8c86cfa6a luis
<h2><%=
966
  if @author.nil?
967
    if @institution_name.blank?
968
      l(:label_activity)
969
    else
970
      l(:label_institution_activity, h(@institution_name))
971
    end
972
  else
973 1385:bfef1bf3bedd luis
    l(:label_user_activity, link_to_user(@author)).html_safe
974 1080:5bd8c86cfa6a luis
  end
975
  %></h2>
976
<p class="subtitle"><%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %></p>
977
978
<div id="activity">
979
<% @events_by_day.keys.sort.reverse.each do |day| %>
980
<h3><%= format_activity_day(day) %></h3>
981
<dl>
982 1486:234d18ea18e9 Chris
<% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%>
983 1080:5bd8c86cfa6a luis
  <%- if e.class != Publication -%>
984 1486:234d18ea18e9 Chris
    <dt class="<%= e.event_type %> <%= "grouped" if in_group %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
985 1080:5bd8c86cfa6a luis
      <%= avatar(e.event_author, :size => "24") if e.respond_to?(:event_author) %>
986
      <span class="time"><%= format_time(e.event_datetime, false) %></span>
987
      <%= content_tag('span', h(e.project), :class => 'project') if @project.nil? || @project != e.project %>
988
      <%= link_to format_activity_title(e.event_title), e.event_url %>
989
    </dt>
990 1486:234d18ea18e9 Chris
    <dd class="<%= "grouped" if in_group %>">
991 1080:5bd8c86cfa6a luis
      <span class="description"><%= format_activity_description(e.event_description) %></span>
992
      <span class="author"><%= link_to_user(e.event_author) if e.respond_to?(:event_author) %></span>
993
    </dd>
994
  <%- else -%>
995
    <dt class="<%= e.event_type %>  <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
996
      <%= avatar(e.event_author, :size => "24") if e.respond_to?(:event_author) %>
997
      <span class="time"><%= format_time(e.event_datetime, false) %></span>
998
      <%= link_to format_activity_title(e.event_title), e.event_url %>
999
      was added to the following
1000
      <% if e.projects.count > 1 %>
1001
        projects:
1002
      <%- else -%>
1003
        project:
1004
      <%- end -%>
1005
      <%= content_tag('span', e.projects.join(', ')) -%>
1006
    </dt>
1007
    <dd>
1008
      <span class="description"><%= e.event_description -%></span>
1009
      <span class="author"><%= link_to_user(e.event_author) if e.respond_to?(:event_author) %></span>
1010
    </dd>
1011
  <% end -%>
1012
<%- end -%>
1013
</dl>
1014
<% end -%>
1015
</div>
1016
1017
<%= content_tag('p', l(:label_no_data), :class => 'nodata') if @events_by_day.empty? %>
1018
1019
<div style="float:left;">
1020
<%= link_to_content_update("\xc2\xab " + l(:label_previous),
1021
                   params.merge(:from => @date_to - @days - 1),
1022
                   :title => l(:label_date_from_to, :start => format_date(@date_to - 2*@days), :end => format_date(@date_to - @days - 1))) %>
1023
</div>
1024
<div style="float:right;">
1025
<%= link_to_content_update(l(:label_next) + " \xc2\xbb",
1026
                   params.merge(:from => @date_to + @days - 1),
1027
                   :title => l(:label_date_from_to, :start => format_date(@date_to), :end => format_date(@date_to + @days - 1))) unless @date_to >= Date.today %>
1028
</div>
1029
&nbsp;
1030
<% other_formats_links do |f| %>
1031
  <%= f.link_to 'Atom', :url => params.merge(:from => nil, :key => User.current.rss_key) %>
1032
<% end %>
1033
1034
<% content_for :header_tags do %>
1035
<%= auto_discovery_link_tag(:atom, params.merge(:format => 'atom', :from => nil, :key => User.current.rss_key)) %>
1036
<% end %>
1037
1038
<% content_for :sidebar do %>
1039
<% form_tag({}, :method => :get) do %>
1040
<h3><%= l(:label_activity) %></h3>
1041 1486:234d18ea18e9 Chris
1042
<ul>
1043
<% @activity.event_types.each do |t| %>
1044
  <li>
1045
    <%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %>
1046
    <label for="show_<%=t%>">
1047
      <%= link_to(l("label_#{t.singularize}_plural"),
1048
                  {"show_#{t}" => 1, :user_id => params[:user_id], :from => params[:from]})%>
1049
    </label>
1050
  </li>
1051
<% end %>
1052
</ul>
1053
1054 1080:5bd8c86cfa6a luis
<% if @project && @project.descendants.active.any? %>
1055
    <%= hidden_field_tag 'with_subprojects', 0 %>
1056
    <p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p>
1057
<% end %>
1058
<%= hidden_field_tag('user_id', params[:user_id]) unless params[:user_id].blank? %>
1059
<p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p>
1060
<% end %>
1061
<% end %>
1062
1063
<% html_title(l(:label_activity), @author) -%>
1064 612:8fa35731c959 luis
<h2><%=l(:label_authors_index)%></h2>
1065 328:aed18b463206 luis
1066 540:951fcb1711f2 luis
<table class="list authors">
1067
	<thead><tr>
1068
	<th><%=l(:field_author_name)%></th>
1069
	<th><%=l(:field_author_username)%></th>
1070
	<th><%=l(:field_author_publications)%></th>
1071
	</tr></thead>
1072
	<tbody>
1073
1074
  <% @authors.each do |author|%>
1075
	<tr id="author-<%= author.id %>" class="<%= cycle('odd', 'even') %>">
1076
		<td class="title">
1077 612:8fa35731c959 luis
			<%= link_to_author author %>
1078 540:951fcb1711f2 luis
		</td>
1079
    <td class="username ">
1080
      <%= link_to author.user unless author.user.nil? %>
1081
    </td>
1082
    <td class="project">
1083
      <%= render_author_publications(author) %>
1084
    </td>
1085
	</tr>
1086
	<% end %>
1087
	</tbody>
1088
</table>
1089
1090 612:8fa35731c959 luis
<h2><%=l(:label_authors_show)%></h2>
1091
1092 698:bd88afe21831 chris
<div class="autoscroll">
1093 612:8fa35731c959 luis
  <table class="list authors">
1094
  	<thead>
1095
  	  <tr>
1096
  	    <th><%=l(:field_authorship_publication_title)%></th>
1097
  	    <th><%=l(:field_authorship_name)%></th>
1098
  	    <th><%=l(:field_authorship_email)%></th>
1099
	 	    <th><%=l(:field_authorship_institution)%></th>
1100
  	  </tr>
1101
  	</thead>
1102
1103
     <% @author.authorships.each do |authorship| %>
1104
       <tr id="authorship-<%= authorship.id %>" class="<%= cycle('odd', 'even') %>">
1105 616:156bd1153f47 luis
         <td class="title"><%= link_to_publication(authorship.publication) %></td>
1106 612:8fa35731c959 luis
         <td class="name"><%= h authorship.name_on_paper %></td>
1107
         <td class="email"><%= h authorship.email %></td>
1108
         <td class="institution"><%= h authorship.institution %></td>
1109
       </tr>
1110
    <% end %>
1111
  	</tbody>
1112
  </table>
1113 698:bd88afe21831 chris
</div>
1114
1115
<% content_for :sidebar do %>
1116
<% end %>
1117
1118 328:aed18b463206 luis
<h2>Authorships#update</h2>
1119 666:865d079e5fa0 luis
<%= l(:mail_body_publication_added, :publication => @publication.title, :project => @project.name) %>
1120
<%= l(:mail_body_publication_added, :publication => @publication.title, :project => @project.name) %>
1121 651:f029431de4dd luis
1122 535:dd9d9c0ff0f9 luis
<% get_my_publications %>
1123
1124
<h3><%=l(:label_my_publications_box) %> <%= "(" + @my_publications.count.to_s + ")" %> </h3>
1125 532:76d064830472 luis
1126 534:cdec3eeaef7e luis
<table class="list publications">
1127
	<thead><tr>
1128
	<th><%=l(:field_publication_title)%></th>
1129
	<th><%=l(:field_publication_authors)%></th>
1130
	<th><%=l(:field_publication_projects)%></th>
1131
	</tr></thead>
1132 535:dd9d9c0ff0f9 luis
	<tbody>
1133
1134
  <% @my_publications.each do |publication|%>
1135 534:cdec3eeaef7e luis
	<tr id="publication-<%= publication.id %>" class="<%= cycle('odd', 'even') %>">
1136
		<td class="title">
1137
			<%= link_to publication.title, publication %>
1138
		</td>
1139
    <td class="authors">
1140 535:dd9d9c0ff0f9 luis
      <%= render_publications_authors(publication) %>
1141 534:cdec3eeaef7e luis
    </td>
1142
    <td class="project">
1143 535:dd9d9c0ff0f9 luis
      <%= render_publications_projects(publication) %>
1144 534:cdec3eeaef7e luis
    </td>
1145
	</tr>
1146
	<% end %>
1147
	</tbody>
1148
</table>
1149 531:baf26f9eb1cf luis
1150
1151 534:cdec3eeaef7e luis
1152 1017:63f8c4f2cf67 luis
<% content_for :header_tags do %>
1153
    <%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %>
1154
    <%= javascript_include_tag 'bibtex', :plugin => 'redmine_bibliography' -%>
1155
<% end %>
1156
1157 646:e01aa4ccc0a2 chris
<% if @project.publications.any? %>
1158 645:b83173d26d86 chris
<%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %>
1159
  <div id="bibliography">
1160
    <div class="box">
1161
    <h3><%=l(:label_related_publication_plural)%></h3>
1162
1163 1068:e11d8d13ebc5 luis
     <dl>
1164
     <% @project.publications.each do |publication| %>
1165 1017:63f8c4f2cf67 luis
       <dt>
1166 1068:e11d8d13ebc5 luis
          <%= print_ieee_format(publication) %>
1167 1017:63f8c4f2cf67 luis
       </dt>
1168
       <dd>
1169 1313:17f075c7fd41 luis
         <%= link_to(l("more_details_link"), {:controller => :publications, :action => :show, :id => publication.id, :project_id => @project.id}) -%>
1170 1068:e11d8d13ebc5 luis
1171 1313:17f075c7fd41 luis
         <%= link_to l(:bibtex_link).html_safe, "javascript:void(0)", :class => "bibtex-link"-%>
1172 1352:939f4a491900 luis
1173
        <%- unless publication.external_url.blank? -%>
1174
            <%= link_to l(:external_url_link), publication.external_url, {:target => "_blank"} -%>
1175
        <%- end -%>
1176
1177
1178 1017:63f8c4f2cf67 luis
       </dd>
1179
       <dd class="bibtex-textarea collapsed" style="display: none;">
1180 1317:2805873c0147 luis
         <textarea readonly> <%= print_bibtex_format(publication) -%> </textarea>
1181 1017:63f8c4f2cf67 luis
       </dd>
1182 645:b83173d26d86 chris
   <% end -%>
1183 1017:63f8c4f2cf67 luis
     </dl>
1184 465:5123e3a1c9cb luis
  </div>
1185 645:b83173d26d86 chris
</div>
1186 1017:63f8c4f2cf67 luis
<% end -%>
1187 465:5123e3a1c9cb luis
<div class="contextual">
1188
	<% if User.current.allowed_to?(:add_subprojects, @project) %>
1189 1486:234d18ea18e9 Chris
		<%= link_to l(:label_subproject_new), new_project_path(:parent_id => @project), :class => 'icon icon-add' %>
1190 465:5123e3a1c9cb luis
	<% end %>
1191 546:7c4b96efa402 luis
1192 1232:345e08eee166 Chris
  <% if User.current.allowed_to?(:close_project, @project) %>
1193
    <% if @project.active? %>
1194
      <%= link_to l(:button_close), close_project_path(@project), :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock' %>
1195
    <% else %>
1196
      <%= link_to l(:button_reopen), reopen_project_path(@project), :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-unlock' %>
1197
    <% end %>
1198 1233:ed0d04113c93 chris
  <% end %>
1199 1232:345e08eee166 Chris
1200 550:2df99e8d191e luis
	<% if @project.module_enabled? :redmine_bibliography %>
1201 626:e2663e0bd5a6 luis
	  <% if User.current.allowed_to?(:add_publication, @project) %>
1202
		  <%= link_to l(:label_add_publication_to_project), {:controller => 'publications', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %>
1203
	  <% end %>
1204 550:2df99e8d191e luis
	<% end %>
1205 465:5123e3a1c9cb luis
</div>
1206
1207 680:65abc6b39292 chris
<% if @project.has_welcome_page %>
1208
<% page = @project.wiki.find_page("Overview") %>
1209
<% end %>
1210
1211
<% if page %>
1212
1213
<% if @project.module_enabled? :wiki %>
1214
<% if User.current.allowed_to?(:edit_wiki_pages, @project) %>
1215
<div class="contextual">
1216
<%= link_to(l(:button_welcome_page_edit_this), {:controller => 'wiki', :action => 'edit', :project_id => @project, :id => Wiki.titleize("Overview")}, :class => 'icon icon-edit') %>
1217
</div>
1218
<% end %>
1219
<% end %>
1220
1221
<div class="contextual" style="clear: right">
1222
<ul>
1223 1232:345e08eee166 Chris
<% unless @project.homepage.blank? %><li><%=l(:field_homepage)%>: <%= link_to h(@project.homepage), @project.homepage %></li><% end %>
1224 680:65abc6b39292 chris
<% if @subprojects.any? %>
1225
	<li><%=l(:label_subproject_plural)%>:
1226 1486:234d18ea18e9 Chris
	    <%= @subprojects.collect{|p| link_to p, project_path(p)}.join(", ").html_safe %></li>
1227 680:65abc6b39292 chris
<% end %>
1228
</ul>
1229
</div>
1230
1231
<%= render(:partial => "wiki/content", :locals => {:content => page.content_for_version()}) %>
1232
1233
<% else %>
1234
1235 465:5123e3a1c9cb luis
<h2><%=l(:label_overview)%></h2>
1236
1237 1232:345e08eee166 Chris
<% unless @project.active? %>
1238
  <p class="warning"><span class="icon icon-lock"><%= l(:text_project_closed) %></span></p>
1239
<% end %>
1240
1241 465:5123e3a1c9cb luis
<div class="splitcontentleft">
1242 1232:345e08eee166 Chris
  <% if @project.description.present? %>
1243 465:5123e3a1c9cb luis
	<div class="wiki">
1244
		<%= textilizable @project.description %>
1245
	</div>
1246 1232:345e08eee166 Chris
  <% end %>
1247 1447:1e67c667641f Chris
  <div class="overviewfields">
1248
	<% unless @project.homepage.blank? %><h4><%=l(:field_homepage)%>:</h4><ul><li><%= link_to h(@project.homepage), @project.homepage %></li></ul><% end %>
1249 465:5123e3a1c9cb luis
  <% if @subprojects.any? %>
1250 1447:1e67c667641f Chris
 	<h4><%=l(:label_subproject_plural)%>:</h4>
1251
          <ul>
1252
	    <li><%= @subprojects.collect{|p| link_to(h(p), :action => 'show', :id => p)}.join("</li><li>").html_safe %></li>
1253
          </ul>
1254 465:5123e3a1c9cb luis
  <% end %>
1255
	<% @project.visible_custom_field_values.each do |custom_value| %>
1256
	<% if !custom_value.value.blank? %>
1257 1447:1e67c667641f Chris
	   <h4><%= custom_value.custom_field.name%>:</h4><ul><li><%=h show_value(custom_value) %></li></ul>
1258 465:5123e3a1c9cb luis
	<% end %>
1259
	<% end %>
1260 1447:1e67c667641f Chris
  </div>
1261 1232:345e08eee166 Chris
  <% if User.current.allowed_to?(:view_issues, @project) and @open_issues_by_tracker.values.any? %>
1262 465:5123e3a1c9cb luis
  <div class="issues box">
1263
    <h3><%=l(:label_issue_tracking)%></h3>
1264
    <ul>
1265
    <% for tracker in @trackers %>
1266 1486:234d18ea18e9 Chris
      <li><%= link_to h(tracker.name), project_issues_path(@project, :set_filter => 1, :tracker_id => tracker.id) %>:
1267 1232:345e08eee166 Chris
	<%= l(:label_x_open_issues_abbr_on_total, :count => @open_issues_by_tracker[tracker].to_i,
1268
	:total => @total_issues_by_tracker[tracker].to_i) %>
1269
      </li>
1270 465:5123e3a1c9cb luis
    <% end %>
1271
    </ul>
1272
    <p>
1273 1486:234d18ea18e9 Chris
    	<%= link_to l(:label_issue_view_all), project_issues_path(@project, :set_filter => 1) %>
1274 465:5123e3a1c9cb luis
	    <% if User.current.allowed_to?(:view_calendar, @project, :global => true) %>
1275 1486:234d18ea18e9 Chris
	      | <%= link_to l(:label_calendar), project_calendar_path(@project) %>
1276
	    <% end %>
1277
	    <% if User.current.allowed_to?(:view_gantt, @project, :global => true) %>
1278
	      | <%= link_to l(:label_gantt), project_gantt_path(@project) %>
1279
	    <% end %>
1280
    </p>
1281 465:5123e3a1c9cb luis
  </div>
1282
  <% end %>
1283
  <%= call_hook(:view_projects_show_left, :project => @project) %>
1284
</div>
1285
1286
<div class="splitcontentright">
1287
1288
  <%= render :partial => 'bibliography_box' %>
1289
1290
  <%= render :partial => 'members_box' %>
1291
1292
  <% if @news.any? && authorize_for('news', 'index') %>
1293
  <div class="news box">
1294
    <h3><%=l(:label_news_latest)%></h3>
1295
    <%= render :partial => 'news/news', :collection => @news %>
1296 1486:234d18ea18e9 Chris
    <p><%= link_to l(:label_news_view_all), project_news_index_path(@project) %></p>
1297 465:5123e3a1c9cb luis
  </div>
1298
  <% end %>
1299 1232:345e08eee166 Chris
1300
  <%= render :partial => 'activities/recent' %>
1301
1302 465:5123e3a1c9cb luis
  <%= call_hook(:view_projects_show_right, :project => @project) %>
1303
</div>
1304
1305
<% content_for :sidebar do %>
1306 810:aaa26ccafb00 chris
    <%= call_hook(:view_projects_show_sidebar_top, :project => @project) %>
1307 1232:345e08eee166 Chris
    <% if @total_hours.present? && User.current.allowed_to?(:view_time_entries, @project) %>
1308 465:5123e3a1c9cb luis
    <h3><%= l(:label_spent_time) %></h3>
1309
    <p><span class="icon icon-time"><%= l_hours(@total_hours) %></span></p>
1310 1232:345e08eee166 Chris
    <p>
1311
    <% if User.current.allowed_to?(:log_time, @project) %>
1312
      <%= link_to l(:button_log_time), new_project_time_entry_path(@project) %> |
1313
    <% end %>
1314
    <%= link_to(l(:label_details), project_time_entries_path(@project)) %> |
1315
    <%= link_to(l(:label_report), report_project_time_entries_path(@project)) %></p>
1316 465:5123e3a1c9cb luis
    <% end %>
1317
    <%= call_hook(:view_projects_show_sidebar_bottom, :project => @project) %>
1318
<% end %>
1319
1320 680:65abc6b39292 chris
<% end %>
1321
1322 465:5123e3a1c9cb luis
<% content_for :header_tags do %>
1323
<%= auto_discovery_link_tag(:atom, {:controller => 'activities', :action => 'index', :id => @project, :format => 'atom', :key => User.current.rss_key}) %>
1324
<% end %>
1325
1326 1511:e1cfd013ef49 chris
<% html_title('') -%>
1327 1324:2e54ae6ab02f luis
<%= form_for(:publication,
1328
            :remote => true,
1329
            :url => {:controller => 'publications', :action => 'add_project', :id => @publication, :project_id => @project},
1330 1317:2805873c0147 luis
            :method => :post,
1331 1324:2e54ae6ab02f luis
            :html => { :id => 'add_project_form' },
1332 1317:2805873c0147 luis
            :loading => "$('project-add-submit').disable()",
1333
            :complete => "$('project-add-submit').enable()") do |f| %>
1334 1324:2e54ae6ab02f luis
1335 1317:2805873c0147 luis
              <fieldset><legend><%=l(:label_add_project_to_publication)%></legend>
1336
                <p>
1337
                  <%= label_tag "project_search", l(:label_project_search) %><%= text_field_tag 'project_search', nil %>
1338
	              </p>
1339 464:fbdfec975bfa luis
1340 1324:2e54ae6ab02f luis
                <%= javascript_tag "observeSearchfield('project_search', 'projects', '#{ escape_javascript url_for(:controller => 'publications',
1341
                 :action => 'autocomplete_for_project',
1342
                 :id => @publication.id) }')" %>
1343
1344
                <div id="projects">
1345 1317:2805873c0147 luis
                  <% if params[:q] && params[:q].length > 1 %>
1346
                    <%= projects_check_box_tags 'project[project_ids][]', @projects %>
1347
                  <% end %>
1348
                </div>
1349 464:fbdfec975bfa luis
1350 1324:2e54ae6ab02f luis
                <p><%= submit_tag l(:button_add), :id => 'project-add-submit' %></p>
1351 1317:2805873c0147 luis
              </fieldset>
1352 464:fbdfec975bfa luis
  <% end %>
1353 481:dd242ea99fd3 luis
<div id="authors" class="fields">
1354 1394:0f918e37e1d6 luis
  <div class="author_edit" id="<%= form_tag_id( f.object_name, :edit_author_info ) %>">
1355
1356 1422:c97b3b9b5c86 luis
    <p><%= f.label :name_on_paper %><%= f.text_field :name_on_paper, :class => "author_name_on_paper" -%></p>
1357
    <p><%= f.label :institution %><%= f.text_field :institution -%></p>
1358
    <p><%= f.label :email %><%= f.text_field :email -%></p>
1359 1394:0f918e37e1d6 luis
1360 1403:35732ac4324a luis
    <p class="author_associated search_author_tie">
1361 1407:00a51e442fe9 luis
      <%= f.check_box :search_author_tie, :label => '' -%>
1362 1434:a9cfc6dcfb83 luis
      <% unless f.object.search_author_tie %>
1363
        <span>Not associated with any SoundSoftware site user.</span>
1364
      <% else %>
1365
        <span>Associated with <%= render_authorship_link(f.object.search_author_class, f.object.search_author_id) -%>.</span>
1366
      <% end %>
1367 1281:e9bfba17e791 luis
    </p>
1368 573:aed210f6095b chris
1369 1403:35732ac4324a luis
    <%= f.hidden_field :search_author_class -%>
1370
    <%= f.hidden_field :search_author_id -%>
1371 601:1608b3cb50cd luis
  </div>
1372 1274:5ea1a213c7a5 luis
1373 1377:f0da42a09a3c luis
  <div>
1374
    <p>
1375 1378:0b2a75f60952 luis
      <%= button_to_function l(:label_save_author), '', :id => form_tag_id(f.object_name, :edit_save_button), :class => 'author_save_btn' -%>
1376 1380:fa92d13876d0 luis
1377 1408:b09744f35f76 luis
      <%= button_to_function l(:label_edit_author), '', :id => form_tag_id(f.object_name, :edit_button), :class => 'author_edit_btn', :style => "display:none;" -%>
1378 1380:fa92d13876d0 luis
1379 1377:f0da42a09a3c luis
      <%= link_to_remove_fields l("remove_author"), f %>
1380
    </p>
1381
  </div>
1382 1394:0f918e37e1d6 luis
</div>
1383 675:fccacd8505e3 luis
<p>
1384 1422:c97b3b9b5c86 luis
  <label for="publication_bibtex_entry_attributes_entry_type"><%=l("field_entry_type")%> <span class="required">*</span></label>
1385 1274:5ea1a213c7a5 luis
	<%= f.collection_select :entry_type,
1386
	        BibtexEntryType.find(:all).reject { |x| x.redundant? },
1387
	        :id,
1388
	        :label,
1389
	        { :selected => @selected_bibtex_entry_type_id, :prompt => true } %>
1390 675:fccacd8505e3 luis
</p>
1391 699:2b665b7e67f4 luis
1392 1274:5ea1a213c7a5 luis
<p class="bibtex hol">
1393 1423:40e82f170353 luis
  <%= f.label :year %><%= f.text_field :year, :size => 5 -%>
1394 675:fccacd8505e3 luis
</p>
1395 1274:5ea1a213c7a5 luis
<p class="bibtex hol">
1396 1423:40e82f170353 luis
  <%= f.label :month %><%= f.text_field :month, :size => 5 -%>
1397 683:c3e6c51170fa luis
</p>
1398 1274:5ea1a213c7a5 luis
<p class="bibtex hol">
1399 1423:40e82f170353 luis
  <%= f.label :chapter %><%= f.text_field :chapter, :size => 5 -%>
1400 675:fccacd8505e3 luis
</p>
1401 1274:5ea1a213c7a5 luis
<p class="bibtex hol">
1402 1423:40e82f170353 luis
  <%= f.label :editor %><%= f.text_field :editor -%>
1403 1274:5ea1a213c7a5 luis
</p>
1404
<p class="bibtex hol">
1405 1423:40e82f170353 luis
  <%= f.label :booktitle %><%= f.text_field :booktitle -%>
1406 1274:5ea1a213c7a5 luis
</p>
1407
<p class="bibtex hol">
1408 1423:40e82f170353 luis
  <%= f.label :publisher %><%= f.text_field :publisher -%>
1409 1274:5ea1a213c7a5 luis
</p>
1410
<p class="bibtex hol">
1411 1423:40e82f170353 luis
  <%= f.label :pages %><%= f.text_field :pages, :size => 5 -%>
1412 1274:5ea1a213c7a5 luis
</p>
1413
<p class="bibtex hol">
1414 1423:40e82f170353 luis
 <%= f.label :address %><%= f.text_field :address -%>
1415 675:fccacd8505e3 luis
</p>
1416 1274:5ea1a213c7a5 luis
<p class="bibtex hol">
1417 1423:40e82f170353 luis
 <%= f.label :annote %><%= f.text_field :annote -%>
1418 675:fccacd8505e3 luis
</p>
1419 1274:5ea1a213c7a5 luis
<p class="bibtex hol">
1420 1423:40e82f170353 luis
 <%= f.label :crossref %><%= f.text_field :crossref -%>
1421 675:fccacd8505e3 luis
</p>
1422 1274:5ea1a213c7a5 luis
<p class="bibtex hol">
1423 1423:40e82f170353 luis
 <%= f.label :edition %><%= f.text_field :edition -%>
1424 675:fccacd8505e3 luis
</p>
1425 1274:5ea1a213c7a5 luis
<p class="bibtex hol">
1426 1423:40e82f170353 luis
 <%= f.label :eprint %><%= f.text_field :eprint -%>
1427 675:fccacd8505e3 luis
</p>
1428 1274:5ea1a213c7a5 luis
<p class="bibtex hol">
1429 1423:40e82f170353 luis
 <%= f.label :howpublished %><%= f.text_field :howpublished -%>
1430 675:fccacd8505e3 luis
</p>
1431 1274:5ea1a213c7a5 luis
<p class="bibtex hol">
1432 1423:40e82f170353 luis
 <%= f.label :journal %><%= f.text_field :journal -%>
1433 675:fccacd8505e3 luis
</p>
1434 1274:5ea1a213c7a5 luis
<p class="bibtex hol">
1435 1423:40e82f170353 luis
 <%= f.label :key %><%= f.text_field :key -%>
1436 675:fccacd8505e3 luis
</p>
1437 1274:5ea1a213c7a5 luis
<p class="bibtex hol">
1438 1423:40e82f170353 luis
 <%= f.label :note %><%= f.text_field :note -%>
1439 675:fccacd8505e3 luis
</p>
1440 1274:5ea1a213c7a5 luis
<p class="bibtex hol">
1441 1423:40e82f170353 luis
 <%= f.label :number %><%= f.text_field :number, :size => 5 -%>
1442 675:fccacd8505e3 luis
</p>
1443 1274:5ea1a213c7a5 luis
<p class="bibtex hol">
1444 1422:c97b3b9b5c86 luis
 <%= f.label :organization %><%= f.text_field :organization %>
1445 675:fccacd8505e3 luis
</p>
1446 1274:5ea1a213c7a5 luis
<p class="bibtex hol">
1447 1422:c97b3b9b5c86 luis
 <%= f.label :school %><%= f.text_field :school %>
1448 675:fccacd8505e3 luis
</p>
1449 1274:5ea1a213c7a5 luis
<p class="bibtex hol">
1450 1422:c97b3b9b5c86 luis
 <%= f.label :series %><%= f.text_field :series %>
1451 675:fccacd8505e3 luis
</p>
1452 1274:5ea1a213c7a5 luis
<p class="bibtex hol">
1453 1422:c97b3b9b5c86 luis
 <%= f.label :type %><%= f.text_field :type %>
1454 675:fccacd8505e3 luis
</p>
1455 1274:5ea1a213c7a5 luis
<p class="bibtex hol">
1456 1422:c97b3b9b5c86 luis
 <%= f.label :url %><%= f.text_field :url %>
1457 675:fccacd8505e3 luis
</p>
1458 1274:5ea1a213c7a5 luis
<p class="bibtex hol">
1459 1422:c97b3b9b5c86 luis
 <%= f.label :volume %><%= f.text_field :volume %>
1460 699:2b665b7e67f4 luis
</p>
1461 1422:c97b3b9b5c86 luis
<h3><%= f.label :title %>&nbsp;<span class="required">*</span>&nbsp;<%= f.text_field :title, :required => true, :size => 70 %></h3>
1462 545:a2c2b9f8380b luis
1463 1059:5617e630bf26 luis
<div class="splitcontentleft">
1464 615:c4ddb9531f4c chris
  <h3><%= l(:label_publication_other_details) %></h3>
1465 610:e9274ba9c1b3 luis
  <div class="box tabular">
1466 1274:5ea1a213c7a5 luis
    <%= f.fields_for :bibtex_entry do |builder| -%>
1467 610:e9274ba9c1b3 luis
      <%= render :partial => 'bibtex_fields', :locals => { :f => builder}  %>
1468
    <%- end -%>
1469 658:65749e700af0 luis
1470
    <p>
1471 1422:c97b3b9b5c86 luis
      <%= f.label :external_url %><%= f.text_field :external_url -%>
1472 658:65749e700af0 luis
      <br />
1473 1422:c97b3b9b5c86 luis
      <em><%= l(:text_external_url) -%></em>
1474 658:65749e700af0 luis
    </p>
1475 1059:5617e630bf26 luis
    <p>
1476 1422:c97b3b9b5c86 luis
      <%= f.label :doi %><%= f.text_field :doi -%>
1477 1059:5617e630bf26 luis
      <br />
1478
      <em><%= l(:text_doi) %></em>
1479
    </p>
1480 658:65749e700af0 luis
1481 610:e9274ba9c1b3 luis
  </div>
1482 573:aed210f6095b chris
</div>
1483 545:a2c2b9f8380b luis
1484 615:c4ddb9531f4c chris
<div class="splitcontentright">
1485 1059:5617e630bf26 luis
  <h3><%= l(:authors) %></h3>
1486 615:c4ddb9531f4c chris
  <div class="box tabular">
1487 1274:5ea1a213c7a5 luis
    <%= f.fields_for :authorships do |builder| -%>
1488 615:c4ddb9531f4c chris
      <%= render "authorship_fields", :f => builder %>
1489
    <%- end -%>
1490 705:b6f9f005c0b6 luis
    <%= link_to_add_author_fields l(:label_add_an_author), f, :authorships, params[:action] %>
1491 615:c4ddb9531f4c chris
  </div>
1492
</div>
1493 545:a2c2b9f8380b luis
1494 615:c4ddb9531f4c chris
1495 480:19efecf4561a luis
<legend><%= "Identify Authors in the system…" %></legend>
1496 477:aeedcec4df5f luis
1497 480:19efecf4561a luis
<%= link_to_remote "It's me!",
1498
   { :url => { :controller => 'publications',
1499
     :action => 'add_me_as_author',
1500
     :project_id => @project }, :method => 'post'},
1501
   { :class => 'icon icon-add', :id => "add_me_as_author" } %>
1502 477:aeedcec4df5f luis
1503 480:19efecf4561a luis
<p>
1504
  <%= label_tag "author_search", l(:label_project_search) %><%= text_field_tag 'author_search', nil %>
1505
</p>
1506 477:aeedcec4df5f luis
1507 481:dd242ea99fd3 luis
<%= observe_field( form_tag_id(f.object_name, :name),
1508 480:19efecf4561a luis
     :frequency => 0.5,
1509
     :update => :identify_author,
1510
     :url => { :controller => 'publications', :action => 'autocomplete_for_author' },
1511
     :with => 'q')
1512
%>
1513 477:aeedcec4df5f luis
1514 480:19efecf4561a luis
<div id="identify_author">
1515
  <% if params[:q] && params[:q].length > 1 %>
1516
    <%= select_author_links 'author[author_ids][]', @authors %>
1517
  <% end %>
1518
</div>
1519 477:aeedcec4df5f luis
1520 691:f8d7e85ccd4e luis
<%= render_projects_list(@publication, true) %>
1521 390:5562a95edbf7 luis
<h3>New Bibtex</h3>
1522 385:a6f8c0584a92 luis
1523 409:50474139cad4 luis
<h4>Paste your Bibtex entries here</h4>
1524 390:5562a95edbf7 luis
<p>
1525
  <%=label_tag :bibtex_entry %>
1526
  <%=text_area_tag :bibtex_entry%>
1527
</p>
1528 385:a6f8c0584a92 luis
1529
1530 390:5562a95edbf7 luis
<h2>Review new entries</h2>
1531
1532 464:fbdfec975bfa luis
page.replace_html :list_projects, :partial => 'list_projects'
1533
page[:add_project_form].reset
1534
1535 1394:0f918e37e1d6 luis
<%= raw @results.map { |result|
1536
    {
1537 1393:67abd7b08753 luis
    'label' => result.name,
1538 1289:7fa299909144 luis
    'value' => result.name,
1539
    'search_author_class' => result.class.name,
1540
    'search_author_id' => result.id,
1541
    'name' => result.name,
1542
    'institution' => result.institution,
1543 1407:00a51e442fe9 luis
    'email' => result.mail,
1544
    'authorship_link' => " Keep associated with #{render_authorship_link(result.class.name, result.id)}"
1545 1289:7fa299909144 luis
    }
1546
}.to_json %>
1547 463:af5f6d56dc3a luis
<% if params[:q] && params[:q].length > 1 %>
1548
	<%= projects_check_box_tags 'publication[project_ids][]', @projects %>
1549
<% end %>
1550 328:aed18b463206 luis
<h2>Publications#create</h2>
1551 545:a2c2b9f8380b luis
<% content_for :header_tags do %>
1552 1391:8580d1d1150e luis
  <%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' -%>
1553
  <%= javascript_include_tag 'bibliography', :plugin => 'redmine_bibliography' -%>
1554
  <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' -%>
1555
1556
  <%= javascript_include_tag 'edit_publication', :plugin => 'redmine_bibliography' -%>
1557
1558
  <%= javascript_tag "$('#publication_bibtex_entry_attributes_entry_type').live('change', function() {
1559
                        $this = $(this);
1560
                        $.ajax({
1561
                            type: 'get',
1562
                            url: '#{url_for(:controller => :publications, :action => :show_bibtex_fields)}',
1563
                            data: {
1564
                                value: $this.val()
1565
                            },
1566
                            dataType: 'script'
1567
                        }); return false; });" -%>
1568
1569 1409:3cb633d4b37d luis
  <%= javascript_tag "authorship_autocomplete('#{url_for :controller => :publications, :action => :autocomplete_for_author}');" -%>
1570
1571 545:a2c2b9f8380b luis
<% end %>
1572 428:9cfd7a1d848e luis
1573 1391:8580d1d1150e luis
<%= error_messages_for 'publication' %>
1574
1575 545:a2c2b9f8380b luis
<h2><%=l(:label_publication_show)%></h2>
1576 428:9cfd7a1d848e luis
1577 1424:637ee26ae557 luis
<%= form_for @publication, :url => { :project_id  => @project, :action => :update } do |f| -%>
1578 610:e9274ba9c1b3 luis
1579 1391:8580d1d1150e luis
    <%= render :partial => 'form', :locals => { :f => f }  %>
1580
1581
    <div style="clear:both"></div>
1582
    <%= f.submit %>
1583 545:a2c2b9f8380b luis
<% end %>
1584 1391:8580d1d1150e luis
1585 429:27930c9b424d luis
<p>
1586 1391:8580d1d1150e luis
    <%= link_to l(:label_publication_show), { :controller => "publications", :action => "show", :id => @publication, :project_id => @project_id } %> |
1587
    <%= link_to l(:label_publication_index), { :controller => "publications", :action => "index", :project_id => @project } %>
1588 452:34a6cf259682 luis
</p>
1589 1376:6ba24edae331 luis
1590 444:b461f84ed41a luis
<h1>New Publication</h1>
1591
1592
<% form_for @publication, :url => { :action => "create" } do |f| %>
1593
  <% f.error_messages %>
1594
1595
  <%= render :partial  => "#{@publication.current_step}_bibtex_step", :locals => { :f => f }  %>
1596
1597
  <p><%= f.submit "Submit" %></p>
1598
  <p><%= f.submit "Back", :name => "back_button" unless @publication.first_step? %></p>
1599
1600
<% end %>
1601
1602 638:c2481ae787f0 luis
<div class="contextual">
1603
  <% if User.current.allowed_to?(:add_publication, @project) %>
1604
	  <%= link_to l(:label_publication_new), {:controller => 'publications', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %>
1605
	<% end %>
1606 457:8aa775cb7c0a luis
</div>
1607 329:4575b631f6ce luis
1608 576:c5858d96b9a4 chris
  <% if @project %>
1609 691:f8d7e85ccd4e luis
    <h3><%= l(:label_all_publications_for_project, :project => @project.name) %></h3>
1610 576:c5858d96b9a4 chris
  <% else %>
1611 691:f8d7e85ccd4e luis
    <h3><%= l(:label_all_publications) %></h3>
1612 576:c5858d96b9a4 chris
  <% end %>
1613 424:b601a9e472f3 luis
1614 585:5818ebc11362 chris
  <div class="autoscroll">
1615
  <table class="list publications">
1616
    <thead><tr>
1617
      <th><%= l(:title) %></th>
1618
      <th><%= l(:authors) %></th>
1619 691:f8d7e85ccd4e luis
      <th><%= l(:year) %></th>
1620
      <th><%= l(:associated_projects) %></th>
1621 585:5818ebc11362 chris
    </tr></thead>
1622 457:8aa775cb7c0a luis
1623 692:dd366a17ab34 luis
    <%- @publications.each do |publication| -%>
1624
      <%- if publication.projects.visible.length > 0 -%>
1625
        <tr class="<%= cycle('odd', 'even') %>">
1626
          <td class="firstcol title" align="top"><%= link_to publication.title, :controller => "publications", :action => "show", :id => publication, :project_id => @project %></td>
1627
          <td class="authors" align="top">
1628 693:5163e3ec00b8 luis
            <%= render_authorships_list(publication) %>
1629 692:dd366a17ab34 luis
          <td class="year"><%= publication.bibtex_entry.year %></td>
1630
          <td class="projects">
1631
              <%= render_projects_list(publication, false) %>
1632
          </td>
1633
        </tr>
1634
      <%- end -%>
1635
    <%- end -%>
1636 457:8aa775cb7c0a luis
  </table>
1637 585:5818ebc11362 chris
  </div>
1638 457:8aa775cb7c0a luis
1639
<% content_for :sidebar do %>
1640
<% end %>
1641 576:c5858d96b9a4 chris
1642 545:a2c2b9f8380b luis
<% content_for :header_tags do %>
1643
    <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %>
1644 619:4ede44d53f76 chris
    <%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %>
1645 1391:8580d1d1150e luis
    <%= javascript_include_tag 'bibliography', :plugin => 'redmine_bibliography' -%>
1646
    <%= javascript_include_tag 'new_publication', :plugin => 'redmine_bibliography' -%>
1647 1409:3cb633d4b37d luis
1648 1391:8580d1d1150e luis
    <%= javascript_tag "
1649
      $('#publication_bibtex_entry_attributes_entry_type').live('change', function() {
1650
          $this = $(this);
1651
          $.ajax({
1652
              type: 'get',
1653
              url: '#{url_for(:controller => :publications, :action => :show_bibtex_fields)}',
1654
              data: {
1655
                  value: $this.val()
1656
              },
1657
              dataType: 'script'
1658
          });
1659
          return false;
1660
      });"-%>
1661
1662 1409:3cb633d4b37d luis
  <%= javascript_tag "authorship_autocomplete('#{url_for :controller => :publications, :action => :autocomplete_for_author}');" -%>
1663
1664 545:a2c2b9f8380b luis
<% end %>
1665 329:4575b631f6ce luis
1666 1391:8580d1d1150e luis
<%= error_messages_for 'publication' %>
1667
1668 545:a2c2b9f8380b luis
<h2><%=l(:label_publication_new)%></h2>
1669
1670 1422:c97b3b9b5c86 luis
<%= form_for @publication, :url => { :project_id  => @project, :action => :create } do |f| -%>
1671 1391:8580d1d1150e luis
1672 1274:5ea1a213c7a5 luis
    <%= render :partial => 'form', :locals => { :f => f }  %>
1673 1391:8580d1d1150e luis
1674 1274:5ea1a213c7a5 luis
    <div style="clear:both"></div>
1675
    <%= f.submit %>
1676 578:c8552c08687f chris
<% end %>
1677 1376:6ba24edae331 luis
<%= javascript_tag "$(document).ready(function(){
1678
1679
   $('#authorships').sortable({
1680
       axis: 'y',
1681
       dropOnEmpty: false,
1682
       handle: '.handle',
1683
       cursor: 'crosshair',
1684
       items: 'li',
1685
       opacity: 0.4,
1686
       scroll: true,
1687
       update: function(){
1688
          $.ajax({
1689
              type: 'post',
1690
              data: $('#authorships').sortable('serialize'),
1691
              dataType: 'script',
1692
              complete: function(request){
1693
                 $('#authorship').effect('highlight');
1694
              },
1695
                 url: '#{url_for(:controller => :authorships, :action => :sort)}'});
1696
              }
1697
          });
1698
     });
1699
" -%>
1700 1364:4d5d25039a5f luis
1701 545:a2c2b9f8380b luis
<h2><%=l(:label_publication_show)%></h2>
1702 464:fbdfec975bfa luis
1703 615:c4ddb9531f4c chris
<div class="box">
1704 946:a0c9cc95bcf3 luis
  <h3>Publication Info</h3>
1705 1068:e11d8d13ebc5 luis
  <p><%= print_ieee_format(@publication)%></p>
1706 1059:5617e630bf26 luis
1707 1037:d937100c4b4a chris
  <h3>B<small>IB</small>T<sub>E</sub>X Format</h3>
1708 1068:e11d8d13ebc5 luis
  <pre><%=h print_bibtex_format(@publication) %></pre>
1709 946:a0c9cc95bcf3 luis
</div>
1710 945:75351d69e2ba luis
1711 946:a0c9cc95bcf3 luis
<div class="box">
1712 329:4575b631f6ce luis
1713 471:49fb7a9ef79c luis
<h4><%= l(:authors) %></h4>
1714 1317:2805873c0147 luis
1715 471:49fb7a9ef79c luis
<ul id="authorships">
1716 556:ca9e8e562ea7 luis
  <% for authorship in @publication.authorships.find(:all, :order => :auth_order) %>
1717 1325:4ef7df804bab luis
    <%= content_tag_for :li, authorship do -%>
1718 1059:5617e630bf26 luis
      <%- if User.current.allowed_to?(:edit_publication, @project) && @publication.authorships.length > 1 -%>
1719 629:f9470a59e5da luis
        <span class="handle">[drag to reorder]</span>
1720
      <%- end -%>
1721 1325:4ef7df804bab luis
1722 1317:2805873c0147 luis
      <%= link_to_authorship authorship %> <em><%= h(authorship.institution) %></em>
1723 1325:4ef7df804bab luis
1724 1317:2805873c0147 luis
      <br />
1725 629:f9470a59e5da luis
    <%- end -%>
1726
  <%- end -%>
1727 471:49fb7a9ef79c luis
</ul>
1728 945:75351d69e2ba luis
1729 445:77f88379115a luis
<%- if @publication.bibtex_entry != nil -%>
1730 1323:e1899e896dbc luis
  <%= show_bibtex_fields(@publication.bibtex_entry).html_safe -%>
1731 445:77f88379115a luis
<%- end -%>
1732 425:4ecbc22579e2 luis
1733 1059:5617e630bf26 luis
<%- unless @publication.external_url.blank? -%>
1734 658:65749e700af0 luis
  <p>
1735 1059:5617e630bf26 luis
    <b><%= l(:field_external_url) %>:</b> <%= link_to h(@publication.external_url), @publication.external_url, {:target => "_blank"} -%>
1736
  </p>
1737
<%- end -%>
1738
1739
<% unless @publication.doi.blank? %>
1740
  <p>
1741
    <b><%= l(:field_doi)-%>:</b> <%= link_to h(@publication.doi), "http://dx.doi.org/#{@publication.doi}", {:target => "_blank"} -%>
1742 658:65749e700af0 luis
  </p>
1743
<% end %>
1744
1745 629:f9470a59e5da luis
<br / >
1746 1059:5617e630bf26 luis
  <% if User.current.allowed_to?(:add_publication, @project) %>
1747 626:e2663e0bd5a6 luis
    <%= link_to l(:label_publication_edit), { :controller => "publications", :action => "edit", :id => @publication, :project_id => @project } %> |
1748
    <%= link_to "Delete", {:controller => 'publications', :action => 'destroy', :id => @publication, :project_id => @project },
1749 560:735388da579a luis
                                                     :confirm => l(:text_are_you_sure), :method => :delete, :title => l(:button_delete) %> |
1750 626:e2663e0bd5a6 luis
  <% end %>
1751 639:cbad7075a60f luis
  <%= link_to l(:view_all_publications), {:controller => 'publications', :action => 'index', :project_id => @project } %>
1752 464:fbdfec975bfa luis
</div>
1753 452:34a6cf259682 luis
1754 464:fbdfec975bfa luis
<% projects = Project.active.find(:all, :limit => 100, :order => 'name ASC') - @publication.projects %>
1755 1059:5617e630bf26 luis
1756 615:c4ddb9531f4c chris
<% content_for :sidebar do %>
1757
  <h3><%=l(:label_publication_project_index)%></h3>
1758 629:f9470a59e5da luis
1759 464:fbdfec975bfa luis
  <p id="list_projects">
1760
    <%= render :partial => 'list_projects' %>
1761
  </p>
1762 1059:5617e630bf26 luis
1763 629:f9470a59e5da luis
  <%- if User.current.allowed_to?(:edit_publication, @project) -%>
1764 1059:5617e630bf26 luis
    <%= render :partial => 'add_project_form' %>
1765 629:f9470a59e5da luis
  <%- end -%>
1766 615:c4ddb9531f4c chris
<% end %>
1767 1274:5ea1a213c7a5 luis
fields = <%= @fields.to_json.html_safe -%>;
1768
1769
$.each($(".bibtex"), function( key, value ) {
1770
    $this = $(this);
1771
1772
    input_id = $this.children('input').attr('id');
1773
    name = input_id.split('_')[4];
1774
1775 1276:20a6b12d1aba luis
    if ($.inArray(name, fields) !== -1){
1776 1274:5ea1a213c7a5 luis
        $this.show();
1777
    }
1778 1276:20a6b12d1aba luis
    else{
1779
        $this.hide();
1780
    }
1781 1274:5ea1a213c7a5 luis
});
1782 328:aed18b463206 luis
<h2>Publications#update</h2>
1783 455:9761ee24f31d luis
<p><label>Menu caption</label>
1784
<%= text_field_tag 'settings[menu]', @settings['menu'], :size => 30 %>
1785
<br /><em>Clear this field if you don't want to add a tab to the project menu</em></p>
1786 694:f098cfb33721 luis
<%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %>
1787
1788
<div class="contextual">
1789
<%= link_to(l(:button_edit), edit_user_path(@user), :class => 'icon icon-edit') if User.current.admin? %>
1790
</div>
1791
1792
<h2><%= avatar @user, :size => "50" %> <%=h @user.name %></h2>
1793
1794
<div class="splitcontentleft">
1795
<ul>
1796
	<% unless @user.pref.hide_mail %>
1797
		<li><%=l(:field_mail)%>: <%= mail_to(h(@user.mail), nil, :encode => 'javascript') %></li>
1798
	<% end %>
1799
	<% @user.visible_custom_field_values.each do |custom_value| %>
1800
	<% if !custom_value.value.blank? %>
1801
    <li><%=h custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
1802
	<% end %>
1803
	<% end %>
1804
    <li><%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %></li>
1805
	<% unless @user.last_login_on.nil? %>
1806
		<li><%=l(:field_last_login_on)%>: <%= format_date(@user.last_login_on) %></li>
1807
	<% end %>
1808
</ul>
1809
1810
<h3><%=l(:label_ssamr_description)%></h3>
1811
<%= textilizable @description %>
1812
1813
<h3><%=l(:label_ssamr_institution)%></h3>
1814
<p><%= h @institution_name %></p>
1815
1816
1817
<% unless @memberships.empty? %>
1818
<h3><%=l(:label_project_plural)%></h3>
1819
<ul>
1820
<% for membership in @memberships %>
1821
	<li><%= link_to_project(membership.project) %>
1822
    (<%=h membership.roles.sort.collect(&:to_s).join(', ') %>, <%= format_date(membership.created_on) %>)</li>
1823
<% end %>
1824
</ul>
1825
<% end %>
1826
<%= call_hook :view_account_left_bottom, :user => @user %>
1827
</div>
1828
1829
<div class="splitcontentright">
1830
1831 708:37e39e437b2c chris
  <% if @user.author %>
1832 694:f098cfb33721 luis
  <div id="bibliography">
1833
    <% @publications = Publication.all(:include => :authors, :conditions => "authors.id = #{@user.author.id}") %>
1834
1835
    <h3><%=l(:publications) %> <%= "(" + @publications.count.to_s + ")" %> </h3>
1836
1837
    <% @publications.each do |publication|%>
1838
      <dt>
1839
        <span class="authors">
1840 721:7c7ef64e68da chris
          <%= publication.authorships.map { |a| h a.name_on_paper }.join(', ') %><% if !publication.authorships.empty? %>.<% end %>
1841 694:f098cfb33721 luis
        </span>
1842 721:7c7ef64e68da chris
        <span class="title"><%= link_to publication.title, :controller => 'publications', :action => 'show', :id => publication %></span>
1843 694:f098cfb33721 luis
        <% if publication.bibtex_entry.year.to_s != "" %>
1844
          <span class="year">
1845 721:7c7ef64e68da chris
            &nbsp;(<%= publication.bibtex_entry.year %>)
1846 694:f098cfb33721 luis
          </span>
1847
        <% end %>
1848 721:7c7ef64e68da chris
      </dt>
1849
      <dd>
1850 694:f098cfb33721 luis
      </dd>
1851
  	<% end %>
1852
  </div>
1853 708:37e39e437b2c chris
  <% end %>
1854 694:f098cfb33721 luis
1855
1856
<% unless @events_by_day.empty? %>
1857
<h3><%= link_to l(:label_activity), :controller => 'activities', :action => 'index', :id => nil, :user_id => @user, :from => @events_by_day.keys.first %></h3>
1858
1859
<p>
1860 1486:234d18ea18e9 Chris
<%=l(:label_reported_issues)%>: <%= Issue.where(:author_id => @user.id).count %>
1861 694:f098cfb33721 luis
</p>
1862
1863
<div id="activity">
1864
<% @events_by_day.keys.sort.reverse.each do |day| %>
1865
<h4><%= format_activity_day(day) %></h4>
1866
<dl>
1867
<% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%>
1868
  <dt class="<%= e.event_type %>">
1869
  <span class="time"><%= format_time(e.event_datetime, false) %></span>
1870
  <%= content_tag('span', h(e.project), :class => 'project') %>
1871
  <%= link_to format_activity_title(e.event_title), e.event_url %></dt>
1872
  <dd><span class="description"><%= format_activity_description(e.event_description) %></span></dd>
1873
<% end -%>
1874
</dl>
1875
<% end -%>
1876
</div>
1877
1878
<% other_formats_links do |f| %>
1879
	<%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => nil, :user_id => @user, :key => User.current.rss_key} %>
1880
<% end %>
1881
1882
<% content_for :header_tags do %>
1883
		<%= auto_discovery_link_tag(:atom, :controller => 'activities', :action => 'index', :user_id => @user, :format => :atom, :key => User.current.rss_key) %>
1884
<% end %>
1885
<% end %>
1886
<%= call_hook :view_account_right_bottom, :user => @user %>
1887
</div>
1888
1889
<% html_title @user.name %>
1890 1278:f8bb7ccc6fac luis
function add_author_fields(link, association, content, action) {
1891
    var new_id = new Date().getTime();
1892
    var regexp = new RegExp("new_" + association, "g");
1893
1894
    $(link).before(content.replace(regexp, new_id));
1895 469:ae87ae455cfb luis
}
1896
1897 1278:f8bb7ccc6fac luis
function remove_fields(link) {
1898
  $(link).prev("input[type=hidden]").val("1");
1899
  $(link).closest(".fields").hide();
1900 481:dd242ea99fd3 luis
}
1901
1902 1409:3cb633d4b37d luis
function authorship_autocomplete(url){
1903
    $(".author_name_on_paper").live('keyup.autocomplete', function(){
1904
         $this = $(this);
1905 1284:3ce07a57ce68 luis
1906 1409:3cb633d4b37d luis
         $this.autocomplete({
1907
            source: url,
1908
            minLength: 2,
1909
            focus: function(event, ui) {
1910
                $this.val(ui.item.label);
1911
                return false;
1912
            },
1913
            select: function(event, ui){
1914
                $this.closest('div').find("input[id$='institution']").val(ui.item.institution);
1915
                $this.closest('div').find("input[id$='email']").val(ui.item.email);
1916 1394:0f918e37e1d6 luis
1917 1409:3cb633d4b37d luis
                $this.closest('div').find("input[id$='search_author_class']").val(ui.item.  search_author_class);
1918
                $this.closest('div').find("input[id$='search_author_id']").val(ui.item. search_author_id);
1919 1407:00a51e442fe9 luis
1920 1409:3cb633d4b37d luis
                $this.closest('div').find("input[id$='search_author_tie']").attr('checked', '   checked');
1921 1427:2599a11ef11a luis
                $this.closest('div').find("input[id$='search_author_tie']").next('span').replaceWith("<span>" + ui.item.authorship_link + "</span>");
1922 1394:0f918e37e1d6 luis
1923 1409:3cb633d4b37d luis
                // triggers the save button
1924
                $this.closest('div').next('div').find('.author_save_btn').click();
1925
            }
1926
            })
1927
            .data( "autocomplete" )._renderItem = function( ul, item ) {
1928
                return $( "<li>" )
1929
                    .data("item.autocomplete", item )
1930
                    .append( "<a>" + item.label + "<br><em>" + item.email + "</em><br>" + item. institution + "</a>" )
1931
                    .appendTo(ul);
1932
                };
1933
            });
1934
}
1935 1379:1053a56bccec luis
// bibliography.js
1936
1937
function disable_fields(){
1938
	$this = $(this);
1939 1394:0f918e37e1d6 luis
1940 1379:1053a56bccec luis
	$author_info = $this.closest('div').prev();
1941 1394:0f918e37e1d6 luis
//    $author_info.children('.description').toggle();
1942 1379:1053a56bccec luis
	$author_info.find('p :input').attr("readonly", true);
1943 1380:fa92d13876d0 luis
    $author_info.find('p :input').addClass('readonly');
1944
1945 1407:00a51e442fe9 luis
    // Always hides on save
1946
    $this.closest('div').prev().find('p.search_author_tie').hide();
1947
1948 1380:fa92d13876d0 luis
    $this.siblings('.author_edit_btn').show();
1949
    $this.hide();
1950 1379:1053a56bccec luis
1951
    return false;
1952 1380:fa92d13876d0 luis
}
1953
1954
function enable_fields(){
1955
    $this = $(this);
1956 1394:0f918e37e1d6 luis
1957 1380:fa92d13876d0 luis
    $author_info = $this.closest('div').prev();
1958 1394:0f918e37e1d6 luis
//    $author_info.children('.description').toggle();
1959 1380:fa92d13876d0 luis
    $author_info.find('p :input').attr("readonly", false);
1960
    $author_info.find('p :input').removeClass('readonly');
1961
1962 1407:00a51e442fe9 luis
    // Always shows on edit
1963
    $this.closest('div').prev().find('p.search_author_tie').show();
1964
1965 1380:fa92d13876d0 luis
    $this.siblings('.author_save_btn').show();
1966
    $this.hide();
1967
1968
    return false;
1969
}
1970 1394:0f918e37e1d6 luis
1971 1017:63f8c4f2cf67 luis
1972 1313:17f075c7fd41 luis
$('.bibtex-link').live("click", function() {
1973
  $this = $(this);
1974
  $this.closest('dd').next('dd').toggle();
1975
});
1976 1389:641ec1b288a6 luis
// edit_publication.js
1977
1978
$(document).ready(function(){
1979
    // shows the correct bibtex fields
1980
    $('#publication_bibtex_entry_attributes_entry_type').trigger('change');
1981
1982
    // adds the events to the edit/save authorship button
1983
    $('.author_save_btn').live('click', disable_fields);
1984
    $('.author_edit_btn').live('click', enable_fields);
1985
1986
    // clicks all authorships
1987
    $('.author_save_btn').trigger('click');
1988
});
1989
// edit_publication.js
1990
1991
$(document).ready(function(){
1992
    // adds the events to the edit/save authorship button
1993
    $('.author_save_btn').live('click', disable_fields);
1994
    $('.author_edit_btn').live('click', enable_fields);
1995 1408:b09744f35f76 luis
1996
1997 1389:641ec1b288a6 luis
});
1998 558:c94e23a6eff1 luis
li .handle {
1999 619:4ede44d53f76 chris
    font-size: 12px;
2000
    cursor: move;
2001
    color: #777;
2002 603:7b39f35803f3 luis
}
2003
2004 1380:fa92d13876d0 luis
.readonly {
2005 619:4ede44d53f76 chris
    border: none;
2006 623:a434a588f16c chris
    padding: 0;
2007
    margin: 0;
2008 619:4ede44d53f76 chris
    background-color: transparent;
2009
}
2010
2011 623:a434a588f16c chris
.tabular .author_identify label {
2012 619:4ede44d53f76 chris
    font-weight: normal;
2013
}
2014 623:a434a588f16c chris
2015
.tabular .author_edit p {
2016
    padding-bottom: 0;
2017
}
2018
2019
.tabular .author_edit .description {
2020
    font-style: italic;
2021 1394:0f918e37e1d6 luis
    font-size: small;
2022 623:a434a588f16c chris
}
2023
2024 625:e1eb4996257f chris
.publication_project {
2025
    margin-right: 18px;
2026
}
2027 645:b83173d26d86 chris
2028 1039:f6c71883b995 chris
div#bibliography dd { margin-bottom: 1em; font-size: 0.9em; }
2029 1017:63f8c4f2cf67 luis
2030 645:b83173d26d86 chris
div#bibliography dd .authors { font-style: italic; }
2031
div#bibliography dd span.authors { color: #808080; }
2032
div#bibliography dd span.year { padding-left: 0.6em; }
2033
2034 1290:dd8b5f835522 luis
div#bibliography .box dt {
2035 1039:f6c71883b995 chris
  background: url(../../../images/document.png) no-repeat 0% 4px;
2036
  padding-left: 20px;
2037
  margin-left: 0;
2038 1017:63f8c4f2cf67 luis
}
2039 1290:dd8b5f835522 luis
div#bibliography .box dd {
2040 1039:f6c71883b995 chris
  padding-left: 20px;
2041
  margin-left: 0;
2042 1017:63f8c4f2cf67 luis
}
2043
2044 1290:dd8b5f835522 luis
div#bibliography h3 {
2045
  background: url(../../../images/table_multiple.png) no-repeat 0% 50%;
2046 1023:3d924264419a luis
  padding-left: 20px;
2047
}
2048 1017:63f8c4f2cf67 luis
2049 1023:3d924264419a luis
div#bibliography textarea {
2050
  width: 90%;
2051
  height: 200px;
2052
  font: normal 8px;
2053
  padding: 2px 10px;
2054 1290:dd8b5f835522 luis
  border: solid 1px #ddd;
2055 1037:d937100c4b4a chris
}
2056 1290:dd8b5f835522 luis
2057
input.author_search {width:100%}
2058
input.author_search {
2059 1291:97b98e7a6eee luis
  background: url(../../../images/magnifier.png) no-repeat 2px 50%; padding-left:20px;
2060 1290:dd8b5f835522 luis
  border:1px solid #9EB1C2; border-radius:3px; height:1.5em; width:95%;
2061
}
2062
input.author_search.ajax-loading {
2063 1291:97b98e7a6eee luis
  background-image: url(../../../images/loading.gif);
2064 1290:dd8b5f835522 luis
}
2065
2066 1407:00a51e442fe9 luis
.search_author_tie {
2067 1403:35732ac4324a luis
  display: none;
2068
  float: left;
2069 1380:fa92d13876d0 luis
}
2070 1408:b09744f35f76 luis
2071
.author_edit_btn {
2072
  display: none;
2073
}
2074 298:a41158bde9e0 luis
# English strings go here for Rails i18n
2075
en:
2076 842:899414bdd24e chris
  project_module_redmine_bibliography: "Publications (references to papers related to the project)"
2077 682:7e887544be06 chris
2078 427:de7c31d4cf9a luis
  title: "Title"
2079
  authors: "Authors"
2080
  author: "Author"
2081
  name: "Name"
2082 585:5818ebc11362 chris
  year: "Year"
2083 691:f8d7e85ccd4e luis
  associated_projects: "Associated Projects"
2084 531:baf26f9eb1cf luis
  publications_box: "My Publications"
2085 532:76d064830472 luis
  label_my_publications_box: "My Publications"
2086 626:e2663e0bd5a6 luis
  view_all_publications: "View All Project's Publications"
2087 694:f098cfb33721 luis
  publications: Publications
2088 1059:5617e630bf26 luis
2089 619:4ede44d53f76 chris
  identify_author_question: Is the right person selected above?
2090 618:18e0709fd0d9 luis
  identify_author_yes: "Yes"
2091 623:a434a588f16c chris
  identify_author_correct: "Yes, but I need to correct some details below"
2092
  identify_author_no: "No, the author was not found in the search"
2093 576:c5858d96b9a4 chris
2094 686:b1debf464389 luis
  error_no_authors: "Please add at least one author to this publication."
2095
2096 576:c5858d96b9a4 chris
  label_all_publications: All Publications
2097
  label_all_publications_for_project: Publications associated with %{project}
2098 698:bd88afe21831 chris
  label_authors_show: "Authorships associated with this author"
2099 613:3b63cea01e7b luisf
  label_authors_index: "List of authors"
2100 1059:5617e630bf26 luis
2101 702:3eb64cb3c7ac chris
  field_authorship_publication_title: "Publication"
2102
  field_authorship_name: "Name on Paper"
2103
  field_authorship_email: "Email"
2104 612:8fa35731c959 luis
  field_authorship_institution: "Institution"
2105 1059:5617e630bf26 luis
2106 658:65749e700af0 luis
  field_external_url: "External URL"
2107 1059:5617e630bf26 luis
  field_doi: "DOI"
2108 534:cdec3eeaef7e luis
  field_publication_title: Title
2109
  field_publication_authors: Authors
2110 645:b83173d26d86 chris
  field_publication_projects: "Associated projects"
2111 540:951fcb1711f2 luis
  field_author_name: Author
2112 573:aed210f6095b chris
  field_author_user: User Name
2113 645:b83173d26d86 chris
  field_author_username: "Associated user"
2114 1059:5617e630bf26 luis
  field_author_publications: "Publications by this Author"
2115 597:70f0276fde9a luis
  field_identify_author_yes: "Yes"
2116
  field_identify_author_correct: "Corrections"
2117
  field_identify_author_no: "No"
2118 1059:5617e630bf26 luis
2119 573:aed210f6095b chris
  label_author_is_me: "(I am this author)"
2120 472:0ce4139187fa luis
  label_add_me_as_author: "Add me as an author"
2121 578:c8552c08687f chris
  label_add_an_author: "Add an author"
2122 472:0ce4139187fa luis
  label_add_another_author: "Add another author"
2123 615:c4ddb9531f4c chris
  field_search_name: "Search by name"
2124
  field_search_results: ""
2125 623:a434a588f16c chris
  label_save_author: "Save author"
2126 660:e40cd3570ebc luis
  label_edit_author: "Edit author"
2127 601:1608b3cb50cd luis
  label_author_information: "Author Information"
2128 449:d643b4186e4c luis
2129 471:49fb7a9ef79c luis
  remove_author: "Remove this author"
2130 1059:5617e630bf26 luis
2131 642:8c88a15a701e chris
  label_publication_plural: "Publications"
2132
  label_related_publication_plural: "Related publications"
2133 545:a2c2b9f8380b luis
  label_publication_new: "Create New Publication"
2134 550:2df99e8d191e luis
  label_publication_index: "List of Publication"
2135 576:c5858d96b9a4 chris
  label_add_publication_to_project: "Add publication to this project"
2136 545:a2c2b9f8380b luis
  label_publication_edit: "Edit Publication"
2137
  label_publication_show: "Publication Details"
2138 576:c5858d96b9a4 chris
  label_add_project_to_publication: "Add this publication to a project"
2139
  label_project_search: "Find project by name: "
2140 547:56ad0c490f5e luis
  label_publication_project_index: "Projects associated with this publication"
2141
  label_publication_index: "View all publications"
2142 615:c4ddb9531f4c chris
  label_publication_other_details: "Details"
2143 1059:5617e630bf26 luis
2144 661:6246ad0f9e98 chris
  text_external_url: "Link to the publication or to an external page about it."
2145 1059:5617e630bf26 luis
  text_doi: "DOI (Digital Object Identifier)."
2146 619:4ede44d53f76 chris
  text_author_name_on_paper: "Author's name as it appears on the paper."
2147
  text_author_institution: "Author's institution as on the paper."
2148 477:aeedcec4df5f luis
  text_author_email: "Author's email address as on the paper."
2149 1059:5617e630bf26 luis
2150 591:9e866f13c984 luis
  text_author_search: "Search existing authors"
2151 1059:5617e630bf26 luis
2152 471:49fb7a9ef79c luis
  # authorships model
2153 544:f05f3a9ef569 luis
  field_institution: "Institution"
2154 1059:5617e630bf26 luis
  field_name_on_paper: "Name"
2155 544:f05f3a9ef569 luis
  field_email: "Email Address"
2156 1059:5617e630bf26 luis
2157 471:49fb7a9ef79c luis
  # bibtex_entries model
2158 573:aed210f6095b chris
  field_entry_type: "Publication Type"
2159 1059:5617e630bf26 luis
  field_id: "id"
2160 544:f05f3a9ef569 luis
  field_publication_id: "Publication_id"
2161
  field_address: "Address"
2162
  field_annote: "Annote"
2163 702:3eb64cb3c7ac chris
  field_booktitle: "Title of Book or Proceedings"
2164 544:f05f3a9ef569 luis
  field_chapter: "Chapter"
2165
  field_crossref: "Cross Reference"
2166
  field_edition: "Edition"
2167
  field_editor: "Editor"
2168
  field_eprint: "eprint"
2169
  field_howpublished: "How was it Published"
2170
  field_journal: "Journal"
2171
  field_key: "Key"
2172
  field_month: "Month"
2173
  field_note: "Note"
2174
  field_number: "Number"
2175
  field_organization: "Organization"
2176
  field_pages: "Pages"
2177
  field_publisher: "Publisher"
2178
  field_school: "School"
2179
  field_series: "Series"
2180
  field_type: "Type"
2181
  field_url: "URL"
2182
  field_volume: "Volume"
2183
  field_year: "Year"
2184 586:658cfb481618 chris
2185
  field_bibtex_article: Journal article
2186
  field_bibtex_book: Book
2187
  field_bibtex_booklet: Booklet
2188
  field_bibtex_conference: Article in conference proceedings
2189
  field_bibtex_inbook: Book chapter or part
2190
  field_bibtex_incollection: Part of a collection
2191
  field_bibtex_inproceedings: Article in conference proceedings
2192
  field_bibtex_manual: Technical manual
2193
  field_bibtex_masterthesis: "Master's thesis"
2194
  field_bibtex_misc: Other
2195
  field_bibtex_phdthesis: "PhD thesis"
2196
  field_bibtex_proceedings: Conference proceedings
2197
  field_bibtex_techreport: Technical report
2198
  field_bibtex_unpublished: Unpublished
2199 1059:5617e630bf26 luis
2200 573:aed210f6095b chris
  label_author_1: First author
2201
  label_author_2: Second author
2202
  label_author_3: Third author
2203
  label_author_4: Fourth author
2204
  label_author_5: Fifth author
2205
  label_author_6: Sixth author
2206
  label_author_7: Seventh author
2207
  label_author_8: Eighth author
2208
  label_author_9: Ninth author
2209
  label_author_10: Tenth author
2210
  label_author_11: Eleventh author
2211
  label_author_12: Twelfth author
2212
  label_author_13: Thirteenth author
2213
  label_author_14: Fourteenth author
2214
  label_author_15: Fifteenth author
2215
  label_author_16: Sixteenth author
2216
  label_author_17: Seventeenth author
2217
  label_author_18: Eighteenth author
2218
  label_author_19: Nineteenth author
2219
  label_author_20: Twentieth author
2220
2221 667:764e3dfb173b chris
  mail_subject_publication_added: "You have been added as an author to a new publication"
2222
  mail_body_publication_added: "A new publication (%{publication}) has been added to the project '%{project}.'"
2223 1059:5617e630bf26 luis
2224 1313:17f075c7fd41 luis
  bibtex_link: "[B<small>IB</small>T<sub>E</sub>X]"
2225
  more_details_link: "[More Details]"
2226 1352:939f4a491900 luis
  external_url_link: "[URL (ext.)]"
2227 1059:5617e630bf26 luis
2228 1130:f589996baa51 luis
RedmineApp::Application.routes.draw do
2229 1282:8d30e7644b75 luis
    match "publications/show_bibtex_fields", :to => 'publications#show_bibtex_fields', :via => "get"
2230 1274:5ea1a213c7a5 luis
2231 1282:8d30e7644b75 luis
    match "publications/autocomplete_for_author", :to => 'publications#autocomplete_for_author', :via => "get"
2232 1274:5ea1a213c7a5 luis
2233 1306:af51e7e3e846 luis
    match "authors/show/:id", :to => 'authors#show'
2234
2235 1317:2805873c0147 luis
    match "publications/add_project/:id", :to => 'publications#add_project'
2236 1306:af51e7e3e846 luis
2237 1324:2e54ae6ab02f luis
    match "publications/autocomplete_for_project", :to => 'publications#autocomplete_for_project'
2238
2239 1364:4d5d25039a5f luis
    resources :authorships do
2240
        collection do
2241
            post 'sort', :action => 'sort'
2242
        end
2243
    end
2244 1306:af51e7e3e846 luis
2245 1282:8d30e7644b75 luis
    resources :publications
2246 444:b461f84ed41a luis
end
2247 328:aed18b463206 luis
class CreateAuthors < ActiveRecord::Migration
2248
  def self.up
2249
    create_table :authors do |t|
2250
      t.column :user_id, :integer
2251 406:40144aa9dfe7 luis
      t.column :name, :string
2252 328:aed18b463206 luis
    end
2253
  end
2254
2255
  def self.down
2256
    drop_table :authors
2257
  end
2258
end
2259
class CreatePublications < ActiveRecord::Migration
2260
  def self.up
2261
    create_table :publications do |t|
2262
      t.column :title, :string
2263 408:cd3158bf28b5 luis
      t.column :reviewed, :boolean, :default => false
2264 328:aed18b463206 luis
    end
2265
  end
2266
2267
  def self.down
2268
    drop_table :publications
2269
  end
2270
end
2271
class CreateAuthorships < ActiveRecord::Migration
2272
  def self.up
2273
    create_table :authorships do |t|
2274
      t.column :author_id, :integer
2275
      t.column :publication_id, :integer
2276
      t.column :name_on_paper, :string
2277 556:ca9e8e562ea7 luis
      t.column :auth_order, :integer
2278 328:aed18b463206 luis
      t.column :institution, :string
2279
      t.column :email, :string
2280
    end
2281
  end
2282
2283
  def self.down
2284
    drop_table :authorships
2285
  end
2286
end
2287 392:b97577523b0c luis
class CreateBibtexEntries < ActiveRecord::Migration
2288
  def self.up
2289
    create_table :bibtex_entries do |t|
2290 402:ef8a9bc67e15 luis
      t.column :publication_id, :integer
2291 542:23a9272bf766 luis
      t.column :entry_type, :integer
2292 392:b97577523b0c luis
      t.column :address, :string
2293
      t.column :annote, :string
2294
      t.column :booktitle, :string
2295
      t.column :chapter, :string
2296
      t.column :crossref, :string
2297
      t.column :edition, :string
2298
      t.column :editor, :string
2299
      t.column :eprint, :string
2300
      t.column :howpublished, :string
2301
      t.column :journal, :string
2302
      t.column :key, :string
2303
      t.column :month, :string
2304
      t.column :note, :text
2305
      t.column :number, :string
2306
      t.column :organization, :string
2307
      t.column :pages, :string
2308
      t.column :publisher, :string
2309
      t.column :school, :string
2310
      t.column :series, :string
2311
      t.column :type, :string
2312
      t.column :url, :string
2313
      t.column :volume, :integer
2314
      t.column :year, :integer
2315
    end
2316
  end
2317
2318
  def self.down
2319
    drop_table :bibtex_entries
2320
  end
2321
end
2322 453:2daa350e1da2 luis
class CreateProjectsPublicationsJoinTable < ActiveRecord::Migration
2323
  def self.up
2324
    create_table :projects_publications, :id => false do |t|
2325
      t.integer :project_id
2326
      t.integer :publication_id
2327
    end
2328
  end
2329
2330
  def self.down
2331
    drop_table :projects_publications
2332
  end
2333
end
2334 542:23a9272bf766 luis
class CreateBibtexEntryTypes < ActiveRecord::Migration
2335
  def self.up
2336
    create_table :bibtex_entry_types do |t|
2337
      t.string :name
2338
2339
      t.timestamps
2340
    end
2341
  end
2342
2343
  def self.down
2344
    drop_table :bibtex_entry_types
2345
  end
2346
end
2347 656:6fe283d584cf luis
class AddExternalUrlColumnToPublications < ActiveRecord::Migration
2348
  def self.up
2349
    add_column :publications, :external_url, :string
2350
  end
2351
2352
  def self.down
2353
    remove_column :publications, :external_url
2354
  end
2355
end
2356 1055:b6f7225bf954 luis
class AddDoiAndTimestampColumnsToPublications < ActiveRecord::Migration
2357
  def self.up
2358
    add_column :publications, :doi, :string
2359
    add_timestamps :publications
2360
2361
  end
2362
2363
  def self.down
2364
    remove_column :publications, :doi
2365
    remove_timestamps :publications
2366
  end
2367
end
2368 1056:6b67deb0674b luis
class AddTimestampColumnsToAuthors < ActiveRecord::Migration
2369
  def self.up
2370
    add_timestamps :authors
2371
  end
2372
2373
  def self.down
2374
    remove_timestamps :authors
2375
  end
2376
end
2377 586:658cfb481618 chris
inproceedings
2378
conference
2379 543:85dd79181088 luis
article
2380 586:658cfb481618 chris
masterthesis
2381
phdthesis
2382 543:85dd79181088 luis
book
2383
booklet
2384
inbook
2385
incollection
2386
manual
2387 586:658cfb481618 chris
techreport
2388
proceedings
2389
unpublished
2390 543:85dd79181088 luis
misc
2391 298:a41158bde9e0 luis
require 'redmine'
2392 454:2f1a308c4c11 luis
2393 945:75351d69e2ba luis
require 'bibtex'
2394
require 'citeproc'
2395 1580:fa3d9c22497c Chris
require 'citeproc/ruby'
2396
require 'csl/styles'
2397 945:75351d69e2ba luis
2398 454:2f1a308c4c11 luis
# Patches to the Redmine core.
2399 1127:736d01c1d2d0 luis
ActionDispatch::Callbacks.to_prepare do
2400 454:2f1a308c4c11 luis
  require_dependency 'project'
2401 466:a7dc708d48a1 luis
  require_dependency 'user'
2402 651:f029431de4dd luis
  require_dependency 'mailer'
2403 454:2f1a308c4c11 luis
2404
  unless Project.included_modules.include? Bibliography::ProjectPublicationsPatch
2405
    Project.send(:include, Bibliography::ProjectPublicationsPatch)
2406
  end
2407 466:a7dc708d48a1 luis
2408 483:cc267eb99115 luis
  unless User.included_modules.include? Bibliography::UserAuthorPatch
2409
    User.send(:include, Bibliography::UserAuthorPatch)
2410 466:a7dc708d48a1 luis
  end
2411 649:0aef0738823b luis
2412 651:f029431de4dd luis
  unless Mailer.included_modules.include? Bibliography::MailerPatch
2413
    Mailer.send(:include, Bibliography::MailerPatch)
2414 649:0aef0738823b luis
  end
2415
2416 1070:858f042e8d11 luis
  unless ProjectsHelper.included_modules.include?(Bibliography::ProjectsHelperPatch)
2417
    ProjectsHelper.send(:include, Bibliography::ProjectsHelperPatch)
2418 1068:e11d8d13ebc5 luis
  end
2419 1234:e0167f4e1d8a chris
2420
  unless MyHelper.included_modules.include?(Bibliography::MyHelperPatch)
2421
    MyHelper.send(:include, Bibliography::MyHelperPatch)
2422
  end
2423 454:2f1a308c4c11 luis
end
2424 298:a41158bde9e0 luis
2425 455:9761ee24f31d luis
2426
# Plugin Info
2427 298:a41158bde9e0 luis
Redmine::Plugin.register :redmine_bibliography do
2428
  name 'Redmine Bibliography plugin'
2429
  author 'Chris Cannam, Luis Figueira'
2430 455:9761ee24f31d luis
  description 'This is a bibliography management plugin for Redmine'
2431 298:a41158bde9e0 luis
  version '0.0.1'
2432
  url 'http://example.com/path/to/plugin'
2433
  author_url 'http://example.com/about'
2434 376:ad71d0604ac2 luis
2435 835:7240e0419aac chris
  settings :default => { 'menu' => 'Publications' }, :partial => 'settings/bibliography'
2436 454:2f1a308c4c11 luis
2437 455:9761ee24f31d luis
  project_module :redmine_bibliography do
2438 1087:74407a04925c luis
    permission :view_publication, {:publications => :show}, :public => :true
2439 630:d91ee0e196e5 luis
    permission :publications, { :publications => :index }, :public => true
2440
    permission :edit_publication, {:publications => [:edit, :update]}
2441
    permission :add_publication, {:publications => [:new, :create]}
2442 632:84a746383a5b luis
    permission :delete_publication, {:publications => :destroy}
2443
2444 1087:74407a04925c luis
2445 455:9761ee24f31d luis
  end
2446 454:2f1a308c4c11 luis
2447 455:9761ee24f31d luis
  # extending the Project Menu
2448 456:773fe1222605 luis
  menu :project_menu, :publications, { :controller => 'publications', :action => 'index', :path => nil }, :after => :activity, :param => :project_id, :caption => Proc.new { Setting.plugin_redmine_bibliography['menu'] },
2449 455:9761ee24f31d luis
   :if => Proc.new { !Setting.plugin_redmine_bibliography['menu'].blank? }
2450 1068:e11d8d13ebc5 luis
2451 1080:5bd8c86cfa6a luis
  activity_provider :publication, :class_name => 'Publication', :default => true
2452
2453 614:712324fee0c0 luis
end
2454 1080:5bd8c86cfa6a luis
2455
2456
2457 298:a41158bde9e0 luis
# English strings go here
2458
my_label: "My label"
2459 651:f029431de4dd luis
require_dependency 'mailer'
2460
2461
module Bibliography
2462
  module MailerPatch
2463
      def self.included(base) # :nodoc:
2464
2465 1400:581999ce44ea luis
        # Builds a tmail object used to email the specified user that a publication was created and the user is
2466 651:f029431de4dd luis
        # an author of that publication
2467
        #
2468
        # Example:
2469
        #   publication_added(user) => tmail object
2470
        #   Mailer.deliver_add_to_project(user) => sends an email to the registered user
2471 666:865d079e5fa0 luis
        def publication_added(user, publication, project)
2472 651:f029431de4dd luis
2473
          @publication = publication
2474 666:865d079e5fa0 luis
          @project = project
2475 651:f029431de4dd luis
2476
          set_language_if_valid user.language
2477 666:865d079e5fa0 luis
2478 1400:581999ce44ea luis
          mail :to => user.mail,
2479 1513:a59e53e4f006 Chris
          :subject => l(:mail_subject_publication_added, Setting.app_title)
2480 666:865d079e5fa0 luis
2481 1400:581999ce44ea luis
          @publication_url = url_for( :controller => 'publications', :action => 'show', :id => publication.id )
2482
          @publication_title = publication.title
2483 651:f029431de4dd luis
        end
2484 1400:581999ce44ea luis
2485
2486 651:f029431de4dd luis
    end
2487
  end
2488
end
2489 1234:e0167f4e1d8a chris
module Bibliography
2490
  module MyHelperPatch
2491 535:dd9d9c0ff0f9 luis
2492 1234:e0167f4e1d8a chris
    def self.included(base) # :nodoc:
2493
      base.send(:include, InstanceMethods)
2494
2495
      base.class_eval do
2496
        unloadable
2497
      end
2498 535:dd9d9c0ff0f9 luis
    end
2499
2500 1234:e0167f4e1d8a chris
    module InstanceMethods
2501
2502
      def get_my_publications()
2503
        if not User.current.author.nil?
2504
          @my_publications = Publication.all(:include => :authors, :conditions => "authors.id = #{User.current.author.id}")
2505
        else
2506
          @my_publications = []
2507
        end
2508
      end
2509
2510
      def render_publications_projects(publication)
2511
        s = ""
2512
        projs = []
2513
2514
        publication.projects.each do |proj|
2515
          projs << link_to(proj.name, proj)
2516
        end
2517
2518
        s << projs.join(', ')
2519
2520
        s.html_safe
2521
      end
2522
2523
      def render_publications_authors(publication)
2524
        s = ""
2525
        auths = []
2526
2527
        publication.authorships.each do |auth|
2528
          auths << h(auth.name_on_paper)
2529
        end
2530
2531
        s << auths.join(', ')
2532
2533
        s.html_safe
2534
      end
2535
2536
2537 535:dd9d9c0ff0f9 luis
    end
2538
  end
2539 1234:e0167f4e1d8a chris
end
2540 535:dd9d9c0ff0f9 luis
2541 454:2f1a308c4c11 luis
require_dependency 'project'
2542
2543
module Bibliography
2544
  module ProjectPublicationsPatch
2545
    def self.included(base)
2546
          base.class_eval do
2547 464:fbdfec975bfa luis
            has_and_belongs_to_many :publications, :uniq => true
2548 1123:48c5fdd6cf10 luis
2549 1253:29dd06e01be3 luis
            scope :name_or_homepage_like, lambda {|q|
2550 461:841b2e40895d luis
              s = "%#{q.to_s.strip.downcase}%"
2551 462:b02b2eb2a312 luis
              {:conditions => ["LOWER(name) LIKE :s OR LOWER(homepage) LIKE :s", {:s => s}],
2552 461:841b2e40895d luis
               :order => 'name'
2553
              }
2554
            }
2555 454:2f1a308c4c11 luis
          end
2556 461:841b2e40895d luis
    end #self.included
2557 1123:48c5fdd6cf10 luis
2558 461:841b2e40895d luis
    module ProjectMethods
2559
2560
2561
2562 1123:48c5fdd6cf10 luis
2563 461:841b2e40895d luis
    end #ProjectMethods
2564 454:2f1a308c4c11 luis
  end #ProjectPublicationsPatch
2565
end #RedmineBibliography
2566 1070:858f042e8d11 luis
module Bibliography
2567
  module ProjectsHelperPatch
2568
2569
    def self.included(base) # :nodoc:
2570
      base.send(:include, InstanceMethods)
2571
      base.send(:include, PublicationsHelper)
2572
2573
      base.class_eval do
2574
        unloadable
2575
      end
2576
    end
2577
2578
    module InstanceMethods
2579
    end
2580
  end
2581
end
2582
2583 466:a7dc708d48a1 luis
require_dependency 'user'
2584
2585
module Bibliography
2586 1070:858f042e8d11 luis
  module UserAuthorPatch
2587 466:a7dc708d48a1 luis
    def self.included(base)
2588 1070:858f042e8d11 luis
      base.send(:include, InstanceMethods)
2589 1441:8d721cac2925 luis
2590
      base.class_eval do
2591
        # adapted from the app/models/principals_model.rb
2592
        # to remove the email address from the search
2593
        scope :name_like, lambda {|q|
2594
          q = q.to_s
2595
          if q.blank?
2596
            where({})
2597
          else
2598
            pattern = "%#{q}%"
2599
            sql = %w(login firstname lastname).map {|column| "LOWER(#{  table_name}.    #{column}) LIKE LOWER(:p)"}.join(" OR ")
2600
            params = {:p => pattern}
2601
            if q =~ /^(.+)\s+(.+)$/
2602
              a, b = "#{$1}%", "#{$2}%"
2603
              sql << " OR (LOWER(#{table_name}.firstname) LIKE LOWER(:a) AND  LOWER    (#{table_name}.lastname) LIKE LOWER(:b))"
2604
              sql << " OR (LOWER(#{table_name}.firstname) LIKE LOWER(:b) AND  LOWER    (#{table_name}.lastname) LIKE LOWER(:a))"
2605
              params.merge!(:a => a, :b => b)
2606
            end
2607
          where(sql, params)
2608
          end
2609
        }
2610
      end #base.class_eval
2611 1070:858f042e8d11 luis
2612 466:a7dc708d48a1 luis
    end #self.included
2613 1070:858f042e8d11 luis
2614 483:cc267eb99115 luis
    module InstanceMethods
2615 518:b24091590b63 luis
2616 1441:8d721cac2925 luis
      # todo: deprecated? ~lf.20131011
2617 600:c3c1091639ad luis
      def institution
2618
        unless self.ssamr_user_detail.nil?
2619
          institution_name = self.ssamr_user_detail.institution_name
2620
        else
2621
          institution_name = "No Institution Set"
2622 1070:858f042e8d11 luis
        end
2623
        return institution_name
2624 600:c3c1091639ad luis
      end
2625
2626 483:cc267eb99115 luis
    end #InstanceMethods
2627 1070:858f042e8d11 luis
2628 466:a7dc708d48a1 luis
  end #UserPublicationsPatch
2629 567:5404f7dfb4b3 chris
end #RedmineBibliography
2630 542:23a9272bf766 luis
namespace :redmine do
2631
  namespace :plugins do
2632
    namespace :redmine_bibliography do
2633
2634
      task :seed_bibtex_entry_types  => :environment do
2635
        desc "Seeds the Bibtex Entry Types Table"
2636
2637
        quoted = ActiveRecord::Base.connection.quote_table_name('bibtex_entry_types')
2638
        ActiveRecord::Base.connection.execute("TRUNCATE #{quoted}")
2639
2640
        open(File.dirname(__FILE__) + "/../../db/seed_data/bibtex_entry_types_list.txt") do |bibtex_entry_types|
2641
          bibtex_entry_types.read.each_line do |bibtex_entry_type|
2642 543:85dd79181088 luis
            BibtexEntryType.create(:name => bibtex_entry_type.chomp)
2643 542:23a9272bf766 luis
          end
2644
        end
2645
      end
2646
2647
    end
2648
  end
2649
end
2650 1371:a8d468e143f7 luis
# authors.yml
2651
---
2652 328:aed18b463206 luis
one:
2653
  id: 1
2654 1370:0b169a5e3837 luis
  user_id: 1
2655 1371:a8d468e143f7 luis
  name:
2656 328:aed18b463206 luis
two:
2657
  id: 2
2658 1370:0b169a5e3837 luis
  user_id:
2659 1371:a8d468e143f7 luis
  name:
2660 1370:0b169a5e3837 luis
three:
2661 424:b601a9e472f3 luis
  id: 3
2662 1370:0b169a5e3837 luis
  user_id:
2663 1371:a8d468e143f7 luis
  name:
2664 1370:0b169a5e3837 luis
four:
2665 424:b601a9e472f3 luis
  id: 4
2666 1370:0b169a5e3837 luis
  user_id:
2667 1371:a8d468e143f7 luis
  name:
2668
# authorships.yml
2669
---
2670 328:aed18b463206 luis
one:
2671
  id: 1
2672 424:b601a9e472f3 luis
  author_id: 1
2673
  publication_id: 1
2674
  name_on_paper: Yih-Farn R. Chen
2675 1371:a8d468e143f7 luis
  auth_order: 1
2676
  institution: Imperial College London
2677 1372:a8832968d927 luis
  email: chen@imperial.ac.uk
2678 328:aed18b463206 luis
two:
2679
  id: 2
2680 424:b601a9e472f3 luis
  author_id: 2
2681
  publication_id: 1
2682
  name_on_paper: Glenn S. Fowler
2683 1371:a8d468e143f7 luis
  auth_order: 2
2684 1370:0b169a5e3837 luis
  institution:
2685 328:aed18b463206 luis
  email: MyString
2686 424:b601a9e472f3 luis
three:
2687
  id: 3
2688 1371:a8d468e143f7 luis
  author_id: 3
2689 424:b601a9e472f3 luis
  publication_id: 1
2690 1372:a8832968d927 luis
  name_on_paper: Jackie Brown
2691 1371:a8d468e143f7 luis
  auth_order: 1
2692 1370:0b169a5e3837 luis
  institution:
2693 1372:a8832968d927 luis
  email: j.brown@m.com
2694 424:b601a9e472f3 luis
four:
2695
  id: 4
2696 1371:a8d468e143f7 luis
  author_id: 4
2697 424:b601a9e472f3 luis
  publication_id: 1
2698 1372:a8832968d927 luis
  name_on_paper: Captain Boomtime
2699 1371:a8d468e143f7 luis
  auth_order: 2
2700 1370:0b169a5e3837 luis
  institution:
2701 1372:a8832968d927 luis
  email: cpt.boom@time.co.uk
2702
five:
2703
  id: 5
2704
  author_id: 1
2705
  publication_id: 2
2706
  name_on_paper: Yih-Farn Chen
2707
  auth_order: 1
2708
  institution: "Imperial College, London"
2709
  email: yfc@gmail.com
2710
# bibtex_entries.yml
2711
---
2712 393:9595ab4cac6b luis
one:
2713
  id: 1
2714 424:b601a9e472f3 luis
  entry_type: InProceedings
2715
  booktitle: International Conference on Software Maintenance
2716
  year: 1995
2717 328:aed18b463206 luis
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2718
one:
2719 1371:a8d468e143f7 luis
    id: 1
2720
    title: Publication Number 1
2721
    reviewed: true
2722
    external_url:
2723
    doi:
2724 328:aed18b463206 luis
two:
2725 1371:a8d468e143f7 luis
    id: 2
2726
    title: Publication Number 2
2727
    reviewed: false
2728
    external_url:
2729
    doi:
2730
# users.yml
2731
---
2732
users_004:
2733 1370:0b169a5e3837 luis
  created_on: 2006-07-19 19:34:07 +02:00
2734
  status: 1
2735 1371:a8d468e143f7 luis
  last_login_on:
2736 1370:0b169a5e3837 luis
  language: en
2737
  # password = foo
2738
  salt: 3126f764c3c5ac61cbfc103f25f934cf
2739
  hashed_password: 9e4dd7eeb172c12a0691a6d9d3a269f7e9fe671b
2740
  updated_on: 2006-07-19 19:34:07 +02:00
2741
  admin: false
2742
  mail: rhill@somenet.foo
2743
  lastname: Hill
2744
  firstname: Robert
2745
  id: 4
2746 1371:a8d468e143f7 luis
  auth_source_id:
2747 1370:0b169a5e3837 luis
  mail_notification: all
2748
  login: rhill
2749
  type: User
2750 1371:a8d468e143f7 luis
users_001:
2751 1370:0b169a5e3837 luis
  created_on: 2006-07-19 19:12:21 +02:00
2752
  status: 1
2753
  last_login_on: 2006-07-19 22:57:52 +02:00
2754
  language: en
2755
  # password = admin
2756
  salt: 82090c953c4a0000a7db253b0691a6b4
2757
  hashed_password: b5b6ff9543bf1387374cdfa27a54c96d236a7150
2758
  updated_on: 2006-07-19 22:57:52 +02:00
2759
  admin: true
2760
  mail: admin@somenet.foo
2761
  lastname: Admin
2762
  firstname: redMine
2763
  id: 1
2764 1371:a8d468e143f7 luis
  auth_source_id:
2765 1370:0b169a5e3837 luis
  mail_notification: all
2766
  login: admin
2767
  type: User
2768 1371:a8d468e143f7 luis
users_002:
2769 1370:0b169a5e3837 luis
  created_on: 2006-07-19 19:32:09 +02:00
2770
  status: 1
2771
  last_login_on: 2006-07-19 22:42:15 +02:00
2772
  language: en
2773
  # password = jsmith
2774
  salt: 67eb4732624d5a7753dcea7ce0bb7d7d
2775
  hashed_password: bfbe06043353a677d0215b26a5800d128d5413bc
2776
  updated_on: 2006-07-19 22:42:15 +02:00
2777
  admin: false
2778
  mail: jsmith@somenet.foo
2779
  lastname: Smith
2780
  firstname: John
2781
  id: 2
2782 1371:a8d468e143f7 luis
  auth_source_id:
2783 1370:0b169a5e3837 luis
  mail_notification: all
2784
  login: jsmith
2785
  type: User
2786 1371:a8d468e143f7 luis
users_003:
2787 1370:0b169a5e3837 luis
  created_on: 2006-07-19 19:33:19 +02:00
2788
  status: 1
2789 1371:a8d468e143f7 luis
  last_login_on:
2790 1370:0b169a5e3837 luis
  language: en
2791
  # password = foo
2792
  salt: 7599f9963ec07b5a3b55b354407120c0
2793
  hashed_password: 8f659c8d7c072f189374edacfa90d6abbc26d8ed
2794
  updated_on: 2006-07-19 19:33:19 +02:00
2795
  admin: false
2796
  mail: dlopper@somenet.foo
2797
  lastname: Lopper
2798
  firstname: Dave
2799
  id: 3
2800 1371:a8d468e143f7 luis
  auth_source_id:
2801 1370:0b169a5e3837 luis
  mail_notification: all
2802
  login: dlopper
2803
  type: User
2804 1371:a8d468e143f7 luis
users_005:
2805 1370:0b169a5e3837 luis
  id: 5
2806
  created_on: 2006-07-19 19:33:19 +02:00
2807
  # Locked
2808
  status: 3
2809 1371:a8d468e143f7 luis
  last_login_on:
2810 1370:0b169a5e3837 luis
  language: en
2811
  hashed_password: 1
2812
  updated_on: 2006-07-19 19:33:19 +02:00
2813
  admin: false
2814
  mail: dlopper2@somenet.foo
2815
  lastname: Lopper2
2816
  firstname: Dave2
2817 1371:a8d468e143f7 luis
  auth_source_id:
2818 1370:0b169a5e3837 luis
  mail_notification: all
2819
  login: dlopper2
2820
  type: User
2821 1371:a8d468e143f7 luis
users_006:
2822 1370:0b169a5e3837 luis
  id: 6
2823
  created_on: 2006-07-19 19:33:19 +02:00
2824
  status: 0
2825 1371:a8d468e143f7 luis
  last_login_on:
2826 1370:0b169a5e3837 luis
  language: ''
2827
  hashed_password: 1
2828
  updated_on: 2006-07-19 19:33:19 +02:00
2829
  admin: false
2830
  mail: ''
2831
  lastname: Anonymous
2832
  firstname: ''
2833 1371:a8d468e143f7 luis
  auth_source_id:
2834 1370:0b169a5e3837 luis
  mail_notification: only_my_events
2835
  login: ''
2836
  type: AnonymousUser
2837 1371:a8d468e143f7 luis
users_007:
2838 1370:0b169a5e3837 luis
  id: 7
2839
  created_on: 2006-07-19 19:33:19 +02:00
2840
  status: 1
2841 1371:a8d468e143f7 luis
  last_login_on:
2842 1370:0b169a5e3837 luis
  language: ''
2843
  hashed_password: 1
2844
  updated_on: 2006-07-19 19:33:19 +02:00
2845
  admin: false
2846
  mail: someone@foo.bar
2847
  lastname: One
2848
  firstname: Some
2849 1371:a8d468e143f7 luis
  auth_source_id:
2850 1370:0b169a5e3837 luis
  mail_notification: only_my_events
2851
  login: someone
2852
  type: User
2853 1371:a8d468e143f7 luis
users_008:
2854 1370:0b169a5e3837 luis
  id: 8
2855
  created_on: 2006-07-19 19:33:19 +02:00
2856
  status: 1
2857 1371:a8d468e143f7 luis
  last_login_on:
2858 1370:0b169a5e3837 luis
  language: 'it'
2859
  # password = foo
2860
  salt: 7599f9963ec07b5a3b55b354407120c0
2861
  hashed_password: 8f659c8d7c072f189374edacfa90d6abbc26d8ed
2862
  updated_on: 2006-07-19 19:33:19 +02:00
2863
  admin: false
2864
  mail: miscuser8@foo.bar
2865
  lastname: Misc
2866
  firstname: User
2867 1371:a8d468e143f7 luis
  auth_source_id:
2868 1370:0b169a5e3837 luis
  mail_notification: only_my_events
2869
  login: miscuser8
2870
  type: User
2871 1371:a8d468e143f7 luis
users_009:
2872 1370:0b169a5e3837 luis
  id: 9
2873
  created_on: 2006-07-19 19:33:19 +02:00
2874
  status: 1
2875 1371:a8d468e143f7 luis
  last_login_on:
2876 1370:0b169a5e3837 luis
  language: 'it'
2877
  hashed_password: 1
2878
  updated_on: 2006-07-19 19:33:19 +02:00
2879
  admin: false
2880
  mail: miscuser9@foo.bar
2881
  lastname: Misc
2882
  firstname: User
2883 1371:a8d468e143f7 luis
  auth_source_id:
2884 1370:0b169a5e3837 luis
  mail_notification: only_my_events
2885
  login: miscuser9
2886
  type: User
2887 1371:a8d468e143f7 luis
groups_010:
2888 1370:0b169a5e3837 luis
  id: 10
2889
  lastname: A Team
2890
  type: Group
2891 1371:a8d468e143f7 luis
groups_011:
2892 1370:0b169a5e3837 luis
  id: 11
2893
  lastname: B Team
2894
  type: Group
2895
2896 1371:a8d468e143f7 luis
2897
# authors_controller_test.rb
2898
2899 1370:0b169a5e3837 luis
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2900 328:aed18b463206 luis
2901
class AuthorsControllerTest < ActionController::TestCase
2902 1370:0b169a5e3837 luis
  self.fixture_path = File.dirname(__FILE__) + "/../fixtures/"
2903 1371:a8d468e143f7 luis
  fixtures :users, :authors, :authorships
2904 1370:0b169a5e3837 luis
2905 1371:a8d468e143f7 luis
  def test_truth
2906
    assert true
2907 328:aed18b463206 luis
  end
2908 1370:0b169a5e3837 luis
2909 328:aed18b463206 luis
end
2910
require File.dirname(__FILE__) + '/../test_helper'
2911
2912
class AuthorshipsControllerTest < ActionController::TestCase
2913
  # Replace this with your real tests.
2914
  def test_truth
2915
    assert true
2916
  end
2917
end
2918
require File.dirname(__FILE__) + '/../test_helper'
2919
2920
class PublicationsControllerTest < ActionController::TestCase
2921
  # Replace this with your real tests.
2922
  def test_truth
2923
    assert true
2924
  end
2925
end
2926 1368:987e71e73116 luis
ENV['RAILS_ENV'] ||= 'test'
2927
2928 298:a41158bde9e0 luis
# Load the normal Rails helper
2929 1368:987e71e73116 luis
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
2930
require File.expand_path(File.dirname(__FILE__) + '/../app/controllers/publications_controller')
2931 298:a41158bde9e0 luis
2932 1369:40e64d14e691 luis
class BibliographyControllerTest < ActionController::TestCase
2933
  self.fixture_path = File.dirname(__FILE__) + "/fixtures/"
2934 424:b601a9e472f3 luis
2935 1369:40e64d14e691 luis
  fixtures :authors
2936 424:b601a9e472f3 luis
2937
  def setup
2938 1369:40e64d14e691 luis
2939 424:b601a9e472f3 luis
  end
2940
2941 1371:a8d468e143f7 luis
  def test_truth
2942
    assert true
2943 425:4ecbc22579e2 luis
  end
2944
2945 1369:40e64d14e691 luis
  # def test_routing
2946
  #   assert_routing(
2947
  #         {:method => :get, :path => '/requirements'},
2948
  #         :controller => 'requirements', :action => 'index'
2949
  #       )
2950
  # end
2951 1368:987e71e73116 luis
2952
end
2953 1371:a8d468e143f7 luis
# author_test.rb
2954
2955
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2956 328:aed18b463206 luis
2957
class AuthorTest < ActiveSupport::TestCase
2958 1371:a8d468e143f7 luis
    self.fixture_path = File.dirname(__FILE__) + "/../fixtures/"
2959
    fixtures :users, :authors, :authorships
2960 328:aed18b463206 luis
2961 1371:a8d468e143f7 luis
    def test_relationships
2962
        author = Author.find(1)
2963 1372:a8832968d927 luis
2964
        assert_equal(author.authorships.first.name_on_paper, "Yih-Farn R. Chen")
2965
        assert_equal(author.authorships.count, 2)
2966
2967 1371:a8d468e143f7 luis
    end
2968 1370:0b169a5e3837 luis
2969 328:aed18b463206 luis
end
2970
require File.dirname(__FILE__) + '/../test_helper'
2971
2972
class AuthorshipTest < ActiveSupport::TestCase
2973
  fixtures :authorships
2974
2975
  # Replace this with your real tests.
2976
  def test_truth
2977 1370:0b169a5e3837 luis
        luis = Author.first
2978
2979
2980 328:aed18b463206 luis
    assert true
2981
  end
2982 1368:987e71e73116 luis
2983
2984
2985 328:aed18b463206 luis
end
2986 393:9595ab4cac6b luis
require File.dirname(__FILE__) + '/../test_helper'
2987
2988
class BibtexEntryTest < ActiveSupport::TestCase
2989
  fixtures :bibtex_entries
2990
2991
  # Replace this with your real tests.
2992
  def test_truth
2993
    assert true
2994
  end
2995
end
2996 1373:95a6d8cecdb8 luis
# publication_test
2997
2998 1371:a8d468e143f7 luis
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2999 328:aed18b463206 luis
3000
class PublicationTest < ActiveSupport::TestCase
3001 1371:a8d468e143f7 luis
    self.fixture_path = File.dirname(__FILE__) + "/../fixtures/"
3002 328:aed18b463206 luis
3003 1371:a8d468e143f7 luis
    fixtures :publications, :authorships
3004
3005
    # Replace this with your real tests.
3006
    def test_truth
3007
        assert true
3008
    end
3009
3010
    def test_relationships
3011
        # test authorships - publication relationship
3012
        publication = Publication.find(1)
3013
3014 1373:95a6d8cecdb8 luis
        assert 4, publication.authorships.count
3015
    end
3016
3017
    def test_new_publication_validations
3018
        pub = Publication.create
3019
3020
        assert !pub.valid?, "!pub.valid?"
3021
        assert_equal 2, pub.errors.count, "Number of errors"
3022
        assert_equal ["can't be blank"], pub.errors[:title]
3023
        assert_equal ["Please add at least one author to this publication."], pub.errors[:authorships]
3024 1371:a8d468e143f7 luis
    end
3025
3026 328:aed18b463206 luis
end