Class: Tilia::CalDav::Subscriptions::Plugin
- Inherits:
-
Dav::ServerPlugin
- Object
- Dav::ServerPlugin
- Tilia::CalDav::Subscriptions::Plugin
- Defined in:
- lib/tilia/cal_dav/subscriptions/plugin.rb
Overview
This plugin adds calendar-subscription support to your CalDAV server.
Some clients support ‘managed subscriptions’ server-side. This is basically a list of subscription urls a user is using.
Instance Method Summary collapse
-
#features ⇒ Object
This method should return a list of server-features.
-
#plugin_info ⇒ Object
Returns a bunch of meta-data about the plugin.
-
#plugin_name ⇒ Object
Returns a plugin name.
-
#prop_find(prop_find, _node) ⇒ Object
Triggered after properties have been fetched.
-
#setup(server) ⇒ Object
This initializes the plugin.
Methods inherited from Dav::ServerPlugin
#http_methods, #supported_report_set
Instance Method Details
#features ⇒ Object
This method should return a list of server-features.
This is for example ‘versioning’ and is added to the DAV: header in an OPTIONS response.
31 32 33 |
# File 'lib/tilia/cal_dav/subscriptions/plugin.rb', line 31 def features ['calendarserver-subscribed'] end |
#plugin_info ⇒ Object
Returns a bunch of meta-data about the plugin.
Providing this information is optional, and is mainly displayed by the Browser plugin.
The description key in the returned array may contain html and will not be sanitized.
73 74 75 76 77 78 79 |
# File 'lib/tilia/cal_dav/subscriptions/plugin.rb', line 73 def plugin_info { 'name' => plugin_name, 'description' => 'This plugin allows users to store iCalendar subscriptions in their calendar-home.', 'link' => nil } end |
#plugin_name ⇒ Object
Returns a plugin name.
Using this name other plugins will be able to access other plugins using SabreDAVServer::getPlugin
60 61 62 |
# File 'lib/tilia/cal_dav/subscriptions/plugin.rb', line 60 def plugin_name 'subscriptions' end |
#prop_find(prop_find, _node) ⇒ Object
Triggered after properties have been fetched.
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/tilia/cal_dav/subscriptions/plugin.rb', line 40 def prop_find(prop_find, _node) # There's a bunch of properties that must appear as a self-closing # xml-element. This event handler ensures that this will be the case. props = [ '{http://calendarserver.org/ns/}subscribed-strip-alarms', '{http://calendarserver.org/ns/}subscribed-strip-attachments', '{http://calendarserver.org/ns/}subscribed-strip-todos' ] props.each do |prop| prop_find.set(prop, '', 200) if prop_find.status(prop) == 200 end end |
#setup(server) ⇒ Object
This initializes the plugin.
This function is called by SabreDAVServer, after addPlugin is called.
This method should set up the required event subscriptions.
18 19 20 21 22 23 |
# File 'lib/tilia/cal_dav/subscriptions/plugin.rb', line 18 def setup(server) server.resource_type_mapping[ISubscription] = '{http://calendarserver.org/ns/}subscribed' server.xml.element_map['{http://calendarserver.org/ns/}source'] = Dav::Xml::Property::Href server.on('propFind', method(:prop_find), 150) end |