Преглед изворни кода

Some pretty awesome stuff.

pull/24/head
Ben Kurtovic пре 13 година
родитељ
комит
2ee3a79d20
11 измењених фајлова са 192 додато и 17 уклоњено
  1. +1
    -1
      build.py
  2. +1
    -1
      pages/bash.mako
  3. +2
    -0
      pages/earwigbot.mako
  4. +2
    -0
      pages/extensions.mako
  5. +27
    -0
      pages/index.mako
  6. +3
    -2
      pages/support/footer.mako
  7. +16
    -3
      pages/support/header.mako
  8. +2
    -0
      pages/surveyor.mako
  9. +2
    -0
      pages/swmt.mako
  10. +36
    -10
      static/css/main.css
  11. +100
    -0
      static/js/potd.js

+ 1
- 1
build.py Прегледај датотеку

@@ -17,7 +17,7 @@ def myapp(environ, start_response):
start_response("200 OK", [("Content-Type", "text/html")])
lookup = TemplateLookup(directories=["{{pages_dir}}"])
template = Template(filename="{{src}}", module_directory="{{temp_dir}}",
lookup=lookup)
lookup=lookup, format_exceptions=True)
return [template.render(environ=environ).encode("utf8")]

if __name__ == "__main__":


+ 1
- 1
pages/bash.mako Прегледај датотеку

@@ -5,7 +5,7 @@
"I make tools and tool accessories."
]
%>\
<%def name="bash()">${choice(bashes)}</%def>\
<%def name="get_bash()">${choice(bashes)}</%def>\
<%include file="/support/header.mako" args="environ=environ, title='Bash'"/>
<ol>
% for bash in bashes:


+ 2
- 0
pages/earwigbot.mako Прегледај датотеку

@@ -0,0 +1,2 @@
<%include file="/support/header.mako" args="environ=environ, title='EarwigBot Status'"/>
<%include file="/support/footer.mako" args="environ=environ"/>

+ 2
- 0
pages/extensions.mako Прегледај датотеку

@@ -0,0 +1,2 @@
<%include file="/support/header.mako" args="environ=environ, title='File Extension Checker'"/>
<%include file="/support/footer.mako" args="environ=environ"/>

+ 27
- 0
pages/index.mako Прегледај датотеку

@@ -1,2 +1,29 @@
<%!
from os import path
import time

tools = [
("Home", "home", "index", True, None),
("Copyvio Detector", "copyvios", "copyvios", False, "Blah"),
("EarwigBot Status", "earwigbot", "earwigbot", True, "Blah"),
("File Extension Checker", "extensions", "extensions", False, "Blah"),
("Contribution Surveyor", "surveyor", "surveyor", False, "Blah"),
("SWMT Helper", "swmt", "swmt", False, "Blah"),
]
%>\
<%
root = path.dirname(environ["SCRIPT_NAME"])
pretty = path.split(root)[0]
%>\
<%def name="get_tools()"><% return tools %></%def>\
<%include file="/support/header.mako" args="environ=environ, title='Home', slug='home'"/>
<h1>My Tools</h1>
% for name, tool, link, complete, desc in tools:
% if desc:
<div class="toolbox">
<p class="toolname"><a class="dark" href="${pretty}/${link}"><span class="medium">${tool}:</span> ${name}</a></p>
<p class="tooldesc">${desc}</p>
</div>
% endif
% endfor
<%include file="/support/footer.mako" args="environ=environ"/>

+ 3
- 2
pages/support/footer.mako Прегледај датотеку

@@ -1,5 +1,5 @@
<%page args="environ"/>\
<%namespace name="bash" file="/bash.mako"/>\
<%namespace name="bash" file="/bash.mako" import="get_bash"/>\
<%!
from os import path
%>\
@@ -19,8 +19,9 @@
<p>Copyright &copy; 2009&ndash;2012 <a href="http://en.wikipedia.org/wiki/User:The_Earwig">Ben Kurtovic</a> &bull; \
<a href="mailto:earwig@toolserver.org">Contact</a> &bull; \
<a href="https://github.com/earwig/toolserver">View Source</a> &bull; \
<a id="bg_image_link" href="">Background</a> &bull; \
<a href="http://validator.w3.org/check?uri=referer">Valid XHTML 1.0 Strict</a><br />
<i><a class="incognito" href="${pretty}/bash">"${bash.bash()}"</a></i>
<i><a class="black" href="${pretty}/bash">"${get_bash()}"</a></i>
</p>
</td>
<td>


+ 16
- 3
pages/support/header.mako Прегледај датотеку

@@ -1,13 +1,18 @@
<%page args="environ, title, slug=None"/>\
<%namespace name="index" file="/index.mako" import="get_tools"/>\
<%!
from itertools import count
from os import path
%>\
<%
tools = get_tools()
root = path.dirname(environ["SCRIPT_NAME"])
this = environ["PATH_INFO"]
pretty = path.split(root)[0]
if not slug:
slug = path.split(this)[1]
if slug.endswith(".fcgi"):
slug = slug[:-5]
%>\
<!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" lang="en-us">
@@ -15,10 +20,18 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>${title} - earwig@toolserver</title>
<link rel="stylesheet" href="${root}/static/css/main.css" type="text/css" />
<script src="${root}/static/js/potd.js" type="text/javascript"></script>
</head>
<body>
<body onload="potd_set_background()">
<div id="header">
<h1 id="head"><a class="dark" href="${pretty}">earwig</a><span class="light">@</span><a class="mid" href="http://wiki.toolserver.org/">toolserver</a><span class="light">:</span><a class="dark" href="${this}">${slug}</a></h1>
<h2 id="links"><span class="light">&gt;</span> <a class="dark" href="${pretty}/index">home</a> <span class="light">&#124;</span> <a class="dark" href="${pretty}/copyvios">copyvios</a></h2>
<p id="heading"><a class="dark" href="${pretty}">earwig</a><span class="light">@</span><a class="mid" href="http://wiki.toolserver.org/">toolserver</a><span class="light">:</span><a class="dark" href="${this}">${slug}</a></p>
<p id="links"><span class="light">&gt;</span>
% for (name, tool, link, complete, desc), num in zip(tools, count(1)):
<abbr title="${name}${' (incomplete)' if not complete else ''}"><a class="${'dark' if complete else 'mid'}" href="${pretty}/${link}">${tool}</a></abbr>
% if num < len(tools):
<span class="light">&#124;</span>
% endif
% endfor
</p>
</div>
<div id="container">

+ 2
- 0
pages/surveyor.mako Прегледај датотеку

@@ -0,0 +1,2 @@
<%include file="/support/header.mako" args="environ=environ, title='Contribution Surveyor'"/>
<%include file="/support/footer.mako" args="environ=environ"/>

+ 2
- 0
pages/swmt.mako Прегледај датотеку

@@ -0,0 +1,2 @@
<%include file="/support/header.mako" args="environ=environ, title='SWMT Helper'"/>
<%include file="/support/footer.mako" args="environ=environ"/>

+ 36
- 10
static/css/main.css Прегледај датотеку

@@ -2,7 +2,8 @@ body {
font-family: helvetica, arial, clean, sans-serif;
font-size: 14px;
color: #000;
background-color: #E0E0E0;
/*background-color: #E0E0E0;*/
background-color: #000;
}

ul, ol {
@@ -12,7 +13,7 @@ ul, ol {
div#header {
margin: 20px;
padding: 2px 15px 2px 15px;
border: 1px solid #999;
border: 1px solid #777;
background-color: #FFF;
}

@@ -20,7 +21,7 @@ div#container {
line-height: 1.5;
margin: 0 20px 90px 20px;
padding: 2px 15px 2px 15px;
border: 1px solid #999;
border: 1px solid #777;
background-color: #FFF;
}

@@ -43,17 +44,19 @@ div#footer {
}

div#foot-divider {
border-bottom: 1px solid #999;
border-bottom: 1px solid #777;
}

h1#head {
p#heading {
font-size: 3em;
font-weight: bold;
margin: 15px 0 12px 0;
}

h2#links {
font-size: 1.75em;
margin: 8px 0 8px 0;
p#links {
font-size: 1.65em;
font-weight: bold;
margin: 8px 0 14px 0;
}

table#footer-box {
@@ -61,16 +64,39 @@ table#footer-box {
height: 100%;
}

span.light { color: #CCC; }
div.toolbox {
margin: 15px 0 15px 0;
padding: 0 6px 0 6px;
border: 1px solid #999;
background-color: #F5F5F5;
}

p.toolname {
font-size: 18px;
margin: 6px 0 6px 0;
background-color: #E7E7E7;
}

p.tooldesc {
margin: 6px 0 6px 0;
}

span.light { color: #CCC; }
span.medium { color: #AAA; }

a:link { color: #373; text-decoration: none; }
a:visited { color: #373; text-decoration: none; }
a:hover { color: #040; text-decoration: underline; }
a:active { color: #404; text-decoration: underline; }

a.black:link { color: #000; }
a.black:visited { color: #000; }
a.black:hover { color: #000; }
a.black:active { color: #000; }

a.dark:link { color: #777; }
a.dark:visited { color: #777; }
a.dark:hover { color: #555; }
a.dark:hover { color: #777; }
a.dark:active { color: #333; }

a.mid:link { color: #AAA; }


+ 100
- 0
static/js/potd.js Прегледај датотеку

@@ -0,0 +1,100 @@
function potd_set_background() {
var d = new Date();
var callback = "like_a_boss";
var date = (d.getUTCFullYear()) + "-" + zero_pad(d.getUTCMonth() + 1, 2) + "-" + zero_pad(d.getUTCDate(), 2);
var base = "http://commons.wikimedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Template:Potd/";
var url = base + date + "&callback=" + callback;

var script = document.createElement("script");
var head = document.getElementsByTagName("head")[0];

window[callback] = function(data) {
head.removeChild(script);
parse_file_name(data);
};

script.src = url;
head.appendChild(script);
}

function parse_file_name(data) {
var content = "";
var res = data["query"]["pages"];
for (pageid in res) {
content = res[pageid]["revisions"][0]["*"];
}
var filename = /\{\{Potd filename\|(1=)?(.*?)\|.*?\}\}/.exec(content)[2];

var callback = "like_a_faust";
var base = "http://commons.wikimedia.org/w/api.php?action=query&prop=imageinfo&iiprop=url|size&format=json&titles=File:";
var url = base + escape(filename) + "&callback=" + callback;

var script = document.createElement("script");
var head = document.getElementsByTagName("head")[0];

window[callback] = function(data) {
head.removeChild(script);
parse_file_url(data, escape(filename.replace(/ /g, "_")));
};

script.src = url;
head.appendChild(script);
}

function parse_file_url(data, filename) {
var url = "";
var descurl = "";
var imgwidth = 1024;
var imgheight = 768;

var res = data["query"]["pages"];
for (pageid in res) {
r = res[pageid]["imageinfo"][0];
url = r["url"];
descurl = r["descriptionurl"];
imgwidth = r["width"];
imgheight = r["height"];
}

url = url.replace(/\/commons\//, "/commons/thumb/");
var s = get_window_size();
var winwidth = s[0];
var winheight = s[1];

var width = winwidth;
if (imgwidth/imgheight > winwidth/winheight) {
width = Math.round((imgwidth/imgheight) * winheight);
}
url += "/" + width + "px-" + filename;

document.body.style.backgroundImage="url('" + url + "')";
document.getElementById("bg_image_link").href = descurl;
}

function zero_pad(value, length) {
value = String(value);
length = length || 2;
while (value.length < length) {
value = "0" + value;
}
return value;
}

function get_window_size() {
// See http://www.javascripter.net/faq/browserw.htm
var width = 1024,
height = 768;
if (document.body && document.body.offsetWidth && document.body.offsetHeight) {
width = document.body.offsetWidth;
height = document.body.offsetHeight;
}
if (document.compatMode=="CSS1Compat" && document.documentElement && document.documentElement.offsetWidth && document.documentElement.offsetHeight) {
width = document.documentElement.offsetWidth;
height = document.documentElement.offsetHeight;
}
if (window.innerWidth && window.innerHeight) {
width = window.innerWidth;
height = window.innerHeight;
}
return [width, height];
}

Loading…
Откажи
Сачувај