Class | PresentationController |
In: |
app/controllers/presentation_controller.rb
|
Parent: | ApplicationController |
Presentations | = | 'presentations' |
# File app/controllers/presentation_controller.rb, line 51 51: def extras 52: @lines=[] 53: if p=get_presentation 54: # logger.info "presenting #{p}" 55: chs= IO.readlines(p) 56: chs.collect!{|s|s.strip} 57: blanks=[-1] 58: chs.each_with_index do |s,i| 59: if s.strip =='' 60: blanks << i 61: end 62: end 63: blanks << chs.size+1 64: # logger.info "blanks #{blanks.inspect}" 65: si=get_selected_item % (blanks.size-1) 66: @lines=chs[blanks[si]+2,blanks[si+1]-blanks[si]-2] 67: @title=chs[blanks[si]+1] 68: if @lines && @lines[0] && 69: (@lines[0] =~ /(JPG|JPEG|GIF)$/i) 70: @pic=@lines.shift 71: end 72: end 73: end
# File app/controllers/presentation_controller.rb, line 3 3: def first_time 4: session[:presentation]=nil 5: if pa=params[:id] 6: session[:presentation]=pa 7: session[:selected_item]=-1 8: end 9: redirect_to :action =>"index" 10: end
# File app/controllers/presentation_controller.rb, line 14 14: def get_presentation 15: d=Giver.new 16: if p=session[:presentation] 17: rx=Regexp.new('(.*'+p+'.*txt$)', 18: Regexp::IGNORECASE) 19: g=d.get_filename_part(Presentations,rx)[0] 20: else 21: Dir.mkdir(Presentations) unless 22: File.directory?(Presentations) 23: rx=Regexp.new(Presentations+'/(.*).txt$', 24: Regexp::IGNORECASE) 25: g=d.get_filename_part(Presentations,rx) 26: if g.size==1 27: session[:selected_item]=0 28: p=session[:presentation]=g[0] 29: rx=Regexp.new('(.*'+p+'.*txt$)', 30: Regexp::IGNORECASE) 31: g=d.get_filename_part(Presentations,rx)[0] 32: else 33: session[:presentation]=nil 34: end 35: end 36: end
# File app/controllers/presentation_controller.rb, line 47 47: def selected str 48: session[:presentation]=str 49: session[:selected_item]=0 50: end