Skip to content
This repository was archived by the owner on Nov 27, 2022. It is now read-only.

Commit 2fbda6b

Browse files
committed
Added: categories filter
1 parent bb76826 commit 2fbda6b

File tree

4 files changed

+82
-32
lines changed

4 files changed

+82
-32
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
.DS_Store
22
log/**/*
3+
tmp
34
tmp/**/*
45
bin/*
6+
vendor
57
vendor/gems/*
68
!vendor/gems/cache/
79
.sass-cache/*

app/controllers/jenkins_plugins.rb

+24-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,34 @@
55
get :show, :map => '/' do
66
json = ''
77
open('http://mirror.xmission.com/jenkins/updates/update-center.json') do |f|
8+
#open(File.dirname(__FILE__) + '/../../tmp/update-center.json') do |f|
89
json = f.read
910
end
1011
json = json.sub('updateCenter.post(', '').sub(/\);$/, '')
1112
@plugins = JSON.parse(json)
13+
@categories = [
14+
"scm",
15+
"misc",
16+
"notifier",
17+
"listview-column",
18+
"builder",
19+
"user",
20+
"ui",
21+
"report",
22+
"maven",
23+
"buildwrapper",
24+
"post-build",
25+
"upload",
26+
"external",
27+
"trigger",
28+
"page-decorator",
29+
"slaves",
30+
"scm-related",
31+
"cluster",
32+
"cli",
33+
"envfile",
34+
"must-be-labeled"
35+
]
1236
render 'jenkins_plugins/show'
1337
end
14-
1538
end

app/views/jenkins_plugins/show.haml

+32-24
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
1-
%header
2-
.container
3-
.row
4-
.span2.logo
5-
= image_tag('icon.png')
6-
.span14
7-
%h1
8-
Jenkins Plugin Hub
9-
%p.lead
10-
This site is a hub site for Jekins plugins. This site provides you Jenkins plugins quick search and RSS feed.
11-
%br
12-
Now
13-
= @plugins['plugins'].size
14-
plugins are available.
15-
161
.container
172
.row
18-
%table.zebra-striped
19-
%tr
20-
%th Name
21-
%th Version
22-
%th Release
23-
%th Description
24-
- @plugins['plugins'].each do |key, plugin|
3+
%ul#filter.pills{:style => 'margin-bottom:0'}
4+
%li.active= link_to "All", "#"
5+
- @categories.each do |category|
6+
%li= link_to category, "?category=#{category}"
7+
.row
8+
%table#table.zebra-striped
9+
%thead
2510
%tr
11+
%th Name
12+
%th Version
13+
%th Release
14+
%th Description
15+
%tbody
16+
- @plugins['plugins'].each do |key, plugin|
17+
%tr{:class => (plugin['labels']||[]).join(' ')}
2618
%td.name= link_to(key, plugin['wiki'])
2719
%td.version= plugin['version']
2820
%td.release= plugin['releaseTimestamp']
2921
%td.discription= plugin['excerpt']
3022

31-
.container
32-
%footer Copyright (C) 2011 codefirst.org. All rights reserved.
23+
:javascript
24+
$(function() {
25+
var filter = function(category) {
26+
$('#table tbody tr').each(function() {
27+
if (category == 'All' || $(this).hasClass(category)) {
28+
$(this).show();
29+
} else {
30+
$(this).hide();
31+
}
32+
});
33+
}
34+
$('#filter li').bind("click", function(e) {
35+
$('#filter li').removeClass("active");
36+
$(e.target).parent().addClass("active");
37+
filter(e.target.text);
38+
return false;
39+
});
40+
});

app/views/layouts/application.haml

+24-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
!!! Strict
22
%html
3-
%head
4-
%title= [@title, "Jenkins Plugin Hub"].compact.join(" | ")
5-
= stylesheet_link_tag 'bootstrap.min', 'application'
6-
= yield_content :include
7-
= javascript_include_tag 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js'
8-
%body
9-
= yield
3+
%head
4+
%title= [@title, "Jenkins Plugin Hub"].compact.join(" | ")
5+
= stylesheet_link_tag 'bootstrap.min', 'application'
6+
= yield_content :include
7+
= javascript_include_tag 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js'
8+
%body
9+
%header
10+
.container
11+
.row
12+
.span2.logo
13+
= image_tag('icon.png')
14+
.span14
15+
%h1
16+
Jenkins Plugin Hub
17+
%p.lead
18+
This site is a hub site for Jekins plugins. This site provides you Jenkins plugins quick search and RSS feed.
19+
%br
20+
Now
21+
= @plugins['plugins'].size
22+
plugins are available.
23+
= yield
24+
.container
25+
%footer Copyright (C) 2011 codefirst.org. All rights reserved.
26+

0 commit comments

Comments
 (0)