This repository has been archived by the owner on May 12, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
3,026 additions
and
1,333 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 * |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
Oops, something went wrong.