Changeset 5158


Ignore:
Timestamp:
01/04/09 17:08:10 (10 years ago)
Author:
cbyrom
Message:

Add new home page for the browse service + implement usage of the
before methods on controllers to check if MILK is set up to
allow the various services before the controller methods are invoked.
Also add a top level default controller to redirect user to the correct
home page depending on the mode of operation + improve styles,
remove unused controller and move error template to more general top
level - for re-use across the MILK stack.

Location:
MILK/trunk/milk_server/milk_server
Files:
2 added
1 deleted
10 edited
1 moved

Legend:

Unmodified
Added
Removed
  • MILK/trunk/milk_server/milk_server/config/routing.py

    r5099 r5158  
    3030    map.connect('example', 'exampleGranulite', controller = 'atom_editor/listatom', action='showExampleGranulite') 
    3131    map.connect('help', 'help', controller = 'atom_editor/listatom', action='showAtomHelp') 
    32     map.connect('home', 'atomHome', controller = 'atom_editor/listatom', action='atomHome') 
     32    map.connect('atomHome', 'atomHome', controller = 'atom_editor/listatom', action='atomHome') 
    3333    map.connect('list', 'listAtom/:searchData/:associatedAtomID/:associatedAtomType/:associationType', \ 
    3434                controller = 'atom_editor/listatom', action='list', searchData='', \ 
     
    4545    map.connect('semantic',controller='browse/discovery', action='semantic') 
    4646    map.connect('view/:uri', controller = 'browse/retrieve', action='view') 
     47    map.connect('browseHome', controller = 'browse/retrieve', action='home') 
    4748    map.connect('retrive', 'retrieve/:uri', controller = 'browse/retrieve') 
    4849    map.connect('selectedItems',controller='visualise/selectedItems',action='index') 
     
    6263 
    6364    #do this last or else you'll get bizarre behaviour 
    64     map.connect('',controller='browse/discovery',action='index') 
     65    map.connect('default', '',controller='home',action='index') 
    6566    map.connect('clearSession',controller='browse/discovery',action='clearSession') 
    6667    return map 
  • MILK/trunk/milk_server/milk_server/controllers/atom_editor/atomeditorcontroller.py

    r5128 r5158  
    2121    REMOVE_ASSOCIATIONS = 4 
    2222 
     23    def __before__(self): 
     24        ''' 
     25        Before anything is done, ensure the atom editor is enabled 
     26        ''' 
     27        if not g.atomEditorEnabled: 
     28            logging.info("Editor not enabled - cannot edit atoms - redirecting to default") 
     29            return h.redirect_to(h.url_for('default')) 
     30         
     31 
    2332    def _setup(self, uri=None, loadAtom=True): 
    2433        '''  
     
    2837        Default is True.  
    2938        ''' 
    30         # check the editor is enabled first 
    31         if not g.atomEditorEnabled: 
    32             logging.info("Editor not enabled - cannot edit atoms - redirect to 'view' mode") 
    33             return h.redirect_to(h.url_for('discovery')) 
    3439 
    3540        logging.info("Setting up AtomEditorController") 
     
    137142 
    138143 
    139     def _handleError(self, e, template='atom_editor/error'): 
     144    def _handleError(self, e, template='error'): 
    140145        ''' 
    141146        Handle exceptions thrown; if debug mode on, display full stack trace 
  • MILK/trunk/milk_server/milk_server/controllers/atom_editor/editatom.py

    r5136 r5158  
    173173        elif uri: 
    174174            # something has gone wrong here... 
    175             return render("genshi", 'atom_editor/error') 
     175            return render("genshi", 'error') 
    176176        else: 
    177177            return self.createGranule(**self.inputs) 
     
    380380         
    381381        response.status_code = 400 
    382         return render("genshi", 'atom_editor/error') 
     382        return render("genshi", 'error') 
    383383 
    384384 
  • MILK/trunk/milk_server/milk_server/controllers/atom_editor/listatom.py

    r5111 r5158  
    137137         
    138138        response.status_code = 400 
    139         return render("genshi", 'atom_editor/error') 
     139        return render("genshi", 'error') 
    140140     
    141141     
  • MILK/trunk/milk_server/milk_server/controllers/browse/discovery.py

    r5136 r5158  
    1717 
    1818class DiscoveryController(BaseController): 
    19     ''' Provides the pylons controller for NDG discovery ''' 
    20      
     19    '''  
     20    Provides the pylons controller for NDG discovery  
     21    ''' 
     22 
    2123    def __setup(self): 
    2224        ''' Common setup for controller methods ''' 
     
    3234         
    3335        # parse the query string and hand off to a discovery engine 
    34         if self.inputs=={} or 'ClearForm' in self.inputs:  
    35             return self.__advancedPrompt() 
     36        if self.inputs=={} or 'ClearForm' in self.inputs: 
     37            if g.discoveryEnabled: 
     38                return self.__advancedPrompt() 
     39            else: 
     40                logging.info("Discovery mode not enabled - redirect to default") 
     41                return h.redirect_to(h.url_for('default')) 
    3642        
    3743        # see if this is a discovery search or a more complicated search 
     
    4248        continuations={'start':1,'howmany':10} 
    4349        for i in continuations: 
    44             if i not in self.inputs: self.inputs[i]=continuations[i] 
    45              
     50            if i not in self.inputs:  
     51                self.inputs[i]=continuations[i] 
    4652             
    4753        # the simplest query we might get is a text search, in which case 
  • MILK/trunk/milk_server/milk_server/controllers/browse/retrieve.py

    r5128 r5158  
    2222    to retrieve the doc remotely.  
    2323    ''' 
     24    def __before__(self): 
     25        ''' 
     26        Before anything is done, ensure the browse mode is enabled 
     27        - unless we're retrieving associated data then we can do this regardless 
     28        of the mode of operation 
     29        ''' 
     30        if not g.browseEnabled and not g.atomEditorEnabled:# request.path_info.startswith('/viewAssociatedData'): 
     31            logging.info("Browse mode not enabled - redirect to default") 
     32            return h.redirect_to(h.url_for('default')) 
     33 
     34 
     35    def home(self): 
     36        ''' 
     37        Display the browse home page 
     38        ''' 
     39        logging.debug("Displaying browse home page") 
     40        c.title = "Browse" 
     41         
     42        c.doc = "Use the search box above to find data centre metadata records"  
     43        return render('genshi', 'browse/home') 
     44 
    2445     
    2546    def __setup(self, uri): 
  • MILK/trunk/milk_server/milk_server/public/layout/style/ndg2.css

    r5141 r5158  
    2121        font-family:Verdana, Arial, Helvetica, sans-serif; 
    2222        line-height:1.4; 
    23         font-size:small; 
     23        font-size:medium; 
    2424} 
    2525 
  • MILK/trunk/milk_server/milk_server/templates/atom_editor/atom_help.html

    r5134 r5158  
    622622                    <ol> 
    623623                    <li> 
    624                     From the <a href="${h.url_for('home')}">atom home page</a>, click on <a href="${h.url_for('create')}">Create atom</a> link. 
     624                    From the <a href="${h.url_for('atomHome')}">atom home page</a>, click on <a href="${h.url_for('create')}">Create atom</a> link. 
    625625                    </li> 
    626626                    <li> 
     
    644644                    <ol> 
    645645                    <li> 
    646                     Return to the home page, clicking on the <a href="${h.url_for('home')}">Home</a> link. 
     646                    Return to the home page, clicking on the <a href="${h.url_for('atomHome')}">Home</a> link. 
    647647                    </li> 
    648648                    <li> 
     
    681681                    <ol> 
    682682                    <li> 
    683                     Return to the home page, clicking on the <a href="${h.url_for('home')}">Home</a> link. 
     683                    Return to the home page, clicking on the <a href="${h.url_for('atomHome')}">Home</a> link. 
    684684                    </li> 
    685685                    <li> 
     
    702702                    <ol> 
    703703                    <li> 
    704                     Return to the home page, clicking on the <a href="${h.url_for('home')}">Home</a> link. 
     704                    Return to the home page, clicking on the <a href="${h.url_for('atomHome')}">Home</a> link. 
    705705                    </li> 
    706706                    Click on <a href="${h.url_for('create')}">Create atom</a> link and create a new atom - this type specifying 'Deployment' as the data type. 
     
    727727                    <dd> 
    728728                    <li> 
    729                     Return to the home page, clicking on the <a href="${h.url_for('home')}">Home</a> link. 
     729                    Return to the home page, clicking on the <a href="${h.url_for('atomHome')}">Home</a> link. 
    730730                    </li> 
    731731                    <li> 
     
    769769                    <dd> 
    770770                    <li> 
    771                     From the <a href="${h.url_for('home')}">atom home page</a>, click on the <a href="${h.url_for('list')}">Edit/List atoms</a> link and search for and open the Deployment atom created previously. 
     771                    From the <a href="${h.url_for('atomHome')}">atom home page</a>, click on the <a href="${h.url_for('list')}">Edit/List atoms</a> link and search for and open the Deployment atom created previously. 
    772772                    </li> 
    773773                    <li> 
     
    793793                    <dd> 
    794794                    <li> 
    795                     From the <a href="${h.url_for('home')}">atom home page</a>, click on the <a href="${h.url_for('list')}">Edit/List atoms</a> link and search for and open the Data Entity atom created previously. 
     795                    From the <a href="${h.url_for('atomHome')}">atom home page</a>, click on the <a href="${h.url_for('list')}">Edit/List atoms</a> link and search for and open the Data Entity atom created previously. 
    796796                    </li> 
    797797                    <li> 
  • MILK/trunk/milk_server/milk_server/templates/error.html

    r5134 r5158  
    22        xmlns:py="http://genshi.edgewall.org/"  
    33        xmlns:xi="http://www.w3.org/2001/XInclude"> 
    4         <xi:include href="../layout.html" /> 
     4        <xi:include href="layout.html" /> 
    55        <head> 
    66        <title py:content="c.title">title</title> 
    77    </head> 
    88        <body class="submit"> 
    9       <panelTab>Editor</panelTab> 
    109        <div id="contents"> 
    1110            <div class="metadata"> 
  • MILK/trunk/milk_server/milk_server/templates/layout.html

    r5145 r5158  
    3535              <div py:replace="searchOneLine()"/> 
    3636          </div> 
    37       <div py:if="not g.discoveryEnabled"> 
     37      <div py:if="g.browseEnabled or g.atomEditorEnabled"> 
    3838            <div py:replace="localTextSearch()"/> 
    3939          </div> 
     
    4141                <table py:if="g.atomEditorEnabled and c.title != ATOM_HOME_TITLE" class="homeHelpBar"> 
    4242                        <tr><td align="left"> 
    43                             <a href="${h.url_for('home')}">Home</a> 
     43                            <a href="${h.url_for('atomHome')}">Home</a> 
    4444                            </td><td align="right"><a py:if="c.title != HELP_PAGE_TITLE" href="${h.url_for('help')}">Help</a> 
    4545                            </td></tr> 
  • MILK/trunk/milk_server/milk_server/templates/ndgPage.html

    r5134 r5158  
    2626        <table width="100%"><tr><td align="left"> 
    2727        <form action="$g.discoveryURL"> 
    28             New text search<span py:replace="helpIcon('nts_help', 'div')"/>&nbsp; 
     28            Discovery text search<span py:replace="helpIcon('nts_help', 'div')"/>&nbsp; 
    2929            <input type="text" size="25" name="searchString"/> 
    3030            <select name="textTarget"> 
     
    5151        </td></tr></table> 
    5252          <div id="nts_help" class="hidden"> 
    53             <div class="helptxt"><p> This will do a completely new text search with no constraints beyond the target of the 
     53            <div class="helptxt"><p> This will do a completely new discovery text search with no constraints beyond the target of the 
    5454            text search from the drop down list (All, Authors, Parameters) </p></div> 
    5555          </div> 
Note: See TracChangeset for help on using the changeset viewer.