Permalink
Browse files

Merge pull request #3 from lhagan/master

Improved wiki & theme modularity
  • Loading branch information...
2 parents c86b9c8 + 5e153e7 commit 9b607884151518a2dbb16b9ae2de518de8831076 @rcarmo committed Nov 25, 2011
View
@@ -6,6 +6,7 @@ yaki/var/log/*
yaki/var/index/*
yaki/var/cache/*
yaki/var/log/*
+yaki/var/Yaki*
yaki/tmp/*
View
@@ -1,2 +0,0 @@
-<%@allowcaching=yes%>
-<%$httpredirect="p/start"%>
@@ -1,140 +0,0 @@
-<%@outputencoding="UTF-8"%>
-<%@inputencoding="UTF-8"%>
-<%@session=dontcreate%>
-<%
-import time
-import datetime
-self.setHeader("Last-Modified",self.Request.getParameter('lastmodified',''))
-self.setHeader("Etag", self.Request.getParameter('etag',''))
-self.setHeader("Cache-Control", self.Request.getParameter('cachecontrol','public, max-age=86400'))
-self.setHeader("Expires", self.Request.getParameter('expires',(datetime.datetime.utcnow() + datetime.timedelta(seconds=3600*24*30)).strftime('%a, %d %b %Y %H:%M:%S GMT')))
-#unset these headers to force browsers to rely on Last-Modified and etag
-ac = self.ApplicationCtx
-%>
-<% self.Assetprefix = 'themes/bootstrap/' %>
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title><%=self.Request.getParameter('title','Untitled Page')%> - <%=ac.siteinfo['sitename']%></title>
- <meta name="keywords" content="<%=self.Request.getParameter('keywords','')%>" />
- <meta name="description" content="">
- <meta name="author" content="">
-
- <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
- <!--[if lt IE 9]>
- <script src="/themes/bootstrap/js/html5.js"></script>
- <![endif]-->
-
- <!-- Le styles -->
- <link href="/themes/bootstrap/css/bootstrap.css" rel="stylesheet">
- <link href="/themes/bootstrap/css/syntax.css" rel="stylesheet">
- <style type="text/css">
- /* Override some defaults */
- html, body {
- background-color: #eee;
- }
- body {
- padding-top: 40px; /* 40px to make the container go all the way to the bottom of the topbar */
- }
- .container > footer p {
- text-align: center; /* center align it with the container */
- }
- .container {
- width: 820px; /* downsize our container to make the content feel a bit tighter and more cohesive. NOTE: this removes two full columns from the grid, meaning you only go to 14 columns and not 16. */
- }
-
- /* The white background content wrapper */
- .content {
- background-color: #fff;
- padding: 20px;
- margin: 0 -20px; /* negative indent the amount of the padding to maintain the grid system */
- -webkit-border-radius: 0 0 6px 6px;
- -moz-border-radius: 0 0 6px 6px;
- border-radius: 0 0 6px 6px;
- -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.15);
- -moz-box-shadow: 0 1px 2px rgba(0,0,0,.15);
- box-shadow: 0 1px 2px rgba(0,0,0,.15);
- }
-
- /* Page header tweaks */
- .page-header {
- background-color: #f5f5f5;
- padding: 20px 20px 10px;
- margin: -20px -20px 20px;
- }
-
- /* Styles you shouldn't keep as they are for displaying this base example only */
- .content .span10,
- .content .span4 {
- min-height: 500px;
- }
- /* Give a quick and non-cross-browser friendly divider */
- .content .span4 {
- margin-left: 0;
- padding-left: 19px;
- border-left: 1px solid #eee;
- }
-
- .topbar .btn {
- border: 0;
- }
-
- </style>
-
- <!-- Le fav and touch icons -->
- <link rel="shortcut icon" href="/themes/bootstrap/img/favicon.ico">
- <link rel="apple-touch-icon" href="/themes/bootstrap/img/bootstrap-apple-57x57.png">
- <link rel="apple-touch-icon" sizes="72x72" href="/themes/bootstrap/img/bootstrap-apple-72x72.png">
- <link rel="apple-touch-icon" sizes="114x114" href="/themes/bootstrap/img/bootstrap-apple-114x114.png">
- </head>
-
- <body>
-
- <div class="topbar">
- <div class="fill">
- <div class="container">
- <a class="brand" href="/p/start"><%=ac.siteinfo['sitename']%></a>
- <ul class="nav">
- <li class="active"><a href="/p/start">Home</a></li>
- <li><a href="/p/site/about">About</a></li>
- </ul>
- <form action="/p/meta/Search" method="get" accept-charset="utf-8" class="pull-right">
- <input class="input-small" name="q" type="text" placeholder="Search">
- <button class="btn" type="submit">Go</button>
- </form>
- </div>
- </div>
- </div>
-
- <div class="container">
-
- <div class="content">
- <div class="page-header">
- <h1><%=self.Request.getParameter('title','Untitled Page')%>
- <small><!-- TODO: add metadata here --></small></h1>
- </div>
- <div class="row">
- <div class="span10">
- <%=self.Request.getParameter('postbody','')%>
- </div>
- <div class="span4">
- <h3>Links</h3>
- <ul>
- <li><a href="/p/meta/Archives">Archives</a></li>
- <li><a href="/p/meta/Index">Index</a></li>
- <li><a href="/p/meta/RecentUpdates">Recent Updates</a></li>
- </ul>
- </div>
- </div>
- </div>
-
- <footer>
- <p>Powered by <a href="https://github.com/rcarmo/Yaki">Yaki</a>. Themed by <a href="http://twitter.github.com/bootstrap/">Bootstrap</a>. Batteries included.</p>
- </footer>
-
- </div> <!-- /container -->
-
- </body>
-</html>
@@ -11,7 +11,7 @@ self.setHeader("Expires", self.Request.getParameter('expires',(datetime.datetime
#unset these headers to force browsers to rely on Last-Modified and etag
ac = self.ApplicationCtx
%>
-<% self.Assetprefix = 'themes/bootstrap/' %>
+<% self.Assetprefix = 'theme/%s/' % self.Request.getParameter('theme', '') %>
<!DOCTYPE html>
<html lang="en">
<head>
@@ -24,12 +24,12 @@ ac = self.ApplicationCtx
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
- <script src="/themes/bootstrap/js/html5.js"></script>
+ <script src="/themes/<%=self.Request.getParameter('theme', '')%>/js/html5.js"></script>
<![endif]-->
<!-- Le styles -->
- <link href="/themes/bootstrap/css/bootstrap.css" rel="stylesheet">
- <link href="/themes/bootstrap/css/syntax.css" rel="stylesheet">
+ <link href="/themes/<%=self.Request.getParameter('theme', '')%>/css/style.css" rel="stylesheet">
+ <link href="/themes/<%=self.Request.getParameter('theme', '')%>/css/syntax.css" rel="stylesheet">
<style type="text/css">
/* Override some defaults */
html, body {
@@ -84,23 +84,23 @@ ac = self.ApplicationCtx
</style>
<!-- Le fav and touch icons -->
- <link rel="shortcut icon" href="/themes/bootstrap/img/favicon.ico">
- <link rel="apple-touch-icon" href="/themes/bootstrap/img/bootstrap-apple-57x57.png">
- <link rel="apple-touch-icon" sizes="72x72" href="/themes/bootstrap/img/bootstrap-apple-72x72.png">
- <link rel="apple-touch-icon" sizes="114x114" href="/themes/bootstrap/img/bootstrap-apple-114x114.png">
+ <link rel="shortcut icon" href="/themes/<%=self.Request.getParameter('theme', '')%>/img/favicon.ico">
+ <link rel="apple-touch-icon" href="/themes/<%=self.Request.getParameter('theme', '')%>/img/apple-touch-icon-57x57.png">
+ <link rel="apple-touch-icon" sizes="72x72" href="/themes/<%=self.Request.getParameter('theme', '')%>/img/apple-touch-icon-72x72.png">
+ <link rel="apple-touch-icon" sizes="114x114" href="/themes/<%=self.Request.getParameter('theme', '')%>/img/apple-touch-icon-114x114.png">
</head>
<body>
<div class="topbar">
<div class="fill">
<div class="container">
- <a class="brand" href="/p/start"><%=ac.siteinfo['sitename']%></a>
+ <a class="brand" href="/<%=self.Request.getParameter('siteroot', '')%>/start"><%=ac.siteinfo['sitename']%></a>
<ul class="nav">
- <li class="active"><a href="/p/start">Home</a></li>
- <li><a href="/p/site/about">About</a></li>
+ <li class="active"><a href="/<%=self.Request.getParameter('siteroot', '')%>/start">Home</a></li>
+ <li><a href="/<%=self.Request.getParameter('siteroot', '')%>/site/about">About</a></li>
</ul>
- <form action="/p/meta/Search" method="get" accept-charset="utf-8" class="pull-right">
+ <form action="/<%=self.Request.getParameter('siteroot', '')%>/meta/Search" method="get" accept-charset="utf-8" class="pull-right">
<input class="input-small" name="q" type="text" placeholder="Search">
<button class="btn" type="submit">Go</button>
</form>
@@ -122,13 +122,16 @@ ac = self.ApplicationCtx
<div class="span4">
<h3>Links</h3>
<ul>
- <li><a href="/p/meta/Archives">Archives</a></li>
- <li><a href="/p/meta/Index">Index</a></li>
- <li><a href="/p/meta/RecentUpdates">Recent Updates</a></li>
+ <li><a href="/<%=self.Request.getParameter('siteroot', '')%>/meta/Archives">Archives</a></li>
+ <li><a href="/<%=self.Request.getParameter('siteroot', '')%>/meta/Index">Index</a></li>
+ <li><a href="/<%=self.Request.getParameter('siteroot', '')%>/meta/RecentUpdates">Recent Updates</a></li>
</ul>
</div>
<div class="span14">
- <%=self.Request.getParameter('seealso','')%>
+ <%
+ if self.Request.getParameter('path', '') != "home":
+ self.write( '%s' % self.Request.getParameter('seealso',''))
+ %>
</div>
</div>
</div>
@@ -378,7 +378,7 @@ def serve(self, request, response):
link = rellink = permalink = plainpermalink = u"%s%s" % (ac.base, c.path)
description = self.i18n['permalink_description']
c.headers['bookmark'] = request.getBaseURL() + permalink
- if SANITIZE_TITLE_REGEX.match(c.path):
+ if re.compile('^(%s|links)' % ac.siteinfo['journal']).match(c.path):
permalink = permalink + u"#%s" % sanitizeTitle(c.title)
linkclass = "wikilink"
@@ -434,6 +434,11 @@ def serve(self, request, response):
c.postbody = ac.templates['generic'] % locals()
c.sitename = ac.siteinfo['sitename']
c.sitedescription = ac.siteinfo['sitedescription']
+
+ c.siteroot = ac.siteinfo['siteroot']
+ c.theme = ac.siteinfo['theme']
+ c.media = ac.siteinfo['media']
+
except Warning, e:
c.status = e.value
(c.headers, c.content) = self.getPage(request, response)
@@ -538,3 +543,4 @@ def checkRedirects(self, appcontext, page):
if cmp(redirect,page):
return redirect
return None
+
@@ -22,7 +22,6 @@
import simplejson as json
exclusions = ['^HomePage$','^meta.+']
-sanitize = re.compile('^(blog|links)')
def filtered(name,namespace,exclusions):
for pattern in exclusions:
@@ -163,7 +162,7 @@ def buildItems(self, recent, request):
else:
permalink = link = guid = self.baseurl + pagename.replace(' ','_')
- if SANITIZE_TITLE_REGEX.match(pagename):
+ if re.compile('^(%s|links)' % ac.siteinfo['journal']).match(pagename):
permalink = permalink + "#%s" % sanitizeTitle(title)
guid = ac.siteinfo['siteurl'].replace("http://","") + "." + hashlib.sha1(guid).hexdigest()
@@ -36,7 +36,7 @@ def run(self, serial, tag, tagname, pagename, soup, request, response):
except:
bound = 12
# filter for the namespaces to be shown on the home page
- mask = re.compile('^(blog|links|podcast)\/(\d+){4}\/(\d+){2}\/(\d+){2}.*')
+ mask = re.compile('^(%s|links|podcast)\/(\d+){4}\/(\d+){2}\/(\d+){2}.*' % ac.siteinfo['journal'])
# this is what entries ought to look like, ideally
canon = "0000/00/00/0000"
@@ -80,8 +80,9 @@ def run(self, serial, tag, tagname, pagename, soup, request, response):
linkclass = "wikilink"
posttitle = headers['title']
rellink = path
- permalink = headers['bookmark'] = request.getBaseURL() + rellink
- if SANITIZE_TITLE_REGEX.match(name):
+ #permalink = headers['bookmark'] = request.getBaseURL() + rellink
+ permalink = headers['bookmark'] = rellink
+ if re.compile('^(%s|links)' % ac.siteinfo['journal']).match(name):
permalink = permalink + "#%s" % sanitizeTitle(posttitle)
description = "permanent link to this entry"
if 'x-link' in headers.keys():
@@ -0,0 +1,23 @@
+from snakeserver.snakelet import Snakelet
+
+class Redirect(Snakelet):
+ """
+ Redirect to wiki home page (start).
+ TODO: achieve this in a more elegant way?
+ """
+ def getDescription(self):
+ return "Redirector"
+
+ def allowCaching(self):
+ return True
+
+ def requiresSession(self):
+ return self.SESSION_DONTCREATE
+
+ def serve(self, request, response):
+ request.setEncoding("UTF-8")
+ response.setEncoding("UTF-8")
+ a = request.getWebApp()
+ ac = a.getContext()
+ response.HTTPredirect("%s/start" % ac.siteinfo['siteroot'])
+ return
@@ -26,9 +26,6 @@
# regexp for matching caching headers
MAX_AGE_REGEX = re.compile('max-age(\s*)=(\s*)(\d+)')
-# regexp for sanitizing titles
-SANITIZE_TITLE_REGEX = re.compile('^(blog|links)')
-
#
# Date handling
#
Oops, something went wrong.

0 comments on commit 9b60788

Please sign in to comment.