Class: Workshop::Program
- Inherits:
-
Object
- Object
- Workshop::Program
- Defined in:
- lib/workshop.rb
Instance Attribute Summary collapse
-
#cfg ⇒ Object
readonly
Returns the value of attribute cfg.
-
#colors ⇒ Object
readonly
Returns the value of attribute colors.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#guests ⇒ Object
readonly
Returns the value of attribute guests.
-
#prog ⇒ Object
readonly
Returns the value of attribute prog.
-
#rooms ⇒ Object
readonly
Returns the value of attribute rooms.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#subms ⇒ Object
readonly
Returns the value of attribute subms.
Instance Method Summary collapse
-
#cell_session(id) ⇒ Object
guest or simple info.
- #html_cell_session(id) ⇒ Object
-
#initialize(root, program_yml = "program.yml", subms_csv = "submission_browse.csv", guests_yml = "guests.yml", contacts_csv = "user_browse.csv") ⇒ Program
constructor
A new instance of Program.
-
#last_subm(s_id) ⇒ Object
s_id: id of submission.
- #prepare_email_list ⇒ Object
- #prepare_pdfs(from, to = nil) ⇒ Object
- #subm_info(subm) ⇒ Object
- #subms_session(id) ⇒ Object
- #textab_cell_session(id, mode = :fr) ⇒ Object
Constructor Details
#initialize(root, program_yml = "program.yml", subms_csv = "submission_browse.csv", guests_yml = "guests.yml", contacts_csv = "user_browse.csv") ⇒ Program
Returns a new instance of Program.
48 49 50 51 52 53 54 55 56 57 58 |
# 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 |
Instance Attribute Details
#cfg ⇒ Object (readonly)
Returns the value of attribute cfg.
46 47 48 |
# File 'lib/workshop.rb', line 46 def cfg @cfg end |
#colors ⇒ Object (readonly)
Returns the value of attribute colors.
46 47 48 |
# File 'lib/workshop.rb', line 46 def colors @colors end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
46 47 48 |
# File 'lib/workshop.rb', line 46 def event @event end |
#guests ⇒ Object (readonly)
Returns the value of attribute guests.
46 47 48 |
# File 'lib/workshop.rb', line 46 def guests @guests end |
#prog ⇒ Object (readonly)
Returns the value of attribute prog.
46 47 48 |
# File 'lib/workshop.rb', line 46 def prog @prog end |
#rooms ⇒ Object (readonly)
Returns the value of attribute rooms.
46 47 48 |
# File 'lib/workshop.rb', line 46 def rooms @rooms end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
46 47 48 |
# File 'lib/workshop.rb', line 46 def root @root end |
#subms ⇒ Object (readonly)
Returns the value of attribute subms.
46 47 48 |
# File 'lib/workshop.rb', line 46 def subms @subms end |
Instance Method Details
#cell_session(id) ⇒ Object
guest or simple info
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# 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) ⇒ Object
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# 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) ⇒ Object
s_id: id of submission
101 102 103 104 105 106 107 108 109 |
# 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 ⇒ Object
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# 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) ⇒ Object
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# 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) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/workshop.rb', line 130 def subm_info(subm) begin if subm.is_a? Array =subm[4].split("|||").map do || # tmp=.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,=subm.gsub(/[^[:print:]]/,' '),[] end rescue ,title=[],"" Dyndoc.warn :subm, subm end info={id: subm[0], authors: , title: title, abstract: subm[3].gsub(/[^[:print:]]/,' ').gsub("\u200B", "")} #.gsub("%","\\%")} end |
#subms_session(id) ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# 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) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# 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 |