Skip to content

Commit

Permalink
Registers iCal feed as global plugin and introduces (unfinished) example
Browse files Browse the repository at this point in the history
  • Loading branch information
njpearman committed Nov 13, 2020
1 parent 79fb1c0 commit 8fa15b1
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
67 changes: 67 additions & 0 deletions examples/icalendar.html
@@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link href='../packages/bundle/main.css' rel='stylesheet' />
<script src='../packages/bundle/main.js'></script>
<script>

document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');

var calendar = new FullCalendar.Calendar(calendarEl, {

events: {
feedUrl: 'https://duckduckgo.com', // need a valid request that obeys CORS
},

headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,listYear'
},

displayEventTime: false, // don't show the time column in list view

loading: function(bool) {
document.getElementById('loading').style.display =
bool ? 'block' : 'none';
}

});

calendar.render();
});

</script>
<style>

body {
margin: 40px 10px;
padding: 0;
font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
font-size: 14px;
}

#loading {
display: none;
position: absolute;
top: 10px;
right: 10px;
}

#calendar {
max-width: 1100px;
margin: 0 auto;
}

</style>
</head>
<body>

<div id='loading'>loading...</div>

<div id='calendar'></div>

</body>
</html>
Expand Up @@ -15,7 +15,7 @@ let eventSourceDef: EventSourceDef<ICalFeedMeta> = {
parseMeta(refined) {
if (refined.feedUrl) {
return {
feedUrl: refined.url,
feedUrl: refined.feedUrl,
method: (refined.method || 'GET').toUpperCase(),
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/global-plugins.ts
Expand Up @@ -3,6 +3,7 @@ import { createPlugin } from './plugin-system'
import { arrayEventSourcePlugin } from './event-sources/array-event-source'
import { funcEventSourcePlugin } from './event-sources/func-event-source'
import { jsonFeedEventSourcePlugin } from './event-sources/json-feed-event-source'
import { iCalFeedEventSourcePlugin } from './event-sources/ical-feed-event-source'
import { simpleRecurringEventsPlugin } from './structs/recurring-event-simple'
import { changeHandlerPlugin } from './option-change-handlers'
import { handleDateProfile } from './dates-set'
Expand All @@ -18,6 +19,7 @@ export const globalPlugins: PluginDef[] = [ // TODO: make a const?
arrayEventSourcePlugin,
funcEventSourcePlugin,
jsonFeedEventSourcePlugin,
iCalFeedEventSourcePlugin,
simpleRecurringEventsPlugin,
changeHandlerPlugin,
createPlugin({ // misc...
Expand Down
4 changes: 3 additions & 1 deletion packages/common/src/structs/event-source-parse.ts
Expand Up @@ -20,7 +20,9 @@ const EVENT_SOURCE_REFINERS = { // does NOT include EVENT_UI_REFINERS
failure: identity as Identity<EventSourceErrorResponseHandler>,
}

type BuiltInEventSourceRefiners = typeof EVENT_SOURCE_REFINERS & typeof JSON_FEED_EVENT_SOURCE_REFINERS & typeof ICAL_FEED_EVENT_SOURCE_REFINERS
type BuiltInEventSourceRefiners = typeof EVENT_SOURCE_REFINERS &
typeof JSON_FEED_EVENT_SOURCE_REFINERS &
typeof ICAL_FEED_EVENT_SOURCE_REFINERS

export interface EventSourceRefiners extends BuiltInEventSourceRefiners {
// for extending
Expand Down

0 comments on commit 8fa15b1

Please sign in to comment.