-
Notifications
You must be signed in to change notification settings - Fork 64
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
Rough draft for Kazari JS plugin for code decoration #52
Rough draft for Kazari JS plugin for code decoration #52
Conversation
@raulraja @dialelo: @juanpedromoreno and I have added support to use the evaluator-client to establish connection with the remote evaluator. Could you please review? |
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.
Great stuff! I've added some minor suggestions and a couple of questions though.
@@ -38,12 +38,24 @@ lazy val micrositeSettings = Seq( | |||
includeFilter in makeSite := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.js" | "*.swf" | "*.md" | |||
) | |||
|
|||
val circeVersion = "0.5.2" |
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.
This val is not being used. We could remove it.
client.api.evaluates( | ||
dependencies = getDependenciesList(), | ||
resolvers = getResolversList(), | ||
code = snippet.getOrElse("")).exec |
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 would suggest to skip the evaluation if the code snippet is empty.
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.
Switched to a foreach on the option (as it's a side effect really!)
val resolversMetaName = "scala-resolvers" | ||
|
||
@JSExport | ||
def main(): Unit = { } |
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.
Is this method required by ScalaJS?
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.
Yep, it's needed when defining a "JSApp" object, even if it's empty :/
object KazariPlugin extends JSApp with DOMHelper { | ||
val codeExcludeClass = "code-exclude" | ||
lazy val codeSnippets = document.querySelectorAll(s"code.language-scala:not(.$codeExcludeClass)") | ||
val dependenciesMetaName = "scala-dependencies" |
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 would suggest changing these meta-tags for evaluator-dependencies
and evaluator-resolvers
. What do you think?
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.
Agree!
"org.scala-js" %%% "scalajs-dom" % "0.9.0", | ||
"be.doeraene" %%% "scalajs-jquery" % "0.9.0", | ||
"com.lihaoyi" %%% "upickle" % "0.4.1", | ||
"org.scala-exercises" %%% "evaluator-client" % "0.1.0-SNAPSHOT"), |
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.
We could change the evaluator client to 0.1.1-SNAPSHOT
, now that it's available ;)
This PR introduces "Kazari", a Scala.JS-powered plugin that will allow developers to add Scala Exercises-like abilities to their documentations. Basically it will traverse the DOM of any site which includes the generated JS script, decorate any Scala code block by adding an "evaluate" button (which will send requests to our Scala remote evaluator) and also allow live code edition and evaluation.
Right now the plugin just decorates the code with a button to allow calls to the remote evaluator, sending basic requests to the remote evaluator. Refactoring of the network code is also needed, as now it's using JQuery simple Ajax calls. Plans to integrate the remote evaluator client are in motion!
This PR is partly dependant on scala-exercises/evaluator#31, which allows the Scala evaluator to receive CORS calls (like the ones produced by the plugin).
Could you please review @raulraja @dialelo @rafaparadela? Thanks!!