FEATURE: iCalendar feed for Bookmark reminders
This commit is contained in:
parent
1c7680c568
commit
d6838608ff
|
@ -1397,6 +1397,9 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
def bookmarks
|
def bookmarks
|
||||||
user = fetch_user_from_params
|
user = fetch_user_from_params
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.json do
|
||||||
bookmarks = BookmarkQuery.new(user, params).list_all
|
bookmarks = BookmarkQuery.new(user, params).list_all
|
||||||
|
|
||||||
if bookmarks.empty?
|
if bookmarks.empty?
|
||||||
|
@ -1408,6 +1411,11 @@ class UsersController < ApplicationController
|
||||||
render_serialized(bookmarks, UserBookmarkSerializer, root: 'bookmarks')
|
render_serialized(bookmarks, UserBookmarkSerializer, root: 'bookmarks')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
format.ics do
|
||||||
|
@bookmark_reminders = Bookmark.where(user_id: user.id).where.not(reminder_at: nil).joins(:topic)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
HONEYPOT_KEY ||= 'HONEYPOT_KEY'
|
HONEYPOT_KEY ||= 'HONEYPOT_KEY'
|
||||||
CHALLENGE_KEY ||= 'CHALLENGE_KEY'
|
CHALLENGE_KEY ||= 'CHALLENGE_KEY'
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
BEGIN:VCALENDAR
|
||||||
|
VERSION:2.0
|
||||||
|
PRODID:-//Discourse//<%= Discourse.current_hostname %>//<%= Discourse.full_version %>//EN
|
||||||
|
<% @bookmark_reminders.each do |bookmark| %>
|
||||||
|
BEGIN:VEVENT
|
||||||
|
UID:bookmark_reminder_#<%= bookmark.id %>@<%= Discourse.current_hostname %>
|
||||||
|
DTSTAMP:<%= bookmark.updated_at.strftime("%Y%m%dT%H%M%SZ") %>
|
||||||
|
DTSTART:<%= bookmark.reminder_at.strftime("%Y%m%dT%H%M%SZ") %>
|
||||||
|
DTEND:<%= (bookmark.reminder_at + 1.hour).strftime("%Y%m%dT%H%M%SZ") %>
|
||||||
|
SUMMARY:<%= bookmark.name.presence || bookmark.topic.title %>
|
||||||
|
URL:<%= Discourse.base_url %>/t/-/<%= bookmark.topic_id %>
|
||||||
|
END:VEVENT
|
||||||
|
<% end %>
|
||||||
|
END:VCALENDAR
|
|
@ -469,7 +469,7 @@ Discourse::Application.routes.draw do
|
||||||
get "#{root_path}/:username/activity" => "users#show", constraints: { username: RouteFormat.username }
|
get "#{root_path}/:username/activity" => "users#show", constraints: { username: RouteFormat.username }
|
||||||
get "#{root_path}/:username/activity/:filter" => "users#show", constraints: { username: RouteFormat.username }
|
get "#{root_path}/:username/activity/:filter" => "users#show", constraints: { username: RouteFormat.username }
|
||||||
get "#{root_path}/:username/badges" => "users#badges", constraints: { username: RouteFormat.username }
|
get "#{root_path}/:username/badges" => "users#badges", constraints: { username: RouteFormat.username }
|
||||||
get "#{root_path}/:username/bookmarks" => "users#bookmarks", constraints: { username: RouteFormat.username }
|
get "#{root_path}/:username/bookmarks" => "users#bookmarks", constraints: { username: RouteFormat.username, format: /(json|ics)/ }
|
||||||
get "#{root_path}/:username/notifications" => "users#show", constraints: { username: RouteFormat.username }
|
get "#{root_path}/:username/notifications" => "users#show", constraints: { username: RouteFormat.username }
|
||||||
get "#{root_path}/:username/notifications/:filter" => "users#show", constraints: { username: RouteFormat.username }
|
get "#{root_path}/:username/notifications/:filter" => "users#show", constraints: { username: RouteFormat.username }
|
||||||
delete "#{root_path}/:username" => "users#destroy", constraints: { username: RouteFormat.username }
|
delete "#{root_path}/:username" => "users#destroy", constraints: { username: RouteFormat.username }
|
||||||
|
|
Loading…
Reference in New Issue