Cleanup and building static site
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
build/
|
19
pages/index.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
title: ''
|
||||||
|
permalink: /
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
<div class="contentItem">
|
||||||
|
<h2 class="postTitle"><a href="/blog/">Blog</a></h2>
|
||||||
|
<p class="postSubTitle">Pretty much anything I feel like writing.</p>
|
||||||
|
</div>
|
||||||
|
<!--
|
||||||
|
<div class="contentItem">
|
||||||
|
<h2 class="postTitle"><a href="/photos/">Photos</a></h2>
|
||||||
|
<p class="postSubTitle">Some of my best photos.</p>
|
||||||
|
</div>
|
||||||
|
-->
|
||||||
|
<div class="contentItem">
|
||||||
|
<h2 class="postTitle"><a href="/about/">About</a></h2>
|
||||||
|
<p class="postSubTitle">A litte about me.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -1,11 +1,8 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import sys
|
import sys
|
||||||
from os.path import basename
|
|
||||||
from glob import glob
|
|
||||||
|
|
||||||
from flask import Flask, render_template, send_from_directory
|
from flask import Flask, render_template, request
|
||||||
from flask_flatpages import FlatPages
|
from flask_flatpages import FlatPages
|
||||||
from flask_frozen import Freezer
|
|
||||||
import arrow
|
import arrow
|
||||||
|
|
||||||
|
|
||||||
@ -18,59 +15,64 @@ FLATPAGES_MARKDOWN_EXTENSIONS = ['codehilite', 'extra']
|
|||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config.from_object(__name__)
|
app.config.from_object(__name__)
|
||||||
pages = FlatPages(app)
|
pages = FlatPages(app)
|
||||||
freezer = Freezer(app)
|
|
||||||
|
|
||||||
permalinks = {}
|
permalinks = {}
|
||||||
blogposts = []
|
blogposts = []
|
||||||
tags = set()
|
tags = set()
|
||||||
|
# Find all pages
|
||||||
for page in pages:
|
for page in pages:
|
||||||
parts = page.path.split('-')
|
|
||||||
if page.meta.get('permalink', None):
|
if page.meta.get('permalink', None):
|
||||||
|
# Special page
|
||||||
page.meta['url'] = page.meta['permalink']
|
page.meta['url'] = page.meta['permalink']
|
||||||
else:
|
else:
|
||||||
|
# Blog post
|
||||||
|
blogposts.append(page)
|
||||||
|
tags.update(page.meta.get('tags', []))
|
||||||
|
# Setup permalink
|
||||||
|
parts = page.path.split('-')
|
||||||
page.meta['url'] = '/blog/{}/{}/{}/'.format(parts[0], parts[1], '-'.join(parts[3:]))
|
page.meta['url'] = '/blog/{}/{}/{}/'.format(parts[0], parts[1], '-'.join(parts[3:]))
|
||||||
|
|
||||||
|
# Find and format post publication date
|
||||||
date = arrow.get('-'.join(parts[0:3]))
|
date = arrow.get('-'.join(parts[0:3]))
|
||||||
page.meta['date'] = date
|
page.meta['date'] = date
|
||||||
page.meta['datestr'] = date.format('D MMM YYYY')
|
page.meta['datestr'] = date.format('D MMM YYYY')
|
||||||
blogposts.append(page)
|
|
||||||
tags.update(page.meta.get('tags', []))
|
|
||||||
permalinks[page.meta['url']] = page
|
permalinks[page.meta['url']] = page
|
||||||
blogposts = sorted(blogposts, key=lambda p: p.meta['date'], reverse=True)
|
blogposts = sorted(blogposts, key=lambda p: p.meta['date'], reverse=True)
|
||||||
|
|
||||||
# Static files
|
|
||||||
@app.route("/src/<path:path>")
|
|
||||||
def scripts(path):
|
|
||||||
return send_from_directory('src', path)
|
|
||||||
@app.route("/media/<path:path>")
|
|
||||||
def media(path):
|
|
||||||
return send_from_directory('media', path)
|
|
||||||
@app.route("/favicon.ico")
|
|
||||||
def favicon():
|
|
||||||
return send_from_directory('src', 'favicon.ico')
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
|
||||||
return "Hello World!"
|
|
||||||
|
|
||||||
@app.route("/<path:path>")
|
@app.route("/<path:path>")
|
||||||
def permalink(path):
|
def permalink(path=''):
|
||||||
page = permalinks['/'+path]
|
page = permalinks['/'+path]
|
||||||
if path.startswith('blog/'):
|
template = 'blog_post.html' if page in blogposts else 'page.html'
|
||||||
return render_template('post.html', page=page)
|
return render_template(template, page=page)
|
||||||
return render_template('page.html', page=page)
|
|
||||||
|
|
||||||
@app.route("/blog/")
|
@app.route("/blog/")
|
||||||
def blog_default():
|
|
||||||
return render_template('blog.html', posts=blogposts, tags=tags)
|
|
||||||
|
|
||||||
@app.route("/blog/<string:tag>/")
|
@app.route("/blog/<string:tag>/")
|
||||||
def tag(tag):
|
def blog_listing(tag=None):
|
||||||
posts = [post for post in blogposts if tag in post.meta.get('tags', [])]
|
posts = blogposts
|
||||||
return render_template('blog.html', posts=posts, title=tag, tags=tags)
|
if tag:
|
||||||
|
posts = [post for post in posts if tag in post.meta.get('tags', [])]
|
||||||
|
return render_template('blog_listing.html', posts=posts, tags=tags, title=tag)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) > 1 and sys.argv[1] == "build":
|
if len(sys.argv) > 1 and sys.argv[1] == "build":
|
||||||
|
from flask_frozen import Freezer
|
||||||
|
from glob import iglob
|
||||||
|
from shutil import move, rmtree
|
||||||
|
freezer = Freezer(app)
|
||||||
freezer.freeze()
|
freezer.freeze()
|
||||||
|
for f in iglob('build/static/*'):
|
||||||
|
move(f, 'build/'+f[len('build/static/'):])
|
||||||
|
rmtree('build/static/')
|
||||||
else:
|
else:
|
||||||
|
@app.route("/media/<path:path>")
|
||||||
|
@app.route("/src/<path:path>")
|
||||||
|
@app.route("/favicon.ico")
|
||||||
|
def static_file(path):
|
||||||
|
return app.send_static_file(request.path[1:])
|
||||||
app.run()
|
app.run()
|
||||||
|
1498
src/cufon-yui.js
@ -1,34 +0,0 @@
|
|||||||
* desert scheme ported from vim to google prettify */
|
|
||||||
pre { display: block; background-color: #333 }
|
|
||||||
pre .nocode { background-color: none; color: #000 }
|
|
||||||
pre .str { color: #ffa0a0 } /* string - pink */
|
|
||||||
pre .kwd { color: #f0e68c; font-weight: bold }
|
|
||||||
pre .com { color: #87ceeb } /* comment - skyblue */
|
|
||||||
pre .typ { color: #98fb98 } /* type - lightgreen */
|
|
||||||
pre .lit { color: #cd5c5c } /* literal - darkred */
|
|
||||||
pre .pun { color: #fff } /* punctuation */
|
|
||||||
pre .pln { color: #fff } /* plaintext */
|
|
||||||
pre .tag { color: #f0e68c; font-weight: bold } /* html/xml tag - lightyellow */
|
|
||||||
pre .atn { color: #bdb76b; font-weight: bold } /* attribute name - khaki */
|
|
||||||
pre .atv { color: #ffa0a0 } /* attribute value - pink */
|
|
||||||
pre .dec { color: #98fb98 } /* decimal - lightgreen */
|
|
||||||
|
|
||||||
/* Specify class=linenums on a pre to get line numbering */
|
|
||||||
ol.linenums { margin-top: 0; margin-bottom: 0; color: #AEAEAE } /* IE indents via margin-left */
|
|
||||||
li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8 { list-style-type: none }
|
|
||||||
/* Alternate shading for lines */
|
|
||||||
li.L1,li.L3,li.L5,li.L7,li.L9 { }
|
|
||||||
|
|
||||||
@media print {
|
|
||||||
pre { background-color: none }
|
|
||||||
pre .str, code .str { color: #060 }
|
|
||||||
pre .kwd, code .kwd { color: #006; font-weight: bold }
|
|
||||||
pre .com, code .com { color: #600; font-style: italic }
|
|
||||||
pre .typ, code .typ { color: #404; font-weight: bold }
|
|
||||||
pre .lit, code .lit { color: #044 }
|
|
||||||
pre .pun, code .pun { color: #440 }
|
|
||||||
pre .pln, code .pln { color: #000 }
|
|
||||||
pre .tag, code .tag { color: #006; font-weight: bold }
|
|
||||||
pre .atn, code .atn { color: #404 }
|
|
||||||
pre .atv, code .atv { color: #060 }
|
|
||||||
}
|
|
Before Width: | Height: | Size: 85 KiB |
@ -1,7 +0,0 @@
|
|||||||
(function($){$.fn.easyTabs=function(option){var param=jQuery.extend({fadeSpeed:"fast",defaultContent:1,activeClass:'active'},option);$(this).each(function(){var thisId="#"+this.id;if(param.defaultContent==''){param.defaultContent=1;}
|
|
||||||
if(typeof param.defaultContent=="number")
|
|
||||||
{var defaultTab=$(thisId+" .tabs li:eq("+(param.defaultContent-1)+") a").attr('href').substr(1);}else{var defaultTab=param.defaultContent;}
|
|
||||||
$(thisId+" .tabs li a").each(function(){var tabToHide=$(this).attr('href').substr(1);$("#"+tabToHide).addClass('easytabs-tab-content');});hideAll();changeContent(defaultTab);function hideAll(){$(thisId+" .easytabs-tab-content").hide();}
|
|
||||||
function changeContent(tabId){hideAll();$(thisId+" .tabs li").removeClass(param.activeClass);$(thisId+" .tabs li a[href=#"+tabId+"]").closest('li').addClass(param.activeClass);if(param.fadeSpeed!="none")
|
|
||||||
{$(thisId+" #"+tabId).fadeIn(param.fadeSpeed);}else{$(thisId+" #"+tabId).show();}}
|
|
||||||
$(thisId+" .tabs li").click(function(){var tabId=$(this).find('a').attr('href').substr(1);changeContent(tabId);return false;});});}})(jQuery);
|
|
@ -1,129 +0,0 @@
|
|||||||
/*Notes about grid:
|
|
||||||
Columns: 12
|
|
||||||
Grid Width: 825px
|
|
||||||
Column Width: 55px
|
|
||||||
Gutter Width: 15px
|
|
||||||
-------------------------------*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.section {margin-bottom: 18px;
|
|
||||||
}
|
|
||||||
.section:after {content: ".";display: block;height: 0;clear: both;visibility: hidden;}
|
|
||||||
.section {*zoom: 1;}
|
|
||||||
|
|
||||||
.section .firstcolumn,
|
|
||||||
.section .firstcol {margin-left: 0;}
|
|
||||||
|
|
||||||
|
|
||||||
/* Border on left hand side of a column. */
|
|
||||||
.border {
|
|
||||||
padding-left: 7px;
|
|
||||||
margin-left: 7px;
|
|
||||||
border-left: 1px solid #eee;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Border with more whitespace, spans one column. */
|
|
||||||
.colborder {
|
|
||||||
padding-left: 42px;
|
|
||||||
margin-left: 42px;
|
|
||||||
border-left: 1px solid #eee;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* The Grid Classes */
|
|
||||||
.grid1, .grid1_2cols, .grid1_3cols, .grid1_4cols, .grid2, .grid2_3cols, .grid2_4cols, .grid3, .grid3_2cols, .grid3_4cols, .grid4, .grid4_3cols, .grid5, .grid5_2cols, .grid5_3cols, .grid5_4cols, .grid6, .grid6_4cols, .grid7, .grid7_2cols, .grid7_3cols, .grid7_4cols, .grid8, .grid8_3cols, .grid9, .grid9_2cols, .grid9_4cols, .grid10, .grid10_3cols, .grid10_4cols, .grid11, .grid11_2cols, .grid11_3cols, .grid11_4cols, .grid12
|
|
||||||
{margin-left: 15px;float: left;display: inline; overflow: hidden;}
|
|
||||||
|
|
||||||
|
|
||||||
.width1, .grid1, .span-1 {width: 55px;}
|
|
||||||
.width1_2cols,.grid1_2cols {width: 20px;}
|
|
||||||
.width1_3cols,.grid1_3cols {width: 8px;}
|
|
||||||
.width1_4cols,.grid1_4cols {width: 2px;}
|
|
||||||
.input_width1 {width: 49px;}
|
|
||||||
|
|
||||||
.width2, .grid2, .span-2 {width: 125px;}
|
|
||||||
.width2_3cols,.grid2_3cols {width: 31px;}
|
|
||||||
.width2_4cols,.grid2_4cols {width: 20px;}
|
|
||||||
.input_width2 {width: 119px;}
|
|
||||||
|
|
||||||
.width3, .grid3, .span-3 {width: 195px;}
|
|
||||||
.width3_2cols,.grid3_2cols {width: 90px;}
|
|
||||||
.width3_4cols,.grid3_4cols {width: 37px;}
|
|
||||||
.input_width3 {width: 189px;}
|
|
||||||
|
|
||||||
.width4, .grid4, .span-4 {width: 265px;}
|
|
||||||
.width4_3cols,.grid4_3cols {width: 78px;}
|
|
||||||
.input_width4 {width: 259px;}
|
|
||||||
|
|
||||||
.width5, .grid5, .span-5 {width: 335px;}
|
|
||||||
.width5_2cols,.grid5_2cols {width: 160px;}
|
|
||||||
.width5_3cols,.grid5_3cols {width: 101px;}
|
|
||||||
.width5_4cols,.grid5_4cols {width: 72px;}
|
|
||||||
.input_width5 {width: 329px;}
|
|
||||||
|
|
||||||
.width6, .grid6, .span-6 {width: 405px;}
|
|
||||||
.width6_4cols,.grid6_4cols {width: 90px;}
|
|
||||||
.input_width6 {width: 399px;}
|
|
||||||
|
|
||||||
.width7, .grid7, .span-7 {width: 475px;}
|
|
||||||
.width7_2cols,.grid7_2cols {width: 230px;}
|
|
||||||
.width7_3cols,.grid7_3cols {width: 148px;}
|
|
||||||
.width7_4cols,.grid7_4cols {width: 107px;}
|
|
||||||
.input_width7 {width: 469px;}
|
|
||||||
|
|
||||||
.width8, .grid8, .span-8 {width: 545px;}
|
|
||||||
.width8_3cols,.grid8_3cols {width: 171px;}
|
|
||||||
.input_width8 {width: 539px;}
|
|
||||||
|
|
||||||
.width9, .grid9, .span-9 {width: 615px;}
|
|
||||||
.width9_2cols,.grid9_2cols {width: 300px;}
|
|
||||||
.width9_4cols,.grid9_4cols {width: 142px;}
|
|
||||||
.input_width9 {width: 609px;}
|
|
||||||
|
|
||||||
.width10, .grid10, .span-10 {width: 685px;}
|
|
||||||
.width10_3cols,.grid10_3cols {width: 218px;}
|
|
||||||
.width10_4cols,.grid10_4cols {width: 160px;}
|
|
||||||
.input_width10 {width: 679px;}
|
|
||||||
|
|
||||||
.width11, .grid11, .span-11 {width: 755px;}
|
|
||||||
.width11_2cols,.grid11_2cols {width: 370px;}
|
|
||||||
.width11_3cols,.grid11_3cols {width: 241px;}
|
|
||||||
.width11_4cols,.grid11_4cols {width: 177px;}
|
|
||||||
.input_width11 {width: 749px;}
|
|
||||||
|
|
||||||
.width12, .grid12, .span-12 {width: 825px;}
|
|
||||||
.input_width12 {width: 819px;}
|
|
||||||
|
|
||||||
/* Subdivided grid spaces */
|
|
||||||
.emptycols_left1, .prepend-1 {padding-left: 70px;}
|
|
||||||
.emptycols_right1, .append-1 {padding-right: 70px;}
|
|
||||||
.emptycols_left2, .prepend-2 {padding-left: 140px;}
|
|
||||||
.emptycols_right2, .append-2 {padding-right: 140px;}
|
|
||||||
.emptycols_left3, .prepend-3 {padding-left: 210px;}
|
|
||||||
.emptycols_right3, .append-3 {padding-right: 210px;}
|
|
||||||
.emptycols_left4, .prepend-4 {padding-left: 280px;}
|
|
||||||
.emptycols_right4, .append-4 {padding-right: 280px;}
|
|
||||||
.emptycols_left5, .prepend-5 {padding-left: 350px;}
|
|
||||||
.emptycols_right5, .append-5 {padding-right: 350px;}
|
|
||||||
.emptycols_left6, .prepend-6 {padding-left: 420px;}
|
|
||||||
.emptycols_right6, .append-6 {padding-right: 420px;}
|
|
||||||
.emptycols_left7, .prepend-7 {padding-left: 490px;}
|
|
||||||
.emptycols_right7, .append-7 {padding-right: 490px;}
|
|
||||||
.emptycols_left8, .prepend-8 {padding-left: 560px;}
|
|
||||||
.emptycols_right8, .append-8 {padding-right: 560px;}
|
|
||||||
.emptycols_left9, .prepend-9 {padding-left: 630px;}
|
|
||||||
.emptycols_right9, .append-9 {padding-right: 630px;}
|
|
||||||
.emptycols_left10, .prepend-10 {padding-left: 700px;}
|
|
||||||
.emptycols_right10, .append-10 {padding-right: 700px;}
|
|
||||||
.emptycols_left11, .prepend-11 {padding-left: 770px;}
|
|
||||||
.emptycols_right11, .append-11 {padding-right: 770px;}
|
|
||||||
.pull-1 {margin-left: -70px;}
|
|
||||||
.push-1 {margin-right: -70px;margin-left: 18px;float: right;}
|
|
||||||
.pull-2 {margin-left: -140px;}
|
|
||||||
.push-2 {margin-right: -140px;margin-left: 18px;float: right;}
|
|
||||||
.pull-3 {margin-left: -210px;}
|
|
||||||
.push-3 {margin-right: -210px;margin-left: 18px;float: right;}
|
|
||||||
.pull-4 {margin-left: -280px;}
|
|
||||||
.push-4 {margin-right: -280px;margin-left: 18px;float: right;}
|
|
@ -1,396 +0,0 @@
|
|||||||
@import url('grid_12-825-55-15.css');
|
|
||||||
|
|
||||||
/*
|
|
||||||
CSS Reset by Eric Meyer - Released under Public Domain
|
|
||||||
http://meyerweb.com/eric/tools/css/reset/
|
|
||||||
*/
|
|
||||||
html, body, div, span, applet, object, iframe,
|
|
||||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
|
||||||
a, abbr, acronym, address, big, cite, code,
|
|
||||||
del, dfn, em, font, img, ins, kbd, q, s, samp,
|
|
||||||
small, strike, strong, sub, sup, tt, var,
|
|
||||||
b, u, i, center, dl, dt, dd, ol, ul, li,
|
|
||||||
fieldset, form, label, legend, table,
|
|
||||||
caption, tbody, tfoot, thead, tr, th, td
|
|
||||||
{margin: 0;padding: 0;border: 0;outline: 0;
|
|
||||||
font-size: 100%;vertical-align: baseline;
|
|
||||||
background: transparent;}
|
|
||||||
body {line-height: 1;}
|
|
||||||
ol, ul {list-style: none;}
|
|
||||||
blockquote, q {quotes: none;}
|
|
||||||
blockquote:before, blockquote:after,
|
|
||||||
q:before, q:after {content: ''; content: none;}
|
|
||||||
:focus {outline: 0;}
|
|
||||||
ins {text-decoration: none;}
|
|
||||||
del {text-decoration: line-through;}
|
|
||||||
table {border-collapse: collapse;border-spacing: 0;}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
body {
|
|
||||||
color: #000;
|
|
||||||
background-color: #dcdcdc;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
text-decoration: none;
|
|
||||||
color: #1883ba;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1{
|
|
||||||
font-size: 32px;
|
|
||||||
font-weight: normal;
|
|
||||||
font-style: normal;
|
|
||||||
margin-bottom: 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2{
|
|
||||||
font-size: 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#container {
|
|
||||||
width: 865px;
|
|
||||||
margin: 0px auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#header {
|
|
||||||
padding: 20px;
|
|
||||||
font-size: 36px;
|
|
||||||
background-color: #000;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
#header span {
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
#main_content {
|
|
||||||
background-color: #fff;
|
|
||||||
padding: 60px 20px 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#footer p {
|
|
||||||
margin: 0;
|
|
||||||
padding-top: 10px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
color: #333;
|
|
||||||
font: 10px Arial, sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tabs {
|
|
||||||
width: 100%;
|
|
||||||
height: 31px;
|
|
||||||
background-color: #444;
|
|
||||||
}
|
|
||||||
.tabs li {
|
|
||||||
float: left;
|
|
||||||
margin: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
background-color: #444;
|
|
||||||
}
|
|
||||||
.tabs li a {
|
|
||||||
display: block;
|
|
||||||
color: #fff;
|
|
||||||
text-decoration: none;
|
|
||||||
font: bold 11px/11px 'Arial';
|
|
||||||
text-transform: uppercase;
|
|
||||||
padding: 10px 15px;
|
|
||||||
border-right: 1px solid #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tabs li a:hover {
|
|
||||||
background-color: #00b3ff;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.tabs li.active a {
|
|
||||||
color: #000;
|
|
||||||
background-color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
div.huge {
|
|
||||||
|
|
||||||
font-size: 300px;
|
|
||||||
line-height: 1em;
|
|
||||||
padding: 0;
|
|
||||||
letter-spacing: -.02em;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
div.glyph_range {
|
|
||||||
font-size: 72px;
|
|
||||||
line-height: 1.1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.size10{ font-size: 10px; }
|
|
||||||
.size11{ font-size: 11px; }
|
|
||||||
.size12{ font-size: 12px; }
|
|
||||||
.size13{ font-size: 13px; }
|
|
||||||
.size14{ font-size: 14px; }
|
|
||||||
.size16{ font-size: 16px; }
|
|
||||||
.size18{ font-size: 18px; }
|
|
||||||
.size20{ font-size: 20px; }
|
|
||||||
.size24{ font-size: 24px; }
|
|
||||||
.size30{ font-size: 30px; }
|
|
||||||
.size36{ font-size: 36px; }
|
|
||||||
.size48{ font-size: 48px; }
|
|
||||||
.size60{ font-size: 60px; }
|
|
||||||
.size72{ font-size: 72px; }
|
|
||||||
.size90{ font-size: 90px; }
|
|
||||||
|
|
||||||
|
|
||||||
.psample_row1 { height: 120px;}
|
|
||||||
.psample_row1 { height: 120px;}
|
|
||||||
.psample_row2 { height: 160px;}
|
|
||||||
.psample_row3 { height: 160px;}
|
|
||||||
.psample_row4 { height: 160px;}
|
|
||||||
|
|
||||||
.psample {
|
|
||||||
overflow: hidden;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.psample p {
|
|
||||||
line-height: 1.3em;
|
|
||||||
display: block;
|
|
||||||
overflow: hidden;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.psample span {
|
|
||||||
margin-right: .5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.white_blend {
|
|
||||||
width: 100%;
|
|
||||||
height: 61px;
|
|
||||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVkAAAA9CAYAAAAH4BojAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAO1JREFUeNrs3TsKgFAMRUE/eer+NxztxMYuEWQG3ECKwwUF58ycAKixOAGAyAKILAAiCyCyACILgMgCiCyAyAIgsgAiCyCyAIgsgMgCiCwAIgsgsgAiC4DIAogsACIL0CWuZ3UGgLrIhjMA1EV2OAOAJQtgyQLwjOzmDAAiCyCyAIgsQFtkd2cAEFkAkQVAZAHaIns4A4AlC2DJAiCyACILILIAiCzAV5H1dQGAJQsgsgCILIDIAvwisl58AViyAJYsACILILIAIgvAe2T9EhxAZAFEFgCRBeiL7HAGgLrIhjMAWLIAliwAt1OAAQDwygTBulLIlQAAAABJRU5ErkJggg==);
|
|
||||||
position: absolute;
|
|
||||||
bottom: 0;
|
|
||||||
}
|
|
||||||
.black_blend {
|
|
||||||
width: 100%;
|
|
||||||
height: 61px;
|
|
||||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVkAAAA9CAYAAAAH4BojAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAPJJREFUeNrs3TEKhTAQRVGjibr/9QoxhY2N3Ywo50A28IrLwP9g6b1PAMSYTQAgsgAiC4DIAogsgMgCILIAIgsgsgCILIDIAogsACILILIAIguAyAKILIDIAiCyACILgMgCZCnjLWYAiFGvB0BQZJsZAFyyAC5ZAO6RXc0AILIAIguAyAKkRXYzA4DIAogsACILkBbZ3QwALlkAlywAIgsgsgAiC4DIArwVWf8uAHDJAogsACILILIAv4isH74AXLIALlkARBZAZAFEFoDnyPokOIDIAogsACILkBfZZgaAuMhWMwC4ZAE+p4x3mAEgxinAAJ+XBbPWGkwAAAAAAElFTkSuQmCC);
|
|
||||||
position: absolute;
|
|
||||||
bottom: 0;
|
|
||||||
}
|
|
||||||
.fullreverse {
|
|
||||||
background: #000 !important;
|
|
||||||
color: #fff !important;
|
|
||||||
margin-left: -20px;
|
|
||||||
padding-left: 20px;
|
|
||||||
margin-right: -20px;
|
|
||||||
padding-right: 20px;
|
|
||||||
padding: 20px;
|
|
||||||
margin-bottom:0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.sample_table td {
|
|
||||||
padding-top: 3px;
|
|
||||||
padding-bottom:5px;
|
|
||||||
padding-left: 5px;
|
|
||||||
vertical-align: middle;
|
|
||||||
line-height: 1.2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sample_table td:first-child {
|
|
||||||
background-color: #eee;
|
|
||||||
text-align: right;
|
|
||||||
padding-right: 5px;
|
|
||||||
padding-left: 0;
|
|
||||||
padding: 5px;
|
|
||||||
font: 11px/12px "Courier New", Courier, mono;
|
|
||||||
}
|
|
||||||
|
|
||||||
code {
|
|
||||||
white-space: pre;
|
|
||||||
background-color: #eee;
|
|
||||||
display: block;
|
|
||||||
padding: 10px;
|
|
||||||
margin-bottom: 18px;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.bottom,.last {margin-bottom:0 !important; padding-bottom:0 !important;}
|
|
||||||
|
|
||||||
.box {
|
|
||||||
padding: 18px;
|
|
||||||
margin-bottom: 18px;
|
|
||||||
background: #eee;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reverse,.reversed { background: #000 !important;color: #fff !important; border: none !important;}
|
|
||||||
|
|
||||||
#bodycomparison {
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
font-size: 72px;
|
|
||||||
height: 90px;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
#bodycomparison div{
|
|
||||||
font-size: 72px;
|
|
||||||
line-height: 90px;
|
|
||||||
display: inline;
|
|
||||||
margin: 0 15px 0 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#bodycomparison div span{
|
|
||||||
font: 10px Arial;
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
}
|
|
||||||
#xheight {
|
|
||||||
float: none;
|
|
||||||
position: absolute;
|
|
||||||
color: #d9f3ff;
|
|
||||||
font-size: 72px;
|
|
||||||
line-height: 90px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fontbody {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.arialbody{
|
|
||||||
font-family: Arial;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.verdanabody{
|
|
||||||
font-family: Verdana;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.georgiabody{
|
|
||||||
font-family: Georgia;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* @group Layout page
|
|
||||||
*/
|
|
||||||
|
|
||||||
#layout h1 {
|
|
||||||
font-size: 36px;
|
|
||||||
line-height: 42px;
|
|
||||||
font-weight: normal;
|
|
||||||
font-style: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
#layout h2 {
|
|
||||||
font-size: 24px;
|
|
||||||
line-height: 23px;
|
|
||||||
font-weight: normal;
|
|
||||||
font-style: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
#layout h3 {
|
|
||||||
font-size: 22px;
|
|
||||||
line-height: 1.4em;
|
|
||||||
margin-top: 1em;
|
|
||||||
font-weight: normal;
|
|
||||||
font-style: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#layout p.byline {
|
|
||||||
font-size: 12px;
|
|
||||||
margin-top: 18px;
|
|
||||||
line-height: 12px;
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
#layout p {
|
|
||||||
font-size: 14px;
|
|
||||||
line-height: 21px;
|
|
||||||
margin-bottom: .5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#layout p.large{
|
|
||||||
font-size: 18px;
|
|
||||||
line-height: 26px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#layout .sidebar p{
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 1.4em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#layout p.caption {
|
|
||||||
font-size: 10px;
|
|
||||||
margin-top: -16px;
|
|
||||||
margin-bottom: 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* @end */
|
|
||||||
|
|
||||||
/* @group Glyphs */
|
|
||||||
|
|
||||||
#glyph_chart div{
|
|
||||||
background-color: #d9f3ff;
|
|
||||||
color: black;
|
|
||||||
float: left;
|
|
||||||
font-size: 36px;
|
|
||||||
height: 1.2em;
|
|
||||||
line-height: 1.2em;
|
|
||||||
margin-bottom: 1px;
|
|
||||||
margin-right: 1px;
|
|
||||||
text-align: center;
|
|
||||||
width: 1.2em;
|
|
||||||
position: relative;
|
|
||||||
padding: .6em .2em .2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#glyph_chart div p {
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
display: block;
|
|
||||||
text-align: center;
|
|
||||||
font: bold 9px Arial, sans-serif;
|
|
||||||
background-color: #3a768f;
|
|
||||||
width: 100%;
|
|
||||||
color: #fff;
|
|
||||||
padding: 2px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#glyphs h1 {
|
|
||||||
font-family: Arial, sans-serif;
|
|
||||||
}
|
|
||||||
/* @end */
|
|
||||||
|
|
||||||
/* @group Installing */
|
|
||||||
|
|
||||||
#installing {
|
|
||||||
font: 13px Arial, sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
#installing p,
|
|
||||||
#glyphs p{
|
|
||||||
line-height: 1.2em;
|
|
||||||
margin-bottom: 18px;
|
|
||||||
font: 13px Arial, sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#installing h3{
|
|
||||||
font-size: 15px;
|
|
||||||
margin-top: 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* @end */
|
|
||||||
|
|
||||||
#rendering h1 {
|
|
||||||
font-family: Arial, sans-serif;
|
|
||||||
}
|
|
||||||
.render_table td {
|
|
||||||
font: 11px "Courier New", Courier, mono;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
|||||||
// Copyright (C) 2009 Onno Hommes.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @fileoverview
|
|
||||||
* Registers a language handler for the AGC/AEA Assembly Language as described
|
|
||||||
* at http://virtualagc.googlecode.com
|
|
||||||
* <p>
|
|
||||||
* This file could be used by goodle code to allow syntax highlight for
|
|
||||||
* Virtual AGC SVN repository or if you don't want to commonize
|
|
||||||
* the header for the agc/aea html assembly listing.
|
|
||||||
*
|
|
||||||
* @author ohommes@alumni.cmu.edu
|
|
||||||
*/
|
|
||||||
|
|
||||||
PR.registerLangHandler(
|
|
||||||
PR.createSimpleLexer(
|
|
||||||
[
|
|
||||||
// A line comment that starts with ;
|
|
||||||
[PR.PR_COMMENT, /^#[^\r\n]*/, null, '#'],
|
|
||||||
// Whitespace
|
|
||||||
[PR.PR_PLAIN, /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
|
|
||||||
// A double quoted, possibly multi-line, string.
|
|
||||||
[PR.PR_STRING, /^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/, null, '"']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
[PR.PR_KEYWORD, /^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\s/,null],
|
|
||||||
[PR.PR_TYPE, /^(?:-?GENADR|=MINUS|2BCADR|VN|BOF|MM|-?2CADR|-?[1-6]DNADR|ADRES|BBCON|[SE]?BANK\=?|BLOCK|BNKSUM|E?CADR|COUNT\*?|2?DEC\*?|-?DNCHAN|-?DNPTR|EQUALS|ERASE|MEMORY|2?OCT|REMADR|SETLOC|SUBRO|ORG|BSS|BES|SYN|EQU|DEFINE|END)\s/,null],
|
|
||||||
// A single quote possibly followed by a word that optionally ends with
|
|
||||||
// = ! or ?.
|
|
||||||
[PR.PR_LITERAL,
|
|
||||||
/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],
|
|
||||||
// Any word including labels that optionally ends with = ! or ?.
|
|
||||||
[PR.PR_PLAIN,
|
|
||||||
/^-*(?:[!-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],
|
|
||||||
// A printable non-space non-special character
|
|
||||||
[PR.PR_PUNCTUATION, /^[^\w\t\n\r \xA0()\"\\\';]+/]
|
|
||||||
]),
|
|
||||||
['apollo', 'agc', 'aea']);
|
|
@ -1,20 +0,0 @@
|
|||||||
|
|
||||||
PR.registerLangHandler(
|
|
||||||
PR.createSimpleLexer(
|
|
||||||
[
|
|
||||||
// A line comment that starts with ;
|
|
||||||
[PR.PR_COMMENT, /^;[^\r\n]*/, null, ';'],
|
|
||||||
// Whitespace
|
|
||||||
[PR.PR_PLAIN, /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
[PR.PR_KEYWORD, /^\[[\w\s]+\]/],
|
|
||||||
[PR.PR_KEYWORD, /^\%\w+/],
|
|
||||||
[PR.PR_KEYWORD,
|
|
||||||
/[0-9]+(,5)?hp/],
|
|
||||||
[PR.PR_TYPE,
|
|
||||||
/^[A-Z]{3,4}[0-9]{2,3}/],
|
|
||||||
[PR.PR_LITERAL, /^0x[0-9A-F]*/]
|
|
||||||
|
|
||||||
]),
|
|
||||||
['betyg']);
|
|
@ -1,78 +0,0 @@
|
|||||||
// Copyright (C) 2009 Google Inc.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @fileoverview
|
|
||||||
* Registers a language handler for CSS.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* To use, include prettify.js and this file in your HTML page.
|
|
||||||
* Then put your code in an HTML tag like
|
|
||||||
* <pre class="prettyprint lang-css"></pre>
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* http://www.w3.org/TR/CSS21/grammar.html Section G2 defines the lexical
|
|
||||||
* grammar. This scheme does not recognize keywords containing escapes.
|
|
||||||
*
|
|
||||||
* @author mikesamuel@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
PR.registerLangHandler(
|
|
||||||
PR.createSimpleLexer(
|
|
||||||
[
|
|
||||||
// The space production <s>
|
|
||||||
[PR.PR_PLAIN, /^[ \t\r\n\f]+/, null, ' \t\r\n\f']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
// Quoted strings. <string1> and <string2>
|
|
||||||
[PR.PR_STRING,
|
|
||||||
/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/, null],
|
|
||||||
[PR.PR_STRING,
|
|
||||||
/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/, null],
|
|
||||||
['lang-css-str', /^url\(([^\)\"\']*)\)/i],
|
|
||||||
[PR.PR_KEYWORD,
|
|
||||||
/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,
|
|
||||||
null],
|
|
||||||
// A property name -- an identifier followed by a colon.
|
|
||||||
['lang-css-kw', /^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],
|
|
||||||
// A C style block comment. The <comment> production.
|
|
||||||
[PR.PR_COMMENT, /^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],
|
|
||||||
// Escaping text spans
|
|
||||||
[PR.PR_COMMENT, /^(?:<!--|-->)/],
|
|
||||||
// A number possibly containing a suffix.
|
|
||||||
[PR.PR_LITERAL, /^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],
|
|
||||||
// A hex color
|
|
||||||
[PR.PR_LITERAL, /^#(?:[0-9a-f]{3}){1,2}/i],
|
|
||||||
// An identifier
|
|
||||||
[PR.PR_PLAIN,
|
|
||||||
/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],
|
|
||||||
// A run of punctuation
|
|
||||||
[PR.PR_PUNCTUATION, /^[^\s\w\'\"]+/]
|
|
||||||
]),
|
|
||||||
['css']);
|
|
||||||
PR.registerLangHandler(
|
|
||||||
PR.createSimpleLexer([],
|
|
||||||
[
|
|
||||||
[PR.PR_KEYWORD,
|
|
||||||
/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]
|
|
||||||
]),
|
|
||||||
['css-kw']);
|
|
||||||
PR.registerLangHandler(
|
|
||||||
PR.createSimpleLexer([],
|
|
||||||
[
|
|
||||||
[PR.PR_STRING, /^[^\)\"\']+/]
|
|
||||||
]),
|
|
||||||
['css-str']);
|
|
101
src/lang-hs.js
@ -1,101 +0,0 @@
|
|||||||
// Copyright (C) 2009 Google Inc.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @fileoverview
|
|
||||||
* Registers a language handler for Haskell.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* To use, include prettify.js and this file in your HTML page.
|
|
||||||
* Then put your code in an HTML tag like
|
|
||||||
* <pre class="prettyprint lang-hs">(my lisp code)</pre>
|
|
||||||
* The lang-cl class identifies the language as common lisp.
|
|
||||||
* This file supports the following language extensions:
|
|
||||||
* lang-cl - Common Lisp
|
|
||||||
* lang-el - Emacs Lisp
|
|
||||||
* lang-lisp - Lisp
|
|
||||||
* lang-scm - Scheme
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* I used http://www.informatik.uni-freiburg.de/~thiemann/haskell/haskell98-report-html/syntax-iso.html
|
|
||||||
* as the basis, but ignore the way the ncomment production nests since this
|
|
||||||
* makes the lexical grammar irregular. It might be possible to support
|
|
||||||
* ncomments using the lookbehind filter.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author mikesamuel@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
PR.registerLangHandler(
|
|
||||||
PR.createSimpleLexer(
|
|
||||||
[
|
|
||||||
// Whitespace
|
|
||||||
// whitechar -> newline | vertab | space | tab | uniWhite
|
|
||||||
// newline -> return linefeed | return | linefeed | formfeed
|
|
||||||
[PR.PR_PLAIN, /^[\t\n\x0B\x0C\r ]+/, null, '\t\n\x0B\x0C\r '],
|
|
||||||
// Single line double and single-quoted strings.
|
|
||||||
// char -> ' (graphic<' | \> | space | escape<\&>) '
|
|
||||||
// string -> " {graphic<" | \> | space | escape | gap}"
|
|
||||||
// escape -> \ ( charesc | ascii | decimal | o octal
|
|
||||||
// | x hexadecimal )
|
|
||||||
// charesc -> a | b | f | n | r | t | v | \ | " | ' | &
|
|
||||||
[PR.PR_STRING, /^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/,
|
|
||||||
null, '"'],
|
|
||||||
[PR.PR_STRING, /^\'(?:[^\'\\\n\x0C\r]|\\[^&])\'?/,
|
|
||||||
null, "'"],
|
|
||||||
// decimal -> digit{digit}
|
|
||||||
// octal -> octit{octit}
|
|
||||||
// hexadecimal -> hexit{hexit}
|
|
||||||
// integer -> decimal
|
|
||||||
// | 0o octal | 0O octal
|
|
||||||
// | 0x hexadecimal | 0X hexadecimal
|
|
||||||
// float -> decimal . decimal [exponent]
|
|
||||||
// | decimal exponent
|
|
||||||
// exponent -> (e | E) [+ | -] decimal
|
|
||||||
[PR.PR_LITERAL,
|
|
||||||
/^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i,
|
|
||||||
null, '0123456789']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
// Haskell does not have a regular lexical grammar due to the nested
|
|
||||||
// ncomment.
|
|
||||||
// comment -> dashes [ any<symbol> {any}] newline
|
|
||||||
// ncomment -> opencom ANYseq {ncomment ANYseq}closecom
|
|
||||||
// dashes -> '--' {'-'}
|
|
||||||
// opencom -> '{-'
|
|
||||||
// closecom -> '-}'
|
|
||||||
[PR.PR_COMMENT, /^(?:(?:--+(?:[^\r\n\x0C]*)?)|(?:\{-(?:[^-]|-+[^-\}])*-\}))/],
|
|
||||||
// reservedid -> case | class | data | default | deriving | do
|
|
||||||
// | else | if | import | in | infix | infixl | infixr
|
|
||||||
// | instance | let | module | newtype | of | then
|
|
||||||
// | type | where | _
|
|
||||||
[PR.PR_KEYWORD, /^(?:case|class|data|default|deriving|do|else|if|import|in|infix|infixl|infixr|instance|let|module|newtype|of|then|type|where|_)(?=[^a-zA-Z0-9\']|$)/, null],
|
|
||||||
// qvarid -> [ modid . ] varid
|
|
||||||
// qconid -> [ modid . ] conid
|
|
||||||
// varid -> (small {small | large | digit | ' })<reservedid>
|
|
||||||
// conid -> large {small | large | digit | ' }
|
|
||||||
// modid -> conid
|
|
||||||
// small -> ascSmall | uniSmall | _
|
|
||||||
// ascSmall -> a | b | ... | z
|
|
||||||
// uniSmall -> any Unicode lowercase letter
|
|
||||||
// large -> ascLarge | uniLarge
|
|
||||||
// ascLarge -> A | B | ... | Z
|
|
||||||
// uniLarge -> any uppercase or titlecase Unicode letter
|
|
||||||
[PR.PR_PLAIN, /^(?:[A-Z][\w\']*\.)*[a-zA-Z][\w\']*/],
|
|
||||||
// matches the symbol production
|
|
||||||
[PR.PR_PUNCTUATION, /^[^\t\n\x0B\x0C\r a-zA-Z0-9\'\"]+/]
|
|
||||||
]),
|
|
||||||
['hs']);
|
|
@ -1,93 +0,0 @@
|
|||||||
// Copyright (C) 2008 Google Inc.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @fileoverview
|
|
||||||
* Registers a language handler for Common Lisp and related languages.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* To use, include prettify.js and this file in your HTML page.
|
|
||||||
* Then put your code in an HTML tag like
|
|
||||||
* <pre class="prettyprint lang-lisp">(my lisp code)</pre>
|
|
||||||
* The lang-cl class identifies the language as common lisp.
|
|
||||||
* This file supports the following language extensions:
|
|
||||||
* lang-cl - Common Lisp
|
|
||||||
* lang-el - Emacs Lisp
|
|
||||||
* lang-lisp - Lisp
|
|
||||||
* lang-scm - Scheme
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* I used http://www.devincook.com/goldparser/doc/meta-language/grammar-LISP.htm
|
|
||||||
* as the basis, but added line comments that start with ; and changed the atom
|
|
||||||
* production to disallow unquoted semicolons.
|
|
||||||
*
|
|
||||||
* "Name" = 'LISP'
|
|
||||||
* "Author" = 'John McCarthy'
|
|
||||||
* "Version" = 'Minimal'
|
|
||||||
* "About" = 'LISP is an abstract language that organizes ALL'
|
|
||||||
* | 'data around "lists".'
|
|
||||||
*
|
|
||||||
* "Start Symbol" = [s-Expression]
|
|
||||||
*
|
|
||||||
* {Atom Char} = {Printable} - {Whitespace} - [()"\'']
|
|
||||||
*
|
|
||||||
* Atom = ( {Atom Char} | '\'{Printable} )+
|
|
||||||
*
|
|
||||||
* [s-Expression] ::= [Quote] Atom
|
|
||||||
* | [Quote] '(' [Series] ')'
|
|
||||||
* | [Quote] '(' [s-Expression] '.' [s-Expression] ')'
|
|
||||||
*
|
|
||||||
* [Series] ::= [s-Expression] [Series]
|
|
||||||
* |
|
|
||||||
*
|
|
||||||
* [Quote] ::= '' !Quote = do not evaluate
|
|
||||||
* |
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* I used <a href="http://gigamonkeys.com/book/">Practical Common Lisp</a> as
|
|
||||||
* the basis for the reserved word list.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author mikesamuel@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
PR.registerLangHandler(
|
|
||||||
PR.createSimpleLexer(
|
|
||||||
[
|
|
||||||
['opn', /^\(/, null, '('],
|
|
||||||
['clo', /^\)/, null, ')'],
|
|
||||||
// A line comment that starts with ;
|
|
||||||
[PR.PR_COMMENT, /^;[^\r\n]*/, null, ';'],
|
|
||||||
// Whitespace
|
|
||||||
[PR.PR_PLAIN, /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
|
|
||||||
// A double quoted, possibly multi-line, string.
|
|
||||||
[PR.PR_STRING, /^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/, null, '"']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
[PR.PR_KEYWORD, /^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/, null],
|
|
||||||
[PR.PR_LITERAL,
|
|
||||||
/^[+\-]?(?:0x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],
|
|
||||||
// A single quote possibly followed by a word that optionally ends with
|
|
||||||
// = ! or ?.
|
|
||||||
[PR.PR_LITERAL,
|
|
||||||
/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],
|
|
||||||
// A word that optionally ends with = ! or ?.
|
|
||||||
[PR.PR_PLAIN,
|
|
||||||
/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],
|
|
||||||
// A printable non-space non-special character
|
|
||||||
[PR.PR_PUNCTUATION, /^[^\w\t\n\r \xA0()\"\\\';]+/]
|
|
||||||
]),
|
|
||||||
['cl', 'el', 'lisp', 'scm']);
|
|
@ -1,59 +0,0 @@
|
|||||||
// Copyright (C) 2008 Google Inc.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @fileoverview
|
|
||||||
* Registers a language handler for Lua.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* To use, include prettify.js and this file in your HTML page.
|
|
||||||
* Then put your code in an HTML tag like
|
|
||||||
* <pre class="prettyprint lang-lua">(my Lua code)</pre>
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* I used http://www.lua.org/manual/5.1/manual.html#2.1
|
|
||||||
* Because of the long-bracket concept used in strings and comments, Lua does
|
|
||||||
* not have a regular lexical grammar, but luckily it fits within the space
|
|
||||||
* of irregular grammars supported by javascript regular expressions.
|
|
||||||
*
|
|
||||||
* @author mikesamuel@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
PR.registerLangHandler(
|
|
||||||
PR.createSimpleLexer(
|
|
||||||
[
|
|
||||||
// Whitespace
|
|
||||||
[PR.PR_PLAIN, /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
|
|
||||||
// A double or single quoted, possibly multi-line, string.
|
|
||||||
[PR.PR_STRING, /^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])*(?:\'|$))/, null, '"\'']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
// A comment is either a line comment that starts with two dashes, or
|
|
||||||
// two dashes preceding a long bracketed block.
|
|
||||||
[PR.PR_COMMENT, /^--(?:\[(=*)\[[\s\S]*?(?:\]\1\]|$)|[^\r\n]*)/],
|
|
||||||
// A long bracketed block not preceded by -- is a string.
|
|
||||||
[PR.PR_STRING, /^\[(=*)\[[\s\S]*?(?:\]\1\]|$)/],
|
|
||||||
[PR.PR_KEYWORD, /^(?:and|break|do|else|elseif|end|false|for|function|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/, null],
|
|
||||||
// A number is a hex integer literal, a decimal real literal, or in
|
|
||||||
// scientific notation.
|
|
||||||
[PR.PR_LITERAL,
|
|
||||||
/^[+-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i],
|
|
||||||
// An identifier
|
|
||||||
[PR.PR_PLAIN, /^[a-z_]\w*/i],
|
|
||||||
// A run of punctuation
|
|
||||||
[PR.PR_PUNCTUATION, /^[^\w\t\n\r \xA0][^\w\t\n\r \xA0\"\'\-\+=]*/]
|
|
||||||
]),
|
|
||||||
['lua']);
|
|
@ -1,56 +0,0 @@
|
|||||||
// Copyright (C) 2008 Google Inc.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @fileoverview
|
|
||||||
* Registers a language handler for OCaml, SML, F# and similar languages.
|
|
||||||
*
|
|
||||||
* Based on the lexical grammar at
|
|
||||||
* http://research.microsoft.com/fsharp/manual/spec2.aspx#_Toc202383715
|
|
||||||
*
|
|
||||||
* @author mikesamuel@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
PR.registerLangHandler(
|
|
||||||
PR.createSimpleLexer(
|
|
||||||
[
|
|
||||||
// Whitespace is made up of spaces, tabs and newline characters.
|
|
||||||
[PR.PR_PLAIN, /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
|
|
||||||
// #if ident/#else/#endif directives delimit conditional compilation
|
|
||||||
// sections
|
|
||||||
[PR.PR_COMMENT,
|
|
||||||
/^#(?:if[\t\n\r \xA0]+(?:[a-z_$][\w\']*|``[^\r\n\t`]*(?:``|$))|else|endif|light)/i,
|
|
||||||
null, '#'],
|
|
||||||
// A double or single quoted, possibly multi-line, string.
|
|
||||||
// F# allows escaped newlines in strings.
|
|
||||||
[PR.PR_STRING, /^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])*(?:\'|$))/, null, '"\'']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
// Block comments are delimited by (* and *) and may be
|
|
||||||
// nested. Single-line comments begin with // and extend to
|
|
||||||
// the end of a line.
|
|
||||||
// TODO: (*...*) comments can be nested. This does not handle that.
|
|
||||||
[PR.PR_COMMENT, /^(?:\/\/[^\r\n]*|\(\*[\s\S]*?\*\))/],
|
|
||||||
[PR.PR_KEYWORD, /^(?:abstract|and|as|assert|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|if|in|inherit|inline|interface|internal|lazy|let|match|member|module|mutable|namespace|new|null|of|open|or|override|private|public|rec|return|static|struct|then|to|true|try|type|upcast|use|val|void|when|while|with|yield|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|global|include|method|mixin|object|parallel|process|protected|pure|sealed|trait|virtual|volatile)\b/],
|
|
||||||
// A number is a hex integer literal, a decimal real literal, or in
|
|
||||||
// scientific notation.
|
|
||||||
[PR.PR_LITERAL,
|
|
||||||
/^[+\-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i],
|
|
||||||
[PR.PR_PLAIN, /^(?:[a-z_]\w*[!?#]?|``[^\r\n\t`]*(?:``|$))/i],
|
|
||||||
// A printable non-space non-special character
|
|
||||||
[PR.PR_PUNCTUATION, /^[^\t\n\r \xA0\"\'\w]+/]
|
|
||||||
]),
|
|
||||||
['fs', 'ml']);
|
|
@ -1,48 +0,0 @@
|
|||||||
// Copyright (C) 2009 Onno Hommes.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @fileoverview
|
|
||||||
* Registers a language handler for the AGC/AEA Assembly Language as described
|
|
||||||
* at http://virtualagc.googlecode.com
|
|
||||||
* <p>
|
|
||||||
* This file could be used by goodle code to allow syntax highlight for
|
|
||||||
* Virtual AGC SVN repository or if you don't want to commonize
|
|
||||||
* the header for the agc/aea html assembly listing.
|
|
||||||
*
|
|
||||||
* @author ohommes@alumni.cmu.edu
|
|
||||||
*/
|
|
||||||
|
|
||||||
PR.registerLangHandler(
|
|
||||||
PR.createSimpleLexer(
|
|
||||||
[
|
|
||||||
// A line comment that starts with ;
|
|
||||||
[PR.PR_COMMENT, /^;[^\r\n]*/, null, ';'],
|
|
||||||
// Whitespace
|
|
||||||
[PR.PR_PLAIN, /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
[PR.PR_KEYWORD, /^\[[\w\s]+\]/],
|
|
||||||
[PR.PR_KEYWORD, /^\%\w+/],
|
|
||||||
[PR.PR_KEYWORD,
|
|
||||||
/^\b(align|cli|sti|mov|equ|dd|dw|times|or|lgdt|xor|invlpg|add|pusha|push|call|jmp|popa|pop|int|ret)\b/],
|
|
||||||
[PR.PR_TYPE,
|
|
||||||
/^\b(eax|ax|ah|al|ebx|bx|bh|bl|ecx|cx|ch|cl|edx|dx|dh|dl|esi|edi|ebp|eip|esp|eflags|cs|ds|es|fs|gs|ss|cr0|cr1|cr2|cr3|cr4)\b/],
|
|
||||||
[PR.PR_DECLARATION, /^#.*/, null, '#'],
|
|
||||||
[PR.PR_LITERAL, /^0x[0-9A-F]*/],
|
|
||||||
[PR.PR_LITERAL, /^\d+/]
|
|
||||||
|
|
||||||
]),
|
|
||||||
['nasm', 'asm', 'as', 's']);
|
|
@ -1,35 +0,0 @@
|
|||||||
// Copyright (C) 2006 Google Inc.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @fileoverview
|
|
||||||
* Registers a language handler for Protocol Buffers as described at
|
|
||||||
* http://code.google.com/p/protobuf/.
|
|
||||||
*
|
|
||||||
* Based on the lexical grammar at
|
|
||||||
* http://research.microsoft.com/fsharp/manual/spec2.aspx#_Toc202383715
|
|
||||||
*
|
|
||||||
* @author mikesamuel@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
PR.registerLangHandler(PR.sourceDecorator({
|
|
||||||
keywords: (
|
|
||||||
'bool bytes default double enum extend extensions false fixed32 '
|
|
||||||
+ 'fixed64 float group import int32 int64 max message option '
|
|
||||||
+ 'optional package repeated required returns rpc service '
|
|
||||||
+ 'sfixed32 sfixed64 sint32 sint64 string syntax to true uint32 '
|
|
||||||
+ 'uint64'),
|
|
||||||
cStyleComments: true
|
|
||||||
}), ['proto']);
|
|
@ -1,54 +0,0 @@
|
|||||||
// Copyright (C) 2010 Google Inc.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @fileoverview
|
|
||||||
* Registers a language handler for Scala.
|
|
||||||
*
|
|
||||||
* Derived from http://lampsvn.epfl.ch/svn-repos/scala/scala-documentation/trunk/src/reference/SyntaxSummary.tex
|
|
||||||
*
|
|
||||||
* @author mikesamuel@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
PR.registerLangHandler(
|
|
||||||
PR.createSimpleLexer(
|
|
||||||
[
|
|
||||||
// Whitespace
|
|
||||||
[PR.PR_PLAIN, /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
|
|
||||||
// A double or single quoted string
|
|
||||||
// or a triple double-quoted multi-line string.
|
|
||||||
[PR.PR_STRING,
|
|
||||||
/^(?:"(?:(?:""(?:""?(?!")|[^\\"]|\\.)*"{0,3})|(?:[^"\r\n\\]|\\.)*"?))/,
|
|
||||||
null, '"'],
|
|
||||||
[PR.PR_LITERAL, /^`(?:[^\r\n\\`]|\\.)*`?/, null, '`'],
|
|
||||||
[PR.PR_PUNCTUATION, /^[!#%&()*+,\-:;<=>?@\[\\\]^{|}~]+/, null,
|
|
||||||
'!#%&()*+,-:;<=>?@[\\]^{|}~']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
// A symbol literal is a single quote followed by an identifier with no
|
|
||||||
// single quote following
|
|
||||||
// A character literal has single quotes on either side
|
|
||||||
[PR.PR_STRING, /^'(?:[^\r\n\\']|\\(?:'|[^\r\n']+))'/],
|
|
||||||
[PR.PR_LITERAL, /^'[a-zA-Z_$][\w$]*(?!['$\w])/],
|
|
||||||
[PR.PR_KEYWORD, /^(?:abstract|case|catch|class|def|do|else|extends|final|finally|for|forSome|if|implicit|import|lazy|match|new|object|override|package|private|protected|requires|return|sealed|super|throw|trait|try|type|val|var|while|with|yield)\b/],
|
|
||||||
[PR.PR_LITERAL, /^(?:true|false|null|this)\b/],
|
|
||||||
[PR.PR_LITERAL, /^(?:(?:0(?:[0-7]+|X[0-9A-F]+))L?|(?:(?:0|[1-9][0-9]*)(?:(?:\.[0-9]+)?(?:E[+\-]?[0-9]+)?F?|L?))|\\.[0-9]+(?:E[+\-]?[0-9]+)?F?)/i],
|
|
||||||
// Treat upper camel case identifiers as types.
|
|
||||||
[PR.PR_TYPE, /^[$_]*[A-Z][_$A-Z0-9]*[a-z][\w$]*/],
|
|
||||||
[PR.PR_PLAIN, /^[$a-zA-Z_][\w$]*/],
|
|
||||||
[PR.PR_COMMENT, /^\/(?:\/.*|\*(?:\/|\**[^*/])*(?:\*+\/?)?)/],
|
|
||||||
[PR.PR_PUNCTUATION, /^(?:\.+|\/)/]
|
|
||||||
]),
|
|
||||||
['scala']);
|
|
@ -1,57 +0,0 @@
|
|||||||
// Copyright (C) 2008 Google Inc.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @fileoverview
|
|
||||||
* Registers a language handler for SQL.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* To use, include prettify.js and this file in your HTML page.
|
|
||||||
* Then put your code in an HTML tag like
|
|
||||||
* <pre class="prettyprint lang-sql">(my SQL code)</pre>
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* http://savage.net.au/SQL/sql-99.bnf.html is the basis for the grammar, and
|
|
||||||
* http://msdn.microsoft.com/en-us/library/aa238507(SQL.80).aspx as the basis
|
|
||||||
* for the keyword list.
|
|
||||||
*
|
|
||||||
* @author mikesamuel@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
PR.registerLangHandler(
|
|
||||||
PR.createSimpleLexer(
|
|
||||||
[
|
|
||||||
// Whitespace
|
|
||||||
[PR.PR_PLAIN, /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
|
|
||||||
// A double or single quoted, possibly multi-line, string.
|
|
||||||
[PR.PR_STRING, /^(?:"(?:[^\"\\]|\\.)*"|'(?:[^\'\\]|\\.)*')/, null,
|
|
||||||
'"\'']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
// A comment is either a line comment that starts with two dashes, or
|
|
||||||
// two dashes preceding a long bracketed block.
|
|
||||||
[PR.PR_COMMENT, /^(?:--[^\r\n]*|\/\*[\s\S]*?(?:\*\/|$))/],
|
|
||||||
[PR.PR_KEYWORD, /^(?:ADD|ALL|ALTER|AND|ANY|AS|ASC|AUTHORIZATION|BACKUP|BEGIN|BETWEEN|BREAK|BROWSE|BULK|BY|CASCADE|CASE|CHECK|CHECKPOINT|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMN|COMMIT|COMPUTE|CONSTRAINT|CONTAINS|CONTAINSTABLE|CONTINUE|CONVERT|CREATE|CROSS|CURRENT|CURRENT_DATE|CURRENT_TIME|CURRENT_TIMESTAMP|CURRENT_USER|CURSOR|DATABASE|DBCC|DEALLOCATE|DECLARE|DEFAULT|DELETE|DENY|DESC|DISK|DISTINCT|DISTRIBUTED|DOUBLE|DROP|DUMMY|DUMP|ELSE|END|ERRLVL|ESCAPE|EXCEPT|EXEC|EXECUTE|EXISTS|EXIT|FETCH|FILE|FILLFACTOR|FOR|FOREIGN|FREETEXT|FREETEXTTABLE|FROM|FULL|FUNCTION|GOTO|GRANT|GROUP|HAVING|HOLDLOCK|IDENTITY|IDENTITYCOL|IDENTITY_INSERT|IF|IN|INDEX|INNER|INSERT|INTERSECT|INTO|IS|JOIN|KEY|KILL|LEFT|LIKE|LINENO|LOAD|NATIONAL|NOCHECK|NONCLUSTERED|NOT|NULL|NULLIF|OF|OFF|OFFSETS|ON|OPEN|OPENDATASOURCE|OPENQUERY|OPENROWSET|OPENXML|OPTION|OR|ORDER|OUTER|OVER|PERCENT|PLAN|PRECISION|PRIMARY|PRINT|PROC|PROCEDURE|PUBLIC|RAISERROR|READ|READTEXT|RECONFIGURE|REFERENCES|REPLICATION|RESTORE|RESTRICT|RETURN|REVOKE|RIGHT|ROLLBACK|ROWCOUNT|ROWGUIDCOL|RULE|SAVE|SCHEMA|SELECT|SESSION_USER|SET|SETUSER|SHUTDOWN|SOME|STATISTICS|SYSTEM_USER|TABLE|TEXTSIZE|THEN|TO|TOP|TRAN|TRANSACTION|TRIGGER|TRUNCATE|TSEQUAL|UNION|UNIQUE|UPDATE|UPDATETEXT|USE|USER|VALUES|VARYING|VIEW|WAITFOR|WHEN|WHERE|WHILE|WITH|WRITETEXT)(?=[^\w-]|$)/i, null],
|
|
||||||
// A number is a hex integer literal, a decimal real literal, or in
|
|
||||||
// scientific notation.
|
|
||||||
[PR.PR_LITERAL,
|
|
||||||
/^[+-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i],
|
|
||||||
// An identifier
|
|
||||||
[PR.PR_PLAIN, /^[a-z_][\w-]*/i],
|
|
||||||
// A run of punctuation
|
|
||||||
[PR.PR_PUNCTUATION, /^[^\w\t\n\r \xA0\"\'][^\w\t\n\r \xA0+\-\"\']*/]
|
|
||||||
]),
|
|
||||||
['sql']);
|
|
@ -1,46 +0,0 @@
|
|||||||
// Copyright (C) 2011 Martin S.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @fileoverview
|
|
||||||
* Support for tex highlighting as discussed on
|
|
||||||
* <a href="http://meta.tex.stackexchange.com/questions/872/text-immediate-following-double-backslashes-is-highlighted-as-macro-inside-a-code/876#876">meta.tex.stackexchange.com</a>.
|
|
||||||
*
|
|
||||||
* @author Martin S.
|
|
||||||
*/
|
|
||||||
|
|
||||||
PR.registerLangHandler(
|
|
||||||
PR.createSimpleLexer(
|
|
||||||
[
|
|
||||||
// whitespace
|
|
||||||
[PR.PR_PLAIN, /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
|
|
||||||
// all comments begin with '%'
|
|
||||||
[PR.PR_COMMENT, /^%[^\r\n]*/, null, '%']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
//[PR.PR_DECLARATION, /^\\([egx]?def|(new|renew|provide)(command|environment))\b/],
|
|
||||||
// any command starting with a \ and contains
|
|
||||||
// either only letters (a-z,A-Z), '@' (internal macros)
|
|
||||||
[PR.PR_KEYWORD, /^\\[a-zA-Z@]+/],
|
|
||||||
// or contains only one character
|
|
||||||
[PR.PR_KEYWORD, /^\\./],
|
|
||||||
// Highlight dollar for math mode and ampersam for tabular
|
|
||||||
[PR.PR_TYPE, /^[$&]/],
|
|
||||||
// numeric measurement values with attached units
|
|
||||||
[PR.PR_LITERAL,
|
|
||||||
/[+-]?(?:\.\d+|\d+(?:\.\d*)?)(cm|em|ex|in|pc|pt|bp|mm)/i],
|
|
||||||
// punctuation usually occurring within commands
|
|
||||||
[PR.PR_PUNCTUATION, /^[{}()\[\]=]+/]
|
|
||||||
]),
|
|
||||||
['latex', 'tex']);
|
|
@ -1,61 +0,0 @@
|
|||||||
// Copyright (C) 2009 Google Inc.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @fileoverview
|
|
||||||
* Registers a language handler for various flavors of basic.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* To use, include prettify.js and this file in your HTML page.
|
|
||||||
* Then put your code in an HTML tag like
|
|
||||||
* <pre class="prettyprint lang-vb"></pre>
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* http://msdn.microsoft.com/en-us/library/aa711638(VS.71).aspx defines the
|
|
||||||
* visual basic grammar lexical grammar.
|
|
||||||
*
|
|
||||||
* @author mikesamuel@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
PR.registerLangHandler(
|
|
||||||
PR.createSimpleLexer(
|
|
||||||
[
|
|
||||||
// Whitespace
|
|
||||||
[PR.PR_PLAIN, /^[\t\n\r \xA0\u2028\u2029]+/, null, '\t\n\r \xA0\u2028\u2029'],
|
|
||||||
// A double quoted string with quotes escaped by doubling them.
|
|
||||||
// A single character can be suffixed with C.
|
|
||||||
[PR.PR_STRING, /^(?:[\"\u201C\u201D](?:[^\"\u201C\u201D]|[\"\u201C\u201D]{2})(?:[\"\u201C\u201D]c|$)|[\"\u201C\u201D](?:[^\"\u201C\u201D]|[\"\u201C\u201D]{2})*(?:[\"\u201C\u201D]|$))/i, null,
|
|
||||||
'"\u201C\u201D'],
|
|
||||||
// A comment starts with a single quote and runs until the end of the
|
|
||||||
// line.
|
|
||||||
[PR.PR_COMMENT, /^[\'\u2018\u2019][^\r\n\u2028\u2029]*/, null, '\'\u2018\u2019']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
[PR.PR_KEYWORD, /^(?:AddHandler|AddressOf|Alias|And|AndAlso|Ansi|As|Assembly|Auto|Boolean|ByRef|Byte|ByVal|Call|Case|Catch|CBool|CByte|CChar|CDate|CDbl|CDec|Char|CInt|Class|CLng|CObj|Const|CShort|CSng|CStr|CType|Date|Decimal|Declare|Default|Delegate|Dim|DirectCast|Do|Double|Each|Else|ElseIf|End|EndIf|Enum|Erase|Error|Event|Exit|Finally|For|Friend|Function|Get|GetType|GoSub|GoTo|Handles|If|Implements|Imports|In|Inherits|Integer|Interface|Is|Let|Lib|Like|Long|Loop|Me|Mod|Module|MustInherit|MustOverride|MyBase|MyClass|Namespace|New|Next|Not|NotInheritable|NotOverridable|Object|On|Option|Optional|Or|OrElse|Overloads|Overridable|Overrides|ParamArray|Preserve|Private|Property|Protected|Public|RaiseEvent|ReadOnly|ReDim|RemoveHandler|Resume|Return|Select|Set|Shadows|Shared|Short|Single|Static|Step|Stop|String|Structure|Sub|SyncLock|Then|Throw|To|Try|TypeOf|Unicode|Until|Variant|Wend|When|While|With|WithEvents|WriteOnly|Xor|EndIf|GoSub|Let|Variant|Wend)\b/i, null],
|
|
||||||
// A second comment form
|
|
||||||
[PR.PR_COMMENT, /^REM[^\r\n\u2028\u2029]*/i],
|
|
||||||
// A boolean, numeric, or date literal.
|
|
||||||
[PR.PR_LITERAL,
|
|
||||||
/^(?:True\b|False\b|Nothing\b|\d+(?:E[+\-]?\d+[FRD]?|[FRDSIL])?|(?:&H[0-9A-F]+|&O[0-7]+)[SIL]?|\d*\.\d+(?:E[+\-]?\d+)?[FRD]?|#\s+(?:\d+[\-\/]\d+[\-\/]\d+(?:\s+\d+:\d+(?::\d+)?(\s*(?:AM|PM))?)?|\d+:\d+(?::\d+)?(\s*(?:AM|PM))?)\s+#)/i],
|
|
||||||
// An identifier?
|
|
||||||
[PR.PR_PLAIN, /^(?:(?:[a-z]|_\w)\w*|\[(?:[a-z]|_\w)\w*\])/i],
|
|
||||||
// A run of punctuation
|
|
||||||
[PR.PR_PUNCTUATION,
|
|
||||||
/^[^\w\t\n\r \"\'\[\]\xA0\u2018\u2019\u201C\u201D\u2028\u2029]+/],
|
|
||||||
// Square brackets
|
|
||||||
[PR.PR_PUNCTUATION, /^(?:\[|\])/]
|
|
||||||
]),
|
|
||||||
['vb', 'vbs']);
|
|
@ -1,34 +0,0 @@
|
|||||||
/**
|
|
||||||
* @fileoverview
|
|
||||||
* Registers a language handler for VHDL '93.
|
|
||||||
*
|
|
||||||
* Based on the lexical grammar and keywords at
|
|
||||||
* http://www.iis.ee.ethz.ch/~zimmi/download/vhdl93_syntax.html
|
|
||||||
*
|
|
||||||
* @author benoit@ryder.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
PR.registerLangHandler(
|
|
||||||
PR.createSimpleLexer(
|
|
||||||
[
|
|
||||||
// Whitespace
|
|
||||||
[PR.PR_PLAIN, /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
// String, character or bit string
|
|
||||||
[PR.PR_STRING, /^(?:[BOX]?"(?:[^\"]|"")*"|'.')/i],
|
|
||||||
// Comment, from two dashes until end of line.
|
|
||||||
[PR.PR_COMMENT, /^--[^\r\n]*/],
|
|
||||||
[PR.PR_KEYWORD, /^(?:abs|access|after|alias|all|and|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|mod|nand|new|next|nor|not|null|of|on|open|or|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|rem|report|return|rol|ror|select|severity|shared|signal|sla|sll|sra|srl|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with|xnor|xor)(?=[^\w-]|$)/i, null],
|
|
||||||
// Type, predefined or standard
|
|
||||||
[PR.PR_TYPE, /^(?:bit|bit_vector|character|boolean|integer|real|time|string|severity_level|positive|natural|signed|unsigned|line|text|std_u?logic(?:_vector)?)(?=[^\w-]|$)/i, null],
|
|
||||||
// Predefined attributes
|
|
||||||
[PR.PR_TYPE, /^\'(?:ACTIVE|ASCENDING|BASE|DELAYED|DRIVING|DRIVING_VALUE|EVENT|HIGH|IMAGE|INSTANCE_NAME|LAST_ACTIVE|LAST_EVENT|LAST_VALUE|LEFT|LEFTOF|LENGTH|LOW|PATH_NAME|POS|PRED|QUIET|RANGE|REVERSE_RANGE|RIGHT|RIGHTOF|SIMPLE_NAME|STABLE|SUCC|TRANSACTION|VAL|VALUE)(?=[^\w-]|$)/i, null],
|
|
||||||
// Number, decimal or based literal
|
|
||||||
[PR.PR_LITERAL, /^\d+(?:_\d+)*(?:#[\w\\.]+#(?:[+\-]?\d+(?:_\d+)*)?|(?:\.\d+(?:_\d+)*)?(?:E[+\-]?\d+(?:_\d+)*)?)/i],
|
|
||||||
// Identifier, basic or extended
|
|
||||||
[PR.PR_PLAIN, /^(?:[a-z]\w*|\\[^\\]*\\)/i],
|
|
||||||
// Punctuation
|
|
||||||
[PR.PR_PUNCTUATION, /^[^\w\t\n\r \xA0\"\'][^\w\t\n\r \xA0\-\"\']*/]
|
|
||||||
]),
|
|
||||||
['vhdl', 'vhd']);
|
|
@ -1,53 +0,0 @@
|
|||||||
// Copyright (C) 2009 Google Inc.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @fileoverview
|
|
||||||
* Registers a language handler for Wiki pages.
|
|
||||||
*
|
|
||||||
* Based on WikiSyntax at http://code.google.com/p/support/wiki/WikiSyntax
|
|
||||||
*
|
|
||||||
* @author mikesamuel@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
PR.registerLangHandler(
|
|
||||||
PR.createSimpleLexer(
|
|
||||||
[
|
|
||||||
// Whitespace
|
|
||||||
[PR.PR_PLAIN, /^[\t \xA0a-gi-z0-9]+/, null,
|
|
||||||
'\t \xA0abcdefgijklmnopqrstuvwxyz0123456789'],
|
|
||||||
// Wiki formatting
|
|
||||||
[PR.PR_PUNCTUATION, /^[=*~\^\[\]]+/, null, '=*~^[]']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
// Meta-info like #summary, #labels, etc.
|
|
||||||
['lang-wiki.meta', /(?:^^|\r\n?|\n)(#[a-z]+)\b/],
|
|
||||||
// A WikiWord
|
|
||||||
[PR.PR_LITERAL, /^(?:[A-Z][a-z][a-z0-9]+[A-Z][a-z][a-zA-Z0-9]+)\b/
|
|
||||||
],
|
|
||||||
// A preformatted block in an unknown language
|
|
||||||
['lang-', /^\{\{\{([\s\S]+?)\}\}\}/],
|
|
||||||
// A block of source code in an unknown language
|
|
||||||
['lang-', /^`([^\r\n`]+)`/],
|
|
||||||
// An inline URL.
|
|
||||||
[PR.PR_STRING,
|
|
||||||
/^https?:\/\/[^\/?#\s]*(?:\/[^?#\s]*)?(?:\?[^#\s]*)?(?:#\S*)?/i],
|
|
||||||
[PR.PR_PLAIN, /^(?:\r\n|[\s\S])[^#=*~^A-Zh\{`\[\r\n]*/]
|
|
||||||
]),
|
|
||||||
['wiki']);
|
|
||||||
|
|
||||||
PR.registerLangHandler(
|
|
||||||
PR.createSimpleLexer([[PR.PR_KEYWORD, /^#[a-z]+/i, null, '#']], []),
|
|
||||||
['wiki.meta']);
|
|
@ -1,27 +0,0 @@
|
|||||||
// Contributed by ribrdb @ code.google.com
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @fileoverview
|
|
||||||
* Registers a language handler for YAML.
|
|
||||||
*
|
|
||||||
* @author ribrdb
|
|
||||||
*/
|
|
||||||
|
|
||||||
PR.registerLangHandler(
|
|
||||||
PR.createSimpleLexer(
|
|
||||||
[
|
|
||||||
[PR.PR_PUNCTUATION, /^[:|>?]+/, null, ':|>?'],
|
|
||||||
[PR.PR_DECLARATION, /^%(?:YAML|TAG)[^#\r\n]+/, null, '%'],
|
|
||||||
[PR.PR_TYPE, /^[&]\S+/, null, '&'],
|
|
||||||
[PR.PR_TYPE, /^!\S*/, null, '!'],
|
|
||||||
[PR.PR_STRING, /^"(?:[^\\"]|\\.)*(?:"|$)/, null, '"'],
|
|
||||||
[PR.PR_STRING, /^'(?:[^']|'')*(?:'|$)/, null, "'"],
|
|
||||||
[PR.PR_COMMENT, /^#[^\r\n]*/, null, '#'],
|
|
||||||
[PR.PR_PLAIN, /^\s+/, null, ' \t\r\n']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
[PR.PR_DECLARATION, /^(?:---|\.\.\.)(?:[\r\n]|$)/],
|
|
||||||
[PR.PR_PUNCTUATION, /^-/],
|
|
||||||
[PR.PR_KEYWORD, /^\w+:[ \r\n]/],
|
|
||||||
[PR.PR_PLAIN, /^\w+/]
|
|
||||||
]), ['yaml', 'yml']);
|
|
765
src/openid.php
@ -1,765 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* This class provides a simple interface for OpenID (1.1 and 2.0) authentication.
|
|
||||||
* Supports Yadis discovery.
|
|
||||||
* The authentication process is stateless/dumb.
|
|
||||||
*
|
|
||||||
* Usage:
|
|
||||||
* Sign-on with OpenID is a two step process:
|
|
||||||
* Step one is authentication with the provider:
|
|
||||||
* <code>
|
|
||||||
* $openid = new LightOpenID;
|
|
||||||
* $openid->identity = 'ID supplied by user';
|
|
||||||
* header('Location: ' . $openid->authUrl());
|
|
||||||
* </code>
|
|
||||||
* The provider then sends various parameters via GET, one of them is openid_mode.
|
|
||||||
* Step two is verification:
|
|
||||||
* <code>
|
|
||||||
* if ($this->data['openid_mode']) {
|
|
||||||
* $openid = new LightOpenID;
|
|
||||||
* echo $openid->validate() ? 'Logged in.' : 'Failed';
|
|
||||||
* }
|
|
||||||
* </code>
|
|
||||||
*
|
|
||||||
* Optionally, you can set $returnUrl and $realm (or $trustRoot, which is an alias).
|
|
||||||
* The default values for those are:
|
|
||||||
* $openid->realm = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'];
|
|
||||||
* $openid->returnUrl = $openid->realm . $_SERVER['REQUEST_URI'];
|
|
||||||
* If you don't know their meaning, refer to any openid tutorial, or specification. Or just guess.
|
|
||||||
*
|
|
||||||
* AX and SREG extensions are supported.
|
|
||||||
* To use them, specify $openid->required and/or $openid->optional before calling $openid->authUrl().
|
|
||||||
* These are arrays, with values being AX schema paths (the 'path' part of the URL).
|
|
||||||
* For example:
|
|
||||||
* $openid->required = array('namePerson/friendly', 'contact/email');
|
|
||||||
* $openid->optional = array('namePerson/first');
|
|
||||||
* If the server supports only SREG or OpenID 1.1, these are automaticaly
|
|
||||||
* mapped to SREG names, so that user doesn't have to know anything about the server.
|
|
||||||
*
|
|
||||||
* To get the values, use $openid->getAttributes().
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* The library requires PHP >= 5.1.2 with curl or http/https stream wrappers enabled.
|
|
||||||
* @author Mewp
|
|
||||||
* @copyright Copyright (c) 2010, Mewp
|
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
|
||||||
*/
|
|
||||||
class LightOpenID
|
|
||||||
{
|
|
||||||
public $returnUrl
|
|
||||||
, $required = array()
|
|
||||||
, $optional = array()
|
|
||||||
, $verify_peer = null
|
|
||||||
, $capath = null
|
|
||||||
, $cainfo = null;
|
|
||||||
private $identity, $claimed_id;
|
|
||||||
protected $server, $version, $trustRoot, $aliases, $identifier_select = false
|
|
||||||
, $ax = false, $sreg = false, $data, $setup_url = null;
|
|
||||||
static protected $ax_to_sreg = array(
|
|
||||||
'namePerson/friendly' => 'nickname',
|
|
||||||
'contact/email' => 'email',
|
|
||||||
'namePerson' => 'fullname',
|
|
||||||
'birthDate' => 'dob',
|
|
||||||
'person/gender' => 'gender',
|
|
||||||
'contact/postalCode/home' => 'postcode',
|
|
||||||
'contact/country/home' => 'country',
|
|
||||||
'pref/language' => 'language',
|
|
||||||
'pref/timezone' => 'timezone',
|
|
||||||
'namePerson/first' => 'firstname',
|
|
||||||
'namePerson/last' => 'lastname',
|
|
||||||
);
|
|
||||||
|
|
||||||
function __construct()
|
|
||||||
{
|
|
||||||
$this->trustRoot = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'];
|
|
||||||
$uri = rtrim(preg_replace('#((?<=\?)|&)openid\.[^&]+#', '', $_SERVER['REQUEST_URI']), '?');
|
|
||||||
$this->returnUrl = $this->trustRoot . $uri;
|
|
||||||
|
|
||||||
$this->data = $_POST + $_GET; # OPs may send data as POST or GET.
|
|
||||||
|
|
||||||
if(!function_exists('curl_init') && !in_array('https', stream_get_wrappers())) {
|
|
||||||
throw new ErrorException('You must have either https wrappers or curl enabled.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function __set($name, $value)
|
|
||||||
{
|
|
||||||
switch ($name) {
|
|
||||||
case 'identity':
|
|
||||||
if (strlen($value = trim((String) $value))) {
|
|
||||||
if (preg_match('#^xri:/*#i', $value, $m)) {
|
|
||||||
$value = substr($value, strlen($m[0]));
|
|
||||||
} elseif (!preg_match('/^(?:[=@+\$!\(]|https?:)/i', $value)) {
|
|
||||||
$value = "http://$value";
|
|
||||||
}
|
|
||||||
if (preg_match('#^https?://[^/]+$#i', $value, $m)) {
|
|
||||||
$value .= '/';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->$name = $this->claimed_id = $value;
|
|
||||||
break;
|
|
||||||
case 'trustRoot':
|
|
||||||
case 'realm':
|
|
||||||
$this->trustRoot = trim($value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function __get($name)
|
|
||||||
{
|
|
||||||
switch ($name) {
|
|
||||||
case 'identity':
|
|
||||||
# We return claimed_id instead of identity,
|
|
||||||
# because the developer should see the claimed identifier,
|
|
||||||
# i.e. what he set as identity, not the op-local identifier (which is what we verify)
|
|
||||||
return $this->claimed_id;
|
|
||||||
case 'trustRoot':
|
|
||||||
case 'realm':
|
|
||||||
return $this->trustRoot;
|
|
||||||
case 'mode':
|
|
||||||
return empty($this->data['openid_mode']) ? null : $this->data['openid_mode'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the server specified in the url exists.
|
|
||||||
*
|
|
||||||
* @param $url url to check
|
|
||||||
* @return true, if the server exists; false otherwise
|
|
||||||
*/
|
|
||||||
function hostExists($url)
|
|
||||||
{
|
|
||||||
if (strpos($url, '/') === false) {
|
|
||||||
$server = $url;
|
|
||||||
} else {
|
|
||||||
$server = @parse_url($url, PHP_URL_HOST);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$server) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return !!gethostbynamel($server);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function request_curl($url, $method='GET', $params=array())
|
|
||||||
{
|
|
||||||
$params = http_build_query($params, '', '&');
|
|
||||||
$curl = curl_init($url . ($method == 'GET' && $params ? '?' . $params : ''));
|
|
||||||
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
|
|
||||||
curl_setopt($curl, CURLOPT_HEADER, false);
|
|
||||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/xrds+xml, */*'));
|
|
||||||
|
|
||||||
if($this->verify_peer !== null) {
|
|
||||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verify_peer);
|
|
||||||
if($this->capath) {
|
|
||||||
curl_setopt($curl, CURLOPT_CAPATH, $this->capath);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($this->cainfo) {
|
|
||||||
curl_setopt($curl, CURLOPT_CAINFO, $this->cainfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($method == 'POST') {
|
|
||||||
curl_setopt($curl, CURLOPT_POST, true);
|
|
||||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
|
|
||||||
} elseif ($method == 'HEAD') {
|
|
||||||
curl_setopt($curl, CURLOPT_HEADER, true);
|
|
||||||
curl_setopt($curl, CURLOPT_NOBODY, true);
|
|
||||||
} else {
|
|
||||||
curl_setopt($curl, CURLOPT_HTTPGET, true);
|
|
||||||
}
|
|
||||||
$response = curl_exec($curl);
|
|
||||||
|
|
||||||
if($method == 'HEAD') {
|
|
||||||
$headers = array();
|
|
||||||
foreach(explode("\n", $response) as $header) {
|
|
||||||
$pos = strpos($header,':');
|
|
||||||
$name = strtolower(trim(substr($header, 0, $pos)));
|
|
||||||
$headers[$name] = trim(substr($header, $pos+1));
|
|
||||||
}
|
|
||||||
|
|
||||||
# Updating claimed_id in case of redirections.
|
|
||||||
$effective_url = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
|
|
||||||
if($effective_url != $url) {
|
|
||||||
$this->identity = $this->claimed_id = $effective_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $headers;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (curl_errno($curl)) {
|
|
||||||
throw new ErrorException(curl_error($curl), curl_errno($curl));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function request_streams($url, $method='GET', $params=array())
|
|
||||||
{
|
|
||||||
if(!$this->hostExists($url)) {
|
|
||||||
throw new ErrorException('Invalid request.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$params = http_build_query($params, '', '&');
|
|
||||||
switch($method) {
|
|
||||||
case 'GET':
|
|
||||||
$opts = array(
|
|
||||||
'http' => array(
|
|
||||||
'method' => 'GET',
|
|
||||||
'header' => 'Accept: application/xrds+xml, */*',
|
|
||||||
'ignore_errors' => true,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$url = $url . ($params ? '?' . $params : '');
|
|
||||||
break;
|
|
||||||
case 'POST':
|
|
||||||
$opts = array(
|
|
||||||
'http' => array(
|
|
||||||
'method' => 'POST',
|
|
||||||
'header' => 'Content-type: application/x-www-form-urlencoded',
|
|
||||||
'content' => $params,
|
|
||||||
'ignore_errors' => true,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case 'HEAD':
|
|
||||||
# We want to send a HEAD request,
|
|
||||||
# but since get_headers doesn't accept $context parameter,
|
|
||||||
# we have to change the defaults.
|
|
||||||
$default = stream_context_get_options(stream_context_get_default());
|
|
||||||
stream_context_get_default(
|
|
||||||
array('http' => array(
|
|
||||||
'method' => 'HEAD',
|
|
||||||
'header' => 'Accept: application/xrds+xml, */*',
|
|
||||||
'ignore_errors' => true,
|
|
||||||
))
|
|
||||||
);
|
|
||||||
|
|
||||||
$url = $url . ($params ? '?' . $params : '');
|
|
||||||
$headers_tmp = get_headers ($url);
|
|
||||||
if(!$headers_tmp) {
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
# Parsing headers.
|
|
||||||
$headers = array();
|
|
||||||
foreach($headers_tmp as $header) {
|
|
||||||
$pos = strpos($header,':');
|
|
||||||
$name = strtolower(trim(substr($header, 0, $pos)));
|
|
||||||
$headers[$name] = trim(substr($header, $pos+1));
|
|
||||||
|
|
||||||
# Following possible redirections. The point is just to have
|
|
||||||
# claimed_id change with them, because get_headers() will
|
|
||||||
# follow redirections automatically.
|
|
||||||
# We ignore redirections with relative paths.
|
|
||||||
# If any known provider uses them, file a bug report.
|
|
||||||
if($name == 'location') {
|
|
||||||
if(strpos($headers[$name], 'http') === 0) {
|
|
||||||
$this->identity = $this->claimed_id = $headers[$name];
|
|
||||||
} elseif($headers[$name][0] == '/') {
|
|
||||||
$parsed_url = parse_url($this->claimed_id);
|
|
||||||
$this->identity =
|
|
||||||
$this->claimed_id = $parsed_url['scheme'] . '://'
|
|
||||||
. $parsed_url['host']
|
|
||||||
. $headers[$name];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# And restore them.
|
|
||||||
stream_context_get_default($default);
|
|
||||||
return $headers;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($this->verify_peer) {
|
|
||||||
$opts += array('ssl' => array(
|
|
||||||
'verify_peer' => true,
|
|
||||||
'capath' => $this->capath,
|
|
||||||
'cafile' => $this->cainfo,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
$context = stream_context_create ($opts);
|
|
||||||
|
|
||||||
return file_get_contents($url, false, $context);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function request($url, $method='GET', $params=array())
|
|
||||||
{
|
|
||||||
if(function_exists('curl_init') && !ini_get('safe_mode') && !ini_get('open_basedir')) {
|
|
||||||
return $this->request_curl($url, $method, $params);
|
|
||||||
}
|
|
||||||
return $this->request_streams($url, $method, $params);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function build_url($url, $parts)
|
|
||||||
{
|
|
||||||
if (isset($url['query'], $parts['query'])) {
|
|
||||||
$parts['query'] = $url['query'] . '&' . $parts['query'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$url = $parts + $url;
|
|
||||||
$url = $url['scheme'] . '://'
|
|
||||||
. (empty($url['username'])?''
|
|
||||||
:(empty($url['password'])? "{$url['username']}@"
|
|
||||||
:"{$url['username']}:{$url['password']}@"))
|
|
||||||
. $url['host']
|
|
||||||
. (empty($url['port'])?'':":{$url['port']}")
|
|
||||||
. (empty($url['path'])?'':$url['path'])
|
|
||||||
. (empty($url['query'])?'':"?{$url['query']}")
|
|
||||||
. (empty($url['fragment'])?'':"#{$url['fragment']}");
|
|
||||||
return $url;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper function used to scan for <meta>/<link> tags and extract information
|
|
||||||
* from them
|
|
||||||
*/
|
|
||||||
protected function htmlTag($content, $tag, $attrName, $attrValue, $valueName)
|
|
||||||
{
|
|
||||||
preg_match_all("#<{$tag}[^>]*$attrName=['\"].*?$attrValue.*?['\"][^>]*$valueName=['\"](.+?)['\"][^>]*/?>#i", $content, $matches1);
|
|
||||||
preg_match_all("#<{$tag}[^>]*$valueName=['\"](.+?)['\"][^>]*$attrName=['\"].*?$attrValue.*?['\"][^>]*/?>#i", $content, $matches2);
|
|
||||||
|
|
||||||
$result = array_merge($matches1[1], $matches2[1]);
|
|
||||||
return empty($result)?false:$result[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Performs Yadis and HTML discovery. Normally not used.
|
|
||||||
* @param $url Identity URL.
|
|
||||||
* @return String OP Endpoint (i.e. OpenID provider address).
|
|
||||||
* @throws ErrorException
|
|
||||||
*/
|
|
||||||
function discover($url)
|
|
||||||
{
|
|
||||||
if (!$url) throw new ErrorException('No identity supplied.');
|
|
||||||
# Use xri.net proxy to resolve i-name identities
|
|
||||||
if (!preg_match('#^https?:#', $url)) {
|
|
||||||
$url = "https://xri.net/$url";
|
|
||||||
}
|
|
||||||
|
|
||||||
# We save the original url in case of Yadis discovery failure.
|
|
||||||
# It can happen when we'll be lead to an XRDS document
|
|
||||||
# which does not have any OpenID2 services.
|
|
||||||
$originalUrl = $url;
|
|
||||||
|
|
||||||
# A flag to disable yadis discovery in case of failure in headers.
|
|
||||||
$yadis = true;
|
|
||||||
|
|
||||||
# We'll jump a maximum of 5 times, to avoid endless redirections.
|
|
||||||
for ($i = 0; $i < 5; $i ++) {
|
|
||||||
if ($yadis) {
|
|
||||||
$headers = $this->request($url, 'HEAD');
|
|
||||||
|
|
||||||
$next = false;
|
|
||||||
if (isset($headers['x-xrds-location'])) {
|
|
||||||
$url = $this->build_url(parse_url($url), parse_url(trim($headers['x-xrds-location'])));
|
|
||||||
$next = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($headers['content-type'])
|
|
||||||
&& (strpos($headers['content-type'], 'application/xrds+xml') !== false
|
|
||||||
|| strpos($headers['content-type'], 'text/xml') !== false)
|
|
||||||
) {
|
|
||||||
# Apparently, some providers return XRDS documents as text/html.
|
|
||||||
# While it is against the spec, allowing this here shouldn't break
|
|
||||||
# compatibility with anything.
|
|
||||||
# ---
|
|
||||||
# Found an XRDS document, now let's find the server, and optionally delegate.
|
|
||||||
$content = $this->request($url, 'GET');
|
|
||||||
|
|
||||||
preg_match_all('#<Service.*?>(.*?)</Service>#s', $content, $m);
|
|
||||||
foreach($m[1] as $content) {
|
|
||||||
$content = ' ' . $content; # The space is added, so that strpos doesn't return 0.
|
|
||||||
|
|
||||||
# OpenID 2
|
|
||||||
$ns = preg_quote('http://specs.openid.net/auth/2.0/');
|
|
||||||
if(preg_match('#<Type>\s*'.$ns.'(server|signon)\s*</Type>#s', $content, $type)) {
|
|
||||||
if ($type[1] == 'server') $this->identifier_select = true;
|
|
||||||
|
|
||||||
preg_match('#<URI.*?>(.*)</URI>#', $content, $server);
|
|
||||||
preg_match('#<(Local|Canonical)ID>(.*)</\1ID>#', $content, $delegate);
|
|
||||||
if (empty($server)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
# Does the server advertise support for either AX or SREG?
|
|
||||||
$this->ax = (bool) strpos($content, '<Type>http://openid.net/srv/ax/1.0</Type>');
|
|
||||||
$this->sreg = strpos($content, '<Type>http://openid.net/sreg/1.0</Type>')
|
|
||||||
|| strpos($content, '<Type>http://openid.net/extensions/sreg/1.1</Type>');
|
|
||||||
|
|
||||||
$server = $server[1];
|
|
||||||
if (isset($delegate[2])) $this->identity = trim($delegate[2]);
|
|
||||||
$this->version = 2;
|
|
||||||
|
|
||||||
$this->server = $server;
|
|
||||||
return $server;
|
|
||||||
}
|
|
||||||
|
|
||||||
# OpenID 1.1
|
|
||||||
$ns = preg_quote('http://openid.net/signon/1.1');
|
|
||||||
if (preg_match('#<Type>\s*'.$ns.'\s*</Type>#s', $content)) {
|
|
||||||
|
|
||||||
preg_match('#<URI.*?>(.*)</URI>#', $content, $server);
|
|
||||||
preg_match('#<.*?Delegate>(.*)</.*?Delegate>#', $content, $delegate);
|
|
||||||
if (empty($server)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
# AX can be used only with OpenID 2.0, so checking only SREG
|
|
||||||
$this->sreg = strpos($content, '<Type>http://openid.net/sreg/1.0</Type>')
|
|
||||||
|| strpos($content, '<Type>http://openid.net/extensions/sreg/1.1</Type>');
|
|
||||||
|
|
||||||
$server = $server[1];
|
|
||||||
if (isset($delegate[1])) $this->identity = $delegate[1];
|
|
||||||
$this->version = 1;
|
|
||||||
|
|
||||||
$this->server = $server;
|
|
||||||
return $server;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$next = true;
|
|
||||||
$yadis = false;
|
|
||||||
$url = $originalUrl;
|
|
||||||
$content = null;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ($next) continue;
|
|
||||||
|
|
||||||
# There are no relevant information in headers, so we search the body.
|
|
||||||
$content = $this->request($url, 'GET');
|
|
||||||
$location = $this->htmlTag($content, 'meta', 'http-equiv', 'X-XRDS-Location', 'content');
|
|
||||||
if ($location) {
|
|
||||||
$url = $this->build_url(parse_url($url), parse_url($location));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$content) $content = $this->request($url, 'GET');
|
|
||||||
|
|
||||||
# At this point, the YADIS Discovery has failed, so we'll switch
|
|
||||||
# to openid2 HTML discovery, then fallback to openid 1.1 discovery.
|
|
||||||
$server = $this->htmlTag($content, 'link', 'rel', 'openid2.provider', 'href');
|
|
||||||
$delegate = $this->htmlTag($content, 'link', 'rel', 'openid2.local_id', 'href');
|
|
||||||
$this->version = 2;
|
|
||||||
|
|
||||||
if (!$server) {
|
|
||||||
# The same with openid 1.1
|
|
||||||
$server = $this->htmlTag($content, 'link', 'rel', 'openid.server', 'href');
|
|
||||||
$delegate = $this->htmlTag($content, 'link', 'rel', 'openid.delegate', 'href');
|
|
||||||
$this->version = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($server) {
|
|
||||||
# We found an OpenID2 OP Endpoint
|
|
||||||
if ($delegate) {
|
|
||||||
# We have also found an OP-Local ID.
|
|
||||||
$this->identity = $delegate;
|
|
||||||
}
|
|
||||||
$this->server = $server;
|
|
||||||
return $server;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new ErrorException('No servers found!');
|
|
||||||
}
|
|
||||||
throw new ErrorException('Endless redirection!');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function papeParams()
|
|
||||||
{
|
|
||||||
$params = array();
|
|
||||||
$params['openid.ns.pape'] = 'http://specs.openid.net/extensions/pape/1.0';
|
|
||||||
$params['openid.pape.max_auth_age'] = '0';
|
|
||||||
$params['openid.ns.ui'] = 'http://specs.openid.net/extensions/ui/1.0';
|
|
||||||
$params['openid.ui.mode'] = 'popup';
|
|
||||||
return $params;
|
|
||||||
}
|
|
||||||
protected function sregParams()
|
|
||||||
{
|
|
||||||
$params = array();
|
|
||||||
# We always use SREG 1.1, even if the server is advertising only support for 1.0.
|
|
||||||
# That's because it's fully backwards compatibile with 1.0, and some providers
|
|
||||||
# advertise 1.0 even if they accept only 1.1. One such provider is myopenid.com
|
|
||||||
$params['openid.ns.sreg'] = 'http://openid.net/extensions/sreg/1.1';
|
|
||||||
if ($this->required) {
|
|
||||||
$params['openid.sreg.required'] = array();
|
|
||||||
foreach ($this->required as $required) {
|
|
||||||
if (!isset(self::$ax_to_sreg[$required])) continue;
|
|
||||||
$params['openid.sreg.required'][] = self::$ax_to_sreg[$required];
|
|
||||||
}
|
|
||||||
$params['openid.sreg.required'] = implode(',', $params['openid.sreg.required']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->optional) {
|
|
||||||
$params['openid.sreg.optional'] = array();
|
|
||||||
foreach ($this->optional as $optional) {
|
|
||||||
if (!isset(self::$ax_to_sreg[$optional])) continue;
|
|
||||||
$params['openid.sreg.optional'][] = self::$ax_to_sreg[$optional];
|
|
||||||
}
|
|
||||||
$params['openid.sreg.optional'] = implode(',', $params['openid.sreg.optional']);
|
|
||||||
}
|
|
||||||
return $params;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function axParams()
|
|
||||||
{
|
|
||||||
$params = array();
|
|
||||||
if ($this->required || $this->optional) {
|
|
||||||
$params['openid.ns.ax'] = 'http://openid.net/srv/ax/1.0';
|
|
||||||
$params['openid.ax.mode'] = 'fetch_request';
|
|
||||||
$this->aliases = array();
|
|
||||||
$counts = array();
|
|
||||||
$required = array();
|
|
||||||
$optional = array();
|
|
||||||
foreach (array('required','optional') as $type) {
|
|
||||||
foreach ($this->$type as $alias => $field) {
|
|
||||||
if (is_int($alias)) $alias = strtr($field, '/', '_');
|
|
||||||
$this->aliases[$alias] = 'http://axschema.org/' . $field;
|
|
||||||
if (empty($counts[$alias])) $counts[$alias] = 0;
|
|
||||||
$counts[$alias] += 1;
|
|
||||||
${$type}[] = $alias;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($this->aliases as $alias => $ns) {
|
|
||||||
$params['openid.ax.type.' . $alias] = $ns;
|
|
||||||
}
|
|
||||||
foreach ($counts as $alias => $count) {
|
|
||||||
if ($count == 1) continue;
|
|
||||||
$params['openid.ax.count.' . $alias] = $count;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Don't send empty ax.requied and ax.if_available.
|
|
||||||
# Google and possibly other providers refuse to support ax when one of these is empty.
|
|
||||||
if($required) {
|
|
||||||
$params['openid.ax.required'] = implode(',', $required);
|
|
||||||
}
|
|
||||||
if($optional) {
|
|
||||||
$params['openid.ax.if_available'] = implode(',', $optional);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $params;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function authUrl_v1($immediate)
|
|
||||||
{
|
|
||||||
$returnUrl = $this->returnUrl;
|
|
||||||
# If we have an openid.delegate that is different from our claimed id,
|
|
||||||
# we need to somehow preserve the claimed id between requests.
|
|
||||||
# The simplest way is to just send it along with the return_to url.
|
|
||||||
if($this->identity != $this->claimed_id) {
|
|
||||||
$returnUrl .= (strpos($returnUrl, '?') ? '&' : '?') . 'openid.claimed_id=' . $this->claimed_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
$params = array(
|
|
||||||
'openid.return_to' => $returnUrl,
|
|
||||||
'openid.mode' => $immediate ? 'checkid_immediate' : 'checkid_setup',
|
|
||||||
'openid.identity' => $this->identity,
|
|
||||||
'openid.trust_root' => $this->trustRoot,
|
|
||||||
) + $this->sregParams() + $this->papeParams();
|
|
||||||
|
|
||||||
return $this->build_url(parse_url($this->server)
|
|
||||||
, array('query' => http_build_query($params, '', '&')));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function authUrl_v2($immediate)
|
|
||||||
{
|
|
||||||
$params = array(
|
|
||||||
'openid.ns' => 'http://specs.openid.net/auth/2.0',
|
|
||||||
'openid.mode' => $immediate ? 'checkid_immediate' : 'checkid_setup',
|
|
||||||
'openid.return_to' => $this->returnUrl,
|
|
||||||
'openid.realm' => $this->trustRoot,
|
|
||||||
);
|
|
||||||
if ($this->ax) {
|
|
||||||
$params += $this->axParams();
|
|
||||||
}
|
|
||||||
if ($this->sreg) {
|
|
||||||
$params += $this->sregParams();
|
|
||||||
}
|
|
||||||
if (!$this->ax && !$this->sreg) {
|
|
||||||
# If OP doesn't advertise either SREG, nor AX, let's send them both
|
|
||||||
# in worst case we don't get anything in return.
|
|
||||||
$params += $this->axParams() + $this->sregParams();
|
|
||||||
}
|
|
||||||
$params = $params + $this->papeParams();
|
|
||||||
if ($this->identifier_select) {
|
|
||||||
$params['openid.identity'] = $params['openid.claimed_id']
|
|
||||||
= 'http://specs.openid.net/auth/2.0/identifier_select';
|
|
||||||
} else {
|
|
||||||
$params['openid.identity'] = $this->identity;
|
|
||||||
$params['openid.claimed_id'] = $this->claimed_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->build_url(parse_url($this->server)
|
|
||||||
, array('query' => http_build_query($params, '', '&')));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns authentication url. Usually, you want to redirect your user to it.
|
|
||||||
* @return String The authentication url.
|
|
||||||
* @param String $select_identifier Whether to request OP to select identity for an user in OpenID 2. Does not affect OpenID 1.
|
|
||||||
* @throws ErrorException
|
|
||||||
*/
|
|
||||||
function authUrl($immediate = false)
|
|
||||||
{
|
|
||||||
if ($this->setup_url && !$immediate) return $this->setup_url;
|
|
||||||
if (!$this->server) $this->discover($this->identity);
|
|
||||||
|
|
||||||
if ($this->version == 2) {
|
|
||||||
return $this->authUrl_v2($immediate);
|
|
||||||
}
|
|
||||||
return $this->authUrl_v1($immediate);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Performs OpenID verification with the OP.
|
|
||||||
* @return Bool Whether the verification was successful.
|
|
||||||
* @throws ErrorException
|
|
||||||
*/
|
|
||||||
function validate()
|
|
||||||
{
|
|
||||||
# If the request was using immediate mode, a failure may be reported
|
|
||||||
# by presenting user_setup_url (for 1.1) or reporting
|
|
||||||
# mode 'setup_needed' (for 2.0). Also catching all modes other than
|
|
||||||
# id_res, in order to avoid throwing errors.
|
|
||||||
if(isset($this->data['openid_user_setup_url'])) {
|
|
||||||
$this->setup_url = $this->data['openid_user_setup_url'];
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if($this->mode != 'id_res') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->claimed_id = isset($this->data['openid_claimed_id'])?$this->data['openid_claimed_id']:$this->data['openid_identity'];
|
|
||||||
$params = array(
|
|
||||||
'openid.assoc_handle' => $this->data['openid_assoc_handle'],
|
|
||||||
'openid.signed' => $this->data['openid_signed'],
|
|
||||||
'openid.sig' => $this->data['openid_sig'],
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isset($this->data['openid_ns'])) {
|
|
||||||
# We're dealing with an OpenID 2.0 server, so let's set an ns
|
|
||||||
# Even though we should know location of the endpoint,
|
|
||||||
# we still need to verify it by discovery, so $server is not set here
|
|
||||||
$params['openid.ns'] = 'http://specs.openid.net/auth/2.0';
|
|
||||||
} elseif (isset($this->data['openid_claimed_id'])
|
|
||||||
&& $this->data['openid_claimed_id'] != $this->data['openid_identity']
|
|
||||||
) {
|
|
||||||
# If it's an OpenID 1 provider, and we've got claimed_id,
|
|
||||||
# we have to append it to the returnUrl, like authUrl_v1 does.
|
|
||||||
$this->returnUrl .= (strpos($this->returnUrl, '?') ? '&' : '?')
|
|
||||||
. 'openid.claimed_id=' . $this->claimed_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->data['openid_return_to'] != $this->returnUrl) {
|
|
||||||
# The return_to url must match the url of current request.
|
|
||||||
# I'm assuing that noone will set the returnUrl to something that doesn't make sense.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$server = $this->discover($this->claimed_id);
|
|
||||||
|
|
||||||
foreach (explode(',', $this->data['openid_signed']) as $item) {
|
|
||||||
# Checking whether magic_quotes_gpc is turned on, because
|
|
||||||
# the function may fail if it is. For example, when fetching
|
|
||||||
# AX namePerson, it might containg an apostrophe, which will be escaped.
|
|
||||||
# In such case, validation would fail, since we'd send different data than OP
|
|
||||||
# wants to verify. stripslashes() should solve that problem, but we can't
|
|
||||||
# use it when magic_quotes is off.
|
|
||||||
$value = $this->data['openid_' . str_replace('.','_',$item)];
|
|
||||||
$params['openid.' . $item] = get_magic_quotes_gpc() ? stripslashes($value) : $value;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$params['openid.mode'] = 'check_authentication';
|
|
||||||
|
|
||||||
$response = $this->request($server, 'POST', $params);
|
|
||||||
|
|
||||||
return preg_match('/is_valid\s*:\s*true/i', $response);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getAxAttributes()
|
|
||||||
{
|
|
||||||
$alias = null;
|
|
||||||
if (isset($this->data['openid_ns_ax'])
|
|
||||||
&& $this->data['openid_ns_ax'] != 'http://openid.net/srv/ax/1.0'
|
|
||||||
) { # It's the most likely case, so we'll check it before
|
|
||||||
$alias = 'ax';
|
|
||||||
} else {
|
|
||||||
# 'ax' prefix is either undefined, or points to another extension,
|
|
||||||
# so we search for another prefix
|
|
||||||
foreach ($this->data as $key => $val) {
|
|
||||||
if (substr($key, 0, strlen('openid_ns_')) == 'openid_ns_'
|
|
||||||
&& $val == 'http://openid.net/srv/ax/1.0'
|
|
||||||
) {
|
|
||||||
$alias = substr($key, strlen('openid_ns_'));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!$alias) {
|
|
||||||
# An alias for AX schema has not been found,
|
|
||||||
# so there is no AX data in the OP's response
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$attributes = array();
|
|
||||||
foreach ($this->data as $key => $value) {
|
|
||||||
$keyMatch = 'openid_' . $alias . '_value_';
|
|
||||||
if (substr($key, 0, strlen($keyMatch)) != $keyMatch) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$key = substr($key, strlen($keyMatch));
|
|
||||||
if (!isset($this->data['openid_' . $alias . '_type_' . $key])) {
|
|
||||||
# OP is breaking the spec by returning a field without
|
|
||||||
# associated ns. This shouldn't happen, but it's better
|
|
||||||
# to check, than cause an E_NOTICE.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$key = substr($this->data['openid_' . $alias . '_type_' . $key],
|
|
||||||
strlen('http://axschema.org/'));
|
|
||||||
$attributes[$key] = $value;
|
|
||||||
}
|
|
||||||
return $attributes;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getSregAttributes()
|
|
||||||
{
|
|
||||||
$attributes = array();
|
|
||||||
$sreg_to_ax = array_flip(self::$ax_to_sreg);
|
|
||||||
foreach ($this->data as $key => $value) {
|
|
||||||
$keyMatch = 'openid_sreg_';
|
|
||||||
if (substr($key, 0, strlen($keyMatch)) != $keyMatch) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$key = substr($key, strlen($keyMatch));
|
|
||||||
if (!isset($sreg_to_ax[$key])) {
|
|
||||||
# The field name isn't part of the SREG spec, so we ignore it.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$attributes[$sreg_to_ax[$key]] = $value;
|
|
||||||
}
|
|
||||||
return $attributes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets AX/SREG attributes provided by OP. should be used only after successful validaton.
|
|
||||||
* Note that it does not guarantee that any of the required/optional parameters will be present,
|
|
||||||
* or that there will be no other attributes besides those specified.
|
|
||||||
* In other words. OP may provide whatever information it wants to.
|
|
||||||
* * SREG names will be mapped to AX names.
|
|
||||||
* * @return Array Array of attributes with keys being the AX schema names, e.g. 'contact/email'
|
|
||||||
* @see http://www.axschema.org/types/
|
|
||||||
*/
|
|
||||||
function getAttributes()
|
|
||||||
{
|
|
||||||
if (isset($this->data['openid_ns'])
|
|
||||||
&& $this->data['openid_ns'] == 'http://specs.openid.net/auth/2.0'
|
|
||||||
) { # OpenID 2.0
|
|
||||||
# We search for both AX and SREG attributes, with AX taking precedence.
|
|
||||||
return $this->getAxAttributes() + $this->getSregAttributes();
|
|
||||||
}
|
|
||||||
return $this->getSregAttributes();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
/* Pretty printing styles. Used with prettify.js. */
|
|
||||||
|
|
||||||
.str { color: #080; }
|
|
||||||
.kwd { color: #008; }
|
|
||||||
.com { color: #800; }
|
|
||||||
.typ { color: #606; }
|
|
||||||
.lit { color: #066; }
|
|
||||||
.pun { color: #660; }
|
|
||||||
.pln { color: #000; }
|
|
||||||
.tag { color: #008; }
|
|
||||||
.atn { color: #606; }
|
|
||||||
.atv { color: #080; }
|
|
||||||
.dec { color: #606; }
|
|
||||||
pre.prettyprint { padding: 0px; border: 1px solid #888; clear: both; }
|
|
||||||
|
|
||||||
/* Specify class=linenums on a pre to get line numbering */
|
|
||||||
ol.linenums { margin-top: 0; margin-bottom: 0; margin-left: 30px} /* IE indents via margin-left */
|
|
||||||
li.L0,
|
|
||||||
li.L1,
|
|
||||||
li.L2,
|
|
||||||
li.L3,
|
|
||||||
li.L5,
|
|
||||||
li.L6,
|
|
||||||
li.L7,
|
|
||||||
li.L8 { list-style-type: none }
|
|
||||||
/* Alternate shading for lines */
|
|
||||||
li.L1,
|
|
||||||
li.L3,
|
|
||||||
li.L5,
|
|
||||||
li.L7,
|
|
||||||
li.L9 { background: #eee }
|
|
||||||
|
|
||||||
@media print {
|
|
||||||
.str { color: #060; }
|
|
||||||
.kwd { color: #006; font-weight: bold; }
|
|
||||||
.com { color: #600; font-style: italic; }
|
|
||||||
.typ { color: #404; font-weight: bold; }
|
|
||||||
.lit { color: #044; }
|
|
||||||
.pun { color: #440; }
|
|
||||||
.pln { color: #000; }
|
|
||||||
.tag { color: #006; font-weight: bold; }
|
|
||||||
.atn { color: #404; }
|
|
||||||
.atv { color: #060; }
|
|
||||||
}
|
|
1408
src/prettify.js
@ -1,53 +0,0 @@
|
|||||||
div pre , .prettyprint {
|
|
||||||
color: #839496;
|
|
||||||
background-color: #002b36;
|
|
||||||
}
|
|
||||||
|
|
||||||
.prettyprint .pln {
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.prettyprint .str,
|
|
||||||
.prettyprint .lit,
|
|
||||||
.prettyprint .atv {
|
|
||||||
color: #2aa198;
|
|
||||||
}
|
|
||||||
|
|
||||||
.prettyprint .kwd {
|
|
||||||
/* color: #268bd2; */
|
|
||||||
color: #859900;
|
|
||||||
}
|
|
||||||
|
|
||||||
.prettyprint .com {
|
|
||||||
color: #586e75;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
.prettyprint .dec {
|
|
||||||
color: #cb4b16;
|
|
||||||
}
|
|
||||||
|
|
||||||
.prettyprint .typ {
|
|
||||||
color: #b58900;
|
|
||||||
}
|
|
||||||
|
|
||||||
.prettyprint .pun {
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.prettyprint .opn {
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.prettyprint .clo {
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.prettyprint .tag {
|
|
||||||
color: #268bd2;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.prettyprint .atn {
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
/* Pretty printing styles. Used with prettify.js. */
|
|
||||||
/* Vim sunburst theme by David Leibovic */
|
|
||||||
|
|
||||||
pre .str, code .str { color: #65B042; } /* string - green */
|
|
||||||
pre .kwd, code .kwd { color: #E28964; } /* keyword - dark pink */
|
|
||||||
pre .com, code .com { color: #AEAEAE; font-style: italic; } /* comment - gray */
|
|
||||||
pre .typ, code .typ { color: #89bdff; } /* type - light blue */
|
|
||||||
pre .lit, code .lit { color: #3387CC; } /* literal - blue */
|
|
||||||
pre .pun, code .pun { color: #fff; } /* punctuation - white */
|
|
||||||
pre .pln, code .pln { color: #fff; } /* plaintext - white */
|
|
||||||
pre .tag, code .tag { color: #89bdff; } /* html/xml tag - light blue */
|
|
||||||
pre .atn, code .atn { color: #bdb76b; } /* html/xml attribute name - khaki */
|
|
||||||
pre .atv, code .atv { color: #65B042; } /* html/xml attribute value - green */
|
|
||||||
pre .dec, code .dec { color: #3387CC; } /* decimal - blue */
|
|
||||||
|
|
||||||
pre.prettyprint, code.prettyprint{
|
|
||||||
background-color: #000;
|
|
||||||
-moz-border-radius: 8px;
|
|
||||||
-webkit-border-radius: 8px;
|
|
||||||
-o-border-radius: 8px;
|
|
||||||
-ms-border-radius: 8px;
|
|
||||||
-khtml-border-radius: 8px;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
pre.prettyprint {
|
|
||||||
width: 95%;
|
|
||||||
margin: 1em auto;
|
|
||||||
padding: 1em;
|
|
||||||
clear: both
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Specify class=linenums on a pre to get line numbering */
|
|
||||||
ol.linenums { margin-top: 0; margin-bottom: 0; color: #AEAEAE; } /* IE indents via margin-left */
|
|
||||||
li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8 { list-style-type: none }
|
|
||||||
/* Alternate shading for lines */
|
|
||||||
li.L1,li.L3,li.L5,li.L7,li.L9 { }
|
|
||||||
|
|
||||||
@media print {
|
|
||||||
pre .str, code .str { color: #060; }
|
|
||||||
pre .kwd, code .kwd { color: #006; font-weight: bold; }
|
|
||||||
pre .com, code .com { color: #600; font-style: italic; }
|
|
||||||
pre .typ, code .typ { color: #404; font-weight: bold; }
|
|
||||||
pre .lit, code .lit { color: #044; }
|
|
||||||
pre .pun, code .pun { color: #440; }
|
|
||||||
pre .pln, code .pln { color: #000; }
|
|
||||||
pre .tag, code .tag { color: #006; font-weight: bold; }
|
|
||||||
pre .atn, code .atn { color: #404; }
|
|
||||||
pre .atv, code .atv { color: #060; }
|
|
||||||
}
|
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 534 KiB After Width: | Height: | Size: 534 KiB |
Before Width: | Height: | Size: 534 KiB After Width: | Height: | Size: 534 KiB |
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 132 KiB |
Before Width: | Height: | Size: 314 KiB After Width: | Height: | Size: 314 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 533 KiB After Width: | Height: | Size: 533 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 470 KiB After Width: | Height: | Size: 470 KiB |
Before Width: | Height: | Size: 529 KiB After Width: | Height: | Size: 529 KiB |
Before Width: | Height: | Size: 533 KiB After Width: | Height: | Size: 533 KiB |
Before Width: | Height: | Size: 592 KiB After Width: | Height: | Size: 592 KiB |
Before Width: | Height: | Size: 575 KiB After Width: | Height: | Size: 575 KiB |
Before Width: | Height: | Size: 139 KiB After Width: | Height: | Size: 139 KiB |
Before Width: | Height: | Size: 306 KiB After Width: | Height: | Size: 306 KiB |
Before Width: | Height: | Size: 150 KiB After Width: | Height: | Size: 150 KiB |
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 9.0 KiB |
Before Width: | Height: | Size: 151 KiB After Width: | Height: | Size: 151 KiB |
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 157 KiB After Width: | Height: | Size: 157 KiB |
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 722 KiB After Width: | Height: | Size: 722 KiB |
Before Width: | Height: | Size: 147 KiB After Width: | Height: | Size: 147 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 143 KiB After Width: | Height: | Size: 143 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 174 KiB After Width: | Height: | Size: 174 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 419 KiB After Width: | Height: | Size: 419 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 548 KiB After Width: | Height: | Size: 548 KiB |
Before Width: | Height: | Size: 551 KiB After Width: | Height: | Size: 551 KiB |
Before Width: | Height: | Size: 583 KiB After Width: | Height: | Size: 583 KiB |
Before Width: | Height: | Size: 572 KiB After Width: | Height: | Size: 572 KiB |
@ -1,3 +1,4 @@
|
|||||||
|
.codehilite pre {background-color: #002b36;}
|
||||||
/* Text */
|
/* Text */
|
||||||
.codehilite .t { color: #586e75 }
|
.codehilite .t { color: #586e75 }
|
||||||
|
|
Before Width: | Height: | Size: 969 KiB After Width: | Height: | Size: 969 KiB |
@ -5,43 +5,13 @@
|
|||||||
<title>
|
<title>
|
||||||
Thomas Lovén - {% if page %}{{ page.title }}{% endif %}
|
Thomas Lovén - {% if page %}{{ page.title }}{% endif %}
|
||||||
</title>
|
</title>
|
||||||
<link rel="stylesheet" type="text/css" href="/src/solarized.css">
|
|
||||||
<link rel="stylesheet" type="text/css" href="/src/fonts/dejavuserif/stylesheet.css">
|
<link rel="stylesheet" type="text/css" href="/src/fonts/dejavuserif/stylesheet.css">
|
||||||
<link rel="stylesheet" type="text/css" href="/src/style.css">
|
<link rel="stylesheet" type="text/css" href="/src/style.css">
|
||||||
<link rel="stylesheet" type="text/css" href="/src/site-solarized.css">
|
<link rel="stylesheet" type="text/css" href="/src/site-solarized.css">
|
||||||
<link rel="stylesheet" type="text/css" href="/src/codestyle.css">
|
<link rel="stylesheet" type="text/css" href="/src/codestyle.css">
|
||||||
|
|
||||||
<!-- <script type="text/javascript" src="/src/prettify.js"></script> -->
|
|
||||||
<!-- <script type="text/javascript" src="/src/lang-tex.js"></script> -->
|
|
||||||
<!-- <script type="text/javascript" src="/src/lang-nasm.js"></script> -->
|
|
||||||
<!-- <script type="text/javascript" src="/src/lang-betyg.js"></script> -->
|
|
||||||
|
|
||||||
<!-- <script type="text/x-mathjax-config"> -->
|
|
||||||
<!-- MathJax.Hub.Config({ -->
|
|
||||||
<!-- tex2jax: { -->
|
|
||||||
<!-- skipTags: ["script","noscript","style","textarea","code"], -->
|
|
||||||
<!-- ignoreClass: ".*", -->
|
|
||||||
<!-- processClass: "latex" -->
|
|
||||||
<!-- } -->
|
|
||||||
<!-- }); -->
|
|
||||||
<!-- MathJax.Hub.Queue( function() { -->
|
|
||||||
<!-- var all = MathJax.Hub.getAllJax(), i; -->
|
|
||||||
<!-- for(i=0; i < all.length; i += 1) { -->
|
|
||||||
<!-- all[i].SourceElement().parentNode.className += ' has-jax'; -->
|
|
||||||
<!-- } -->
|
|
||||||
<!-- }); -->
|
|
||||||
<!-- </script> -->
|
|
||||||
<!-- <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script> -->
|
|
||||||
|
|
||||||
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
|
|
||||||
|
|
||||||
<script src="/src/blankwin.js" type="text/javascript"></script>
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<!-- <body onload="$('pre').not('.nopretty').not('.latex').addClass('prettyprint'); prettyPrint(); blankwin(); $('body').width($('body').width()+1).width('auto')"> -->
|
<body>
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="wrap">
|
<div id="wrap">
|
||||||
<div id="header">
|
<div id="header">
|
||||||
<div id="title">
|
<div id="title">
|
||||||
@ -49,12 +19,8 @@
|
|||||||
</div><!--title-->
|
</div><!--title-->
|
||||||
<div id="links">
|
<div id="links">
|
||||||
<a href="/">Home</a>
|
<a href="/">Home</a>
|
||||||
-
|
- <a href="/blog/">Blog</a>
|
||||||
<a href="/blog/">Blog</a>
|
- <a href="/about/">About</a>
|
||||||
-
|
|
||||||
<a href="/photos/">Photos</a>
|
|
||||||
-
|
|
||||||
<a href="/about/">About</a>
|
|
||||||
</div><!--links-->
|
</div><!--links-->
|
||||||
</div><!--header-->
|
</div><!--header-->
|
||||||
|
|
||||||
@ -75,6 +41,13 @@
|
|||||||
<a href="http://github.com/thomasloven">GitHub</a>
|
<a href="http://github.com/thomasloven">GitHub</a>
|
||||||
</div><!--bottom-->
|
</div><!--bottom-->
|
||||||
|
|
||||||
|
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
|
||||||
</body>
|
<script src="/src/blankwin.js" type="text/javascript"></script>
|
||||||
|
<script>
|
||||||
|
blankwin();
|
||||||
|
$('body').width($('body').width()+1).width('auto');
|
||||||
|
</script>
|
||||||
|
{% block morescripts %}
|
||||||
|
{% endblock morescripts %}
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
{% extends "base.html" %}
|
|
||||||
|
|
||||||
{% block page %}
|
|
||||||
<div id="categories">
|
|
||||||
{% if title %}
|
|
||||||
<a href="{{url_for("blog_default")}}">All</a>
|
|
||||||
{% else %}
|
|
||||||
All
|
|
||||||
{% endif %}
|
|
||||||
{% for tag in tags %}
|
|
||||||
{% if tag == title %}
|
|
||||||
-
|
|
||||||
{{ tag }}
|
|
||||||
{% else %}
|
|
||||||
-
|
|
||||||
<a href="{{url_for("tag", tag=tag)}}">{{ tag }}</a>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
<div class="content">
|
|
||||||
<ol class="content-list">
|
|
||||||
{% for post in posts %}
|
|
||||||
<li class="content">
|
|
||||||
<h3 class="postTitle"><a href="{{ post.url }}">{{ post.title }}</a></h3><p class="postDate">{{ post.datestr }}</p><p class="postSubTitle">{{ post.subtitle }}<br>
|
|
||||||
<a href="{{ post.url }}#disqus_thread" data-disqus-identifier="{{ post.url[:-1] }}"></a></p>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ol>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
|
|
||||||
var disqus_shortname = 'thomasloven'; // required: replace example with your forum shortname
|
|
||||||
|
|
||||||
/* * * DON'T EDIT BELOW THIS LINE * * */
|
|
||||||
(function () {
|
|
||||||
var s = document.createElement('script'); s.async = true;
|
|
||||||
s.type = 'text/javascript';
|
|
||||||
s.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
|
|
||||||
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
|
|
||||||
}());
|
|
||||||
</script>
|
|
||||||
{% endblock page %}
|
|
43
templates/blog_listing.html
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block page %}
|
||||||
|
<div id="categories">
|
||||||
|
{% if title %}
|
||||||
|
<a href="{{url_for("blog_listing")}}">All</a>
|
||||||
|
{% else %}
|
||||||
|
All
|
||||||
|
{% endif %}
|
||||||
|
{% for tag in tags %}
|
||||||
|
{% if tag == title %}
|
||||||
|
- {{ tag }}
|
||||||
|
{% else %}
|
||||||
|
- <a href="{{url_for("blog_listing", tag=tag)}}">{{ tag }}</a>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<ol class="content-list">
|
||||||
|
{% for post in posts %}
|
||||||
|
<li class="content">
|
||||||
|
<h3 class="postTitle"><a href="{{ url_for("permalink",
|
||||||
|
path=post.url) }}">{{ post.title }}</a></h3><p class="postDate">{{ post.datestr }}</p><p class="postSubTitle">{{ post.subtitle }}<br>
|
||||||
|
<a href="{{ post.url }}#disqus_thread" data-disqus-identifier="{{ post.url[:-1] }}"></a></p>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
{% endblock page %}
|
||||||
|
|
||||||
|
{% block morescripts %}
|
||||||
|
<script type="text/javascript">
|
||||||
|
var disqus_shortname = 'thomasloven';
|
||||||
|
|
||||||
|
/* * * DON'T EDIT BELOW THIS LINE * * */
|
||||||
|
(function () {
|
||||||
|
var s = document.createElement('script'); s.async = true;
|
||||||
|
s.type = 'text/javascript';
|
||||||
|
s.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
|
||||||
|
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
|
||||||
|
}());
|
||||||
|
</script>
|
||||||
|
{% endblock morescripts %}
|
28
templates/blog_post.html
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block page %}
|
||||||
|
<h1> {{ page.title }} </h1>
|
||||||
|
<div id="subtitle">
|
||||||
|
<p>{{ page.datestr }}</p>
|
||||||
|
</div>
|
||||||
|
<div id="post-text">
|
||||||
|
{{ page }}
|
||||||
|
<h2 id="comment">Comments</h2>
|
||||||
|
<div id="disqus_thread"></div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
|
||||||
|
var disqus_shortname = 'thomasloven'; // required: replace example with your forum shortname
|
||||||
|
var disqus_identifier = '{{ page.url[:-1] }}';
|
||||||
|
|
||||||
|
/* * * DON'T EDIT BELOW THIS LINE * * */
|
||||||
|
(function() {
|
||||||
|
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
||||||
|
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
|
||||||
|
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
|
||||||
|
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endblock page %}
|
@ -1,28 +0,0 @@
|
|||||||
{% extends "base.html" %}
|
|
||||||
|
|
||||||
{% block page %}
|
|
||||||
<h1> {{ page.title }} </h1>
|
|
||||||
<div id="subtitle">
|
|
||||||
<p>{{ page.datestr }}</p>
|
|
||||||
</div>
|
|
||||||
<div id="post-text">
|
|
||||||
{{ page }}
|
|
||||||
<h2 id="comment">Comments</h2>
|
|
||||||
<div id="disqus_thread"></div>
|
|
||||||
<script type="text/javascript">
|
|
||||||
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
|
|
||||||
var disqus_shortname = 'thomasloven'; // required: replace example with your forum shortname
|
|
||||||
var disqus_identifier = '{{ page.url[:-1] }}';
|
|
||||||
|
|
||||||
/* * * DON'T EDIT BELOW THIS LINE * * */
|
|
||||||
(function() {
|
|
||||||
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
|
||||||
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
|
|
||||||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
|
|
||||||
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
{% endblock page %}
|
|