Coming Soon – Embedded Reviews

Chris has stated his desire to be able to embed his DvdFriend reviews elsewhere in the internet galaxy. Interesting idea. I haven’t done that before. (For those of you just joining us, I’m not real big on building web pages. There are a lot of things I haven’t done.)

Anyway, I started looking into this. The first thing that jumped to mind was left over from 1995: Add an iframe. The second thing to jump to mind was: don’t be ridiculous.

I started searching on the current swell ways to do this. The goal, per normal, is keep it simple. I just want the user to drop a little piece of something on their page and have it work. I came across XSS pretty quick, then avoided it since XSS is often associated with bad mojo due to attacks. I looked at the object
tag… Couldn’t get it to work with external web pages.

Eventually, I ended up back to XSS.

Created A Page called ReviewScript.aspx
I wiped out everything from the ASPX except for the server tags at the top.

The PageLoad calls Response.Clear(). It then builds a big piece of javascript that, basically, generates some html then writes it to the document.

Add a script tag to the page that references ReviewScript.aspx
Every time I paste any type of tag into this stupid thing, it loses it. And I’m currently too lazy to deal with a screen shot. So, mentally fill in angle brackets.

script language=’javascript’ type=’text/javascript’ src=’http://www.dvdfriend.us/ReviewScript.aspx?id=xxx’
/script

Sweet. I started by including that on the dvdfriend main page (dev version) so that I can compare whats generated to what shows up on the page.

Templates / Make it look as it does on the main page

The generated html is based on a template. The default template is going to look exactly like a rewiew does on the main page. I started by embedding the script on the main page so that I could look at them next to each other. Once it was close, I moved it to another site altogether.

Create a new CSS

As soon as I imported the dvdfriend.css to the other site, it messed up the entire page. That was expected. I created a new css called external.css and copied over only the styles i needed. I renamed them all with a prefix of DF, just to keep them separated.

Incidentally, the css is included by document.writing a link tag.

That pretty much did it.

Template – So Far

The template has these tokens so far:
DvdFriendCss
Rating
Title
ProductTypeImage
ProductName
ProductId
CreateDate
Author – pending. Have to populate this
RatingClass
AuthorLink
ProductLink
ReadLink

The list will grow. Most of them are just pieces of data so that you can build it anyway you want. Some of them are more generic to give you something to start with. the LINK tokens, for example, automatically create the links as you see them on the home page now.

TODO

– See if there is a better way to include the CSS. If there are multiple embeds on the same page, it will import the css multiple times. Would rather do it through javascript.

– Retrieve the author. The page is built from a datatable. The script is built from a blog object which, mysteriously, doesn’t already have an AUTHOR property exposed.

– Work out some additional css issues. It almost looks like it does on the site, but I still have some font issues to resolve.

– Test in production environment. I’ve only used it on my local machine. Lets see if it actually works out there. Furthermore, lets see what types of things, if any, prevent the xss from firing.

– LATER: Allow for users to create their own templates using the available tokens. I think that every template will be available to every user, but it can only be editted by the person who created it. We’ll see.

– Brush my teeth and go to bed

– Server it as a WCF service rather than an aspx page. The aspx is a quick and dirty just to get it going. I will convert it to a WCF service much like the RSS feed. The one missing piece of info there is how to pass parameters. It shouldn’t be a big deal; I just have to look into it.

Screenshot

Here’s what it looks like embedded on the now neglected Clan Friend site.

The background of the review is always white. Its not inheriting it from the parent element.

Advertisements

One Response to Coming Soon – Embedded Reviews

  1. Chris, Certified Scrum Master says:

    Definitely, Mostly, Surely, Absolutely, the most awesome development ever!

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: