templates: Use uri_for to reference static paths.

This commit is provided by (zsh syntax):

sed -i 's|/static[^"]*|[% c.uri_for("&") %]|;s/\[% size %\]/${size}/' **/*.tt

And the reason for this change is to make it easier to change the base
path with headers like X-Request-Base to be served within a URI prefix,
especially when behind a reverse proxy.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig 2013-09-25 12:34:13 +02:00 committed by Eelco Dolstra
parent a2491f76a4
commit 0b202580ce
8 changed files with 44 additions and 44 deletions

View file

@ -402,8 +402,8 @@
<div id="placeholder" style="width:800px;height:400px;"></div> <div id="placeholder" style="width:800px;height:400px;"></div>
<div id="overview" style="margin-left:50px;margin-top:20px;width:600px;height:50px"></div> <div id="overview" style="margin-left:50px;margin-top:20px;width:600px;height:50px"></div>
<script src="/static/js/flot/jquery.flot.js" type="text/javascript"></script> <script src="[% c.uri_for("/static/js/flot/jquery.flot.js") %]" type="text/javascript"></script>
<script src="/static/js/flot/jquery.flot.selection.js" type="text/javascript"></script> <script src="[% c.uri_for("/static/js/flot/jquery.flot.selection.js") %]" type="text/javascript"></script>
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
var d = []; var d = [];

View file

@ -44,7 +44,7 @@
</tbody> </tbody>
</table> </table>
<p><button type="submit"><img alt="Add" src="/static/images/success.gif" />Add to queue</button></p> <p><button type="submit"><img alt="Add" src="[% c.uri_for("/static/images/success.gif") %]" />Add to queue</button></p>
</form> </form>

View file

@ -195,24 +195,24 @@ BLOCK renderBuildStatusIcon;
buildstatus = buildstatus != undef ? buildstatus : build.buildstatus; buildstatus = buildstatus != undef ? buildstatus : build.buildstatus;
IF finished; IF finished;
IF buildstatus == 0 %] IF buildstatus == 0 %]
<img src="/static/images/checkmark_[% size %].png" alt="Succeeded" /> <img src="[% c.uri_for("/static/images/checkmark_${size}.png") %]" alt="Succeeded" />
[% ELSIF buildstatus == 1 %] [% ELSIF buildstatus == 1 %]
<img src="/static/images/error_[% size %].png" alt="Failed" /> <img src="[% c.uri_for("/static/images/error_${size}.png") %]" alt="Failed" />
[% ELSIF buildstatus == 2 || buildstatus == 5 %] [% ELSIF buildstatus == 2 || buildstatus == 5 %]
<img src="/static/images/dependency_[% size %].png" alt="Dependency failed" /> <img src="[% c.uri_for("/static/images/dependency_${size}.png") %]" alt="Dependency failed" />
[% ELSIF buildstatus == 3 %] [% ELSIF buildstatus == 3 %]
<img src="/static/images/warning_[% size %].png" alt="Aborted" /> <img src="[% c.uri_for("/static/images/warning_${size}.png") %]" alt="Aborted" />
[% ELSIF buildstatus == 4 %] [% ELSIF buildstatus == 4 %]
<img src="/static/images/forbidden_[% size %].png" alt="Cancelled" /> <img src="[% c.uri_for("/static/images/forbidden_${size}.png") %]" alt="Cancelled" />
[% ELSIF buildstatus == 6 %] [% ELSIF buildstatus == 6 %]
<img src="/static/images/error_[% size %].png" alt="Failed (with result)" /> <img src="[% c.uri_for("/static/images/error_${size}.png") %]" alt="Failed (with result)" />
[% ELSE %] [% ELSE %]
<img src="/static/images/error_[% size %].png" alt="Failed" /> <img src="[% c.uri_for("/static/images/error_${size}.png") %]" alt="Failed" />
[% END; [% END;
ELSIF busy %] ELSIF busy %]
<img src="/static/images/help_[% size %].png" alt="Busy" /> <img src="[% c.uri_for("/static/images/help_${size}.png") %]" alt="Busy" />
[% ELSE %] [% ELSE %]
<img src="/static/images/help_[% size %].png" alt="Scheduled" /> <img src="[% c.uri_for("/static/images/help_${size}.png") %]" alt="Scheduled" />
[% END; [% END;
END; END;
@ -456,7 +456,7 @@ BLOCK renderLogLinks %]
BLOCK makeLazyTab %] BLOCK makeLazyTab %]
<div id="[% tabName %]" class="tab-pane"> <div id="[% tabName %]" class="tab-pane">
<center><img src="/static/images/ajax-loader.gif" alt="Loading..." /></center> <center><img src="[% c.uri_for("/static/images/ajax-loader.gif") %]" alt="Loading..." /></center>
</div> </div>
<script> <script>
$(function() { makeLazyTab("[% tabName %]", "[% uri %]"); }); $(function() { makeLazyTab("[% tabName %]", "[% uri %]"); });

View file

@ -6,7 +6,7 @@
<button type="button" class="btn btn-info [% IF showInactive %]active[% END %]" id="active-toggle">Show inactive jobs</button> <button type="button" class="btn btn-info [% IF showInactive %]active[% END %]" id="active-toggle">Show inactive jobs</button>
</div> </div>
&nbsp; &nbsp;
<img src="/static/images/ajax-loader.gif" alt="Loading..." style="display: none;" id="filter-loading" /> <img src="[% c.uri_for("/static/images/ajax-loader.gif") %]" alt="Loading..." style="display: none;" id="filter-loading" />
</form> </form>
<script> <script>

View file

@ -15,25 +15,25 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script type="text/javascript" src="/static/bootstrap/js/bootstrap.min.js"></script> <script type="text/javascript" src="[% c.uri_for("/static/bootstrap/js/bootstrap.min.js") %]"></script>
<link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet" /> <link href="[% c.uri_for("/static/bootstrap/css/bootstrap.min.css") %]" rel="stylesheet" />
<!-- hydra.css must be included before bootstrap-responsive to <!-- hydra.css must be included before bootstrap-responsive to
make the @media rule work. --> make the @media rule work. -->
<link rel="stylesheet" href="/static/css/hydra.css" type="text/css" /> <link rel="stylesheet" href="[% c.uri_for("/static/css/hydra.css") %]" type="text/css" />
<link rel="stylesheet" href="/static/css/rotated-th.css" type="text/css" /> <link rel="stylesheet" href="[% c.uri_for("/static/css/rotated-th.css") %]" type="text/css" />
<link href="/static/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" /> <link href="[% c.uri_for("/static/bootstrap/css/bootstrap-responsive.min.css") %]" rel="stylesheet" />
<style> <style>
.popover { max-width: 40%; } .popover { max-width: 40%; }
</style> </style>
<script type="text/javascript" src="/static/js/bootbox.min.js"></script> <script type="text/javascript" src="[% c.uri_for("/static/js/bootbox.min.js") %]"></script>
<link rel="stylesheet" href="/static/css/tree.css" type="text/css" /> <link rel="stylesheet" href="[% c.uri_for("/static/css/tree.css") %]" type="text/css" />
<link rel="stylesheet" href="/static/css/logfile.css" type="text/css" /> <link rel="stylesheet" href="[% c.uri_for("/static/css/logfile.css") %]" type="text/css" />
<script type="text/javascript" src="/static/js/common.js"></script> <script type="text/javascript" src="[% c.uri_for("/static/js/common.js") %]"></script>
[% tracker %] [% tracker %]

View file

@ -40,7 +40,7 @@
<tr class="product"> <tr class="product">
<td> <td>
<a href="[% contents %]"> <a href="[% contents %]">
<img src="/static/images/error_32.png" alt="Source" /> <img src="[% c.uri_for("/static/images/error_32.png") %]" alt="Source" />
Failed build produced output. Click here to inspect the output. Failed build produced output. Click here to inspect the output.
</a> </a>
[% WRAPPER makePopover title="Help" classes="btn-mini" %] [% WRAPPER makePopover title="Help" classes="btn-mini" %]
@ -59,7 +59,7 @@
<td> <td>
[% uri = c.uri_for('/build' build.id 'nix' 'pkg' "${build.nixname}-${build.system}.nixpkg") %] [% uri = c.uri_for('/build' build.id 'nix' 'pkg' "${build.nixname}-${build.system}.nixpkg") %]
<a href="[% uri %]"> <a href="[% uri %]">
<img src="/static/images/nix-build.png" alt="Source" /> <img src="[% c.uri_for("/static/images/nix-build.png") %]" alt="Source" />
One-click install of Nix package <tt>[% build.nixname %]</tt> One-click install of Nix package <tt>[% build.nixname %]</tt>
</a> </a>
[% WRAPPER makePopover title="Help" classes="btn-mini" %] [% WRAPPER makePopover title="Help" classes="btn-mini" %]
@ -87,7 +87,7 @@
[% uri = c.uri_for('/build' build.id 'nix' 'closure' filename ) %] [% uri = c.uri_for('/build' build.id 'nix' 'closure' filename ) %]
<a href="[% uri %]"> <a href="[% uri %]">
<img src="/static/images/nix-build.png" alt="Source" /> <img src="[% c.uri_for("/static/images/nix-build.png") %]" alt="Source" />
Nix closure of path <tt>[% product.path %]</tt> Nix closure of path <tt>[% product.path %]</tt>
</a> </a>
@ -127,17 +127,17 @@
<a href="[% uri %]"> <a href="[% uri %]">
[% SWITCH product.subtype %] [% SWITCH product.subtype %]
[% CASE "source-dist" %] [% CASE "source-dist" %]
<img src="/static/images/source-dist.png" alt="Source" /> Source distribution <tt>[% product.name %]</tt> <img src="[% c.uri_for("/static/images/source-dist.png") %]" alt="Source" /> Source distribution <tt>[% product.name %]</tt>
[% CASE "rpm" %] [% CASE "rpm" %]
<img src="/static/images/rpm.png" alt="RPM" /> RPM package <tt>[% product.name %]</tt> <img src="[% c.uri_for("/static/images/rpm.png") %]" alt="RPM" /> RPM package <tt>[% product.name %]</tt>
[% CASE "srpm" %] [% CASE "srpm" %]
<img src="/static/images/rpm.png" alt="Source RPM" /> Source RPM package <tt>[% product.name %]</tt> <img src="[% c.uri_for("/static/images/rpm.png") %]" alt="Source RPM" /> Source RPM package <tt>[% product.name %]</tt>
[% CASE "deb" %] [% CASE "deb" %]
<img src="/static/images/debian.png" alt="RPM" /> Debian package <tt>[% product.name %]</tt> <img src="[% c.uri_for("/static/images/debian.png") %]" alt="RPM" /> Debian package <tt>[% product.name %]</tt>
[% CASE "iso" %] [% CASE "iso" %]
<img src="/static/images/iso.png" alt="ISO" /> ISO-9660 CD/DVD image <tt>[% product.name %]</tt> <img src="[% c.uri_for("/static/images/iso.png") %]" alt="ISO" /> ISO-9660 CD/DVD image <tt>[% product.name %]</tt>
[% CASE "binary-dist" %] [% CASE "binary-dist" %]
<img src="/static/images/binary-dist.png" alt="Binary distribution" /> Binary distribution <tt>[% product.name %]</tt> <img src="[% c.uri_for("/static/images/binary-dist.png") %]" alt="Binary distribution" /> Binary distribution <tt>[% product.name %]</tt>
[% CASE DEFAULT %] [% CASE DEFAULT %]
File <tt>[% product.name %]</tt> of type <tt>[% product.subtype %]</tt> File <tt>[% product.name %]</tt> of type <tt>[% product.subtype %]</tt>
[% END %] [% END %]
@ -160,7 +160,7 @@
<tr class="product"> <tr class="product">
<td> <td>
<a href="[% uri %]"> <a href="[% uri %]">
<img src="/static/images/report.png" alt="Report" /> <img src="[% c.uri_for("/static/images/report.png") %]" alt="Report" />
[% SWITCH product.subtype %] [% SWITCH product.subtype %]
[% CASE "coverage" %] [% CASE "coverage" %]
Code coverage analysis report Code coverage analysis report
@ -177,9 +177,9 @@
<td> <td>
<a href="[% uri %]"> <a href="[% uri %]">
[% IF product.type == "doc-pdf" %] [% IF product.type == "doc-pdf" %]
<img src="/static/images/pdf.png" alt="PDF document" /> <img src="[% c.uri_for("/static/images/pdf.png") %]" alt="PDF document" />
[% ELSE %] [% ELSE %]
<img src="/static/images/document.png" alt="Document" /> <img src="[% c.uri_for("/static/images/document.png") %]" alt="Document" />
[% END %] [% END %]
[% SWITCH product.subtype %] [% SWITCH product.subtype %]
[% CASE "readme" %] [% CASE "readme" %]

View file

@ -32,13 +32,13 @@
<tr> <tr>
<td> <td>
[% IF j.get_column('nrscheduled') > 0 %] [% IF j.get_column('nrscheduled') > 0 %]
<img src="/static/images/help_16.png" alt="Scheduled" /> <img src="[% c.uri_for("/static/images/help_16.png") %]" alt="Scheduled" />
[% ELSIF j.get_column('nrfailed') == 0 %] [% ELSIF j.get_column('nrfailed') == 0 %]
<img src="/static/images/checkmark_16.png" alt="Succeeded" /> <img src="[% c.uri_for("/static/images/checkmark_16.png") %]" alt="Succeeded" />
[% ELSIF j.get_column('nrfailed') > 0 && j.get_column('nrsucceeded') > 0 %] [% ELSIF j.get_column('nrfailed') > 0 && j.get_column('nrsucceeded') > 0 %]
<img src="/static/images/error_some_16.png" alt="Some Failed" /> <img src="[% c.uri_for("/static/images/error_some_16.png") %]" alt="Some Failed" />
[% ELSE %] [% ELSE %]
<img src="/static/images/error_16.png" alt="All Failed" /> <img src="[% c.uri_for("/static/images/error_16.png") %]" alt="All Failed" />
[% END %] [% END %]
</td> </td>
<td><span class="[% IF !j.enabled %]disabled-jobset[% END %] [%+ IF j.hidden %]hidden-jobset[% END %]">[% INCLUDE renderJobsetName project=project.name jobset=j.name inRow=1 %]</span></td> <td><span class="[% IF !j.enabled %]disabled-jobset[% END %] [%+ IF j.hidden %]hidden-jobset[% END %]">[% INCLUDE renderJobsetName project=project.name jobset=j.name inRow=1 %]</span></td>

View file

@ -27,11 +27,11 @@
<tr> <tr>
<td> <td>
[% IF result.status == 0 %] [% IF result.status == 0 %]
<img src="/static/images/checkmark_16.png" /> <img src="[% c.uri_for("/static/images/checkmark_16.png") %]" />
[% ELSIF result.status == 1 %] [% ELSIF result.status == 1 %]
<img src="/static/images/error_16.png" /> <img src="[% c.uri_for("/static/images/error_16.png") %]" />
[% ELSIF result.status == 2 %] [% ELSIF result.status == 2 %]
<img src="/static/images/help_16.png" /> <img src="[% c.uri_for("/static/images/help_16.png") %]" />
[% END %] [% END %]
</td> </td>
<td><a class="row-link" href="[% c.uri_for('/view' project.name view.name result.id) %]">[% result.id %]</a></td> <td><a class="row-link" href="[% c.uri_for('/view' project.name view.name result.id) %]">[% result.id %]</a></td>
@ -48,9 +48,9 @@
[% IF j.build %] [% IF j.build %]
<a href="[% c.uri_for('/build' j.build.id) %]"> <a href="[% c.uri_for('/build' j.build.id) %]">
[% IF j.build.get_column('buildstatus') == 0 %] [% IF j.build.get_column('buildstatus') == 0 %]
<img src="/static/images/checkmark_16.png" /> <img src="[% c.uri_for("/static/images/checkmark_16.png") %]" />
[% ELSE %] [% ELSE %]
<img src="/static/images/error_16.png" /> <img src="[% c.uri_for("/static/images/error_16.png") %]" />
[% END %] [% END %]
</a> </a>
[% END %] [% END %]