Add a search feature

[?]
Feb 22, 2013, 2:45 PM
UICHT2PSN2QOCHP6MGY5QQJUDU4IF6FBIOJLBA55QBJDK6ST566AC

Dependencies

  • [2] VH5ZABDR Add a page to show the latest evaluations for the entire server
  • [3] HRAFVVOE make logo configurable via HYDRA_LOGO env var
  • [4] G4X5IUYJ Remove default logo, replaced by text for now. Hide template in jobset edit.
  • [5] QL55ECJ6 - adapted ui for hydra, more in line with nixos.org website
  • [6] 7ZQAHJQM Fix indentation
  • [7] QBT7FA7R Compatibility with latest bootstrap
  • [8] SBMOICGV Evil CSS hackery to prevent link targets from being under the navbar
  • [9] OEPUOUNB Using twitter bootstrap for more consistent looks for Hydra
  • [10] NOSDBMWD Remove comments, re-add logo.
  • [11] JZVRK5QJ Group some menu items together under a "Status" menu
  • [*] J5UVLXOK * Start of a basic Catalyst web interface.
  • [*] D5QIOJGP * Move everything up one directory.

Change contents

  • edit in src/lib/Hydra/Controller/Root.pm at line 300
    [2.843]
    [3.416]
    }
    sub search :Local Args(0) {
    my ($self, $c) = @_;
    $c->stash->{template} = 'search.tt';
    my $query = trim $c->request->params->{"query"};
    error($c, "Query is empty.") if $query eq "";
    error($c, "Invalid character in query.")
    unless $query =~ /^[a-zA-Z0-9_\-]+$/;
    $c->stash->{projects} = [ $c->model('DB::Projects')->search(
    { -or => [ name => { ilike => "%$query%" }, displayName => { ilike => "%$query%" }, description => { ilike => "%$query%" } ] },
    { order_by => ["name"] } ) ];
    $c->stash->{jobsets} = [ $c->model('DB::Jobsets')->search(
    { -or => [ name => { ilike => "%$query%" }, description => { ilike => "%$query%" } ] },
    { order_by => ["project", "name"] } ) ];
    $c->stash->{jobs} = [ $c->model('DB::Jobs')->search(
    { name => { ilike => "%$query%" } },
    { order_by => ["project", "jobset", "name"] } ) ];
  • replacement in src/root/layout.tt at line 88
    [3.6851][3.6851:6939]()
    <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
    [3.6851]
    [3.6939]
    <a class="btn btn-navbar" data-toggle="collapse" data-target=".navbar-responsive-collapse">
  • replacement in src/root/layout.tt at line 100
    [3.708][3.522:568]()
    <div class="nav-collapse collapse">
    [3.708]
    [3.7222]
    <div class="nav-collapse collapse navbar-responsive-collapse">
  • file addition: search.tt (----------)
    [14.1486]
    [% WRAPPER layout.tt title="Search results" %]
    [% PROCESS common.tt %]
    [% IF projects.size > 0; matched = 1 %]
    <p>The following projects match your query:</p>
    <table class="table table-striped table-condensed">
    <thead>
    <tr><th>Project</th><th>Description</th></tr>
    </thead>
    <tbody>
    [% FOREACH p IN projects %]
    <tr>
    <td>[% INCLUDE renderProjectName project=p.name %]</td>
    <td>[% HTML.escape(p.description) %]</td>
    </tr>
    [% END %]
    </tbody>
    </table>
    [% END %]
    [% IF jobsets.size > 0; matched = 1 %]
    <p>The following jobsets match your query:</p>
    <table class="table table-striped table-condensed">
    <thead>
    <tr><th>Jobset</th><th>Description</th></tr>
    </thead>
    <tbody>
    [% FOREACH j IN jobsets %]
    <tr>
    <td>[% INCLUDE renderFullJobsetName project=j.get_column('project') jobset=j.name %]</td>
    <td>[% HTML.escape(j.description) %]</td>
    </tr>
    [% END %]
    </tbody>
    </table>
    [% END %]
    [% IF jobs.size > 0; matched = 1 %]
    <p>The following jobs match your query:</p>
    <table class="table table-striped table-condensed">
    <thead>
    <tr><th>Job</th></tr>
    </thead>
    <tbody>
    [% FOREACH j IN jobs %]
    <tr>
    <td>[% INCLUDE renderFullJobName project=j.get_column('project') jobset=j.get_column('jobset') job=j.name %]</td>
    </tr>
    [% END %]
    </tbody>
    </table>
    [% END %]
    [% IF !matched %]
    <div class="alert alert-warn">Sorry! Nothing matches your
    query.</div>
    [% END %]
    [% END %]
  • replacement in src/root/topbar.tt at line 27
    [3.11122][3.238:269]()
    <ul class="nav" id="top-menu">
    [3.11122]
    [3.0]
    <ul class="nav pull-left" id="top-menu">
  • edit in src/root/topbar.tt at line 186
    [3.2728]
    [3.15871]
    </ul>
  • replacement in src/root/topbar.tt at line 189
    [3.15872][3.2729:2975](),[3.2975][3.15872:15884](),[3.15872][3.15872:15884]()
    [% IF c.user_exists %]
    [% INCLUDE makeLink uri = c.uri_for(c.controller('Root').action_for('logout')) title = "Sign out" %]
    [% ELSE %]
    [% INCLUDE makeLink uri = c.uri_for(c.controller('Root').action_for('login')) title = "Sign in" %]
    [% END %]
    [3.15872]
    [3.15884]
    <div class="pull-right">
  • replacement in src/root/topbar.tt at line 191
    [3.15885][3.2976:2982]()
    </ul>
    [3.15885]
    <form class="navbar-search" action="[% c.uri_for('/search') %]">
    <input name="query" type="text" class="search-query span2" placeholder="Search"></input>
    </form>
    <ul class="nav" id="top-menu">
    [% IF c.user_exists %]
    [% INCLUDE makeLink uri = c.uri_for(c.controller('Root').action_for('logout')) title = "Sign out" %]
    [% ELSE %]
    [% INCLUDE makeLink uri = c.uri_for(c.controller('Root').action_for('login')) title = "Sign in" %]
    [% END %]
    </ul>
    </div>