This repository has been archived by the owner on Jun 24, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: svn+ssh://svn.osteele.com/home/osteele/svn/projects/cloud@42 e7b8d44c-8308-0410-acfb-b763ae30a170
- Loading branch information
Showing
5 changed files
with
238 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
<!-- | ||
Copryight 2005-2006 Oliver steele. Some rights reserved. | ||
$LastChangedDate: 2006-01-07 08:16:19 -0500 (Sat, 07 Jan 2006) $ | ||
|
||
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License: | ||
http://creativecommons.org/licenses/by-nc-sa/2.5/. | ||
--> | ||
<canvas proxied="false" title="expialidocio.us" height="100%"> | ||
<include href="incubator/roundrectbutton.lzx"/> | ||
<include href="incubator/ulink.lzx"/> | ||
<include href="thumb.lzx"/> | ||
<script src="analyzer.js"/> | ||
<script src="colors.js"/> | ||
<splash/> | ||
|
||
<dataset name="postData" src="http:data.xml" ondata="canvas.processPostDataset()"/> | ||
|
||
<script><![CDATA[ | ||
var ServerURLs = { | ||
localhost: 'http://localhost/proxy.php', | ||
server: 'http://expialidocio.us/proxy.php' | ||
} | ||
function isRemoteRequest(sourceKey) { | ||
return ServerURLs[sourceKey]; | ||
} | ||
function requestPosts(sourceKey, username, password) { | ||
var url = ServerURLs[sourceKey]; | ||
if (url) { | ||
postData.setQueryType('POST'); | ||
postData.setQueryParams({user: username, password: password}) | ||
} else { | ||
url = 'http:tests/' + source + '.xml'; | ||
} | ||
Debug.write(url); | ||
postData.setSrc(url); | ||
appstate.setAttribute('state', 'retrieving'); | ||
postData.doRequest(); | ||
} | ||
]]></script> | ||
|
||
<!-- Process the post data, once it has returned. The dataset's ondata | ||
handler invokes this. --> | ||
<method name="processPostDataset"><![CDATA[ | ||
var root = postData.data; | ||
if (root.nodeName=='error') { | ||
var message = | ||
root.attributes['code'] == '401' ? | ||
"Del.icio.us didn't accept your username and password. Please try again.<br/><font size='10' color='#000'>If the problem persists, del.icio.us may be refusing requests from the expialidocio.us server. If you're certain you got your name and password right, please try again tomorrow.</font>" : | ||
LzBrowser.urlUnescape(postData.attributes['message']); | ||
loginView.errorMessage.setAttribute('text', message); | ||
return appstate.setAttribute('state', 'login'); | ||
} | ||
if (!(root.childNodes||[]).length) | ||
return appstate.setAttribute('state', 'empty'); | ||
appstate.setAttribute('username', root.attributes['user']); | ||
appstate.setAttribute('state', 'running'); | ||
|
||
TagData = new DataFrame; | ||
//var t0 = (new Date).getTime(); | ||
fillTagFrame(TagData, root.childNodes); | ||
//Debug.write('fill', (new Date).getTime-t0); | ||
|
||
SortedTags = [].concat(TagData.rowNames); | ||
SortedTags.sort(); | ||
TagSortInverse = computeArrayinversion(SortedTags, TagData.rowNames); | ||
|
||
histogram.drawGraph(); | ||
allStart.setText(TagData.columnNames[0]); | ||
allEnd.setText(TagData.columnNames[TagData.columnNames.length - 1]); | ||
var cn = Math.floor(TagData.columns.length/3); | ||
histogram.selector.setRange(cn, TagData.columns.length-cn); | ||
myview.animate('opacity', 1.0, 1000); | ||
credits.animate('y', myview.y+myview.height+40, 0); | ||
]]></method> | ||
|
||
<node id="appstate"> | ||
<attribute name="username" type="string" value=""/> | ||
<attribute name="state" type="string" value="login"/> | ||
<method name="signin" args="username, password"><![CDATA[ | ||
loginView.errorMessage.setAttribute('text', ''); | ||
appstate.setAttribute('username', username); | ||
requestPosts(source, username, password); | ||
]]></method> | ||
<method name="signout"> | ||
appstate.setAttribute('state', 'login'); | ||
credits.setAttribute('y', 0) | ||
</method> | ||
</node> | ||
|
||
<!-- The dates at the bottom of the tag cloud and the histogram. --> | ||
<class name="dateLabel" extends="text" resize="true" | ||
fontsize="24" fgcolor="#60ff60"/> | ||
|
||
<!-- The "logged in" box at the upper right --> | ||
<hbox id="loggedIn" align="right" visible="${appstate.state == 'running'}" fontsize="14" y="5"> | ||
<text>username:</text> | ||
<text resize="true" fontstyle="bold" text="${appstate.username}"/> | ||
<view width="2"/> | ||
<roundrectbutton width="$once{null}" height="15" y="4" onclick="appstate.signout()">Logout</roundrectbutton> | ||
<view width="10" height="25"/> | ||
</hbox> | ||
|
||
<!-- The tag cloud. This is just a container for a text field that | ||
knows how to set its text. --> | ||
<view id="myview" width="100%" layout="axis: y" opacity="0.1" | ||
visible="${appstate.state=='running'}" y="${loggedIn.height}"> | ||
<view id="cloud" width="${parent.width-20}" x="10" height="200" bgcolor="#f0f0ff"> | ||
<attribute name="rangeMin" value="null"/> | ||
<attribute name="rangeMax" value="null"/> | ||
<method name="setRange" args="a,b"><![CDATA[ | ||
if (arguments.length < 1) a = 0; | ||
if (arguments.length < 2) b = TagData.columns.length; | ||
if (a == rangeMin && b == rangeMax) return; | ||
currentStart.setText(TagData.columnNames[a]); | ||
currentEnd.setText(TagData.columnNames[b-1]); | ||
this.rangeMin = a; | ||
this.rangeMax = b; | ||
var tagCounts = TagData.columnRangeSum(a, b); | ||
|
||
var max = 0; | ||
var min = 100; | ||
for (var i = 0; i < tagCounts.length; i++) { | ||
var c = tagCounts[i]; | ||
if (c > max) max = c; | ||
if (c < min) min = c; | ||
} | ||
|
||
str = ''; | ||
for (var i = 0; i < tagCounts.length; i++) { | ||
var tagname = SortedTags[i]; | ||
var count = tagCounts[TagSortInverse[i]]; | ||
if (!count) continue; | ||
var s = (count - min) / (max - min); | ||
var c = Math.floor(255*(1-1.0*s)); | ||
var fontsize = 10+12*s; | ||
// TODO: change this to cloud.fgcolor | ||
var color = long2css(interpolateColors(cloud.bgcolor, 0x0000FF, 0.25+0.75*s)); | ||
var label = '<font size=\"' + fontsize + '" color="' + color + '">' + tagname + ' </font>' | ||
var url = 'http://del.icio.us/' + appstate.username + '/' + tagname | ||
str += '<a href=\"' + url + '\" target="_blank">' + label + '</a>' | ||
} | ||
tags.setText(str); | ||
]]></method> | ||
<text name="tags" multiline="true" width="100%" height="100%"/> | ||
</view> | ||
|
||
<!-- The funnel from the histogram to the cloud. -->> | ||
<drawview id="funnel" x="${cloud.x}" width="${cloud.width}" height="50"> | ||
<dateLabel id="currentStart" align="left" valign="bottom"/> | ||
<dateLabel id="currentEnd" align="right" valign="bottom"/> | ||
<method name="update" event="onx" reference="histogram.selector"> | ||
var h = this.height; | ||
var r = 20; // rounding radius | ||
var x0 = cloud.getAttributeRelative('x', this)-10; | ||
var x1 = histogram.selector.getAttributeRelative('x', this)-10; | ||
var x2 = x1+histogram.selector.getAttributeRelative('width', this); | ||
var x3 = x0+cloud.getAttributeRelative('width', this); | ||
clear(); | ||
beginPath(); | ||
moveTo(x0, 0); | ||
quadraticCurveTo(x0, r, x0+r, r) | ||
lineTo(x1-r, h-r); | ||
quadraticCurveTo(x1, h-r, x1, h); | ||
lineTo(x2, h); | ||
quadraticCurveTo(x2, h-r, x2+r, h-r); | ||
lineTo(x3-r, r); | ||
quadraticCurveTo(x3, r, x3, 0); | ||
this.fillStyle = cloud.bgcolor; | ||
var g = this.createLinearGradient(0, 0, 0, h); | ||
g.addColorStop(0, cloud.bgcolor); | ||
g.addColorStop(1, histogram.bgcolor); | ||
this.fillStyle = g; | ||
fill(); | ||
</method> | ||
<method event="onwidth" reference="histogram.selector"> | ||
update(); | ||
</method> | ||
</drawview> | ||
|
||
<!-- The date*postings histogram... --> | ||
<include href="histogram.lzx"/> | ||
|
||
<!-- and its labels. --> | ||
<view x="${histogram.x}" width="${histogram.width}"> | ||
<dateLabel id="allStart" fontsize="18" align="left"/> | ||
<dateLabel id="allEnd" fontsize="18" align="right"/> | ||
</view> | ||
</view> | ||
|
||
<!-- FIXME: ${credits.height} is too high --> | ||
<view x="25%" width="50%" y="150" fontsize="24"> | ||
<text visible="${appstate.state=='empty'}" width="100%" align="center" valign="middle" multiline="true"><a href="http://del.icio.us"><u><font color="#0000ff">de.licio.us</font></u></a> doesn't show any posts tagged with your account. This could be because you haven't tagged any pages, in which case you should tag some and then come back here. Or it could be because the del.icio.us server is responding null.</text> | ||
</view> | ||
|
||
<view id="credits" layout="axis: y"> | ||
<view id="logo" resource="expialidocious.png"/> | ||
<text visible="${appstate.state=='running'}" multiline="true" width="${logo.width}" fgcolor="#444">The bar chart displays the number of posts you've tagged, for each day that you've tagged any posts at all. The tag cloud contains tags for the selected range of dates. Drag the red slider to move the date range; drag the side handles to extend it. Click on a tag name to visit your de.licio.us page for that tag.</text> | ||
<text fgcolor="#222"><i>Copyright 2005 by <a href="http://osteele.com"><u><font color="#0000ff">Oliver Steele</font></u></a>. <a href="http://creativecommons.org/licenses/by-nc-sa/2.5/">Some rights reserved.</a></i></text> | ||
<hbox> | ||
<ulink href="about/about.html">About</ulink> | ||
<text>|</text> | ||
<ulink href="mailto:steele@osteele.com">Contact</ulink> | ||
<text>|</text> | ||
<ulink href="about/privacy.html">Privacy</ulink> | ||
</hbox> | ||
</view> | ||
|
||
<include href="login.lzx"/> | ||
|
||
<debug/> | ||
|
||
<script> | ||
if (_root['source'] == undefined) source = 'posts'; | ||
if (!isRemoteRequest(source)) requestPosts(source); | ||
</script> | ||
</canvas> |