Changeset - 11e8eb5a92e3
[Not reviewed]
default
0 8 0
Marcin Kuzminski - 15 years ago 2010-05-21 23:51:02
marcin@python-works.com
new way of menu generation for base, and all admin pages
8 files changed with 28 insertions and 39 deletions:
0 comments (0 inline, 0 general)
pylons_app/templates/admin/admin.html
Show inline comments
 
## -*- coding: utf-8 -*-
 
<%inherit file="/base/base.html"/>
 

	
 
<%def name="title()">
 
    ${_('Repository managment')}
 
</%def>
 
<%def name="breadcrumbs()">
 
	${h.link_to(u'Admin',h.url('admin_home'))}
 
	 /  
 
</%def>
 
<%def name="page_nav()">
 
<ul class="page-nav">
 
	<li>${h.link_to(u'Home',h.url('/'))}</li>
 
	<li class="current">${_('Admin')}</li>
 
</ul>
 
	${self.menu('admin')}
 
</%def>
 
<%def name="main()">
 
    %if c.admin_user:
 
	    <ul class="submenu">
 
	        <li>
 
	            ${h.link_to(u'Repos',h.url('repos'))}
 
	        </li>
 
	        <li>
 
	            ${h.link_to(u'Users',h.url('users'))}
 
	        </li>
 
	    </ul>
 
	    <br/>
 
	    <div>
 
	        <h2>Welcome ${c.admin_username}</h2>
 
			    <div id="user_log">
 
					${c.log_data}
 
				</div>
 
	    </div>
 
    %else:
 
		<h2>${_('Sorry only admin users can acces this area')}</h2>
 
    %endif
 
    
 
</%def>
 
\ No newline at end of file
pylons_app/templates/admin/repos/repo_add.html
Show inline comments
 
## -*- coding: utf-8 -*-
 
<%inherit file="/base/base.html"/>
 

	
 
<%def name="title()">
 
    ${_('Add new repository')}
 
</%def>
 

	
 
<%def name="breadcrumbs()">
 
	${h.link_to(u'Admin',h.url('admin_home'))}
 
	 / 
 
</%def>
 

	
 
<%def name="page_nav()">
 
<ul class="page-nav">
 
	<li>${h.link_to(u'Home',h.url('/'))}</li>
 
	<li class="current">${_('Admin')}</li>
 
</ul>
 
	${self.menu('admin')}
 
</%def>
 

	
 
<%def name="main()">
 
     <table cellspacing="0">
 
        <tr>
 
            <td><h1>${c.msg}</h1></td>
 
        </tr>
 
        <tr>
 
            <td><h2>${c.new_repo}</h2></td>
 
        </tr>
 
    </table>   
 
</%def>
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
pylons_app/templates/admin/repos/repo_edit.html
Show inline comments
 
<%inherit file="base/base.html"/>
 
<%def name="title()">
 
    ${_('Repository managment')}
 
</%def>
 
<%def name="breadcrumbs()">
 
    ${h.link_to(u'Admin',h.url('admin_home'))}
 
    /
 
    ${h.link_to(u'Repos managment',h.url('repos'))}
 
</%def>
 
<%def name="page_nav()">
 
	<li>${h.link_to(u'Home',h.url('/'))}</li>
 
	<li class="current">${_('Admin')}</li>
 
	${self.menu('admin')}
 
</%def>
 
<%def name="main()">
 
    <ul class="submenu">
 
        <li class="current_submenu">
 
            ${h.link_to(u'Repos',h.url('repos'))}
 
        </li>
 
        <li>
 
            ${h.link_to(u'Users',h.url('users'))}
 
        </li>
 
    </ul>
 
	<div>
 
        <h2>${_('Mercurial repos')}</h2>
 
    </div>
 
</%def>    
 
\ No newline at end of file
pylons_app/templates/admin/repos/repos.html
Show inline comments
 
<%inherit file="/base/base.html"/>
 
<%def name="title()">
 
    ${_('Repository managment')}
 
</%def>
 
<%def name="breadcrumbs()">
 
    ${h.link_to(u'Admin',h.url('admin_home'))}
 
    /
 
    ${h.link_to(u'Repos managment',h.url('repos'))}
 
</%def>
 
<%def name="page_nav()">
 
<ul class="page-nav">
 
	<li>${h.link_to(u'Home',h.url('/'))}</li>
 
	<li class="current">${_('Admin')}</li>
 
</ul>
 
	${self.menu('admin')}
 
</%def>
 
<%def name="main()">
 
    <ul class="submenu">
 
        <li>
 
            ${h.link_to(u'Repos',h.url('repos'), class_="current_submenu")}
 
        </li>
 
        <li>
 
            ${h.link_to(u'Users',h.url('users'))}
 
        </li>
 
    </ul>
 
	<div>
 
        <h2>${_('Mercurial repos')}</h2>
 
        <table>
 
	        %for cnt,repo in enumerate(c.repos_list):
 
	 		<tr class="parity${cnt%2}">
 
			    <td>${h.link_to(repo['name'],h.url('summary_home',repo_name=repo['name']))}</td>
 
		        <td>r${repo['rev']}:${repo['tip']}</td>
 
                <td>
 
                  ${h.form(url('repo', id=repo['name']),method='delete')}
 
                  	${h.submit('remove','remove',class_="submit",onclick="return confirm('Confirm to delete this repository');")}
 
                  ${h.end_form()}
 
     			</td>
 
			</tr>
 
			%endfor
 
		</table>
 
    </div>
 
</%def>    
 
\ No newline at end of file
pylons_app/templates/admin/users/user_add.html
Show inline comments
 
<%inherit file="/base/base.html"/>
 
<%def name="title()">
 
    ${_('User')} - ${_('add new')}
 
</%def>
 
<%def name="breadcrumbs()">
 
    ${h.link_to(u'Admin',h.url('admin_home'))}
 
    /
 
    ${h.link_to(u'Users',h.url('users'))}
 
</%def>
 
<%def name="page_nav()">
 
<ul class="page-nav">
 
	<li>${h.link_to(u'Home',h.url('/'))}</li>
 
	<li class="current">${_('Admin')}</li>
 
</ul>
 
	${self.menu('admin')}
 
</%def>
 
<%def name="main()">
 
    <ul class="submenu">
 
        <li>
 
            ${h.link_to(u'Repos',h.url('repos'))}
 
        </li>
 
        <li class="current_submenu">
 
            ${h.link_to(u'Users',h.url('users'))}
 
        </li>
 
    </ul>
 
	<div>
 
        <h2>${_('User')} - ${_('add new')}</h2>
 
        ${h.form(url('users'))}
 
        <table>
 
        	<tr>
 
        		<td>${_('Username')}</td>
 
        		<td>${h.text('username')}</td>
 
        	</tr>
 
        	<tr>
 
        		<td>${_('password')}</td>
 
        		<td>${h.text('password')}</td>
 
        	</tr>
 
        	<tr>
 
        		<td>${_('Active')}</td>
 
        		<td>${h.checkbox('active')}</td>
 
        	</tr>
 
        	<tr>
 
        		<td></td>
 
        		<td>${h.submit('add','add')}</td>
 
        	</tr>
 
        	        	        	
 
        </table>
 
        	
 
        ${h.end_form()}
 
    </div>
 
</%def>    
 
\ No newline at end of file
pylons_app/templates/admin/users/user_edit.html
Show inline comments
 
<%inherit file="/base/base.html"/>
 
<%def name="title()">
 
    ${_('User')} - ${c.user.username}
 
</%def>
 
<%def name="breadcrumbs()">
 
    ${h.link_to(u'Admin',h.url('admin_home'))}
 
    /
 
    ${h.link_to(u'Users',h.url('users'))}
 
</%def>
 
<%def name="page_nav()">
 
<ul class="page-nav">
 
	<li>${h.link_to(u'Home',h.url('/'))}</li>
 
	<li class="current">${_('Admin')}</li>
 
</ul>
 
	${self.menu('admin')}
 
</%def>
 
<%def name="main()">
 
    <ul class="submenu">
 
        <li>
 
            ${h.link_to(u'Repos',h.url('repos'))}
 
        </li>
 
        <li class="current_submenu">
 
            ${h.link_to(u'Users',h.url('users'))}
 
        </li>
 
    </ul>
 
	<div>
 
        <h2>${_('User')} - ${c.user.username}</h2>
 
        ${h.form(url('user', id=c.user.user_id),method='put')}
 
        <table>
 
        	<tr>
 
        		<td>${_('Username')}</td>
 
        		<td>${h.text('username')}</td>
 
        	</tr>
 
        	<tr>
 
        		<td>${_('New password')}</td>
 
        		<td>${h.text('new_password')}</td>
 
        	</tr>
 
        	<tr>
 
        		<td>${_('Active')}</td>
 
        		<td>${h.checkbox('active',value=True)}</td>
 
        	</tr>
 
        	<tr>
 
        		<td></td>
 
        		<td>${h.submit('save','save')}</td>
 
        	</tr>
 
        	        	        	
 
        </table>
 
        	
 
        ${h.end_form()}
 
    </div>
 
</%def>    
 
\ No newline at end of file
pylons_app/templates/admin/users/users.html
Show inline comments
 
<%inherit file="/base/base.html"/>
 
<%def name="title()">
 
    ${_('Users managment')}
 
</%def>
 
<%def name="breadcrumbs()">
 
    ${h.link_to(u'Admin',h.url('admin_home'))}
 
    /
 
    ${h.link_to(u'Users managment',h.url('users'))}
 
</%def>
 
<%def name="page_nav()">
 
<ul class="page-nav">
 
	<li>${h.link_to(u'Home',h.url('/'))}</li>
 
	<li class="current">${_('Admin')}</li>
 
</ul>
 
	${self.menu('admin')}
 
</%def>
 
<%def name="main()">
 
    <ul class="submenu">
 
        <li>
 
            ${h.link_to(u'Repos',h.url('repos'))}
 
        </li>
 
        <li>
 
            ${h.link_to(u'Users',h.url('users'), class_="current_submenu")}
 
        </li>
 
    </ul>
 
	<div>
 
        <h2>${_('Mercurial users')}</h2>
 
        <table>
 
         <tr>
 
            <th>Id</th>
 
            <th>Username</th>
 
            <th>Active</th>
 
            <th>Admin</th>
 
            <th>Action</th>
 
         </tr>
 
            %for user in c.users_list:
 
                <tr>
 
                    <td>${user.user_id}</td>
 
                    <td>${h.link_to(user.username,h.url('edit_user', id=user.user_id))}</td>
 
                    <td>${user.active}</td>
 
                    <td>${user.admin}</td>
 
                    <td>
 
	                    ${h.form(url('user', id=user.user_id),method='delete')}
 
	                    	${h.submit('remove','remove',class_="submit")}
 
	                    ${h.end_form()}
 
        			</td>
 
                </tr>
 
            %endfor
 
        </table>
 
        <h3>${h.link_to(u'Add user',h.url('new_user'))}</h3>        
 
    </div>
 

	
 
</%def>    
 
\ No newline at end of file
pylons_app/templates/base/base.html
Show inline comments
 
## -*- coding: utf-8 -*-
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" id="mainhtml">
 
<head>
 
    <link rel="icon" href="/images/hgicon.png" type="image/png" />
 
    <meta name="robots" content="index, nofollow"/>
 
    <title>${next.title()}</title>
 
    ##<link rel="stylesheet" href="/js/yui/reset-fonts-grids/reset-fonts-grids.css" type="text/css" />
 
    ${self.css()}
 
    ${self.js()}
 
</head>
 

	
 
<body class="mainbody">
 
<div id="container">
 
    <div class="page-header">
 
        <h1>${next.breadcrumbs()}</h1>
 
        ${self.page_nav()}
 
    </div>
 
    <div id="main">
 
    	${next.main()}
 
    </div>
 
    <div class="page-footer">
 
        Mercurial App &copy; 2010
 
    </div>   
 

	
 
    <div id="powered-by">
 
        <p>
 
        <a href="http://mercurial.selenic.com/" title="Mercurial">
 
            <img src="/images/hglogo.png" width="75" height="90" alt="mercurial"/></a>
 
        </p>
 
    </div>
 

	
 
    <div id="corner-top-left"></div>
 
    <div id="corner-top-right"></div>
 
    <div id="corner-bottom-left"></div>
 
    <div id="corner-bottom-right"></div>
 

	
 
</div>
 
</body>
 
</html>
 

	
 
### MAKO DEFS ### 
 

	
 
<%def name="page_nav()">
 
	${self.menu()}
 
</%def>
 

	
 

	
 
<%def name="menu(current)">
 
<% 
 
def is_current(selected):
 
	if selected == current:
 
		return 'class=current'
 
%>
 
		%if current not in ['home','admin']:
 
       <script type="text/javascript">
 
       	YAHOO.util.Event.onDOMReady(function(){
 
			YAHOO.util.Event.addListener('repo_switcher','click',function(){
 
				if(YAHOO.util.Dom.hasClass('repo_switcher','selected')){
 
					YAHOO.util.Dom.setStyle('switch_repos','display','none');
 
					YAHOO.util.Dom.setStyle('repo_switcher','background','');
 
					YAHOO.util.Dom.removeClass('repo_switcher','selected');
 
				}
 
				else{
 
					YAHOO.util.Dom.setStyle('switch_repos','display','');
 
					YAHOO.util.Dom.setStyle('repo_switcher','background','#FFFFFF');
 
					YAHOO.util.Dom.addClass('repo_switcher','selected');
 
				}
 
				});
 
			YAHOO.util.Event.addListener('repos_list','change',function(e){
 
	            var wa = YAHOO.util.Dom.get('repos_list').value;
 
	        	
 
	            var url = "${h.url('summary_home',repo_name='__REPLACE__')}".replace('__REPLACE__',wa);
 
		        window.location = url;
 
			})
 
           });
 
       	</script>
 
        <ul class="page-nav">
 
			<li>
 
				<a id="repo_switcher" title="${_('Switch repository')}" href="#">&darr;</a>
 
				<div id="switch_repos" style="display:none;position: absolute;width: 150px;height: 25px">
 
					<select id="repos_list" size="=10">
 
					%for repo in c.cached_repo_list:
 
						<option value="${repo['name']}">${repo['name']}</option>
 
					%endfor
 
					</select>
 
				</div>			
 
			</li>
 
			<%def name="is_current(selected)">
 
				<%
 
					if selected == current:
 
						return 'class="current"'
 
				%>
 
			</%def>
 
            <li ${is_current('summary')|n}>${h.link_to(_('summary'),h.url('summary_home',repo_name=c.repo_name))}</li>
 
            <li ${is_current('shortlog')|n}>${h.link_to(_('shortlog'),h.url('shortlog_home',repo_name=c.repo_name))}</li>
 
			<li ${is_current('changelog')|n}>${h.link_to(_('changelog'),h.url('changelog_home',repo_name=c.repo_name))}</li>            
 
            <li ${is_current('branches')|n}>${h.link_to(_('branches'),h.url('branches_home',repo_name=c.repo_name))}</li>
 
            <li ${is_current('tags')|n}>${h.link_to(_('tags'),h.url('tags_home',repo_name=c.repo_name))}</li>
 
            <li ${is_current('files')|n}>${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name))}</li>
 
	            <li ${is_current('summary')}>${h.link_to(_('summary'),h.url('summary_home',repo_name=c.repo_name))}</li>
 
	            <li ${is_current('shortlog')}>${h.link_to(_('shortlog'),h.url('shortlog_home',repo_name=c.repo_name))}</li>
 
				<li ${is_current('changelog')}>${h.link_to(_('changelog'),h.url('changelog_home',repo_name=c.repo_name))}</li>            
 
	            <li ${is_current('branches')}>${h.link_to(_('branches'),h.url('branches_home',repo_name=c.repo_name))}</li>
 
	            <li ${is_current('tags')}>${h.link_to(_('tags'),h.url('tags_home',repo_name=c.repo_name))}</li>
 
	            <li ${is_current('files')}>${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name))}</li>
 
        </ul>
 
		%else:
 
			<ul class="page-nav">
 
				<li ${is_current('home')}>${h.link_to(_('Home'),h.url('/'))}</li>
 
				<li ${is_current('admin')}>${h.link_to(_('Admin'),h.url('admin_home'))}</li>
 
				<li class="logout">${h.link_to(u'Logout',h.url('logout_home'))}</li>
 
			</ul>
 
		%endif    
 
</%def>
 

	
 
<%def name="css()">
 
<link rel="stylesheet" href="/css/monoblue_custom.css" type="text/css" />
 
</%def>
 

	
 
<%def name="js()">
 
<script type="text/javascript" src="/js/yui/utilities/utilities.js"></script>
 
</%def>
 

	
 
<!-- DEFINITION OF FORM ERROR FETCHER -->
 
<%def name="get_form_error(element)">
 
	%if hasattr(c,'form_errors') and type(c.form_errors) == dict:
 
        %if c.form_errors.get(element,False):
 
            <span class="error-message">
 
                ${c.form_errors.get(element,'')}
 
            </span>
 
        %endif
 
	%endif           
 
</%def>
 
\ No newline at end of file
0 comments (0 inline, 0 general)