From 7742dcc1fbda04c3a1c76a057a1a93a8f504502e Mon Sep 17 00:00:00 2001 From: Joar Wandborg Date: Sun, 14 Oct 2012 13:46:31 +0200 Subject: [PATCH 001/140] Switched most stuff over from Routes Removed the Routes routing functionality and replaced it with werkzeug.routes. Most views are functional. Known issues: - Translation integration with the request object is not yet figured out. This breaks 404 pages. --- mediagoblin/app.py | 73 +++++++++-------- mediagoblin/auth/routing.py | 53 ++++++++----- mediagoblin/edit/routing.py | 14 ++-- mediagoblin/listings/routing.py | 16 ++-- mediagoblin/plugins/api/__init__.py | 12 +-- mediagoblin/plugins/oauth/__init__.py | 24 +++--- mediagoblin/routing.py | 40 ++++------ mediagoblin/submit/routing.py | 11 +-- mediagoblin/tools/pluginapi.py | 2 +- mediagoblin/user_pages/routing.py | 108 +++++++++++++++----------- mediagoblin/webfinger/routing.py | 12 ++- 11 files changed, 189 insertions(+), 176 deletions(-) diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 08515df9..5758dbbb 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -18,11 +18,12 @@ import os import urllib import logging -import routes -from webob import exc -from werkzeug.wrappers import Request +from mediagoblin.routing import url_map, view_functions, add_route -from mediagoblin import routing, meddleware, __version__ +from werkzeug.wrappers import Request +from werkzeug.exceptions import HTTPException, NotFound + +from mediagoblin import meddleware, __version__ from mediagoblin.tools import common, translate, template from mediagoblin.tools.response import render_404 from mediagoblin.tools.theme import register_themes @@ -90,7 +91,10 @@ class MediaGoblinApp(object): self.public_store, self.queue_store = setup_storage() # set up routing - self.routing = routing.get_mapper(PluginManager().get_routes()) + self.url_map = url_map + + for route in PluginManager().get_routes(): + add_route(*route) # set up staticdirector tool self.staticdirector = get_staticdirector(app_config) @@ -135,7 +139,7 @@ class MediaGoblinApp(object): ## Routing / controller loading stuff path_info = request.path - route_match = self.routing.match(path_info) + map_adapter = self.url_map.bind_to_environ(request.environ) # By using fcgi, mediagoblin can run under a base path # like /mediagoblin/. request.path_info contains the @@ -154,47 +158,52 @@ class MediaGoblinApp(object): environ.pop('HTTPS') ## Attach utilities to the request object - request.matchdict = route_match - request.urlgen = routes.URLGenerator(self.routing, environ) # Do we really want to load this via middleware? Maybe? request.session = request.environ['beaker.session'] # Attach self as request.app # Also attach a few utilities from request.app for convenience? request.app = self - request.locale = translate.get_locale_from_request(request) - request.template_env = template.get_jinja_env( - self.template_loader, request.locale) request.db = self.db request.staticdirect = self.staticdirector mg_request.setup_user_in_request(request) - # No matching page? - if route_match is None: - # Try to do see if we have a match with a trailing slash - # added and if so, redirect - if not path_info.endswith('/') \ - and request.method == 'GET' \ - and self.routing.match(path_info + '/'): - new_path_info = path_info + '/' - if request.GET: - new_path_info = '%s?%s' % ( - new_path_info, urllib.urlencode(request.GET)) - redirect = exc.HTTPFound(location=new_path_info) - return request.get_response(redirect)(environ, start_response) + try: + endpoint, url_values = map_adapter.match() + request.matchdict = url_values - # Okay, no matches. 404 time! - request.matchdict = {} # in case our template expects it + request.locale = translate.get_locale_from_request(request) + request.template_env = template.get_jinja_env( + self.template_loader, request.locale) + except NotFound as exc: + return NotImplemented return render_404(request)(environ, start_response) + except HTTPException as exc: + # Support legacy webob.exc responses + return exc(environ, start_response) - # import the controller, or if it's already a callable, call that - route_controller = route_match['controller'] - if isinstance(route_controller, unicode) \ - or isinstance(route_controller, str): - controller = common.import_component(route_match['controller']) + def build_proxy(endpoint, **kw): + try: + qualified = kw.pop('qualified') + except KeyError: + qualified = False + + return map_adapter.build( + endpoint, + values=dict(**kw), + force_external=qualified) + + request.urlgen = build_proxy + + view_func = view_functions[endpoint] + + # import the endpoint, or if it's already a callable, call that + if isinstance(view_func, unicode) \ + or isinstance(view_func, str): + controller = common.import_component(view_func) else: - controller = route_match['controller'] + controller = view_func # pass the request through our meddleware classes for m in self.meddleware: diff --git a/mediagoblin/auth/routing.py b/mediagoblin/auth/routing.py index 15d8fc3c..58faa5a3 100644 --- a/mediagoblin/auth/routing.py +++ b/mediagoblin/auth/routing.py @@ -14,25 +14,36 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from routes.route import Route +from routes.route import add_route +from mediagoblin.routing import add_route -auth_routes = [ - Route('mediagoblin.auth.register', '/register/', - controller='mediagoblin.auth.views:register'), - Route('mediagoblin.auth.login', '/login/', - controller='mediagoblin.auth.views:login'), - Route('mediagoblin.auth.logout', '/logout/', - controller='mediagoblin.auth.views:logout'), - Route('mediagoblin.auth.verify_email', '/verify_email/', - controller='mediagoblin.auth.views:verify_email'), - Route('mediagoblin.auth.resend_verification', '/resend_verification/', - controller='mediagoblin.auth.views:resend_activation'), - Route('mediagoblin.auth.resend_verification_success', - '/resend_verification_success/', - template='mediagoblin/auth/resent_verification_email.html', - controller='mediagoblin.views:simple_template_render'), - Route('mediagoblin.auth.forgot_password', '/forgot_password/', - controller='mediagoblin.auth.views:forgot_password'), - Route('mediagoblin.auth.verify_forgot_password', - '/forgot_password/verify/', - controller='mediagoblin.auth.views:verify_forgot_password')] +add_route('mediagoblin.auth.logout', + '/auth/logout/', 'mediagoblin.auth.views:logout') + + +add_route('mediagoblin.auth.register', '/register/', + 'mediagoblin.auth.views:register') + +add_route('mediagoblin.auth.login', '/login/', + 'mediagoblin.auth.views:login') + +add_route('mediagoblin.auth.logout', '/logout/', + 'mediagoblin.auth.views:logout') + +add_route('mediagoblin.auth.verify_email', '/verify_email/', + 'mediagoblin.auth.views:verify_email') + +add_route('mediagoblin.auth.resend_verification', '/resend_verification/', + 'mediagoblin.auth.views:resend_activation') + +add_route('mediagoblin.auth.resend_verification_success', + '/resend_verification_success/', + template='mediagoblin/auth/resent_verification_email.html', + 'mediagoblin.views:simple_template_render') + +add_route('mediagoblin.auth.forgot_password', '/forgot_password/', + 'mediagoblin.auth.views:forgot_password') + +add_route('mediagoblin.auth.verify_forgot_password', + '/forgot_password/verify/', + 'mediagoblin.auth.views:verify_forgot_password') diff --git a/mediagoblin/edit/routing.py b/mediagoblin/edit/routing.py index 321c1f44..28b73d1e 100644 --- a/mediagoblin/edit/routing.py +++ b/mediagoblin/edit/routing.py @@ -14,13 +14,9 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from mediagoblin.routing import add_route -from routes.route import Route - -edit_routes = [ - # Media editing view handled in user_pages/routing.py - Route('mediagoblin.edit.profile', '/profile/', - controller="mediagoblin.edit.views:edit_profile"), - Route('mediagoblin.edit.account', '/account/', - controller="mediagoblin.edit.views:edit_account"), - ] +add_route('mediagoblin.edit.profile', '/edit/profile/', + 'mediagoblin.edit.views:edit_profile') +add_route('mediagoblin.edit.account', '/edit/account/', + 'mediagoblin.edit.views:edit_account') diff --git a/mediagoblin/listings/routing.py b/mediagoblin/listings/routing.py index d228a727..d25f1c8c 100644 --- a/mediagoblin/listings/routing.py +++ b/mediagoblin/listings/routing.py @@ -14,14 +14,10 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from mediagoblin.routing import add_route -from routes.route import Route - -tag_routes = [ - # Route('mediagoblin.listings.tags_home', "/", - # controller="mediagoblin.listings.views:tags_home"), - Route('mediagoblin.listings.tags_listing', "/{tag}/", - controller="mediagoblin.listings.views:tag_listing"), - Route('mediagoblin.listings.tag_atom_feed', "/{tag}/atom/", - controller="mediagoblin.listings.views:tag_atom_feed"), - ] +add_route('mediagoblin.listings.tags_listing', + "/tag//", + "mediagoblin.listings.views:tag_listing") +add_route('mediagoblin.listings.tag_atom_feed', "/tag//atom/", + "mediagoblin.listings.views:tag_atom_feed") diff --git a/mediagoblin/plugins/api/__init__.py b/mediagoblin/plugins/api/__init__.py index 40722088..f370cca6 100644 --- a/mediagoblin/plugins/api/__init__.py +++ b/mediagoblin/plugins/api/__init__.py @@ -33,12 +33,12 @@ def setup_plugin(): _log.debug('API config: {0}'.format(config)) routes = [ - Route('mediagoblin.plugins.api.test', '/api/test', - controller='mediagoblin.plugins.api.views:api_test'), - Route('mediagoblin.plugins.api.entries', '/api/entries', - controller='mediagoblin.plugins.api.views:get_entries'), - Route('mediagoblin.plugins.api.post_entry', '/api/submit', - controller='mediagoblin.plugins.api.views:post_entry')] + ('mediagoblin.plugins.api.test', '/api/test', + 'mediagoblin.plugins.api.views:api_test'), + ('mediagoblin.plugins.api.entries', '/api/entries', + 'mediagoblin.plugins.api.views:get_entries'), + ('mediagoblin.plugins.api.post_entry', '/api/submit', + 'mediagoblin.plugins.api.views:post_entry')] pluginapi.register_routes(routes) diff --git a/mediagoblin/plugins/oauth/__init__.py b/mediagoblin/plugins/oauth/__init__.py index 63bf49a8..64acf0e7 100644 --- a/mediagoblin/plugins/oauth/__init__.py +++ b/mediagoblin/plugins/oauth/__init__.py @@ -36,21 +36,21 @@ def setup_plugin(): _log.debug('OAuth config: {0}'.format(config)) routes = [ - Route('mediagoblin.plugins.oauth.authorize', '/oauth/authorize', - controller='mediagoblin.plugins.oauth.views:authorize'), - Route('mediagoblin.plugins.oauth.authorize_client', '/oauth/client/authorize', - controller='mediagoblin.plugins.oauth.views:authorize_client'), - Route('mediagoblin.plugins.oauth.access_token', '/oauth/access_token', - controller='mediagoblin.plugins.oauth.views:access_token'), - Route('mediagoblin.plugins.oauth.access_token', + ('mediagoblin.plugins.oauth.authorize', '/oauth/authorize', + 'mediagoblin.plugins.oauth.views:authorize'), + ('mediagoblin.plugins.oauth.authorize_client', '/oauth/client/authorize', + 'mediagoblin.plugins.oauth.views:authorize_client'), + ('mediagoblin.plugins.oauth.access_token', '/oauth/access_token', + 'mediagoblin.plugins.oauth.views:access_token'), + ('mediagoblin.plugins.oauth.access_token', '/oauth/client/connections', - controller='mediagoblin.plugins.oauth.views:list_connections'), - Route('mediagoblin.plugins.oauth.register_client', + 'mediagoblin.plugins.oauth.views:list_connections'), + ('mediagoblin.plugins.oauth.register_client', '/oauth/client/register', - controller='mediagoblin.plugins.oauth.views:register_client'), - Route('mediagoblin.plugins.oauth.list_clients', + 'mediagoblin.plugins.oauth.views:register_client'), + ('mediagoblin.plugins.oauth.list_clients', '/oauth/client/list', - controller='mediagoblin.plugins.oauth.views:list_clients')] + 'mediagoblin.plugins.oauth.views:list_clients')] pluginapi.register_routes(routes) pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates')) diff --git a/mediagoblin/routing.py b/mediagoblin/routing.py index 90e1f3f8..4b9c42ee 100644 --- a/mediagoblin/routing.py +++ b/mediagoblin/routing.py @@ -14,36 +14,22 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from routes import Mapper +from werkzeug.routing import Map, Rule -from mediagoblin.auth.routing import auth_routes -from mediagoblin.submit.routing import submit_routes -from mediagoblin.user_pages.routing import user_routes -from mediagoblin.edit.routing import edit_routes -from mediagoblin.listings.routing import tag_routes -from mediagoblin.webfinger.routing import webfinger_well_known_routes, \ - webfinger_routes -from mediagoblin.admin.routing import admin_routes +url_map = Map() +view_functions = {'index': 'mediagoblin.views:index'} -def get_mapper(plugin_routes): - mapping = Mapper() - mapping.minimization = False +def add_route(endpoint, url, controller): + view_functions.update({endpoint: controller}) - # Plugin routes go first so they can override default routes. - mapping.extend(plugin_routes) + url_map.add(Rule(url, endpoint=endpoint)) - mapping.connect( - "index", "/", - controller="mediagoblin.views:root_view") +add_route('index', '/', 'mediagoblin.views:root_view') - mapping.extend(auth_routes, '/auth') - mapping.extend(submit_routes, '/submit') - mapping.extend(user_routes, '/u') - mapping.extend(edit_routes, '/edit') - mapping.extend(tag_routes, '/tag') - mapping.extend(webfinger_well_known_routes, '/.well-known') - mapping.extend(webfinger_routes, '/api/webfinger') - mapping.extend(admin_routes, '/a') - - return mapping +import mediagoblin.submit.routing +import mediagoblin.user_pages.routing +import mediagoblin.auth.routing +import mediagoblin.edit.routing +import mediagoblin.webfinger.routing +import mediagoblin.listings.routing diff --git a/mediagoblin/submit/routing.py b/mediagoblin/submit/routing.py index 1e399d1e..cbed1895 100644 --- a/mediagoblin/submit/routing.py +++ b/mediagoblin/submit/routing.py @@ -14,11 +14,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from routes.route import Route +from mediagoblin.routing import add_route -submit_routes = [ - Route('mediagoblin.submit.start', '/', - controller='mediagoblin.submit.views:submit_start'), - Route('mediagoblin.submit.collection', '/collection', - controller='mediagoblin.submit.views:add_collection'), - ] +add_route('mediagoblin.submit.start', + '/submit/', 'mediagoblin.submit.views:submit_start') +add_route('collection_home', '/submit/collection', 'mediagoblin.submit.views:add_collection') diff --git a/mediagoblin/tools/pluginapi.py b/mediagoblin/tools/pluginapi.py index 7c1e108b..df3f51c4 100644 --- a/mediagoblin/tools/pluginapi.py +++ b/mediagoblin/tools/pluginapi.py @@ -162,7 +162,7 @@ def register_routes(routes): Be careful when designing your route urls. If they clash with core urls, then it could result in DISASTER! """ - if isinstance(routes, (tuple, list)): + if isinstance(routes, list): for route in routes: PluginManager().register_route(route) else: diff --git a/mediagoblin/user_pages/routing.py b/mediagoblin/user_pages/routing.py index 1cfce2dd..678f18f9 100644 --- a/mediagoblin/user_pages/routing.py +++ b/mediagoblin/user_pages/routing.py @@ -14,48 +14,68 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from routes.route import Route +from mediagoblin.routing import add_route -user_routes = [ - Route('mediagoblin.user_pages.user_home', "/{user}/", - controller="mediagoblin.user_pages.views:user_home"), - Route('mediagoblin.user_pages.user_gallery', "/{user}/gallery/", - controller="mediagoblin.user_pages.views:user_gallery"), - Route('mediagoblin.user_pages.media_home', '/{user}/m/{media}/', - requirements=dict(m_id="[0-9a-fA-F]{24}"), - controller="mediagoblin.user_pages.views:media_home"), - Route('mediagoblin.user_pages.media_home.view_comment', - '/{user}/m/{media}/c/{comment}/', - controller="mediagoblin.user_pages.views:media_home"), - Route('mediagoblin.edit.edit_media', "/{user}/m/{media}/edit/", - controller="mediagoblin.edit.views:edit_media"), - Route('mediagoblin.edit.attachments', - '/{user}/m/{media}/attachments/', - controller="mediagoblin.edit.views:edit_attachments"), - Route('mediagoblin.user_pages.media_confirm_delete', - "/{user}/m/{media}/confirm-delete/", - controller="mediagoblin.user_pages.views:media_confirm_delete"), - Route('mediagoblin.user_pages.atom_feed', '/{user}/atom/', - controller="mediagoblin.user_pages.views:atom_feed"), - Route('mediagoblin.user_pages.media_post_comment', - '/{user}/m/{media}/comment/add/', - controller="mediagoblin.user_pages.views:media_post_comment"), - Route('mediagoblin.user_pages.media_collect', - "/{user}/m/{media}/collect/", - controller="mediagoblin.user_pages.views:media_collect"), - Route('mediagoblin.user_pages.user_collection', "/{user}/collection/{collection}/", - controller="mediagoblin.user_pages.views:user_collection"), - Route('mediagoblin.edit.edit_collection', "/{user}/c/{collection}/edit/", - controller="mediagoblin.edit.views:edit_collection"), - Route('mediagoblin.user_pages.collection_confirm_delete', - "/{user}/c/{collection}/confirm-delete/", - controller="mediagoblin.user_pages.views:collection_confirm_delete"), - Route('mediagoblin.user_pages.collection_item_confirm_remove', - "/{user}/collection/{collection}/{collection_item}/confirm_remove/", - controller="mediagoblin.user_pages.views:collection_item_confirm_remove"), - Route('mediagoblin.user_pages.collection_atom_feed', '/{user}/collection/{collection}/atom/', - controller="mediagoblin.user_pages.views:collection_atom_feed"), - Route('mediagoblin.user_pages.processing_panel', - '/{user}/panel/', - controller="mediagoblin.user_pages.views:processing_panel"), - ] +add_route('mediagoblin.user_pages.user_home', + '/u//', 'mediagoblin.user_pages.views:user_home') + +add_route('mediagoblin.user_pages.media_home', + '/u//m//', + 'mediagoblin.user_pages.views:media_home') + +add_route('mediagoblin.user_pages.media_confirm_delete', + '/u//m//confirm-delete/', + 'mediagoblin.user_pages.views:media_confirm_delete') + +add_route('mediagoblin.user_pages.media_post_comment', + '/u//m//comment/add/', + 'mediagoblin.user_pages.views:media_post_comment') + +add_route('mediagoblin.user_pages.user_gallery', + '/u//gallery/', + 'mediagoblin.user_pages.views:user_gallery') + +add_route('mediagoblin.user_pages.media_home.view_comment', + '/u//m//c//', + 'mediagoblin.user_pages.views:media_home') + +add_route('mediagoblin.user_pages.atom_feed', + '/u//atom/', + 'mediagoblin.user_pages.views:atom_feed') + +add_route('mediagoblin.user_pages.media_collect', + '/u//m//collect/', + 'mediagoblin.user_pages.views:media_collect') + +add_route('mediagoblin.user_pages.user_collection', + '/u//collection//', + 'mediagoblin.user_pages.views:user_collection') + +add_route('mediagoblin.edit.edit_collection', + '/u//c//edit/', + 'mediagoblin.edit.views:edit_collection') + +add_route('mediagoblin.user_pages.collection_confirm_delete', + '/u//c//confirm-delete/', + 'mediagoblin.user_pages.views:collection_confirm_delete') + +add_route('mediagoblin.user_pages.collection_item_confirm_remove', + '/u//collection///confirm_remove/', + 'mediagoblin.user_pages.views:collection_item_confirm_remove') + +add_route('mediagoblin.user_pages.collection_atom_feed', + '/u//collection//atom/', + 'mediagoblin.user_pages.views:collection_atom_feed') + +add_route('mediagoblin.user_pages.processing_panel', + '/u//panel/', + 'mediagoblin.user_pages.views:processing_panel') + +# Stray edit routes +add_route('mediagoblin.edit.edit_media', + '/u//m//edit/', + 'mediagoblin.user_pages.views:edit_media') + +add_route('mediagoblin.edit.attachments', + '/u//m//attachments/', + 'mediagoblin.user_pages.views:edit_attachments') diff --git a/mediagoblin/webfinger/routing.py b/mediagoblin/webfinger/routing.py index 7e84a00a..18f9eb02 100644 --- a/mediagoblin/webfinger/routing.py +++ b/mediagoblin/webfinger/routing.py @@ -14,12 +14,10 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from routes.route import Route +from mediagoblin.routing import add_route -webfinger_well_known_routes = [ - Route('mediagoblin.webfinger.host_meta', '/host-meta', - controller='mediagoblin.webfinger.views:host_meta')] +add_route('mediagoblin.webfinger.host_meta', '/.well-known/host-meta', + 'mediagoblin.webfinger.views:host_meta') -webfinger_routes = [ - Route('mediagoblin.webfinger.xrd', '/xrd', - controller='mediagoblin.webfinger.views:xrd')] +add_route('mediagoblin.webfinger.xrd', '/webfinger/xrd', + 'mediagoblin.webfinger.views:xrd') From 1ec7ff2adbb1821c5318b4e0a18194f441d7a87e Mon Sep 17 00:00:00 2001 From: Joar Wandborg Date: Sun, 14 Oct 2012 20:05:44 +0200 Subject: [PATCH 002/140] Fixed 404 page under werkzeug.routing - Removed ?lang= feature due to incompatibility with werkzeug routes in the current state of the architecture. --- mediagoblin/app.py | 35 ++++++++++++++++--------------- mediagoblin/auth/routing.py | 4 ++-- mediagoblin/tools/translate.py | 7 +------ mediagoblin/user_pages/routing.py | 2 +- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 5758dbbb..8a19b3e0 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -15,7 +15,6 @@ # along with this program. If not, see . import os -import urllib import logging from mediagoblin.routing import url_map, view_functions, add_route @@ -138,7 +137,6 @@ class MediaGoblinApp(object): request.accept = request.accept_mimetypes ## Routing / controller loading stuff - path_info = request.path map_adapter = self.url_map.bind_to_environ(request.environ) # By using fcgi, mediagoblin can run under a base path @@ -167,21 +165,9 @@ class MediaGoblinApp(object): request.db = self.db request.staticdirect = self.staticdirector - mg_request.setup_user_in_request(request) - - try: - endpoint, url_values = map_adapter.match() - request.matchdict = url_values - - request.locale = translate.get_locale_from_request(request) - request.template_env = template.get_jinja_env( - self.template_loader, request.locale) - except NotFound as exc: - return NotImplemented - return render_404(request)(environ, start_response) - except HTTPException as exc: - # Support legacy webob.exc responses - return exc(environ, start_response) + request.locale = translate.get_locale_from_request(request) + request.template_env = template.get_jinja_env( + self.template_loader, request.locale) def build_proxy(endpoint, **kw): try: @@ -196,8 +182,23 @@ class MediaGoblinApp(object): request.urlgen = build_proxy + mg_request.setup_user_in_request(request) + + try: + endpoint, url_values = map_adapter.match() + request.matchdict = url_values + except NotFound as exc: + return render_404(request)(environ, start_response) + except HTTPException as exc: + # Support legacy webob.exc responses + return exc(environ, start_response) + view_func = view_functions[endpoint] + _log.debug('endpoint: {0} view_func: {1}'.format( + endpoint, + view_func)) + # import the endpoint, or if it's already a callable, call that if isinstance(view_func, unicode) \ or isinstance(view_func, str): diff --git a/mediagoblin/auth/routing.py b/mediagoblin/auth/routing.py index 58faa5a3..ee4b957a 100644 --- a/mediagoblin/auth/routing.py +++ b/mediagoblin/auth/routing.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from routes.route import add_route from mediagoblin.routing import add_route add_route('mediagoblin.auth.logout', @@ -36,9 +35,10 @@ add_route('mediagoblin.auth.verify_email', '/verify_email/', add_route('mediagoblin.auth.resend_verification', '/resend_verification/', 'mediagoblin.auth.views:resend_activation') +# XXX: Does this work? add_route('mediagoblin.auth.resend_verification_success', '/resend_verification_success/', - template='mediagoblin/auth/resent_verification_email.html', + # template='mediagoblin/auth/resent_verification_email.html', 'mediagoblin.views:simple_template_render') add_route('mediagoblin.auth.forgot_password', '/forgot_password/', diff --git a/mediagoblin/tools/translate.py b/mediagoblin/tools/translate.py index cdc827a0..01cabe6a 100644 --- a/mediagoblin/tools/translate.py +++ b/mediagoblin/tools/translate.py @@ -65,12 +65,7 @@ def get_locale_from_request(request): if request_form.has_key('lang'): return locale_to_lower_upper(request_form['lang']) - # Your routing can explicitly specify a target language - matchdict = request.matchdict or {} - - if 'locale' in matchdict: - target_lang = matchdict['locale'] - elif 'target_lang' in request.session: + if 'target_lang' in request.session: target_lang = request.session['target_lang'] # Pull the first acceptable language or English else: diff --git a/mediagoblin/user_pages/routing.py b/mediagoblin/user_pages/routing.py index 678f18f9..35e1bd6e 100644 --- a/mediagoblin/user_pages/routing.py +++ b/mediagoblin/user_pages/routing.py @@ -74,7 +74,7 @@ add_route('mediagoblin.user_pages.processing_panel', # Stray edit routes add_route('mediagoblin.edit.edit_media', '/u//m//edit/', - 'mediagoblin.user_pages.views:edit_media') + 'mediagoblin.edit.views:edit_media') add_route('mediagoblin.edit.attachments', '/u//m//attachments/', From 0d857844b12b033ee8ecdbcfa474781f835bee59 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Sun, 14 Oct 2012 16:26:23 -0500 Subject: [PATCH 003/140] Added rudimentary route "mounting" w/ werkzeug routes; fixed auth routes auth routes fixes: - mounted the auth routes at /auth/ - removed crufty old verification email route --- mediagoblin/auth/routing.py | 50 +++++++++++++---------------------- mediagoblin/routing.py | 15 ++++++++++- mediagoblin/submit/routing.py | 2 +- 3 files changed, 33 insertions(+), 34 deletions(-) diff --git a/mediagoblin/auth/routing.py b/mediagoblin/auth/routing.py index ee4b957a..145761ea 100644 --- a/mediagoblin/auth/routing.py +++ b/mediagoblin/auth/routing.py @@ -14,36 +14,22 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from mediagoblin.routing import add_route -add_route('mediagoblin.auth.logout', - '/auth/logout/', 'mediagoblin.auth.views:logout') - - -add_route('mediagoblin.auth.register', '/register/', - 'mediagoblin.auth.views:register') - -add_route('mediagoblin.auth.login', '/login/', - 'mediagoblin.auth.views:login') - -add_route('mediagoblin.auth.logout', '/logout/', - 'mediagoblin.auth.views:logout') - -add_route('mediagoblin.auth.verify_email', '/verify_email/', - 'mediagoblin.auth.views:verify_email') - -add_route('mediagoblin.auth.resend_verification', '/resend_verification/', - 'mediagoblin.auth.views:resend_activation') - -# XXX: Does this work? -add_route('mediagoblin.auth.resend_verification_success', - '/resend_verification_success/', - # template='mediagoblin/auth/resent_verification_email.html', - 'mediagoblin.views:simple_template_render') - -add_route('mediagoblin.auth.forgot_password', '/forgot_password/', - 'mediagoblin.auth.views:forgot_password') - -add_route('mediagoblin.auth.verify_forgot_password', - '/forgot_password/verify/', - 'mediagoblin.auth.views:verify_forgot_password') +auth_routes = [ + ('mediagoblin.auth.logout', + '/logout/', 'mediagoblin.auth.views:logout'), + ('mediagoblin.auth.register', '/register/', + 'mediagoblin.auth.views:register'), + ('mediagoblin.auth.login', '/login/', + 'mediagoblin.auth.views:login'), + ('mediagoblin.auth.logout', '/logout/', + 'mediagoblin.auth.views:logout'), + ('mediagoblin.auth.verify_email', '/verify_email/', + 'mediagoblin.auth.views:verify_email'), + ('mediagoblin.auth.resend_verification', '/resend_verification/', + 'mediagoblin.auth.views:resend_activation'), + ('mediagoblin.auth.forgot_password', '/forgot_password/', + 'mediagoblin.auth.views:forgot_password'), + ('mediagoblin.auth.verify_forgot_password', + '/forgot_password/verify/', + 'mediagoblin.auth.views:verify_forgot_password')] diff --git a/mediagoblin/routing.py b/mediagoblin/routing.py index 4b9c42ee..8f0f37a5 100644 --- a/mediagoblin/routing.py +++ b/mediagoblin/routing.py @@ -21,15 +21,28 @@ url_map = Map() view_functions = {'index': 'mediagoblin.views:index'} def add_route(endpoint, url, controller): + """ + Add a route to the url mapping + """ view_functions.update({endpoint: controller}) url_map.add(Rule(url, endpoint=endpoint)) +def mount(mountpoint, routes): + """ + Mount a bunch of routes to this mountpoint + """ + for endpoint, url, controller in routes: + url = "%s/%s" % (mountpoint.rstrip('/'), url.lstrip('/')) + add_route(endpoint, url, controller) + add_route('index', '/', 'mediagoblin.views:root_view') import mediagoblin.submit.routing import mediagoblin.user_pages.routing -import mediagoblin.auth.routing import mediagoblin.edit.routing import mediagoblin.webfinger.routing import mediagoblin.listings.routing + +from mediagoblin.auth.routing import auth_routes +mount('/auth', auth_routes) diff --git a/mediagoblin/submit/routing.py b/mediagoblin/submit/routing.py index cbed1895..fbe3c39c 100644 --- a/mediagoblin/submit/routing.py +++ b/mediagoblin/submit/routing.py @@ -18,4 +18,4 @@ from mediagoblin.routing import add_route add_route('mediagoblin.submit.start', '/submit/', 'mediagoblin.submit.views:submit_start') -add_route('collection_home', '/submit/collection', 'mediagoblin.submit.views:add_collection') +add_route('mediagoblin.submit.collection', '/submit/collection', 'mediagoblin.submit.views:add_collection') From d56e82635f85f7a8a7d184a3eae539c09a7b001d Mon Sep 17 00:00:00 2001 From: Joar Wandborg Date: Mon, 15 Oct 2012 00:12:58 +0200 Subject: [PATCH 004/140] Fixed OAuth access_token duplicate route Changed route name to "[...]list_connections" --- mediagoblin/app.py | 1 + mediagoblin/auth/routing.py | 2 -- mediagoblin/plugins/api/__init__.py | 9 ++++++--- mediagoblin/plugins/oauth/__init__.py | 11 +++++++---- mediagoblin/routing.py | 4 +++- mediagoblin/tools/pluginapi.py | 1 + 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 8a19b3e0..3a2d00f0 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -93,6 +93,7 @@ class MediaGoblinApp(object): self.url_map = url_map for route in PluginManager().get_routes(): + _log.debug('adding plugin route: {0}'.format(route)) add_route(*route) # set up staticdirector tool diff --git a/mediagoblin/auth/routing.py b/mediagoblin/auth/routing.py index 145761ea..2a6abb47 100644 --- a/mediagoblin/auth/routing.py +++ b/mediagoblin/auth/routing.py @@ -16,8 +16,6 @@ auth_routes = [ - ('mediagoblin.auth.logout', - '/logout/', 'mediagoblin.auth.views:logout'), ('mediagoblin.auth.register', '/register/', 'mediagoblin.auth.views:register'), ('mediagoblin.auth.login', '/login/', diff --git a/mediagoblin/plugins/api/__init__.py b/mediagoblin/plugins/api/__init__.py index f370cca6..3b7ced0c 100644 --- a/mediagoblin/plugins/api/__init__.py +++ b/mediagoblin/plugins/api/__init__.py @@ -33,11 +33,14 @@ def setup_plugin(): _log.debug('API config: {0}'.format(config)) routes = [ - ('mediagoblin.plugins.api.test', '/api/test', + ('mediagoblin.plugins.api.test', + '/api/test', 'mediagoblin.plugins.api.views:api_test'), - ('mediagoblin.plugins.api.entries', '/api/entries', + ('mediagoblin.plugins.api.entries', + '/api/entries', 'mediagoblin.plugins.api.views:get_entries'), - ('mediagoblin.plugins.api.post_entry', '/api/submit', + ('mediagoblin.plugins.api.post_entry', + '/api/submit', 'mediagoblin.plugins.api.views:post_entry')] pluginapi.register_routes(routes) diff --git a/mediagoblin/plugins/oauth/__init__.py b/mediagoblin/plugins/oauth/__init__.py index 64acf0e7..3ed695de 100644 --- a/mediagoblin/plugins/oauth/__init__.py +++ b/mediagoblin/plugins/oauth/__init__.py @@ -36,13 +36,16 @@ def setup_plugin(): _log.debug('OAuth config: {0}'.format(config)) routes = [ - ('mediagoblin.plugins.oauth.authorize', '/oauth/authorize', + ('mediagoblin.plugins.oauth.authorize', + '/oauth/authorize', 'mediagoblin.plugins.oauth.views:authorize'), - ('mediagoblin.plugins.oauth.authorize_client', '/oauth/client/authorize', + ('mediagoblin.plugins.oauth.authorize_client', + '/oauth/client/authorize', 'mediagoblin.plugins.oauth.views:authorize_client'), - ('mediagoblin.plugins.oauth.access_token', '/oauth/access_token', - 'mediagoblin.plugins.oauth.views:access_token'), ('mediagoblin.plugins.oauth.access_token', + '/oauth/access_token', + 'mediagoblin.plugins.oauth.views:access_token'), + ('mediagoblin.plugins.oauth.list_connections', '/oauth/client/connections', 'mediagoblin.plugins.oauth.views:list_connections'), ('mediagoblin.plugins.oauth.register_client', diff --git a/mediagoblin/routing.py b/mediagoblin/routing.py index 8f0f37a5..b61a3626 100644 --- a/mediagoblin/routing.py +++ b/mediagoblin/routing.py @@ -18,12 +18,14 @@ from werkzeug.routing import Map, Rule url_map = Map() -view_functions = {'index': 'mediagoblin.views:index'} +view_functions = {} def add_route(endpoint, url, controller): """ Add a route to the url mapping """ + #assert endpoint not in view_functions.keys(), 'Trying to overwrite a rule' + view_functions.update({endpoint: controller}) url_map.add(Rule(url, endpoint=endpoint)) diff --git a/mediagoblin/tools/pluginapi.py b/mediagoblin/tools/pluginapi.py index df3f51c4..1752dfc8 100644 --- a/mediagoblin/tools/pluginapi.py +++ b/mediagoblin/tools/pluginapi.py @@ -125,6 +125,7 @@ class PluginManager(object): def register_route(self, route): """Registers a single route""" + _log.debug('registering route: {0}'.format(route)) self.routes.append(route) def get_routes(self): From 42d4763c7a4cb049ed8ab30935a6a6394abdd8f4 Mon Sep 17 00:00:00 2001 From: Jef van Schendel Date: Fri, 19 Oct 2012 21:01:44 +0200 Subject: [PATCH 005/140] Thumbnail styling edits to base theme and Airy theme --- mediagoblin/static/css/base.css | 8 ++++++-- mediagoblin/themes/airy/assets/css/airy.css | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mediagoblin/static/css/base.css b/mediagoblin/static/css/base.css index 6bc85674..c6152a1c 100644 --- a/mediagoblin/static/css/base.css +++ b/mediagoblin/static/css/base.css @@ -408,10 +408,10 @@ textarea#comment_content { .media_thumbnail { float: left; padding: 0px; - width: 180px; + width: 212px; height: 156px; overflow: hidden; - margin: 0px 4px 10px; + margin: 0px 28px 24px 0px; text-align: center; font-size: 0.875em; background-color: #222; @@ -431,6 +431,10 @@ textarea#comment_content { max-height: 135px; } +.thumb_entry_last { + margin-right: 0px; +} + /* collection media */ .collection_thumbnail { diff --git a/mediagoblin/themes/airy/assets/css/airy.css b/mediagoblin/themes/airy/assets/css/airy.css index 22f12d5e..da4ed085 100644 --- a/mediagoblin/themes/airy/assets/css/airy.css +++ b/mediagoblin/themes/airy/assets/css/airy.css @@ -67,7 +67,7 @@ input, textarea { .media_thumbnail { background-color: #fff; border: 1px solid #e4e4e4; - margin: 0 3px 10px; + border-width: 1px 1px 2px; } .media_thumbnail a { From 1c66750a4a0611d2399e6e60eec5ea6915b458f6 Mon Sep 17 00:00:00 2001 From: Jef van Schendel Date: Fri, 19 Oct 2012 21:13:40 +0200 Subject: [PATCH 006/140] Thumbnail styling edits plus edits to the object_gallery (4 columns instead of 5 by default) --- mediagoblin/static/css/base.css | 11 ++++++++--- .../templates/mediagoblin/utils/object_gallery.html | 7 +++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/mediagoblin/static/css/base.css b/mediagoblin/static/css/base.css index c6152a1c..312edc49 100644 --- a/mediagoblin/static/css/base.css +++ b/mediagoblin/static/css/base.css @@ -409,9 +409,8 @@ textarea#comment_content { float: left; padding: 0px; width: 212px; - height: 156px; overflow: hidden; - margin: 0px 28px 24px 0px; + margin: 0px 28px 26px 0px; text-align: center; font-size: 0.875em; background-color: #222; @@ -425,10 +424,16 @@ textarea#comment_content { .media_thumbnail a { color: #eee; text-decoration: none; + display: block; +} + +a.thumb_entry_title { + padding: 8px; } .media_thumbnail img { - max-height: 135px; + width: 212px; + max-height: 159px; } .thumb_entry_last { diff --git a/mediagoblin/templates/mediagoblin/utils/object_gallery.html b/mediagoblin/templates/mediagoblin/utils/object_gallery.html index 81506a84..b63419a8 100644 --- a/mediagoblin/templates/mediagoblin/utils/object_gallery.html +++ b/mediagoblin/templates/mediagoblin/utils/object_gallery.html @@ -18,7 +18,7 @@ {% from "mediagoblin/utils/pagination.html" import render_pagination %} -{% macro media_grid(request, media_entries, col_number=5) %} +{% macro media_grid(request, media_entries, col_number=4) %} {% for row in gridify_cursor(media_entries, col_number) %} {% if entry.title %} -
- {{ entry.title }} + {{ entry.title }} {% endif %} {% endfor %} @@ -56,7 +55,7 @@ - col_number: How many columns per row (default 5) #} {% macro object_gallery(request, media_entries, pagination, - pagination_base_url=None, col_number=5) %} + pagination_base_url=None, col_number=4) %} {% if media_entries and media_entries.count() %} {{ media_grid(request, media_entries, col_number=col_number) }}
From 54397b90633b350984dc72ce192b2e2373203463 Mon Sep 17 00:00:00 2001 From: Jef van Schendel Date: Fri, 19 Oct 2012 21:21:53 +0200 Subject: [PATCH 007/140] Styling edits for buttons (Airy only) --- mediagoblin/themes/airy/assets/css/airy.css | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mediagoblin/themes/airy/assets/css/airy.css b/mediagoblin/themes/airy/assets/css/airy.css index da4ed085..ba9048b2 100644 --- a/mediagoblin/themes/airy/assets/css/airy.css +++ b/mediagoblin/themes/airy/assets/css/airy.css @@ -18,7 +18,8 @@ a { .navigation_button { background-color: #fff; border: 1px solid; - border-color: #F3F3F3 #ECECEC #C7C7C7; + border-color: #e4e4e4; + border-width: 1px 1px 2px; color: #4a4a4a; font-weight: bold; } @@ -44,14 +45,16 @@ footer { color: #4a4a4a; background-color: #fff; border: 1px solid; - border-color: #F3F3F3 #ECECEC #C7C7C7; + border-color: #E4E4E4; + border-width: 1px 1px 2px; padding: 5px 10px; } .button_action_highlight, .button_form { color: #fff; background-color: #37BD85; - border-color: #A2DEC3 #6CAA8E #5C9179; + border-color: #6CAA8E; + border-width: 1px 1px 2px; } input, textarea { From 5b60ec41ee5d0f25d66190b2a0114a8e1b216f86 Mon Sep 17 00:00:00 2001 From: Joar Wandborg Date: Sat, 20 Oct 2012 12:09:23 +0200 Subject: [PATCH 008/140] Removed Routes dependency, added admin routes --- mediagoblin/admin/routing.py | 7 +++---- mediagoblin/plugins/api/__init__.py | 2 -- mediagoblin/plugins/flatpagesfile/__init__.py | 3 +-- mediagoblin/plugins/oauth/__init__.py | 2 -- mediagoblin/routing.py | 13 +++++++++---- setup.py | 1 - 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/mediagoblin/admin/routing.py b/mediagoblin/admin/routing.py index ea768c24..29515f12 100644 --- a/mediagoblin/admin/routing.py +++ b/mediagoblin/admin/routing.py @@ -14,8 +14,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from routes.route import Route - admin_routes = [ - Route('mediagoblin.admin.panel', '/panel', - controller='mediagoblin.admin.views:admin_processing_panel')] + ('mediagoblin.admin.panel', + '/panel', + 'mediagoblin.admin.views:admin_processing_panel')] diff --git a/mediagoblin/plugins/api/__init__.py b/mediagoblin/plugins/api/__init__.py index 3b7ced0c..d3fdf2ef 100644 --- a/mediagoblin/plugins/api/__init__.py +++ b/mediagoblin/plugins/api/__init__.py @@ -17,8 +17,6 @@ import os import logging -from routes.route import Route - from mediagoblin.tools import pluginapi _log = logging.getLogger(__name__) diff --git a/mediagoblin/plugins/flatpagesfile/__init__.py b/mediagoblin/plugins/flatpagesfile/__init__.py index b9b52012..3d797809 100644 --- a/mediagoblin/plugins/flatpagesfile/__init__.py +++ b/mediagoblin/plugins/flatpagesfile/__init__.py @@ -19,7 +19,6 @@ import logging import os import jinja2 -from routes.route import Route from mediagoblin.tools import pluginapi from mediagoblin.tools.response import render_to_response @@ -68,7 +67,7 @@ def setup_plugin(): name = 'flatpagesfile.%s' % name.strip() controller = flatpage_handler_builder(template) routes.append( - Route(name, url, controller=controller)) + (name, url, controller)) pluginapi.register_routes(routes) _log.info('Done setting up flatpagesfile!') diff --git a/mediagoblin/plugins/oauth/__init__.py b/mediagoblin/plugins/oauth/__init__.py index 3ed695de..4714d95d 100644 --- a/mediagoblin/plugins/oauth/__init__.py +++ b/mediagoblin/plugins/oauth/__init__.py @@ -17,8 +17,6 @@ import os import logging -from routes.route import Route - from mediagoblin.tools import pluginapi from mediagoblin.plugins.oauth.models import OAuthToken, OAuthClient, \ OAuthUserClient diff --git a/mediagoblin/routing.py b/mediagoblin/routing.py index b61a3626..defbc4ba 100644 --- a/mediagoblin/routing.py +++ b/mediagoblin/routing.py @@ -24,7 +24,10 @@ def add_route(endpoint, url, controller): """ Add a route to the url mapping """ - #assert endpoint not in view_functions.keys(), 'Trying to overwrite a rule' + # XXX: We cannot use this, since running tests means that the plugin + # routes will be populated over and over over the same session. + # + # assert endpoint not in view_functions.keys(), 'Trying to overwrite a rule' view_functions.update({endpoint: controller}) @@ -40,11 +43,13 @@ def mount(mountpoint, routes): add_route('index', '/', 'mediagoblin.views:root_view') +from mediagoblin.admin.routing import admin_routes +from mediagoblin.auth.routing import auth_routes +mount('/auth', auth_routes) +mount('/a', admin_routes) + import mediagoblin.submit.routing import mediagoblin.user_pages.routing import mediagoblin.edit.routing import mediagoblin.webfinger.routing import mediagoblin.listings.routing - -from mediagoblin.auth.routing import auth_routes -mount('/auth', auth_routes) diff --git a/setup.py b/setup.py index 21c1179e..99584369 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,6 @@ setup( 'setuptools', 'PasteScript', 'beaker', - 'routes', 'webob<=1.2a2,>=1.1', 'wtforms', 'py-bcrypt', From e3f1fddf872caae45d6f4fdc81c2f4f9e8e19022 Mon Sep 17 00:00:00 2001 From: Jef van Schendel Date: Sat, 20 Oct 2012 15:19:11 +0200 Subject: [PATCH 009/140] Fix thumbnail aspect ratios --- mediagoblin/static/css/base.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediagoblin/static/css/base.css b/mediagoblin/static/css/base.css index 312edc49..b37da026 100644 --- a/mediagoblin/static/css/base.css +++ b/mediagoblin/static/css/base.css @@ -432,7 +432,7 @@ a.thumb_entry_title { } .media_thumbnail img { - width: 212px; + width: auto; max-height: 159px; } From 933b5a49633b497af9557e94cf20cf280bae9e72 Mon Sep 17 00:00:00 2001 From: Jef van Schendel Date: Sat, 20 Oct 2012 16:47:31 +0200 Subject: [PATCH 010/140] Replace dark empty_dots.png for Airy theme --- mediagoblin/themes/airy/assets/css/airy.css | 4 ++++ .../themes/airy/assets/images/empty_dots.png | Bin 0 -> 205 bytes 2 files changed, 4 insertions(+) create mode 100644 mediagoblin/themes/airy/assets/images/empty_dots.png diff --git a/mediagoblin/themes/airy/assets/css/airy.css b/mediagoblin/themes/airy/assets/css/airy.css index ba9048b2..09d447d2 100644 --- a/mediagoblin/themes/airy/assets/css/airy.css +++ b/mediagoblin/themes/airy/assets/css/airy.css @@ -86,3 +86,7 @@ input, textarea { .dropdown_items { background-color: #fff; } + +.empty_space { + background-image: url("../images/empty_dots.png"); +} diff --git a/mediagoblin/themes/airy/assets/images/empty_dots.png b/mediagoblin/themes/airy/assets/images/empty_dots.png new file mode 100644 index 0000000000000000000000000000000000000000..5ee050b218fce0f869580f5060a4774bf7508788 GIT binary patch literal 205 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4u@pObhHwBu4M$1`kk47*5m^kR ztU#FYL&_vCprB-lYeY$Kep*R+Vo@qXd3m{BW?pu2a$-TMUVc&f>~}U&Kt*1jE{-7* zQxJ3EWj|NZ~}pJ#``Wgx{ZAtAA3=8PGaBtI}L1M^-UNSOct literal 0 HcmV?d00001 From e711d1cf7271c24597dcd7fb42746e7e474b63cb Mon Sep 17 00:00:00 2001 From: Jef van Schendel Date: Sat, 20 Oct 2012 18:09:45 +0200 Subject: [PATCH 011/140] Replace icon_feed.png with proper Airy version --- .../themes/airy/assets/images/icon_feed.png | Bin 0 -> 473 bytes .../mediagoblin/utils/feed_link.html | 23 ++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 mediagoblin/themes/airy/assets/images/icon_feed.png create mode 100644 mediagoblin/themes/airy/templates/mediagoblin/utils/feed_link.html diff --git a/mediagoblin/themes/airy/assets/images/icon_feed.png b/mediagoblin/themes/airy/assets/images/icon_feed.png new file mode 100644 index 0000000000000000000000000000000000000000..18c085b4c40c7e0043f354bee4c81688d7504f88 GIT binary patch literal 473 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^PK; zkR_TQD8gCb5m^k>ejS7voit`w00r4gJbhi+?{J9-F!HZVRI~+}66xvU7-DgH>14xI zha3dj_IH?HIOP?{!o7OSL1vCH=C1aDi5eab0xbLqIcFFzATF>>%F`FHJAi>~3Y3!7sC!Z^IBi4p7lvv5e z-p<>;o. +#} + + + {% trans %}feed icon{% endtrans %} + +{%- trans %}Atom feed{% endtrans -%} From f93ac9f28cf966f67af4a675a07fc79429e3095d Mon Sep 17 00:00:00 2001 From: Jef van Schendel Date: Sat, 20 Oct 2012 18:33:26 +0200 Subject: [PATCH 012/140] Implement new RSS icon for Airy theme --- .../themes/airy/templates/mediagoblin/utils/feed_link.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediagoblin/themes/airy/templates/mediagoblin/utils/feed_link.html b/mediagoblin/themes/airy/templates/mediagoblin/utils/feed_link.html index 6a41cef5..cf5099a2 100644 --- a/mediagoblin/themes/airy/templates/mediagoblin/utils/feed_link.html +++ b/mediagoblin/themes/airy/templates/mediagoblin/utils/feed_link.html @@ -17,7 +17,7 @@ #} - {% trans %}feed icon{% endtrans %} {%- trans %}Atom feed{% endtrans -%} From ac4c5aef5775d5c4a3d8ebd5528e6d2db8062174 Mon Sep 17 00:00:00 2001 From: Joar Wandborg Date: Sat, 20 Oct 2012 23:56:00 +0200 Subject: [PATCH 013/140] Added HTTP API auth plugin --- mediagoblin/plugins/httpapiauth/__init__.py | 58 +++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 mediagoblin/plugins/httpapiauth/__init__.py diff --git a/mediagoblin/plugins/httpapiauth/__init__.py b/mediagoblin/plugins/httpapiauth/__init__.py new file mode 100644 index 00000000..d3d2065e --- /dev/null +++ b/mediagoblin/plugins/httpapiauth/__init__.py @@ -0,0 +1,58 @@ +# GNU MediaGoblin -- federated, autonomous media hosting +# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import logging +import base64 + +from werkzeug.exceptions import BadRequest, Unauthorized + +from mediagoblin.plugins.api.tools import Auth + +_log = logging.getLogger(__name__) + + +def setup_http_api_auth(): + _log.info('Setting up HTTP API Auth...') + + +class HTTPAuth(Auth): + def trigger(self, request): + if request.authorization: + return True + + return False + + def __call__(self, request, *args, **kw): + _log.debug('Trying to authorize the user agent via HTTP Auth') + if not request.authorization: + return False + + user = request.db.User.query.filter_by( + username=request.authorization['username']).first() + + if user.check_login(request.authorization['password']): + request.user = user + return True + else: + raise Unauthorized() + + return False + + + +hooks = { + 'setup': setup_http_api_auth, + 'auth': HTTPAuth()} From c40cb686de2c5ea242af81ac749d9239ac6a2dab Mon Sep 17 00:00:00 2001 From: Jef van Schendel Date: Sun, 21 Oct 2012 02:17:38 +0200 Subject: [PATCH 014/140] Styling edits to Airy theme --- mediagoblin/themes/airy/assets/css/airy.css | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mediagoblin/themes/airy/assets/css/airy.css b/mediagoblin/themes/airy/assets/css/airy.css index 09d447d2..6143b6e1 100644 --- a/mediagoblin/themes/airy/assets/css/airy.css +++ b/mediagoblin/themes/airy/assets/css/airy.css @@ -3,16 +3,12 @@ body { background-color: #F7F7F7; } -h1,h2 { - color: #787878; -} - -h3 { +h1,h2,h3 { color: #4a4a4a; } a { - color: #37BD85; + color: #37AB74; } .navigation_button { @@ -52,7 +48,7 @@ footer { .button_action_highlight, .button_form { color: #fff; - background-color: #37BD85; + background-color: #37AB74; border-color: #6CAA8E; border-width: 1px 1px 2px; } From 30a8828f9b4efc4ff8026a375f11756ca76e412b Mon Sep 17 00:00:00 2001 From: Jef van Schendel Date: Sun, 21 Oct 2012 20:36:30 +0200 Subject: [PATCH 015/140] Add "Add collection" link to Airy theme --- mediagoblin/themes/airy/templates/mediagoblin/base.html | 1 + 1 file changed, 1 insertion(+) diff --git a/mediagoblin/themes/airy/templates/mediagoblin/base.html b/mediagoblin/themes/airy/templates/mediagoblin/base.html index 8bd9a7f9..d243d331 100644 --- a/mediagoblin/themes/airy/templates/mediagoblin/base.html +++ b/mediagoblin/themes/airy/templates/mediagoblin/base.html @@ -65,6 +65,7 @@ {% for row in gridify_cursor(media_entries, col_number) %} From 52aef5b445710dbe800ebba7f44ca0cc0e06ea54 Mon Sep 17 00:00:00 2001 From: Jef van Schendel Date: Thu, 1 Nov 2012 17:10:16 +0100 Subject: [PATCH 027/140] Revert thumbnail styling and sizing; allows for 5 thumbnails per row --- mediagoblin/static/css/base.css | 8 ++++---- mediagoblin/themes/airy/assets/css/airy.css | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/mediagoblin/static/css/base.css b/mediagoblin/static/css/base.css index 6cda47fc..4120f965 100644 --- a/mediagoblin/static/css/base.css +++ b/mediagoblin/static/css/base.css @@ -377,9 +377,10 @@ textarea#comment_content { .media_thumbnail { float: left; padding: 0px; - width: 212px; + width: 180px; + height: 156px; overflow: hidden; - margin: 0px 28px 26px 0px; + margin: 0px 4px 10px; text-align: center; font-size: 0.875em; background-color: #222; @@ -401,8 +402,7 @@ a.thumb_entry_title { } .media_thumbnail img { - width: 212px; - max-height: 159px; + max-height: 135px; } .thumb_entry_last { diff --git a/mediagoblin/themes/airy/assets/css/airy.css b/mediagoblin/themes/airy/assets/css/airy.css index f3d11171..c63345b2 100644 --- a/mediagoblin/themes/airy/assets/css/airy.css +++ b/mediagoblin/themes/airy/assets/css/airy.css @@ -65,8 +65,6 @@ input, textarea { .media_thumbnail { background-color: #fff; - border: 1px solid #e4e4e4; - border-width: 1px 1px 2px; } .media_thumbnail a { From 5e5b8acfec73ad7f12eb685ff81c6962aee655f1 Mon Sep 17 00:00:00 2001 From: LotusEcho Date: Mon, 24 Sep 2012 16:15:34 -0400 Subject: [PATCH 028/140] Don't put checkbox text on separate line (#475) Manually render the "notify me" checkbox line in the account settings to not put the form label as a heading but in the same line as the checkbox. Edit forms.py to use the label attribute for the caption. Original patch modified by Sebastian Spaeth to 1) not translate the checkbox label in the template, it is translated in forms.py already. 2) Simplify the HTML, manually constructing the