Commits

Janto Dreijer  committed 384d66c

  • Participants
  • Parent commits 4a39519

Comments (0)

Files changed (3)

File code/scikits.py

 		if show_latest_changes:
 			newest_packages_html = []
 
-			oldest = datetime.fromtimestamp(time.time() - SECONDS_IN_WEEK * 3)
+			oldest = datetime.datetime.fromtimestamp(time.time() - SECONDS_IN_WEEK * 3)
 			news_items = []
 			for package in Package.packages().values():
 				first_char = package.name[0]
 	'''.strip() % locals())
 	return "\n".join(result)
 
-class AdminPage(Page):
-	name="admin"
+class EditPage(Page):
+	editors = [
+		"jantod@gmail.com",
+		"sjvdwalt@gmail.com",
+		"damian.eads@gmail.com",
+	]
+	name="edit"
 	def get(self):
 		"""
 		@template_name
 		user = users.get_current_user()
 		self.write("<p>")
 		if not user:
-			self.write('only site admins allowed here.\n')
-			self.write('<a href="%s">sign in</a>' % users.create_login_url("/admin"))
+			self.write('only site editors allowed here.\n')
+			self.write('<a href="%s">sign in</a>' % users.create_login_url("/edit"))
 			self.print_footer()
 			return
-		if not users.is_current_user_admin():
-			self.write('only site admin allowed here.\n')
-			self.write('<a href="%s">sign out</a>.' % users.create_logout_url("/admin"))
+		if users.get_current_user().email().lower() not in self.editors:
+			self.write('only site editors allowed here.\n')
+			self.write('<a href="%s">sign out</a>.' % users.create_logout_url("/edit"))
 			self.print_footer()
 			return
 		self.write("welcome %s.\n" % user.nickname())
-		self.write('<a href="%s">sign out</a>.' % users.create_logout_url("/admin"))
+		self.write('<a href="%s">sign out</a>.' % users.create_logout_url("/edit"))
 		self.write("</p>")
 
 		# backup and stats
 				)
 				self.write("sent backup to %s at %s" % (address, t))
 		self.write("""
-		<form action="/admin" method="post">
+		<form action="/edit" method="post">
 		<input type="hidden" name="email_backup" value="yes">
 		<input type="submit" value="Email me a backup" />
 		</form>
 			self.write("</p>")
 
 		# list templates
-
 		for template_name in [
 			"header",
 			"footer",
 			self.write("""
 <h2>%(template_name)s</h2>
 <p>
-<form action="/admin" method="post">
+<form action="/edit" method="post">
 <textarea name="template_text" cols="80" rows="20">%(template_text)s</textarea>
 <input type="hidden" name="template_name" value="%(template_name)s">
 <br />
 </p>
 			""" % locals())
 
+		self.print_footer()
 
-		self.write("<h1>Other</h1>")
+	post = get
+
+class AdminPage(Page):
+
+	name="admin"
+	def get(self):
+		"""
+		@clear_memcache
+
+		"""
+		self.print_header()
+		self.print_menu()
+
+		# authorize
+
+		user = users.get_current_user()
+		self.write("<p>")
+		if not user:
+			self.write('only site admins allowed here.\n')
+			self.write('<a href="%s">sign in</a>' % users.create_login_url("/admin"))
+			self.print_footer()
+			return
+		if not users.is_current_user_admin():
+			self.write('only site admin allowed here.\n')
+			self.write('<a href="%s">sign out</a>.' % users.create_logout_url("/admin"))
+			self.print_footer()
+			return
+		self.write("welcome %s.\n" % user.nickname())
+		self.write('<a href="%s">sign out</a>.' % users.create_logout_url("/admin"))
+		self.write("</p>")
 
 		# memcache management
 		self.write("<h2>memcache</h2>")
 	('/search', SearchPage),
 	('/admin', AdminPage),
 	('/debug', DebugPage),
+	('/edit', EditPage),
 	('/robots.txt', RobotsPage),
 
 	('/(.+)', PackageInfoPage),

File code/templates.py

 
 <div class="footer">
 See the <a href="http://code.google.com/p/scikits-index/source/checkout">source</a>.
-Created page in %(load_time)0.3f seconds. <a href="/admin">Admin</a>.
+Created page in %(load_time)0.3f seconds. <a href="/edit">Edit Pages</a>.
 <br />
 Designed by <a href="http://janto.blogspot.com/">Janto Dreijer</a>.
 Appearance based on <a href="http://sphinx.pocoo.org/">Sphinx</a> and <a href="http://www.vistaicons.com/icon/i160s0/phuzion_icon_pack.htm">Phuzion icons</a>.
 You can download the latest distribution from PyPI here: <a href="http://pypi.python.org/pypi/%(name)s">http://pypi.python.org/pypi/%(name)s</a>
 </p>
 
-<h4>EasyInstall</h4>
+<h4>Easy Install</h4>
 <p>
-Install the <a href="http://peak.telecommunity.com/DevCenter/EasyInstall">EasyInstall</a> tools. Afterwards you can install %(name)s from the terminal by executing:
-<code>sudo easy_install %(name)s</code>
+Install the <a href="http://peak.telecommunity.com/DevCenter/EasyInstall">Easy Install</a> tools. Afterwards you can install %(name)s from the terminal by executing:
+<pre>sudo easy_install %(name)s</pre>
+</p>
+
+<p>
+If you prefer to do a local installation, specify an installation prefix:
+<pre>easy_install --prefix=${HOME} %(name)s</pre>
+and ensure that your <code>PYTHONPATH</code> is up to date, e.g.:
+<pre>export PYTHONPATH=$PYTHONPATH:${HOME}/lib/python2.5/site-packages</pre>
 </p>
 
 <h4>Source code</h4>
 <p>
-You can get the latest sources from the repository
-<code>svn checkout <a href="%(repo_url)s">%(repo_url)s</a></code>
+You can get the latest sources from the repository using
+<pre>svn checkout <a href="%(repo_url)s">%(repo_url)s</a></pre>
 </p>
 
 """

File code/tools.py

 
 import cgi
 import datetime
+from BeautifulSoup import BeautifulSoup
 import wsgiref.handlers
 
 import re
 	items = re.findall('<a href="(.+?)/">.+?</a>', result.content)
 	return [os.path.join(url, item) for item in items if not item.startswith("http://") and not item.startswith("..")]
 
-from datetime import datetime
-from BeautifulSoup import BeautifulSoup
-
 def fetch_links_with_dates(url, cache_duration=None):
 	response = get_url(url, cache_duration=cache_duration)
 	if response.status_code != 200:
 		# find date field
 		for td in tr.findAll("td"):
 			try:
-				t = datetime.strptime(str(td.contents[0]).strip(), "%d-%b-%Y %H:%M")
+				t = datetime.datetime.strptime(str(td.contents[0]).strip(), "%d-%b-%Y %H:%M")
 				break
 			except ValueError:
 				continue