Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

First half-assed attempted at Sphinx-ify-ing the Djangobook theme.

  • Loading branch information...
commit 5819bf5266484341408b32accc4b166eb70d341b 1 parent acc918f
@jacobian jacobian authored
View
46 themes/djangobook/layout.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ <title>{% block title %}The Django Book{% endblock %}</title>
+ <link rel="stylesheet" href="{{ pathto("_static/reset-min.css", 1) }}" type="text/css">
+ <link rel="stylesheet" href="{{ pathto("_static/grids-min.css", 1) }}" type="text/css">
+ <link rel="stylesheet" href="{{ pathto("_static/djangobook.css", 1) }}" type="text/css">
+ {% block extrahead %}{% endblock %}
+ </head>
+ <body>
+ <div id="doc" class="yui-t7">
+ <div id="hd">
+ <h1><a href="/">The Django Book</a></h1>
+ <div id="global-nav">
+ <a class="about" href="/about/">About</a>
+ |
+ <a class="comment-help" href="/about/comments/">Comment help</a>
+ |
+ <a class="contact" href="/contact/">Contact us</a>
+ |
+ <a class="errata" href="/errata/">Errata</a>
+ |
+ <a class="buy"
+ href="http://www.amazon.com/gp/product/1590597257?ie=UTF8&amp;tag=djangoproject-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1590597257">
+ Buy the print version on Amazon.com</a>
+ </div>
+ {% block hdnav %}{% endblock %}
+ </div>
+ <div id="bd">
+ <div id="yui-main">
+ <div class="yui-b">
+ {% block content %}{% endblock %}
+ </div>
+ </div>
+ </div>
+ <div id="ft">
+ {% block ftnav %}{% endblock %}
+ Copyright Adrian Holovaty, Jacob Kaplan-Moss, et al.<br>This
+ work is licensed under the <a href="/license/">GNU Free Document
+ License</a>.
+ </div>
+ </div>
+ {% block afterbody %}{% endblock %}
+ </body>
+</html>
View
7 themes/djangobook/page.html
@@ -0,0 +1,7 @@
+{% extends "layout.html" %}
+
+{% block title %}{{ title }}{% endblock %}
+
+{% block content %}
+ <div id="chapter-body">{{ body }}</div>
+{% endblock %}
View
1  themes/djangobook/search.html
@@ -0,0 +1 @@
+TODO!
View
177 themes/djangobook/static/djangobook.css
@@ -0,0 +1,177 @@
+/*** setup ***/
+body { font:12px/1.5 Verdana,sans-serif; background:#092e20; color: white;}
+#bd { background:#487858; }
+#doc { padding-top:16px; }
+
+/*** links ***/
+a img {border: none;}
+a {text-decoration: none;}
+a:hover { color:#ffe761; }
+a:link, a:visited { color:#ffc757; }
+h2 a, h3 a, h4 a { text-decoration:none !important; }
+#bd a:hover { background-color:#E0FFB8; color:#234f32; text-decoration:none; }
+#bd a:link, #bd a:visited { color:#ab5603; }
+
+/*** nav ***/
+div.nav { margin: 0; font-size: 11px; text-align: right; color: #487858;}
+#hd div.nav { margin-top: -27px; }
+#ft div.nav { margin-bottom: -18px; }
+
+#hd h1 a { color: white; }
+
+#global-nav { position:absolute; top:5px; padding:7px 0; color:#263E2B;}
+#global-nav a:link, #global-nav a:visited {color:#487858;}
+#global-nav a {padding:0 4px;}
+#global-nav a.about {padding-left:0;}
+#global-nav:hover {color:#fff;}
+#global-nav:hover a:link, #global-nav:hover a:visited { color:#ffc757; }
+
+
+/*** content ***/
+#chapter-body { position: relative; }
+#yui-main div.yui-b { margin: 0 0 0 20px; background: white; color: black; padding: 0.3em 2em 1em 2em; }
+dd { margin-left:15px; }
+h1 { font-size:218%; margin-top:0.6em; margin-bottom:.4em; line-height:1.1em; }
+h1,h2,h3,h4 { margin-top:1.4em; font-family:"Trebuchet MS",sans-serif; font-weight:normal; }
+h2#chapter-title { font-size: 218%; line-height:1.2em; margin-bottom: 0.8em; }
+h2#chapter-subtitle { font-size: 140%; margin-top:-1.2em !important; margin-bottom:1.6em; margin-left:.2em; color:#487858; }
+h3 { font-size:150%; margin-bottom:.6em; line-height:1.2em; color:#092e20; }
+h4 { font-size:125%; font-weight:bold; margin-bottom:.2em; color:#487858; }
+h5 { font-size:1em; font-weight:bold; margin-top:1.5em; margin-bottom:3px; }
+div.figure { text-align: center; }
+div.figure p.caption { font-size:1em; margin-top:0; margin-bottom:1.5em; color: #555;}
+hr { color:#ccc; background-color:#ccc; height:1px; border:0; }
+p, ul, dl { margin-top:.6em; margin-bottom:1em; padding-bottom: 0.1em;}
+#chapter-body img { max-width: 50em; margin-left: auto; margin-right: auto; display: block; }
+table { color:#000; margin-bottom: 1em; width: 100%; }
+table.docutils td p { margin-top:0; margin-bottom:.5em; }
+table.docutils td, table.docutils th { border-bottom:1px solid #dfdfdf; padding:4px 2px;}
+table.docutils thead th { border-bottom:2px solid #dfdfdf; text-align:left; font-weight: bold; white-space: nowrap; }
+table.docutils thead th p { margin: 0; padding: 0; }
+table.docutils { border-collapse:collapse; }
+caption { font-size:1em; font-weight:bold; margin-top:0.5em; margin-bottom:0.5em; margin-left: 2px; text-align: center; }
+blockquote { padding: 0 1em; margin: 1em 0; font:125%/1.2em "Trebuchet MS", sans-serif; color:#234f32; border-left:2px solid #94da3a; }
+strong { font-weight: bold; }
+em { font-style: italic; }
+
+/*** one-off for chapter 7 ***/
+#chapter-body #cn0 strong { font-size:150%; margin-bottom:.6em; line-height:1.2em; color:#092e20; }
+
+/*** messages ***/
+div.newer-version, div.message {color:#092e20; background: #FAFBD1 url(images/error.png) no-repeat 10px 50%; padding:3px 2px 5px 35px; font-size:13px; margin-top:1.5em;}
+
+/*** lists ***/
+ul { padding-left:30px; }
+ol { padding-left:30px; }
+ol.arabic { list-style-type: decimal; }
+ul li { list-style-type:square; margin-bottom:.4em; }
+ol li { margin-bottom: .4em; }
+ul ul { padding-left:1.2em; }
+ul ul ul { padding-left:1em; }
+ul.linklist, ul.toc { padding-left:0; }
+ul.toc ul { margin-left:.6em; }
+ul.toc ul li { list-style-type:square; }
+ul.toc ul ul li { list-style-type:disc; }
+ul.linklist li, ul.toc li { list-style-type:none; }
+dt { font-weight:bold; margin-top:.5em; font-size:1.1em; }
+dd { margin-bottom:.8em; }
+ol.toc { margin-bottom: 2em; }
+ol.toc li { font-size:125%; padding: .5em; line-height:1.2em; clear: right; }
+ol.toc li.b { background-color: #E0FFB8; }
+ol.toc li a:hover { background-color: transparent !important; text-decoration: underline !important; }
+ol.toc span.release-date { color:#487858; float: right; font-size: 85%; padding-right: .5em; }
+ol.toc span.comment-count { font-size: 75%; color: #999; }
+/*** code blocks ***/
+.literal { white-space:nowrap; }
+.literal, .literal-block { color:#234f32; }
+.sidebar .literal { color:white; background:transparent; font-size:11px; }
+h4 .literal { color: #234f32; font-size: 13px; }
+pre, .literal-block { font-size:medium; background:#E0FFB8; border:1px solid #94da3a; border-width:1px 0; margin: 1em 0; padding: .3em .4em; overflow: hidden; }
+dt .literal, table .literal { background:none; }
+
+/*** notes & admonitions ***/
+.note, .admonition { padding:.8em 1em .8em; margin: 1em 0; border:1px solid #94da3a; }
+.admonition-title { font-weight:bold; margin-top:0 !important; margin-bottom:0 !important;}
+.admonition .last { margin-bottom:0 !important; }
+.admonition-philosophy { padding-left:65px; background:url(http://media.djangoproject.com/img/doc/icons/docicons-philosophy.gif) .8em .8em no-repeat;}
+.note, .admonition { padding-left:65px; background:url(http://media.djangoproject.com/img/doc/icons/docicons-note.gif) .8em .8em no-repeat;}
+.admonition-behind-the-scenes { padding-left:65px; background:url(http://media.djangoproject.com/img/doc/icons/docicons-behindscenes.gif) .8em .8em no-repeat;}
+
+/*** comment stuff ***/
+.cn { position: relative; }
+#comments { padding: 0; border: 1px #092e20 solid; left: 300; top:0; position: absolute; z-index: 10; background-color: #E0FFB8; width: 600px; height: 400px; color: black; overflow: hidden; display: none; text-align: left; }
+#comment-tabs { padding: 6px; }
+#comments .ft { height:50px; overflow:hidden; padding: 6px; }
+#comments .tabset .hd li a { background-color: #487858; color:white; }
+#comments .tabset .hd li.on em { color: #092e20; }
+#comments .yui-ext-tabbody { font-size: 90%; background-color: white; border: 1px #999 solid; border-top: none; height: 285px; overflow: auto; padding: 1em; }
+#comments div.tab input { width: 100%; }
+#comments div.tab input#id_name { width: 70%; }
+#comments div.tab input#id_remember_me { width: auto; }
+#comments div.tab label { font-weight: bold; display: block; color: #487858; }
+#comments div.tab textarea { width: 100%; height: 100px; }
+#comments div.tab p { margin-bottom: 0; }
+#comments div.tab span.actions { float: right; margin-top: -15px; }
+#comments div.tab span.thanks { color: black; font-weight: bold; color: #F7C754; position: relative;}
+#comments-close { margin-left:5px;margin-right:15px; }
+#comments-head .close { position: absolute; top: 3px; right: 4px; height: 13px; width: 17px; margin:0; padding: 0; overflow: hidden; text-indent:-999px; background: url(images/close.png) no-repeat top left;}
+#comments-head { background-color: #487858; color: white; padding: 2px 4px; font-weight: bold; margin: 0 0 6px 0; position: relative;}
+#comments-message { font-size: 90%; padding-left: 20px; float:left; clear:none; width:270px; }
+#comments-message.loading { background: url(images/loading.gif) no-repeat center left; }
+#comments-message.error { background: url(images/error.png) no-repeat center left; color: red; font-weight: bold; }
+#comments-submit-wrapper { float:right; clear:none;white-space:nowrap; width: 150px; text-align: right;}
+#comments-submit-wrapper input { font-size: 11px; }
+#highlight-floater { position: absolute; z-index: 5; background: #487858; top:0; left:0; width:100%; height: 10px; visibility: hidden; border-top: 1px black solid; border-bottom: 1px black solid; border-left: 20px black solid;}
+
+/*** comment box resizer ***/
+#comments .yresizable-handle-east { background-image: url(yui-ext/images/sizer/e-handle-dark.gif); border: 0px; }
+#comments .yresizable-handle-south { background-image: url(yui-ext/images/sizer/s-handle-dark.gif); border: 0px; }
+#comments .yresizable-handle-southeast { background-image: url(yui-ext/images/sizer/se-handle-dark.gif); border: 0px; }
+
+/*** comment list tab ***/
+#comment-tabs div.tab ol { padding: 0; margin: 0; font-size: 90%; }
+#comment-tabs div.tab dl { margin-bottom: 0; }
+#comment-tabs div.tab li { border-bottom: 1px #E0FFB8 solid; }
+#comment-tabs div.tab li span.meta { font-weight:normal; color: #487858; font-size: 90%; }
+#comment-tabs div.tab a:hover { background-color:#E0FFB8; color:#234f32; text-decoration:none; }
+#comment-tabs div.tab a:link, #comment-tabs div.tab a:visited { color:#ab5603; }
+
+/*** comment indicator ***/
+div.comment-indicator { position: absolute; width: 20px; z-index: 999; text-align: center; color: black; font-size: 11px; left: -44px; top: 0; }
+li.cn div.comment-indicator { left: -74px; }
+div.admonition div.comment-indicator { left: -45px; }
+blockquote div.comment-indicator { left: -46px; }
+ul ul li.cn div.comment-indicator { left: -88px; }
+div.comment-indicator:hover { background-color: #406b4e; }
+div.comment-indicator span { position: absolute; top: -10px; left: -10px; width: 25px; height: 25px; }
+div.comment-indicator:hover span { background-image: url(images/comment-hover.png); }
+div.has-comments > span, div.has-comments:hover > span { background-image: url(images/comment-active.png); }
+
+/*** help tab ***/
+#comment-tabs-help h4 { margin-top: 0; }
+#comment-tabs-help p.image { text-align: center; }
+#comment-tabs-help img { padding: 4px; border: 1px #999 solid; }
+
+/*** forms ***/
+#chapter-body form label { display: block; font-weight: bold; margin-top: 1.5em; margin-bottom: 0;}
+#chapter-body form label span { font-weight: normal; color: #555; }
+#chapter-body form input, #chapter-body form textarea, #chapter-body form select { width: 100%; padding: 1px; }
+#chapter-body form p { margin: 0; }
+#chapter-body form p.submit { text-align: right; }
+#chapter-body form p.submit input { width: 10em; font-size: 1.5em; }
+#chapter-body form p.errors { margin: 0; padding: 0; font-weight: bold; color: red; }
+
+/*** errata pages ***/
+div.errata p.reported-by { font-size: 90%; color: #555; }
+div.errata p { margin-bottom: 0; }
+div.errata { border-bottom:1px solid #dfdfdf; padding-bottom: 0.5em; }
+div.last { border-bottom: 0px none; }
+#chapter-title span { font-size: 70%; }
+
+/*** footer ***/
+#ft { color:#487858; font-size:90%; padding-bottom: 2em; }
+
+/*** IE hacks ***/
+* pre { width: 100%; }
+* div.has-comments span { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="http://media.djangobook.com/images/comment-active.png", sizingMethod="scale"); }
+* #comments div.tab input { width: 95%; }
View
2  themes/djangobook/static/grids-min.css
@@ -0,0 +1,2 @@
+/* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt Version: 0.11.3 */
+body{text-align:center;}#doc{width:57.69em;*width:56.3em;min-width:750px;margin:auto;text-align:left;}#hd,#bd{margin-bottom:1em;text-align:left;}#ft{font-size:77%;font-family:verdana;clear:both;}.yui-t1 #yui-main .yui-b, .yui-t2 #yui-main .yui-b, .yui-t3 #yui-main .yui-b, .yui-t4 .yui-b, .yui-t5 .yui-b, .yui-t6 .yui-b{float:right;}.yui-t1 .yui-b, .yui-t2 .yui-b, .yui-t3 .yui-b, .yui-t4 #yui-main .yui-b, .yui-t5 #yui-main .yui-b, .yui-t6 #yui-main .yui-b{float:left;}.yui-t1 #yui-main .yui-b{width:76%;min-width:570px;}.yui-t1 .yui-b{width:21.33%;min-width:160px;}.yui-t2 #yui-main .yui-b, .yui-t4 #yui-main .yui-b{width:73.4%;min-width:550px;}.yui-t2 .yui-b, .yui-t4 .yui-b{width:24%;min-width:180px;}.yui-t3 #yui-main .yui-b, .yui-t6 #yui-main .yui-b{width:57.6%;min-width:430px;}.yui-t3 .yui-b, .yui-t6 .yui-b{width:40%;min-width:300px;}.yui-t5 #yui-main .yui-b{width:65.4%;min-width:490px;}.yui-t5 .yui-b{width:32%;min-width:240px;}.yui-g .yui-u, .yui-g .yui-g, .yui-ge .yui-u, .yui-gf .yui-u{float:right;display:inline;}.yui-g .first, .yui-gd .first, .yui-ge .first, .yui-gf .first{float:left;}.yui-g .yui-u, .yui-g .yui-g{width:49.1%;}.yui-g .yui-g .yui-u{width:48.1%;}.yui-gb .yui-u, .yui-gc .yui-u, .yui-gd .yui-u{float:left;margin-left:2%;*margin-left:1.895%;width:32%;}.yui-gb .first, .yui-gc .first, .yui-gd .first{margin-left:0;}.yui-gc .first, .yui-gd .yui-u{width:66%;}.yui-gd .first{width:32%;}.yui-ge .yui-u{width:24%;}.yui-ge .first, .yui-gf .yui-u{width:74.2%;}.yui-gf .first{width:24%;}.yui-ge .first{width:74.2%;}#bd:after, .yui-g:after, .yui-gb:after, .yui-gc:after, .yui-gd:after, .yui-ge:after, .yui-gf:after{content:".";display:block;height:0;clear:both;visibility:hidden;}#bd, .yui-g, .yui-gb, .yui-gc, .yui-gd, .yui-ge, .yui-gf{zoom:1;}
View
BIN  themes/djangobook/static/images/bar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  themes/djangobook/static/images/close.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  themes/djangobook/static/images/comment-active.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  themes/djangobook/static/images/comment-hover.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  themes/djangobook/static/images/djangobook-logo.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  themes/djangobook/static/images/error.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  themes/djangobook/static/images/loading.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
375 themes/djangobook/static/pea.py
@@ -0,0 +1,375 @@
+#!/usr/bin/env python
+"""peastat - simple live web stats
+http://www.throwingbeans.org/peastat/
+
+instructions:
+1. configure the 'logfile' and 'rooturl' values below
+2. upload peastat.py somewhere it can be executed on your web server (e.g. your cgi-bin)
+3. make peastat.py executable (set its permissions to 755)
+"""
+__version__ = "0.2"
+__author__ = "Tom Dyson (tomdyson at spamcop dot net)"
+__copyright__ = "(C) 2005 Tom Dyson. GNU GPL 2."
+__url__ = 'http://www.throwingbeans.org/peastat/'
+
+import cgitb
+cgitb.enable()
+import cgi, os, re, time, urllib
+try: import dbm # anydbm is unreliable...
+except: import dumbdbm as dbm
+
+# start configuring:
+logfile = "/home/jacob/web/log/djangobook.com/www.log" # full path to log file
+rooturl = "http://www.djangobook.com/" # root url of site whose logs we're analysing
+# configure if you want to:
+minresults = 10 # minimum results to include in overview
+lastlines = 5000 # number of most recent requests to analyse
+ispage = re.compile('/$').search # requests matching this regex count as pages
+ignorelines = re.compile('24\.124\.4\.220').search # ignore lines including this regex
+recentreferrers = 20 # show this many recent referrers
+recentsearches = 20 # show this many recent search terms
+database = "/tmp/jkmpeastat.db" # store DNS lookups here
+# stop configuring
+
+url = None; ip = None; atom = False
+cgiloc = os.environ.get('SCRIPT_NAME', '')
+request_uri = os.environ.get('REQUEST_URI', '')
+server_name = os.environ.get('SERVER_NAME', '')
+apachetoday = time.strftime('%d/%b/%Y')
+# todo ooh
+
+form = cgi.FieldStorage()
+if form.has_key( "url" ): url = form["url"].value
+if form.has_key( "ip" ): ip = form["ip"].value
+if form.has_key( "atom" ): atom = True
+
+def justdomain(url):
+ # Return only the domain of a URL
+ try:
+ return url.split('//')[1].split('/')[0]
+ except IndexError: # catch evil referrers
+ return 'bad referrer'
+
+thisdomain = justdomain(rooturl)
+
+def sortByValue(d):
+ """ Returns the keys of dictionary d sorted by their values """
+ items=d.items()
+ backitems=[ [v[1],v[0]] for v in items]
+ backitems.sort(); backitems.reverse()
+ return [ backitems[i][1] for i in range(0,len(backitems))]
+
+def tailLines(filename,linesback):
+ """python tail - modified from recipe at
+ http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/157035
+ returns list of [linesback] lines from end of [filename]"""
+ avgcharsperline=150
+
+ file = open(filename,'r')
+ while 1:
+ try: file.seek(-1 * avgcharsperline * linesback,2)
+ except IOError: file.seek(0)
+ if file.tell() == 0: atstart=1
+ else: atstart=0
+ lines=file.read().split("\n")
+ if (len(lines) > (linesback+1)) or atstart: break
+ #The lines are bigger than we thought
+ avgcharsperline=avgcharsperline * 1.3 #Inc avg for retry
+ file.close()
+
+ if len(lines) > linesback: start=len(lines)-linesback -1
+ else: start=0
+ return lines[start:len(lines)-1]
+
+def timeSinceApacheDate(apacheDate):
+ then = time.strptime(apacheDate,'%d/%b/%Y:%H:%M:%S')
+ then = time.mktime(then)
+ now = time.mktime(time.localtime())
+ minutesSince = (now-then) / 60
+ hours, minutes = divmod(minutesSince,60)
+ return int(hours), int(minutes)
+
+def getDNS(ip):
+ # get the domain name, if we've seen it before
+ try:
+ db = dbm.open(database, "c")
+ if db.has_key(ip): addr = db[ip]
+ else: addr = ip
+ db.close()
+ except: addr = ip
+ return addr
+
+def getLogLines(logfile):
+ try: logLines = tailLines(logfile,lastlines)
+ except: # or try system's tail
+ logLines = os.popen('/usr/bin/tail -n '
+ + str(lastlines) + ' ' + logfile).readlines()
+ if len(logLines) == 0: # can't handle popen exceptions properly
+ raise Exception ('No lines found')
+ return logLines
+
+loglines = getLogLines(logfile)
+
+def getOverview():
+
+ t0 = time.time()
+ overview = {'cgiloc':cgiloc}
+ hits = {}
+ pagecount = 0
+ overview["totalhits"] = len(loglines)
+ referrers = []
+ queries = {}
+ timeoffirsthit = loglines[0].split(' ')[3].replace('[','')
+
+ for line in loglines:
+ resource = line.split(' ')[6]
+ if ispage(resource) and not ignorelines(line):
+ pagecount = pagecount + 1
+ hits[resource] = hits.get(resource,0) + 1
+ lastres = resource
+ line = line.replace('\\"','&quot;') # some agents include escaped quotes
+ referrer = line.split('"')[-4]
+ if len(referrer) > 1 and referrer.find(thisdomain) == -1:
+ # count queries
+ querydict = cgi.parse_qs(referrer.split("?")[-1])
+ if referrer.count(".yahoo."):
+ q = querydict.get("p")
+ else: q = querydict.get("q")
+ if q:
+ q = q[0].lower()
+ queries[q] = queries.get(q,0) + 1
+ referrers.append([referrer, q])
+
+ t1 = time.time()
+ overview["timing"] = int((t1 - t0) * 1000)
+ overview["logfile"] = logfile
+ overview["timeoffirsthit"] = timeoffirsthit
+ overview["hits"] = hits
+ overview["lastrequest"] = lastres
+ overview["pagecount"] = pagecount
+ overview["referrers"] = referrers
+ overview["queries"] = queries
+ hourssince, minutessince = timeSinceApacheDate(timeoffirsthit)
+ pagehitsperhour = pagecount / (hourssince + ( float(minutessince) / 60 ))
+ overview["hourssince"], overview["minutessince"] = hourssince, minutessince
+ overview["pagehitsperhour"] = int(round(pagehitsperhour))
+
+ return overview
+
+def displayOverviewHTML(overview):
+ print """
+ <p class = "section"><strong>Summary</strong><br />
+ First hit counted %(hourssince)s hours, %(minutessince)s minutes ago<br />
+ Total hits: %(totalhits)s<br />
+ Page hits: %(pagecount)s (%(pagehitsperhour)s per hour)<br />
+ Last page request: %(lastrequest)s <a href = "%(cgiloc)s?url=%(lastrequest)s">details</a><br />
+ Processing time: %(timing)s ms</p>""" % overview
+
+ print """<p class = "section"><strong>Recent popular pages (%s or more requests)</strong><br />""" % minresults
+
+ hits = overview["hits"]
+ for res in sortByValue(hits):
+ score = hits[res]
+ if score >= minresults:
+ print """%s:
+ <a href = "%s?url=%s">%s</a>
+ <br />""" % (res, overview["cgiloc"], urllib.quote(res), score)
+
+ print """</p><p class = "section"><strong>%s recent referrers</strong><br />""" % recentreferrers
+
+ referrers = overview["referrers"]
+ referrers.reverse()
+ for referrer, query in referrers[0:recentreferrers]:
+ referrer = referrer.replace("&","&amp;")
+ print """<a href = "%s" title = "%s" rel = "nofollow">%s</a>""" % (referrer, referrer, justdomain(referrer))
+ if query: print "<i> - %s</i>" % query
+ print "<br />"
+ print "</p>"
+
+ print """<p class = "section"><strong>%s recent popular search terms</strong><br />""" % recentsearches
+
+ queries = overview["queries"]
+ for query in sortByValue(queries)[0:recentsearches]:
+ query_score = queries[query]
+ quoted_query = query.replace('"','%22')
+ print """<a href = "http://www.google.com/search?q=%(quoted_query)s">%(query)s</a>:
+ %(query_score)s<br />""" % vars()
+ print "</p>"
+
+def urldetails(url, cgiloc):
+
+ print """<p class = "section" id = "urldetails">Requests for <b>%s</b><br /><br />""" % url
+ counter = 1
+ for line in loglines:
+ resource = line.split(' ')[6]
+ if resource == url and not ignorelines(line):
+ time = line.split(' ')[3].replace('[','')
+ if time.startswith(apachetoday): time = time.replace(apachetoday +':','today, ')
+ ip = line.split(' ')[0]
+ addr = getDNS(ip)
+ print """%(counter)s: %(time)s: <a href = "%(cgiloc)s?ip=%(ip)s">%(addr)s</a>
+ <br />""" % vars()
+ counter = counter + 1
+ print "</p>"
+
+def ipdetails(ip, cgiloc):
+
+ import socket
+ try: addr = socket.gethostbyaddr(ip)[0]
+ except: addr = 'unknown host'
+ if addr != 'unknown host': # add successful lookups to the DNS cache
+ try:
+ db = dbm.open(database, "c")
+ db[ip] = addr
+ db.close()
+ except: pass # fail silently - lots of things could have gone wrong...
+ print """<p class = "section">Visit details for <b>%s</b><br /><b>hostname:</b> %s<br />""" % (ip, addr)
+ counter = 1; pagecounter = 1
+ for line in loglines:
+ address = line.split(' ')[0]
+ if address == ip:
+ time = line.split(' ')[3].replace('[','')
+ if time.startswith(apachetoday): time = time.replace(apachetoday +':','today, ')
+ resource = line.split(' ')[6]
+ if counter == 1:
+ referrer = line.split('"')[-4]
+ user_agent = line.split('"')[-2]
+ if len(user_agent) > 50: user_agent = user_agent[0:50].strip() + "..."
+ if len(referrer) > 1:
+ print """<b>referrer:</b> <a href = "%(referrer)s">%(referrer)s</a><br />""" % vars()
+ print """<b>browser:</b> %(user_agent)s<br /><br />""" % vars()
+ if ispage(resource):
+ quotedresource = urllib.quote(resource)
+ print """%(pagecounter)s: <b>%(time)s</b>: %(resource)s [<a href = "%(cgiloc)s?url=%(quotedresource)s">details</a>]
+ <br />""" % vars()
+ pagecounter += 1
+ counter += 1
+ print "</p>"
+
+def header():
+ print "Content-type: text/html\n\n"
+ print """<!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>peastat</title>
+ <link rel="alternate" type="application/atom+xml" title="Atom" href="http://%s%s?atom=true" />""" % (server_name, request_uri)
+ print """<meta http-equiv="content-type" content="text/html" />
+ <meta http-equiv="content-language" content="en" />
+ <style>
+ #container {width: 450px; margin: 10px auto 10px auto; text-align: left; border: dotted 0px #999}
+ body{
+ margin: 0px 0px 0px 0px;
+ background-color: #F5F5F5;
+ text-align: center;
+ font-family: 'Lucida Grande', 'Lucida Sans Unicode', Lucida, 'Trebuchet MS', Trebuchet, Verdana, Geneva, Arial, Helvetica, sans-serif;
+ #border-color: #CCF; border-width: 6px; border-style: dotted none none none;
+ border-color: white; border-width: 8px; border-style: dotted none none none;
+ font-size: small;
+ color: #333;line-height: 150%;
+ }
+ strong {color:orange}
+ a:visited, a:active, a:link {color: #C30; text-decoration: none; border-bottom: dotted 1px #999;}
+ a:hover {color: red; text-decoration: none; border-bottom: dotted 1px #999;}
+ h4 {font-weight: bold; font-size: 26px; color: #666; margin-bottom: 3px; margin-top:3px}
+ h4 a {border-bottom: dotted 0px white !important}
+ .section {padding:4px; border:1px solid #ddd; background-color:#FFF}
+ .greysection {
+ padding:4px; border:1px solid #ddd; background-color:#F5F5F5;
+ color:grey}
+ .greysection a {color: gray}
+ .section:hover {border:1px dotted red;}
+ #urldetails a:visited {color:#333;}
+ </style>
+ <script type="text/javascript">
+ // simple AJAX library
+ // see http://homepage.mac.com/kevinmarks/staticjah.html
+ function jah(url,target) {
+ // native XMLHttpRequest object
+ document.getElementById(target).innerHTML = 'sending...';
+ if (window.XMLHttpRequest) {
+ req = new XMLHttpRequest();
+ req.onreadystatechange = function() {jahDone(target);};
+ req.open("GET", url, true);
+ req.send(null);
+ // IE/Windows ActiveX version
+ } else if (window.ActiveXObject) {
+ req = new ActiveXObject("Microsoft.XMLHTTP");
+ if (req) {
+ req.onreadystatechange = function() {jahDone(target);};
+ req.open("GET", url, true);
+ req.send();
+ }
+ }
+ }
+ function jahDone(target) {
+ // only if req is "loaded"
+ if (req.readyState == 4) {
+ // only if "OK"
+ if (req.status == 200) {
+ results = req.responseText;
+ document.getElementById(target).innerHTML = results;
+ } else {
+ document.getElementById(target).innerHTML="jah error: " + req.statusText;
+ }
+ }
+ }
+ </script>
+ </head>
+ <body><div id = "container">"""
+
+ print """<h4><a href = "%s">peastat</a></h4>""" % (cgiloc)
+
+def footer(): print """
+ <p class = "greysection">
+ peastat %s
+ &copy; <a href = "http://www.throwingbeans.org/">tom dyson</a> 2005 //
+ <a href = "http://www.throwingbeans.org/peastat/">updates, bugs, suggestions</a>
+ </p>
+ </div></body></html>""" % (__version__)
+
+def atomHeader():
+ basehref = server_name + request_uri
+ cleanurl = rooturl.replace("http://","")
+ timestamp = time.strftime("%Y-%m-%dT%H:%M:%SZ")
+ print """Content-type: application/atom+xml\n\n<?xml version='1.0' encoding='UTF-8'?>
+ <feed xmlns="http://www.w3.org/2005/Atom">
+ <title>peastat for %(cleanurl)s</title>
+ <link href="http://%(basehref)s/"/>
+ <updated>%(timestamp)s</updated>
+ <author><name>peastat</name></author>
+ <id>http://%(basehref)s/</id>""" % vars()
+
+def atomSummary(overview):
+ basehref = server_name + request_uri
+ cleanurl = rooturl.replace("http://","")
+ timestamp = time.strftime("%Y-%m-%dT%H:%M:%SZ")
+ print """<entry>
+ <title>Summary for %(cleanurl)s</title>
+ <link href='%(basehref)s' />
+ <id>http://%(basehref)s</id>
+ <updated>%(timestamp)s</updated>
+ <content type="xhtml">
+ <div xmlns="http://www.w3.org/1999/xhtml">""" % vars()
+
+ displayOverviewHTML(overview)
+
+ print """</div></content></entry>"""
+
+def atomFooter():
+ print "</feed>"
+
+if __name__ == "__main__":
+ if atom:
+ atomHeader()
+ overview = getOverview()
+ atomSummary(overview)
+ atomFooter()
+ else:
+ header()
+ if url: urldetails(url, cgiloc)
+ elif ip: ipdetails(ip, cgiloc)
+ else:
+ overview = getOverview()
+ displayOverviewHTML(overview)
+ footer()
View
2  themes/djangobook/static/reset-min.css
@@ -0,0 +1,2 @@
+/* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License:http://developer.yahoo.net/yui/license.txt Version: 0.11.3 */
+body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}ol,ul {list-style:none;}caption,th {text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;}q:before,q:after{content:'';}
View
4 themes/djangobook/theme.conf
@@ -0,0 +1,4 @@
+[theme]
+inherit = none
+stylesheet = djangobook.css
+pygments_style = sphinx
Please sign in to comment.
Something went wrong with that request. Please try again.