diff options
author | Ralph Bean <ralph.bean@gmail.com> | 2011-04-12 13:44:48 -0400 |
---|---|---|
committer | Ralph Bean <ralph.bean@gmail.com> | 2011-04-12 13:44:48 -0400 |
commit | eb391450fce38a448e2cb67892d771bc221aae91 (patch) | |
tree | 1e63e7aadb5bc5d10854a3f5fb276b8b918efbf6 | |
parent | 6726d44da179a5f5c1286fc4b4c5bec96b226e00 (diff) | |
download | leafymiracle-eb391450fce38a448e2cb67892d771bc221aae91.tar.gz leafymiracle-eb391450fce38a448e2cb67892d771bc221aae91.tar.xz leafymiracle-eb391450fce38a448e2cb67892d771bc221aae91.zip |
Style tweaks
-rw-r--r-- | leafymiracle/__init__.py | 1 | ||||
-rw-r--r-- | leafymiracle/static/css/leafy.css | 7 | ||||
-rw-r--r-- | leafymiracle/templates/model.pt | 5 | ||||
-rw-r--r-- | leafymiracle/widgets.py | 35 |
4 files changed, 43 insertions, 5 deletions
diff --git a/leafymiracle/__init__.py b/leafymiracle/__init__.py index 46e19d9..0a89de9 100644 --- a/leafymiracle/__init__.py +++ b/leafymiracle/__init__.py @@ -32,6 +32,7 @@ def main(global_config, **settings): config.add_view('leafymiracle.views.view_model', context='leafymiracle.models.Root', renderer="templates/model.pt") + config.add_static_view(name='static', path='static') # Create the data view for our tw2.jit.SQLARadialGraph jit_view = lambda context, request: LeafyGraph.request(request) diff --git a/leafymiracle/static/css/leafy.css b/leafymiracle/static/css/leafy.css new file mode 100644 index 0000000..78e98f5 --- /dev/null +++ b/leafymiracle/static/css/leafy.css @@ -0,0 +1,7 @@ +#leafy_graph { + width: 100%; +} + +#leafy_graph-canvaswidget { + margin: auto; +} diff --git a/leafymiracle/templates/model.pt b/leafymiracle/templates/model.pt index cb452a4..12bc660 100644 --- a/leafymiracle/templates/model.pt +++ b/leafymiracle/templates/model.pt @@ -2,8 +2,9 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:tal="http://xml.zope.org/namespaces/tal"> <head> <title>Fedora Comps Visualization, by Luke Macken</title> + <link rel="stylesheet" type="text/css" href="static/css/leafy.css"/> </head> -<body bgcolor="#444444"> - <div tal:content="structure jitwidget.display()"></div> +<body> + <div class="inner" tal:content="structure jitwidget.display()"></div> </body> </html> diff --git a/leafymiracle/widgets.py b/leafymiracle/widgets.py index cf17342..d2b38c0 100644 --- a/leafymiracle/widgets.py +++ b/leafymiracle/widgets.py @@ -18,15 +18,20 @@ from tw2.core.resources import JSSymbol from leafymiracle import models +# Using mihmo's mathematically nice colors for fedora. +# http://mihmo.livejournal.com/37350.html +triads = ["#3c6eb4", "#b53c6e", "#6eb53c"] +triads_dark = ["#294172", "#732942", "#427329"] + + class LeafyGraph(SQLARadialGraph): id = 'leafy_graph' entities = [models.Root, models.Category, models.Group, models.Package] base_url = '/data' width = '1000' - height = '650' + height = '750' depth = 2 levelDistance = 150 - backgroundcolor = '#444444' alphabetize_relations = 24 alphabetize_minimal = True show_attributes = False @@ -35,4 +40,28 @@ class LeafyGraph(SQLARadialGraph): excluded_columns = ['group'] deep_linking = True #transition = JSSymbol(src='$jit.Trans.Back.easeInOut') - duration = 200 + duration = 400 + + backgroundcolor = '#FFFFFF' + background = { 'CanvasStyles': { 'strokeStyle' : '#FFFFFF' } } + Node = { 'color' : triads[1] } + Edge = { 'color' : triads[2], 'lineWidth':1.5, } + + # Override the label style + onPlaceLabel = JSSymbol(src=""" + (function(domElement, node){ + domElement.style.display = "none"; + domElement.innerHTML = node.name; + domElement.style.display = ""; + var left = parseInt(domElement.style.left); + domElement.style.width = '120px'; + domElement.style.height = ''; + var w = domElement.offsetWidth; + domElement.style.left = (left - w /2) + 'px'; + + domElement.style.cursor = 'pointer'; + if ( node._depth <= 1 ) + domElement.style.color = '%s'; + else + domElement.style.color = '%s'; + })""" % (triads[0], triads_dark[0])) |