dustin (owner)

Revisions

gist: 39613 Download_button fork
public
Description:
HTML to generate an HTML list of related links for you.
Public Clone URL: git://gist.github.com/39613.git
Embed All Files: show embed
autolinks.html #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- Copyright (c) 2008 Dustin Sallings <dustin+html@spy.net> -->
<html lang="en">
<head>
<title>Relativity.</title>
<style type="text/css">
img { border: 0; margin-right: 2px; }
textarea { overflow: scroll; }
input { width: 350px; }
</style>
    <script type="text/javascript"
      src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
var my_url = null;
 
function makeLink(url) {
var domain=url.split("/")[2];
var sdom=domain.split(".");
sdom=sdom[sdom.length - 2];
var img="http://www.google.com/s2/favicons?domain=" + domain;
return '<a rel="me" href="' + url + '">' +
'<img alt="' + sdom +'" src="' + img + '"/></a>\n';
}
 
function drawStuff(graph) {
console.log(graph);
var icons=document.getElementById('icons');
var text=[];
for (var node in graph.nodes) {
var n = graph.nodes[node];
if (n.nodes_referenced_by[my_url]) {
$(icons).append(makeLink(node));
text.push(makeLink(node));
}
}
var formthing=document.getElementById('content');
formthing.value = text.join("");
$('#icons').fadeIn("slow");
$('#sample-input').fadeIn("slow");
}
 
function getArgs() {
var args = {};
var query = location.search.substring(1);
var pairs = query.split("&");
for(var i = 0; i < pairs.length; i++) {
var pos = pairs[i].indexOf('=');
if (pos == -1) continue;
var argname = pairs[i].substring(0,pos);
var value = pairs[i].substring(pos+1);
args[argname] = unescape(value);
}
return args;
}
 
$('body').ready(function() {
var a = getArgs();
if(a.u) {
my_url = a.u;
document.getElementById('u-input').value=my_url;
   var s = document.createElement("script");
   s.src = 'http://socialgraph.apis.google.com/lookup?q=' + my_url +
'&fme=1&edi=1&edo=1&callback=drawStuff';
   s.type = 'text/javascript';
   $('body').append(s);
}
});
 
</script>
</head>
 
<body>
<form method="get" action="autolinks.html">
<fieldset>
<legend>Your URL</legend>
<input type="text" name="u" id="u-input"
value="http://bleu.west.spy.net/~dustin/"></input>
</fieldset>
</form>
<div style="display: none" id="icons">
</div>
<form id="sample-input" style="display: none" method="post" action="">
<textarea rows="30" cols="150" id="content"></textarea>
</form>
</body>
</html>