fixed more absolute-root problems. Introduced ROOT global Genshi variable.
authorgfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Wed, 8 Apr 2009 01:43:41 +0000 (01:43 +0000)
committergfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Wed, 8 Apr 2009 01:43:41 +0000 (01:43 +0000)
ROOT can be used in templates: it has the value of the CGI variable
SCRIPT_NAME, so we can use it to determine what the root-prefix of the
app is.

git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@300 6d9bc8c9-1ec2-4278-b937-99fde70a366f

13 files changed:
conifer/genshi_support.py
conifer/settings.py
conifer/templates/browse_index.xhtml
conifer/templates/course_detail.xhtml
conifer/templates/edit_course.xhtml
conifer/templates/edit_course_permissions.xhtml
conifer/templates/feeds/course_feed_index.xhtml
conifer/templates/item_heading_detail.xhtml
conifer/templates/item_relocate.xhtml
conifer/templates/master.xhtml
conifer/templates/prefs.xhtml
conifer/templates/tabbar.xhtml
conifer/templates/tabbar_anonymous.xhtml

index 54c9ec6..da40313 100644 (file)
@@ -37,6 +37,7 @@ def template(tname):
 def _inject_django_things_into_namespace(request, ns):
     ns['_'] = _
     ns['request'] = request
+    ns['ROOT']    = request.META['SCRIPT_NAME']
     ns['user'] = getattr(request, 'user', None)
     ns.update(genshi_namespace.__dict__)
 
index a2b84ae..a1a0f89 100644 (file)
@@ -5,6 +5,8 @@
 
 import os
 
+os.environ['PYTHON_EGG_CACHE'] = '/tmp/eggs'
+
 BASE_DIRECTORY = os.path.abspath(os.path.dirname(__file__))
 HERE = lambda s: os.path.join(BASE_DIRECTORY, s)
 
index 02cf5ae..64df7ba 100644 (file)
@@ -11,7 +11,7 @@ title = _('Browse the Reserves')
 <body>
   <h1>${title}</h1> 
   (Note: some course materials may require you
-    to <a href="/syrup/accounts/login/?next=/syrup/">log in</a>)
+    to <a href="${ROOT}/accounts/login/?next=${ROOT}/">log in</a>)
     <h2>Choose from one of the options below:</h2>
     <ul>
         <li><a href="courses">Browse by Course Name</a></li>
index c8b60ec..b8a8031 100644 (file)
@@ -10,7 +10,7 @@ is_editor = course.can_edit(request.user)
   <xi:include href="components/course.xhtml"/>
   <head>
     <title>${title}</title>
-    <script type="text/javascript" src="/syrup/static/menublocks.js"/>
+    <script type="text/javascript" src="${ROOT}/static/menublocks.js"/>
   </head>
   <body>
     ${course_banner(course)}
index 87c32f4..c569d2d 100644 (file)
@@ -11,7 +11,7 @@ else:
 <xi:include href="components/course.xhtml"/>
 <head>
   <title>${title}</title>
-  <script type="text/javascript" src="/syrup/static/edit_course.js"/>
+  <script type="text/javascript" src="${ROOT}/static/edit_course.js"/>
 </head>
 <body>
   <div py:if="instance.id">${course_banner(instance)}</div>
index e754bdf..e8adbe2 100644 (file)
@@ -9,7 +9,7 @@ instructors = [m for m in models.Member.objects.filter(course=course) if m.role
   <xi:include href="components/course.xhtml"/>
 <head>
   <title>${title}</title>
-  <script type="text/javascript" src="/syrup/static/edit_course_permissions.js"/>
+  <script type="text/javascript" src="${ROOT}/static/edit_course_permissions.js"/>
 </head>
 <body>
   ${course_banner(course)}
index f7999c9..f30709c 100644 (file)
@@ -8,7 +8,7 @@ title = _('Available Feeds')
   <xi:include href="../components/course.xhtml"/>
   <head>
     <title>${title}</title>
-    <script type="text/javascript" src="/syrup/static/menublocks.js"/>
+    <script type="text/javascript" src="${ROOT}/static/menublocks.js"/>
   </head>
   <body>
     ${course_banner(course)}
index 9a6c639..f722432 100644 (file)
@@ -12,7 +12,7 @@ item_tree = course.item_tree(subtree=item)
   <xi:include href="components/course.xhtml"/>
    <head>
     <title>${title}</title>
-    <script type="text/javascript" src="/syrup/static/menublocks.js"/>
+    <script type="text/javascript" src="${ROOT}/static/menublocks.js"/>
   </head>
   <body>
     ${course_banner(course)}
index f5f88dc..8724f48 100644 (file)
@@ -8,7 +8,7 @@ title = 'Move item under a different heading'
   <xi:include href="components/course.xhtml"/>
    <head>
     <title>${title}</title>
-    <script type="text/javascript" src="/syrup/static/menublocks.js"/>
+    <script type="text/javascript" src="${ROOT}/static/menublocks.js"/>
   </head>
   <body>
     ${course_banner(course)}
index cde8578..8947b00 100644 (file)
@@ -2,7 +2,6 @@
 app_name = _('Syrup E-Reserve System')
 search = _('search...')
 import os
-rooted = lambda url: request.META['SCRIPT_NAME'] + url
 ?>
 <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:py="http://genshi.edgewall.org/"
@@ -12,10 +11,10 @@ rooted = lambda url: request.META['SCRIPT_NAME'] + url
     <head py:attrs="select('@*')"
          py:with="t=list(select('title/text()'))">
       <title>${app_name}<py:if test="t">: ${t}</py:if></title>
-    <link rel="stylesheet" type="text/css" href="${rooted('/static/main.css')}"/>
-    <script type="text/javascript" src="${rooted('/static/jquery/js/jquery-1.3.2.min.js')}"/>
-    <script type="text/javascript" src="${rooted('/static/jquery/js/jquery-ui-1.7.1.custom.min.js')}"/>
-    <script type="text/javascript" src="${rooted('/static/jquery/js/jquery.tablesorter.min.js')}"/>
+    <link rel="stylesheet" type="text/css" href="${ROOT}/static/main.css"/>
+    <script type="text/javascript" src="${ROOT}/static/jquery/js/jquery-1.3.2.min.js"/>
+    <script type="text/javascript" src="${ROOT}/static/jquery/js/jquery-ui-1.7.1.custom.min.js"/>
+    <script type="text/javascript" src="${ROOT}/static/jquery/js/jquery.tablesorter.min.js"/>
     ${select('*[local-name()!="title"]')}
     </head>
   </py:match>
@@ -27,7 +26,7 @@ rooted = lambda url: request.META['SCRIPT_NAME'] + url
          ${os.getpid()}
          ${app_name}
        </div>
-       <img src="${rooted('/static/institution-logo.png')}" style="height: 50;"/>
+       <img src="${ROOT}/static/institution-logo.png" style="height: 50;"/>
       </div>
         <!--
       <div id="header" py:if="user.is_authenticated()">
@@ -35,7 +34,7 @@ rooted = lambda url: request.META['SCRIPT_NAME'] + url
         -->
       <div id="header">
         <div id="search">
-            <form method="get" action="${rooted('/search')}
+            <form method="get" action="${ROOT}/search
                 onsubmit="if(q.value.replace(/^\s*/, '').replace(/\s*$/, '') =='') return false;"
             >
             <input id="q" name="q" maxlength="100" size="25" type="text" 
@@ -45,13 +44,13 @@ rooted = lambda url: request.META['SCRIPT_NAME'] + url
         </div>
       <span py:if="user.is_authenticated()">
        <strong style="padding-right: 18;">Welcome, ${user.first_name or user.username}!</strong>
-       <a href="${rooted('/accounts/logout')}">Log Out</a>
-       &bull; <a href="${rooted('/prefs/')}">Preferences</a>
+       <a href="${ROOT}/accounts/logout">Log Out</a>
+       &bull; <a href="${ROOT}/prefs/">Preferences</a>
       </span>
       <span py:if="not user.is_authenticated()">
        <strong style="padding-right: 18;">Welcome!</strong>
-       <a class="loginbutton" href="${rooted('/accounts/login/')}">Log In</a>
-       &bull; <a href="${rooted('/prefs/')}">Preferences</a>
+       <a class="loginbutton" href="${ROOT}/accounts/login/">Log In</a>
+       &bull; <a href="${ROOT}/prefs/}">Preferences</a>
       </span>
     </div>
       <xi:include py:if="user.is_authenticated()" href="tabbar.xhtml"/>
index 833aa43..2ad2cd0 100644 (file)
@@ -13,7 +13,7 @@ title = _('Preferences')
 <h1>${title}</h1>
 <h2>Preferred Language</h2>
 <form action="../i18n/setlang/" method="post">
-<input name="next" type="hidden" value="/syrup/" />
+<input name="next" type="hidden" value="${ROOT}/" />
 <select name="language">
 <option py:for="code,descr in settings.LANGUAGES"
        value="${code}">${_(descr)}</option>
index 88bca81..eda139d 100644 (file)
@@ -7,13 +7,13 @@
     use one for now
 -->
 <ul id="tabbar">
-  <li><a href="${rooted('/')}">Home</a></li>
-  <li><a href="${rooted('/browse/')}">Browse</a></li>
-  <li class="active"><a href="${rooted('/course/')}">My Courses</a></li>
+  <li><a href="${ROOT}/">Home</a></li>
+  <li><a href="${ROOT}/browse/">Browse</a></li>
+  <li class="active"><a href="${ROOT}/course/">My Courses</a></li>
   <div py:strip="True"
        py:if="request.user.is_staff">
-    <li><a href="${rooted('/admin/')}">Admin Options</a></li>
-    <li><a href="${rooted('/phys/')}">Physical Items</a></li>
+    <li><a href="${ROOT}/admin/">Admin Options</a></li>
+    <li><a href="${ROOT}/phys/">Physical Items</a></li>
   </div>
 </ul>
 </html>
index ba37cd2..66b92e3 100644 (file)
@@ -7,7 +7,7 @@
     use one for now
 -->
 <ul id="tabbar">
-  <li><a href="/syrup/">Home</a></li>
-  <li><a href="/syrup/browse/">Browse</a></li>
+  <li><a href="${ROOT}/">Home</a></li>
+  <li><a href="${ROOT}/browse/">Browse</a></li>
 </ul>
 </html>