Commits

Anonymous committed 5b564a3

Fixed authentication decorators, they now work after adding self to the arg list of decorator class

Comments (0)

Files changed (8)

 --
 
 INSERT INTO `articles` (`id_`, `url_id`, `title`, `tags`, `author`, `timestamp`, `content`, `comment_count`, `ip`, `active`) VALUES
-(1, 'welcome-to-point-blank', 'Welcome to Point-blank', 'announcements, help', '', '1275674040', 'Congrats on getting Point-blank up and running. Now just login (to the right) with the credentials you supplied in `config.rc`. Once logged in, you''ll be able to delete this article and create new ones from this page.\r\n\r\nWhat is Point-blank?\r\n--------------------\r\n\r\nPoint-blank is a content management system written in Python. It uses [web.py](#) for its framework and [Storm](#) for the ORM. It is intentionally minimal. Some of the benefits of Point-blank are:\r\n\r\n1. Simple to setup\r\n2. Simple to use (intuitive, uses Markdown text)\r\n3. Minimalistic, small size\r\n5. In-line, in-your-face administration.\r\n6. Portable (can be used on any WSGI server, selection of database types)\r\n\r\nPoint-blank is essentially an extremely lightweight blog mixed with a very simple wiki system. If you want to add static pages/content to your website, you need to create a page in `static/pages/` with the filename as the name of the page. There is a demo page included: [preview it and delete it if you want](#). Remember that while you can type in HTML, Markdown is also accepted as input. I suggest learning the [Markdown syntax](http://en.wikipedia.org/wiki/Markdown#Syntax_examples) to type faster and easier.\r\n\r\nChanging the default template\r\n-----------------------------\r\n\r\nFirst, you''ll probably going to want to modify the default template. You can find these in the `templates/` directory, and any CSS/JS/images can be edited in the `static/` directory. Before making any serious modifications to these templates, skim through and see how these templates are constructed. For example, it''s important to note that *all paths must include `$site_vars[''base_url'']` before the rest of the location.* This will be replaced with something like `http://example.com/`.\r\n\r\nFor example, this is the template for the login form:\r\n\r\n	<link rel="stylesheet" type="text/css" href="$site_vars[''base_url'']static/css/_main.css" />\r\n\r\nFinally, if you want to be able to use the CSS/JS files as templates, you must place an underscore before its name, like `_main.css`.\r\n\r\n\r\nModifying the configuration\r\n----------------------------\r\n\r\nAny change to `config.rc` will require a server restart, or at least the termination of the WSGI program. This is very easy to overlook, so hopefully this reminder will save you some headaches.\r\n\r\n\r\nPoint-blank is open-source\r\n--------------------------\r\n\r\nPoint-blank is [Free Software](#) and is licensed under the GNU GPL. That means you can change this program and share it easily with your friends or users. You can read more about the GPL at the [FSF](#).\r\n\r\nIf you are a programmer, you can help me out by fixing bugs, cleaning up code, and making things more efficient. I gladly accept community branches into the main codebase at [Bitbucket](#).\r\n\r\n\r\n', 0, 'localhost', 1);
+(1, 'welcome-to-point-blank', 'Welcome to Point-blank', 'announcements, help', 'alecwh', '1275674040', 'Congrats on getting Point-blank up and running. Now just login (to the right) with the credentials you supplied in `config.rc`. Once logged in, you''ll be able to delete this article and create new ones from this page.\r\n\r\nWhat is Point-blank?\r\n--------------------\r\n\r\nPoint-blank is a content management system written in Python. It uses [web.py](#) for its framework and [Storm](#) for the ORM. It is intentionally minimal. Some of the benefits of Point-blank are:\r\n\r\n1. Simple to setup\r\n2. Simple to use (intuitive, uses Markdown text)\r\n3. Minimalistic, small size\r\n5. In-line, in-your-face administration.\r\n6. Portable (can be used on any WSGI server, selection of database types)\r\n\r\nPoint-blank is essentially an extremely lightweight blog mixed with a very simple wiki system. If you want to add static pages/content to your website, you need to create a page in `static/pages/` with the filename as the name of the page. There is a demo page included: [preview it and delete it if you want](#). Remember that while you can type in HTML, Markdown is also accepted as input. I suggest learning the [Markdown syntax](http://en.wikipedia.org/wiki/Markdown#Syntax_examples) to type faster and easier.\r\n\r\nChanging the default template\r\n-----------------------------\r\n\r\nFirst, you''ll probably going to want to modify the default template. You can find these in the `templates/` directory, and any CSS/JS/images can be edited in the `static/` directory. Before making any serious modifications to these templates, skim through and see how these templates are constructed. For example, it''s important to note that *all paths must include `$site_vars[''base_url'']` before the rest of the location.* This will be replaced with something like `http://example.com/`.\r\n\r\nFor example, this is the template for the login form:\r\n\r\n	<link rel="stylesheet" type="text/css" href="$site_vars[''base_url'']static/css/_main.css" />\r\n\r\nFinally, if you want to be able to use the CSS/JS files as templates, you must place an underscore before its name, like `_main.css`.\r\n\r\n\r\nModifying the configuration\r\n----------------------------\r\n\r\nAny change to `config.rc` will require a server restart, or at least the termination of the WSGI program. This is very easy to overlook, so hopefully this reminder will save you some headaches.\r\n\r\n\r\nPoint-blank is open-source\r\n--------------------------\r\n\r\nPoint-blank is [Free Software](#) and is licensed under the GNU GPL. That means you can change this program and share it easily with your friends or users. You can read more about the GPL at the [FSF](#).\r\n\r\nIf you are a programmer, you can help me out by fixing bugs, cleaning up code, and making things more efficient. I gladly accept community branches into the main codebase at [Bitbucket](#).\r\n\r\n\r\n', 0, 'localhost', 1);
 
 -- --------------------------------------------------------
 
 
 [display]
 items_per_page = 5
-date_format = %a %B %d, %Y at %H:%M
+date_format = %B %d, %Y @ %H:%M
 # can be 'asc' or 'desc' or 'alpha'
 order = desc
 
 	formatted = time.strftime(format_to_use, date_obj)
 	
 	return unicode(formatted)
+
+def rfc_timestamp(timestamp):
+	"""
+	Converts timestamp to RFC 2822 compatible format
+	"""
+	return strftime("%a, %d %b %Y %H:%M:%S +0000", timestamp)
 	
 def hyperlink_tags(tags):
 	"""
 	'/\+feed/(\w+)/?',									'Feed',
 	)
 	
-
-class redirect:
-	def GET(self):
-		web.seeother('/' + path)
+class restrict(object):
+	"""
+	Decorator for admin section of the website that need restriction.
+	"""
+	def __init__(self, request):
+		self.__request = request
+		
+	def __call__(self, *args, **kwargs):
+		if session.auth != 1:
+			web.seeother(config.general.base_url)
+		else:
+			return self.__request(self, *args, **kwargs)
 
 class articleList:
 	def GET(self, page=0, year=None, month=None, day=None):
 			
 		return templater(config.general.base_path+"templates/site.html", site_vars)
 		
+	@restrict
 	def POST(self):
 		# web.py and mod_wsgi make a persistance python session
 		# therefore, reload db after every use
 		
 		return templater(config.general.base_path+"templates/site.html", {"page_html":page_html, "base_url":config.general.base_url, "page_type":page_type, "session":session, "page_name":article.title})
 		
+	@restrict
 	def POST(self, url_id, format):
 		# init input
 		i = web.input()
 			raise web.seeother(config.general.base_url+'+login/')
 			
 class Logout:
+	@restrict
 	def GET(self):
 		session.kill()
 		raise web.seeother(config.general.base_url)
 			
 class Admin:
-	def GET(self, component, id_="null"):
-		if session.auth != 1:
-			raise web.seeother(config.general.base_url)
-			
+	@restrict
+	def GET(self, component, id_="null"):	
 		if component == "delete_article":
 			id_ = str(id_).replace("delete_", "").replace("/", "")
 			
 			return page_html
 		
 class Ajax:
-	def GET(self, action, object_id=16):
-		if session.auth != 1:
-			raise web.seeother(config.general.base_url)
-			
+	@restrict
+	def GET(self, action, object_id=16):	
 		if action == "edit_form":
 			# serve a preloaded edit form
 			matches = db.store.find(db.Article, db.Article.id_ == int(object_id))

static/css/_main.css

 body {
-	font: 13px sans-serif;
+	font: 14px sans-serif;
 	background: #fff url("../images/bodygrad.png") 0 -20px repeat-x;
 	margin: 0 auto;
 	padding: 10px 10px 10px 10px;
 	}
 h1 {
-	color: #222;
-	font-weight: normal;
-	font-family: sans-serif;
+	color: #333;
+	cursor: default;
+	font-family: 'Droid Sans', sans-serif;
 	font-size: 28px;
 	}
 	h1 * {
 			color: #333;
 			text-decoration: underline;
 			}
-	
 h2 {
 	color: #333;
-	font: 22px sans-serif;
+	font: 22px 'Droid Sans', sans-serif;
+	text-shadow: 2px -2px #eee;
 	margin-top: 30px;
 	clear: left;
 	}
 h3 {
 	}
 h4 {
+	cursor: default;
 	color: #555;
 	font-weight: normal;
-	font: 14px  sans-serif;
+	font: 14px  'Droid Sans', sans-serif;
 	margin-top: 0;
 	}
 p, ol, ul, blockquote {
-	font: 14px sans-serif;
+	font-size: 14px;
+	text-align: justify;
 	line-height: 150%;
 	}
 a {
-	color: #0000AB;
+	color: #00457B;
 	text-decoration: none;
 	}
 pre {
 	}
 hr {
 	margin: 20px 0;
-	width: 600px;
 	border: 0;
 	height: 1px;
 	color: #444;
 #header {
 	height: 25px;
 	margin: -10px -10px 10px -10px;
-	background: #6BA81E;
-
+	background: #9AC65C;
 	}
 	#header ul {
 		margin: 0;
 
 #date_modified {
 	float: right;
-	color: #ccc;
+	color: #999;
 	font-size: 12px;
 	cursor: default;
 	}
 		}
 	#navbar {
 		color: #000;
+		font-family: 'Droid Sans', sans-serif;
 		background: white url("../images/navgrad.png") 0 100% repeat-x;
 		border: 1px solid #999;
 		margin-top: -5px;
 				color: #193441;
 				}
 		#navbar li a {
-			font: 14px sans-serif;
+			font-size: 14px;
 			text-decoration: none;
 			}
 	.pullbox {

templates/article.html

 				<span></span>
 			
 			</h1>
-			<h4> <em>Published on</em> $article['date'] &mdash; tagged $article['tag_list']</h4>
+			<h4> <em>Published</em> $article['date'] by $article['author'] &mdash; tagged $article['tag_list']</h4>
 			<!--<div class="social_networking"><script type="text/javascript" src="http://reddit.com/static/button/button3.js?url=$article['base_url']$article['year']/$article['month']/$article['day']/$article['url_id']/"></script></div>-->
 			<!-- Content -->
 			$article['content']

templates/article.markdown

 $article.title
 $('='*len(article.title))
 
-* Posted on (unix): $article.timestamp
+* Timestamp: $article.timestamp
+* Author: $article.author
 * Tags: $article.tags
 * URL title: $article.url_id
 * Comments: $article.comment_count

templates/site.html

 <html xmlns="http://www.w3.org/1999/xhtml">
 	<head>
 		<title>alecwh &mdash; $site_vars['page_name'] (~$site_vars['session'].username)</title>
+		<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid%20Sans:regular,bold" media="screen" />
 		<link rel="stylesheet" type="text/css" href="$site_vars['base_url']static/css/_main.css" />
 		<link rel="stylesheet" type="text/css" href="$site_vars['base_url']static/css/print.css" media="print" />
 		<link rel="stylesheet" type="text/css" href="$site_vars['base_url']static/css/handheld.css" media="handheld" />
 			<div id="staticbar">
 				<div id="navbar">
 					<h2><a href="$site_vars['base_url']" longdesc="Point-blank blog application">Pb</a><span> ver 0.1</span></h2>
-					<strong>Other pages</strong>
+					<strong>Pages</strong>
 					<ul>
 						<li><a href="$site_vars['base_url']">Home</a></li>
 						<li><a href="$site_vars['base_url']about.html">About me</a></li>