Skip to content

Commit 4bc68b5

Browse files
committed
Initial commit - draft version, designs still need to be applied
0 parents  commit 4bc68b5

20 files changed

+3047
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
.DS_Store
3+
build/
4+
output/
5+

README.md

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# @passmarked/js
2+
3+
[Passmarked](http://passmarked.com) is a suite of tests that can be run against any page/website to identify issues with parity to most online tools in one package.
4+
5+
The [Terminal Client](http://npmjs.org/package/passmarked) is intended for use by developers to integrate into their workflow/CI servers but also integrate into their own application that might need to test websites and provide realtime feedback.
6+
7+
All of the checks on [Passmarked](http://passmarked.com) can be voted on importance and are [open-sourced](http://github.com/passmarked/suite), to encourage community involvement in fixing and adding new rules. We are building the living Web Standard and love any [contributions](#contributing).
8+
9+
## Installing
10+
11+
To install just add the library as part of your HTML:
12+
13+
```
14+
<script src="//cdn.passmarked.com/jsapi/v1.js"></script>
15+
```
16+
17+
The page will now have a global `passmarked` object that can be used
18+
19+
## Widget
20+
21+
The JS API provides a simple to use widget that can be added to any page using a few lines of Javascript code. This widget will allow users to test numerous parts of their site depending on the `mode`, which can be:
22+
23+
* `categories` (default) - Displays the list of categories [Performance](https://passmarked.com/library/performance) / [Compatibility](https://passmarked.com/library/compatibility) / [Content](https://passmarked.com/library/content) / [Security](https://passmarked.com/library/security).
24+
* `rules` - Displays a list of selected rules in a list with a check next to each if found on the target page
25+
* `screenshots` - Displays a list of screenshots of numerous screensize's, to show how a site appears on each of these devices.
26+
*
27+
28+
To use the widget, first make sure the library is loaded in the head or just before the body of the page:
29+
30+
```
31+
<script src="//cdn.passmarked.com/jsapi/v1.js"></script>
32+
```
33+
34+
Then create a div that the widget can use (everything inside this div will be removed when the widget's HTML is inserted:
35+
36+
```
37+
<div id="passmarked-widget"></div>
38+
```
39+
40+
then simply start the actual widget pointing to the defined wrapper block:
41+
42+
```
43+
var widget = passmarked.createWidget({
44+
45+
el: document.querySelector('#passmarked-widget'),
46+
token: '<token-for-passmarked-api>'
47+
48+
});
49+
```
50+
51+
After reloading the page, the widget will now appear be usable.
52+
53+
## Running a report with the API
54+
55+
```
56+
/**
57+
* Create a report
58+
**/
59+
var report = passmarked.create({
60+
61+
url: 'http://example.com',
62+
token: '<token-here>'
63+
64+
});
65+
66+
/**
67+
* Start the report
68+
**/
69+
report.start(function(err, code) {
70+
71+
if(err) {
72+
73+
/** Something with the network went terribly wrong **/
74+
75+
} else if(code) {
76+
77+
/** Validation code returned **/
78+
79+
}
80+
81+
});
82+
83+
/**
84+
* Listen when the report is done
85+
**/
86+
report.on('done', function() {
87+
88+
// get the data
89+
var page = report.getResult();
90+
91+
// output done !
92+
console.log('Page scored ' + page.getScore() + '!');
93+
94+
// get the screenshot
95+
console.log('preview of desktop: ' + page.getPreview('desktop'));
96+
97+
// check if a certain rule is broken
98+
if(page.hasRule('heartbleed')) {
99+
100+
// output that the server is in trouble ...
101+
console.log('Server is vunerable to HeartBleed !');
102+
103+
}
104+
105+
});
106+
```
107+
108+
## Rules
109+
110+
Rules represent checks that occur in this module, all of these rules have a **UID** which can be used to check for specific rules. For the structure and more details see the [Wiki](https://github.com/passmarked/passmarked/wiki) page on [Rules](https://github.com/passmarked/passmarked/wiki/Create).
111+
112+
> Rules also include a `type` which could be `critical`, `error`, `warning` or `notice` giving a better view on the importance of the rule.
113+
114+
See [passmarked.com/library](https://passmarked.com/library) for all the rules.
115+
116+
## Contributing
117+
118+
```bash
119+
git clone git@github.com:passmarked/seo.git
120+
npm install
121+
npm test
122+
```
123+
124+
Pull requests have a prerequisite of passing tests. If your contribution is accepted, it will be merged into `develop` (and then `master` after staging tests by the team) which will then be deployed live to [passmarked.com](http://passmarked.com) and on NPM for everyone to download and test.
125+
126+
## About
127+
128+
To learn more visit:
129+
130+
* [Passmarked](http://passmarked.com)
131+
* [Terminal Client](https://www.npmjs.com/package/passmarked)
132+
* [Slack](http://passmarked.com/chat) - We have a Slack team with all our team and open to anyone using the site to chat and figure out problems. To join head over to [passmarked.com/chat](http://passmarked.com/chat) and request a invite.
133+
134+
## License
135+
136+
Copyright 2016 Passmarked Inc
137+
138+
Licensed under the Apache License, Version 2.0 (the "License");
139+
you may not use this file except in compliance with the License.
140+
You may obtain a copy of the License at
141+
142+
http://www.apache.org/licenses/LICENSE-2.0
143+
144+
Unless required by applicable law or agreed to in writing, software
145+
distributed under the License is distributed on an "AS IS" BASIS,
146+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
147+
See the License for the specific language governing permissions and
148+
limitations under the License.

gulpfile.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
const gulp = require('gulp');
2+
const handlebars = require('gulp-handlebars');
3+
const wrap = require('gulp-wrap');
4+
const declare = require('gulp-declare');
5+
const concat = require('gulp-concat');
6+
const fs = require('fs');
7+
const uglify = require('gulp-uglify');
8+
const watch = require('gulp-watch');
9+
const less = require('gulp-less');
10+
11+
gulp.task('build', function(){
12+
13+
// Build
14+
gulp.src([
15+
16+
'styles/main.less'
17+
18+
])
19+
.pipe(less())
20+
.pipe(concat('style.css'))
21+
.pipe(gulp.dest('./build'))
22+
.on('end', function() {
23+
24+
gulp.src('templates/*.hbs')
25+
.pipe(handlebars())
26+
.pipe(wrap('Handlebars.template(<%= contents %>)'))
27+
.pipe(declare({
28+
29+
namespace: 'templates',
30+
noRedeclare: true, // Avoid duplicate declarations
31+
32+
}))
33+
.pipe(concat('templates.js'))
34+
.pipe(gulp.dest('build/'))
35+
.on('end', function(){
36+
37+
// file to load in
38+
var loadingFiles = [
39+
40+
'./vendor/*.js',
41+
'./build/templates.js',
42+
'./src/api.js',
43+
'./src/events.js',
44+
'./src/issue.js',
45+
'./src/page.js',
46+
'./src/log.js',
47+
'./src/utils.js',
48+
'./src/report.js',
49+
'./src/channel.js',
50+
'./src/widget.js',
51+
'./src/main.js'
52+
53+
];
54+
55+
gulp.src(loadingFiles)
56+
.pipe(concat({ path: 'passmarked.min.js', stat: { mode: 0666 }}))
57+
.pipe(uglify())
58+
.pipe(wrap('/**0.1**/(function(){<%= contents %>})();'))
59+
.pipe(gulp.dest('./output/'));
60+
61+
gulp.src(loadingFiles)
62+
.pipe(concat({ path: 'passmarked.js', stat: { mode: 0666 }}))
63+
.pipe(wrap('/**0.1**/(function(){<%= contents %>})();'))
64+
.pipe(gulp.dest('./output/'));
65+
66+
});
67+
68+
});
69+
70+
});
71+
72+
// watch for dev
73+
gulp.task('watch', function() {
74+
75+
gulp.watch('src/**/**.js', [ 'build' ]);
76+
gulp.watch('templates/*.hbs', [ 'build' ]);
77+
78+
});

package.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"name": "passmarked-js",
3+
"version": "0.0.1",
4+
"description": "Javascript API for the Passmarked Platform",
5+
"homepage": "https://passmarked.com",
6+
"preferGlobal": true,
7+
"engines": {
8+
"node": ">0.12"
9+
},
10+
"bin": {
11+
"passmarked": "index"
12+
},
13+
"scripts": {
14+
},
15+
"author": "Passmarked <info@passmarked.com>",
16+
"keywords": [
17+
"passmarked",
18+
"performance",
19+
"js",
20+
"jsapi",
21+
"javascript",
22+
"pagespeed",
23+
"security",
24+
"compatibility",
25+
"standards"
26+
],
27+
"license": "Apache-2.0",
28+
"dependencies": {},
29+
"repository": {
30+
"type": "git",
31+
"url": "https://github.com/passmarked/js/"
32+
},
33+
"bugs": {
34+
"url": "https://github.com/passmarked/js/issues",
35+
"email": "support@passmarked.com"
36+
},
37+
"devDependencies": {
38+
"chai": "^3.2.0",
39+
"codeclimate-test-reporter": "^0.1.1",
40+
"gulp": "^3.9.1",
41+
"gulp-concat": "^2.6.0",
42+
"gulp-declare": "^0.3.0",
43+
"gulp-handlebars": "^4.0.0",
44+
"gulp-inline-css": "^3.1.0",
45+
"gulp-less": "^3.1.0",
46+
"gulp-uglify": "^2.0.0",
47+
"gulp-watch": "^4.3.10",
48+
"gulp-wrap": "^0.13.0",
49+
"istanbul": "^0.3.18",
50+
"mocha": "^2.2.5",
51+
"nock": "^5.2.1"
52+
}
53+
}

0 commit comments

Comments
 (0)