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

webinterface: fix gist user discovery requests #760

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
24 changes: 17 additions & 7 deletions source/webinterface.d
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class WebInterface
sourceCode = Base64.encode(cast(ubyte[]) sourceCodeRaw);
}
auto googleAnalyticsId = googleAnalyticsId_;
showEditor(sourceCode);
showEditor(sourceCode);
ljmf00 marked this conversation as resolved.
Show resolved Hide resolved
}

@path("/gist/:gist")
Expand All @@ -287,7 +287,17 @@ class WebInterface
string user = "";
auto location = URL(res.headers.get("Location", "https://gist.github.com/run-dlang")).path.bySegment;
if (!location.empty)
user = location.front.name;
{
auto first_loc = location.front.name;
// skip first slash from path
if(first_loc.empty) {
ljmf00 marked this conversation as resolved.
Show resolved Hide resolved
location.popFront;
ljmf00 marked this conversation as resolved.
Show resolved Hide resolved
user = location.front.name;
}
else {
ljmf00 marked this conversation as resolved.
Show resolved Hide resolved
user = first_loc;
}
}

getGist(user, _gist);
}
Expand All @@ -296,14 +306,14 @@ class WebInterface
void getGist(string _user, string _gist)
{
import std.base64;
auto sourceCode = requestHTTP("https://gist.githubusercontent.com/%s/%s/raw".format(_user, _gist))
.bodyReader
.readAllUTF8;
showEditor(Base64.encode(sourceCode.representation));
auto sourceCode = requestHTTP("https://gist.githubusercontent.com/%s/%s/raw".format(_user, _gist))
.bodyReader
.readAllUTF8;
showEditor(Base64.encode(sourceCode.representation));
}

void showEditor(string sourceCode) {
string googleAnalyticsId = googleAnalyticsId_;
string googleAnalyticsId = googleAnalyticsId_;
const title = "Online D Editor";
const chapterId = "";
const language = "en";
Expand Down