battis.net and I'm all out of bubble gum…

Because I can’t stop playing with something that already works fine, I’ve continued to tweak my syllabus-generating spreadsheet. With the addition of an external script, I’m able to link directly to a specific cell in the spreadsheet — letting me share a link to my syllabi that takes people not just to the overall document, but to the current day (or the next day that’s closest to the current day) in the syllabus. The script could be used to link to any cell in any published Google Spreadsheet, with the caveat that if there are multiple cells with that match that value, the link will take you to the first appearance of the value in the spreadsheet.

$url = $_REQUEST["url"];
$key = $_REQUEST["key"];
$anchor = $_REQUEST["anchor"];
 
$html = file_get_contents($url);
$output = str_replace($key, "<a name="$anchor"></a>$key", $html);
$output = str_replace("href='/", "href='https://docs.google.com/", $output);
 
header("Content-Type: text/html");
echo $output;

This takes a GET URL of the format http://server/script?url=[url]&key=[key]&anchor=[anchor]#[anchor], where…

  • The URL is the URL of the published Google spreadsheet location.
  • The key is the text to search for in the spreadsheet (so you could link to anything in the published HTML, but it’s easiest to link to a unique value in a cell).
  • The anchor is the name of the HREF anchor you will be creating (note that you then need to, well… link to that anchor).
Enjoy. You can try it out on my server:
URL:
Key:
Anchor:

Nota Bene: You have to add your own link to the anchor — this is a quick, slapped-together connection to my script.

Update: I was sitting here staring at the script, trying to figure out why I hadn’t put the anchor tag around the key, and then I realized what’s going on. The key (on my spreadsheet) is formatted to be white text on a white background (Rothko-style, if you will). If it gets converted to an anchor, its styling is affected and (without more work in the script) it turns blue and underlined. Lame. So… the anchor goes before the key, so the key’s CSS style won’t be affected.

This is why you document your code. Even when it’s short.

October 31st, 2012

Posted In: How To

Tags: , , , , ,

I had hoped that someone else would have put together a handy flyer to explain better options for sharing files than sending email attachments. But in a casual search of the web, none came up. This is my initial pass at the problem of presenting the Web 2.0 and the cloud to folks who are comfortable with email, but who don’t feel confident in their use of other technologies.

The first pass is truly aimed at providing a flyer that could be tacked up next to someone’s monitor.

http://www.scribd.com/doc/111473318/So-I-want-to-share-a-document-smartly%E2%80%A6

I made a second version, which I posted to Google Docs, so that the links are clickable as well.

If you’d like to examine the assumptions and reasoning behind this, I have a flowchart that I felt… might not be as helpful in conveying these ideas.

For what it’s worth, when I was discussing the response to this broadsheet (broadside?) among the folks at school, my wife asked me if I sent this as an attachment.

She’s a funny one.

October 29th, 2012

Posted In: How To

Tags: , , , , , , , , , , , , , , , , ,

css.php