[hgweb] Initial import of the "gitweb" style

This commit is contained in:
Josef "Jeff" Sipek 2005-12-05 04:30:47 -05:00
parent 41566e68ad
commit 5786e36aca
16 changed files with 470 additions and 0 deletions

View File

@ -632,6 +632,7 @@ class hgweb(object):
for k,n in i:
yield {"parity": parity,
"tag": k,
"date": cl.read(n)[2],
"node": hex(n)}
parity = 1 - parity
@ -639,6 +640,76 @@ class hgweb(object):
manifest=hex(mf),
entries=entries)
def summary(self):
cl = self.repo.changelog
mf = cl.read(cl.tip())[0]
i = self.repo.tagslist()
i.reverse()
def tagentries(**map):
parity = 0
count = 0
for k,n in i:
if k == "tip": # skip tip
continue;
count += 1
if count > 10: # limit to 10 tags
break;
c = cl.read(n)
m = c[0]
t = c[2]
yield self.t("tagentry",
parity = parity,
tag = k,
node = hex(n),
date = t,
manifest = hex(m))
parity = 1 - parity
def changelist(**map):
parity = 0
cl = self.repo.changelog
l = [] # build a list in forward order for efficiency
for i in range(start, end):
n = cl.node(i)
changes = cl.read(n)
hn = hex(n)
t = changes[2]
l.insert(0, self.t(
'shortlogentry',
parity = parity,
author = changes[1],
manifest = hex(changes[0]),
desc = changes[4],
date = t,
rev = i,
node = hn))
parity = 1 - parity
yield l
cl = self.repo.changelog
mf = cl.read(cl.tip())[0]
count = cl.count()
start = max(0, count - self.maxchanges)
end = min(count, start + self.maxchanges)
pos = end - 1
yield self.t("summary",
desc = self.repo.ui.config("web", "description", "unknown"),
owner = (self.repo.ui.config("ui", "username") or # preferred
self.repo.ui.config("web", "contact") or # deprecated
self.repo.ui.config("web", "author", "unknown")), # also
lastchange = (0, 0), # FIXME
manifest = hex(mf),
tags = tagentries,
shortlog = changelist)
def filediff(self, file, changeset):
cl = self.repo.changelog
n = self.repo.lookup(changeset)
@ -798,6 +869,9 @@ class hgweb(object):
elif req.form['cmd'][0] == 'tags':
req.write(self.tags())
elif req.form['cmd'][0] == 'summary':
req.write(self.summary())
elif req.form['cmd'][0] == 'filediff':
req.write(self.filediff(req.form['file'][0], req.form['node'][0]))

View File

@ -0,0 +1,30 @@
#header#
<title>#repo|escape#: Changelog</title>
<link rel="alternate" type="application/rss+xml"
href="?cmd=changelog;style=rss" title="RSS feed for #repo|escape#">
</head>
<body>
<div class="page_header">
<a href="http://www.selenic.com/mercurial/" title="Mercurial"><div style="float:right;">Mercurial</div></a><a href="?cmd=summary;style=gitweb">#repo|escape#</a> / changelog
</div>
<form action="#">
<div class="search">
<input type="hidden" name="repo" value="#repo#" />
<input type="hidden" name="style" value="gitweb" />
<input type="hidden" name="cmd" value="changelog" />
<input type="text" name="rev" />
</div>
</form>
</div>
<div class="page_nav">
<a href="?cmd=summary;style=gitweb">summary</a> | changelog | <a href="?cmd=tags;style=gitweb">tags</a> | <a href="?cmd=manifest;manifest=#manifest#;path=/;style=gitweb">manifest</a><br/>
<br/>
#changenav%naventry#<br/>
</div>
#entries%changelogentry#
#footer#

View File

@ -0,0 +1,14 @@
<div>
<a class="title" href="?cmd=changeset;node=#node#;style=gitweb"><span class="age">#date|age# ago</span>#desc|firstline|escape#</a>
</div>
<div class="title_text">
<div class="log_link">
<a href="?cmd=changeset;node=#node#;style=gitweb">changeset</a><br/>
</div>
<i>#author|obfuscate# [#date|rfc822date#]</i><br/>
</div>
<div class="log_body">
#desc|addbreaks#
<br/>
<br/>
</div>

View File

@ -0,0 +1,40 @@
#header#
<title>#repo|escape#: Changeset</title>
<link rel="alternate" type="application/rss+xml"
href="?cmd=changelog;style=rss" title="RSS feed for #repo|escape#">
</head>
<body>
<div class="page_header">
<a href="http://www.selenic.com/mercurial/" title="Mercurial"><div style="float:right;">Mercurial</div></a><a href="?cmd=summary;style=gitweb">#repo|escape#</a> / changeset
</div>
<div class="page_nav">
<a href="?cmd=summary;style=gitweb">summary</a> | <a href="?cmd=changelog;rev=#rev#;style=gitweb">changelog</a> | <a href="?cmd=tags;style=gitweb">tags</a> | <a href="?cmd=manifest;manifest=#manifest#;path=/;style=gitweb">manifest</a> | changeset | <a href="?cmd=changeset;node=#node#;style=raw">raw</a><br/>
</div>
<div>
<a class="title" href="?cmd=changeset;node=#node#;style=raw">#desc|escape|firstline#</a>
</div>
<div class="title_text">
<table cellspacing="0">
<tr><td>author</td><td>#author|obfuscate#</td></tr>
<tr><td></td><td>#date|date# (#date|age# ago)</td></tr>
<tr><td>changeset</td><td style="font-family:monospace">#node|short#</td></tr>
<tr><td>manifest</td><td style="font-family:monospace"><a class="list" href="?cmd=manifest;manifest=#manifest|short#;path=/;style=gitweb">#manifest|short#</a></td></tr>
#parent%changesetparent#
#changesettag#
</table></div>
<div class="title_text">
#desc|addbreaks#
</div>
<div class="title_text">
<table cellspacing="0">
#files#
</table></div>
<div class="page_body">#diff#</div>
#footer#

View File

@ -0,0 +1,12 @@
#header#
<div class="page_nav">
<a href="?cmd=summary;style=gitweb">summary</a> | <a href="?cmd=changelog;style=gitweb">log</a> | <a href="?cmd=tags;style=gitweb">tags</a> | <a href="?cmd=manifest;manifest=#manifest#;path=/;style=gitweb">manifest</a><br/>
</div>
<div>
<br/>
<i>Error parsing query string</i><br/>
<br/>
</div>
#footer#

View File

@ -0,0 +1,43 @@
#header#
<title>#repo|escape#: Annotate</title>
<link rel="alternate" type="application/rss+xml"
href="?cmd=changelog;style=rss" title="RSS feed for #repo|escape#">
</head>
<body>
<div class="page_header">
<a href="http://www.selenic.com/mercurial/" title="Mercurial"><div style="float:right;">Mercurial</div></a><a href="?cmd=summary;style=gitweb">#repo|escape#</a> / annotate
</div>
<div class="page_nav">
<a href="?cmd=summary;style=gitweb">summary</a> | <a href="?cmd=changelog;style=gitweb">changelog</a> | <a href="?cmd=tags;style=gitweb">tags</a> | <a href="?cmd=manifest;manifest=#manifest#;path=#path#;style=gitweb">manifest</a> | <a href="?cmd=changeset;node=#node#;style=gitweb">changeset</a> | <a href="?cmd=file;file=#file#;filenode=#filenode#;style=gitweb">file</a> | <a href="?cmd=filelog;file=#file#;filenode=#filenode#;style=gitweb">revisions</a> | annotate<br/>
</div>
<h2>Annotate #file# (#filenode|short#)</h2>
<table>
<tr>
<td class="metatag">changeset #rev#:</td>
<td><a href="?cmd=changeset;node=#node#;style=gitweb">#node|short#</a></td></tr>
#parent%fileannotateparent#
<tr>
<td class="metatag">manifest:</td>
<td><a href="?cmd=manifest;manifest=#manifest#;path=/;style=gitweb">#manifest|short#</a></td></tr>
<tr>
<td class="metatag">author:</td>
<td>#author|obfuscate#</td></tr>
<tr>
<td class="metatag">date:</td>
<td>#date|date# (#date|age# ago)</td></tr>
<tr>
<td class="metatag">permissions:</td>
<td>#permissions|permissions#</td></tr>
</table>
<br/>
<table cellspacing="0" cellpadding="0">
#annotate%annotateline#
</table>
#footer#

View File

@ -0,0 +1,9 @@
#header#
<div class="page_nav">
<a href="?cmd=summary;style=gitweb">summary</a> | <a href="?cmd=changelog;style=gitweb">log</a> | <a href="?cmd=tags;style=gitweb">tags</a> | <a href="?cmd=file;file=#file#;filenode=#filenode#;style=gitweb">file</a> | <a href="?cmd=annotate;file=#file#;filenode=#filenode#;style=gitweb">annotate</a><br/>
</div>
<!--FIXME: the entries have wrong format -->
#entries#
#footer#

View File

@ -0,0 +1,22 @@
#header#
<title>#repo|escape#: File revision</title>
<link rel="alternate" type="application/rss+xml"
href="?cmd=changelog;style=rss" title="RSS feed for #repo|escape#">
</head>
<body>
<div class="page_header">
<a href="http://www.selenic.com/mercurial/" title="Mercurial"><div style="float:right;">Mercurial</div></a><a href="?cmd=summary;style=gitweb">#repo|escape#</a> / file revision
</div>
<div class="page_nav">
<a href="?cmd=summary;style=gitweb">summary</a> | <a href="?cmd=changelog;style=gitweb">changelog</a> | <a href="?cmd=tags;style=gitweb">tags</a> | <a href="?cmd=manifest;manifest=#manifest#;path=#path#;style=gitweb">manifest</a> | <a href="?cmd=changeset;node=#node#;style=gitweb">changeset</a> | file | <a href="?cmd=filelog;file=#file#;filenode=#filenode#;style=gitweb">revisions</a> | <a href="?cmd=annotate;file=#file#;filenode=#filenode#;style=gitweb">annotate</a> | <a href="?cmd=file;file=#file#;filenode=#filenode#;style=raw">raw</a><br/>
</div>
<div><a class="title" href="?cmd=FIXME;style=gitweb">#desc|firstline|escape#</a></div>
<div class="page_path"><b>#file#</b></div>
<div class="page_body">
#text#
</div>
#footer#

View File

@ -0,0 +1,6 @@
<div class="page_footer">
<div class="page_footer_text">#repo|escape#</div>
<a class="rss_logo" href="?cmd=changelog;style=rss">RSS</a>
</div>
</body>
</html>

View File

@ -0,0 +1,59 @@
Content-type: text/html
<?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">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="robots" content="index, nofollow"/>
<style type="text/css">
body { font-family: sans-serif; font-size: 12px; margin:0px; border:solid #d9d8d1; border-width:1px; margin:10px; }
a { color:#0000cc; }
a:hover, a:visited, a:active { color:#880000; }
div.page_header { height:25px; padding:8px; font-size:18px; font-weight:bold; background-color:#d9d8d1; }
div.page_header a:visited { color:#0000cc; }
div.page_header a:hover { color:#880000; }
div.page_nav { padding:8px; }
div.page_nav a:visited { color:#0000cc; }
div.page_path { padding:8px; border:solid #d9d8d1; border-width:0px 0px 1px}
div.page_footer { height:17px; padding:4px 8px; background-color: #d9d8d1; }
div.page_footer_text { float:left; color:#555555; font-style:italic; }
div.page_body { padding:8px; }
div.title, a.title {
display:block; padding:6px 8px;
font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000;
}
a.title:hover { background-color: #d9d8d1; }
div.title_text { padding:6px 0px; border: solid #d9d8d1; border-width:0px 0px 1px; }
div.log_body { padding:8px 8px 8px 150px; }
span.age { position:relative; float:left; width:142px; font-style:italic; }
div.log_link {
padding:0px 8px;
font-size:10px; font-family:sans-serif; font-style:normal;
position:relative; float:left; width:136px;
}
div.list_head { padding:6px 8px 4px; border:solid #d9d8d1; border-width:1px 0px 0px; font-style:italic; }
a.list { text-decoration:none; color:#000000; }
a.list:hover { text-decoration:underline; color:#880000; }
table { padding:8px 4px; }
th { padding:2px 5px; font-size:12px; text-align:left; }
tr.light:hover, tr.parity0:hover { background-color:#edece6; }
tr.dark, tr.parity1 { background-color:#f6f6f0; }
tr.dark:hover, tr.parity1:hover { background-color:#edece6; }
td { padding:2px 5px; font-size:12px; vertical-align:top; }
td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; }
div.pre { font-family:monospace; font-size:12px; white-space:pre; }
div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; }
div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; }
div.search { margin:4px 8px; position:absolute; top:56px; right:12px }
a.linenr { color:#999999; text-decoration:none }
a.rss_logo {
float:right; padding:3px 0px; width:35px; line-height:10px;
border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e;
color:#ffffff; background-color:#ff6600;
font-weight:bold; font-family:sans-serif; font-size:10px;
text-align:center; text-decoration:none;
}
a.rss_logo:hover { background-color:#ee5500; }
</style>

View File

@ -0,0 +1,27 @@
#header#
<title>#repo|escape#: Manifest</title>
<link rel="alternate" type="application/rss+xml"
href="?cmd=changelog;style=rss" title="RSS feed for #repo|escape#">
</head>
<body>
<div class="page_header">
<a href="http://www.selenic.com/mercurial/" title="Mercurial"><div style="float:right;">Mercurial</div></a><a href="?cmd=summary;style=gitweb">#repo|escape#</a> / manifest
</div>
<div class="page_nav">
<a href="?cmd=summary;style=gitweb">summary</a> | <a href="?cmd=changelog;style=gitweb">changelog</a> | <a href="?cmd=tags;style=gitweb">tags</a> | manifest | <a href="http://FIXME">changeset</a><br/>
</div>
<div class="title" >#path|escape#</div>
<div class="page_body">
<table cellspacing="0">
<tr class="light">
<td style="font-family:monospace">drwxr-xr-x</td>
<td><a href="?cmd=manifest;manifest=#manifest#;path=#up#;style=gitweb">[up]</a></td>
<td class="link">&nbsp;</td>
</tr>
#dentries%manifestdirentry#
#fentries%manifestfileentry#
</table>
#footer#

42
templates/map-gitweb Normal file
View File

@ -0,0 +1,42 @@
default = "summary"
header = header-gitweb.tmpl
footer = footer-gitweb.tmpl
search = search-gitweb.tmpl
changelog = changelog-gitweb.tmpl
summary = summary-gitweb.tmpl
error = error-gitweb.tmpl
naventry = "<a href="?cmd=changelog;rev=#rev#;style=gitweb">#label#</a> "
navshortentry = "<a href="?cmd=shortlog;rev=#rev#;style=gitweb">#label#</a> "
filedifflink = "<a href="?cmd=filediff;node=#node#;file=#file#;style=gitweb">#file#</a> "
filenodelink = "<tr class="light"><td><a class="list" href="">#file#</a></td><td></td><td class="link"><a href="?cmd=file;filenode=#filenode#;file=#file#;style=gitweb">file</a> | <a href="http://FIXME">diff</a> | <a href="http://FIXME">revisions</a></td></tr>"
fileellipses = "..."
changelogentry = changelogentry-gitweb.tmpl
searchentry = changelogentry-gitweb.tmpl
changeset = changeset-gitweb.tmpl
manifest = manifest-gitweb.tmpl
manifestdirentry = "<tr class="parity#parity#"><td style="font-family:monospace">drwxr-xr-x</td><td><a href="?mf=#manifest|short#;path=#path#;style=gitweb">#basename#/</a></td><td class="link"><a href="?mf=#manifest|short#;path=#path#;style=gitweb">manifest</a></td></tr>"
manifestfileentry = "<tr class="parity#parity#"><td style="font-family:monospace">#permissions|permissions#</td><td class="list"><a class="list" href="?f=#filenode|short#;file=#file#;style=gitweb">#basename#</a></td><td class="link"><a href="?f=#filenode|short#;file=#file#;style=gitweb">file</a> | <a href="?fl=#filenode|short#;file=#file#;style=gitweb">revisions</a> | <a href="?fa=#filenode|short#;file=#file#;style=gitweb">annotate</a></td></tr>"
filerevision = filerevision-gitweb.tmpl
fileannotate = fileannotate-gitweb.tmpl
filediff = filediff-gitweb.tmpl
filelog = filelog-gitweb.tmpl
fileline = "<div class="pre"><a id="l#linenumber#" href="#l#linenumber#" class="linenr"> #linenumber#</a> #line|escape#</div>"
filelogentry = filelogentry-gitweb.tmpl
annotateline = "<tr class="parity#parity#"><td class="annotate"><a href="?cmd=changeset;node=#node#;style=gitweb">#author|obfuscate#@#rev#</a></td><td><pre>#line|escape#</pre></td></tr>"
difflineplus = "<div class="pre" style="color:#008800;">#line|escape#</div>"
difflineminus = "<div class="pre" style="color:#cc0000;">#line|escape#</div>"
difflineat = "<div class="pre" style="color:#990099;">#line|escape#</div>"
diffline = "<div class="pre">#line|escape#</div>"
changelogparent = "<tr><th class="parent">parent #rev#:</th><td class="parent"><a href="?cmd=changeset;node=#node#;style=gitweb">#node|short#</a></td></tr>"
changesetparent = "<tr><td>parent</td><td style="font-family:monospace"><a class="list" href="?cmd=changeset;node=#node|short#;style=gitweb">#node|short#</a></td></tr>"
filerevparent = "<tr><td class="metatag">parent:</td><td><a href="?cmd=file;file=#file#;filenode=#node#;style=gitweb">#node|short#</a></td></tr>"
fileannotateparent = "<tr><td class="metatag">parent:</td><td><a href="?cmd=annotate;file=#file#;filenode=#node#;style=gitweb">#node|short#</a></td></tr>"
tags = tags-gitweb.tmpl
tagentry = "<tr class="parity#parity#"><td><i>#date|age# ago</i></td><td><a class="list" href="?cmd=changeset;node=#node|short#;style=gitweb"><b>#tag#</b></a></td><td class="link"><a href="?cmd=changeset;node=#node|short#;style=gitweb">changeset</a> | <a href="?cmd=changelog;rev=#node|short#;style=gitweb">changelog</a> | <a href="?cmd=manifest;manifest=#manifest|short#;path=/;style=gitweb">manifest</a></td></tr>"
diffblock = "#lines#"
changelogtag = "<tr><th class="tag">tag:</th><td class="tag">#tag#</td></tr>"
changesettag = "<tr><td>tag</td><td>#tag#</td></tr>"
filediffparent = "<tr><th class="parent">parent #rev#:</th><td class="parent"><a href="?cmd=changeset;node=#node#;style=gitweb">#node|short#</a></td></tr>"
filelogparent = "<tr><td align="right">parent #rev#:&nbsp;</td><td><a href="?cmd=file;file=#file#;filenode=#node#;style=gitweb">#node|short#</a></td></tr>"
shortlog = shortlog-gitweb.tmpl
shortlogentry = "<tr class="parity#parity#"><td><i>#date|age# ago</i></td><td><a class="list" href="?cmd=changeset;node=#node|short#;style=gitweb"><b>#desc|firstline|escape#</b></a></td><td class="link"><a href="?cmd=changeset;node=#node|short#;style=gitweb">changeset</a> | <a href="?cmd=manifest;manifest=#manifest|short#;path=/;style=gitweb">manifest</a></td></tr>"

View File

@ -0,0 +1,24 @@
#header#
<div class="page_nav">
<a href="?cmd=summary;style=gitweb">summary</a> | log | <a href="?cmd=tags;style=gitweb">tags</a> | <a href="?cmd=manifest;manifest=#manifest#;path=/;style=gitweb">manifest</a><br/>
</div>
<h2>searching for #query|escape#</h2>
<form>
search:
<input type="hidden" name="cmd" value="changelog">
<input type="hidden" name="style" value="gitweb">
<input name="rev" type="text" width="30" value="#query|escape#">
</form>
#entries#
<form>
search:
<input type="hidden" name="cmd" value="changelog">
<input type="hidden" name="style" value="gitweb">
<input name="rev" type="text" width="30">
</form>
#footer#

View File

@ -0,0 +1,13 @@
#header#
<div class="page_nav">
<a href="?cmd=summary;style=gitweb">summary</a> | <a href="?cmd=changelog;style=gitweb">log</a> | <a href="?cmd=tags;style=gitweb">tags</a> | <a href="?cmd=manifest;manifest=#manifest#;path=/;style=gitweb">manifest</a><br/>
#changenav%naventry#<br/>
</div>
<table cellspacing="0">
#entries#
</table>
#footer#

View File

@ -0,0 +1,34 @@
#header#
<title>#repo|escape#: Summary</title>
<link rel="alternate" type="application/rss+xml"
href="?cmd=changelog;style=rss" title="RSS feed for #repo|escape#">
</head>
<body>
<div class="page_header">
<a href="http://www.selenic.com/mercurial/" title="Mercurial"><div style="float:right;">Mercurial</div></a><a href="?cmd=summary;style=gitweb">#repo|escape#</a> / summary
</div>
<div class="page_nav">
summary | <a href="?cmd=changelog;style=gitweb">changelog</a> | <a href="?cmd=tags;style=gitweb">tags</a> | <a href="?cmd=manifest;manifest=#manifest#;path=/;style=gitweb">manifest</a><br/>
</div>
<div class="title">&nbsp;</div>
<table cellspacing="0">
<tr><td>description</td><td>#desc#</td></tr>
<tr><td>owner</td><td>#owner#</td></tr>
<!-- <tr><td>last change</td><td>#lastchange|rfc822date#</td></tr> -->
</table>
<div><a class="title" href="?cmd=changelog;style=gitweb">changes</a></div>
<table cellspacing="0">
#shortlog#
<tr class="light"><td colspan="3"><a class="list" href="?cmd=changelog;rev=;style=gitweb">...</a></td></tr>
</table>
<div><a class="title" href="?cmd=tags;style=gitweb">tags</a></div>
<table cellspacing="0">
#tags#
<tr class="light"><td colspan="3"><a class="list" href="?cmd=tags;style=gitweb">...</a></td></tr>
</table>
#footer#

View File

@ -0,0 +1,21 @@
#header#
<title>#repo|escape#: Tags</title>
<link rel="alternate" type="application/rss+xml"
href="?cmd=changelog;style=rss" title="RSS feed for #repo|escape#">
</head>
<body>
<div class="page_header">
<a href="http://www.selenic.com/mercurial/" title="Mercurial"><div style="float:right;">Mercurial</div></a><a href="?cmd=summary;style=gitweb">#repo|escape#</a> / tags
</div>
<div class="page_nav">
<a href="?cmd=summary;style=gitweb">summary</a> | <a href="?cmd=changelog;rev=#rev#;style=gitweb">changelog</a> | tags | <a href="?cmd=manifest;manifest=#manifest#;path=/;style=gitweb">manifest</a>
<br/>
</div>
<table cellspacing="0">
#entries%tagentry#
</table>
#footer#