Initial commit; very dumb front page support.
authorEevee <git@veekun.com>
Thu, 15 Jul 2010 04:47:31 +0000 (21:47 -0700)
committerEevee <git@veekun.com>
Thu, 15 Jul 2010 04:47:31 +0000 (21:47 -0700)
.gitignore [new file with mode: 0644]
setup.py [new file with mode: 0644]
splinext/__init__.py [new file with mode: 0644]
splinext/frontpage/__init__.py [new file with mode: 0644]
splinext/frontpage/controllers/__init__.py [new file with mode: 0644]
splinext/frontpage/controllers/frontpage.py [new file with mode: 0644]
splinext/frontpage/templates/index.mako [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..942b636
--- /dev/null
@@ -0,0 +1,4 @@
+*.swp
+*.pyc
+
+*.egg-info/
diff --git a/setup.py b/setup.py
new file mode 100644 (file)
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 (file)
index 0000000..de40ea7
--- /dev/null
@@ -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 (file)
index 0000000..ceb606c
--- /dev/null
@@ -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 (file)
index 0000000..e69de29
diff --git a/splinext/frontpage/controllers/frontpage.py b/splinext/frontpage/controllers/frontpage.py
new file mode 100644 (file)
index 0000000..959f5fb
--- /dev/null
@@ -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 (file)
index 0000000..b9d9f4f
--- /dev/null
@@ -0,0 +1,10 @@
+<%inherit file="base.mako" />
+
+<%def name="title()">Home</%def>
+
+<h1>Updates</h1>
+% for update in c.updates:
+<p>${repr(update.__dict__)}</p>
+<%include file="${update.template}" args="update=update" />
+<hr>
+% endfor