📄 eventscheduler.cfm.txt
字号:
<!--- Base/Calendar API Cold Fusion Event Search Demonstration by Marc ScalettaThis is completely open - feel free to use it however you please. ---><html><head><title>Google Base/Calendar Event Scheduler</title><style type="text/css"> a { text-decoration: none; } a:hover { text-decoration: underline; }</style></head><body link="#1122CC" bgcolor="#AABBCC"><cfif (isdefined("addtocal"))> <!--- If we're adding the current data to the calendar, skip the search and process that data ---><cfif isdefined("when")> <!--- If there's a date... ---> <cfset startdate=trim(mid(when, 1, find(" ", when)))> <!--- Start date starts at the beginning, ends at the first space ---> <cfset enddate=trim(mid(when, find(" ", when) + 1, len(when)))> <!--- End date is the rest of it ---> <cfif startdate EQ ""> <!--- If the event JUST has a start date, startDate will be empty right now ---> <cfif mid(enddate, 12, 8) EQ "00:00:00"> <!--- If enddate has no time specified, chop it off ---> <cfset enddate = mid(enddate, 1, 10)> <cfelse> <!--- If there is a time, chop the "z" off the end so Calendar uses the local time zone ---> <cfset enddate=mid(enddate, 1, len(enddate) -1)> </cfif> <cfset startdate = enddate> <cfelse> <!--- Event has both start end end times, chop off the "z" ---> <cfset startdate=mid(startdate, 1, len(startdate) -1)> <cfset enddate=mid(enddate, 1, len(enddate) -1)> </cfif></cfif> <!--- Set up the initial Calendar XML entry ---><cfset xmlentry="<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005'> <category scheme='http://schemas.google.com/g/2005##kind' term='http://schemas.google.com/g/2005##event'></category> <title type='text'>#urldecode(title)#</title>"> <cfif isdefined("link")> <!--- If there's a link, add it to the entry ---> <cfset xmlentry = xmlentry & "<content type='text'><![CDATA[#urldecode(link)#]]></content>"></cfif><cfif isdefined("where")> <!--- If there's a location, add it to the entry ---> <cfset xmlentry = xmlentry & "<gd:where valueString='#urldecode(where)#'></gd:where>"></cfif><cfif isdefined("when")> <!--- If there's a time, add it to the entry ---> <cfset xmlentry = xmlentry & "<gd:when startTime='#startdate#'"> <cfif startDate NEQ endDate> <cfset xmlentry = xmlentry & " endTime='#enddate#'"> </cfif> <cfset xmlentry = xmlentry & "></gd:when>"></cfif><cfset xmlentry = xmlentry & "</entry>"> <!--- Send the entry to Google Calendar ---> <cfhttp url="http://www.google.com/calendar/feeds/default/private/full" method="post" redirect="no"> <cfhttpparam type="header" name="Content-Type" value="application/atom+xml"> <cfhttpparam type="header" name="Authorization" value="AuthSub token=#token#"> <cfhttpparam type="Body" value="#xmlentry#"> </cfhttp><cfoutput><!--- Debugging code - checking HTTP status code and other information ---><!--- <font size=-1>#cfhttp.header#<br>#cfhttp.statusCode#<br><br>#title#<br>#where#<br>#when#<br><br></font> ---> <cfif ((left(cfhttp.statusCode,3) EQ "302"))> <!--- If Google Calendar gives us a redirect, redirect ---> <cfset redir=#cfhttp.responseHeader["location"]#> <!--- Get redirect location ---> <cfhttp url="#redir#" method="post" redirect="no"> <!--- Send the old entry to the new location ---> <cfhttpparam type="header" name="Content-Type" value="application/atom+xml"> <cfhttpparam type="header" name="Authorization" value="AuthSub token=#token#"> <cfhttpparam type="Body" value="#xmlentry#"> </cfhttp> <center> <font size=+2 color="##4466DD" face="verdana"><b>CalendarMeIn</b></font><br>Google Base/Google Calendar Event Scheduler <font color="##787878">BETA</font> <br><br><br><br>The event "#title#" has been added to your calendar!<br><br> <a href="http://calendar.google.com">View Calendar</a> <br> <a href="eventscheduler.cfm?token=#token#&search=1">Back to Event Search</a></center><br><br> <!--- If Calendar returns a "500", "404" or "400" code, we have a problem... ---><cfelseif ((left(cfhttp.statusCode,3) EQ "500") or (left(cfhttp.statusCode,3) EQ "400") or (left(cfhttp.statusCode,3) EQ "404"))> <b><font size=+1>Unable to add event to Google Calendar. Please make sure you have a Google Calendar account set up and that you are logged into it. Please visit <a href="http://calendar.google.com" target="_blank">calendar.google.com</a> to sign up, then refresh this page to try again.</font></b><cfelse>Error - status:<br>#cfhttp.header# </cfif><!--- More debugging code ---><!--- #xmlentry#<br> <font size=-1>#cfhttp.header# - #cfhttp.filecontent#</font> ---></cfoutput> <cfelseif (isdefined("token") or isdefined("Cookie.calendartoken"))> <!--- If "token" is defined or if the token cookie exists, we can proceed ---><cfif isdefined("Cookie.calendartoken")> <!--- If there's a cookie with the token in it, grab it ---><cfset token = Cookie.calendartoken><cfset search="1"> <!--- Tells the app that we DO have a reusable token ---></cfif><cfif not isdefined("search")> <!--- If we don't have a reusable token, upgrade the one we have ---><cfoutput><cfhttp method="get" url="http://www.google.com/accounts/AuthSubSessionToken"> <cfhttpparam type="header" name="Content-Type" value="application/atom+xml"> <cfhttpparam type="header" name="Authorization" value="AuthSub token=#token#"> <cfhttpparam name="X-Google-Key" type="Header" value="key=REPLACE WITH YOUR DEVELOPER KEY"></cfhttp><cfset tk = cfhttp.fileContent><br><cfset startindex=find("=", tk)><cfset endindex=len(tk)><cfset token=trim(mid(tk,startindex+1,endindex))><cfcookie name="calendartoken" value=#token#> <!--- Once we get the token, set a session cookie so we don't have to keep getting it ---></cfoutput></cfif><br><FORM name="gbsearch" action="eventscheduler.cfm"> <!--- Submits the query to this same form, getting the Base results ---><table border="0" cellspacing="6" cellPadding="0" align=center><tr><td rowspan="3" valign="top" width=200><div style='padding:1px; width: 100%;border:1px solid black;text-align:center;background-color:#F1F1FF;'><font size=+2 color="#4466DD" face="verdana"><b>CalendarMeIn</b></font><br>Google Base/Google Calendar Event Scheduler <font color="#787878">BETA</font></div></td><td rowspan="3"> </td><td style="font-size:80%"> Event Type: <br><select name="eventType"> <option value="">All</option> <option value="Art ">- Art</option> <option value="Class OR Lesson OR Lecture">- Classes and Lectures</option> <option value="Comedy OR Stand-up OR Standup ">- Comedy</option> <option value="Food OR Cuisine ">- Food</option> <option value="Festival OR Fair ">- Festivals and Fairs</option> <option value="Music OR Concert ">- Music</option> <option value="Reading OR Signing ">- Readings and Signings</option> <option value="Shopping OR Sale OR Market ">- Shopping</option> </select> or other: <INPUT name="textQuery" type="text" size="20" <cfoutput><cfif isdefined("textQuery")>value="#textQuery#"</cfif></cfoutput>> <button type="submit" >Search for events</BUTTON></td></tr> <tr><td style="font-size:80%"> Location:<br> <select name="miles"> <option value="5">Within 5 miles</option> <option value="10">Within 10 miles</option> <option value="25">Within 25 miles</option> <option value="50">Within 50 miles</option> </select> of <input name="location" type="text" size="20" <cfoutput><cfif isdefined("location")>value="#location#"</cfif></cfoutput>><font color="#222222"> (leave blank for anywhere)</font></td></tr> <tr><td style="font-size:80%"> When:<br><select name="dateMonth"> <option value="00">Any</option> <option value="01">January</option> <option value="02">February</option> <option value="03">March</option> <option value="04">April</option> <option value="05">May</option> <option value="06">June</option> <option value="07">July</option> <option value="08">August</option> <option value="09">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> <select name="dateDay"> <option value="00">Any</option> <option value="01">1</option> <option value="02">2</option> <option value="03">3</option> <option value="04">4</option> <option value="05">5</option> <option value="06">6</option> <option value="07">7</option> <option value="08">8</option> <option value="09">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -