From: Eevee Date: Thu, 15 Jul 2010 04:47:31 +0000 (-0700) Subject: Initial commit; very dumb front page support. X-Git-Tag: veekun-promotions/2010080801~9 X-Git-Url: http://git.veekun.com/zzz-spline-frontpage.git/commitdiff_plain/475ce71bfb57fba45376c568d603007a5e52f54a?ds=sidebyside Initial commit; very dumb front page support. --- 475ce71bfb57fba45376c568d603007a5e52f54a diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..942b636 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.swp +*.pyc + +*.egg-info/ diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..a256563 --- /dev/null +++ b/setup.py @@ -0,0 +1,18 @@ +from setuptools import setup, find_packages +setup( + name = 'spline-frontpage', + version = '0.1', + packages = find_packages(), + + install_requires = [ + 'spline', + ], + + include_package_data = True, + + zip_safe = False, + + entry_points = {'spline.plugins': 'frontpage = splinext.frontpage:FrontPagePlugin'}, + + namespace_packages = ['splinext'], +) diff --git a/splinext/__init__.py b/splinext/__init__.py new file mode 100644 index 0000000..de40ea7 --- /dev/null +++ b/splinext/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/splinext/frontpage/__init__.py b/splinext/frontpage/__init__.py new file mode 100644 index 0000000..ceb606c --- /dev/null +++ b/splinext/frontpage/__init__.py @@ -0,0 +1,27 @@ +from pkg_resources import resource_filename + +from spline.lib.plugin import PluginBase +from spline.lib.plugin import PluginBase, PluginLink, Priority + +import splinext.frontpage.controllers.frontpage + +def add_routes_hook(map, *args, **kwargs): + """Hook to inject some of our behavior into the routes configuration.""" + map.connect('/', controller='frontpage', action='index') + + +class FrontPagePlugin(PluginBase): + def controllers(self): + return dict( + frontpage = splinext.frontpage.controllers.frontpage.FrontPageController, + ) + + def template_dirs(self): + return [ + (resource_filename(__name__, 'templates'), Priority.FIRST) + ] + + def hooks(self): + return [ + ('routes_mapping', Priority.NORMAL, add_routes_hook), + ] diff --git a/splinext/frontpage/controllers/__init__.py b/splinext/frontpage/controllers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/splinext/frontpage/controllers/frontpage.py b/splinext/frontpage/controllers/frontpage.py new file mode 100644 index 0000000..959f5fb --- /dev/null +++ b/splinext/frontpage/controllers/frontpage.py @@ -0,0 +1,32 @@ +import logging + +from pylons import config, request, response, session, tmpl_context as c, url +from pylons.controllers.util import abort, redirect_to +from routes import request_config +from sqlalchemy.orm.exc import NoResultFound + +from spline.lib import helpers as h +from spline.lib.base import BaseController, render +from spline.lib.plugin.load import run_hooks + +log = logging.getLogger(__name__) + +class FrontPageController(BaseController): + + def index(self): + """Magicaltastic front page. + + Plugins can register things to appear on it, somehow. + + Local plugins can override the fairly simple index.mako template to + customize the front page layout. + """ + # Hooks should return a list of FrontPageUpdate objects, making this + # return value a list of lists + updates_lol = run_hooks('frontpage_updates', limit=10) + updates = sum(updates_lol, []) + updates.sort(key=lambda obj: obj.time) + + c.updates = updates[0:10] + + return render('/index.mako') diff --git a/splinext/frontpage/templates/index.mako b/splinext/frontpage/templates/index.mako new file mode 100644 index 0000000..b9d9f4f --- /dev/null +++ b/splinext/frontpage/templates/index.mako @@ -0,0 +1,10 @@ +<%inherit file="base.mako" /> + +<%def name="title()">Home + +

Updates

+% for update in c.updates: +

${repr(update.__dict__)}

+<%include file="${update.template}" args="update=update" /> +
+% endfor