A day of going nowhere

OK, so the user login stuff is working now, though those annoying change password bugs are still there (the first box is filled in with some random crap and if you try to submit different password and confirmation you get a list of users to choose from). Going to leave bug fixing for now, though i’ll ask about it on the forums.

Next step is to add the links section – just the manual stuff for now. Functionality:

  • The user can click on ‘add a link’, and be presented with a page which is effectively the same as the one they use to add a link to the list page.
  • Once added, a link is associated with the article above.
  • Links and articles have a many-to-many relationship – an article can have many links and a link can be associated with many articles.
  • The user should have the option to add the link to the article list while they’re at it (not all links should be articles in their own right but many of them will probably belong there

This has raised a complication: some links are also articles. Like it says above, when adding a link the user should have the option of ‘promoting’ it to a fully fledged article. That raises the complication of how to store articles and links: originally it was going to be a many to many relationship between articles and links, but if articles can link to other articles as well (which they should i think) then you have a many to many articles-links and a many to many articles-articles.

I’m not sure how to best go about this – maybe it’s better to have a single list of articles but add a field called ‘link’ which is checked for items that aren’t 1st class articles?

While i think about this (and wait for some advice to come back), i’m going to try to get the ‘add the current article’ link working. This requires getting the url and title of the web page currently visible in the iframe, which as far as i can tell requires the use of some javascript ( i found some javascript to do this on the net): if my iframe is called frame1 i can say something like (in javascript)

title = top.frame1.document.title;

I found out how to embed some javascript into html:

From a javascript (.js) file –

<script type=”text”/javascript”
src=”myjavascript.js”></script>

Or inline –

<script type=”text/javascript”>
<!–
//javascript here
–>
</script>

So, i can get my rhtml page to do something dumb like pop up an alert box, so the javascript is working. However, when i try and do an alert that puts up the title, with

string 2 = (“title = ” + parent.myframe.document.title);
alert(string2);

Then nothing happens – it’s as if the javascript is failing, and just stops, so never gets to the alert line.

Also, i’ve got no idea how to integrate that with rails. What i need is a javascript function that returns something, and then have rails set a variable equal to the result. Not having much look with the forums today.

Made some very slight progress – i can display the title and url of the current page (still just in javascript), but only the page that holds the iframe (ie the show page), not the iframe itself. I’m being denies permission to access the iframe (i found this out by installing a handy firefox plugin called ‘firebug’ which is a debugging tool for teh interweb):

uncaught exception: Permission denied to get property HTMLDocument.title

Today’s been a writeoff pretty much. Found a few things out, and maybe worked out why i couldn’t get what i wanted to work, but haven’t actually managed to DO anything. Better luck tomorrow.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

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