Squiz Matrix and Using Complex Keyword Modifiers

7 months ago by Nicholas Hubbard in #Matrix #PUC

Today I was working on creating a .ics file for Pacific Union College and I ran into a problem. Because I wasn't using an asset listing (using a Rolling Calendar Page) I wasn't able to use conditional keywords in order to change some of my output.

The problem was, iCal files are picky. They have to validate just like an RSS feed would. The DTSTART property must be printed differently if it doesn't contain a time. I wanted to check the results of a keyword to see if it didn't contain a time, which shows up as --:--:--. I also needed it to write some extra text if it didn't contain time. Here is what I came up with:

%asset_attribute_start_date^contains:--^replace:3:;VALUE=DATE^replace:0:%

Breaking It Down

Here is how this keyword works. It will be printing the date/time in two different ways. Assets that have a time will print like 20110122T111500 while another might just print 20110122, which is without a time. If I don't have a time, I need to also add ;VALUE=DATE, this tells the file it is only a date.

The keyword modifier looks at the result of the asset_attribute_start_date keyword and checks to see if it contains any --, if it does, it will return the number of times it find that, in my case, 3. So, I want to replace that number 3 with ;VALUE=DATE but if it returns 0 (meaning it found nothing) then we just want to replace it with a blank string.

It seems complicated but it actually is really logical and works really well. Very powerful stuff!

I found a bug in Matrix that prevents keyword modifiers from being used on event keywords such as %event_start_time_12h%, so if that had worked there would have been more than one way to accomplish this.

ZSImageView: A UIImageView Replacement for Loading Remote Images

When working on the iPad version of the Pacific Union College app I had a need for a UIImageView that could load a remote image while showing a default image during the loading time. Since I am doing everything I can to get away from the horrible Three20 Library, I figured that I would write my own UIImageView replacement.

ZSImageView allows remote image loading, using a default image and also rounding the edges of the view. It is pretty easy to add a ZSImageView to your project.

Download ZSImageView on github

  • ZSImageView

Create a ZSImageView and set the remote and default image:

ZSImageView *imageView = [[[ZSImageView alloc] initWithFrame:CGRectMake(0, 0, 200.0f, 200.0f)] autorelease];
imageView.imageUrl = @"http://www.desktopwallpaperhd.com/wallpapers/3/4501.jpg";
imageView.defaultImage = [UIImage imageNamed:@"no-image.png"];
imageView.contentMode = UIViewContentModeScaleAspectFill;
[self.view addSubview:imageView];

If you want to round two of the edges and give the view a cornerRadius of 10 it is pretty easy:

ZSImageView *imageView = [[[ZSImageView alloc] initWithFrame:CGRectMake(0, 0, 200.0f, 200.0f)] autorelease];
imageView.imageUrl = @"http://www.desktopwallpaperhd.com/wallpapers/3/4501.jpg";
imageView.defaultImage = [UIImage imageNamed:@"no-image.png"];
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.corners = ZSRoundCornerTopLeft | ZSRoundCornerBottomLeft;
imageView.cornerRadius = 10;
[self.view addSubview:imageView];

ZSImageView requires the QuartzCore.framework. Once you have that added you need to copy ZSImageView.h and ZSImageView.m as well as JMImageCache.h and JMImageCache.m to your project. Then #import the ZSImageView.h header file where you need it and start using it.

Download ZSImageView on github

PUC Website Moves to a VM in the Cloud

9 months ago by Nicholas Hubbard in #Matrix #PUC

The Pacific Union College website had a problem. Our servers were nearing 5 years old, both of them out of warranty and feeling very slow with aging hardware. Our version of Squiz Matrix was 3.24.3, a version which came out on December 7, 2009. I had patched in a few of the newer features of Matrix such as more SOAP methods and JS API methods, but it was starting to feel like a patchwork of old version code and a bit of new code for added functionality. We were in need of an upgrade badly, but we could not afford to have Squiz do the upgrade for us. I know that they would have done a wonderful job, but we just didn't have the money. So, we made the decision to move the PUC website over to a VM on our internal cloud. This would allow us the flexibility of a VM and the power of the cloud.

  • Listing

The migration took a few days of planning including writing out all of the upgrade steps that would be needed and finally doing a number of test upgrades from our backup files. We ran into many issues during testing, but lucky for us we were just in the testing and documenting state, so each error or issue we had was good news because we could figure out what was wrong then write down those steps so we wouldn't have the same issue next time.

Once all testing and steps had been completed we implemented an editing freeze and used our most recent backup file. The entire upgrade from 3.24.3 to 4.4.0 took the better part of the day, but by 4:00pm we were ready to move over from our physical servers to our finalized VM of Squiz Matrix 4.4.0. Everything went fairly smoothly, just a few forgotten steps and a script that needed to be ran here or there, but for the most part it was very easy and extremely successful.

I would have to say the most wonderful thing about being on a VM now is that we can easily take a quick snapshot of the system, then move on to upgrading to the most recent version. Since 4.4.1 had come out we decided to make the quick upgrade to make sure that we were completely up-to-date. Again, the process was painless thanks to the Automatic Upgrade scripts.

All in all it was a very successful migration and we are extremely happy with our decision to move to a VM. Look for puc.edu 3.0 coming in the future.

Building the PUC Mobile iPhone App

11 months ago by Nicholas Hubbard in #iOS #Matrix #PUC

In April, Pacific Union College* released its first mobile app called "PUC Mobile". It it is built for iOS devices and has a number of useful features such as News, Photos, Events and a Cafe Menu. The app had been in the planning and development state for quite some time, so I wanted to detailed how that process went and how I worked to develop PUC Mobile.

  • iPad Viewpoint Layout

The Beginning

While PUC had a great website, we didn't have a mobile presence. With the use of smart phones skyrocketing, we knew that we needed to get into the game if we wanted to compete. Initially we came up with an exhaustive list of features and talked with a student about developing the app. After a few months of planning it fell through and the app was again placed on the "back burner" list of projects.

I knew that we needed to start the project and I didn't want to wait any longer, so I made time in my schedule to start the development in-house.

The Features

When development started, it was clear that many of the features on our wish list were not going to happen. I really wanted to have integration with student class schedules and checking of grades, but this wasn't possible with our current records data management solution, so these features were scrapped.

  • iphone
  • iphone

I do think that our initial features are great, here is what they are:

  • News
    Read and share current and archived news stories.
  • Photos
    View and download photos from events, activities, sports and PUC in Pictures.
  • Events
    Stay up to date with everything happening at PUC. See what is happening today, next week, or even next year. You can even add events to your iPhone calendar so that you can be alerted when they are coming up.
  • Maps
    Find on-campus locations, food in the valley, and exciting local places. See information about these locations, give them a call with one click, or map to that location from PUC or your current location.
  • Campus Directory
    Search a listing of faculty and campus department numbers, which can easily be called, emailed or added as a contact on your phone.
  • Cafe Menu
    Find out real-time what is currently being served at the PUC Dining Commons.
  • Contact
    Submit questions and comments to PUC right from the app.
  • Social Networking
    Quickly and easily share PUC news and events with your friends on Facebook, Twitter and e-mail.
  • Retina Display Graphics
    All images and graphics have been optimized for the retina display.
  • Offline Access
    Content is cached locally so that if you don't have an internet connection you can still view content that you have loaded before.

The Development

When I started the development on PUC Mobile, I knew that I would be sourcing the data from our Squiz Matrix CMS (future blog post coming about this). In doing this I needed to make sure that the UITableView would wait until the data was ready. To do that I decided to use the three20 framework which uses TTTableViewController which is a subclass of UITableViewController. Using it allows the app to gather the data in the background and only display it to the user once it is ready.

Another one of great features that three20 provides is TTImageView. It allows you to "lazy load" images within the tableView. This means that we can load images into our table cells starting with a default image, while in the background loading the image data from a url that is specified. Once the data is loaded the default image gets replaced with the loaded image. This makes tableView scrolling much quicker and smoother. Creating a TTImageView object is very easy:

TTImageView* imageView = [[[TTImageView alloc] initWithFrame:CGRectMake(30, 30, 0, 0)] autorelease];
imageView.defaultImage = [UIImage imageNamed:@"default.png"];
imageView.urlPath = @"http://www.puc.edu/myImage.png"; 
[self.view addSubview:imageView];

The Future

Right now the layout of the app is not optimized for the iPad. This will all change this summer when we launch our new 1.2 version with full universal support. We are also adding a number of new features, including Video and Audio that support AirPlay. AirPlay is an amazing new feature of iOS that allows you to stream audio and video content from your iOS device to AirPlay enabled hardware, namely an AppleTV. The new features that I am working on for 1.2 are:

  • Video (with AirPlay)
  • Audio (with AirPlay)
  • Degrees
  • Viewpoint (Alumni Magazine)

Here are what some of the layouts look like for the new features.

  • iphone
  • iphone
  • iphone

I think that the iPad layout for our Viewpoint magazine is particularly awesome. Each issue is loaded as a PDF using the QuickLook framework. They can also be opened and saved in iBooks.

  • iPad Viewpoint Layout

Conclusion

It has been great experience developing PUC Mobile. I have really enjoyed working to build a useful and successful app while trying to compete with and exceed what other school are doing with their mobile apps.

More to come in the future.

*My full-time job is working as the Webmaster of Pacific Union College.