Skip to content

Feature/scastie front page #702

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

Merged
merged 1 commit into from
Jul 18, 2017
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
10 changes: 8 additions & 2 deletions _includes/scastie.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
<div class="wrap">
<div class="heading-line">
<h2><span>Run Scala in your browser</span></h2>
<p class="lead">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer commodo neque eget placerat dapibus. Mauris ullamcorper dui eu pellentesque venenatis. Nam non elit vitae dolor posuere eleifend a facilisis diam</p>
<p class="lead">
Scastie is Scala + SBT in your browser!
You can use any version of Scala, or even alternate backends
such as Dotty, Scala.js, Scala Native, and Typelevel Scala. You can use
any published library. You can save and share Scala programs/builds
with anybody.
</p>
</div>
</div>
<div class="call-to-action action-medium">
Expand All @@ -20,4 +26,4 @@ <h2><span>Run Scala in your browser</span></h2>
</div>
</div>
</div>
</section>
</section>m
Copy link
Member

Choose a reason for hiding this comment

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

Broken

2 changes: 1 addition & 1 deletion _layouts/frontpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ <h3>{{scalaItem.shortTitle}}</h3>
</section>

<!-- Run Scala in your browser -->
<!-- {% include scastie.html %} -->
{% include scastie.html %}

<!-- Courses -->
<section class="courses">
Expand Down
71 changes: 45 additions & 26 deletions resources/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,33 +234,52 @@ $(document).ready(function() {

// Scala in the browser
$(document).ready(function() {
if ($("#scastie-textarea").length) {
var editor = CodeMirror.fromTextArea(document.getElementById("scastie-textarea"), {
lineNumbers: true,
matchBrackets: true,
theme: "monokai",
mode: "text/x-scala",
autoRefresh: true,
fixedGutter: false
});
editor.setSize("100%", ($("#scastie-code-container").height()));

var codeSnippet = "List(\"Hello\", \"World\").mkString(\"\", \", \", \"!\")";
editor.getDoc().setValue(codeSnippet);
editor.refresh();

$('.btn-run').click(function() {
// TODO: Code to connect to the scastie server would be here, what follows is just a simulation for the UI elements:
$('.btn-run').addClass("inactive");
$('.btn-run i').removeClass("fa fa-play").addClass("fa fa-spinner fa-spin");
setTimeout(function() {
var currentCodeSnippet = editor.getDoc().getValue();
console.log("Current code snippet: " + currentCodeSnippet);
$('.btn-run').removeClass("inactive");
$('.btn-run i').removeClass("fa-spinner fa-spin").addClass("fa fa-play");
}, 2000);
})
if ($("#scastie-textarea").length) {
var editor =
CodeMirror.fromTextArea(
document.getElementById("scastie-textarea"),
{
// lineNumbers: false,
matchBrackets: true,
theme: "monokai",
mode: "text/x-scala",
autoRefresh: true,
fixedGutter: false,
extraKeys: {
'Ctrl-Enter': 'run',
'Cmd-Enter': 'run'
}
}
);

editor.setSize("100%", ($("#scastie-code-container").height()));

var codeSnippet = "List(\"Hello\", \"World\").mkString(\"\", \", \", \"!\")";
editor.getDoc().setValue(codeSnippet);
editor.refresh();

function run(){
console.log("run");
// var scastieBaseUrl = "https://scastie.scala-lang.org";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm redeploying scastie, I will force push with the url pointing on the prod server.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, cool. Let me know when it's up, we can test to make sure it's all good, and then we fix this.

var scastieBaseUrl = "http://localhost:9000";

$.ajax(
{
type: "POST",
url: scastieBaseUrl + '/scala-lang',
data: editor.getDoc().getValue(),
success: function(url) {
window.open(scastieBaseUrl + "/" + url);
},
// otherwise it's considered a popup
async: false
}
)
}

$('.btn-run').click(run);
CodeMirror.commands.run = run;
}
});

// OS detection
Expand Down