Skip to content
Open
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
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<li class="dropdown dropdown-submenu">
<a tabindex="-1" href="javascript:void(0)">Sync</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="javascript:void(0)" id="item_github_login">Sign in to Github...</a></li>
<li><a class="dropdown-item" href="javascript:void(0)" id="item_github_login">Sign in to GitHub...</a></li>
<li><a class="dropdown-item" href="javascript:void(0)" id="item_github_logout">Log out</a></li>
<hr>
<li><a class="dropdown-item" href="javascript:void(0)" id="item_github_import">Import Project from GitHub...</a></li>
Expand Down
2 changes: 1 addition & 1 deletion presets/markdown/hello.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ of text
If you DO want to add soft line breaks (which translate to `<br>` in HTML) to a paragraph,
you can do so by adding 3 space characters to the end of the line (` `).

You can also force every line break in paragraphs to translate to `<br>` (as Github does) by
You can also force every line break in paragraphs to translate to `<br>` (as GitHub does) by
enabling the option **`simpleLineBreaks`**.

## Headings
Expand Down
64 changes: 32 additions & 32 deletions src/ide/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,39 +200,39 @@ export class GithubService {
// load README
return sess.repo.contents('README.md').read();
})
.catch( (e) => {
console.log(e);
console.log('no README.md found')
// make user repo exists
return sess.repo.fetch().then( (_repo) => {
return ''; // empty README
.catch((e) => {
console.log(e);
console.log('no README.md found')
// make user repo exists
return sess.repo.fetch().then((_repo) => {
return ''; // empty README
})
})
})
.then( (readme) => {
var m;
// check README for main file
const re8main = /8bitworkshop.com[^)]+file=([^)&]+)/;
m = re8main.exec(readme);
if (m && m[1]) {
console.log("main path: '" + m[1] + "'");
sess.mainPath = m[1];
}
// check README for proper platform
// unless we use githubURL=
// TODO: cannot handle multiple URLs in README
const re8plat = /8bitworkshop.com[^)]+platform=([A-Za-z0-9._\-]+)/;
m = re8plat.exec(readme);
if (m) {
console.log("platform id: '" + m[1] + "'");
if (sess.platform_id && !sess.platform_id.startsWith(m[1]))
throw Error("Platform mismatch: Repository is " + m[1] + ", you have " + sess.platform_id + " selected.");
sess.platform_id = m[1];
}
// bind to repository
this.bind(sess, true);
// get head commit
return sess;
});
.then((readme) => {
var m;
// check README for main file
const re8main = /8bitworkshop.com[^)]+file=([^)&]+)/;
m = re8main.exec(readme);
if (m && m[1]) {
console.log("main path: '" + m[1] + "'");
sess.mainPath = m[1];
}
// check README for proper platform
// unless we use githubURL=
// TODO: cannot handle multiple URLs in README
const re8plat = /8bitworkshop.com[^)]+platform=([A-Za-z0-9._\-]+)/;
m = re8plat.exec(readme);
if (m) {
console.log("platform id: '" + m[1] + "'");
if (sess.platform_id && !sess.platform_id.startsWith(m[1]))
throw Error("Platform mismatch: Repository is '" + m[1] + "', you have '" + sess.platform_id + "' selected.");
sess.platform_id = m[1];
}
// bind to repository
this.bind(sess, true);
// get head commit
return sess;
});
}

pull(ghurl:string, deststore?) : Promise<GHSession> {
Expand Down
14 changes: 9 additions & 5 deletions src/ide/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function importProjectFromGithub(githuburl: string, replaceURL: boo
var sess: GHSession;
var urlparse = parseGithubURL(githuburl);
if (!urlparse) {
alertError('Could not parse Github URL.');
alertError('Could not parse GitHub URL.');
return;
}
// redirect to repo if exists
Expand All @@ -70,14 +70,14 @@ export async function importProjectFromGithub(githuburl: string, replaceURL: boo
}).catch((e) => {
setWaitDialog(false);
console.log(e);
alertError("Could not import " + githuburl + "." + e);
alertError("Could not import " + githuburl + ". " + e);
});
}

export async function _loginToGithub(e) {
var gh = await getGithubService();
gh.login().then(() => {
alertInfo("You are signed in to Github.");
alertInfo("You are signed in to GitHub.");
}).catch((e) => {
alertError("Could not sign in." + e);
});
Expand All @@ -86,14 +86,18 @@ export async function _loginToGithub(e) {
export async function _logoutOfGithub(e) {
var gh = await getGithubService();
gh.logout().then(() => {
alertInfo("You are logged out of Github.");
alertInfo("You are logged out of GitHub.");
});
}

export function _importProjectFromGithub(e) {
var modal = $("#importGithubModal");
var btn = $("#importGithubButton");
modal.modal('show');
modal.off('shown.bs.modal').on('shown.bs.modal', () => $("#importGithubURL").trigger('focus'));
$("#importGithubURL").off('keydown').on('keydown', (e) => {
if (e.key === 'Enter') { e.preventDefault(); btn.trigger('click'); }
});
btn.off('click').on('click', () => {
var githuburl = $("#importGithubURL").val() + "";
modal.modal('hide');
Expand All @@ -103,7 +107,7 @@ export function _importProjectFromGithub(e) {

export function _publishProjectToGithub(e) {
if (repo_id) {
if (!confirm("This project (" + getCurrentProject().mainPath + ") is already bound to a Github repository. Do you want to re-publish to a new repository? (You can instead choose 'Push Changes' to update files in the existing repository.)"))
if (!confirm("This project (" + getCurrentProject().mainPath + ") is already bound to a GitHub repository. Do you want to re-publish to a new repository? (You can instead choose 'Push Changes' to update files in the existing repository.)"))
return;
}
var modal = $("#publishGithubModal");
Expand Down
24 changes: 12 additions & 12 deletions test/services/testgithub.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const t0 = new Date().getTime();

describe('Github', function() {

it('Should import from Github (check README)', function(done) {
it('Should import from GitHub (check README)', function(done) {
var store = createNewPersistentStore('vcs', function(store) {
var gh = newGH(store, 'vcs');
gh.importAndPull('https://github.com/pzpinfo/test123123/').then( (sess) => {
Expand All @@ -52,7 +52,7 @@ describe('Github', function() {
});
});

it('Should import from Github (default branch)', function(done) {
it('Should import from GitHub (default branch)', function(done) {
var store = createNewPersistentStore('nes', function(store) {
var gh = newGH(store, 'nes');
gh.importAndPull('https://github.com/sehugg/mdf2020-nes').then( (sess) => {
Expand All @@ -62,7 +62,7 @@ describe('Github', function() {
});
});

it('Should import from Github (explicit branch)', function(done) {
it('Should import from GitHub (explicit branch)', function(done) {
var store = createNewPersistentStore('nes', function(store) {
var gh = newGH(store, 'nes');
gh.importAndPull('https://github.com/sehugg/mdf2020-nes/tree/main').then( (sess) => {
Expand All @@ -72,7 +72,7 @@ describe('Github', function() {
});
});

it('Should import from Github (binary files)', function(done) {
it('Should import from GitHub (binary files)', function(done) {
var store = createNewPersistentStore('vcs', function(store) {
var gh = newGH(store, 'vcs');
gh.importAndPull('https://github.com/pzpinfo/testrepo3').then( (sess) => {
Expand All @@ -88,7 +88,7 @@ describe('Github', function() {
});
});

it('Should import from Github (wrong platform)', function(done) {
it('Should import from GitHub (wrong platform)', function(done) {
var store = createNewPersistentStore('_FOO', function(store) {
var gh = newGH(store, '_FOO');
gh.importAndPull('https://github.com/pzpinfo/testrepo1557326056720').catch( (e) => {
Expand All @@ -98,7 +98,7 @@ describe('Github', function() {
});
});

it('Should import from Github (invalid URL)', function(done) {
it('Should import from GitHub (invalid URL)', function(done) {
var store = createNewPersistentStore('_FOO', function(store) {
var gh = newGH(store, '_FOO');
gh.importAndPull('https://github.com/pzpinfo/NOEXISTSREPO').catch( (e) => {
Expand All @@ -109,7 +109,7 @@ describe('Github', function() {
});
});

it('Should import from Github (subdirectory tree)', function(done) {
it('Should import from GitHub (subdirectory tree)', function(done) {
var store = createNewPersistentStore('nes', function(store) {
var gh = newGH(store, 'nes');
gh.importAndPull('https://github.com/brovador/NESnake/tree/master/src').then( (sess) => {
Expand All @@ -120,7 +120,7 @@ describe('Github', function() {
});
});

it('Should publish (fail) on Github', function(done) {
it('Should publish (fail) on GitHub', function(done) {
var store = createNewPersistentStore(test_platform_id, function(store) {
var gh = newGH(store);
// should fail
Expand All @@ -130,7 +130,7 @@ describe('Github', function() {
});
});

it('Should publish new repository on Github', function(done) {
it('Should publish new repository on GitHub', function(done) {
var store = createNewPersistentStore(test_platform_id, function(store) {
var gh = newGH(store);
var reponame = 'testrepo'+t0;
Expand All @@ -144,7 +144,7 @@ describe('Github', function() {
});
});

it('Should commit/push to Github', function(done) {
it('Should commit/push to GitHub', function(done) {
var store = createNewPersistentStore(test_platform_id, function(store) {
var gh = newGH(store);
var binfile = new Uint8Array(256);
Expand All @@ -164,7 +164,7 @@ describe('Github', function() {
});
});

it('Should commit/push to Github (subdirectory tree)', function(done) {
it('Should commit/push to GitHub (subdirectory tree)', function(done) {
var store = createNewPersistentStore(test_platform_id, function(store) {
var gh = newGH(store);
var files = [
Expand All @@ -182,7 +182,7 @@ describe('Github', function() {
});
});

it('Should bind paths to Github', function(done) {
it('Should bind paths to GitHub', function(done) {
var store = createNewPersistentStore(test_platform_id, function(store) {
var gh = newGH(store);
var sess = {repopath:'foo/bar', url:'_', platform_id:'vcs',mainPath:'test.c'};
Expand Down
2 changes: 1 addition & 1 deletion test/web/testimport.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ try {
console.log('warning: need ./github.json with {token:"..."}')
}

exports['test import Github'] = async function (browser) {
exports['test import GitHub'] = async function (browser) {

await browser.url(`${IDEURL}?${QS_GITHUBURL}`)
.waitForElementNotPresent('#step-0')
Expand Down
Loading