|
1 | 1 | <!DOCTYPE html>
|
2 | 2 | <html lang="en">
|
3 | 3 | <head>
|
4 |
| - <meta charset="UTF-8"> |
| 4 | + <meta charset="UTF-8"/> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1"/> |
| 6 | + |
5 | 7 | <title>Clippy</title>
|
6 | 8 |
|
7 |
| - <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/css/bootstrap.min.css"/> |
8 |
| - <meta name="viewport" content="width=device-width, initial-scale=1"/> |
| 9 | + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css"/> |
| 10 | + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/styles/github.min.css"/> |
| 11 | + <style> |
| 12 | + blockquote { font-size: 1em; } |
| 13 | + [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { display: none !important; } |
| 14 | + .panel .anchor { display: none; } |
| 15 | + .panel:hover .anchor { display: inline; color: #fff; } |
| 16 | + </style> |
9 | 17 | </head>
|
10 | 18 | <body>
|
11 | 19 | <div class="container" ng-app="clippy" ng-controller="lintList">
|
12 | 20 | <div class="page-header">
|
13 | 21 | <h1>ALL the Clippy Lints</h1>
|
14 | 22 | </div>
|
15 | 23 |
|
16 |
| - <div class="alert alert-info" role="alert" ng-if="loading"> |
17 |
| - Loading… |
18 |
| - </div> |
19 |
| - <div class="alert alert-danger" role="alert" ng-if="error"> |
20 |
| - Error loading commits! |
21 |
| - </div> |
| 24 | + <noscript> |
| 25 | + <div class="alert alert-danger" role="alert"> |
| 26 | + Sorry, this site only works with JavaScript! |
| 27 | + </div> |
| 28 | + </noscript> |
22 | 29 |
|
23 |
| - <div class="panel panel-default" ng-show="data"> |
24 |
| - <div class="panel-body row"> |
25 |
| - <div class="col-md-6 form-inline"> |
26 |
| - <div class="form-group"> |
27 |
| - <label for="filter-level">Level</label> |
28 |
| - <select class="form-control" id="filter-level" ng-model="level.level"> |
29 |
| - <option value="">All</option> |
30 |
| - <option value="Allow">Allow</option> |
31 |
| - <option value="Warn">Warn</option> |
32 |
| - <option value="Deny">Deny</option> |
33 |
| - </select> |
| 30 | + <div ng-cloak> |
| 31 | + |
| 32 | + <div class="alert alert-info" role="alert" ng-if="loading"> |
| 33 | + Loading… |
| 34 | + </div> |
| 35 | + <div class="alert alert-danger" role="alert" ng-if="error"> |
| 36 | + Error loading lints! |
| 37 | + </div> |
| 38 | + |
| 39 | + <div class="panel panel-default" ng-show="data"> |
| 40 | + <div class="panel-body row"> |
| 41 | + <div class="col-md-6 form-inline"> |
| 42 | + <div class="form-group form-group-lg"> |
| 43 | + <div class="checkbox" ng-repeat="(level, enabled) in levels" style="margin-right: 0.6em"> |
| 44 | + <label> |
| 45 | + <input type="checkbox" ng-model="levels[level]" /> |
| 46 | + {{level}} |
| 47 | + </label> |
| 48 | + </div> |
| 49 | + </div> |
34 | 50 | </div>
|
35 |
| - </div> |
36 |
| - <div class="col-md-6"> |
37 |
| - <div class="input-group"> |
38 |
| - <span class="input-group-addon" id="filter-label">Filter:</span> |
39 |
| - <input type="text" class="form-control" placeholder="Keywords or search string" aria-describedby="filter-label" ng-model="search" /> |
40 |
| - <span class="input-group-btn"> |
41 |
| - <button class="btn btn-default" type="button" ng-click="search = ''"> |
42 |
| - Clear |
43 |
| - </button> |
44 |
| - </span> |
| 51 | + <div class="col-md-6"> |
| 52 | + <div class="input-group"> |
| 53 | + <span class="input-group-addon" id="filter-label">Filter:</span> |
| 54 | + <input type="text" class="form-control" placeholder="Keywords or search string" aria-describedby="filter-label" ng-model="search" /> |
| 55 | + <span class="input-group-btn"> |
| 56 | + <button class="btn btn-default" type="button" ng-click="search = ''"> |
| 57 | + Clear |
| 58 | + </button> |
| 59 | + </span> |
| 60 | + </div> |
45 | 61 | </div>
|
46 | 62 | </div>
|
47 | 63 | </div>
|
48 |
| - </div> |
49 | 64 |
|
50 |
| - <article class="panel panel-default" ng-repeat="lint in data | filter:level | filter:search | orderBy:'id' track by lint.id"> |
51 |
| - <header class="panel-heading" ng-click="open[lint.id] = !open[lint.id]"> |
52 |
| - <button class="btn btn-default btn-sm pull-right" style="margin-top: -6px;"> |
53 |
| - <span ng-show="open[lint.id]">−</span> |
54 |
| - <span ng-hide="open[lint.id]">+</span> |
55 |
| - </button> |
56 |
| - |
57 |
| - <h2 class="panel-title"> |
58 |
| - {{lint.id}} |
59 |
| - <span ng-if="lint.level == 'Allow'" class="label label-info">Allow</span> |
60 |
| - <span ng-if="lint.level == 'Warn'" class="label label-warning">Warn</span> |
61 |
| - <span ng-if="lint.level == 'Deny'" class="label label-danger">Deny</span> |
62 |
| - </h2> |
63 |
| - </header> |
64 |
| - |
65 |
| - <ul class="list-group" ng-if="lint.docs" ng-class="{collapse: true, in: open[lint.id]}"> |
66 |
| - <li class="list-group-item" ng-repeat="(title, text) in lint.docs"> |
67 |
| - <h4 class="list-group-item-heading"> |
68 |
| - {{title}} |
69 |
| - </h4> |
70 |
| - <div class="list-group-item-text" ng-bind-html="text | markdown"></div> |
71 |
| - </li> |
72 |
| - </ul> |
73 |
| - </article> |
| 65 | + <article class="panel panel-default" id="{{lint.id}}" ng-repeat="lint in data | filter:byLevels | filter:search | orderBy:'id' track by lint.id"> |
| 66 | + <header class="panel-heading" ng-click="open[lint.id] = !open[lint.id]"> |
| 67 | + <button class="btn btn-default btn-sm pull-right" style="margin-top: -6px;"> |
| 68 | + <span ng-show="open[lint.id]">−</span> |
| 69 | + <span ng-hide="open[lint.id]">+</span> |
| 70 | + </button> |
| 71 | + |
| 72 | + <h2 class="panel-title"> |
| 73 | + {{lint.id}} |
| 74 | + |
| 75 | + <span ng-if="lint.level == 'Allow'" class="label label-info">Allow</span> |
| 76 | + <span ng-if="lint.level == 'Warn'" class="label label-warning">Warn</span> |
| 77 | + <span ng-if="lint.level == 'Deny'" class="label label-danger">Deny</span> |
| 78 | + |
| 79 | + <a href="#{{lint.id}}" class="anchor label label-default">¶</a> |
| 80 | + </h2> |
| 81 | + </header> |
| 82 | + |
| 83 | + <ul class="list-group" ng-if="lint.docs" ng-class="{collapse: true, in: open[lint.id]}"> |
| 84 | + <li class="list-group-item" ng-repeat="(title, text) in lint.docs"> |
| 85 | + <h4 class="list-group-item-heading"> |
| 86 | + {{title}} |
| 87 | + </h4> |
| 88 | + <div class="list-group-item-text" ng-bind-html="text | markdown"></div> |
| 89 | + </li> |
| 90 | + </ul> |
| 91 | + </article> |
| 92 | + </div> |
74 | 93 | </div>
|
75 | 94 |
|
76 | 95 | <a href="https://github.com/Manishearth/rust-clippy">
|
77 | 96 | <img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"/>
|
78 | 97 | </a>
|
79 | 98 |
|
80 |
| - <script src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.2/marked.min.js"></script> |
| 99 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/7.0.0/markdown-it.min.js"></script> |
| 100 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/highlight.min.js"></script> |
| 101 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/languages/rust.min.js"></script> |
81 | 102 | <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.12/angular.min.js"></script>
|
82 | 103 | <script>
|
83 | 104 | (function () {
|
| 105 | + var md = window.markdownit({ |
| 106 | + html: true, |
| 107 | + linkify: true, |
| 108 | + typographer: true, |
| 109 | + highlight: function (str, lang) { |
| 110 | + if (lang && hljs.getLanguage(lang)) { |
| 111 | + try { |
| 112 | + return '<pre class="hljs"><code>' + |
| 113 | + hljs.highlight(lang, str, true).value + |
| 114 | + '</code></pre>'; |
| 115 | + } catch (__) {} |
| 116 | + } |
| 117 | + |
| 118 | + return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>'; |
| 119 | + } |
| 120 | + }); |
| 121 | + |
84 | 122 | angular.module("clippy", [])
|
85 | 123 | .filter('markdown', function ($sce) {
|
86 | 124 | return function (text) {
|
87 |
| - if (typeof text !== 'string') { |
88 |
| - text = '' |
89 |
| - }; |
90 |
| - |
91 | 125 | return $sce.trustAsHtml(
|
92 |
| - marked(text) |
| 126 | + md.render(text || '') |
| 127 | + // Oh deer, what a hack :O |
| 128 | + .replace('<table', '<table class="table"') |
93 | 129 | );
|
94 | 130 | };
|
95 | 131 | })
|
96 | 132 | .controller("lintList", function ($scope, $http) {
|
| 133 | + // Level filter |
| 134 | + $scope.levels = {Allow: true, Warn: true, Deny: true}; |
| 135 | + $scope.byLevels = function (lint) { |
| 136 | + return $scope.levels[lint.level]; |
| 137 | + }; |
| 138 | + |
97 | 139 | // Get data
|
98 | 140 | $scope.open = {};
|
99 | 141 | $scope.loading = true;
|
|
0 commit comments