class Workshop::Program

Attributes

cfg[R]
colors[R]
event[R]
guests[R]
prog[R]
rooms[R]
root[R]
subms[R]

Public Class Methods

new(root,program_yml="program.yml",subms_csv="submission_browse.csv",guests_yml="guests.yml",contacts_csv="user_browse.csv") click to toggle source
# File lib/workshop.rb, line 48
def initialize(root,program_yml="program.yml",subms_csv="submission_browse.csv",guests_yml="guests.yml",contacts_csv="user_browse.csv")
    @root=root
    require 'yaml'
    @cfg=YAML::load_file(File.join(@root,program_yml))
    @event,@prog,@colors,@rooms=@cfg["event"],@cfg["program"],@cfg["colors"],@cfg["rooms"]
    require 'csv'
    @subms = CSV.read(File.join(@root,subms_csv))
    @subms_extra = (@cfg["subms"] || {})
    @guests=YAML::load_file(File.join(@root,guests_yml))
    @contacts=CSV.read(File.join(@root,contacts_csv))
end

Public Instance Methods

cell_session(id) click to toggle source
# File lib/workshop.rb, line 60
def cell_session(id) #guest or simple info
    ev=@event[id]
    is_talk=(ev.is_a? Hash and ev["speaker"])
    sess={is_talk: is_talk}
    if is_talk
        sess[:room],sess[:chair],sess[:thema],sess[:aut_aff]="","","",""
        sess[:type]=ev["type"]
        sess[:room]=@rooms[ev["place"]]["name"] if ev["place"]
        sess[:thema]=ev["thema"]+" : " if ev["thema"]
        if ev["chairman"]
            sess[:chair]=Workshop.format_full_name(ev["chairman"])
        end

        if ev["nb"] and ev["nb"]>1
            sess[:nb]=ev["nb"]
            sess[:authors]=[]
            sess[:thema]=ev["thema"]
            (1..ev["nb"]).each do |i| #
                id2=id+"."+i.to_s
                ev2={}
                ev2[:id]=id2
                ev2[:aut_aff]=Workshop.format_full_name(@guests[id2]["author"])+" ("+@guests[id2]["affiliation"]+")"
                ev2[:title]=@guests[id2]["title"]
                ev2[:index]=@guests[id2]["index"]
                ev2[:abstract]=@guests[id2]["abstract"].strip.gsub("\u200B", "") #.gsub("%","\\%")
                sess[:authors] << ev2
            end
        else
            sess[:aut_aff]=Workshop.format_full_name(@guests[id]["author"])+" ("+@guests[id]["affiliation"]+")"
            sess[:author]=Workshop.format_full_name(@guests[id]["author"])
            sess[:author_index]=Workshop.format_full_name_index(@guests[id]["author"])
            sess[:index]=@guests[id]["index"]
            sess[:title]=@guests[id]["title"] || ev["title"]
            sess[:abstract]=@guests[id]["abstract"].strip.gsub("\u200B", "") #.gsub("%","\\%")
        end
    else
        sess[:title]=(ev.is_a? Hash and ev["title"]) ?  ev["title"] : ev
    end
    sess
end
html_cell_session(id) click to toggle source
# File lib/workshop.rb, line 189
def html_cell_session(id)
    ev=event[id]
    room,chair,speaker="","",""
    if ev.is_a? Hash
        if ev["speaker"]
            if ev["speaker"].include? " et "
            speaker=ev["speaker"].split(" et ").map{|sp| Workshop.format_full_name(sp.strip)}.join(" et ")
            else
            speaker=Workshop.format_full_name(ev["speaker"])
            end
        end
        room=@rooms[ev["place"]]["name"] if ev["place"]
        if ev["chairman"]
            chair=Workshop.format_full_name(ev["chairman"])
        end
        res=""
        res << "<strong>"+ev["thema"]+"</strong>" if ev["thema"]
        res << ": " unless res.empty?
        res << "<strong>"+speaker+ "</strong>"
        res << "<br/>"+ev["title"] if ev["title"]
        res << "<br/><em>Modérateur</em>: "+chair+", <em>Amphi</em>: "+room 
        res
    else
        res="<strong>"+ev+"</strong>"
    end
    res
end
last_subm(s_id) click to toggle source
# File lib/workshop.rb, line 101
def last_subm(s_id) #s_id: id of submission
    subm_res=@subms.select {|subm| subm[0]==s_id}[0]
    if subm_res[5].include? ","
        s_id2=subm_res[5].split(",")[-1]
        #Dyndoc.warn :history, [s,s2]
        subm_res=@subms.select {|subm| subm[0]==s_id2}[0]
    end
    subm_res
end
prepare_email_list() click to toggle source
# File lib/workshop.rb, line 247
def prepare_email_list
    emails=[]
    @prog.each do |k,v|
        v["table"].each do |l|                
            h,txt=l.split("->").map{|e| e.strip}
            elts=txt.split(",").map{|e| e.strip}
            elts.each {|elt| #
                unless elt=="empty"
                    (@event[elt]["subms"] || "").split(",").map{|e| e.strip}.each{|s|
                        unless s.to_i==0
                            subm=last_subm(s)
                            if subm
                                emails << @contacts.select{|u| 
                                    u[0]==subm[1]
                                }[0][1]
                            else
                                puts "Warnings: "+s+" missing!"
                            end
                        end
                    }
                end
            }
        end
    end
    return emails
end
prepare_pdfs(from,to=nil) click to toggle source
# File lib/workshop.rb, line 217
def prepare_pdfs(from,to=nil)
    return unless to
    require 'fileutils'
    @prog.each do |k,v|
        v["table"].each do |l|                
            h,txt=l.split("->").map{|e| e.strip}
            elts=txt.split(",").map{|e| e.strip}
            elts.each {|elt| #
                unless elt=="empty"
                    (@event[elt]["subms"] || "").split(",").map{|e| e.strip}.each{|s|
                        unless s.to_i==0
                            subm=last_subm(s)
                            if subm
                                upload_dir=subm[9]
                                subm_pdf=Dir[File.join(from,upload_dir,"*")]
                                if subm_pdf.length == 1
                                    FileUtils.mkdir_p to
                                    FileUtils.cp subm_pdf[0],File.join(to,"subm"+subm[0]+".pdf")
                                else
                                    puts "Warnings: "+s+","+subm_pdf.inspect
                                end
                            end
                        end
                    }
                end
            }
        end
    end
end
subm_info(subm) click to toggle source
# File lib/workshop.rb, line 130
def subm_info(subm)
    begin
        if subm.is_a? Array
            authors=subm[4].split("|||").map do |author| #
                tmp=author.split("&&&")
                {
                first_name: Workshop.format_first_name(tmp[0]).strip,
                last_name: Workshop.format_last_name(tmp[1]).strip,
                email: tmp[2],
                institution: (tmp[3] || "").gsub("&","\\\\&")
                }
            end
            title=subm[2].gsub(/[^[:print:]]/,' ')
        else
            title,authors=subm.gsub(/[^[:print:]]/,' '),[]
        end 

    rescue
        authors,title=[],""
        Dyndoc.warn :subm, subm
    end
    info={id: subm[0], authors: authors, title: title, abstract: subm[3].gsub(/[^[:print:]]/,' ').gsub("\u200B", "")} #.gsub("%","\\%")}
end
subms_session(id) click to toggle source
# File lib/workshop.rb, line 111
def subms_session(id)
    chair=Workshop.format_full_name(@event[id]["chairman"] || "Maude Herateur")
    chair="TBA" if @event[id]["chairman"]=="TBA"
    sess={
        topic: @event[id]["topic"],
        chairman: chair,
        place: @rooms[@event[id]["place"]]["name"] || "Room",
        label: @event[id]["label"] || "Label",
        subms: (@event[id]["subms"] || "").split(",").map{|e| e.strip}.map{|s| #
            if s.to_i==0
                @subms_extra[s] ? @subms_extra[s] : @event[s]
            else 
                last_subm(s)
            end 
        }
    }
    sess
end
textab_cell_session(id,mode=:fr) click to toggle source
# File lib/workshop.rb, line 154
def textab_cell_session(id,mode=:fr)
    ev=@event[id]
    begin
        if ev.is_a? Hash
            if ev["speaker"]
                if ev["speaker"].include? " et "
                    speaker=ev["speaker"].split(" et ").map{|sp| Workshop.format_full_name(sp.strip)}.join(" et ")
                else
                    speaker=Workshop.format_full_name(ev["speaker"])
                end
            end
            room=@rooms[ev["place"]]["name"] if ev["place"]
            if ev["chairman"]
                chair=ev["chairman"]=="TBA" ? "TBA" : Workshop.format_full_name(ev["chairman"])
            end
            res=""
            res << "\\textbf{"+ev["thema"]+"}" if ev["thema"]
            res << ": " unless res.empty?
            res << "\\textbf{"+speaker+ "}"
            res << "\\\\"+ev["title"] if ev["title"]
            if mode==:fr
                res << "\\\\\\textit{Mod.} : "+chair+", \\textit{Amphi} : "+room 
            else
                res << "\\\\\\textit{Chair}: "+chair+", "+room 
            end
        else 
            res="\\textbf{"+ev+"}"
        end
    rescue
        res="Problem id=#{id}"
    end

    res
end