Class: Vpim::Agent::Ics

Inherits:
Base
  • Object
show all
Defined in:
lib/vpim/agent/ics.rb

Instance Method Summary collapse

Methods inherited from Base

#css, #host_port, #render_css, #request_path, #script_path, #script_url

Instance Method Details

#atomize(caluri, feeduri) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/vpim/agent/ics.rb', line 25

def atomize(caluri, feeduri)
  repo = Vpim::Repo::Uri.new(caluri)
  cal = repo.find{true}
  cal = View.week(cal)
  feed = Agent::Atomize.calendar(cal, feeduri, caluri, cal.name)
  return feed.to_xml,  Agent::Atomize::MIME
end

#get_atom(caluri) ⇒ Object

When we support other forms.. get ‘/ics/:form’ do

form = params[:form]


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/vpim/agent/ics.rb', line 55

def get_atom(caluri)
  if caluri.empty?
    redirect script_url
  end

  feeduri = script_url + "/atom?" + caluri

  begin
    xml, xmltype = atomize(caluri, feeduri)
    content_type xmltype
    body xml
  rescue
    redirect script_url + "?" + caluri
  end
end

#get_base(from) ⇒ Object

Route handlers:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/vpim/agent/ics.rb', line 34

def get_base(from)
  @url_base = script_url   # agent mount point
  @url_ics  = from         # ics from here
  @url_atom = nil          # atom feed from here, if ics is accessible
  @url_error= nil          # error message, if is is not accessible

  if not from.empty?
    begin
      atomize(from, "http://example.com")
      @url_atom = @url_base + "/atom" + "?" + from
    rescue
      @url_error = CGI.escapeHTML($!.to_s)
    end
  end

  haml :"vpim/agent/ics/view"
end

#get_styleObject



71
72
73
74
# File 'lib/vpim/agent/ics.rb', line 71

def get_style
  content_type 'text/css'
  css :"vpim/agent/ics/style"
end