mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-20 06:08:08 +01:00
Move the calendar to its own controller
This commit is contained in:
parent
70fc1848c2
commit
d1ff0daf6f
6 changed files with 97 additions and 26 deletions
21
app/controllers/calendar_controller.rb
Normal file
21
app/controllers/calendar_controller.rb
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
class CalendarController < ApplicationController
|
||||
def show
|
||||
@source_view = 'calendar'
|
||||
@page_title = t('todos.calendar_page_title')
|
||||
|
||||
@calendar = Todos::Calendar.new(current_user)
|
||||
@projects = @calendar.projects
|
||||
@count = current_user.todos.not_completed.are_due.count
|
||||
@due_all = current_user.todos.not_completed.are_due.reorder("due")
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.ics {
|
||||
render :action => 'calendar', :layout => false, :content_type => Mime::ICS
|
||||
}
|
||||
format.xml {
|
||||
render :xml => @due_all.to_xml( *to_xml_params )
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
13
app/views/calendar/show.html.erb
Normal file
13
app/views/calendar/show.html.erb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<div id="display_box">
|
||||
|
||||
<%= todos_calendar_container(:due_today, @calendar.due_today ) %>
|
||||
<%= todos_calendar_container(:due_this_week, @calendar.due_this_week ) %>
|
||||
<%= todos_calendar_container(:due_next_week, @calendar.due_next_week ) %>
|
||||
<%= todos_calendar_container(:due_this_month, @calendar.due_this_month ) %>
|
||||
<%= todos_calendar_container(:due_after_this_month, @calendar.due_after_this_month) %>
|
||||
|
||||
</div><!-- End of display_box -->
|
||||
<div class="input_box" id="input_box">
|
||||
<p><%= link_to('<span class="feed">iCal</span>'.html_safe, {:format => 'ics', :token => current_user.token}, :title => "iCal feed" ) %>
|
||||
- <%= t('todos.calendar.get_in_ical_format') %></p>
|
||||
</div>
|
||||
32
app/views/calendar/show.ics.erb
Normal file
32
app/views/calendar/show.ics.erb
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
BEGIN:VCALENDAR
|
||||
PRODID:-//TRACKS//<%= TRACKS_VERSION %>//EN
|
||||
VERSION:2.0
|
||||
CALSCALE:GREGORIAN
|
||||
METHOD:PUBLISH
|
||||
X-WR-CALNAME:Tracks
|
||||
<% for todo in @due_all
|
||||
due_date = todo.due
|
||||
overdue_text = ""
|
||||
if due_date.at_midnight < Time.zone.now.at_midnight
|
||||
due_date = Time.zone.now
|
||||
overdue_text = t('todos.overdue') +": "
|
||||
end
|
||||
modified = todo.updated_at || todo.created_at
|
||||
%>BEGIN:VEVENT
|
||||
DTSTART;VALUE=DATE:<%= due_date.strftime("%Y%m%d") %>
|
||||
DTEND;VALUE=DATE:<%= (due_date+1.day).strftime("%Y%m%d") %>
|
||||
DTSTAMP:<%= due_date.strftime("%Y%m%dT%H%M%SZ") %>
|
||||
UID:<%= todo_url(todo) %>
|
||||
CLASS:PUBLIC
|
||||
CATEGORIES:Tracks
|
||||
CREATED:<%= todo.created_at.strftime("%Y%m%dT%H%M%SZ") %>
|
||||
DESCRIPTION:<%= format_ical_notes(todo.notes) %>
|
||||
LAST-MODIFIED:<%= modified.strftime("%Y%m%dT%H%M%SZ") %>
|
||||
LOCATION:
|
||||
SEQUENCE:0
|
||||
STATUS:CONFIRMED
|
||||
SUMMARY:<%= overdue_text + todo.description %>
|
||||
TRANSP:TRANSPARENT
|
||||
END:VEVENT
|
||||
<% end
|
||||
%>END:VCALENDAR
|
||||
Loading…
Add table
Add a link
Reference in a new issue