Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

lots of widget work - the widget now works as before, with better for…

…matting, much simpler code
  • Loading branch information...
commit 7a6e88f23388f1404388bbc9c8ded5425e8fdc70 1 parent 00cfed3
Cal Henderson authored
BIN  images/browser.gif
BIN  images/browser_mini.gif
37 templates/inc_widget_html.txt
... ... @@ -0,0 +1,37 @@
  1 +{if $smarty.get.mini}
  2 + {assign var='w' value=80}
  3 + {assign var='h' value=15}
  4 + {assign var='src' value='browser_mini.gif'}
  5 +{else}
  6 + {assign var='w' value=143}
  7 + {assign var='h' value=54}
  8 + {assign var='src' value='browser.gif'}
  9 +{/if}
  10 +{assign var='menu_w' value=200}
  11 +{math assign='menu_offset_x' equation="0-((menu_w-w)/2)" w=$w menu_w=$menu_w}
  12 +{math assign='menu_offset_y' equation="h+5" h=$h}
  13 +
  14 +
  15 +<div id="london-bloggers-widget-{$uid}" style="position: relative; width: {$w}px;">
  16 + <div style="position: relative;">
  17 + <a href="{$cfg.abs_root_url}" onclick="return ToggleTubeMenu('{$uid}');"><img border="0" style="border: 0" src="{$cfg.abs_root_url}images/{$src}" width="{$w}" height="{$h}"></a>
  18 + </div>
  19 + <div id="london-bloggers-widget-menu-{$uid}" style="position: absolute; left: {$menu_offset_x}px; top: {$menu_offset_y}px; zIndex: 10; background-color: #fff; width: {$menu_w}px; display: none">
  20 + <div style="border: 1px solid #666666; font-size: 11px; font-family: Arial, Helvetica, sans-serif; padding: 8px;">
  21 +
  22 +{foreach from=$stations item='station'}
  23 + <b>Weblogs at <a href="{$cfg.abs_root_url}stations/{$station.id}/">{$station.name|escape}</a>:</b><br>
  24 + <br>
  25 + {foreach from=$station.weblogs item='weblog'}
  26 + &bull; <a href="{$weblog.blog_url|escape}">{$weblog.blog_name|escape}</a><br>
  27 + {/foreach}
  28 + {if $station.more}
  29 + &bull; and {$station.more} more...<br>
  30 + {/if}
  31 + <br>
  32 +{/foreach}
  33 + <b><a href="{$cfg.abs_root_url}">Are you a London Blogger?</a></b>
  34 +
  35 + </div>
  36 + </div>
  37 +</div>
20 templates/js_widget.txt
... ... @@ -0,0 +1,20 @@
  1 +{"Content-type: text/plain; charset=UTF-8"|header}
  2 +{capture assign='html'}{include file='inc_widget_html.txt'}{/capture}
  3 +var html = '{$html|trim|escape:'javascript'}';
  4 +
  5 +{literal}
  6 +
  7 +var needs_close = false;
  8 +if (document.all && navigator.appVersion.toLowerCase().indexOf("mac") == -1) needs_close = true;
  9 +if (navigator.userAgent.indexOf('Gecko') != -1) needs_close = true;
  10 +
  11 +document.write(html);
  12 +if (needs) document.close();
  13 +
  14 +function ToggleTubeMenu(uid){
  15 + var m = document.getElementById('london-bloggers-widget-menu-'+uid);
  16 + m.style.display = m.style.display == 'block' ? 'none' : 'block';
  17 + return false;
  18 +}
  19 +
  20 +{/literal}
10 templates/page_widget_demo.txt
@@ -13,14 +13,14 @@
13 13 If you're using an older browser, it will just take you to the london bloggers homepage.<br>
14 14 <br>
15 15 To show multiple stations in your weblog browser, change the "ids=5" part of the code
16   - into "ids=5,12" where 5 and 12 are the station numbers (you can find these out by looking
17   - at the weblog browser code on each station's page). You can add as many station id's as you
18   - like, seperated by commas e.g "ids=1,2,3,4,5,6".<br>
  16 + into "ids=5,12" where 5 and 12 are the station IDs (you can find these out by looking
  17 + at the weblog browser code on each station's page). You can add as many station IDs as you
  18 + like, seperated by commas (e.g. "ids=1,2,3,4,5,6").<br>
19 19 <br>
20 20 To use the mini version of the browser, add <code>&amp;mini=1</code> after the station ids.
21   - It will then use the following graphic:<br>
  21 + The mini version looks like this:<br>
22 22 <br>
23   - <img src="/images/browser_mini.gif" width="80" height="15" />
  23 + <script src="/widget/?ids=3,4&mini=1" type="text/javascript"></script>
24 24 </div>
25 25
26 26 {include file='inc_foot.txt'}
62 widget.php
... ... @@ -0,0 +1,62 @@
  1 +<?
  2 + include("include/init.php");
  3 +
  4 +
  5 + #
  6 + # fetch stations / weblogs
  7 + #
  8 +
  9 + $stations = array();
  10 +
  11 + $ids = explode(',', $_GET['ids']);
  12 + foreach ($ids as $id){
  13 + $id = intval($id);
  14 +
  15 + $station = db_single(db_fetch("SELECT * FROM tube_stations WHERE id=$id"));
  16 + if (!$station['id']) continue;
  17 +
  18 +
  19 + #
  20 + # weblogs
  21 + #
  22 +
  23 + $limit = 5;
  24 +
  25 + $ret2 = db_fetch("SELECT w.*,s.station_id FROM tube_weblogs AS w, tube_weblog_stations AS s WHERE w.id=s.weblog_id AND s.station_id=$station[id] ORDER BY w.date_create DESC LIMIT $limit");
  26 + list($total) = db_list(db_fetch("SELECT COUNT(w.id) FROM tube_weblogs AS w, tube_weblog_stations AS s WHERE w.id=s.weblog_id AND s.station_id=$station[id]"));
  27 +
  28 + $station['weblogs'] = $ret2['rows'];
  29 + $station['more'] = max(0, $total - $limit);
  30 +
  31 +
  32 + $stations[] = $station;
  33 + }
  34 +
  35 + $smarty->assign('stations', $stations);
  36 +
  37 +
  38 + #
  39 + # uid allows multiple widgets per page, somehow!
  40 + #
  41 +
  42 + $smarty->assign('uid', time().rand(100,999));
  43 +
  44 +
  45 +
  46 + #
  47 + # test mode just return the html, with no script to make
  48 + # the menu open - just easier for seeing the raw html
  49 + #
  50 +
  51 + if ($_GET['test']){
  52 + $smarty->display('inc_widget_html.txt');
  53 + exit;
  54 + }
  55 +
  56 +
  57 + #
  58 + # output
  59 + #
  60 +
  61 + $smarty->display('js_widget.txt');
  62 +?>

0 comments on commit 7a6e88f

Please sign in to comment.
Something went wrong with that request. Please try again.