Git Product home page Git Product logo

take-home's Introduction

take-home

take-home is the world's first open-source project with all parts of the stack written in only Elm. The server-side code is Elm. The stylesheets are Elm. The client-side code is Elm.There's even a branch which shows how the build tools could be in Elm. We went all out to write as much as we could in Elm!

Installation

Requirements

  • Node: 4.1.2
  • Elm: 0.16

How to run

  • Clone the repo
  • npm install
  • ./run_prod.sh

Interesting parts

There's a lot in this project to take in. These are the important parts to look at!

Support summary

In a brief summary, this program has support for the following in Elm

Some extras

  • Moment.js wrapper both client and server side
  • Knox server side
  • Uuid server side
  • Nedb server side
  • StartApp on the server

Framework

While this project provides a good start place for anyone wishing to use full-stack Elm, it does not provide a "do everything" framework like Rails or Django just yet. There is work to make it more like a framework with scripting, but at this time it's not there yet.

How does it work?

The server itself follows the Elm architecture. It uses a modified startapp implementation. This means you have the following core functions

update : Action -> Model -> (Model, Effects Action)
routeIncoming : Connection -> Model -> (Model, Effects Action)

Notice how there's no longer a view. The update function is responsible for updating the model, while the router is responsible for writing replies to the client.

Future work

Create a sensible way of having global footers and headers

At the moment, it's hard to link things in like stylesheets in each view without having a monolithic view function that rendered conditionally. It would be much more ideal to support a way of linking CSS in a header that was somehow included everywhere

Session data

There's no way of storing session data right now.

FAQ

Should I use this in production?

No! This project was an experiment and a proof of concept. A lot of the ideas in this project are really cool. But being cool doesn't make for a production-ready system. Let's talk about a day in the life of a server-side Elm programmer.

  • Write some business logic in Elm
  • Realise that you need some library support that doesn't exist in Elm
  • Spend the rest of the day fighting Node

As an Elm programmer, I like to write Elm! As a server-side Elm programmer, I hate writing yet another integration library that wraps around a Node library that uses mutable objects and callbacks in a weird way. There are a lot of battles that you have to face everyday writing libraries that work with Node. Sometimes there just isn't a way to make Node libraries play nicely with Elm. This does not make for a stable runtime, nor a stable platform.

The tl;dr here is that Node is not the ideal platform for server-side Elm. An alternate platform to base itself on would be great, but is unlikely to happen "soon". Please take away some of the ideas here and think about them! But if you value your sanity, your stability and your users, don't use this proof of concept for anything more than interest!

Credit

Fresheyeball provided the PoC HTTP server implementation that we rewrote parts of here and then applied to production!

rtfeldman provided CSS support through elm-css

Awesome!

If you think this is awesome, why not apply to come join us make things?


[NoRedInk][team] [team]: http://noredink.com/about/team

take-home's People

Contributors

bigblue avatar chrisbuttery avatar eeue56 avatar vilterp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

take-home's Issues

Add a route for viewing a submission on a browser

Motivation: as someone on the reviewer side, I want to check out submissions even those I'm not assigned as the reviewer: to check out a particularly good solution, or a solution using a particular framework. However, downloading from S3 and opening the file involves too many clicks and keystrokes.

It'd be nice if the take-home server can serve up submissions.

For zip submissions: zip.js https://gildas-lormeau.github.io/zip.js/

Notify @dui when creating a new take home

It's important that I be notified / subscribed when a new take home is created.

Not sure how we're doing it on the open source version of the tool but on our implementation we need a way to define default subscribers to the issue 👍

Unclear and possibly misleading advice on Tasks

Reading through “Native best practices”, I was confused by the following sections:

Use always to ensure that your Tasks are wrapped appropriately.

See https://github.com/elm-lang/core/issues/453#issuecomment-161050745

Denote impure functions with Task

There's no real way outside of Tasks to signify when a function is impure in Elm. Using units () to signify when a function should run and do something with a side effect allows people to easily identify side effects.

activeElement : () -> Task x QueryNode
activeElement =
    Native.Query.activeElement

@rtfeldman points out that one may discover an incorrectly constructed Task by observing its behaviour in two scenarios:

  1. When given as a parameter to always;
  2. When suspended in an anonymous function that ignores its parameter.

(The latter idiom is known as delay in Scheme, SML and Idris, as lazy in OCaml, and as defer in PureScript.)

I think this guide would benefit from an example of constructing a Task correctly, such as the one given in the linked discussion.

@jvoigtlaender gives the JavaScript part: (https://github.com/elm-lang/core/issues/453#issuecomment-161041092)

const readFileAndLog = function (path) {
  return Task.asyncFunction(function (callback) {
    fs.readFile(path, function(err, data) {
      if (err) {
        throw err;
      } else {
        console.log("data: ", data);
      }
    });
    return callback(Task.succeed(Utils.Tuple0));
  });
};

@Fresheyeball gives the Elm part: (https://github.com/Fresheyeball/isolating-task-bug/blob/asyncFunction-solution/OK.elm)

readFileAndLog : String -> Task x ()
readFileAndLog = Native.FS.readFileAndLog

The advice to “use [() as an additional parameter] to signify when a function should run and do something with a side effect” seems misleading, if we assume that a Task already represents an effectful computation.

Thoughts?

Move to the latest version of elm-css

Right now I'm using a dump of elm-css from master from before things were rewritten. We want to be on the latest version of elm-css, which should be a simple upgrade. It'll look something like this:

  • Update the elm-css folder to have the latest dump of non-test stuff from here
  • Ensure it compiles and fix any compile errors

In theory, it should be a trivial upgrade.

Anonymize with hashing instead of initials

I mentioned this to @dui some time ago: suppose I know my friend Sam Quayle is applying, and I get assigned a take home for "SQ". Suddenly I have to worry about bias.

Would be nicer if I got assigned a take-home for "ac9bfg2" or something similar. 😉

publishing parts of this separately to elm package repo

Hi guys,
This repo contains a lot of goodies; the http server, NeDB bindings and more.
Any plans into publishing parts of this separately so one can just do elm package install NoRedInk/elm-http-server?

PS: amazing work, thank you!

Give a error message if no file chosen

Right now, if a user doesn't submit a file, then it will still count as submitted and upload nothing.

Instead, we want to warn and not let people submit when there's no file selected.

The core logic on the server side is here - https://github.com/NoRedInk/take-home/blob/master/instance/server/Generators.elm#L86

But it should be checked client side if possible, here - https://github.com/NoRedInk/take-home/blob/master/instance/server/Client/StartTakeHome/Views.elm#L76

Note that right now, that view is a statically rendered view

Get rid of Amazon

It would be awesome if you can get rid of Amazon here so everyone can just run this to see how things works.

I know that you do not develop it for people as an example but it would be awesome if you'll find time to do this.

failed with 'FailedConnectionException "

failed with 'FailedConnectionException "github.com" 443' when sending request to
http://github.com/evancz/virtual-dom/zipball/2.1.0/
/home/az/justforfun/ELM/take-home/instance/server/main.js:1
(function (exports, require, module, __filename, __dirname) { Elm.worker(Elm.Main);
^

ReferenceError: Elm is not defined
at Object. (/home/az/justforfun/ELM/take-home/instance/server/main.js:1:63)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:139:18)
at node.js:999:3

Improve styling

A general issue. At the moment, there is little to no styling on any of the pages.

At the moment there are no suggested styles - other than the colours should probably match NRI colours

Motivation

We need to find out use cases of elm-css and how it feels to work with! This project could potentially be the largest use case of elm-css.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.