Integrate CGI front end
This commit is contained in:
parent
0bf34d7751
commit
ca61c7f960
5 changed files with 431 additions and 0 deletions
71
http/menu.css
Normal file
71
http/menu.css
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/* Hierarchical dynamic menu with CSS
|
||||
*
|
||||
* Copyright Petr Stanicek [aka -pixy-] 2003-05-16
|
||||
*
|
||||
* Taken from http://www.pixy.cz/blogg/clanky/csshiermenu/
|
||||
*/
|
||||
|
||||
#menu {
|
||||
position:relative;
|
||||
list-style-type:none;
|
||||
margin:0 0 0 0; padding:0;
|
||||
width:100%; height:1.4em;
|
||||
font:100%/1 sans-serif;
|
||||
}
|
||||
.menuitem {
|
||||
position:absolute; top:-14px;
|
||||
margin:0; padding:0;
|
||||
width:10em; height:1.4em;
|
||||
overflow:hidden;
|
||||
}
|
||||
#mi01 { left:6em }
|
||||
#mi02 { left:16em }
|
||||
#mi03 { left:26em }
|
||||
|
||||
.menuitem ul {
|
||||
display:block;
|
||||
margin: 0; padding:0;
|
||||
list-style-type:none;
|
||||
}
|
||||
.menuitem li { margin:0; padding:0 }
|
||||
.submenu li { position:relative }
|
||||
|
||||
/* 2-class selector to have higher weight than ".menuitem ul" */
|
||||
.submenu .subsubmenu {
|
||||
position:absolute; top:0; left:10em;
|
||||
width:10em;
|
||||
display:none;
|
||||
}
|
||||
|
||||
.menuitem:hover {
|
||||
height:10em;
|
||||
overflow:visible;
|
||||
}
|
||||
.submenu li:hover > .subsubmenu {
|
||||
display:block;
|
||||
}
|
||||
|
||||
#menu a {
|
||||
display:block;
|
||||
margin:0; padding: 0.2em 0.5em;
|
||||
text-align:center;
|
||||
text-decoration:none;
|
||||
color:white;
|
||||
border-top:1px solid #565F68;
|
||||
border-left:1px solid #565F68;
|
||||
}
|
||||
#menu a:hover { background:black }
|
||||
.menuitem a { background:#565F68 }
|
||||
.menuitem ul a { background:#88AA88 }
|
||||
.menuitem ul ul a { background:#AA8888 }
|
||||
.menuitem ul ul ul a { background:violet }
|
||||
.menuitem ul ul ul ul a { background:orange }
|
||||
|
||||
#menu a {
|
||||
border-bottom:none;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
html {
|
||||
overflow-y:scroll;
|
||||
}
|
||||
84
http/style.css
Normal file
84
http/style.css
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
body{margin:20px;background:black;font-family:'Lucida Grande', Verdana, Arial, Sans-Serif;font-size:0.9em;color:#787878;}
|
||||
h1, h2, h3{font-family:'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;font-weight:bold;color:black;}
|
||||
h1{font-size:1.3em;}
|
||||
h2{font-size:1.2em;border-bottom:1px solid #565F68;}
|
||||
h3{font-size:1.1em;}
|
||||
ul, ol, dt, dl{margin-top:0.5em;}
|
||||
li, dd{margin-top:0.35em;}
|
||||
a{text-decoration:none;border-bottom:1px dotted #999999;color:#0A0A0A;}
|
||||
code{font-family:Monaco, "Courier New", Courier, monospace;font-size:1em;color:black;background-color:inherit;padding:0 0.1em;}
|
||||
pre{font-family:Monaco, "Courier New", Courier, monospace;font-size:1em;padding:1em;color:White;background-color:#a9afd1;overflow:auto;}
|
||||
a:hover{background:none;}
|
||||
#wrapper{width:940px;margin:0 auto;padding:20px;background:white;}
|
||||
#header{width:940px;height:158px;margin:0 auto;background:white url(images/img01.jpg) no-repeat left top;}
|
||||
#language{float:left;width:auto;margin:47px 0 0 10px;}
|
||||
#language a{border-style:none;}
|
||||
#language img{border-style:none;}
|
||||
#logo h1{text-align:right;margin:0;padding:10px 20px 0 5px;letter-spacing:-1px;text-transform:capitalize;font-size:2.6em;color:white;background-color:inherit;border:none;}
|
||||
#logo h2{text-align:right;margin:0;padding:10px 20px 0 5px;text-transform:capitalize;font:bold 1.2em Arial, Helvetica, sans-serif;color:white;background-color:inherit;border:none;}
|
||||
#logo p{text-align:right;margin:0;padding:10px 20px 0 5px;text-transform:capitalize;font:bold 1.0em Arial, Helvetica, sans-serif;color:white;background-color:inherit;}
|
||||
#logo a{border:none;background:none;text-decoration:none;color:white;background-color:inherit;border:none;}
|
||||
#search{float:right;width:auto;}
|
||||
#search form{height:30px;margin:0;padding:20px 20px 0 0;}
|
||||
#search fieldset{margin:0;padding:0;border:none;}
|
||||
#search-text{width:200px;border:none;text-transform:lowercase;font:bold 1.2em Arial, Helvetica, sans-serif;color:black;background-color:white;}
|
||||
#search-submit{display:none;}
|
||||
#menu2{width:940px;height:2em;margin:0 auto;padding:0;border-top:1px white solid;color:white;background:#565F68;}
|
||||
#menu2 ul{margin:0;padding:0;list-style:none;line-height:normal;}
|
||||
#menu2 li{float:left;width:auto;}
|
||||
#menu2 a{display:block;padding:0.2em 0.8em 0.5em 1em;text-transform:uppercase;text-decoration:none;font-family:Arial, Helvetica, sans-serif;font-size:0.9em;font-weight:bold;color:white;background-color:inherit;border:none;}
|
||||
#menu2 a:hover, #menu .current_page_item a{color:white;background-color:inherit}
|
||||
#menu2 a:hover{text-decoration:underline;}
|
||||
#topbar{width:940px;height:1.8em;border-top:1px white solid;margin-bottom:1em;background:#565F68;color:white;font-weight:bold;font-size:0.95em;}
|
||||
#topbar p{padding:0.3em 0 0 0.3em;height:0.95em;margin:0;}
|
||||
#topbar a{color:#D3D3D3;border:none;}
|
||||
#page{width:940px;margin:0 auto;}
|
||||
#page img{border:none;}
|
||||
#content{float:right;width:680px;padding:10px 10px 0 0;}
|
||||
.post{}
|
||||
.post .title{color:black;background-color:inherit;}
|
||||
.post .title a{background:none;color:black;border:none;background-color:inherit;}
|
||||
.post .title a:hover{text-decoration:underline;}
|
||||
.post .meta{text-align:left;font-family:Arial, Helvetica, sans-serif;font-size:0.7em;}
|
||||
.post .entry{padding:0 0 1em 0;text-align:justify;}
|
||||
#sidebar{float:left;width:200px;padding:10px 0 0 10px;color:#787878;}
|
||||
#sidebar ul{margin:0;padding:0;list-style:none;}
|
||||
#sidebar li ul{padding-bottom:2em;}
|
||||
#sidebar li li{line-height:1.5em;padding-bottom:0.5em;border-bottom:1px dashed #D2D4C9;}
|
||||
#sidebar h2{letter-spacing:-.5px;color:black;background-color:inherit;}
|
||||
#sidebar p{padding-bottom:20px;text-align:justify;}
|
||||
#sidebar a{color:#787878;border:none;}
|
||||
#sidebar a:hover{text-decoration:underline;color:#787878;}
|
||||
#footer{width:940px;margin:0 auto;padding:20px 0 15px 0;background:#565F68;font-family:Arial, Helvetica, sans-serif;color:#B2B2B2;}
|
||||
#footer p{margin:0;line-height:normal;font-size:0.6em;text-transform:uppercase;text-align:center;}
|
||||
#footer a{color:white;background-color:inherit;}
|
||||
.alignright{float:right;width:auto;}
|
||||
.alignleft{float:left;width:auto;}
|
||||
#respond{margin:0;padding-top:2em;}
|
||||
.navigation{}
|
||||
.pagetitle{padding-bottom:0;}
|
||||
hr{display:none;}
|
||||
p.question{margin:0;font-weight:bold;color:#5d6cb4;}
|
||||
p.summary{font-size:1em;font-weight:bold;color:#5d6cb4;}
|
||||
img.right{float:right;width:auto;margin:2em 0 1.4em 2em;}
|
||||
img.right-top{float:right;width:auto;margin:0em 0 1.4em 2em;}
|
||||
img.left{float:left;width:auto;margin:2em 2em 1.4em 0;}
|
||||
table.listing{border-collapse:collapse;border-style:none;border-spacing:0;}
|
||||
table.listing th{color:white;background:#6d7dd1;font-weight:normal;padding:0.25em 0.25em;text-align:center;border-width:thin;border-color:black;border-style:solid;}
|
||||
table.listing td{text-align:left;padding:0.25em 0.25em;border-width:thin;border-color:black;border-style:solid;}
|
||||
.listing-even{color:white;background-color:#6d7dd1;}
|
||||
.listing-odd{background-color:transparent;}
|
||||
.listing .listing-even a{color:white;background-color:#6d7dd1;}
|
||||
#lxrcode{background-color:white;font-weight:bold;}
|
||||
#lxrcode pre{font-family:Monaco, "Courier New", Courier, monospace;font-size:0.95em;padding:1em;color:#787878;overflow:auto;background-color:white;}
|
||||
#lxrcode a{color:black;background-color:white;}
|
||||
#comments{margin-top:3em;}
|
||||
.commentlist li, #commentform input, #commentform textarea{font:0.9em 'Lucida Grande', Verdana, Arial, Sans-Serif;}
|
||||
.commentlist li ul li{font-size:0.95em;}
|
||||
.commentlist li{list-style-type:none;margin:0em 1em 1em -3em;padding:1em;}
|
||||
.commentlist cite, .commentlist cite a{font-style:normal;font-size:1.05em;}
|
||||
.commentlist p{padding-top:1em;font-weight:normal;line-height:1.5em;text-transform:none;}
|
||||
.thread-alt{background-color:#f8f8f8;}
|
||||
.thread-even{background-color:white;}
|
||||
.depth-1{border:1px solid #ddd;}
|
||||
.depth-2, .depth-3, .depth-4, .depth-5{border-left:1px solid #ddd;}
|
||||
31
http/template-head
Normal file
31
http/template-head
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>$title</title>
|
||||
<link rel="stylesheet" href="/style.css" type="text/css" media="screen" />
|
||||
<link rel="stylesheet" href="/menu.css" type="text/css" media="screen" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<base href="$baseurl"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="wrapper">
|
||||
<div id="wrapper2">
|
||||
<div id="header">
|
||||
|
||||
<div id="logo">
|
||||
<h1>Linux Cross Reference</h1>
|
||||
<h2><a href="http://free-electrons.com">Free Electrons</a></h2>
|
||||
<h2>Embedded Linux Experts</h2>
|
||||
<p>
|
||||
• <a href="source/">source navigation</a> • <a href="ident">identifier search</a> • <a href="search">freetext search</a> •
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="topbar">
|
||||
<p>Version: $versions
|
||||
</div>
|
||||
|
||||
<h1>$banner</h1>
|
||||
23
http/template-tail
Normal file
23
http/template-tail
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<p>
|
||||
This page was automatically generated by LXRFE 0.2 (<a href="lxrfe-0.2.tar.bz2">source</a>)
|
||||
•
|
||||
Linux is a registered trademark of Linus Torvalds
|
||||
</p>
|
||||
|
||||
<div id="menu2">
|
||||
<ul>
|
||||
<li><a href="http://free-electrons.com/">Home</a></li>
|
||||
<li><a href="http://free-electrons.com/blog/category/news/" title="View all posts filed under News">News</a></li>
|
||||
<li><a href="http://free-electrons.com/development/" title="Development">Development</a></li>
|
||||
<li><a href="http://free-electrons.com/services/" title="Services">Services</a></li>
|
||||
<li><a href="http://free-electrons.com/training/" title="Training">Training</a></li>
|
||||
<li><a href="http://free-electrons.com/docs/" title="Docs">Docs</a></li>
|
||||
<li><a href="http://free-electrons.com/community/" title="Community">Community</a></li>
|
||||
<li><a href="http://free-electrons.com/company/" title="Company">Company</a></li>
|
||||
<li><a href="http://free-electrons.com/blog/" title="Blog">Blog</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
222
http/web.py
Executable file
222
http/web.py
Executable file
|
|
@ -0,0 +1,222 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
from subprocess import check_output
|
||||
|
||||
def shell_exec (cmd):
|
||||
try:
|
||||
a = check_output (cmd, shell=True)
|
||||
except:
|
||||
a = b'error\n'
|
||||
|
||||
# decode('ascii') fails on special chars
|
||||
# FIXME: major hack until we handle everything as bytestrings
|
||||
try:
|
||||
a = a.decode ('utf-8')
|
||||
except UnicodeDecodeError:
|
||||
a = a.decode ('iso-8859-1')
|
||||
a = a.split ('\n')
|
||||
del a[-1]
|
||||
return a
|
||||
|
||||
# enable debugging
|
||||
import cgitb
|
||||
cgitb.enable()
|
||||
|
||||
import cgi
|
||||
import os
|
||||
from re import search, sub
|
||||
from collections import OrderedDict
|
||||
|
||||
print ('Content-Type: text/html;charset=utf-8\n')
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
version = form.getvalue ('v')
|
||||
if not (version and search ('^[A-Za-z0-9.-]+$', version)):
|
||||
version = '2.6.11'
|
||||
|
||||
url = os.environ['SCRIPT_URL']
|
||||
m = search ('^/source/(.*)$', url)
|
||||
if m:
|
||||
mode = 'source'
|
||||
path = m.group (1)
|
||||
if not search ('^[A-Za-z0-9_/.,+-]*$', path):
|
||||
path = 'INVALID'
|
||||
url2 = 'source/'+path+'?'
|
||||
|
||||
elif url == '/ident':
|
||||
mode = 'ident'
|
||||
ident = form.getvalue ('i')
|
||||
if not (ident and search ('^[A-Za-z0-9_]*$', ident)):
|
||||
ident = 'INVALID'
|
||||
url2 = 'ident?i='+ident+'&'
|
||||
|
||||
head = open ('template-head').read()
|
||||
head = sub ('\$baseurl', 'http://lxr2', head)
|
||||
|
||||
lines = shell_exec ('cd ..; ./query.py versions')
|
||||
va = OrderedDict()
|
||||
for l in lines:
|
||||
if search ('^2\.6', l):
|
||||
m = search ('^(2\.6)(\.[0-9]*)((\.|-).*)?$', l)
|
||||
else:
|
||||
m = search ('^([0-9]*)(\.[0-9]*)((\.|-).*)?$', l)
|
||||
|
||||
m1 = m.group(1)
|
||||
m2 = m.group(2)
|
||||
|
||||
if m1 not in va:
|
||||
va[m1] = OrderedDict()
|
||||
if m1+m2 not in va[m1]:
|
||||
va[m1][m1+m2] = []
|
||||
va[m1][m1+m2].append (l)
|
||||
|
||||
v = '<ul id="menu">\n'
|
||||
b = 1
|
||||
for v1k in va:
|
||||
v1v = va[v1k]
|
||||
v += ' <li class="menuitem" id="mi0'+str(b)+'"><a href="'+url2+'v='+v1k+'">v'+v1k+'</a>\n'
|
||||
b += 1
|
||||
v += ' <ul class="submenu">\n'
|
||||
for v2k in v1v:
|
||||
v2v = v1v[v2k]
|
||||
v += ' <li><a href="'+url2+'v='+v2k+'">v'+v2k+'</a>\n'
|
||||
v += ' <ul class="subsubmenu">\n'
|
||||
for v3 in v2v:
|
||||
v += ' <li><a href="'+url2+'v='+v3+'">v'+v3+'</a></li>\n'
|
||||
v += ' </ul></li>\n'
|
||||
v += ' </ul></li>\n'
|
||||
v += '</ul>\n'
|
||||
|
||||
head = sub ('\$versions', v, head)
|
||||
|
||||
if mode == 'source':
|
||||
banner = '<a href="source/?v='+version+'">Linux</a>/'
|
||||
p2 = ''
|
||||
for p in path.split ('/'):
|
||||
if p == '': continue
|
||||
banner += '<a href="source/'+p2+p+'/?v='+version+'">'+p+'</a>/'
|
||||
p2 += p+'/'
|
||||
|
||||
head = sub ('\$banner', banner, head)
|
||||
head = sub ('\$title', 'Linux/'+path+' - Linux Cross Reference - Free Electrons', head)
|
||||
print (head, end='')
|
||||
|
||||
lines = ['null - -']
|
||||
|
||||
if path[-1:] == '/' or path == '':
|
||||
type = 'tree'
|
||||
lines += shell_exec ('cd ..; ./query.py dir '+version+' \''+path+'\'')
|
||||
else:
|
||||
type = 'blob'
|
||||
lines += shell_exec ('cd ..; ./query.py file '+version+' \''+path+'\'')
|
||||
|
||||
if type == 'tree':
|
||||
if path != '':
|
||||
lines[0] = 'back - -'
|
||||
|
||||
print ('<table>\n')
|
||||
for l in lines:
|
||||
type, name, size = l.split (' ')
|
||||
|
||||
if type == 'null':
|
||||
continue
|
||||
elif type == 'tree':
|
||||
icon = 'folder.gif'
|
||||
size = ''
|
||||
path2 = path+name+'/'
|
||||
name = name+'/'
|
||||
elif type == 'blob':
|
||||
icon = 'text.gif'
|
||||
size = size+' bytes'
|
||||
path2 = path+name
|
||||
elif type == 'back':
|
||||
icon = 'back.gif'
|
||||
size = ''
|
||||
path2 = os.path.dirname (path[:-1]) + '/'
|
||||
if path2 == '/': path2 = './'
|
||||
name = 'Parent directory'
|
||||
|
||||
print (' <tr>')
|
||||
print (' <td><a href="source/'+path2+'?v='+version+'"><img src="/icons/'+icon+'" width="20" height="22" border="0" alt="'+icon+'"/></a></td>')
|
||||
print (' <td><a href="source/'+path2+'?v='+version+'">'+name+'</a></td>')
|
||||
print (' <td>'+size+'</td>')
|
||||
|
||||
print (' </tr>\n')
|
||||
|
||||
print ('</table>', end='')
|
||||
|
||||
elif type == 'blob':
|
||||
del (lines[0])
|
||||
|
||||
print ('<div id="lxrcode"><pre>')
|
||||
|
||||
width = len (str (len (lines)))
|
||||
num = 1
|
||||
n2 = ('%'+str(width)+'d') % num
|
||||
for l in lines:
|
||||
print ('<a name="L'+str(num)+'" href="source/'+path+'?v='+version+'#L'+str(num)+'">'+n2+'</a> ', end='')
|
||||
l = cgi.escape (l)
|
||||
l = sub ('"', '"', l)
|
||||
l = sub ('\033\[31m(.*?)\033\[0m', '<a href="ident?v='+version+'&i=\\1">\\1</a>', l)
|
||||
l = sub ('\033\[32m', '<i>', l)
|
||||
l = sub ('\033\[0m', '</i>', l)
|
||||
print (l)
|
||||
num += 1
|
||||
n2 = ('%'+str(width)+'d') % num
|
||||
|
||||
print ('</pre></div>', end='')
|
||||
|
||||
|
||||
elif mode == 'ident':
|
||||
head = sub ('\$banner', ident, head)
|
||||
head = sub ('\$title', 'Linux identifier search "'+ident+'" - Linux Cross Reference - Free Electrons', head)
|
||||
print (head, end='')
|
||||
|
||||
lines = shell_exec ('cd .. ; ./query.py ident '+version+' '+ident)
|
||||
lines = iter (lines)
|
||||
|
||||
m = search ('Defined in (\d*) file', next (lines))
|
||||
num = int (m.group(1))
|
||||
|
||||
print ('Defined in', num, 'files:')
|
||||
print ('<ul>')
|
||||
for i in range (0, num):
|
||||
l = next (lines)
|
||||
m = search ('^(.*): (\d*) \((.*)\)$', l)
|
||||
f, n, t = m.groups()
|
||||
print ('<li><a href="source/'+f+'?v='+version+'#L'+n+'">'+f+', line '+n+' (as a '+t+')</a>', end='')
|
||||
print ('</ul>')
|
||||
|
||||
next (lines)
|
||||
|
||||
m = search ('Referenced in (\d*) file', next (lines))
|
||||
num = int (m.group(1))
|
||||
|
||||
print ('Referenced in', num, 'files:')
|
||||
print ('<ul>')
|
||||
for i in range (0, num):
|
||||
l = next (lines)
|
||||
m = search ('^(.*): (.*)$', l)
|
||||
f = m.group (1)
|
||||
ln = m.group (2).split (',')
|
||||
if len (ln) == 1:
|
||||
n = ln[0]
|
||||
print ('<li><a href="source/'+f+'?v='+version+'#L'+str(n)+'">'+f+', line '+str(n)+'</a>', end='')
|
||||
else:
|
||||
if num > 100: # Concise display
|
||||
n = len (ln)
|
||||
print ('<li><a href="source/'+f+'?v='+version+'">'+f+'</a>, '+str(n)+' times')
|
||||
else: # Verbose display
|
||||
print ('<li>'+f)
|
||||
print ('<ul>')
|
||||
for n in ln:
|
||||
print ('<li><a href="source/'+f+'?v='+version+'#L'+str(n)+'">line '+str(n)+'</a>')
|
||||
print ('</ul>')
|
||||
print ('</ul>')
|
||||
|
||||
else:
|
||||
print (head)
|
||||
print ('Invalid request')
|
||||
|
||||
print (open ('template-tail').read(), end='')
|
||||
|
||||
Loading…
Reference in a new issue