Navigation Menu

Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Brought over pyramid gui.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcsackett authored and mitechie committed Aug 20, 2015
1 parent 8c2c10e commit cc35a7f
Show file tree
Hide file tree
Showing 28 changed files with 3,026 additions and 1,333 deletions.
643 changes: 643 additions & 0 deletions HACKING-old.rst

Large diffs are not rendered by default.

634 changes: 36 additions & 598 deletions HACKING.rst

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,8 @@
# Copyright 2015 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

include HACKING.rst
include MANIFEST.in
include Makefile
recursive-include jujugui/static *
recursive-include jujugui/templates *
949 changes: 230 additions & 719 deletions Makefile

Large diffs are not rendered by default.

733 changes: 733 additions & 0 deletions Makefile-old

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions config.js
Expand Up @@ -3,17 +3,21 @@ var config = {
'port': 8888,
'public_hostname': 'localhost',
'template_dirs': [
__dirname + '/app/templates/',
__dirname + '/app/subapps/browser/templates/'
__dirname + '/jujugui/static/gui/src/app/templates/',
__dirname + '/jujugui/static/gui/src/app/subapps/browser/templates/'
],
'view_dirs': [
__dirname + '/jujugui/static/gui/src/lib/views/',
__dirname + '/jujugui/static/gui/src/lib/views/browser'
],
'scss_dirs': [
// Must have the top level path first.
__dirname + '/app/assets/css/',
__dirname + '/app/assets/css/browser',
__dirname + '/app/assets/css/inspector',
__dirname + '/app/assets/css/machine-view'
__dirname + '/jujugui/static/gui/src/app/assets/css/'
__dirname + '/jujugui/static/gui/src/app/assets/css/browser'
__dirname + '/jujugui/static/gui/src/app/assets/css/inspector'
__dirname + '/jujugui/static/gui/src/app/assets/css/machine-view'
],
'public_dir': __dirname + '/app'
'public_dir': __dirname + '/jujugui/static/gui/build/app'
}
};

Expand Down
53 changes: 53 additions & 0 deletions development.ini
@@ -0,0 +1,53 @@
###
# app configuration
# http://docs.pylonsproject.org/projects/pyramid/en/1.5-branch/narr/environment.html
###

[app:main]
use = egg:jujugui

pyramid.reload_templates = true
pyramid.default_locale_name = en

jujugui.sandbox = true

###
# wsgi server configuration
###

[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543

###
# logging configuration
# http://docs.pylonsproject.org/projects/pyramid/en/1.5-branch/narr/logging.html
###

[loggers]
keys = root, jujugui

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = INFO
handlers = console

[logger_jujugui]
level = DEBUG
handlers =
qualname = jujugui

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
2 changes: 1 addition & 1 deletion grunt.js
Expand Up @@ -15,7 +15,7 @@ module.exports = function(grunt) {

},
files: {
'build-shared/juju-ui/assets': 'app/assets/images/*'
'jujugui/static/gui/build/app/assets': 'jujugui/static/gui/src/app/assets/images/*'
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions jujugui/__init__.py
@@ -0,0 +1,20 @@
# Copyright 2015 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

from pyramid.config import Configurator


def main(global_config, **settings):
"""Return a Pyramid WSGI application."""
config = Configurator(settings=settings)
return make_application(config)


def make_application(config):
"""Set up the routes and return the WSGI application."""
# We use two separate included app/routes so that we can
# have the gui parts behind a separate route from the
# assets when we embed it in e.g. the storefront.
config.include('jujugui.gui')
config.include('jujugui.assets')
return config.make_wsgi_app()
13 changes: 13 additions & 0 deletions jujugui/assets.py
@@ -0,0 +1,13 @@
# Copyright 2015 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).


def assets(config):
config.add_static_view(
'juju-ui/assets',
'jujugui:static/gui/build/app/assets',
cache_max_age=3600)


def includeme(config):
return assets(config)
33 changes: 33 additions & 0 deletions jujugui/gui.py
@@ -0,0 +1,33 @@
# Copyright 2015 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

import os

from convoy.combo import combo_app
from pyramid.wsgi import wsgiapp2

from jujugui import options


_APP_DIR = os.path.split(os.path.abspath(__file__))[0]


def gui(config):
options.update(config.registry.settings)
config.add_route('jujugui.app', '/')
config.add_route('jujugui.config', '/config.js')
config.add_route('jujugui.sprites', '/app/assets/sprites.png')
# XXX jcsackett 2015-05-20 As soon as we have a means of getting a version
# or other indicator from the juju-gui we want to add that as a combo
# cache buster.
config.add_route('jujugui.convoy', '/combo')
js_files = _APP_DIR + '/static/gui/build'
headers = [('Cache-Control', 'max-age=3600, public')]
application = combo_app(js_files, additional_headers=headers)
config.add_view(wsgiapp2(application), route_name='jujugui.convoy')
config.include('pyramid_mako')
config.scan('jujugui.views')


def includeme(config):
return gui(config)
35 changes: 35 additions & 0 deletions jujugui/options.py
@@ -0,0 +1,35 @@
# Copyright 2015 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

import functools

from pyramid.settings import asbool


# Define default values for options.
DEFAULT_CHARMSTORE_URL = 'https://api.jujucharms.com/charmstore/'


def update(settings):
"""Normalize and update the Juju GUI app settings.
Modify the given settings object in place.
"""
_update(settings, 'jujugui.charmstore_url', default=DEFAULT_CHARMSTORE_URL)
_update(settings, 'jujugui.ga_key', default='')
_update_bool(settings, 'jujugui.sandbox', default=False)


def _update(settings, name, default=None, convert=lambda value: value):
"""Update the value with the given name on the given settings.
If the value is not found in settings, or it is empty, the given default is
used. If a convert callable is provided, it is called on the resulting
value.
Modify the given settings object in place.
"""
settings[name] = convert(settings.get(name, default) or default)


_update_bool = functools.partial(_update, convert=asbool)

0 comments on commit cc35a7f

Please sign in to comment.