Visar inlägg med etikett scala js. Visa alla inlägg
Visar inlägg med etikett scala js. Visa alla inlägg

2016-09-01

Scala Stack with Google Flexible Environment

Scala Stack with Google Flexible Environment

(this article is not yet completed)
(updated 2016-11-11)

I've created a few Maven projects based on Google Flexible Environment and Scala backend which produces HTML, CSS and JavaScript without any files (.html, .css, .sass, .less, .js) and without any frontend builder like Gulp or Grunt.

Goal

To produce all frontend from Scala backend utilizing shared code and to be fully tested.

Infographic

Scala servlets creates HTML with CSS and JavaScript.
This is a graphic representation of how it works.
  • All code is written in Scala
  • Code may share
    • Resources
    • Validation
    • Routes
    • Logic
    • Translations and other data
    • Structure of
      • HTML
      • CSS
  • A servlet can read Scala JS source code and compile a JavaScript
    • This includes the shared code
  • A servlet can build HTML with CSS 
  • Other servlets can provide REST API and also use the shared code
  • All code can be unit tested and all code can be tested in the same test
This means that the Scala stack covers both frontend and backend.

Code

There is a repository called Scala Stack at Github. There is one branch for jQuery in development and one branch for Angular which is only started:
*Unfortunately I can't afford Google Compute Engine running 24/7 and was forced to shut them down. If Google Compute Engine would scale from 0 to minimize expense I could start them again.

Examples

I'm currently working on a example using jQuery (in progress) and one using Angular (started).
Note that Scala JS source is placed in webapp, an alternative could be resources



2016-07-12

Google Flexible Environment with Virtual Scala JS Compiler

Google Flexible Environment with Virtual Scala JS Compiler

After several months I managed to translate Scala JS Fiddle to Google Java Flexible Environment 

Goal

To create a project with Scala backend which generates JavaScript in a virtual compiler.

Live Demo

The live demo uses a Scala Servlet to generate HTML (Scala Tags) with a JavaScript. A second Scala Servlet is responding to "/javascript.js" and is using a virtual compiler to compile a String with simple Scala JS code to a JavaScript

Environment

It's a Maven project using Google Flexible "Compat" Environment which includes some App Engine features (not used) and Java 8 with Servlet API 3.1.

Source

Check out my Github