Skip to content

Commit

Permalink
Move the event source list to its own file for ease of forking.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabacab committed Sep 30, 2023
1 parent fc90061 commit 5870f4d
Show file tree
Hide file tree
Showing 14 changed files with 980 additions and 1,685 deletions.
895 changes: 895 additions & 0 deletions static/js/event-source-data.js

Large diffs are not rendered by default.

139 changes: 75 additions & 64 deletions static/js/event-sources.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,72 +6,83 @@
* might need to be transformed in different ways so they are
* given their own ECMAScript Module file where they are made
* compatible, if necessary. Then they're all concatenated
* into one big array, here.
* into one big `EventSources` array, here.
*/
import { DiceEventSources } from './event-sources/dice.js';
import { EventBriteEventSources } from './event-sources/eventbrite.js';
import { GoDaddyCalendarWidgetSources } from './event-sources/godaddy-calendar.js';
import { GoogleCalendarEventSources } from './event-sources/google-calendar.js';
import { IcalendarEventSources } from './event-sources/icalendar.js';
import { JSONFeedEventSources } from './event-sources/fullcalendar-json-feed.js';
import { SeeTicketsEventsCalendarSources } from './event-sources/seetickets.js';
import { SquarespaceEventSources } from './event-sources/squarespace.js';
import { TockifyEventSources } from './event-sources/tockify.js';
import { WithFriendsEventSources } from './event-sources/withfriends.js';
import { WordPressTribeEventsCalendarSources } from './event-sources/wordpress-tribe-events-calendar.js';
import { WordPressEventsOrganiserSources } from './event-sources/wordpress-events-organiser.js';
// Site-specific event source data is loaded first.
import { default as EventSourceData } from './event-source-data.js';

const EventSources = [].concat(
DiceEventSources.map((i) => {
i.color = '#E6D500';
return i;
}),
EventBriteEventSources.map((i) => {
i.color = 'red';
return i;
}),
GoDaddyCalendarWidgetSources.map((i) => {
i.color = '#14DCDC';
return i;
}),
GoogleCalendarEventSources.map((i) => {
i.color = 'gray';
return i;
}),
IcalendarEventSources.map((i) => {
i.color = (i.color) ? i.color : 'black';
i.textColor = (i.textColor) ? i.textColor : 'white';
return i;
}),
JSONFeedEventSources.map((i) => {
return i;
}),
SeeTicketsEventsCalendarSources.map((i) => {
i.color = '#FFB200';
return i;
}),
SquarespaceEventSources.map((i) => {
i.color = 'white';
i.textColor = 'black';
return i;
}),
TockifyEventSources.map((i) => {
i.color = '#0497E5';
i.textColor = '#FFF';
return i;
}),
WithFriendsEventSources.map((i) => {
i.color = '#ff877b';
return i;
}),
WordPressTribeEventsCalendarSources.map((i) => {
i.color = (i.color) ? i.color : 'blue';
return i;
}),
WordPressEventsOrganiserSources.map((i) => {
i.color = (i.color) ? i.color : 'blue';
return i;
})
// Each event source module/scraper/transformer is loaded next, as we
// will need access to their prototype object.
let EventConstructors = {};
import { default as Dice } from './event-sources/dice.js';
EventConstructors.Dice = Dice;
import { default as EventBrite } from './event-sources/eventbrite.js';
EventConstructors.EventBrite = EventBrite;
import { default as GoDaddy } from './event-sources/godaddy-calendar.js';
EventConstructors.GoDaddy = GoDaddy;
import { default as GoogleCalendar } from './event-sources/google-calendar.js';
EventConstructors.GoogleCalendar = GoogleCalendar;
import { default as SeeTicketsEvents } from './event-sources/seetickets.js';
EventConstructors.SeeTicketsEvents = SeeTicketsEvents;
import { default as Squarespace } from './event-sources/squarespace.js';
EventConstructors.Squarespace = Squarespace;
import { default as Tockify } from './event-sources/tockify.js';
EventConstructors.Tockify = Tockify;
import { default as WithFriends } from './event-sources/withfriends.js';
EventConstructors.WithFriends = WithFriends;
import { default as WordPressEventsOrganiser } from './event-sources/wordpress-events-organiser.js';
EventConstructors.WordPressEventsOrganiser = WordPressEventsOrganiser;
import { default as WordPressTribeEvents } from './event-sources/wordpress-tribe-events-calendar.js';
EventConstructors.WordPressTribeEvents = WordPressTribeEvents;

// These are natively-supported event source types.
// They don't need or use object constructors.
import { default as JSONFeedEventSources } from './event-sources/fullcalendar-json-feed.js';
import { default as IcalendarEventSources } from './event-sources/icalendar.js';

// Finally, we loop over the site-specific data and
// for each type of event source we construct an
// object for FullCalendar to make use of.
const EventSources = EventSourceData.flatMap(function (element, index, array) {
return element.sources.map(function (source) {
var obj = {
name: source.name,
id: source.id,
className: source.className,
events: async function (fetchInfo, successCallback, failureCallback) {
await new EventConstructors[element.sourceType]({
originUrl: (source.originUrl) ? source.originUrl : null,
url: source.url,
fetchInfo: fetchInfo,
successCallback: successCallback,
failureCallback: failureCallback,
headers: (source.headers) ? source.headers : {},
location: (source.location) ? source.location : {},
movementId: (source.movementId) ? source.movementId : {}
});
}
};
if ( element.options ) {
Object.assign(obj, element.options, source.options);
}
// Special case for when we're using Google
// Calendar API proper.
// TODO: This should probably be treated as
// a different "source type" but, meh.
if ( element.googleCalendarApiKey ) {
delete obj.events;
obj.googleCalendarApiKey = element.googleCalendarApiKey;
obj.googleCalendarId = element.googleCalendarId;
}
console.log(obj);
return obj;
});
}).concat(
// These sources require no manipulation, as
// they're natively understood by FullCalendar,
// so we just add them as-is to our source list.
JSONFeedEventSources,
IcalendarEventSources
);

export default EventSources;
139 changes: 0 additions & 139 deletions static/js/event-sources/dice.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,145 +4,6 @@
*/
import FullCalendarEvent from '../event.js';

export const DiceEventSources = [
{
name: "C'mon Everybody",
id: 'cmon-everybody',
className: 'cmon-everybody',
events: async function (fetchInfo, successCallback, failureCallback) {
await new Dice({
// Pulled from https://www.cmoneverybody.com/events
url: 'https://events-api.dice.fm/v1/events?page%5Bsize%5D=24&types=linkout,event&filter%5Bvenues%5D%5B%5D=C%27mon%20Everybody&filter%5Bvenues%5D%5B%5D=Cmon%20Everybody',
fetchInfo: fetchInfo,
successCallback: successCallback,
failureCallback: failureCallback,
headers: {
'x-api-key': 'PyghT2k59li4oGXIef8t4Git2vRl58H7WAuUJGpd'
}
});
}
},
{
name: "Knockdown Center",
id: 'knockdown-center',
className: 'knockdown-center',
events: async function (fetchInfo, successCallback, failureCallback) {
await new Dice({
url: 'https://events-api.dice.fm/v1/events?page%5Bsize%5D=24&types=linkout,event&filter%5Bvenues%5D%5B%5D=Knockdown%20Center',
fetchInfo: fetchInfo,
successCallback: successCallback,
failureCallback: failureCallback,
headers: {
// Actually C'mon Everybody's API key, but, shrug?
'x-api-key': 'PyghT2k59li4oGXIef8t4Git2vRl58H7WAuUJGpd'
}
});
}
},
{
name: 'Our Wicked Lady',
id: 'our-wicked-lady',
className: 'our-wicked-lady',
events: async function (fetchInfo, successCallback, failureCallback) {
await new Dice({
// Pulled from https://www.ourwickedlady.com/
url: 'https://events-api.dice.fm/v1/events?page[size]=24&types=linkout,event&filter[promoters][]=Our%20Wicked%20Lady%20LLC',
fetchInfo: fetchInfo,
successCallback: successCallback,
failureCallback: failureCallback,
headers: {
'x-api-key': 'vgtVSu5LGc3TMBuE36FwF1hn26kkt6xi5ThPJrqg'
}
});
}
},
{
name: 'Purgatory BK',
id: 'purgatory-bk',
className: 'purgatory-bk',
events: async function (fetchInfo, successCallback, failureCallback) {
await new Dice({
// Pulled from https://www.purgatorybk.com/events
url: 'https://events-api.dice.fm/v1/events?page%5Bsize%5D=24&types=linkout,event&filter%5Bvenues%5D%5B%5D=purgatory&filter%5Bvenues%5D%5B%5D=Purgatory&filter%5Bvenues%5D%5B%5D=Purgatory%20Events%20LLC',
fetchInfo: fetchInfo,
successCallback: successCallback,
failureCallback: failureCallback,
headers: {
'x-api-key': 'VKEBoWiYzJ9uJ8tjR15aD6lL4RnUz8hb4kIYYxFA'
}
});
}
},
{
name: 'Saint Vitus',
id: 'saint-vitus',
className: 'saint-vitus',
events: async function (fetchInfo, successCallback, failureCallback) {
await new Dice({
// Pulled from https://www.saintvitusbar.com/events
url: 'https://events-api.dice.fm/v1/events?page[size]=24&types=linkout,event&filter[promoters][]=Saint%20Vitus%20LLC%20(dba%20Saint%20Vitus%20Bar)',
fetchInfo: fetchInfo,
successCallback: successCallback,
failureCallback: failureCallback,
headers: {
'x-api-key': '1RsJ9u1HnFaj5F5hqFD7F9Idwsqi0o4z7QMQ2uGw'
}
});
}
},
{
name: 'The Brooklyn Monarch',
id: 'the-brooklyn-monarch',
className: 'the-brooklyn-monarch',
events: async function (fetchInfo, successCallback, failureCallback) {
await new Dice({
// Pulled from https://www.thebrooklynmonarch.com/shows
url: 'https://events-api.dice.fm/v1/events?page[size]=24&types=linkout,event&filter[venues][]=The%20Brooklyn%20Monarch',
fetchInfo: fetchInfo,
successCallback: successCallback,
failureCallback: failureCallback,
headers: {
'x-api-key': 'IC6oEVsHlf1eZRkq5Oeuc9XszjvuJCw76K8NSeip'
}
});
}
},
{
name: 'The Sultan Room',
id: 'the-sultan-room',
className: 'the-sultan-room',
events: async function (fetchInfo, successCallback, failureCallback) {
await new Dice({
// Pulled from https://thesultanroom.com/
url: 'https://events-api.dice.fm/v1/events?page[size]=24&types=linkout,event&filter[venues][]=The%20Sultan%20Room&filter[venues][]=The%20Turk%27s%20Inn&filter[venues][]=The%20Sultan%20Room%20Rooftop&filter[promoters][]=Varun%20Kataria%20dba%20Turks%20Group%20LLC',
fetchInfo: fetchInfo,
successCallback: successCallback,
failureCallback: failureCallback,
headers: {
'x-api-key': 'j3UZPWFkiQ2UFTppf79rFatRpao3ol7l5PWjmTE9'
}
});
}
},
{
name: 'Union Pool',
id: 'union-pool',
className: 'union-pool',
events: async function (fetchInfo, successCallback, failureCallback) {
await new Dice({
// Pulled from https://www.union-pool.com/calendar
url: 'https://events-api.dice.fm/v1/events?page%5Bsize%5D=24&types=linkout,event&filter%5Bpromoters%5D%5B%5D=Loop%20De%20Lou%20Production%20Corp%20dba%20Union%20Pool&filter%5Bflags%5D%5B%5D=going_ahead&filter%5Bflags%5D%5B%5D=postponed&filter%5Bflags%5D%5B%5D=rescheduled',
fetchInfo: fetchInfo,
successCallback: successCallback,
failureCallback: failureCallback,
headers: {
'x-api-key': '7rU0bJyVtM5s3vDdYNiuQ4UtDo6pAnmH1QgXsI7E'
}
});
}
}
];

export default function Dice (optionsObj) {
var url = optionsObj.url;
this.requestHeaders = optionsObj.headers;
Expand Down
Loading

0 comments on commit 5870f4d

Please sign in to comment.