Skip to content

Commit

Permalink
Merge pull request #3 from lhagan/master
Browse files Browse the repository at this point in the history
Improved wiki & theme modularity
  • Loading branch information
rcarmo committed Nov 25, 2011
2 parents c86b9c8 + 5e153e7 commit 9b60788
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 183 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,6 +6,7 @@ yaki/var/log/*
yaki/var/index/*
yaki/var/cache/*
yaki/var/log/*
yaki/var/Yaki*
yaki/tmp/*


Expand Down
2 changes: 0 additions & 2 deletions web/main/index.y

This file was deleted.

File renamed without changes.
File renamed without changes.
140 changes: 0 additions & 140 deletions web/main/themes/bootstrap/home.y

This file was deleted.

35 changes: 19 additions & 16 deletions web/main/themes/bootstrap/index.y
Expand Up @@ -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>
Expand All @@ -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 {
Expand Down Expand Up @@ -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>
Expand All @@ -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>
Expand Down
8 changes: 7 additions & 1 deletion yaki/userlibs/yaki/Engine.py
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -538,3 +543,4 @@ def checkRedirects(self, appcontext, page):
if cmp(redirect,page):
return redirect
return None

3 changes: 1 addition & 2 deletions yaki/userlibs/yaki/Feeds.py
Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down
7 changes: 4 additions & 3 deletions yaki/userlibs/yaki/Plugins/Journal.py
Expand Up @@ -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"

Expand Down Expand Up @@ -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():
Expand Down
23 changes: 23 additions & 0 deletions yaki/userlibs/yaki/Redirect.py
@@ -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
3 changes: 0 additions & 3 deletions yaki/userlibs/yaki/Utils.py
Expand Up @@ -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
#
Expand Down

0 comments on commit 9b60788

Please sign in to comment.