added file= to Github URL, added Github login menu options

This commit is contained in:
Steven Hugg 2019-05-22 13:58:44 -04:00
parent 7eb5732273
commit 5193e79b71
3 changed files with 10 additions and 4 deletions

View File

@ -68,6 +68,7 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
<li class="dropdown dropdown-submenu">
<a tabindex="-1" href="#">Sync</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#" id="item_github_login">Sign in to Github...</a></li>
<li><a class="dropdown-item" href="#" id="item_github_import">Import Project from GitHub...</a></li>
<li><a class="dropdown-item" href="#" id="item_github_publish">Publish Project on GitHub...</a></li>
<li><a class="dropdown-item" href="#" id="item_repo_delete">Delete Local Repository...</a></li>
@ -209,7 +210,7 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
<li>
<a class="dropdown-item dropdown-link" target="_book_nes" href="https://www.amazon.com/gp/product/1541021304/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&tag=pzp-20&camp=1789&creative=9325&linkCode=as2&creativeASIN=B01N4DSRIZ&linkId=04d39e274c06e6c93b93d20a9a977111">
<img src="images/book_nes.png"/>
&nbsp;&nbsp;<b>Making Games For The NES</b>
&nbsp;&nbsp;<span class="book-title">Making Games For The NES</span>
</a>
</li>
</ul>

View File

@ -28,7 +28,7 @@ export interface GHSession extends GHRepoMetadata {
paths? : string[];
}
const README_md_template = "$NAME\n=====\n\nCompatible with the [$PLATFORM](http://8bitworkshop.com/redir.html?platform=$PLATFORM&importURL=$GITHUBURL) platform in [8bitworkshop](http://8bitworkshop.com/). Main file is [$MAINFILE]($MAINFILE#mainfile).\n";
const README_md_template = "$NAME\n=====\n\n[Open this project in 8bitworkshop](http://8bitworkshop.com/redir.html?platform=$PLATFORM&importURL=$GITHUBURL&file=$MAINFILE).\n";
export function getRepos() : {[key:string]:GHRepoMetadata} {
return JSON.parse(localStorage.getItem('__repos') || '{}');
@ -166,7 +166,7 @@ export class GithubService {
.then( (readme) => {
var m;
// check README for main file
const re8main = /\(([^)]+)#mainfile\)/;
const re8main = /8bitworkshop.com[^)]+file=([^)&]+)/;
m = re8main.exec(readme);
if (m && m[1]) {
console.log("main path: '" + m[1] + "'");

View File

@ -454,6 +454,10 @@ function importProjectFromGithub(githuburl:string) {
});
}
function _loginToGithub(e) {
getGithubService().login();
}
function _importProjectFromGithub(e) {
var modal = $("#importGithubModal");
var btn = $("#importGithubButton");
@ -854,7 +858,7 @@ function populateRepos(sel) {
if (repos) {
for (let repopath in repos) {
var repo = repos[repopath];
if (getBasePlatform(repo.platform_id) == getBasePlatform(platform_id)) {
if (repo.platform_id && getBasePlatform(repo.platform_id) == getBasePlatform(platform_id)) {
if (n++ == 0)
sel.append($("<option />").text("------ Repositories ------").attr('disabled','true'));
sel.append($("<option />").val(repo.url).text(repo.url.substring(repo.url.indexOf('/'))));
@ -1425,6 +1429,7 @@ function setupDebugControls() {
$(".dropdown-menu").collapse({toggle: false});
$("#item_new_file").click(_createNewFile);
$("#item_upload_file").click(_uploadNewFile);
$("#item_github_login").click(_loginToGithub);
$("#item_github_import").click(_importProjectFromGithub);
$("#item_github_publish").click(_publishProjectToGithub);
$("#item_github_push").click(_pushProjectToGithub);