Skip to content

Commit 4a29d3b

Browse files
committed
wrote more codes
1 parent 4fcce0b commit 4a29d3b

File tree

8 files changed

+69
-48
lines changed

8 files changed

+69
-48
lines changed

Gruntfile.coffee

+8-23
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,11 @@ module.exports = (grunt) ->
1212
'vendor/jquery/jquery.js'
1313
]
1414

15-
coffee:
16-
compile:
17-
files:
18-
'js/all.js': 'coffee/*.coffee'
19-
2015
stylus:
2116
compile:
2217
files:
2318
'css/style.css': 'stylus/style.styl'
2419

25-
clean: ['js/*.js', 'css/*.css', 'build']
26-
2720
watch:
2821
scripts:
2922
files: ['stylus/*.styl', 'coffee/*.coffee', 'templates/*.html']
@@ -42,23 +35,15 @@ module.exports = (grunt) ->
4235
keepalive: true
4336
port: 8002
4437

45-
copy:
38+
browserify:
4639
main:
47-
files: [
48-
expand: true
49-
src: [
50-
# App stuff
51-
'index.html'
52-
'js/**'
53-
'css/**'
54-
55-
# CSS and fonts
56-
'vendor/normalize-css/normalize.css'
57-
]
58-
dest: 'build'
59-
]
40+
options:
41+
browserifyOptions:
42+
extensions: '.coffee'
43+
transform: ['coffeeify']
44+
files:
45+
'js/main.js': 'coffee/main.coffee'
6046

6147
require('load-grunt-tasks')(grunt)
6248

63-
grunt.registerTask 'default', ['stylus']
64-
grunt.registerTask 'build', ['default', 'copy', 'uglify']
49+
grunt.registerTask 'default', ['stylus', 'jst', 'browserify']

bower.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"name": "",
2+
"name": "netvis",
33
"version": "0.0.1",
44
"ignore": [
55
"**/.*",
66
"node_modules",
77
"components"
88
],
99
"dependencies": {
10-
"jquery": "1",
11-
"normalize-css": "2"
10+
"jquery": "2",
11+
"backbone": "~1.1.2"
1212
}
1313
}

coffee/main.coffee

+19-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1-
$ ->
1+
VulnView = require './views/vuln.coffee'
2+
3+
data =
4+
vulnerabilities: [
5+
{
6+
name: 'BadStuff'
7+
description: 'Bad things happen to your computer.'
8+
}
9+
{
10+
name: 'NaughtyCode'
11+
description: 'This perfoms rm -rf /.'
12+
}
13+
]
14+
15+
vulnlist = $('.vulnlist')
16+
17+
for vuln in data.vulnerabilities
18+
view = new VulnView(vuln)
19+
view.render().$el.appendTo(vulnlist)

coffee/views/vuln.coffee

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
VulnView = Backbone.View.extend
22
tagName: 'li'
33

4+
className: 'vuln'
5+
6+
initialize: (data) ->
7+
@data = data
8+
49
render: ->
5-
@$el.html(JST.vuln({
6-
title: "Some title",
7-
description: "A bad thing happens"
8-
}))
10+
@$el.html(JST.vuln(@data))
911

1012
return this
1113

12-
Module.exports = VulnView
14+
module.exports = VulnView

index.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
33

44
<head>
@@ -31,18 +31,18 @@ <h2>Devices</h2>
3131
<h1>Some server</h1>
3232
<div class="vulns">
3333
<h2>Vulnerabilities</h2>
34-
<ul>
35-
<li>
34+
<ul class="vulnlist">
3635

37-
</li>
3836
</ul>
3937
</div>
4038
</div>
4139
</div>
4240

43-
<script src="vendor/jquery/jquery.js"></script>
41+
<script src="vendor/jquery/dist/jquery.js"></script>
42+
<script src="vendor/underscore/underscore.js"></script>
43+
<script src="vendor/backbone/backbone.js"></script>
4444
<script src="js/templates/index.js" charset="utf-8"></script>
45-
<script src="js/all.js" charset="utf-8"></script>
45+
<script src="js/main.js" charset="utf-8"></script>
4646

4747
</body>
4848

package.json

+8-5
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
"version": "0.0.1",
44
"description": "",
55
"main": "js/all.js",
6-
"dependencies": {},
6+
"dependencies": {
7+
"coffeeify": "^1.0.0",
8+
"grunt-browserify": "^3.3.0"
9+
},
710
"devDependencies": {
811
"grunt": "*",
9-
"grunt-contrib-jst": "*",
10-
"grunt-contrib-coffee": "*",
12+
"grunt-contrib-coffee": "^0.12.0",
13+
"grunt-contrib-connect": "*",
14+
"grunt-contrib-jst": "^0.6.0",
1115
"grunt-contrib-stylus": "*",
12-
"grunt-contrib-watch": "*",
13-
"grunt-contrib-connect": "*"
16+
"grunt-contrib-watch": "*"
1417
},
1518
"scripts": {
1619
"test": "echo \"Error: no test specified\" && exit 1"

stylus/style.styl

+17-4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ header
4040
width: 100%
4141
display: block
4242
margin: 0
43+
padding: 5px
44+
45+
h1
46+
margin: 0
47+
48+
ul
49+
padding: 0px
50+
margin: 0px
4351

4452
#main
4553
width: 100%
@@ -57,10 +65,6 @@ header
5765
h2
5866
margin: 20px
5967

60-
ul
61-
padding: 0px
62-
margin: 0px
63-
6468
li
6569
padding: 15px 0px 15px 20px
6670
margin: 0px
@@ -77,4 +81,13 @@ header
7781
padding: 20px
7882
width: 100%
7983

84+
.vuln
85+
padding: 10px
86+
list-style-type: none
87+
border-bottom: 1px solid wet_asphalt
88+
89+
div
90+
padding: 5px
8091

92+
h3
93+
margin: 5px

templates/vuln.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<div class="title"><%= title %></div>
1+
<h3 class="title"><%= name %></h3>
22
<div class="details"><%= description %></div>

0 commit comments

Comments
 (0)