app/models/referent.rb in umlaut-3.2.0 vs app/models/referent.rb in umlaut-3.3.0

- old
+ new

@@ -278,29 +278,31 @@ end return co end # Creates a hash for use in View code to display a citation + # + # Crazy if/else tree logic, should be refactored, needs more tests first prob. def to_citation citation = {} # call self.metadata once and use the array for efficiency, don't # keep calling it. profiling shows it DOES make a difference. my_metadata = self.metadata if my_metadata['atitle'].present? citation[:title] = my_metadata['atitle'] citation[:title_label], citation[:container_label] = case my_metadata['genre'] - when /article|journal|issue/ then ['Article Title', 'journal'] + when /article|journal|issue/ then ['Article Title', 'Journal'] when /bookitem|book/ then ['Chapter/Part Title', 'book'] when /proceeding|conference/ then ['Proceeding Title', 'conference'] when 'report' then ['Report Title','report'] else if self.format == 'book' ['Chapter/Part Title', 'book'] elsif self.format == 'journal' - ['Article Title', 'journal'] + ['Article Title', 'Journal'] else # default fall through, use much what SFX uses. ['Title', ''] end end ['title','btitle','jtitle'].each do | t_type | @@ -310,48 +312,49 @@ break end end else citation[:title_label] = case my_metadata["genre"] - when /article|journal|issue/ then 'journal' - when /bookitem|book/ then 'book' - when /proceeding|conference/ then 'conference' - when 'report' then 'report' - else '' + when /article|journal|issue/i then 'Journal' + when /bookitem|book/i then 'Book' + when /proceeding|conference/i then 'Conference' + when 'report' then 'Report' + else nil end ['title','btitle','jtitle'].each do | t_type | if ! my_metadata[t_type].blank? citation[:title] = my_metadata[t_type] break end end end # add publisher for books - if (my_metadata['genre'] == 'book') + if (my_metadata['genre'] =~ /book/i) citation[:pub] = my_metadata['pub'] unless my_metadata['pub'].blank? end citation[:issn] = issn if issn citation[:isbn] = isbn if isbn ['volume','issue','date'].each do | key | citation[key.to_sym] = my_metadata[key] end - if ! my_metadata["au"].blank? - citation[:author] = my_metadata["au"] + + if my_metadata["au"].present? + citation[:author] = my_metadata["au"].strip elsif my_metadata["aulast"] - citation[:author] = my_metadata["aulast"] - if ! my_metadata["aufirst"].blank? - citation[:author] += ', '+my_metadata["aufirst"] + citation[:author] = my_metadata["aulast"].strip + if my_metadata["aufirst"].present? + citation[:author] += ', '+my_metadata["aufirst"].strip else - if ! my_metadata["auinit"].blank? - citation[:author] += ', '+my_metadata["auinit"] + if my_metadata["auinit"].present? + citation[:author] += ', '+my_metadata["auinit"].strip else - if ! my_metadata["auinit1"].blank? - citation[:author] += ', '+my_metadata["auinit1"] + if my_metadata["auinit1"].present? + citation[:author] += ', '+my_metadata["auinit1"].strip end - if ! my_metadata["auinitm"].blank? - citation[:author] += my_metadata["auinitm"] + if my_metadata["auinitm"].present? + citation[:author] += my_metadata["auinitm"].strip end end end elsif my_metadata["aucorp"] citation[:author] = my_metadata["aucorp"]