← Back to team overview

sloecode-dev team mailing list archive

Re: configurable root path of sloecode instance

 

OK, I've made a start on this. Again, can be found in my branch here:

lp:~guy.kloss/+junk/sloecode-sphinx

On Thu, 02 Jun 2011 8:59:49 PM Thomi Richards wrote:

> I'm rearranging your items to categorise them:
> > * Links to style sheets/JavaScript in lines 10-15:
> >  sloecode/templates/base.html
> > 
> > * Image links:
> >  sloecode/templates/person-details.html (line 46)
> >  sloecode/templates/project-details.html (line 35)
> 
> These are a special case because they're requesting static items
> (i.e.- things served from our filesystem). They all make use of
> functions from the 'helper' module (that's what the 'h' is) to print
> out the actual HTML text. That module is sloecode/lib/helpers.py. I've
> already patched the link_to function for some other functionality I
> needed. Perhaps we should patch all the functions that require a path
> to something to take a custom root part? Off the top of my head this
> could require patching: image, link_to, help_link, stylesheet_link,
> javascript_link and form.

Yes, the option of having a particular path prefix optionally available would 
be very desirable, even for static things, as this will help to nicely 
separate different things on a server.

OK, now let me rearrange:

> > * Links to personal pages in line 31:
> >  sloecode/templates/admin/person-list.html
> > 
> > * As mentioned before:
> >  sloecode/templates/login.html (line 18)
> >  (don't know whether also needed for the hidden field in line 32)
> > 
> > * Link to login in line 16:
> >  sloecode/templates/index.html
> > 
> > * Link to project details:
> >  sloecode/templates/project-details.html (line 59)
> 
> These are all jobs for url_for. So here's how this works:

All these tackled (see attached diff). Also the login.html (line 32), where I 
found an action in a controller called "me", so I've modded that one 
accordingly, hoping that things are correct.

> > * Link to help:
> >  sloecode/templates/admin/person-create.html (line 19)
> >  sloecode/templates/admin/person-update.html (line 60)
> >  sloecode/templates/person-details.html (line 40)

I didn't know what to do with these ones, as I didn't know what kind of 
controller "what-is" would fall under. Actually, couldn't find any controller 
referring to any type of help at all.

[snipped helpful description]

> Here are a few more tips to help you out:
> 
> from the sloecode root directory, if you type 'paster shell' then you
> get a python shell (or ipython, if you have it installed) with the
> WSGI app loaded correctly already for you, so you can do something
> 
> like this:
> >>> import sloecode.lib.helpers as h
> >>> h.url_for(controller='project', action='index',
> >>> project_name='sloecode')
> 
> '/p/sloecode/index'

Couldn't get that to work, so I couldn't test my url_for() calls.

Guy

PS: A simple reply to the list is sufficient, otherwise I'm getting the mail 
multiple times.

-- 
Guy K. Kloss
School of Computing + Mathematical Sciences
Auckland University of Technology
Private Bag 92006, Auckland 1142
phone: +64 9 921 9999 ext. 5032
eMail: Guy.Kloss@xxxxxxxxx
=== modified file 'sloecode/templates/admin/person-list.html'
--- sloecode/templates/admin/person-list.html	2011-04-09 00:11:56 +0000
+++ sloecode/templates/admin/person-list.html	2011-06-03 01:44:24 +0000
@@ -28,7 +28,10 @@
         {% set row_class = cycler('odd', 'even') %}
         {% for person in people.items %}
         <tr class="{{row_class.next()}}">
-          <td>{{h.link_to(person.login|e, '/u/' + (person.login)) }}</td>
+          <td>{{h.link_to(person.login|e,
+                          h.url_for(controller='person',
+                                    action='index',
+                                    person_name=person.login)) }}</td>
           <td>{{person.name|e}}</td>
           <td>{{person.email|e}}</td>
           <td>{% set roles = [] %}

=== modified file 'sloecode/templates/index.html'
--- sloecode/templates/index.html	2011-04-01 23:50:31 +0000
+++ sloecode/templates/index.html	2011-06-03 00:52:46 +0000
@@ -13,6 +13,6 @@
 
 {% if not identity %}
   <p>To get started, You need to 
-  {{h.link_to('login!', '/auth/login')}}</p>
+  {{h.link_to('login!', rl_for(controller="auth", action="dologin"))}}</p>
 {% endif %}
 {% endblock %}

=== modified file 'sloecode/templates/login.html'
--- sloecode/templates/login.html	2011-04-18 10:18:25 +0000
+++ sloecode/templates/login.html	2011-06-03 01:58:10 +0000
@@ -15,7 +15,8 @@
 <div class="yui3-g">
   <div id="page_header" class="yui3-u-1">
     <div class="content-left">
-      {{ h.form('/auth/dologin', name="login_form") }}
+      {{ h.form(url_for(controller="auth", action="dologin"),
+                name="login_form") }}
       <table>
         <tr>
           <td>Username:</td>
@@ -29,7 +30,7 @@
           <td colspan="2"> {{ h.submit('login_btn', 'Login') }} </td>
         </tr>
       </table>
-      {{ h.hidden('came_from', '/me') }}
+      {{ h.hidden('came_from', h.url_for(controller='person', action='me') }}
       {{ h.end_form() }}
     </div>
   </div>

=== modified file 'sloecode/templates/project-details.html'
--- sloecode/templates/project-details.html	2011-04-18 10:18:25 +0000
+++ sloecode/templates/project-details.html	2011-06-03 00:54:54 +0000
@@ -56,7 +56,10 @@
           {% endfor %}
           {% if h.has_site_role(h.PROJECT_ADMIN) or user_role == h.PROJECT_ROLES[2] %}
           <dt class="action">
-            {{ h.link_to('Manage Project Users', '/p/%s/manage_users' % project.name) }}
+            {{ h.link_to('Manage Project Users',
+                         h.url_for(controller='project',
+                                   action='manage_users',
+                                   project_name=project.name) }}
           </dt>
           {% endif %}
 

Attachment: signature.asc
Description: This is a digitally signed message part.


Follow ups

References