Simple "staticstuff" plugin for writing unit tests on plugin static asset linking.

It doesn't do much... it just has a static directory with a "bunnify"
CSS file and has a unit test that returns a json encoded set of a
staticdirect with both this plugin enabled and also
with (theoretically) a file distributed with MediaGoblin (it isn't
really, but in our case that doesn't matter.)

Also set up the static_setup hook / PluginStatic object for this
plugin; testing that with `./bin/gmg theme assetlink` seemed to work.
(And argh, need to update that command name, I know.)

This commit sponsored by Bradley Kuhn.  Thanks bkuhn!
This commit is contained in:
Christopher Allan Webber
2013-05-22 14:20:44 -05:00
parent df69695d9e
commit 1b2cf1e823
4 changed files with 94 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
# 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 <http://www.gnu.org/licenses/>.
from mediagoblin.tools.staticdirect import PluginStatic
from mediagoblin.tools import pluginapi
from pkg_resources import resource_filename
def setup_plugin():
routes = [
('staticstuff.static_demo',
'/staticstuff/',
'mediagoblin.tests.testplugins.staticstuff.views:static_demo')]
pluginapi.register_routes(routes)
hooks = {
'setup': setup_plugin,
'static_setup': lambda: PluginStatic(
'staticstuff',
resource_filename(
'mediagoblin.tests.testplugins.staticstuff',
'static'))}

View File

@@ -0,0 +1,4 @@
body {
background-color: #5edcf1;
color: #eb8add;
}

View File

@@ -0,0 +1,28 @@
# 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 <http://www.gnu.org/licenses/>.
import json
from werkzeug import Response
def static_demo(request):
return Response(json.dumps({
# this does not exist, but we'll pretend it does ;)
'mgoblin_bunny_pic': request.staticdirect(
'images/bunny_pic.png'),
'plugin_bunny_css': request.staticdirect(
'css/bunnyify.css', 'staticstuff')}))