Permalink
Browse files

Packager implementation.

  • Loading branch information...
1 parent 8ebf164 commit fe0b7eabcbc413d516970abccbe53ce829942566 @anutron committed Jun 18, 2011
@@ -10,6 +10,8 @@
)
MIDDLEWARE_CLASSES = (
+ 'django.middleware.common.CommonMiddleware',
+ 'djangomako.middleware.MakoMiddleware',
)
ROOT_URLCONF = 'mootools.urls'
@@ -18,6 +20,10 @@
'depender'
)
+MAKO_TEMPLATE_DIRS = (
+ os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "src", "depender", "templates")),
+)
+
# Depender configuration
@@ -35,7 +41,7 @@
)
DEPENDER_SCRIPTS_JSON = []
DEPENDER_EXCLUDE_BLOCKS = []
-
+BUILDER_PACKAGES = ['Core', 'More']
# Set to true to re-load all JS every time. (slowish)
DEPENDER_DEBUG = True; ##os.getenv("DEPENDER_DEBUG", "0").lower() not in ["0","false",""]
@@ -0,0 +1,89 @@
+<%def name="builder(include_mootools=True, include_reset=True)">
+ <!-- packager -->
+
+ % if include_reset:
+ <link rel="stylesheet" type="text/css" media="screen" href="/depender/static/reset.css" />
+ % endif
+ <link rel="stylesheet" type="text/css" media="screen" href="/depender/static/packager.css" />
+ % if include_mootools:
+ <script type="text/javascript" src="/depender/static/mootools-core-1.3.2.js"></script>
+ % endif
+ <script type="text/javascript" src="/depender/static/packager.js"></script>
+ <script type="text/javascript">document.addEvent('domready', Packager.init);</script>
+ <form id="packager" action="/depender/build" method="get" style="margin-top: 10px">
+ <input type="hidden" name="download" value="true"/>
+
+ % for p in packages:
+ <div id="package-${p}" class="package">
+
+ <table class="vertical">
+ <thead>
+ <tr class="first">
+ <th>Name</th>
+ <td>
+ ${p}
+ <div class="buttons">
+ <input type="checkbox" name="excludeLibs" class="toggle" value="${p}"/>
+ <div class="enabled">
+ <input type="button" class="select" value="select package" />
+ <input type="button" class="deselect" value="deselect package" />
+ <input type="button" class="disable" value="disable package" />
+ </div>
+ <div class="disabled">
+ <input type="button" class="enable" value="enable package" />
+ </div>
+ </div>
+ </td>
+ </tr>
+ </thead>
+ <tbody>
+ % for key in ["web", "description", "copyright", "license", "authors"]:
+ % if key in dpdr.packages[p].metadata:
+ <%
+ klass = "middle"
+ if key == "authors":
+ klass = "last"
+ %>
+ <tr class="${klass}">
+ <th>${key.capitalize()}</th>
+ <td><p>${markdown(dpdr.packages[p].metadata[key])}</p></td>
+ </tr>
+ % endif
+ % endfor
+ </tbody>
+ </table>
+
+ <table class="horizontal">
+ <tr class="first">
+ <th class="first"></th>
+ <th class="middle">File</th>
+ <th class="middle">Provides</th>
+ <th class="last">Description</th>
+ </tr>
+
+ % for filedata in sorted(dpdr.packages[p].files, key=lambda file:file.filename):
+ <tr class="middle unchecked">
+ <td class="first check">
+ <div class="checkbox"></div>
+ <input type="checkbox" name="require" value="${p}/${filedata.metadata['name']}" data-depends="${', '.join(get_depends(p, filedata.filename))}" />
+ </td>
+ <td class="middle file">${filedata.metadata['name']}</td>
+ <td class="middle provides">${', '.join(get_provides(p, filedata.filename))}</td>
+ <td class="last description"><p>${filedata.metadata['description']}</p></td>
+ </tr>
+ % endfor
+
+
+ </table>
+
+ </div>
+ % endfor
+
+ <p class="submit">
+ <input type="reset" value="reset" />
+ <input type="submit" value="download" />
+ </p>
+
+ </form>
+</%def>
+
@@ -0,0 +1,12 @@
+<%namespace name="components" file="builder.mako" />
+
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8" />
+ <title>Depender - Library Builder</title>
+</head>
+<body>
+ ${components.builder()}
+</body>
+</html>
@@ -5,6 +5,7 @@
urlpatterns = patterns('',
url(r'^build$', 'depender.views.build'),
+ url(r'^$', 'depender.views.builder'),
url(r'^test$', 'depender.views.test'),
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': os.path.join(os.path.dirname(__file__), '..', '..', '..', 'styles')}),
@@ -8,6 +8,8 @@
from django.http import HttpResponse
from django.conf import settings
from django.core import urlresolvers
+from djangomako.shortcuts import render_to_response, render_to_string
+from markdown import markdown
import re
from depender.core import DependerData
@@ -120,8 +122,11 @@ def get_arr(name):
output += f.content + u"\n\n"
if client == "true":
- url = request.build_absolute_uri(
- urlresolvers.reverse("depender.views.build"))
+ try:
+ url = request.build_absolute_uri(
+ urlresolvers.reverse("depender.views.build"))
+ except Exception:
+ url = "/depender/build"
output += dpdr.get_client_js(deps, url)
response = HttpResponse(output, content_type="application/x-javascript")
@@ -130,6 +135,37 @@ def get_arr(name):
return response
build.login_notrequired = True
+def builder(request):
+ dpdr = get_depender(False)
+ packages = {}
+ #Core, More, etc
+ for p in settings.BUILDER_PACKAGES:
+ if not hasattr(packages, p):
+ packages[p] = {}
+ #Fx, Element, etc
+ for name, component in dpdr.packages[p].components.iteritems():
+ if not hasattr(packages[p], component.filename):
+ packages[p][component.filename] = {
+ 'provides': [],
+ 'requires': []
+ }
+ packages[p][component.filename]['provides'].extend(component.provides)
+ packages[p][component.filename]['requires'].extend(component.requires)
+ def get_provides(package, filename):
+ return [pc[1] for pc in packages[package][filename]['provides']]
+ def get_depends(package, filename):
+ return [pc[0] + '/' + pc[1] for pc in packages[package][filename]['requires']]
+ return render_to_response('packager.mako',
+ {
+ 'packages': settings.BUILDER_PACKAGES,
+ 'package_data': packages,
+ 'get_provides': get_provides,
+ 'get_depends': get_depends,
+ 'dpdr': dpdr,
+ 'markdown': markdown
+ }
+ )
+
def test(request):
#this seems silly
import os
Oops, something went wrong.

0 comments on commit fe0b7ea

Please sign in to comment.