First off I apologize for be a slacker and not having time to post anything on this blog for quite some time. I’d like to say that I’m going to get better at it, but I probably won’t!
This past week I needed to get an iCal feed created for my DotCMS Calendar. What I came up with might not be the most elegant solution, but it does the trick for Outlook and Google Calendars at least. So I thought I’d post up my process …
First I started by creating an HTML page in DotCMS, and choosing the Blank Template. The next thing I did was create a new contentlet. The important thing to remember about this step is to name your contentlet something that is going to be ewasy to remember. The reason for this is that doing this will break the DotCMS Page Editor. You’ll see why a little latter.
Now for the code:
$response.setContentType('text/calendar')
$response.setHeader("Content-disposition","attachment;filename=calendar.ics")
#set($today = $UtilMethods.now())
#set($fromDate = $date.format("MM/dd/yyyy", $today))
#set($endDate = $UtilMethods.addDays($today, 30))
#set($toDate = $date.format("MM/dd/yyyy", $endDate))
#pullContent("+structureInode:135155 +date1:[01/01/1900 00:00:00
TO $toDate 23:59:59] +date2:[$fromDate 00:00:00 TO 01/01/3000 00:00:00]
+languageId:1 +deleted:false +live:true" '0' 'date1')
BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 9.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
CALSCALE:GREGORIAN
X-WR-TIMEZONE:America/New_York
X-WR-CALNAME:EUP Events
BEGIN:VTIMEZONE
TZID:US-Eastern
LAST-MODIFIED:19870101T000000Z
BEGIN:STANDARD
DTSTART:19971026T020000
RDATE:19971026T020000
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
TZNAME:EST
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19971026T020000
RDATE:19970406T020000
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
TZNAME:EDT
END:DAYLIGHT
END:VTIMEZONE
#foreach($content in $list)
BEGIN:VEVENT
DTSTAMP:$date.format("yyyyMMdd'T'HHmmss", $content.startDate)
DTSTART:$date.format("yyyyMMdd'T'HHmmss", $content.startDate)
DTEND:$date.format("yyyyMMdd'T'HHmmss", $content.endDate)
SUMMARY:$!content.title
UID:$!content.identifier
PRIORITY:3
CATEGORIES:MEETING
LOCATION:Edinboro
END:VEVENT
#end
END:VCALENDAR
Let me pick this apart section by section. First off we have what I like to call, “The Magic” of this whole thing:
$response.setContentType('text/calendar')
$response.setHeader("Content-disposition","attachment;filename=calendar.ics")
What this little bit of code does is set content type for the page, and tells the browser that this should be downloaded, not displayed in the screen. It also tells the browser exactly what the filename should be that they are downloading. This allows us to set the extension of .ics.
#set($today = $UtilMethods.now())
#set($fromDate = $date.format("MM/dd/yyyy", $today))
#set($endDate = $UtilMethods.addDays($today, 30))
#set($toDate = $date.format("MM/dd/yyyy", $endDate))
#pullContent("+structureInode:135155 +date1:[01/01/1900 00:00:00
TO $toDate 23:59:59] +date2:[$fromDate 00:00:00 TO 01/01/3000 00:00:00]
+languageId:1 +deleted:false +live:true" '0' 'date1')
Note: I had to break up the #pullContent into 3 lines so it would fit on the page, this should be one line.
This bit of code is probably fairly familiar to most of you reading this. Basically it is pulling the events from the last 30 days. You will of course need to make sure you change the structureInode to match what your Event Structure’s Inode is.
BEGIN:VCALENDAR PRODID:-//Microsoft Corporation//Outlook 9.0 MIMEDIR//EN VERSION:2.0 METHOD:PUBLISH CALSCALE:GREGORIAN X-WR-TIMEZONE:America/New_York X-WR-CALNAME:EUP Events BEGIN:VTIMEZONE TZID:US-Eastern LAST-MODIFIED:19870101T000000Z BEGIN:STANDARD DTSTART:19971026T020000 RDATE:19971026T020000 TZOFFSETFROM:-0400 TZOFFSETTO:-0500 TZNAME:EST END:STANDARD BEGIN:DAYLIGHT DTSTART:19971026T020000 RDATE:19970406T020000 TZOFFSETFROM:-0500 TZOFFSETTO:-0400 TZNAME:EDT END:DAYLIGHT END:VTIMEZONE
This is the begining of the iCal Code. It defines the Time Zone, the name, the version, and various other tidbits. I found it was necessary to put in the vTimeZone element for the calendar to show up in Google in the right times. I also found a nifty reference of the iCal Format Here.
#foreach($content in $list)
BEGIN:VEVENT
DTSTAMP:$date.format("yyyyMMdd'T'HHmmss", $content.startDate)
DTSTART:$date.format("yyyyMMdd'T'HHmmss", $content.startDate)
DTEND:$date.format("yyyyMMdd'T'HHmmss", $content.endDate)
SUMMARY:$!content.title
UID:$!content.identifier
PRIORITY:3
CATEGORIES:MEETING
LOCATION:Edinboro
END:VEVENT
#end
END:VCALENDAR
The rest of the code is fairly straight foward I think. Loop through each contentlet and create a vEvent item then bookend with your ending vCalendar. The hard part is the Time Format. I found putting in the Timezone here did not work in Google, perhaps you will have better luck.
Now, I know this isn’t perfect. I haven’t put in descriptions and nice locations and all that. This was a quick and dirty write-up to get what I needed done. I hope it benefits you, if you have any questions or suggestions I’d love to hear from you in the comments.
Where to go from here? I would love to see this macroized and/or wigitized and put into a plugin. I hope some day I have time to beef it up and learn more about what I can and can’t do with iCal. I would also like to put in the ability to give iCal Feeds for specific categories and tags. Ultimately, I would like to see the iCal download servelet that already exists in DotCMS fleshed out to this natively within the CMS.
Please if you have any suggestions on how to make this better or any improvements you’ve made on this, I’d love to hear about it in the comments.
Having just gone through this process, I thought I’d share the steps I took to enable SSL in DotCMS. On the DotCMS wiki there are some fairly brief instructions on how to enable SSL. A quick search on Tomcat and SSL will point you to their documentation which explains it step-by-step. So here it is all laid out in once nice How To. Note that I am using windows and our Certificate Authority id DigiCert. Your experience my vary.
The first steps is to generate the keystore. Tomcat, the java application server that DotCMS runs on, uses a format called Java KeyStore (JKS) for it’s keystores. The Java SDK provides all the tools necessary to get the task done. So, hop on over to where you have your SDK installed and follow along
C:\Program Files\Java\jdk1.6.0_03\bin>keytool -genkey -alias tomcat -keyalg RSA -keystore C:\DotCMS_keystore.key
You will need to enter some information about your organization and location. You will have have to choose a password for your keystore. Don’t forget the password or you’ll have to start over. You should now have a valid keystore with the alias of tomcat.
With the keystore in place you could skip all the way to the end now and have a fully functioning self-signed certificate. This is nice, but more likely you are looking to have a certificate authority such as DigiCert or Verisign sign your certificate. To do this you are going to need to generate a CSR or Certificate Signing Request. Thankfully the keytool takes care of that for us as well.
C:\Program Files\Java\jdk1.6.0_03\bin>keytool -certreq -alias tomcat -keyalg RSA -keystore C:\DotCMS_keystore.key -file c:\DotCMS_certreq.csr
You are going to be required to enter your keystore password, but this should generate the certificate request for you without too much trouble. Now you can take your DotCMS_certreq.csr to your signing authority and submit a request for a certificate. I am not going to cover that process because I don’t do that part, my sys admin does. Well, it is also different with each signing authority. Once you have your certificate you are ready to start the next step.
C:\Program Files\Java\jdk1.6.0_03\bin>keytool -import -trustcacerts -alias tomcat -file c:\star_edinboro_edu.p7b -keystore c:\DotCMS_keystore.key
Again, the keytool handles the dirty work for you and you’ll need that password again.
You could probably skip this step if you know you have the right password. Honestly the output of this command really didn’t tell me much other than I could see that my certificated had imported.
C:\Program Files\Java\jdk1.6.0_03\bin>keytool -list -v -keystore c:\DotCMS_keystore.key
The next step is going to require you to head to your DotCMS’s server.xml Add the following lines:
<Connector port="443" address="192.168.8.221"
protocol="HTTP/1.1"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="C:\DotCMS_keystore.key"
keypass="..." />
You will have to change the address and keypass to match your system.
That’s really all there is to it. Restart your DotCMS service and you can use openSSL to test the connection just like telnet.
C:\Program Files\Java\jdk1.6.0_03\bin>openssl s_client -connect 192.168.8.221:443 -state
After it establishes a connection you should see your certificate information. You will of course want to test the whole setup in a browser.
In order for DotCMS to use SSL you also need to set a page to use SSL in the properties. Create a test page, but before you save and publish head to the advanced properties and check the force https option. Now when you try to visit that page it should redirect you https if you are not already using it.
Hopefully this small little guide helps out anyone trying to figure out how to setup SSL in DotCMS.
Last week saw me in Miami at the DotCMS Open Minds Conference, Boot Camp. DotMarketing’s approach to the conference this year was slightly different this year. The focus was more on Training whereas last year was more like demo. I’d have to say that I really enjoyed the conference.
My journey to Miami started a day before the conference. I couldn’t get a flight in the day of the conference. It was fairly uneventful (that’s good!). The Hotel this year was the Mayfair. A little more ritzy than the Sonata, but still very nice. I ended up eating at the Johnny Rockets.
The conference didn’t officially start until the registration/welcome party at 6PM. Since I was there quite early I decided to jump over to DotMarketing Headquarters about 1PM. DotMarketing was nice enough to throw us Jason Tesser for some informal pre-conference training.
We talked a lot about the bits and pieces of DotCMS. Here are some take-aways from that conversation:
After the informal training we went back to the Hotel for the opening party. I got to meet back up with Fienen and meet some of the new folks from the DotCMS Community. A big welcome to IPFW who just made the decision to go with DotCMS and had a considerable force at the conference. After the party we (Jason, Fienen, and some others) headed to the Knife for dinner. The Knife was a very nice place to eat. It is an Argentinian Steak House Buffet kinda thing. Very Nice!
After dinner I had mega troubles with my laptop’s wireless. So that’s why this post is coming a little late.
Thursday started with breakfast at the Bookstore in the Grove. The first session of the day was on structures and relationships. I already knew much of the content here, but for the new guys this was a lot of bricks and mortar kind of training on the Back-End of DotCMS. I did manage to grab a couple morsels of goodness from the session though:
The rest of the day, I spent with Jason Tesser in a one-on-one session. This is the true value of the DotCMS conference. I am really happy to see a company that will give you one-on-one attention. Jason and I talked a lot about the nuts and bolts of the Content API and DotConnect Java Classes. I learned how to use the DotConnect Class to retrieve SQL results from my server and then use the Content API to update and insert new content into DotCMS structures. Very, very valuable stuff.
After the show a few of had a specialized training on administration of DotCMS. We learned that you can use JMX to debug some of the more interesting problems may run into with cache and other things in the system. It looked like really cool stuff, but it was a bit over my head. Andres did a great job of showing us what can can’t be done though.
I ended up going with a rather large group to a sushi place for dinner. I am not overly obsessed with sushi, but I went along and the place we went to was very nice. I had a fried shrimp/lettuce/rice roll that was actually very good.
Breakfast was at the bookstore again. We started the day off with Plugins Training. The training was very well laid out and was my main target for the conference. Jason covered a ton of information about what you can do with plugins and how they work. I wish there was more actual code, but when you are talking to a large audience that kind of thing would’ve been hard to pull off. I can’t say how stoked I am about the addition of plugins to the DotCMS product.
One of the cool things you can do with plugins is move all your configuration and custom macros out of DotCMS. This way if you ever need to restore a server or do an upgrade, you can just stick your plugin back in and you are essentially up and running. I plan on doing this as my first plugin and hope to have a good post about how it’s all done. That is, or corse, if Fienen doesn’t beat me to it
The last half of the day was on Ajax. While I was not overly interested in the ajax stuff, it was interesting to see some of the cool stuff that DotCMS can do there.
After the Ajax session we moved into the Focus Group / Roadmap / Deiscuss / Wrapup portion of the conference. I can’t tell you how impressed I am with the way DotCMS is developing. Here is what is in store for us in the coming year:
So, this has been a really long congolomo-blog post. Sorry for that. As you can see the conference was a great source of information! I thouroughly enjoyed myself and I think everyone that came got a ton of value out of it. Not to mention the networking possibilities. There are some really cool things in store for us this year. To say that I am giddy with anticipation would be an understatement.
Here are some additional links to information about the conference (more as I find them):
I seem to get a lot of questions on how to start with velocity coding. What is available? What is the Syntax? I think it’s a good question so it’s time to write up a quick post about it.
First off, I would start with actually building your site. Come up with a need. Start with something simple and something that you already have data for. I found that trial and error on real problems is the best way for me to learn a new language.
Most likely, if you’re trying to do something simple, there is already an example of how to do it in DotCMS’s Demo Site. The username/password is: test@dotcms.org/test. Remeber to put a /c after the host to get to the login page. I’ve found that most of my questions can be answered just by looking a good example.
From there my next stop is the documentation that DotCMS has on velocity:
If you really cannot find what you are looking for in that, the next step would be to look in the API docs. Now, if you’ve never looked at Javadocs before this might be a little overwhelming at first. But, I find it extremely useful when I am trying to do something out of the box. Browse to http://dotcms.org/api. From there scroll down the list and click on the “View Tools” class (com.dotmarketing.viewtools). From there you will get a list of all the api’s that DotMarketing has created.
That’s nice if what you want is a list of DotCMS’s View Tools, but if you are looking for the built in stuff, head over to Apache’s Velocity Site and click on the Tools link. From there click on Generic Tools and then the specific tool that want to look up.
I hope that helps to get new users up and going with velocity. If you still feel very confused, here is a lit of other resources that you might find handy:
Update: 1:12 PM, July 23, 2008:
Jim S. over in the DotCMS IRC group pointed out a velocity mailing list: http://www.nabble.com/Velocity—User-f347.html. Thanks Jim!
Also, that brings up a good point. We have a core group of DotCMS-er’s over in the #dotcms IRC chatroom. Feel free to jump on board and ask us your questions! We are on freenode.
Posting tweet...
Powered by Twitter Tools