You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2015/12/07 09:22:59 UTC
[03/12] allura git commit: ticket:866 updated template with mavbar;
updated tests for nav and logo;
ticket:866 updated template with mavbar; updated tests for nav and logo;
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/1836c4e2
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/1836c4e2
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/1836c4e2
Branch: refs/heads/ib/5940
Commit: 1836c4e2c691b189b0be3343e3c44ef22ed76192
Parents: fda0efe
Author: DeV1doR <de...@ukr.net>
Authored: Fri Dec 4 02:12:22 2015 +0200
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon Dec 7 10:01:07 2015 +0200
----------------------------------------------------------------------
Allura/allura/lib/app_globals.py | 8 +--
Allura/allura/nf/allura/css/site_style.css | 9 +--
.../templates/jinja_master/theme_macros.html | 6 +-
Allura/allura/tests/functional/test_auth.py | 7 ++-
Allura/allura/tests/functional/test_nav.py | 58 +++++++++-----------
Allura/development.ini | 2 +-
6 files changed, 43 insertions(+), 47 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/1836c4e2/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 84ea20e..c532bdd 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -607,16 +607,16 @@ class Globals(object):
@LazyProperty
def nav_logo(self):
- logo = json.loads(config.get('logo').replace("\'", '"'))
+ logo = json.loads(config.get('logo'))
image_path = logo.get('image_path', False)
if not image_path:
- return {}
+ return False
allura_path = os.path.dirname(os.path.dirname(__file__))
image_full_path = '%s/public/nf/images/%s' % (
allura_path, image_path)
- if not os.path.exists(image_full_path):
- return {}
+ if not os.path.isfile(image_full_path):
+ return False
if not logo.get('redirect_link', False):
logo['redirect_url'] = '/'
http://git-wip-us.apache.org/repos/asf/allura/blob/1836c4e2/Allura/allura/nf/allura/css/site_style.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css
index 53f3a5b..50bda3b 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -446,7 +446,7 @@ blockquote {
color: #555555;
}
#site-header a:first-child, #site-footer a:first-child {
- margin-left: 0;
+ margin-left: 1em;
}
/* site header */
@@ -495,15 +495,12 @@ blockquote {
}
/* nav */
-nav .link-left {
+.nav-left, .nav-logo {
float: left;
}
-nav .link-right {
+.nav-main {
float: right;
}
-/*.link-right, .link-left {
- line-height: 45px;
-}*/
/* logo */
.logo {
http://git-wip-us.apache.org/repos/asf/allura/blob/1836c4e2/Allura/allura/templates/jinja_master/theme_macros.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/theme_macros.html b/Allura/allura/templates/jinja_master/theme_macros.html
index 40f03dc..2ca9fd5 100644
--- a/Allura/allura/templates/jinja_master/theme_macros.html
+++ b/Allura/allura/templates/jinja_master/theme_macros.html
@@ -27,13 +27,17 @@ http://stackoverflow.com/questions/26582731/redefining-imported-jinja-macros
{%- macro header(login_url, logout_url) %}
<header id="site-header">
<div class="wrapper">
- <nav>
+ <div class="nav-logo">
{% if g.nav_logo %}
<a class="link-left" href="{{ g.nav_logo['redirect_link'] }}"><img class="nav-logo" src="{{ g.nav_logo['image_path'] }}" /></a>
{% endif %}
+ </div>
+ <nav class="nav-left">
{% for nav_link in g.global_nav %}
<a class="link-left" href="{{ nav_link['url'] }}">{{ nav_link['title'] }}</a>
{% endfor %}
+ </nav>
+ <nav class="nav-main">
{% if c.user._id %}
<a class="link-right" href="/auth/preferences/">Account</a>
<a class="link-right" href="{{c.user.url()}}">{{name}}</a>
http://git-wip-us.apache.org/repos/asf/allura/blob/1836c4e2/Allura/allura/tests/functional/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index ed926da..855d315 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -81,18 +81,21 @@ class TestAuth(TestController):
def test_logout(self):
self.app.extra_environ = {'disable_auth_magic': 'True'}
+ nav_pattern = ('nav', {'class': 'nav-main'})
r = self.app.get('/auth/')
f = r.forms[0]
f['username'] = 'test-user'
f['password'] = 'foo'
r = f.submit().follow()
logged_in_session = r.session['_id']
- assert_equal(r.html.nav('a')[-1].string, "Log Out")
+ links = r.html.find(*nav_pattern).findAll('a')
+ assert_equal(links[-1].string, "Log Out")
r = self.app.get('/auth/logout').follow()
logged_out_session = r.session['_id']
assert logged_in_session is not logged_out_session
- assert_equal(r.html.nav('a')[-1].string, 'Log In')
+ links = r.html.find(*nav_pattern).findAll('a')
+ assert_equal(links[-1].string, 'Log In')
def test_track_login(self):
user = M.User.by_username('test-user')
http://git-wip-us.apache.org/repos/asf/allura/blob/1836c4e2/Allura/allura/tests/functional/test_nav.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_nav.py b/Allura/allura/tests/functional/test_nav.py
index 306d2e1..d9d267e 100644
--- a/Allura/allura/tests/functional/test_nav.py
+++ b/Allura/allura/tests/functional/test_nav.py
@@ -1,6 +1,7 @@
import mock
import json
from tg import config
+from pylons import app_globals as g
from allura.tests import TestController
from allura.lib import helpers as h
@@ -15,42 +16,33 @@ class TestNavigation(TestController):
def setUp(self):
super(TestNavigation, self).setUp()
+ self.logo_pattern = ('div', {'class': 'nav-logo'})
+ self.global_nav_pattent = ('nav', {'class': 'nav-left'})
+ self.nav_data = {
+ "title": "Link Test", "url": "http://example.com"}
+ self.logo_data = {
+ "redirect_link": "/", "image_path": "test_image.png"}
+ self.config_data = {
+ "global_nav": json.dumps([self.nav_data]),
+ "logo": json.dumps(self.logo_data)
+ }
def test_global_nav_links_present(self):
- data = {"title": "Link Test", "url": "http://example.com"}
- with h.push_config(config, **{"global_nav": json.dumps([data])}):
+ with h.push_config(config, **self.config_data):
response = self.app.get('/')
- assert response.html.nav('a')[0].text == \
- data['title']
- assert response.html.nav('a')[0].attrs[-1][-1] == \
- data['url']
+ nav_left = response.html.find(*self.global_nav_pattent)
+ assert len(nav_left.findAll('a')) == 1
+ assert nav_left.a.get('href') == self.nav_data['url']
+ assert nav_left.a.text == self.nav_data['title']
def test_logo_absent_if_not_image_path(self):
- data = {"redirect_link": "/", "image_path": "bad_image.png"}
- with h.push_config(config, **{"logo": json.dumps(data)}):
+ with h.push_config(config, **self.config_data):
response = self.app.get('/')
- self.logo = json.loads(config.get('logo'))
- main_page_link = response.html.nav('a')[0].attrs[-1][-1]
- assert main_page_link != self.logo['redirect_link']
-
- # @mock.patch('allura.lib.app_globals.os.path.exists')
- # def test_logo_present(self, path_exists):
- # path_exists.return_value = True
- # data = {"redirect_link": "/", "image_path": "user123.png"}
- # with h.push_config(config, **{"logo": json.dumps(data)}):
- # response = self.app.get('/')
- # self.logo = json.loads(config.get('logo'))
- # main_page_link = response.html.nav('a')[0].attrs[-1][-1]
- # image_link = response.html.html.nav('a')[0].img.attrs[-1][-1]
- # assert main_page_link == self.logo['redirect_link']
- # assert self.logo['image_path'] in image_link
-
- # @mock.patch("allura.lib.app_globals.config")
- # def test_logo_redirect_url_absent_and_set_default(self, _config):
- # _config.get('logo').return_value = str({
- # "redirect_link": "/",
- # "image_path": "a.png"
- # })
- # response = self.app.get('/')
- # main_page_link = response.html.findAll('nav')[0]('a')[0].attrs[-1][-1]
- # assert main_page_link == '/'
+ nav_logo = response.html.find(*self.logo_pattern)
+ assert len(nav_logo.findAll('a')) == 0
+
+ @mock.patch.object(g, 'nav_logo')
+ def test_logo_present(self, glogo):
+ response = self.app.get('/')
+ nav_logo = response.html.find(*self.logo_pattern)
+ assert len(nav_logo.findAll('img')) == 1
http://git-wip-us.apache.org/repos/asf/allura/blob/1836c4e2/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index 30f48ff..d438765 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -86,7 +86,7 @@ forgemail.url = http://localhost:8080
; NOTE: specify your static.url_base before config this
; Save your picture in images folder
; Example: ../<static_path>/images/<logo_path>
-; logo = {"redirect_link": "/", "image_path": "user.png"}
+logo = {"redirect_link": "/", "image_path": "user.png"}
; Used to uniquify references to static resources, can be a timestamp or any unique value
; This should be updated each time you deploy (or make significant changes, like new tools, new css)