Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
xst-praya committed Mar 26, 2018
1 parent f6c3406 commit 3ad73c9
Show file tree
Hide file tree
Showing 34 changed files with 3,330 additions and 106 deletions.
11 changes: 11 additions & 0 deletions blueprints/pace/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var RSVP = require('rsvp');

module.exports = {
normalizeEntityName: function() {},

afterInstall: function() {
return RSVP.all([
this.addPackageToProject('pace-progress'),
]);
}
};
100 changes: 99 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,103 @@
/* jshint node: true */
'use strict';

var fs = require('fs');
var path = require('path');
var UglifyJS = require("uglify-js");
var PACE_DIR = 'pace-progress';

var _paceConfig = {};
var _defaultPaceConfig = {
color: 'blue',
theme: 'minimal',
catchupTime: 50,
initialRate: 0.01,
minTime: 100,
ghostTime: 50,
maxProgressPerFrame: 20,
easeFactor: 1.25,
startOnPageLoad: true,
restartOnPushState: true,
restartOnRequestAfter: 500,
target: 'body',
elements: {
checkInterval: 100,
selectors: ['body', '.ember-view']
},
eventLag: {
minSamples: 10,
sampleCount: 3,
lagThreshold: 3
},
ajax: {
trackMethods: ['GET', 'POST', 'DELETE', 'OPTIONS'],
trackWebSockets: true,
ignoreURLs: []
}
};


module.exports = {
name: 'ember-cli-pace'
name: 'ember-cli-pace',

config: function (environment, baseConfig) {
if ('pace' in baseConfig) {
if (!baseConfig.pace) {
_paceConfig = false;
} else {
Object.keys(_defaultPaceConfig).forEach(function (key) {
_paceConfig[key] = baseConfig.pace.hasOwnProperty(key) ? baseConfig.pace[key] : _defaultPaceConfig[key];
});
}
} else {
_paceConfig = _defaultPaceConfig;
}

if (environment === 'development') {
return {
pace: _paceConfig,
contentSecurityPolicy: {
'script-src': "'self' 'unsafe-eval' 'unsafe-inline'"
}
};
}

return {
pace: _paceConfig
};
},

treeFor: function (name) {
if (_paceConfig && name === 'styles') {
var paceThemeName = path.join(_paceConfig.color, 'pace-theme-' + _paceConfig.theme + '.css'),
originalPaceThemePath = path.join('node_modules', PACE_DIR, 'themes', paceThemeName),
addonPaceThemePath = path.join('vendor', 'ember-cli-pace', 'themes', paceThemeName);

if (fs.existsSync(originalPaceThemePath)) {
this.app.import(originalPaceThemePath);
} else if (fs.existsSync(addonPaceThemePath)) {
this.app.import(addonPaceThemePath);
} else {
throw new Error('Pace theme CSS file was not found: ' + paceThemeName);
}
}
},

contentFor: function (name) {
if (_paceConfig && name === 'head') {
var paceScriptPath = path.join('node_modules', PACE_DIR, 'pace.js'),
addonScriptPath = path.resolve(__dirname, 'vendor', 'ember-cli-pace', 'script-loader.js'),
paceScript, addonScript;

if (this.app.env === 'production') {
paceScript = UglifyJS.minify(paceScriptPath).code;
addonScript = UglifyJS.minify(addonScriptPath).code;
} else {
paceScript = fs.readFileSync(paceScriptPath, 'utf8');
addonScript = fs.readFileSync(addonScriptPath, 'utf8');
}

return '<script type="text/javascript" data-pace-options=\'' + JSON.stringify(_paceConfig) + '\'>' + paceScript + ';\n' + addonScript + '</script>';
}
}
};
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-cli-pace",
"version": "0.0.0",
"name": "ember-cli-pace-gs",
"version": "1.1.4",
"description": "The default blueprint for ember-cli addons.",
"keywords": [
"ember-addon"
Expand All @@ -19,7 +19,9 @@
"test": "ember try:each"
},
"dependencies": {
"ember-cli-babel": "^6.6.0"
"ember-cli-babel": "^6.6.0",
"jquery": "^3.3.1",
"pace-progress": "^1.0.2"
},
"devDependencies": {
"broccoli-asset-rev": "^2.4.5",
Expand Down
51 changes: 51 additions & 0 deletions tests/.jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"predef": [
"document",
"window",
"location",
"setTimeout",
"$",
"-Promise",
"define",
"console",
"visit",
"exists",
"fillIn",
"click",
"keyEvent",
"triggerEvent",
"find",
"findWithAssert",
"wait",
"DS",
"andThen",
"currentURL",
"currentPath",
"currentRouteName"
],
"node": false,
"browser": false,
"boss": true,
"curly": false,
"debug": false,
"devel": false,
"eqeqeq": true,
"evil": true,
"forin": false,
"immed": false,
"laxbreak": false,
"newcap": true,
"noarg": true,
"noempty": false,
"nonew": false,
"nomen": false,
"onevar": false,
"plusplus": false,
"regexp": false,
"undef": true,
"sub": true,
"strict": false,
"white": false,
"eqnull": true,
"esnext": true
}
12 changes: 7 additions & 5 deletions tests/dummy/app/app.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import Application from '@ember/application';
import Resolver from './resolver';
import loadInitializers from 'ember-load-initializers';
import Ember from 'ember';
import Resolver from 'ember/resolver';
import loadInitializers from 'ember/load-initializers';
import config from './config/environment';

const App = Application.extend({
Ember.MODEL_FACTORY_INJECTIONS = true;

var App = Ember.Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver
Resolver: Resolver
});

loadInitializers(App, config.modulePrefix);
Expand Down
22 changes: 22 additions & 0 deletions tests/dummy/app/controllers/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Ember from 'ember';

export default Ember.Controller.extend(Ember.PromiseProxyMixin, {
page: 0,

actions: {
load: function () {
var promise = $.ajax({
url: "https://andruxnet-random-famous-quotes.p.mashape.com/cat=movies",
type: 'post',
dataType: 'json',
headers: {
"X-Mashape-Key": "NmMfD3pY9dmshv8ZpOelB8xlmiOPp1JDlGtjsnwdRZKZ1cLgJn",
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json"
}
});

this.set('promise', promise);
}
}
});
20 changes: 11 additions & 9 deletions tests/dummy/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Dummy</title>
<title>Ember Pace.js Demo</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

{{content-for "head"}}
{{content-for 'head'}}

<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/dummy.css">
<link rel="stylesheet" href="assets/vendor.css">
<link rel="stylesheet" href="assets/dummy.css">

{{content-for "head-footer"}}
{{content-for 'head-footer'}}
</head>
<body>
{{content-for "body"}}
<a href="https://github.com/vectart/ember-cli-pace"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>

<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/dummy.js"></script>
{{content-for 'body'}}

{{content-for "body-footer"}}
<script pace-src="assets/vendor.js"></script>
<script pace-src="assets/dummy.js"></script>

{{content-for 'body-footer'}}
</body>
</html>
3 changes: 0 additions & 3 deletions tests/dummy/app/resolver.js

This file was deleted.

11 changes: 4 additions & 7 deletions tests/dummy/app/router.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import EmberRouter from '@ember/routing/router';
import Ember from 'ember';
import config from './config/environment';

const Router = EmberRouter.extend({
location: config.locationType,
rootURL: config.rootURL
var Router = Ember.Router.extend({
location: config.locationType
});

Router.map(function() {
export default Router.map(function() {
});

export default Router;
32 changes: 32 additions & 0 deletions tests/dummy/app/styles/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
html,
body {
font-family: "Helvetica Neue", Arial, sans-serif;
}

article {
padding: 40px;
}

button {
background: black;
color: white;
border: 0 none;
padding: 12px 20px;
border-radius: 5px;
font: inherit;
font-weight: bold;
cursor: pointer;
outline: 0 none;
}

blockquote {
border-left: 2px solid;
margin: 30px 0;
padding-left: 20px;
}

blockquote i {
display: block;
margin-top: 10px;
font-family: serif;
}
16 changes: 14 additions & 2 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
<h2 id="title">Welcome to Ember</h2>
<article>
<h2>Welcome to Ember Pace.js Demo</h2>

{{outlet}}
<p>
<button {{action 'load'}}>Load Quote</button>
</p>

{{#if isFulfilled}}
<blockquote>
{{model.quote}}
<i>{{model.author}}</i>
</blockquote>
{{/if}}

</article>
File renamed without changes.
20 changes: 10 additions & 10 deletions tests/dummy/config/environment.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
'use strict';
/* jshint node: true */

module.exports = function(environment) {
let ENV = {
var ENV = {
modulePrefix: 'dummy',
environment,
environment: environment,
rootURL: '/',
locationType: 'auto',
locationType: 'none',
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. 'with-controller': true
},
EXTEND_PROTOTYPES: {
// Prevent Ember Data from overriding Date.parse.
Date: false
}
},

APP: {
// Here you can pass flags/options to your application instance
// when it is created
},

pace: {
color: 'black'
}
};

Expand All @@ -33,18 +33,18 @@ module.exports = function(environment) {

if (environment === 'test') {
// Testem prefers this...
ENV.rootURL = '/';
ENV.locationType = 'none';

// keep test console output quieter
ENV.APP.LOG_ACTIVE_GENERATION = false;
ENV.APP.LOG_VIEW_LOOKUPS = false;

ENV.APP.rootElement = '#ember-testing';
ENV.APP.autoboot = false;
}

if (environment === 'production') {
// here you can enable a production-specific feature

}

return ENV;
Expand Down
Loading

0 comments on commit 3ad73c9

Please sign in to comment.