Skip to content

Commit

Permalink
Remove jquery from hound
Browse files Browse the repository at this point in the history
  • Loading branch information
twizzyyanki committed Jun 8, 2023
1 parent 93eddc9 commit 9f8b5c5
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 38 deletions.
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
ui/assets/js/JSXTransformer-0.12.2.js
ui/assets/js/jquery-2.1.3.min.js
ui/assets/js/react-0.12.2.min.js
52 changes: 52 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.11.1"
},
"dependencies": {
"merge-anything": "^5.1.7",
"reqwest": "^2.0.5"
}
}
}
1 change: 0 additions & 1 deletion ui/assets/excluded_files.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<div id="root"></div>

<script src="js/react-{{.ReactVersion}}.min.js"></script>
<script src="js/jquery-{{.jQueryVersion}}.min.js"></script>
{{ .Source }}
</body>
</html>
1 change: 0 additions & 1 deletion ui/assets/index.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
var ModelData = {{ .ReposAsJson }};
</script>
<script src="js/react-{{.ReactVersion}}.min.js"></script>
<script src="js/jquery-{{.jQueryVersion}}.min.js"></script>
{{ .Source }}
</body>
</html>
10 changes: 5 additions & 5 deletions ui/assets/js/excluded_files.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {UrlToRepo} from './common';
import reqwest from 'reqwest';

var ExcludedRow = React.createClass({
render: function() {
Expand Down Expand Up @@ -77,9 +78,9 @@ var RepoList = React.createClass({
var FilterableExcludedFiles = React.createClass({
getInitialState: function() {
var _this = this;
$.ajax({
reqwest({
url: 'api/v1/repos',
dataType: 'json',
type: 'json',
success: function(data) {
_this.setState({ repos: data });
},
Expand All @@ -102,11 +103,10 @@ var FilterableExcludedFiles = React.createClass({
searching: true,
repo: this.state.repos[repo],
});
$.ajax({
reqwest({
url: 'api/v1/excludes',
data: {repo: repo},
type: 'GET',
dataType: 'json',
type: 'json',
success: function(data) {
_this.setState({ files: data, searching: false });
},
Expand Down
20 changes: 10 additions & 10 deletions ui/assets/js/hound.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { EscapeRegExp, UrlParts, UrlToRepo } from "./common";
import { Signal } from "./signal";
import reqwest from 'reqwest';
import { merge } from 'merge-anything';

var css = function (el, n, v) {
el.style.setProperty(n, v, "");
Expand Down Expand Up @@ -112,9 +114,9 @@ var Model = {
return;
}

$.ajax({
reqwest({
url: "api/v1/repos",
dataType: "json",
type: "json",
success: function (data) {
_this.repos = data;
next();
Expand All @@ -131,7 +133,7 @@ var Model = {
var _this = this,
startedAt = Date.now();

params = $.extend(
params = merge(
{
stats: "fosho",
repos: "*",
Expand All @@ -157,11 +159,10 @@ var Model = {
return;
}

$.ajax({
reqwest({
url: "api/v1/search",
data: params,
type: "GET",
dataType: "json",
type: "json",
success: function (data) {
if (data.Error) {
_this.didError.raise(_this, data.Error);
Expand Down Expand Up @@ -223,16 +224,15 @@ var Model = {

_this.willLoadMore.raise(this, repo, numLoaded, numNeeded, numToLoad);

var params = $.extend(this.params, {
var params = merge(this.params, {
rng: numLoaded + ":" + endAt,
repos: repo,
});

$.ajax({
reqwest({
url: "api/v1/search",
data: params,
type: "GET",
dataType: "json",
type: "json",
success: function (data) {
if (data.Error) {
_this.didError.raise(_this, data.Error);
Expand Down
4 changes: 0 additions & 4 deletions ui/assets/js/jquery-2.1.3.min.js

This file was deleted.

5 changes: 2 additions & 3 deletions ui/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import "io"

// Current versions of some dependencies.
const (
ReactVersion = "0.12.2"
JQueryVersion = "2.1.3"
ReactVersion = "0.12.2"
)

var contents map[string]*content
Expand All @@ -22,7 +21,7 @@ type renderer interface {
type content struct {

// The uri for accessing this asset
uri string //nolint
uri string //nolint

// The filename of the template relative to the asset directory
template string
Expand Down
22 changes: 10 additions & 12 deletions ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,11 @@ func renderForDev(w io.Writer, root string, c *content, cfg *config.Config, r *h
}

return c.tpl.Execute(w, map[string]interface{}{
"ReactVersion": ReactVersion,
"jQueryVersion": JQueryVersion,
"ReposAsJson": json,
"Title": cfg.Title,
"Source": html_template.HTML(buf.String()),
"Host": r.Host,
"ReactVersion": ReactVersion,
"ReposAsJson": json,
"Title": cfg.Title,
"Source": html_template.HTML(buf.String()),
"Host": r.Host,
})
}

Expand Down Expand Up @@ -156,12 +155,11 @@ func renderForPrd(w io.Writer, c *content, cfg *config.Config, cfgJson string, r
buf.WriteString("</script>")

return c.tpl.Execute(w, map[string]interface{}{
"ReactVersion": ReactVersion,
"jQueryVersion": JQueryVersion,
"ReposAsJson": cfgJson,
"Title": cfg.Title,
"Source": html_template.HTML(buf.String()),
"Host": r.Host,
"ReactVersion": ReactVersion,
"ReposAsJson": cfgJson,
"Title": cfg.Title,
"Source": html_template.HTML(buf.String()),
"Host": r.Host,
})
}

Expand Down

0 comments on commit 9f8b5c5

Please sign in to comment.