Advancing on migrationg to HTML5

* Adding themes to UDS
This commit is contained in:
Adolfo Gómez 2013-11-05 01:20:39 +00:00
parent 36429e0443
commit 5cf101d3c8
12 changed files with 202 additions and 26 deletions

View File

@ -79,6 +79,7 @@ encoding//src/uds/core/transports/TransportsFactory.py=utf-8
encoding//src/uds/core/transports/__init__.py=utf-8
encoding//src/uds/core/transports/protocols.py=utf-8
encoding//src/uds/core/ui/UserInterface.py=utf-8
encoding//src/uds/core/ui/theme.py=utf-8
encoding//src/uds/core/util/AutoAttributes.py=utf-8
encoding//src/uds/core/util/Cache.py=utf-8
encoding//src/uds/core/util/Config.py=utf-8

View File

@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2014 Virtual Cable S.L.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'''
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
'''
from __future__ import unicode_literals
from uds.core.util.Config import GlobalConfig
def template(template_name):
theme_path = GlobalConfig.UDS_THEME.get(True)
if theme_path == 'default':
theme_path = ''
else:
theme_path += '/'
return 'uds/{0}{1}'.format(theme_path, template_name)

View File

@ -251,6 +251,8 @@ class GlobalConfig(object):
# Minimum Free memory for a node to be elegible for a destination of a migration
CLUSTER_ELEGIBLE_MEMORYLOAD = Config.section(CLUSTER_SECTION).value('Migration Free Memory', '40')
# Gui vars
UDS_THEME = Config.section(GLOBAL_SECTION).value('UDS Theme', 'html5')
initDone = False

View File

@ -1,10 +1,22 @@
{% extends "uds/base.html" %}
{% load i18n %}
{% block title %}{% trans "Page not found" %}{% endblock %}
{% block content %}
<h1>{% trans "Page not found" %}</h1>
<p>{% trans "Sorry, but the requested page could not be found." %}</p>
{% extends 'uds/html5/base.html' %}
{% block css %}
<style>
.center {text-align: center; margin-left: auto; margin-right: auto; margin-bottom: auto; margin-top: auto;}
</style>
{% endblock %}
{% block body %}
<div class="container">
<div class="row">
<div class="span12">
<div class="hero-unit center">
<h1>Page Not Found <small><font face="Tahoma" color="red">Error 404</font></small></h1>
<br />
<p>The page you requested could not be found, either contact your webmaster or try again. Use your browsers <b>Back</b> button to navigate to the page you have prevously come from</p>
<p><b>Or you could just press this neat little button:</b></p>
<a href="/" class="btn btn-large btn-info"><i class="icon-home icon-white"></i> Take Me Home</a>
</div>
<br />
</div>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,22 @@
{% extends 'uds/html5/base.html' %}
{% block css %}
<style>
.center {text-align: center; margin-left: auto; margin-right: auto; margin-bottom: auto; margin-top: auto;}
</style>
{% endblock %}
{% block body %}
<div class="container">
<div class="row">
<div class="span12">
<div class="hero-unit center">
<h1>Ooops<small><font face="Tahoma" color="red">Error 500</font></small></h1>
<br />
<p>The server raised an unexpected error, either contact your webmaster or try again. Use your browsers <b>Back</b> button to navigate to the page you have prevously come from</p>
<p><b>Or you could just press this neat little button:</b></p>
<a href="/" class="btn btn-large btn-info"><i class="icon-home icon-white"></i> Take Me Home</a>
</div>
<br />
</div>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,63 @@
{% extends "uds/html5/internal_page.html" %}
{% load i18n static html5 %}
{% block js %}
<script>
$(function() {
{% if not java %}
$('#jmessage').dialog({
autoOpen: false,
width: 500,
buttons: {
"Ok": function() {
$(this).dialog("close");
}
}
});
$("a.nojava").click( function() {
$('#jmessage').dialog('open');
return false;
});
{% endif %}
});
</script>
{% endblock %}
{% block body %}
<div id="services">
<h2>{% trans "Services" %}</h2>
<ul>
{% for ser in services %}
{{ forloop.counter }}
{% if ser.transports %}
<li>
{% with trans=ser.transports|first %}
<a{% if not java and trans.needsJava %} class="nojava"{% endif %} href="{% url "uds.web.views.service" idService=ser.id idTransport=trans.id %}">{{ ser.name }}</a>
{% endwith %}
<ul>
{% for trans in ser.transports %}
<li><a{% if not java and trans.needsJava %} class="nojava"{% endif %} href="{% url "uds.web.views.service" idService=ser.id idTransport=trans.id %}"><img src="{% url "uds.web.views.transportIcon" idTrans=trans.id %}" alt="{{ trans.name }}" />{{ trans.name }}</a></li>
{% endfor %}
</ul>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
{% if not java %}
<div id="jmessage" title="{% trans "Java not found" %}">
<p>{% trans "Java is not available on your browser, and the selected transport needs it." %}</p>
<p>{% trans "Please, install latest version from" %} <a href="http://www.java.com">{% trans "Java website" %}</a> {% trans "and restart browser" %}</p>
</div>
{% endif %}
{% if user.isStaff %}
<div id="adminmsgs">
<div>{% trans "Ip" %}: {{ ip }}</li>
<div>{% trans "Networks" %}: {{ nets }}</div>
<div>{% trans "Transports" %}: {{ transports }}</div>
</div>
</div>
{% endif %}
{% endblock %}

View File

@ -0,0 +1,25 @@
{% extends "uds/html5/base.html" %}
{% load i18n static html5 %}
{% block js %}
<script type="text/javascript">
$(document).ready(function() {
$('#admin ul').hide();
$("#admin").click(function(){
var lista = $('#admin ul');
if (lista.is(":hidden")) {
lista.slideDown("fast");
} else {
lista.hide();
}
});
});
</script>
{% endblock %}
{% block menu %}
{% include 'uds/html5/snippets/navbar_inner.html' %}
{% endblock %}

View File

@ -1,5 +1,5 @@
{% load i18n html5 static %}
<nav class="navbar navbar-default navbar-fixed-top navbar-inverse" role="navigation">
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
@ -8,7 +8,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="{% url 'uds.web.views.index' %}"><span class="navbar-brand">UDS</span></a>
<a href="{% url 'uds.web.views.index' %}"><span class="navbar-brand">Universal Desktop Services</span></a>
</div>
{% block navbar %}{% endblock %}
</nav>

View File

@ -1,9 +1,10 @@
{% extends 'uds/html5/snippets/navbar.html' %}
{% load i18n static %}
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li{% if packages %} class="active"{% endif %}><a href="{% url 'fileshare.views.packages_view' %}">{% trans 'packages'|capfirst %}</a></li>
{% if user.is_staff %}<li><a href="/admin">{% trans 'administration'|capfirst %}</a></li>{% endif %}
</ul>
{% include "uds/html5/snippets/nav-right.html" with logout=True %}
</div><!-- /.navbar-collapse -->
{% block navbar %}
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li><a href="{% url "uds.web.views.prefs" %}">{% trans "User" %} {{ user.real_name }}</a></li>
</ul>
{% include "uds/html5/snippets/nav-right.html" with logout=True %}
</div>
{% endblock %}

View File

@ -1,8 +1,7 @@
{% extends 'uds/html5/snippets/navbar.html' %}
{% load i18n static %}
{% block navbar %}
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
{% include "uds/html5/snippets/nav-right.html" with logout=False %}
</div><!-- /.navbar-collapse -->
{% endblock %}
<div class="collapse navbar-collapse navbar-ex1-collapse">
{% include "uds/html5/snippets/nav-right.html" with logout=False %}
</div>
{% endblock %}

View File

@ -31,6 +31,7 @@
@author: Adolfo Gómez, dkmaster at dkmon dot com
'''
from django.conf import settings
from django.conf.urls.defaults import patterns, include
from uds.core.util.modfinder import loadModulesUrls

View File

@ -35,6 +35,7 @@ from __future__ import unicode_literals
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden
from django.views.decorators.csrf import csrf_exempt
from django.shortcuts import render_to_response
from django.shortcuts import render
from django.template import RequestContext
from django.utils.translation import ugettext as _
from django.core.urlresolvers import reverse
@ -48,6 +49,7 @@ from uds.core.util.Config import GlobalConfig
from uds.core.util.Cache import Cache
from uds.core.util import OsDetector
from uds.core.util import log
from uds.core.ui import theme
from transformers import transformId, scrambleId
@ -121,7 +123,7 @@ def login(request, smallName=None):
else:
form = LoginForm(smallName=smallName)
response = render_to_response('uds/html5/login.html', { 'form' : form, 'customHtml' : GlobalConfig.CUSTOM_HTML_LOGIN.get(True) },
response = render_to_response(theme.template('login.html'), { 'form' : form, 'customHtml' : GlobalConfig.CUSTOM_HTML_LOGIN.get(True) },
context_instance=RequestContext(request))
if request.COOKIES.has_key('uds') is False:
response.set_cookie('uds', ''.join(random.choice(string.letters + string.digits) for _ in xrange(32)))
@ -203,7 +205,7 @@ def index(request):
)
return render_to_response('uds/index.html',
return render_to_response(theme.template('index.html'),
{'services' : services, 'java' : java, 'ip' : request.ip, 'nets' : nets,
'transports' : validTrans },
context_instance=RequestContext(request))
@ -415,3 +417,7 @@ def download(request, idDownload):
return render_to_response('uds/downloads.html', { 'files' : files }, context_instance=RequestContext(request))
return DownloadsManager.manager().send(request, idDownload)
# Customization views
def handler404(request):
return render(request, theme.template('404.html'))