You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.
I wrote a little Google script that creates a cfp calendar from your list. To try it, go to drive.google.com, click New -> Google Apps Script, copy the code into the editor, select syncCfpCalendar as the function to be executed and click the play button. Reload calendar.google.com and you should see a new cfp calendar. Google also provides triggers so you can run this nightly (click Edit -> Current Project's Triggers).
If you think this is useful, feel free to publish it, put it in a readme, provide a public calendar, whatever you want.
varsources=[{rawUrl: 'https://raw.githubusercontent.com/softwaremill/it-cfp-list/master/README.md',link: 'https://github.com/softwaremill/it-cfp-list'}]// name of the calendar to be updated / created.varcalendarName='cfp';// All calendar events are tagged, so we don't accidentally delete unrelated events.vartag={key: 'generated-by',value: 'cfp-calendar-sync'};// main functionfunctionsyncCfpCalendar(){varcal=openCalendar();foreach(sourceinsources){varmarkdownContent=loadMarkdownContent(source.rawUrl);processMarkdownContent(markdownContent,source.link,cal);}}functionloadMarkdownContent(url){varresponse=UrlFetchApp.fetch(sources[0].rawUrl);if(response.getResponseCode()!=200){thrownewError("Got HTTP "+response.getResponseCode()+" when fetching "+cfpListUrl);}returnresponse.getContentText();}functionprocessMarkdownContent(markdownContent,link,cal){vartableStart=falseforeach(lineinmarkdownContent.split(/\r?\n/)){if(!tableStart){if(line.match(/\|-+\|-+\|-+\|-+\|-+\|-+\|/)){tableStart=true;}}else{if(!startsWith(line,"|")){return;// end of table}processTableLine(line,link,cal)}}}functionprocessTableLine(line,link,cal){if(!line.match(/\|.*\|.*\|.*\|.*\|.*\|.*\|/)){Logger.log("skipping line "+line)}line=line.substring(1,line.length-1);// strip "|" from the beginning and end.fields=line.split("|")varcfpStart=startDate(fields[0].trim());varcfpEnd=endDate(fields[0].trim());varconfStart=startDate(fields[1].trim());varconfEnd=endDate(fields[1].trim());varlocation=fields[2].trim();varname=stripLink(fields[3].trim());varkeywords=fields[5].trim();if(cfpStart&&cfpEnd&&cfpStart<=cfpEnd){createEvent('CFP '+name,cfpStart,cfpEnd,keywords,location,link,cal)}if(confStart&&confEnd&&confStart<=confEnd){createEvent(name,confStart,confEnd,keywords,location,link,cal)}}functioncreateEvent(name,start,endInclusive,keywords,location,link,cal){// end date is exclusive, so add 1 dayvarevt=cal.createAllDayEvent(name,start,addDays(endInclusive,1),{description: keywords+', see '+link,location: location});evt.setTag(tag.key,tag.value);}functionstartDate(dateString){// Date formats used in the CFP List:// 2018.12.08// 2018.11.27-29// 2018.11.30-12.01// For the start date, we can ignore stuff following the '-' character.match=dateString.match(/^([0-9]{4})\.([0-9]{2})\.([0-9]{2})(-.*)?$/)if(match){returndateFromCaptureGroups(match,1,2,3);}}functionendDate(dateString){// Date formats used in the CFP List:// 2018.12.08// 2018.11.27-29// 2018.11.30-12.01match=dateString.match(/^([0-9]{4})\.([0-9]{2})\.([0-9]{2})$/)if(match){returndateFromCaptureGroups(match,1,2,3);}match=dateString.match(/^([0-9]{4})\.([0-9]{2})\.([0-9]{2})-([0-9]{2})$/)if(match){returndateFromCaptureGroups(match,1,2,4);}match=dateString.match(/^([0-9]{4})\.([0-9]{2})\.([0-9]{2})-([0-9]{2})\.([0-9]{2})$/)if(match){returndateFromCaptureGroups(match,1,4,5);}}functiondateFromCaptureGroups(match,yearIndex,monthIndex,dayIndex){returnnewDate(parseInt(match[yearIndex],10),parseInt(match[monthIndex],10)-1,dayInt=parseInt(match[dayIndex],10));}functionstripLink(markdownString){// "[devoxx](https://devoxx.be)" -> "devoxx" returnmarkdownString.replace(/\[([^\]]+)\]\([^)]+\)/,'$1')}functionstartsWith(s,c){returns.indexOf(c)==0;}functionaddYears(date,years){varresult=newDate(date);result.setFullYear(date.getFullYear()+years);returnresult;}functionsubtractYears(date,years){returnaddYears(date,0-years);}functionaddDays(date,days){varresult=newDate(date);result.setDate(result.getDate()+days);returnresult;}functionopenCalendar(){varcalendars=CalendarApp.getCalendarsByName(calendarName);switch(calendars.length){case0:
// not found. create a new calendar.returnCalendarApp.createCalendar(calendarName,{summary: 'CFP calendar generated from ...'});case1:
// found. clear existing events, because events will be re-createdvartoday=newDate(),twoYearsAgo=subtractYears(today,2),// API requires a time range for getEvents. take a 4 year time range so we get all events.twoYearsFromNow=addYears(today,2),events=calendars[0].getEvents(twoYearsAgo,twoYearsFromNow);for(vari=0;i<events.length;i++){if(events[i].getTag(tag.key)===tag.value){events[i].deleteEvent()}}returncalendars[0]default:
thrownewError('found '+calendars.length+' calendars with name '+calendarName+'.');}}
The text was updated successfully, but these errors were encountered:
I wrote a little Google script that creates a
cfp
calendar from your list. To try it, go to drive.google.com, click New -> Google Apps Script, copy the code into the editor, selectsyncCfpCalendar
as the function to be executed and click the play button. Reload calendar.google.com and you should see a newcfp
calendar. Google also provides triggers so you can run this nightly (click Edit -> Current Project's Triggers).If you think this is useful, feel free to publish it, put it in a readme, provide a public calendar, whatever you want.
The text was updated successfully, but these errors were encountered: