ICal (iCal v1.0.0)
View SourceThe ICal struct which suppports data serialization and deserialization of iCalendar data, as well as integration with Plug and Phoenix.
Summary
Types
An iCalendar. Event structs are found in events, while vendor-specific
X-name-style entries are recorded in custom_properties. All other fields
conform to the iCalendar standard.
Functions
Returns the default product ID for calendars generated with the ICal library.
To customize this, either set the produdct_id on an %ICal{} struct before
serializing it with to_ics, or use the set_vendor/2 convenience function.
To create a Phoenix/Plug endpoint to retrieve ICal data from,
add this to the application's config.exs
Converts the data in the file at file_path to an ICal{} struct.
Converts a string containing iCalendar data to an ICal{} struct.
Allows setting a custom vendor string while maintaiing the rest of the default product ID string. This helps identify both the application using this library as well as this library when looking at generated output, which can be useful for debug purposes.
Converts an ICal{} struct to iodata.
Types
@type custom_properties() :: %{required(String.t()) => custom_value()}
@type t() :: %ICal{ __other_components: term(), alarms: term(), custom_properties: custom_properties(), default_timezone: String.t(), events: [ICal.Event.t()], method: String.t() | nil, name: String.t() | nil, product_id: String.t() | nil, scale: String.t(), version: String.t() }
An iCalendar. Event structs are found in events, while vendor-specific
X-name-style entries are recorded in custom_properties. All other fields
conform to the iCalendar standard.
Functions
Returns the default product ID for calendars generated with the ICal library.
To customize this, either set the produdct_id on an %ICal{} struct before
serializing it with to_ics, or use the set_vendor/2 convenience function.
To create a Phoenix/Plug endpoint to retrieve ICal data from,
add this to the application's config.exs:
config :phoenix, :format_encoders, ics: ICalAdding this to a controller will trigger the serialization to occur:
calendar = %ICal{ events: events }
render(conn, "index.ics", calendar: calendar)The file suffix .ics triggers the format_encoder as configured.
The same in a view:
def render("index.ics", %{calendar: calendar}) do
calendar
end
Converts the data in the file at file_path to an ICal{} struct.
Converts a string containing iCalendar data to an ICal{} struct.
Allows setting a custom vendor string while maintaiing the rest of the default product ID string. This helps identify both the application using this library as well as this library when looking at generated output, which can be useful for debug purposes.
As such, this should be prefered to changing the product_id field on an
%ICal{} directly.
Converts an ICal{} struct to iodata.
The returned iodata can be written directly to a file, sent across the network,
or turned into a string locally by passing the return value to to_string/1