]> git.lizzy.rs Git - rust.git/blob - util/gh-pages/versions.html
Docs index: Sort versions in a nice way
[rust.git] / util / gh-pages / versions.html
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4     <meta charset="UTF-8"/>
5     <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
7     <title>Clippy</title>
8
9     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css"/>
10     <style>
11         [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { display: none !important; }
12     </style>
13 </head>
14 <body>
15     <div class="container" ng-app="clippy" ng-controller="docVersions">
16         <div class="page-header">
17             <h1>Clippy lints documention</h1>
18         </div>
19
20         <div ng-cloak>
21             <div class="alert alert-info" role="alert" ng-if="loading">
22                 Loading&#x2026;
23             </div>
24             <div class="alert alert-danger" role="alert" ng-if="error">
25                 Error loading versions!<br/>
26                 You can always try to get <a href="master/index.html">the master branch docs</a>.
27             </div>
28
29             <article class="panel panel-default" ng-show="data">
30                 <div class="panel-heading">
31                     <h3 class="panel-title">
32                         Available versions
33                     </h3>
34                 </div>
35
36                 <ul class="list-group">
37                     <a class="list-group-item" ng-repeat="version in data | orderBy:versionOrder:true"
38                        href="./{{version}}/index.html">
39                         {{normalizeVersion(version)}}
40                     </a>
41                 </ul>
42             </article>
43         </div>
44     </div>
45
46     <a href="https://github.com/rust-lang-nursery/rust-clippy">
47         <img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"/>
48     </a>
49
50
51     <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.12/angular.min.js"></script>
52     <script>
53         angular.module('clippy', [])
54         .controller('docVersions', function ($scope, $http) {
55             $scope.loading = true;
56
57             $scope.normalizeVersion = function(v) {
58                 return v.replace(/^v/, '');
59             };
60
61             $scope.versionOrder = function(v) {
62                 if (v === 'master') { return Infinity; }
63                 if (v === 'current') { return Number.MAX_VALUE; }
64
65                 return $scope.normalizeVersion(v)
66                     .split('.')
67                     .reverse()
68                     .reduce(function(acc, val, index) {
69                         return acc + (val * Math.pow(100, index));
70                     }, 0);
71             }
72
73             $http.get('./versions.json')
74             .success(function (data) {
75                 $scope.data = data;
76                 $scope.loading = false;
77             })
78             .error(function (data) {
79                 $scope.error = data;
80                 $scope.loading = false;
81             });
82         })
83         ;
84     </script>
85 </body>
86 </html>