-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
Ability to load a previous revision of a gist #340
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import ApplicationAdapter from './application'; | ||
|
||
export default ApplicationAdapter.extend({ | ||
urlForQuery: function(query) { | ||
const host = this.host || ""; | ||
return `${host}/gists/${query.gistId}/${query.revId}`; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import GistEditRoute from "../route"; | ||
|
||
export default GistEditRoute.extend({ | ||
|
||
controllerName: 'gist', | ||
templateName: 'gist', | ||
|
||
model(params) { | ||
this.get('store').unloadAll('gistFile'); | ||
const gistParams = this.paramsFor('gist.edit'); | ||
|
||
return this.get('store').query('gist-revision', { | ||
gistId: gistParams.gistId, | ||
revId: params.revId | ||
}).then((response) => { | ||
return response.get('firstObject'); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/** | ||
* This is a factory definition for a gist revision. | ||
*/ | ||
import GistFactory from './gist'; | ||
|
||
export default GistFactory.extend({ | ||
url() { | ||
return `https://api.github.com/gists/${this.id}/${this.revId}`; | ||
} | ||
}); | ||
|
||
/* Sample | ||
{ | ||
"url": "https://api.github.com/gists/a9d365962ab98c2e12cd/3421e6dde701325b5da67ba06dc150b7ad7e0547", | ||
"forks_url": "https://api.github.com/gists/a9d365962ab98c2e12cd/forks", | ||
"commits_url": "https://api.github.com/gists/a9d365962ab98c2e12cd/commits", | ||
"id": "a9d365962ab98c2e12cd", | ||
"git_pull_url": "https://gist.github.com/a9d365962ab98c2e12cd.git", | ||
"git_push_url": "https://gist.github.com/a9d365962ab98c2e12cd.git", | ||
"html_url": "https://gist.github.com/a9d365962ab98c2e12cd", | ||
"files": { | ||
"application.controller.js": { | ||
"filename": "application.controller.js", | ||
"type": "application/javascript", | ||
"language": "JavaScript", | ||
"raw_url": "https://gist.githubusercontent.com/Gaurav0/a9d365962ab98c2e12cd/raw/a5591f634f02783af0de26c2a0799e2a6c2deb1d/application.controller.js", | ||
"size": 247, | ||
"truncated": false, | ||
"content": "import Ember from 'ember';\nimport JsonProxy from '../json-proxy';\n\nexport default Ember.Controller.extend({\n appName: 'Ember Twiddle',\n \n init(...args) {\n this._super(...args);\n this.set('somevar', JsonProxy.build([1, 2, 3]));\n\t}\n});\n" | ||
}, | ||
"application.template.hbs": { | ||
"filename": "application.template.hbs", | ||
"type": "text/plain", | ||
"language": "Handlebars", | ||
"raw_url": "https://gist.githubusercontent.com/Gaurav0/a9d365962ab98c2e12cd/raw/95de1498ec47fced63bb38e5a2ec69ef9f1620a5/application.template.hbs", | ||
"size": 108, | ||
"truncated": false, | ||
"content": "<h1>Welcome to {{appName}}</h1>\n<br>\n<ul>\n{{#each somevar as |num|}}\n <li>{{num}}</li>\n{{/each}}\n</ul>\n<br>" | ||
}, | ||
"json-proxy.js": { | ||
"filename": "json-proxy.js", | ||
"type": "application/javascript", | ||
"language": "JavaScript", | ||
"raw_url": "https://gist.githubusercontent.com/Gaurav0/a9d365962ab98c2e12cd/raw/7f218e6a2788227292b99fca84772fb4885a3287/json-proxy.js", | ||
"size": 188, | ||
"truncated": false, | ||
"content": "import Ember from \"ember\";\n\nvar JsonProxy = Ember.ArrayProxy.extend({});\nJsonProxy.build = function(ary) {\n return Ember.ArrayProxy.create({ content: ary });\n};\n\nexport default JsonProxy;" | ||
}, | ||
"twiddle.json": { | ||
"filename": "twiddle.json", | ||
"type": "application/json", | ||
"language": "JSON", | ||
"raw_url": "https://gist.githubusercontent.com/Gaurav0/a9d365962ab98c2e12cd/raw/87a00ec9acd16432438a70288db99b87371a9aeb/twiddle.json", | ||
"size": 511, | ||
"truncated": false, | ||
"content": "{\n \"version\": \"0.6.0\",\n \"EmberENV\": {\n \"FEATURES\": {}\n },\n \"options\": {\n \"enable-testing\": false\n },\n \"dependencies\": {\n \"jquery\": \"https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js\",\n \"ember\": \"https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.3.1/ember.debug.js\",\n \"ember-data\": \"https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.3.3/ember-data.js\",\n \"ember-template-compiler\": \"https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js\"\n }\n}\n" | ||
} | ||
}, | ||
"public": true, | ||
"created_at": "2016-02-25T22:26:03Z", | ||
"updated_at": "2016-02-25T22:28:29Z", | ||
"description": "JsonProxy", | ||
"comments": 0, | ||
"user": null, | ||
"comments_url": "https://api.github.com/gists/a9d365962ab98c2e12cd/comments", | ||
"owner": { | ||
"login": "Gaurav0", | ||
"id": 313960, | ||
"avatar_url": "https://avatars.githubusercontent.com/u/313960?v=3", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/Gaurav0", | ||
"html_url": "https://github.com/Gaurav0", | ||
"followers_url": "https://api.github.com/users/Gaurav0/followers", | ||
"following_url": "https://api.github.com/users/Gaurav0/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/Gaurav0/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/Gaurav0/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/Gaurav0/subscriptions", | ||
"organizations_url": "https://api.github.com/users/Gaurav0/orgs", | ||
"repos_url": "https://api.github.com/users/Gaurav0/repos", | ||
"events_url": "https://api.github.com/users/Gaurav0/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/Gaurav0/received_events", | ||
"type": "User", | ||
"site_admin": false | ||
}, | ||
"forks": [ | ||
|
||
], | ||
"history": [ | ||
{ | ||
"user": { | ||
"login": "Gaurav0", | ||
"id": 313960, | ||
"avatar_url": "https://avatars.githubusercontent.com/u/313960?v=3", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/Gaurav0", | ||
"html_url": "https://github.com/Gaurav0", | ||
"followers_url": "https://api.github.com/users/Gaurav0/followers", | ||
"following_url": "https://api.github.com/users/Gaurav0/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/Gaurav0/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/Gaurav0/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/Gaurav0/subscriptions", | ||
"organizations_url": "https://api.github.com/users/Gaurav0/orgs", | ||
"repos_url": "https://api.github.com/users/Gaurav0/repos", | ||
"events_url": "https://api.github.com/users/Gaurav0/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/Gaurav0/received_events", | ||
"type": "User", | ||
"site_admin": false | ||
}, | ||
"version": "3421e6dde701325b5da67ba06dc150b7ad7e0547", | ||
"committed_at": "2016-02-25T22:26:03Z", | ||
"change_status": { | ||
"total": 42, | ||
"additions": 42, | ||
"deletions": 0 | ||
}, | ||
"url": "https://api.github.com/gists/a9d365962ab98c2e12cd/3421e6dde701325b5da67ba06dc150b7ad7e0547" | ||
} | ||
], | ||
"truncated": false | ||
} | ||
|
||
*/ | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1 @@ | ||
import DS from 'ember-data'; | ||
|
||
export default DS.Model.extend({ | ||
committedAt: DS.attr('date'), | ||
shortId: DS.attr('string') | ||
}); | ||
export { default } from "./gist"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import GistSerializer from "./gist"; | ||
|
||
export default GistSerializer.extend({ | ||
normalizeQueryResponse: function(store, primaryModelClass, payload, id, requestType) { | ||
return this._super(store, primaryModelClass, [payload], id, requestType); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Ember from 'ember'; | ||
import { module, test } from 'qunit'; | ||
import startApp from 'ember-twiddle/tests/helpers/start-app'; | ||
|
||
module('Acceptance | gist-revision', { | ||
beforeEach: function() { | ||
this.application = startApp(); | ||
}, | ||
|
||
afterEach: function() { | ||
Ember.run(this.application, 'destroy'); | ||
} | ||
}); | ||
|
||
test('Able to load a previous revision of a gist', function(assert) { | ||
|
||
const files = [ | ||
{ | ||
filename: "application.template.hbs", | ||
content: "Hello, World!" | ||
} | ||
]; | ||
|
||
runRevision(files); | ||
|
||
andThen(function() { | ||
const outputDiv = 'div'; | ||
|
||
assert.equal(outputContents(outputDiv), 'Hello, World!', 'Previous version of a gist is displayed'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Ember from "ember"; | ||
import runGist from "./run-gist"; | ||
|
||
const { isArray } = Ember; | ||
|
||
export default function(app, options) { | ||
if (isArray(options)) { | ||
options = {files: options}; | ||
} | ||
|
||
options.type = "revision"; | ||
|
||
return runGist(app, options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiousity, why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm querying for a record using two parameters. Ember Data expects an array back when you query. So I wrap the payload in an array.