* Store paths are now abbreviated in the generated HTML file.

Hovering over the abbreviated path will reveal the full path.  This
  probably only works in Mozilla.
This commit is contained in:
Eelco Dolstra 2004-03-16 12:47:09 +00:00
parent 9d2669d218
commit b5539e7a30
3 changed files with 89 additions and 13 deletions

View file

@ -17,9 +17,7 @@
<xsl:template match="nest"> <xsl:template match="nest">
<div class='nesting'> <div class='nesting'>
<div class='head'> <div class='head'>
<code> <xsl:apply-templates select='head'/>
<xsl:value-of select="head"/>
</code>
</div> </div>
<blockquote class='body'> <blockquote class='body'>
<xsl:for-each select='line|nest'> <xsl:for-each select='line|nest'>
@ -52,10 +50,17 @@
</div> </div>
</xsl:template> </xsl:template>
<xsl:template match="line"> <xsl:template match="head|line">
<code class='line'> <code>
<xsl:value-of select="."/> <xsl:apply-templates/>
</code> </code>
</xsl:template> </xsl:template>
<xsl:template match="storeref">
<em class='storeref'>
<span class='z'><span class='popup'><xsl:apply-templates/></span></span>
<span class='elided'>(...)</span><xsl:apply-templates select='name'/><xsl:apply-templates select='path'/>
</em>
</xsl:template>
</xsl:stylesheet> </xsl:stylesheet>

View file

@ -35,12 +35,7 @@ void Decoder::pushChar(char c)
state = stEscape; state = stEscape;
} else if (c == '\n') { } else if (c == '\n') {
finishLine(); finishLine();
} else if (c == '<') } else line += c;
line += "&lt;";
else if (c == '&')
line += "&amp;";
else
line += c;
break; break;
case stEscape: case stEscape:
@ -78,9 +73,43 @@ void Decoder::pushChar(char c)
void Decoder::finishLine() void Decoder::finishLine()
{ {
string storeDir = "/nix/store/";
int sz = storeDir.size();
string tag = inHeader ? "head" : "line"; string tag = inHeader ? "head" : "line";
cout << "<" << tag << ">"; cout << "<" << tag << ">";
cout << line;
for (int i = 0; i < line.size(); i++) {
if (line[i] == '<') cout << "&lt;";
else if (line[i] == '&') cout << "&amp;";
else if (i + sz + 33 < line.size() &&
string(line, i, sz) == storeDir &&
line[i + sz + 32] == '-')
{
int j = i + sz + 32;
/* skip name */
while (!strchr("/\n\r\t ()[]:;?<>", line[j])) j++;
int k = j;
while (!strchr("\n\r\t ()[]:;?<>", line[k])) k++;
// !!! escaping
cout << "<storeref>"
<< "<storedir>"
<< string(line, i, sz)
<< "</storedir>"
<< "<hash>"
<< string(line, i + sz, 32)
<< "</hash>"
<< "<name>"
<< string(line, i + sz + 32, j - (i + sz + 32))
<< "</name>"
<< "<path>"
<< string(line, j, k - j)
<< "</path>"
<< "</storeref>";
i = k - 1;
} else cout << line[i];
}
cout << "</" << tag << ">" << endl; cout << "</" << tag << ">" << endl;
line = ""; line = "";
inHeader = false; inHeader = false;

View file

@ -64,3 +64,45 @@ tr.y > td.dummy > div.dummy
border-left: 3px solid #6185a0; border-left: 3px solid #6185a0;
border-bottom: 3px solid #6185a0; border-bottom: 3px solid #6185a0;
} }
em.storeref
{
color: #500000;
}
em.storeref:hover
{
background-color: #eeeeee;
}
*.popup {
display: none;
/* background: url('http://losser.st-lab.cs.uu.nl/~mbravenb/menuback.png') repeat; */
background: #ffffcd;
border: solid #555555 1px;
position: absolute;
top: 1.5em;
left: 0.5em;
margin: 0;
padding: 0;
z-index: 100;
}
em.storeref {
position: static;
}
span.z {
position: absolute;
width: 100%;
}
em.storeref:hover > span.z > *.popup {
display: block;
}