Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub pages demo #22

Merged
merged 1 commit into from
May 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"jquery": "^1.11.1",
"loader.js": "ember-cli/loader.js#3.2.0",
"pretender": "0.6.0",
"qunit": "~1.17.1"
"qunit": "~1.17.1",
"Faker": "~2.1.3"
}
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@
"ember-cli-app-version": "0.3.3",
"ember-cli-content-security-policy": "0.4.0",
"ember-cli-dependency-checker": "^1.0.0",
"ember-cli-github-pages": "~0.0.4",
"ember-cli-ic-ajax": "0.1.1",
"ember-cli-inject-live-reload": "^1.3.0",
"ember-cli-pretender": "0.3.2",
"ember-cli-qunit": "0.3.13",
"ember-cli-version-checker": "^1.0.2",
"ember-cli-uglify": "^1.0.1",
"ember-cli-version-checker": "^1.0.2",
"ember-data": "1.0.0-beta.17",
"ember-disable-prototype-extensions": "^1.0.0",
"ember-disable-proxy-controllers": "^0.7.0",
"ember-export-application-global": "^1.0.2",
"ember-disable-prototype-extensions": "^1.0.0",
"ember-faker": "1.1.0",
"ember-try": "0.0.5"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/infinity-route-with-meta-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module('Acceptance: Infinity Route', {
});

test('it works when meta is present in payload', assert => {
visit('/');
visit('/test');
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-pathed the route used for acceptance tests, since there's more value in using the root URL / for humans


andThen(() => {
var postsTitle = find('#posts-title');
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/infinity-route-without-meta-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module('Acceptance: Infinity Route', {
});

test('it works when meta is not present in payload', assert => {
visit('/');
visit('/test');

andThen(() => {
var postsTitle = find('#posts-title');
Expand Down
3 changes: 2 additions & 1 deletion tests/dummy/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ var Router = Ember.Router.extend({
});

Router.map(function() {
this.route('home', { path: '/' });
this.route('demo', {path: '/'});
this.route('home', { path: 'test' });
this.route('category', { path: '/category/:category' });
});

Expand Down
44 changes: 44 additions & 0 deletions tests/dummy/app/routes/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import Ember from 'ember';
import InfinityRoute from 'ember-infinity/mixins/route';
import Pretender from 'pretender';
import faker from 'faker';


function generateFakeData(qty) {
var data = [];
for (var i = 0; i < qty; i++) {
data.push({id: i, name: faker.company.companyName()});
}
return data;
}


export default Ember.Route.extend(InfinityRoute, {
init: function () {
this._super(...arguments);
var fakeData = generateFakeData(104);
this.set('pretender', new Pretender());
this.get('pretender').get('/posts', request => {
var queryParams = request.queryParams;
var fd = fakeData;
var page = parseInt(request.queryParams.page, 10);
var per = parseInt(request.queryParams.per_page, 10);
var payload = {
posts: fd.slice((page - 1) * per, Math.min((page) * per, fd.length)),
meta: {
total_pages: Math.ceil(fd.length/per)
}
};
return [200, {}, JSON.stringify(payload)];

}, 500 /*ms*/);
},

tearDownPretender: Ember.observer('deactivate', function () {
this.set('pretender', undefined);
}),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha this is cool


model() {
return this.infinityModel('post');
}
});
45 changes: 44 additions & 1 deletion tests/dummy/app/styles/app.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,46 @@
ul li {
body {
font-family: 'Arial';
padding: 0;
margin: 0;
width: 100%;
}
.demo-view {
margin-top: 160px;
}

.test-list li {
height: 500px;
}

.text-center {
text-align: center;
}

.fixed-to-top {
position: fixed;
top: 0;
left: 0;
right: 0;
}


.jumbo-header {
color: #fff;
background: purple;
font-size: 36px;
width: 100%;
height: 150px;
box-shadow: 0 15px 15px rgba(0,0,0,0.5);
}

.demo-items {
list-style: none;
}
.demo-items li {
border: 1px solid #999;
margin: 10px;
background: #fff;
box-shadow: 0 0 3px rgba(0,0,0,0.5);
padding: 10px;
width: 90%;
}
2 changes: 0 additions & 2 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
<h2 id="title">Welcome to Ember.js</h2>

{{outlet}}
2 changes: 1 addition & 1 deletion tests/dummy/app/templates/category.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h2 id="posts-title">Listing Posts using Parameters</h2>

<ul>
<ul class="test-list">
{{#each model as |item|}}
<li>{{item.name}}</li>
{{/each}}
Expand Down
16 changes: 16 additions & 0 deletions tests/dummy/app/templates/demo.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="demo-view">

<div class="fixed-to-top jumbo-header text-center">
<a href="https://github.com/hhff/ember-infinity"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/52760788cde945287fbb584134c4cbc2bc36f904/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f77686974655f6666666666662e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png"></a>
<h2 id="title">ember-infinity</h2>
</div>
<ul class="demo-items">
{{#each content as |item|}}
<li>{{item.id}}. {{item.name}}</li>
{{/each}}
{{infinity-loader
infinityModel=content
loadingText="Loading more awesome records..."
loadedText="Loaded all the records!"}}
</ul>
</div>
2 changes: 1 addition & 1 deletion tests/dummy/app/templates/home.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h2 id="posts-title">Listing Posts</h2>

<ul>
<ul class="test-list">
{{#each model as |post|}}
<li>{{post.name}}</li>
{{/each}}
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = function(environment) {
modulePrefix: 'dummy',
environment: environment,
baseURL: '/',
locationType: 'auto',
locationType: 'hash',
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
Expand Down Expand Up @@ -40,7 +40,7 @@ module.exports = function(environment) {
}

if (environment === 'production') {

ENV.baseURL = '/ember-infinity'
}

return ENV;
Expand Down