Blogmarks added

As you’ve probably noticed, the blogmarks are visible on the right menu (throughout the site - should be only on the index page, but I haven’t figured out how to do that in a MT global template). If you’ve not got Javascript enabled you won’t see them - the only way I could get dynamic content into a static MT-generated site. Archives will follow.

_[Apologies to Simon for nicking the format - well, they do say imitation is the sincerest form of flattery!]_

h2. Some notes on the implementation

The bookmarklet comes from “Clagnut”:http://clagnut.com/blog/264/ and was used without modification (other than to enter my site’s URI).

h3. Extracting the referrers’ title

I also pinched the logic of his PHP code to grab the title from the referring site, but rewrote it to make it a bit more compact (and hopefully more efficient):

bc. if ($open=@fopen($_GET['via_url'],”r”)) {
while(!feof($open)) {
$line=@fgets($open, 1024);
if (preg_match(’!([^!i', $line, $matches)) {<br /> break;<br /> }<br /> }<br /> fclose($open);<br /> $via_title = $matches[1];</p> <p>It still needs tuning, so the connection dies quicker if the page cannot be found.</p> <p>h3. Storing the blogmarks</p> <p>A simple table, based on the one “Simon uses”:http://simon.incutio.com/archive/2003/11/24/blogmarks but of course with the column names altered slightly :-).</p> <p>bc. CREATE TABLE “blogmarks” (<br /> “blogmark_id” int4 DEFAULT nextval(’”blogmarks_blogmark_id_seq”‘::text) NOT NULL,<br /> “link_url” varchar,<br /> “link_title” varchar,<br /> “comments” varchar,<br /> “via_url” varchar,<br /> “via_title” varchar,<br /> “date_added” timestamp<br /> );<br /> CREATE UNIQUE INDEX “blogmarks_blogmark_id_key” ON “blogmarks” (”blogmark_id”);</p> <p>(This is using PostgreSQL - yes I’m pretty sure the ID should be bigger than int4, but when I said ‘Integer’ that’s what it gave me…)</p> <p>h3. PHP code</p> <p>Very simple in concept, but mine is currently very complicated in execution. I decided to use writing this application as a learning exercise in “DB_DatabOject”:http://pear.php.net/manual/en/package.database.db-dataobject.php - which was way overkill, and I can’t see the use for either. I mean, treating your database as objects just doesn’t seem to make sense. Still, at least I’ve made up my mind now <img src='http://peter.mapledesign.co.uk/weblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br /> I am hoping to release the code once I’ve got it cleaned up and finished writing everything - not sure though whether it’ll be using the native PHP PostgreSQL functions (if so the first time I’ve coded specifically for a database for over a year) or some DBA(Database Abstraction) layer. Part of the script currently uses “MDB”:http://pear.php.net/manual/en/package.database.mdb.php but again it feels like way too much load for such a tiny script. Oh, and there’s no templating at present either - not because I didn’t think it would be a good idea, but because I wanted to write something quickly that worked.</p> </div> <!-- You can start editing here. --> <div id="comments"> <h3 class="comment_intro">3 comments ↓</h3> <dl id="comment_list"> <dt id="comment-180"> <span class="comment_num"><a href="#comment-180" title="Permalink to this comment">#1</a></span> <strong><a href='http://dharik.com/' rel='external nofollow'>dan</a> </strong>on 12.19.03 at 5:45 am </dt> <dd class="entry"> <p>how do u add blogmarks please?</p> </dd> <dt id="comment-181"> <span class="comment_num"><a href="#comment-181" title="Permalink to this comment">#2</a></span> <strong><a href='http://www.kayodeok.co.uk/weblog/' rel='external nofollow'>Kayode Okeyode</a> </strong>on 12.19.03 at 8:46 pm </dt> <dd class="entry"> <p>Thanks for the insight on how to do this. I will definitely take a look at Clagnut’s Bookmarklet and since I have been using FeedDemon recently, I think it is time to programmatically extract the links stored in its News Bin as it is stored in rss format. I still need more ideas but this was a good start. Thanks.</p> </dd> <dt id="comment-182"> <span class="comment_num"><a href="#comment-182" title="Permalink to this comment">#3</a></span> <strong><a href='http://dharik.com/' rel='external nofollow'>dan</a> </strong>on 12.20.03 at 10:46 am </dt> <dd class="entry"> <p>thank you for updating post <img src='http://peter.mapledesign.co.uk/weblog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> </dd> </dl> <!-- Comment Form --> <h3 id="respond">Leave a Comment</h3> <form action="http://peter.mapledesign.co.uk/weblog/wp-comments-post.php" method="post" id="comment_form"> <p><input class="text_input" type="text" name="author" id="author" value="" tabindex="1" /><label for="author"><strong>Name</strong></label></p> <p><input class="text_input" type="text" name="email" id="email" value="" tabindex="2" /><label for="email"><strong>Mail</strong></label></p> <p><input class="text_input" type="text" name="url" id="url" value="" tabindex="3" /><label for="url"><strong>Website</strong></label></p> <!--<p><small><strong>XHTML:</strong> You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> </small></p>--> <p><textarea class="text_input text_area" name="comment" id="comment" rows="7" tabindex="4"></textarea></p> <p style="clear: both;" class="subscribe-to-comments"> <input type="checkbox" name="subscribe" id="subscribe" value="subscribe" style="width: auto;" /> <label for="subscribe">Notify me of followup comments via e-mail</label> </p> <p> <input name="submit" class="form_submit" type="submit" id="submit" tabindex="5" value="Submit" /> <input type="hidden" name="comment_post_ID" value="98" /> </p> </form> </div> <!-- Close #comments container --> </div> <div id="sidebar"> <p id="rss"><a href="http://peter.mapledesign.co.uk/weblog/feed" title="Subscribe to this site's feed"></a></p> <ul class="sidebar_list"> <li class="widget"> <h2>Search</h2> <form method="get" id="search_form" action="http://peter.mapledesign.co.uk/weblog/"> <input type="text" class="search_input" value="To search, type and hit enter" name="s" id="s" onfocus="if (this.value == 'To search, type and hit enter') {this.value = '';}" onblur="if (this.value == '') {this.value = 'To search, type and hit enter';}" /> <input type="hidden" id="searchsubmit" value="Search" /> </form> </li> <li id="categories-1" class="widget widget_categories"><h2 class="widgettitle">Categories</h2> <ul> <li class="cat-item cat-item-13"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/algorithms" title="View all posts filed under Algorithms">Algorithms</a> (4) </li> <li class="cat-item cat-item-25"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/business-ideas" title="View all posts filed under Business Ideas">Business Ideas</a> (1) </li> <li class="cat-item cat-item-33"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/christian" title="View all posts filed under Christian">Christian</a> (2) </li> <li class="cat-item cat-item-23"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/computer-related" title="View all posts filed under Computer related">Computer related</a> (3) </li> <li class="cat-item cat-item-3"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/css" title="View all posts filed under CSS">CSS</a> (1) </li> <li class="cat-item cat-item-22"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/databases" title="View all posts filed under Databases">Databases</a> (2) </li> <li class="cat-item cat-item-8"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/development-musings" title="View all posts filed under Development musings">Development musings</a> (2) </li> <li class="cat-item cat-item-34"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/django" title="View all posts filed under Django">Django</a> (1) </li> <li class="cat-item cat-item-37"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/ethics" title="View all posts filed under Ethics">Ethics</a> (1) </li> <li class="cat-item cat-item-5"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/general-programming" title="View all posts filed under General Programming">General Programming</a> (8) </li> <li class="cat-item cat-item-30"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/gtd" title="View all posts filed under GTD">GTD</a> (1) </li> <li class="cat-item cat-item-26"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/hci" title="View all posts filed under HCI">HCI</a> (1) </li> <li class="cat-item cat-item-24"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/interaction-design" title="View all posts filed under Interaction Design">Interaction Design</a> (1) </li> <li class="cat-item cat-item-10"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/links-for-future-reference" title="View all posts filed under Links (for future reference)">Links (for future reference)</a> (3) </li> <li class="cat-item cat-item-2"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/misc" title="View all posts filed under Misc.">Misc.</a> (22) </li> <li class="cat-item cat-item-9"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/photography" title="View all posts filed under Photography">Photography</a> (2) </li> <li class="cat-item cat-item-6"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/php" title="View all posts filed under PHP">PHP</a> (25) </li> <li class="cat-item cat-item-15"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/physics" title="View all posts filed under Physics">Physics</a> (6) </li> <li class="cat-item cat-item-4"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/python" title="View all posts filed under Python">Python</a> (5) </li> <li class="cat-item cat-item-7"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/quests" title="View all posts filed under Quests">Quests</a> (1) </li> <li class="cat-item cat-item-27"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/questsdocumenting-and-archiving-tool" title="View all posts filed under Quests/Documenting and archiving tool">Quests/Documenting and archiving tool</a> (2) </li> <li class="cat-item cat-item-20"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/questsemail-client" title="View all posts filed under Quests/Email Client">Quests/Email Client</a> (2) </li> <li class="cat-item cat-item-11"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/questsformprocessor" title="View all posts filed under Quests/FormProcessor">Quests/FormProcessor</a> (18) </li> <li class="cat-item cat-item-28"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/questsphp-ide" title="View all posts filed under Quests/PHP IDE">Quests/PHP IDE</a> (5) </li> <li class="cat-item cat-item-29"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/questsrss-reader" title="View all posts filed under Quests/RSS Reader">Quests/RSS Reader</a> (1) </li> <li class="cat-item cat-item-18"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/queststemplates" title="View all posts filed under Quests/Templates">Quests/Templates</a> (1) </li> <li class="cat-item cat-item-19"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/rants" title="View all posts filed under Rants">Rants</a> (8) </li> <li class="cat-item cat-item-21"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/requests" title="View all posts filed under Requests">Requests</a> (6) </li> <li class="cat-item cat-item-32"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/running-a-business" title="View all posts filed under Running a business">Running a business</a> (2) </li> <li class="cat-item cat-item-16"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/site-related" title="View all posts filed under Site related">Site related</a> (13) </li> <li class="cat-item cat-item-1"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/uncategorized" title="View all posts filed under Uncategorized">Uncategorized</a> (9) </li> <li class="cat-item cat-item-14"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/web-development" title="View all posts filed under Web development">Web development</a> (21) </li> <li class="cat-item cat-item-31"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/web-hosting" title="View all posts filed under Web hosting">Web hosting</a> (1) </li> <li class="cat-item cat-item-12"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/web-related" title="View all posts filed under Web related">Web related</a> (20) </li> <li class="cat-item cat-item-17"><a href="http://peter.mapledesign.co.uk/weblog/archives/category/weblog-tools" title="View all posts filed under Weblog tools">Weblog tools</a> (4) </li> </ul> </li> <li id="recent-posts" class="widget widget_recent_entries"> <h2 class="widgettitle">Recent Posts</h2> <ul> <li><a href="http://peter.mapledesign.co.uk/weblog/archives/pinnacle-cart-and-hsbc-cpi">Pinnacle Cart and HSBC-CPI </a></li> <li><a href="http://peter.mapledesign.co.uk/weblog/archives/osx-windows-the-adobe-stink">OSX & Windows - the Adobe stink </a></li> <li><a href="http://peter.mapledesign.co.uk/weblog/archives/why-an-apple-mac">Why a Mac? </a></li> <li><a href="http://peter.mapledesign.co.uk/weblog/archives/never-use-plusnet">Never use Plusnet! </a></li> <li><a href="http://peter.mapledesign.co.uk/weblog/archives/moral-dilemma">Moral Dilemma </a></li> </ul> </li> </ul> </div> </div> </div> <div id="footer"> <p>© Peter Bowyer’s weblog — <a href="http://www.copyblogger.com">Copyblogger</a> theme design by <a href="http://pearsonified.com">Chris Pearson</a></p> </div> <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-990240-1"; urchinTracker(); </script> </body> </html>