-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·215 lines (190 loc) · 7.65 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Bare - Start Bootstrap Template</title>
<!-- Bootstrap Core CSS -->
<link href="node_modules/tether/dist/css/tether.min.css" rel="stylesheet">
<link href="node_modules/tether/dist/css/tether-theme-basic.min.css" rel="stylesheet">
<link href="node_modules/bootstrap/dist/css/bootstrap-grid.css" rel="stylesheet">
<link href="node_modules/bootstrap/dist/css/bootstrap-reboot.css" rel="stylesheet">
<link href="node_modules/bootstrap/dist/css/bootstrap.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link href="css/wired.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-dark bg-primary">
<button class="navbar-toggler hidden-md-up pull-xs-right" data-target="#collapsed-bg-inverse" data-toggle="collapse"
type="button"><i class="fa fa-bars"></i></button>
<div class="collapse navbar-toggleable-sm" id="collapsed-bg-inverse">
<ul class="nav navbar-nav">
<li class="nav-item active"><a class="nav-link" href="#">Home<span class="sr-only" current=""></span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="http://embark.readthedocs.io" target="_blank">Docs</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/iurimatias/embark-framework" target="_blank">
<i class="fa fa-github"></i>
Github
</a>
</li>
<li class="nav-item"><a class="nav-link" href="#">About</a></li>
</ul>
</div>
</nav>
<!-- Page Content -->
<div class="container-fluid">
<div class="row">
<div class="col-lg-12 text-center">
<div class="mt-5 jumbotron">
<h1 class="display-3">Embark Plugins</h1>
<p class="lead">Find and share plugins for the Embark community</p>
</div>
<div class="mt-1">
<div class="form-group">
<div class="input-group">
<input id="search" type="search" class="form-control" placeholder="Find Plugins">
<span class="input-group-btn">
<button class="btn btn-secondary" type="button"><i class="fa fa-search"></i></button>
</span>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div id="results" class="col-lg-12">
</div>
</div>
</div>
<script type="text/x-handlebars-template" id="result-tmpl">
<div class="card">
<h3 class="card-header">{{name}}</h3>
<div class="card-block">
<h4 class="card-title">{{author}}</h4>
<p class="card-text">{{{parsedDescription}}}</p>
<a href="{{homepage}}" target="_blank">homepage</a>
<div class="readme">
{{{parsedReadme}}}
</div>
</div>
<div class="card-footer text-muted">
<p class="text-muted">keywords:
{{#each keywords}}
{{this}}
{{/each}}
</p>
{{version}} : released {{lastUpdated}}
</div>
</div>
</script>
<script type="text/x-handlebars-template" id="result-err-tmpl">
<div class="alert {{level}} alert-dismissible fade in" role="alert">
<button aria-label="Close" class="close" data-dismiss="alert" type="button">
<span aria-hidden="true"><i class="fa fa-close"></i> </span>
</button>
<strong>{{title}}</strong>{{message}}
</div>
</script>
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/tether/dist/js/tether.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="node_modules/handlebars/dist/handlebars.min.js"></script>
<script src="node_modules/moment/min/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.6.4/showdown.min.js"></script>
<script id="searchbox">
var searchUrl = 'http://npmsearch.com/query';
/* seems unable to talk to elasticsearch */
// var searchUrl = 'http://localhost:8080/query';
var results = jQuery("#results");
//https://davidwalsh.name/javascript-debounce-function
function debounce(func, wait, immediate) {
var timeout;
return function () {
var context = this, args = arguments;
var later = function () {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
}
var parseMarkdown = function (text) {
var markdown = new showdown.Converter();
markdown.setFlavor('github');
return markdown.makeHtml(text);
};
var flashMessage = function (opts) {
var source = jQuery("#result-err-tmpl").html();
var template = Handlebars.compile(source);
var result = template({
level: opts.level || 'warning',
title: opts.title || 'Warning: ',
message: opts.message || "Problem getting results from server detected."
});
results.append(result);
};
var doSearch = function () {
var queryVal = jQuery('#search').val();
debounce(
jQuery.getJSON({
url: searchUrl,
data: {
q: queryVal + '&keywords:embark, embark-plugin',
fields: ['name', 'readme', 'description', 'keywords', 'author', 'times.published', 'homepage', 'version', 'license', '_score'].join(',')
},
error: function (data) {
results.html("");
var opts = {
level: data.status <= 500 ? 'alert-danger' : 'alert-warning',
title: data.status <= 500 ? 'Danger: ' : 'Warning: ',
message: data.responseText
};
flashMessage(opts);
},
success: function (data) {
results.html("");
if (data.total == 0) {
var opts = {
level: 'alert-info',
title: 'No Results',
message: " "
};
return flashMessage(opts)
}
for (var i = 0; data.results.length > i; i++) {
var source = jQuery("#result-tmpl").html();
template = Handlebars.compile(source);
if(data.results[i].readme){
data.results[i].parsedReadme = parseMarkdown(data.results[i].readme[0]);
}
if(data.results[i].description){
data.results[i].parsedDescription = parseMarkdown(data.results[i].description[0]);
}
data.results[i].lastUpdated = moment(data.results[i]['times.published'][0], "YYYYMMDD").fromNow();
result = template(data.results[i]);
results.append(result);
}
}
}), 500);
};
jQuery('#search').on('keyup', doSearch);
</script>
</body>
</html>